From f1d956dec36db180eba1333303361fe577229fbd Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Wed, 6 Nov 2024 19:06:38 +0000 Subject: [PATCH 01/87] feat(api): api update (#64) --- .../api/client/BraintrustClientAsyncImpl.kt | 5 - .../api/client/BraintrustClientImpl.kt | 5 - .../api/core/HttpRequestBodies.kt | 111 ++ .../com/braintrustdata/api/core/Properties.kt | 13 +- .../com/braintrustdata/api/core/Values.kt | 5 +- .../api/core/handlers/ErrorHandler.kt | 125 ++ .../api/core/handlers/JsonHandler.kt | 21 + .../api/core/handlers/StringHandler.kt | 13 + .../api/core/http/HttpRequest.kt | 2 +- .../api/errors/BraintrustError.kt | 4 +- .../com/braintrustdata/api/models/Acl.kt | 70 +- .../api/models/AclBatchUpdateParams.kt | 191 +-- .../api/models/AclBatchUpdateResponse.kt | 48 +- .../api/models/AclCreateParams.kt | 89 +- .../api/models/AclDeleteParams.kt | 13 +- .../api/models/AclFindAndDeleteParams.kt | 89 +- .../braintrustdata/api/models/AclListPage.kt | 17 +- .../api/models/AclListPageAsync.kt | 17 +- .../api/models/AclListParams.kt | 30 +- .../api/models/AclRetrieveParams.kt | 11 +- .../com/braintrustdata/api/models/AiSecret.kt | 96 +- .../api/models/AiSecretCreateParams.kt | 113 +- .../api/models/AiSecretDeleteParams.kt | 13 +- .../api/models/AiSecretFindAndDeleteParams.kt | 63 +- .../api/models/AiSecretListPage.kt | 17 +- .../api/models/AiSecretListPageAsync.kt | 17 +- .../api/models/AiSecretListParams.kt | 39 +- .../api/models/AiSecretReplaceParams.kt | 113 +- .../api/models/AiSecretRetrieveParams.kt | 11 +- .../api/models/AiSecretUpdateParams.kt | 111 +- .../com/braintrustdata/api/models/ApiKey.kt | 56 +- .../api/models/ApiKeyCreateParams.kt | 63 +- .../api/models/ApiKeyDeleteParams.kt | 13 +- .../api/models/ApiKeyListPage.kt | 17 +- .../api/models/ApiKeyListPageAsync.kt | 17 +- .../api/models/ApiKeyListParams.kt | 28 +- .../api/models/ApiKeyRetrieveParams.kt | 11 +- .../models/ChatCompletionContentPartImage.kt | 100 +- .../models/ChatCompletionContentPartText.kt | 50 +- .../models/ChatCompletionMessageToolCall.kt | 100 +- .../braintrustdata/api/models/CodeBundle.kt | 218 ++- .../api/models/CreateApiKeyOutput.kt | 58 +- .../api/models/CrossObjectInsertResponse.kt | 164 +- .../braintrustdata/api/models/DataSummary.kt | 42 +- .../com/braintrustdata/api/models/Dataset.kt | 98 +- .../api/models/DatasetCreateParams.kt | 67 +- .../api/models/DatasetDeleteParams.kt | 13 +- .../braintrustdata/api/models/DatasetEvent.kt | 104 +- .../api/models/DatasetFeedbackParams.kt | 57 +- .../api/models/DatasetFetchParams.kt | 19 +- .../api/models/DatasetFetchPostParams.kt | 81 +- .../api/models/DatasetInsertParams.kt | 64 +- .../api/models/DatasetListPage.kt | 17 +- .../api/models/DatasetListPageAsync.kt | 17 +- .../api/models/DatasetListParams.kt | 32 +- .../api/models/DatasetRetrieveParams.kt | 11 +- .../api/models/DatasetSummarizeParams.kt | 13 +- .../api/models/DatasetUpdateParams.kt | 107 +- .../com/braintrustdata/api/models/EnvVar.kt | 58 +- .../api/models/EnvVarCreateParams.kt | 73 +- .../api/models/EnvVarDeleteParams.kt | 13 +- .../api/models/EnvVarListParams.kt | 28 +- .../api/models/EnvVarListResponse.kt | 42 +- .../api/models/EnvVarReplaceParams.kt | 73 +- .../api/models/EnvVarRetrieveParams.kt | 11 +- .../api/models/EnvVarUpdateParams.kt | 65 +- .../api/models/EvalCreateParams.kt | 934 +++++------ .../braintrustdata/api/models/Experiment.kt | 110 +- .../api/models/ExperimentCreateParams.kt | 133 +- .../api/models/ExperimentDeleteParams.kt | 13 +- .../api/models/ExperimentEvent.kt | 312 ++-- .../api/models/ExperimentFeedbackParams.kt | 57 +- .../api/models/ExperimentFetchParams.kt | 19 +- .../api/models/ExperimentFetchPostParams.kt | 81 +- .../api/models/ExperimentInsertParams.kt | 64 +- .../api/models/ExperimentListPage.kt | 17 +- .../api/models/ExperimentListPageAsync.kt | 17 +- .../api/models/ExperimentListParams.kt | 32 +- .../api/models/ExperimentRetrieveParams.kt | 11 +- .../api/models/ExperimentSummarizeParams.kt | 15 +- .../api/models/ExperimentUpdateParams.kt | 127 +- .../api/models/FeedbackDatasetItem.kt | 92 +- .../api/models/FeedbackExperimentItem.kt | 134 +- .../api/models/FeedbackProjectLogsItem.kt | 134 +- .../api/models/FeedbackResponseSchema.kt | 44 +- .../api/models/FetchDatasetEventsResponse.kt | 48 +- .../models/FetchExperimentEventsResponse.kt | 48 +- .../models/FetchProjectLogsEventsResponse.kt | 48 +- .../com/braintrustdata/api/models/Function.kt | 539 +++---- .../api/models/FunctionCreateParams.kt | 518 +++---- .../api/models/FunctionDeleteParams.kt | 13 +- .../api/models/FunctionInvokeParams.kt | 685 ++++---- .../api/models/FunctionInvokeResponse.kt | 39 +- .../api/models/FunctionListPage.kt | 17 +- .../api/models/FunctionListPageAsync.kt | 17 +- .../api/models/FunctionListParams.kt | 36 +- .../api/models/FunctionReplaceParams.kt | 518 +++---- .../api/models/FunctionRetrieveParams.kt | 11 +- .../api/models/FunctionToolChoice.kt | 42 +- .../api/models/FunctionUpdateParams.kt | 439 +++--- .../com/braintrustdata/api/models/Group.kt | 62 +- .../api/models/GroupCreateParams.kt | 75 +- .../api/models/GroupDeleteParams.kt | 13 +- .../api/models/GroupListPage.kt | 17 +- .../api/models/GroupListPageAsync.kt | 17 +- .../api/models/GroupListParams.kt | 28 +- .../api/models/GroupReplaceParams.kt | 75 +- .../api/models/GroupRetrieveParams.kt | 11 +- .../api/models/GroupUpdateParams.kt | 81 +- .../api/models/InsertDatasetEventMerge.kt | 100 +- .../api/models/InsertDatasetEventReplace.kt | 100 +- .../api/models/InsertEventsResponse.kt | 42 +- .../api/models/InsertExperimentEventMerge.kt | 306 ++-- .../models/InsertExperimentEventReplace.kt | 306 ++-- .../api/models/InsertProjectLogsEventMerge.kt | 304 ++-- .../models/InsertProjectLogsEventReplace.kt | 304 ++-- .../api/models/MetricSummary.kt | 56 +- .../api/models/OnlineScoreConfig.kt | 157 +- .../braintrustdata/api/models/Organization.kt | 58 +- .../api/models/OrganizationDeleteParams.kt | 13 +- .../api/models/OrganizationListPage.kt | 17 +- .../api/models/OrganizationListPageAsync.kt | 17 +- .../api/models/OrganizationListParams.kt | 26 +- .../models/OrganizationMemberUpdateParams.kt | 177 +-- .../api/models/OrganizationRetrieveParams.kt | 11 +- .../api/models/OrganizationUpdateParams.kt | 77 +- .../models/PatchOrganizationMembersOutput.kt | 50 +- .../api/models/PathLookupFilter.kt | 52 +- .../com/braintrustdata/api/models/Project.kt | 58 +- .../api/models/ProjectCreateParams.kt | 63 +- .../api/models/ProjectDeleteParams.kt | 13 +- .../api/models/ProjectListPage.kt | 17 +- .../api/models/ProjectListPageAsync.kt | 17 +- .../api/models/ProjectListParams.kt | 28 +- .../api/models/ProjectLogFeedbackParams.kt | 57 +- .../api/models/ProjectLogFetchParams.kt | 19 +- .../api/models/ProjectLogFetchPostParams.kt | 81 +- .../api/models/ProjectLogInsertParams.kt | 64 +- .../api/models/ProjectLogsEvent.kt | 314 ++-- .../api/models/ProjectRetrieveParams.kt | 11 +- .../braintrustdata/api/models/ProjectScore.kt | 208 +-- .../api/models/ProjectScoreCategory.kt | 48 +- .../api/models/ProjectScoreConfig.kt | 52 +- .../api/models/ProjectScoreCreateParams.kt | 231 ++- .../api/models/ProjectScoreDeleteParams.kt | 13 +- .../api/models/ProjectScoreListPage.kt | 17 +- .../api/models/ProjectScoreListPageAsync.kt | 17 +- .../api/models/ProjectScoreListParams.kt | 43 +- .../api/models/ProjectScoreReplaceParams.kt | 231 ++- .../api/models/ProjectScoreRetrieveParams.kt | 11 +- .../api/models/ProjectScoreType.kt | 2 +- .../api/models/ProjectScoreUpdateParams.kt | 229 ++- .../api/models/ProjectSettings.kt | 42 +- .../braintrustdata/api/models/ProjectTag.kt | 58 +- .../api/models/ProjectTagCreateParams.kt | 71 +- .../api/models/ProjectTagDeleteParams.kt | 13 +- .../api/models/ProjectTagListPage.kt | 17 +- .../api/models/ProjectTagListPageAsync.kt | 17 +- .../api/models/ProjectTagListParams.kt | 32 +- .../api/models/ProjectTagReplaceParams.kt | 71 +- .../api/models/ProjectTagRetrieveParams.kt | 11 +- .../api/models/ProjectTagUpdateParams.kt | 69 +- .../api/models/ProjectUpdateParams.kt | 65 +- .../com/braintrustdata/api/models/Prompt.kt | 112 +- .../api/models/PromptCreateParams.kt | 85 +- .../braintrustdata/api/models/PromptData.kt | 1375 +++++++---------- .../api/models/PromptDeleteParams.kt | 13 +- .../api/models/PromptListPage.kt | 17 +- .../api/models/PromptListPageAsync.kt | 17 +- .../api/models/PromptListParams.kt | 36 +- .../api/models/PromptReplaceParams.kt | 85 +- .../api/models/PromptRetrieveParams.kt | 11 +- .../api/models/PromptUpdateParams.kt | 77 +- .../com/braintrustdata/api/models/RepoInfo.kt | 62 +- .../com/braintrustdata/api/models/Role.kt | 114 +- .../api/models/RoleCreateParams.kt | 127 +- .../api/models/RoleDeleteParams.kt | 13 +- .../braintrustdata/api/models/RoleListPage.kt | 17 +- .../api/models/RoleListPageAsync.kt | 17 +- .../api/models/RoleListParams.kt | 28 +- .../api/models/RoleReplaceParams.kt | 127 +- .../api/models/RoleRetrieveParams.kt | 11 +- .../api/models/RoleUpdateParams.kt | 185 +-- .../braintrustdata/api/models/ScoreSummary.kt | 54 +- .../com/braintrustdata/api/models/Scorer.kt | 50 +- .../api/models/SummarizeDatasetResponse.kt | 54 +- .../api/models/SummarizeExperimentResponse.kt | 134 +- .../com/braintrustdata/api/models/Task.kt | 42 +- .../braintrustdata/api/models/ToolChoice.kt | 66 +- .../api/models/TopLevelHelloWorldParams.kt | 6 +- .../com/braintrustdata/api/models/User.kt | 56 +- .../braintrustdata/api/models/UserListPage.kt | 17 +- .../api/models/UserListPageAsync.kt | 17 +- .../api/models/UserListParams.kt | 57 +- .../api/models/UserRetrieveParams.kt | 11 +- .../com/braintrustdata/api/models/View.kt | 68 +- .../api/models/ViewCreateParams.kt | 91 +- .../com/braintrustdata/api/models/ViewData.kt | 40 +- .../api/models/ViewDataSearch.kt | 52 +- .../api/models/ViewDeleteParams.kt | 67 +- .../braintrustdata/api/models/ViewListPage.kt | 17 +- .../api/models/ViewListPageAsync.kt | 17 +- .../api/models/ViewListParams.kt | 36 +- .../braintrustdata/api/models/ViewOptions.kt | 127 +- .../api/models/ViewReplaceParams.kt | 91 +- .../api/models/ViewRetrieveParams.kt | 17 +- .../api/models/ViewUpdateParams.kt | 89 +- .../api/services/async/AclServiceAsyncImpl.kt | 8 +- .../async/AiSecretServiceAsyncImpl.kt | 8 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 8 +- .../services/async/DatasetServiceAsyncImpl.kt | 8 +- .../services/async/EnvVarServiceAsyncImpl.kt | 8 +- .../services/async/EvalServiceAsyncImpl.kt | 8 +- .../async/ExperimentServiceAsyncImpl.kt | 8 +- .../async/FunctionServiceAsyncImpl.kt | 8 +- .../services/async/GroupServiceAsyncImpl.kt | 8 +- .../async/OrganizationServiceAsyncImpl.kt | 8 +- .../async/ProjectScoreServiceAsyncImpl.kt | 8 +- .../services/async/ProjectServiceAsyncImpl.kt | 8 +- .../async/ProjectTagServiceAsyncImpl.kt | 8 +- .../services/async/PromptServiceAsyncImpl.kt | 8 +- .../services/async/RoleServiceAsyncImpl.kt | 8 +- .../async/TopLevelServiceAsyncImpl.kt | 6 +- .../services/async/UserServiceAsyncImpl.kt | 6 +- .../services/async/ViewServiceAsyncImpl.kt | 8 +- .../organizations/MemberServiceAsyncImpl.kt | 8 +- .../async/projects/LogServiceAsyncImpl.kt | 8 +- .../api/services/blocking/AclServiceImpl.kt | 8 +- .../services/blocking/AiSecretServiceImpl.kt | 8 +- .../services/blocking/ApiKeyServiceImpl.kt | 8 +- .../services/blocking/DatasetServiceImpl.kt | 8 +- .../services/blocking/EnvVarServiceImpl.kt | 8 +- .../api/services/blocking/EvalServiceImpl.kt | 8 +- .../blocking/ExperimentServiceImpl.kt | 8 +- .../services/blocking/FunctionServiceImpl.kt | 8 +- .../api/services/blocking/GroupServiceImpl.kt | 8 +- .../blocking/OrganizationServiceImpl.kt | 8 +- .../blocking/ProjectScoreServiceImpl.kt | 8 +- .../services/blocking/ProjectServiceImpl.kt | 8 +- .../blocking/ProjectTagServiceImpl.kt | 8 +- .../services/blocking/PromptServiceImpl.kt | 8 +- .../api/services/blocking/RoleServiceImpl.kt | 8 +- .../services/blocking/TopLevelServiceImpl.kt | 6 +- .../api/services/blocking/UserServiceImpl.kt | 6 +- .../api/services/blocking/ViewServiceImpl.kt | 8 +- .../organizations/MemberServiceImpl.kt | 8 +- .../blocking/projects/LogServiceImpl.kt | 8 +- .../models/ProjectScoreCreateParamsTest.kt | 14 +- .../models/ProjectScoreReplaceParamsTest.kt | 14 +- .../api/models/ProjectScoreTest.kt | 4 +- .../models/ProjectScoreUpdateParamsTest.kt | 14 +- .../blocking/ProjectScoreServiceTest.kt | 18 +- .../main/kotlin/braintrust.java.gradle.kts | 1 + .../main/kotlin/braintrust.kotlin.gradle.kts | 1 + 254 files changed, 6731 insertions(+), 11150 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/StringHandler.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index ee5f3110..d5a7c733 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -3,19 +3,14 @@ package com.braintrustdata.api.client import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.* import com.braintrustdata.api.services.async.* -import com.braintrustdata.api.services.errorHandler class BraintrustClientAsyncImpl constructor( private val clientOptions: ClientOptions, ) : BraintrustClientAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val sync: BraintrustClient by lazy { BraintrustClientImpl(clientOptions) } private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index e23daeb0..e770915e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -3,19 +3,14 @@ package com.braintrustdata.api.client import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.* import com.braintrustdata.api.services.blocking.* -import com.braintrustdata.api.services.errorHandler class BraintrustClientImpl constructor( private val clientOptions: ClientOptions, ) : BraintrustClient { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val async: BraintrustClientAsync by lazy { BraintrustClientAsyncImpl(clientOptions) } private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt new file mode 100644 index 00000000..65052ee1 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt @@ -0,0 +1,111 @@ +@file:JvmName("HttpRequestBodies") + +package com.braintrustdata.api.core + +import com.braintrustdata.api.core.http.HttpRequestBody +import com.braintrustdata.api.errors.BraintrustException +import com.fasterxml.jackson.databind.json.JsonMapper +import java.io.ByteArrayOutputStream +import java.io.OutputStream +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder + +@JvmSynthetic +internal inline fun json( + jsonMapper: JsonMapper, + value: T, +): HttpRequestBody { + return object : HttpRequestBody { + private var cachedBytes: ByteArray? = null + + private fun serialize(): ByteArray { + if (cachedBytes != null) return cachedBytes!! + + val buffer = ByteArrayOutputStream() + try { + jsonMapper.writeValue(buffer, value) + cachedBytes = buffer.toByteArray() + return cachedBytes!! + } catch (e: Exception) { + throw BraintrustException("Error writing request", e) + } + } + + override fun writeTo(outputStream: OutputStream) { + outputStream.write(serialize()) + } + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long { + return serialize().size.toLong() + } + + override fun repeatable(): Boolean = true + + override fun close() {} + } +} + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + parts: Array?> +): HttpRequestBody { + val builder = MultipartEntityBuilder.create() + parts.forEach { part -> + if (part?.value != null) { + when (part.value) { + is JsonValue -> { + val buffer = ByteArrayOutputStream() + try { + jsonMapper.writeValue(buffer, part.value) + } catch (e: Exception) { + throw BraintrustException("Error serializing value to json", e) + } + builder.addBinaryBody( + part.name, + buffer.toByteArray(), + part.contentType, + part.filename + ) + } + is Boolean -> + builder.addTextBody( + part.name, + if (part.value) "true" else "false", + part.contentType + ) + is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) + is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) + is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) + is ByteArray -> + builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) + is String -> builder.addTextBody(part.name, part.value, part.contentType) + is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) + else -> + throw IllegalArgumentException( + "Unsupported content type: ${part.value::class.java.simpleName}" + ) + } + } + } + val entity = builder.build() + + return object : HttpRequestBody { + override fun writeTo(outputStream: OutputStream) { + try { + return entity.writeTo(outputStream) + } catch (e: Exception) { + throw BraintrustException("Error writing request", e) + } + } + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = -1 + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt index 1c59eee1..a0924603 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt @@ -34,14 +34,9 @@ fun getOsName(): String { } } -fun getOsVersion(): String { - return System.getProperty("os.version", "unknown") -} +fun getOsVersion(): String = System.getProperty("os.version", "unknown") -fun getPackageVersion(): String { - return Properties::class.java.`package`.implementationVersion ?: "unknown" -} +fun getPackageVersion(): String = + Properties::class.java.`package`.implementationVersion ?: "unknown" -fun getJavaVersion(): String { - return System.getProperty("java.version", "unknown") -} +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 9ede4db6..45e19b1c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -479,9 +479,8 @@ internal constructor( } } - override fun toString(): String { - return "MultipartFormValue(name='$name', contentType=$contentType, filename=$filename, value=${valueToString()})" - } + override fun toString(): String = + "MultipartFormValue{name=$name, contentType=$contentType, filename=$filename, value=${valueToString()}}" private fun valueToString(): String = when (value) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt new file mode 100644 index 00000000..62010fbb --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt @@ -0,0 +1,125 @@ +@file:JvmName("ErrorHandler") + +package com.braintrustdata.api.core.handlers + +import com.braintrustdata.api.core.http.HttpResponse +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BadRequestException +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.errors.InternalServerException +import com.braintrustdata.api.errors.NotFoundException +import com.braintrustdata.api.errors.PermissionDeniedException +import com.braintrustdata.api.errors.RateLimitException +import com.braintrustdata.api.errors.UnauthorizedException +import com.braintrustdata.api.errors.UnexpectedStatusCodeException +import com.braintrustdata.api.errors.UnprocessableEntityException +import com.fasterxml.jackson.databind.json.JsonMapper +import com.google.common.collect.ListMultimap +import java.io.ByteArrayInputStream +import java.io.InputStream + +@JvmSynthetic +internal fun errorHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) + + return object : Handler { + override fun handle(response: HttpResponse): BraintrustError = + try { + handler.handle(response) + } catch (e: Exception) { + BraintrustError.builder().build() + } + } +} + +@JvmSynthetic +internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = + object : Handler { + override fun handle(response: HttpResponse): T { + when (val statusCode = response.statusCode()) { + in 200..299 -> { + return this@withErrorHandler.handle(response) + } + 400 -> { + val buffered = response.buffered() + throw BadRequestException( + buffered.headers(), + stringHandler().handle(buffered), + errorHandler.handle(buffered), + ) + } + 401 -> { + val buffered = response.buffered() + throw UnauthorizedException( + buffered.headers(), + stringHandler().handle(buffered), + errorHandler.handle(buffered), + ) + } + 403 -> { + val buffered = response.buffered() + throw PermissionDeniedException( + buffered.headers(), + stringHandler().handle(buffered), + errorHandler.handle(buffered), + ) + } + 404 -> { + val buffered = response.buffered() + throw NotFoundException( + buffered.headers(), + stringHandler().handle(buffered), + errorHandler.handle(buffered), + ) + } + 422 -> { + val buffered = response.buffered() + throw UnprocessableEntityException( + buffered.headers(), + stringHandler().handle(buffered), + errorHandler.handle(buffered), + ) + } + 429 -> { + val buffered = response.buffered() + throw RateLimitException( + buffered.headers(), + stringHandler().handle(buffered), + errorHandler.handle(buffered), + ) + } + in 500..599 -> { + val buffered = response.buffered() + throw InternalServerException( + statusCode, + buffered.headers(), + stringHandler().handle(buffered), + errorHandler.handle(buffered), + ) + } + else -> { + val buffered = response.buffered() + throw UnexpectedStatusCodeException( + statusCode, + buffered.headers(), + stringHandler().handle(buffered), + errorHandler.handle(buffered), + ) + } + } + } + } + +private fun HttpResponse.buffered(): HttpResponse { + val body = body().readBytes() + + return object : HttpResponse { + override fun statusCode(): Int = this@buffered.statusCode() + + override fun headers(): ListMultimap = this@buffered.headers() + + override fun body(): InputStream = ByteArrayInputStream(body) + + override fun close() = this@buffered.close() + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt new file mode 100644 index 00000000..6db3e392 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt @@ -0,0 +1,21 @@ +@file:JvmName("JsonHandler") + +package com.braintrustdata.api.core.handlers + +import com.braintrustdata.api.core.http.HttpResponse +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.errors.BraintrustException +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef + +@JvmSynthetic +internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = + object : Handler { + override fun handle(response: HttpResponse): T { + try { + return jsonMapper.readValue(response.body(), jacksonTypeRef()) + } catch (e: Exception) { + throw BraintrustException("Error reading response", e) + } + } + } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/StringHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/StringHandler.kt new file mode 100644 index 00000000..bb04609d --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/StringHandler.kt @@ -0,0 +1,13 @@ +@file:JvmName("StringHandler") + +package com.braintrustdata.api.core.handlers + +import com.braintrustdata.api.core.http.HttpResponse +import com.braintrustdata.api.core.http.HttpResponse.Handler + +@JvmSynthetic internal fun stringHandler(): Handler = StringHandlerInternal + +private object StringHandlerInternal : Handler { + override fun handle(response: HttpResponse): String = + response.body().readBytes().toString(Charsets.UTF_8) +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index f4ba383e..4662ece7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -17,7 +17,7 @@ private constructor( ) { override fun toString(): String = - "HttpRequest {method=$method, pathSegments=$pathSegments, queryParams=$queryParams, headers=$headers, body=$body}" + "HttpRequest{method=$method, pathSegments=$pathSegments, queryParams=$queryParams, headers=$headers, body=$body}" companion object { @JvmStatic fun builder() = Builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index e845c581..aa821e80 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -26,11 +26,11 @@ constructor( return true } - return other is BraintrustError && this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is BraintrustError && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(additionalProperties) + return /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ } override fun toString() = "BraintrustError{additionalProperties=$additionalProperties}" 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 4af6e306..25b577be 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 @@ -48,8 +48,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the acl */ fun id(): String = id.getRequired("id") @@ -152,48 +150,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Acl && - this.id == other.id && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.userId == other.userId && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this._objectOrgId == other._objectOrgId && - this.created == other.created && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - _objectOrgId, - created, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Acl{id=$id, objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, _objectOrgId=$_objectOrgId, created=$created, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -378,7 +334,7 @@ private constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -489,7 +445,7 @@ private constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -582,7 +538,7 @@ private constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -679,4 +635,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Acl && this.id == other.id && this.objectType == other.objectType && this.objectId == other.objectId && this.userId == other.userId && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this._objectOrgId == other._objectOrgId && this.created == other.created && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, _objectOrgId, created, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Acl{id=$id, objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, _objectOrgId=$_objectOrgId, created=$created, additionalProperties=$additionalProperties}" } 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 0ce57d6e..f41f20ec 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 @@ -53,8 +53,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** * An ACL grants a certain permission or role to a certain user or group on an object. * @@ -85,32 +83,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclBatchUpdateBody && - this.addAcls == other.addAcls && - this.removeAcls == other.removeAcls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - addAcls, - removeAcls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AclBatchUpdateBody{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -178,6 +150,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclBatchUpdateBody && this.addAcls == other.addAcls && this.removeAcls == other.removeAcls && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AclBatchUpdateBody{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -191,22 +183,11 @@ constructor( return true } - return other is AclBatchUpdateParams && - this.addAcls == other.addAcls && - this.removeAcls == other.removeAcls && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AclBatchUpdateParams && this.addAcls == other.addAcls && this.removeAcls == other.removeAcls && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - addAcls, - removeAcls, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -379,8 +360,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The object type that the ACL applies to */ @JsonProperty("object_type") fun objectType(): ObjectType? = objectType @@ -421,42 +400,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddAcl && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.userId == other.userId && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AddAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -567,7 +510,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -678,7 +621,7 @@ constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -771,7 +714,7 @@ constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -869,6 +812,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddAcl && this.objectType == other.objectType && this.objectId == other.objectId && this.userId == other.userId && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AddAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" } /** @@ -895,8 +858,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The object type that the ACL applies to */ @JsonProperty("object_type") fun objectType(): ObjectType? = objectType @@ -937,42 +898,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveAcl && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.userId == other.userId && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RemoveAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1083,7 +1008,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1194,7 +1119,7 @@ constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1287,7 +1212,7 @@ constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1385,5 +1310,25 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RemoveAcl && this.objectType == other.objectType && this.objectId == other.objectId && this.userId == other.userId && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RemoveAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index 4d9d89b7..48ad5d75 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -25,8 +25,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * An ACL grants a certain permission or role to a certain user or group on an object. * @@ -89,32 +87,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclBatchUpdateResponse && - this.addedAcls == other.addedAcls && - this.removedAcls == other.removedAcls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - addedAcls, - removedAcls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -208,4 +180,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclBatchUpdateResponse && this.addedAcls == other.addedAcls && this.removedAcls == other.removedAcls && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(addedAcls, removedAcls, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" } 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 df9d7d5e..82944d42 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 @@ -88,8 +88,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The id of the object the ACL applies to */ @JsonProperty("object_id") fun objectId(): String? = objectId @@ -130,42 +128,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclCreateBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -262,6 +224,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclCreateBody && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -275,32 +257,11 @@ constructor( return true } - return other is AclCreateParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AclCreateParams && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -458,7 +419,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -569,7 +530,7 @@ constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -662,7 +623,7 @@ constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 6ffaefdf..93e7f1e1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is AclDeleteParams && - this.aclId == other.aclId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AclDeleteParams && this.aclId == other.aclId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aclId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(aclId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = 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 c9af483d..7d334fa5 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 @@ -88,8 +88,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The id of the object the ACL applies to */ @JsonProperty("object_id") fun objectId(): String? = objectId @@ -130,42 +128,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclFindAndDeleteBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AclFindAndDeleteBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -262,6 +224,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclFindAndDeleteBody && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AclFindAndDeleteBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -275,32 +257,11 @@ constructor( return true } - return other is AclFindAndDeleteParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AclFindAndDeleteParams && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -458,7 +419,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -569,7 +530,7 @@ constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -662,7 +623,7 @@ constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index b3c80969..86271fa0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is AclListPage && - this.aclsService == other.aclsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is AclListPage && this.aclsService == other.aclsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aclsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ } override fun toString() = @@ -121,13 +114,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index ec02e5b8..05369260 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is AclListPageAsync && - this.aclsService == other.aclsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is AclListPageAsync && this.aclsService == other.aclsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aclsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ } override fun toString() = @@ -124,13 +117,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = 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 20be8167..70a432dd 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 @@ -71,28 +71,11 @@ constructor( return true } - return other is AclListParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is AclListParams && this.objectId == other.objectId && this.objectType == other.objectType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - endingBefore, - ids, - limit, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -160,7 +143,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -240,7 +223,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -385,11 +368,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -423,6 +406,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 52819618..11b1ce01 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is AclRetrieveParams && - this.aclId == other.aclId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is AclRetrieveParams && this.aclId == other.aclId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aclId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(aclId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt index e7d4df58..8543661d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt @@ -32,8 +32,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the AI secret */ fun id(): String = id.getRequired("id") @@ -90,42 +88,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AISecret && - this.id == other.id && - this.created == other.created && - this.orgId == other.orgId && - this.name == other.name && - this.type == other.type && - this.metadata == other.metadata && - this.previewSecret == other.previewSecret && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - created, - orgId, - name, - type, - metadata, - previewSecret, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AISecret{id=$id, created=$created, orgId=$orgId, name=$name, type=$type, metadata=$metadata, previewSecret=$previewSecret, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -240,8 +202,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -254,23 +214,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -301,5 +244,44 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AISecret && this.id == other.id && this.created == other.created && this.orgId == other.orgId && this.name == other.name && this.type == other.type && this.metadata == other.metadata && this.previewSecret == other.previewSecret && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, created, orgId, name, type, metadata, previewSecret, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AISecret{id=$id, created=$created, orgId=$orgId, name=$name, type=$type, metadata=$metadata, previewSecret=$previewSecret, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 779156e8..c8ac3207 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -64,8 +64,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the AI secret */ @JsonProperty("name") fun name(): String? = name @@ -92,38 +90,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiSecretCreateBody && - this.name == other.name && - this.metadata == other.metadata && - this.orgName == other.orgName && - this.secret == other.secret && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - metadata, - orgName, - secret, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AiSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -194,6 +160,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretCreateBody && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AiSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -207,28 +193,11 @@ constructor( return true } - return other is AiSecretCreateParams && - this.name == other.name && - this.metadata == other.metadata && - this.orgName == other.orgName && - this.secret == other.secret && - this.type == other.type && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AiSecretCreateParams && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - metadata, - orgName, - secret, - type, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -359,31 +328,12 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -414,5 +364,24 @@ constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index 6ddecb7f..5403ba52 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is AiSecretDeleteParams && - this.aiSecretId == other.aiSecretId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AiSecretDeleteParams && this.aiSecretId == other.aiSecretId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aiSecretId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(aiSecretId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 837d68ed..064eb2fa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -49,8 +49,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the AI secret */ @JsonProperty("name") fun name(): String? = name @@ -67,32 +65,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiSecretFindAndDeleteBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AiSecretFindAndDeleteBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -143,6 +115,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretFindAndDeleteBody && this.name == other.name && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, orgName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AiSecretFindAndDeleteBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -156,22 +148,11 @@ constructor( return true } - return other is AiSecretFindAndDeleteParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AiSecretFindAndDeleteParams && this.name == other.name && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index 2adbb611..a0e9abfc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is AiSecretListPage && - this.aiSecretsService == other.aiSecretsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is AiSecretListPage && this.aiSecretsService == other.aiSecretsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aiSecretsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ } override fun toString() = @@ -127,13 +120,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index af3a1365..7b2b31aa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is AiSecretListPageAsync && - this.aiSecretsService == other.aiSecretsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is AiSecretListPageAsync && this.aiSecretsService == other.aiSecretsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aiSecretsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ } override fun toString() = @@ -134,13 +127,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index d9170848..4be9c8dc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -72,30 +72,11 @@ constructor( return true } - return other is AiSecretListParams && - this.aiSecretName == other.aiSecretName && - this.aiSecretType == other.aiSecretType && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is AiSecretListParams && this.aiSecretName == other.aiSecretName && this.aiSecretType == other.aiSecretType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aiSecretName, - aiSecretType, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -143,7 +124,7 @@ constructor( this.aiSecretType = AiSecretType.ofString(string) } - fun aiSecretType(strings: List) = apply { + fun aiSecretTypeOfStrings(strings: List) = apply { this.aiSecretType = AiSecretType.ofStrings(strings) } @@ -172,7 +153,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -290,13 +271,11 @@ constructor( return true } - return other is AiSecretType && - this.string == other.string && - this.strings == other.strings + return /* spotless:off */ other is AiSecretType && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -330,6 +309,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): AiSecretType { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return AiSecretType(string = it, _json = json) } @@ -405,11 +385,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -443,6 +423,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index ab2ecf44..130b0aef 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -64,8 +64,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the AI secret */ @JsonProperty("name") fun name(): String? = name @@ -92,38 +90,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiSecretReplaceBody && - this.name == other.name && - this.metadata == other.metadata && - this.orgName == other.orgName && - this.secret == other.secret && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - metadata, - orgName, - secret, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AiSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -194,6 +160,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretReplaceBody && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AiSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -207,28 +193,11 @@ constructor( return true } - return other is AiSecretReplaceParams && - this.name == other.name && - this.metadata == other.metadata && - this.orgName == other.orgName && - this.secret == other.secret && - this.type == other.type && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AiSecretReplaceParams && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - metadata, - orgName, - secret, - type, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -359,31 +328,12 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -414,5 +364,24 @@ constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index b0e59f6d..c4d8d0e2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is AiSecretRetrieveParams && - this.aiSecretId == other.aiSecretId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is AiSecretRetrieveParams && this.aiSecretId == other.aiSecretId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aiSecretId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(aiSecretId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 4973300d..449d0223 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -69,8 +69,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonProperty("metadata") fun metadata(): Metadata? = metadata /** Name of the AI secret */ @@ -86,36 +84,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiSecretUpdateBody && - this.metadata == other.metadata && - this.name == other.name && - this.secret == other.secret && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - metadata, - name, - secret, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AiSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -171,6 +139,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretUpdateBody && this.metadata == other.metadata && this.name == other.name && this.secret == other.secret && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(metadata, name, secret, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AiSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -184,28 +172,11 @@ constructor( return true } - return other is AiSecretUpdateParams && - this.aiSecretId == other.aiSecretId && - this.metadata == other.metadata && - this.name == other.name && - this.secret == other.secret && - this.type == other.type && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is AiSecretUpdateParams && this.aiSecretId == other.aiSecretId && this.metadata == other.metadata && this.name == other.name && this.secret == other.secret && this.type == other.type && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - aiSecretId, - metadata, - name, - secret, - type, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(aiSecretId, metadata, name, secret, type, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -328,31 +299,12 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -383,5 +335,24 @@ constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 14eed088..78072843 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -31,8 +31,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the api key */ fun id(): String = id.getRequired("id") @@ -85,40 +83,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKey && - this.id == other.id && - this.created == other.created && - this.name == other.name && - this.previewName == other.previewName && - this.userId == other.userId && - this.orgId == other.orgId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - created, - name, - previewName, - userId, - orgId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ApiKey{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -214,4 +178,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ApiKey && this.id == other.id && this.created == other.created && this.name == other.name && this.previewName == other.previewName && this.userId == other.userId && this.orgId == other.orgId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, created, name, previewName, userId, orgId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ApiKey{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index e5d0f3b9..79d4d800 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -49,8 +49,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the api key. Does not have to be unique */ @JsonProperty("name") fun name(): String? = name @@ -67,32 +65,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyCreateBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -143,6 +115,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ApiKeyCreateBody && this.name == other.name && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, orgName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -156,22 +148,11 @@ constructor( return true } - return other is ApiKeyCreateParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ApiKeyCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index 8b48e6d1..337d12c8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is ApiKeyDeleteParams && - this.apiKeyId == other.apiKeyId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ApiKeyDeleteParams && this.apiKeyId == other.apiKeyId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - apiKeyId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(apiKeyId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 6369da73..5a79da82 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is ApiKeyListPage && - this.apiKeysService == other.apiKeysService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ApiKeyListPage && this.apiKeysService == other.apiKeysService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - apiKeysService, - params, - response, - ) + return /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ } override fun toString() = @@ -121,13 +114,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index d8742552..b3d2f9a4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is ApiKeyListPageAsync && - this.apiKeysService == other.apiKeysService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ApiKeyListPageAsync && this.apiKeysService == other.apiKeysService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - apiKeysService, - params, - response, - ) + return /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ } override fun toString() = @@ -124,13 +117,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index dbaf4340..bf72099b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -68,28 +68,11 @@ constructor( return true } - return other is ApiKeyListParams && - this.apiKeyName == other.apiKeyName && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ApiKeyListParams && this.apiKeyName == other.apiKeyName && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -154,7 +137,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -271,11 +254,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -309,6 +292,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 836fb6f3..1a577eb5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is ApiKeyRetrieveParams && - this.apiKeyId == other.apiKeyId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ApiKeyRetrieveParams && this.apiKeyId == other.apiKeyId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - apiKeyId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(apiKeyId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index 7bca54f3..cd41c589 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -29,8 +29,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") fun type(): Type = type.getRequired("type") @@ -53,32 +51,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ChatCompletionContentPartImage && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -142,8 +114,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun url(): String = url.getRequired("url") fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) @@ -166,32 +136,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -257,7 +201,7 @@ private constructor( return true } - return other is Detail && this.value == other.value + return /* spotless:off */ other is Detail && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -306,6 +250,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ImageUrl && this.url == other.url && this.detail == other.detail && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(url, detail, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" } class Type @@ -321,7 +285,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -358,4 +322,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPartImage && this.imageUrl == other.imageUrl && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(imageUrl, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index 3df6a2a5..0a46ca17 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -29,8 +29,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun text(): Optional = Optional.ofNullable(text.getNullable("text")) fun type(): Type = type.getRequired("type") @@ -53,32 +51,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ChatCompletionContentPartText && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ChatCompletionContentPartText{text=$text, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -144,7 +116,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -181,4 +153,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPartText && this.text == other.text && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(text, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ChatCompletionContentPartText{text=$text, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 5fa0d38a..dbe33932 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -29,8 +29,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun id(): String = id.getRequired("id") fun function(): Function = function.getRequired("function") @@ -58,34 +56,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ChatCompletionMessageToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -156,8 +126,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") @@ -180,32 +148,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -257,6 +199,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } class Type @@ -272,7 +234,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -309,4 +271,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionMessageToolCall && this.id == other.id && this.function == other.function && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, function, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index d99a8cc3..844b82b2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -40,8 +40,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun location(): Location = location.getRequired("location") @@ -76,36 +74,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CodeBundle && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtimeContext, - location, - bundleId, - preview, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CodeBundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -230,13 +198,11 @@ private constructor( return true } - return other is Location && - this.experiment == other.experiment && - this.function == other.function + return /* spotless:off */ other is Location && this.experiment == other.experiment && this.function == other.function /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(experiment, function) + return /* spotless:off */ Objects.hash(experiment, function) /* spotless:on */ } override fun toString(): String { @@ -270,6 +236,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Location { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Location(experiment = it, _json = json) @@ -311,8 +278,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun evalName(): String = evalName.getRequired("eval_name") @@ -340,34 +305,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Experiment && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Experiment{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -479,13 +416,11 @@ private constructor( return true } - return other is Position && - this.task == other.task && - this.scorer == other.scorer + return /* spotless:off */ other is Position && this.task == other.task && this.scorer == other.scorer /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(task, scorer) + return /* spotless:off */ Objects.hash(task, scorer) /* spotless:on */ } override fun toString(): String { @@ -519,6 +454,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Position { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Position(task = it, _json = json) @@ -562,7 +498,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -599,6 +535,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Experiment && this.type == other.type && this.evalName == other.evalName && this.position == other.position && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, evalName, position, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Experiment{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Function.Builder::class) @@ -612,8 +568,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun index(): Long = index.getRequired("index") @@ -636,32 +590,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{type=$type, index=$index, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -728,7 +656,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -765,6 +693,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.type == other.type && this.index == other.index && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, index, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{type=$type, index=$index, additionalProperties=$additionalProperties}" } } @@ -779,8 +727,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") @@ -803,32 +749,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -894,7 +814,7 @@ private constructor( return true } - return other is Runtime && this.value == other.value + return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -937,5 +857,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CodeBundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "CodeBundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index f8043a78..aa08e7f4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -32,8 +32,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the api key */ fun id(): String = id.getRequired("id") @@ -93,42 +91,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateApiKeyOutput && - this.id == other.id && - this.created == other.created && - this.name == other.name && - this.previewName == other.previewName && - this.userId == other.userId && - this.orgId == other.orgId && - this.key == other.key && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - created, - name, - previewName, - userId, - orgId, - key, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateApiKeyOutput{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -235,4 +197,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreateApiKeyOutput && this.id == other.id && this.created == other.created && this.name == other.name && this.previewName == other.previewName && this.userId == other.userId && this.orgId == other.orgId && this.key == other.key && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, created, name, previewName, userId, orgId, key, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "CreateApiKeyOutput{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index 9c3ace5c..b4f6ca10 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -27,8 +27,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** A mapping from experiment id to row ids for inserted `events` */ fun experiment(): Optional = Optional.ofNullable(experiment.getNullable("experiment")) @@ -64,34 +62,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CrossObjectInsertResponse && - this.experiment == other.experiment && - this.dataset == other.dataset && - this.projectLogs == other.projectLogs && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - experiment, - dataset, - projectLogs, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CrossObjectInsertResponse{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -171,8 +141,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -185,23 +153,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Dataset && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Dataset{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -232,6 +183,25 @@ private constructor( fun build(): Dataset = Dataset(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Dataset && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Dataset{additionalProperties=$additionalProperties}" } /** A mapping from experiment id to row ids for inserted `events` */ @@ -244,8 +214,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -258,23 +226,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Experiment && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Experiment{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -305,6 +256,25 @@ private constructor( fun build(): Experiment = Experiment(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Experiment && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Experiment{additionalProperties=$additionalProperties}" } /** A mapping from project id to row ids for inserted `events` */ @@ -317,8 +287,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -331,23 +299,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogs && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "ProjectLogs{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -378,5 +329,44 @@ private constructor( fun build(): ProjectLogs = ProjectLogs(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogs && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "ProjectLogs{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CrossObjectInsertResponse && this.experiment == other.experiment && this.dataset == other.dataset && this.projectLogs == other.projectLogs && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(experiment, dataset, projectLogs, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "CrossObjectInsertResponse{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index 09ea8607..b09f0838 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -25,8 +25,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Total number of records in the dataset */ fun totalRecords(): Long = totalRecords.getRequired("total_records") @@ -46,26 +44,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DataSummary && - this.totalRecords == other.totalRecords && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(totalRecords, additionalProperties) - } - return hashCode - } - - override fun toString() = - "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -106,4 +84,24 @@ private constructor( fun build(): DataSummary = DataSummary(totalRecords, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DataSummary && this.totalRecords == other.totalRecords && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(totalRecords, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 6ff84bcd..325b230e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -33,8 +33,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the dataset */ fun id(): String = id.getRequired("id") @@ -105,44 +103,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Dataset && - this.id == other.id && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.created == other.created && - this.deletedAt == other.deletedAt && - this.userId == other.userId && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - projectId, - name, - description, - created, - deletedAt, - userId, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Dataset{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, deletedAt=$deletedAt, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -273,8 +233,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -287,23 +245,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -334,5 +275,44 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Dataset && this.id == other.id && this.projectId == other.projectId && this.name == other.name && this.description == other.description && this.created == other.created && this.deletedAt == other.deletedAt && this.userId == other.userId && this.metadata == other.metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, projectId, name, description, created, deletedAt, userId, metadata, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Dataset{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, deletedAt=$deletedAt, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 4146c66e..5390c300 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -54,8 +54,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the dataset. Within a project, dataset names are unique */ @JsonProperty("name") fun name(): String? = name @@ -71,34 +69,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.description == other.description && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - description, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -152,6 +122,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetCreateBody && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, description, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -165,24 +155,11 @@ constructor( return true } - return other is DatasetCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is DatasetCreateParams && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, projectId, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 29ce38b2..aa332eff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is DatasetDeleteParams && - this.datasetId == other.datasetId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is DatasetDeleteParams && this.datasetId == other.datasetId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(datasetId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 1ea168ef..08d204b8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -36,8 +36,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate * one for you @@ -167,50 +165,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetEvent && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.datasetId == other.datasetId && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.spanId == other.spanId && - this.rootSpanId == other.rootSpanId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags, - spanId, - rootSpanId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -413,8 +367,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -427,23 +379,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -474,5 +409,44 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetEvent && this.id == other.id && this._xactId == other._xactId && this.created == other.created && this.projectId == other.projectId && this.datasetId == other.datasetId && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, _xactId, created, projectId, datasetId, input, expected, metadata, tags, spanId, rootSpanId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index c32d823b..b3fbe140 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -50,8 +50,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** A list of dataset feedback items */ @JsonProperty("feedback") fun feedback(): List? = feedback @@ -61,26 +59,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode - } - - override fun toString() = - "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -122,6 +100,26 @@ constructor( additionalProperties.toUnmodifiable() ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetFeedbackBody && this.feedback == other.feedback && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(feedback, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -135,22 +133,11 @@ constructor( return true } - return other is DatasetFeedbackParams && - this.datasetId == other.datasetId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is DatasetFeedbackParams && this.datasetId == other.datasetId && this.feedback == other.feedback && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(datasetId, feedback, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 1698818b..6202841f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -58,26 +58,11 @@ constructor( return true } - return other is DatasetFetchParams && - this.datasetId == other.datasetId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is DatasetFetchParams && this.datasetId == other.datasetId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 7d3a72e7..945c769d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -79,8 +79,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** * An opaque string to be used as a cursor for the next page of results, in order from * latest to earliest. @@ -159,40 +157,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -320,6 +284,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -333,32 +317,11 @@ constructor( return true } - return other is DatasetFetchPostParams && - this.datasetId == other.datasetId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(datasetId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 8089fb3e..ef809f0f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -61,8 +61,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** A list of dataset events to insert */ @JsonProperty("events") fun events(): List? = events @@ -72,26 +70,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode - } - - override fun toString() = - "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -132,6 +110,26 @@ constructor( additionalProperties.toUnmodifiable() ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetInsertBody && this.events == other.events && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(events, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -145,22 +143,11 @@ constructor( return true } - return other is DatasetInsertParams && - this.datasetId == other.datasetId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is DatasetInsertParams && this.datasetId == other.datasetId && this.events == other.events && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(datasetId, events, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -322,13 +309,11 @@ constructor( return true } - return other is Event && - this.insertDatasetEventReplace == other.insertDatasetEventReplace && - this.insertDatasetEventMerge == other.insertDatasetEventMerge + return /* spotless:off */ other is Event && this.insertDatasetEventReplace == other.insertDatasetEventReplace && this.insertDatasetEventMerge == other.insertDatasetEventMerge /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) + return /* spotless:off */ Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) /* spotless:on */ } override fun toString(): String { @@ -370,6 +355,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Event { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Event(insertDatasetEventReplace = it, _json = json) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index 5ad34048..636f0fbf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is DatasetListPage && - this.datasetsService == other.datasetsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is DatasetListPage && this.datasetsService == other.datasetsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ } override fun toString() = @@ -127,13 +120,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index ab1096f7..b0a51d0c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is DatasetListPageAsync && - this.datasetsService == other.datasetsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is DatasetListPageAsync && this.datasetsService == other.datasetsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ } override fun toString() = @@ -134,13 +127,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index d42871f3..2f4645b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -76,32 +76,11 @@ constructor( return true } - return other is DatasetListParams && - this.datasetName == other.datasetName && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is DatasetListParams && this.datasetName == other.datasetName && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetName, - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -170,7 +149,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -295,11 +274,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -333,6 +312,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index 963469a6..833cc3fc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is DatasetRetrieveParams && - this.datasetId == other.datasetId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is DatasetRetrieveParams && this.datasetId == other.datasetId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(datasetId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 434a6d19..bc730d6d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is DatasetSummarizeParams && - this.datasetId == other.datasetId && - this.summarizeData == other.summarizeData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is DatasetSummarizeParams && this.datasetId == other.datasetId && this.summarizeData == other.summarizeData && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetId, - summarizeData, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 1ab15c86..148e70e1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -64,8 +64,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Textual description of the dataset */ @JsonProperty("description") fun description(): String? = description @@ -81,34 +79,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetUpdateBody && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - description, - metadata, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -162,6 +132,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetUpdateBody && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(description, metadata, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -175,26 +165,11 @@ constructor( return true } - return other is DatasetUpdateParams && - this.datasetId == other.datasetId && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is DatasetUpdateParams && this.datasetId == other.datasetId && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - datasetId, - description, - metadata, - name, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(datasetId, description, metadata, name, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -315,31 +290,12 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -370,5 +326,24 @@ constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 73e03e71..f6242dc9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -34,8 +34,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the environment variable */ fun id(): String = id.getRequired("id") @@ -90,40 +88,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EnvVar && - this.id == other.id && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.name == other.name && - this.created == other.created && - this.used == other.used && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - objectType, - objectId, - name, - created, - used, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "EnvVar{id=$id, objectType=$objectType, objectId=$objectId, name=$name, created=$created, used=$used, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -235,7 +199,7 @@ private constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -284,4 +248,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVar && this.id == other.id && this.objectType == other.objectType && this.objectId == other.objectId && this.name == other.name && this.created == other.created && this.used == other.used && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, objectType, objectId, name, created, used, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "EnvVar{id=$id, objectType=$objectType, objectId=$objectId, name=$name, created=$created, used=$used, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 4b7c486e..56aeae21 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -63,8 +63,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The name of the environment variable */ @JsonProperty("name") fun name(): String? = name @@ -83,36 +81,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EnvVarCreateBody && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.value == other.value && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - objectId, - objectType, - value, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "EnvVarCreateBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -172,6 +140,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarCreateBody && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "EnvVarCreateBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -185,26 +173,11 @@ constructor( return true } - return other is EnvVarCreateParams && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.value == other.value && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is EnvVarCreateParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - objectId, - objectType, - value, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -330,7 +303,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index 358a7d95..e3e82fb3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is EnvVarDeleteParams && - this.envVarId == other.envVarId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is EnvVarDeleteParams && this.envVarId == other.envVarId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - envVarId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(envVarId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun 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 4f26f91e..9dcaf1d1 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 @@ -67,26 +67,11 @@ constructor( return true } - return other is EnvVarListParams && - this.envVarName == other.envVarName && - this.ids == other.ids && - this.limit == other.limit && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is EnvVarListParams && this.envVarName == other.envVarName && this.ids == other.ids && this.limit == other.limit && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - envVarName, - ids, - limit, - objectId, - objectType, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -140,7 +125,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -250,11 +235,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -288,6 +273,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } @@ -329,7 +315,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 2232c807..22112cd4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -24,8 +24,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** A list of env_var objects */ fun objects(): List = objects.getRequired("objects") @@ -45,26 +43,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EnvVarListResponse && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(objects, additionalProperties) - } - return hashCode - } - - override fun toString() = - "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -109,4 +87,24 @@ private constructor( additionalProperties.toUnmodifiable() ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarListResponse && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index b14cc253..cb7eb09d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -63,8 +63,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The name of the environment variable */ @JsonProperty("name") fun name(): String? = name @@ -83,36 +81,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EnvVarReplaceBody && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.value == other.value && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - objectId, - objectType, - value, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "EnvVarReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -172,6 +140,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarReplaceBody && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "EnvVarReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -185,26 +173,11 @@ constructor( return true } - return other is EnvVarReplaceParams && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.value == other.value && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is EnvVarReplaceParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - objectId, - objectType, - value, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -330,7 +303,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 4c26e77c..764d154d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is EnvVarRetrieveParams && - this.envVarId == other.envVarId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is EnvVarRetrieveParams && this.envVarId == other.envVarId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - envVarId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(envVarId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 8da2fd52..e502769a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -59,8 +59,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The name of the environment variable */ @JsonProperty("name") fun name(): String? = name @@ -73,32 +71,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EnvVarUpdateBody && - this.name == other.name && - this.value == other.value && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - value, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "EnvVarUpdateBody{name=$name, value=$value, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -144,6 +116,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarUpdateBody && this.name == other.name && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, value, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "EnvVarUpdateBody{name=$name, value=$value, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -157,24 +149,11 @@ constructor( return true } - return other is EnvVarUpdateParams && - this.envVarId == other.envVarId && - this.name == other.name && - this.value == other.value && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is EnvVarUpdateParams && this.envVarId == other.envVarId && this.name == other.name && this.value == other.value && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - envVarId, - name, - value, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(envVarId, name, value, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 31605b1c..0ef11ee3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -88,8 +88,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The dataset to use */ @JsonProperty("data") fun data(): Data? = data @@ -127,42 +125,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EvalCreateBody && - this.data == other.data && - this.projectId == other.projectId && - this.scores == other.scores && - this.task == other.task && - this.experimentName == other.experimentName && - this.metadata == other.metadata && - this.stream == other.stream && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - data, - projectId, - scores, - task, - experimentName, - metadata, - stream, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, experimentName=$experimentName, metadata=$metadata, stream=$stream, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -254,6 +216,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EvalCreateBody && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.experimentName == other.experimentName && this.metadata == other.metadata && this.stream == other.stream && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(data, projectId, scores, task, experimentName, metadata, stream, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, experimentName=$experimentName, metadata=$metadata, stream=$stream, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -267,32 +249,11 @@ constructor( return true } - return other is EvalCreateParams && - this.data == other.data && - this.projectId == other.projectId && - this.scores == other.scores && - this.task == other.task && - this.experimentName == other.experimentName && - this.metadata == other.metadata && - this.stream == other.stream && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is EvalCreateParams && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.experimentName == other.experimentName && this.metadata == other.metadata && this.stream == other.stream && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - data, - projectId, - scores, - task, - experimentName, - metadata, - stream, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(data, projectId, scores, task, experimentName, metadata, stream, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -525,13 +486,11 @@ constructor( return true } - return other is Data && - this.datasetId == other.datasetId && - this.projectDatasetName == other.projectDatasetName + return /* spotless:off */ other is Data && this.datasetId == other.datasetId && this.projectDatasetName == other.projectDatasetName /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(datasetId, projectDatasetName) + return /* spotless:off */ Objects.hash(datasetId, projectDatasetName) /* spotless:on */ } override fun toString(): String { @@ -567,6 +526,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Data(datasetId = it, _json = json) @@ -608,8 +568,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun datasetId(): String = datasetId.getRequired("dataset_id") @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId @@ -627,26 +585,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetId && - this.datasetId == other.datasetId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(datasetId, additionalProperties) - } - return hashCode - } - - override fun toString() = - "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -686,6 +624,26 @@ constructor( fun build(): DatasetId = DatasetId(datasetId, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetId && this.datasetId == other.datasetId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(datasetId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" } /** Project and dataset name */ @@ -700,8 +658,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun projectName(): String = projectName.getRequired("project_name") fun datasetName(): String = datasetName.getRequired("dataset_name") @@ -724,32 +680,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectDatasetName && - this.projectName == other.projectName && - this.datasetName == other.datasetName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - datasetName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectDatasetName{projectName=$projectName, datasetName=$datasetName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -806,6 +736,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectDatasetName && this.projectName == other.projectName && this.datasetName == other.datasetName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(projectName, datasetName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectDatasetName{projectName=$projectName, datasetName=$datasetName, additionalProperties=$additionalProperties}" } } @@ -902,24 +852,11 @@ constructor( return true } - return other is Score && - this.functionId == other.functionId && - this.projectSlug == other.projectSlug && - this.globalFunction == other.globalFunction && - this.promptSessionId == other.promptSessionId && - this.inlineCode == other.inlineCode && - this.inlinePrompt == other.inlinePrompt + return /* spotless:off */ other is Score && this.functionId == other.functionId && this.projectSlug == other.projectSlug && this.globalFunction == other.globalFunction && this.promptSessionId == other.promptSessionId && this.inlineCode == other.inlineCode && this.inlinePrompt == other.inlinePrompt /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionId, - projectSlug, - globalFunction, - promptSessionId, - inlineCode, - inlinePrompt, - ) + return /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ } override fun toString(): String { @@ -979,6 +916,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Score { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Score(functionId = it, _json = json) @@ -1040,8 +978,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The ID of the function */ fun functionId(): String = functionId.getRequired("function_id") @@ -1068,32 +1004,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionId && - this.functionId == other.functionId && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - functionId, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1152,6 +1062,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionId && this.functionId == other.functionId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(functionId, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" } /** Project name and slug */ @@ -1167,8 +1097,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The name of the project containing the function */ fun projectName(): String = projectName.getRequired("project_name") @@ -1202,34 +1130,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectSlug && - this.projectName == other.projectName && - this.slug == other.slug && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - slug, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1299,6 +1199,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectSlug && this.projectName == other.projectName && this.slug == other.slug && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(projectName, slug, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" } /** Global function name */ @@ -1312,8 +1232,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals @@ -1339,26 +1257,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GlobalFunction && - this.globalFunction == other.globalFunction && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(globalFunction, additionalProperties) - } - return hashCode - } - - override fun toString() = - "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1410,6 +1308,26 @@ constructor( fun build(): GlobalFunction = GlobalFunction(globalFunction, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GlobalFunction && this.globalFunction == other.globalFunction && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(globalFunction, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" } /** Prompt session id */ @@ -1425,8 +1343,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The ID of the prompt session */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") @@ -1465,34 +1381,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptSessionId && - this.promptSessionId == other.promptSessionId && - this.promptSessionFunctionId == other.promptSessionFunctionId && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptSessionId, - promptSessionFunctionId, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptSessionId{promptSessionId=$promptSessionId, promptSessionFunctionId=$promptSessionFunctionId, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1566,9 +1454,29 @@ constructor( additionalProperties.toUnmodifiable(), ) } - } - /** Inline code function */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptSessionId && this.promptSessionId == other.promptSessionId && this.promptSessionFunctionId == other.promptSessionFunctionId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(promptSessionId, promptSessionFunctionId, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PromptSessionId{promptSessionId=$promptSessionId, promptSessionFunctionId=$promptSessionFunctionId, version=$version, additionalProperties=$additionalProperties}" + } + + /** Inline code function */ @JsonDeserialize(builder = InlineCode.Builder::class) @NoAutoDetect class InlineCode @@ -1581,8 +1489,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun inlineContext(): InlineContext = inlineContext.getRequired("inline_context") /** The inline code to execute */ @@ -1614,34 +1520,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InlineCode && - this.inlineContext == other.inlineContext && - this.code == other.code && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - inlineContext, - code, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InlineCode{inlineContext=$inlineContext, code=$code, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1722,8 +1600,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") @@ -1746,32 +1622,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InlineContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1839,7 +1689,7 @@ constructor( return true } - return other is Runtime && this.value == other.value + return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1882,7 +1732,47 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InlineContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InlineCode && this.inlineContext == other.inlineContext && this.code == other.code && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(inlineContext, code, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InlineCode{inlineContext=$inlineContext, code=$code, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ @@ -1897,8 +1787,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The prompt, model, and its parameters */ fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) @@ -1926,32 +1814,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InlinePrompt && - this.inlinePrompt == other.inlinePrompt && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - inlinePrompt, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2011,6 +1873,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InlinePrompt && this.inlinePrompt == other.inlinePrompt && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(inlinePrompt, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" } } @@ -2107,24 +1989,11 @@ constructor( return true } - return other is Task && - this.functionId == other.functionId && - this.projectSlug == other.projectSlug && - this.globalFunction == other.globalFunction && - this.promptSessionId == other.promptSessionId && - this.inlineCode == other.inlineCode && - this.inlinePrompt == other.inlinePrompt + return /* spotless:off */ other is Task && this.functionId == other.functionId && this.projectSlug == other.projectSlug && this.globalFunction == other.globalFunction && this.promptSessionId == other.promptSessionId && this.inlineCode == other.inlineCode && this.inlinePrompt == other.inlinePrompt /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionId, - projectSlug, - globalFunction, - promptSessionId, - inlineCode, - inlinePrompt, - ) + return /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ } override fun toString(): String { @@ -2183,6 +2052,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Task { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Task(functionId = it, _json = json) @@ -2244,8 +2114,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The ID of the function */ fun functionId(): String = functionId.getRequired("function_id") @@ -2272,32 +2140,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionId && - this.functionId == other.functionId && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - functionId, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2356,6 +2198,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionId && this.functionId == other.functionId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(functionId, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" } /** Project name and slug */ @@ -2371,8 +2233,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The name of the project containing the function */ fun projectName(): String = projectName.getRequired("project_name") @@ -2406,34 +2266,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectSlug && - this.projectName == other.projectName && - this.slug == other.slug && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - slug, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2503,6 +2335,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectSlug && this.projectName == other.projectName && this.slug == other.slug && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(projectName, slug, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" } /** Global function name */ @@ -2516,8 +2368,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals @@ -2543,26 +2393,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GlobalFunction && - this.globalFunction == other.globalFunction && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(globalFunction, additionalProperties) - } - return hashCode - } - - override fun toString() = - "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2614,6 +2444,26 @@ constructor( fun build(): GlobalFunction = GlobalFunction(globalFunction, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GlobalFunction && this.globalFunction == other.globalFunction && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(globalFunction, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" } /** Prompt session id */ @@ -2629,8 +2479,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The ID of the prompt session */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") @@ -2669,34 +2517,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptSessionId && - this.promptSessionId == other.promptSessionId && - this.promptSessionFunctionId == other.promptSessionFunctionId && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptSessionId, - promptSessionFunctionId, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptSessionId{promptSessionId=$promptSessionId, promptSessionFunctionId=$promptSessionFunctionId, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2770,6 +2590,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptSessionId && this.promptSessionId == other.promptSessionId && this.promptSessionFunctionId == other.promptSessionFunctionId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(promptSessionId, promptSessionFunctionId, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PromptSessionId{promptSessionId=$promptSessionId, promptSessionFunctionId=$promptSessionFunctionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ @@ -2785,8 +2625,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun inlineContext(): InlineContext = inlineContext.getRequired("inline_context") /** The inline code to execute */ @@ -2818,34 +2656,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InlineCode && - this.inlineContext == other.inlineContext && - this.code == other.code && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - inlineContext, - code, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InlineCode{inlineContext=$inlineContext, code=$code, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2926,8 +2736,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") @@ -2950,32 +2758,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InlineContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -3043,7 +2825,7 @@ constructor( return true } - return other is Runtime && this.value == other.value + return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3086,7 +2868,47 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InlineContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InlineCode && this.inlineContext == other.inlineContext && this.code == other.code && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(inlineContext, code, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InlineCode{inlineContext=$inlineContext, code=$code, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ @@ -3101,8 +2923,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The prompt, model, and its parameters */ fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) @@ -3130,32 +2950,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InlinePrompt && - this.inlinePrompt == other.inlinePrompt && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - inlinePrompt, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -3215,6 +3009,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InlinePrompt && this.inlinePrompt == other.inlinePrompt && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(inlinePrompt, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" } } @@ -3229,31 +3043,12 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -3284,5 +3079,24 @@ constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 7e07bb42..7d6d775b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -39,8 +39,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the experiment */ fun id(): String = id.getRequired("id") @@ -166,56 +164,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Experiment && - this.id == other.id && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.created == other.created && - this.repoInfo == other.repoInfo && - this.commit == other.commit && - this.baseExpId == other.baseExpId && - this.deletedAt == other.deletedAt && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.public_ == other.public_ && - this.userId == other.userId && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - projectId, - name, - description, - created, - repoInfo, - commit, - baseExpId, - deletedAt, - datasetId, - datasetVersion, - public_, - userId, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Experiment{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, repoInfo=$repoInfo, commit=$commit, baseExpId=$baseExpId, deletedAt=$deletedAt, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -430,8 +378,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -444,23 +390,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -491,5 +420,44 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Experiment && this.id == other.id && this.projectId == other.projectId && this.name == other.name && this.description == other.description && this.created == other.created && this.repoInfo == other.repoInfo && this.commit == other.commit && this.baseExpId == other.baseExpId && this.deletedAt == other.deletedAt && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.public_ == other.public_ && this.userId == other.userId && this.metadata == other.metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, projectId, name, description, created, repoInfo, commit, baseExpId, deletedAt, datasetId, datasetVersion, public_, userId, metadata, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Experiment{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, repoInfo=$repoInfo, commit=$commit, baseExpId=$baseExpId, deletedAt=$deletedAt, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index c4aa0d18..df88f2a2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -89,8 +89,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Unique identifier for the project that the experiment belongs under */ @JsonProperty("project_id") fun projectId(): String? = projectId @@ -139,48 +137,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentCreateBody && - this.projectId == other.projectId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.ensureNew == other.ensureNew && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -297,6 +253,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentCreateBody && this.projectId == other.projectId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.ensureNew == other.ensureNew && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -310,38 +286,11 @@ constructor( return true } - return other is ExperimentCreateParams && - this.projectId == other.projectId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.ensureNew == other.ensureNew && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ExperimentCreateParams && this.projectId == other.projectId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.ensureNew == other.ensureNew && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -510,31 +459,12 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -565,5 +495,24 @@ constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index e3e57b22..d1522848 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is ExperimentDeleteParams && - this.experimentId == other.experimentId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ExperimentDeleteParams && this.experimentId == other.experimentId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(experimentId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index ec5c09a6..debb6043 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -47,8 +47,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unique identifier for the experiment event. If you don't provide one, BrainTrust will * generate one for you @@ -311,66 +309,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentEvent && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.experimentId == other.experimentId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -723,8 +661,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The function in code which created the experiment event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) @@ -763,34 +699,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -865,6 +773,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -883,8 +811,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -897,23 +823,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -944,6 +853,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } /** @@ -965,8 +893,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unix timestamp recording when the section of code which produced the experiment event * started @@ -1042,38 +968,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1191,6 +1085,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" } /** @@ -1211,8 +1125,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1225,23 +1137,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1272,6 +1167,25 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" } /** Human-identifying attributes of the span, such as name, type, etc. */ @@ -1286,8 +1200,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the span, for display purposes only */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -1314,32 +1226,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1409,7 +1295,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1476,5 +1362,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentEvent && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this._xactId == other._xactId && this.created == other.created && this.projectId == other.projectId && this.experimentId == other.experimentId && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanId == other.spanId && this.spanParents == other.spanParents && this.rootSpanId == other.rootSpanId && this.spanAttributes == other.spanAttributes && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, datasetRecordId, _xactId, created, projectId, experimentId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, spanAttributes, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 02de4d52..8b2a759e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -50,8 +50,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** A list of experiment feedback items */ @JsonProperty("feedback") fun feedback(): List? = feedback @@ -61,26 +59,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -124,6 +102,26 @@ constructor( additionalProperties.toUnmodifiable() ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentFeedbackBody && this.feedback == other.feedback && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(feedback, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -137,22 +135,11 @@ constructor( return true } - return other is ExperimentFeedbackParams && - this.experimentId == other.experimentId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ExperimentFeedbackParams && this.experimentId == other.experimentId && this.feedback == other.feedback && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(experimentId, feedback, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 9f90dc28..cb530419 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -58,26 +58,11 @@ constructor( return true } - return other is ExperimentFetchParams && - this.experimentId == other.experimentId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ExperimentFetchParams && this.experimentId == other.experimentId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index b208f3c8..36eafdcb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -79,8 +79,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** * An opaque string to be used as a cursor for the next page of results, in order from * latest to earliest. @@ -159,40 +157,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -320,6 +284,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -333,32 +317,11 @@ constructor( return true } - return other is ExperimentFetchPostParams && - this.experimentId == other.experimentId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(experimentId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index b03547c6..728d5bdb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -61,8 +61,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** A list of experiment events to insert */ @JsonProperty("events") fun events(): List? = events @@ -72,26 +70,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -132,6 +110,26 @@ constructor( additionalProperties.toUnmodifiable() ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentInsertBody && this.events == other.events && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(events, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -145,22 +143,11 @@ constructor( return true } - return other is ExperimentInsertParams && - this.experimentId == other.experimentId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ExperimentInsertParams && this.experimentId == other.experimentId && this.events == other.events && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(experimentId, events, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -322,13 +309,11 @@ constructor( return true } - return other is Event && - this.insertExperimentEventReplace == other.insertExperimentEventReplace && - this.insertExperimentEventMerge == other.insertExperimentEventMerge + return /* spotless:off */ other is Event && this.insertExperimentEventReplace == other.insertExperimentEventReplace && this.insertExperimentEventMerge == other.insertExperimentEventMerge /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) + return /* spotless:off */ Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) /* spotless:on */ } override fun toString(): String { @@ -374,6 +359,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Event { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 18eb99a7..4e6b5d8f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is ExperimentListPage && - this.experimentsService == other.experimentsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ExperimentListPage && this.experimentsService == other.experimentsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ } override fun toString() = @@ -131,13 +124,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index 2b5d3b79..ff0a1487 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is ExperimentListPageAsync && - this.experimentsService == other.experimentsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ExperimentListPageAsync && this.experimentsService == other.experimentsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ } override fun toString() = @@ -134,13 +127,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 6c36c064..a2b8bb99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -76,32 +76,11 @@ constructor( return true } - return other is ExperimentListParams && - this.endingBefore == other.endingBefore && - this.experimentName == other.experimentName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ExperimentListParams && this.endingBefore == other.endingBefore && this.experimentName == other.experimentName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - experimentName, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -170,7 +149,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -295,11 +274,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -333,6 +312,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 3062382b..ebb46148 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is ExperimentRetrieveParams && - this.experimentId == other.experimentId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ExperimentRetrieveParams && this.experimentId == other.experimentId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(experimentId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index c72fa655..8923ed07 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -52,22 +52,11 @@ constructor( return true } - return other is ExperimentSummarizeParams && - this.experimentId == other.experimentId && - this.comparisonExperimentId == other.comparisonExperimentId && - this.summarizeScores == other.summarizeScores && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ExperimentSummarizeParams && this.experimentId == other.experimentId && this.comparisonExperimentId == other.comparisonExperimentId && this.summarizeScores == other.summarizeScores && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentId, - comparisonExperimentId, - summarizeScores, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index bac822b2..37a22a12 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -89,8 +89,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Id of default base experiment to compare against when viewing this experiment */ @JsonProperty("base_exp_id") fun baseExpId(): String? = baseExpId @@ -129,44 +127,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentUpdateBody && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -265,6 +225,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentUpdateBody && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -278,36 +258,11 @@ constructor( return true } - return other is ExperimentUpdateParams && - this.experimentId == other.experimentId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ExperimentUpdateParams && this.experimentId == other.experimentId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - experimentId, - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(experimentId, baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -466,31 +421,12 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -521,5 +457,24 @@ constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 7e931a63..3422a014 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -31,8 +31,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * The id of the dataset event to log feedback for. This is the row `id` returned by `POST * /v1/dataset/{dataset_id}/insert` @@ -85,36 +83,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackDatasetItem && - this.id == other.id && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -216,8 +184,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -230,23 +196,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -277,6 +226,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class Source @@ -292,7 +260,7 @@ private constructor( return true } - return other is Source && this.value == other.value + return /* spotless:off */ other is Source && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -341,4 +309,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FeedbackDatasetItem && this.id == other.id && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, comment, metadata, source, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index 2abcfe43..f05a762a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -33,8 +33,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * The id of the experiment event to log feedback for. This is the row `id` returned by `POST * /v1/experiment/{experiment_id}/insert` @@ -113,40 +111,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackExperimentItem && - this.id == other.id && - this.scores == other.scores && - this.expected == other.expected && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -276,8 +240,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -290,23 +252,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -337,6 +282,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } /** @@ -352,8 +316,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -366,23 +328,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -413,6 +358,25 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" } class Source @@ -428,7 +392,7 @@ private constructor( return true } - return other is Source && this.value == other.value + return /* spotless:off */ other is Source && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -477,4 +441,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FeedbackExperimentItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index becc2347..776bee1a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -33,8 +33,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * The id of the project logs event to log feedback for. This is the row `id` returned by `POST * /v1/project_logs/{project_id}/insert` @@ -113,40 +111,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackProjectLogsItem && - this.id == other.id && - this.scores == other.scores && - this.expected == other.expected && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -276,8 +240,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -290,23 +252,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -337,6 +282,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } /** @@ -352,8 +316,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -366,23 +328,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -413,6 +358,25 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" } class Source @@ -428,7 +392,7 @@ private constructor( return true } - return other is Source && this.value == other.value + return /* spotless:off */ other is Source && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -477,4 +441,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FeedbackProjectLogsItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index a3654dac..a14a83a4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -27,8 +27,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun status(): Status = status.getRequired("status") @JsonProperty("status") @ExcludeMissing fun _status() = status @@ -46,26 +44,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackResponseSchema && - this.status == other.status && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(status, additionalProperties) - } - return hashCode - } - - override fun toString() = - "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -119,7 +97,7 @@ private constructor( return true } - return other is Status && this.value == other.value + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -156,4 +134,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FeedbackResponseSchema && this.status == other.status && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(status, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 00a47268..6d3bd511 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -26,8 +26,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** A list of fetched events */ fun events(): List = events.getRequired("events") @@ -64,32 +62,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FetchDatasetEventsResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -155,4 +127,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FetchDatasetEventsResponse && this.events == other.events && this.cursor == other.cursor && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(events, cursor, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 318e1c7a..6be52808 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -26,8 +26,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** A list of fetched events */ fun events(): List = events.getRequired("events") @@ -64,32 +62,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FetchExperimentEventsResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -155,4 +127,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FetchExperimentEventsResponse && this.events == other.events && this.cursor == other.cursor && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(events, cursor, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 7c808c80..49bebdf3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -26,8 +26,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** A list of fetched events */ fun events(): List = events.getRequired("events") @@ -64,32 +62,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FetchProjectLogsEventsResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -155,4 +127,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FetchProjectLogsEventsResponse && this.events == other.events && this.cursor == other.cursor && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(events, cursor, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } 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 54481c03..b81f35c2 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 @@ -53,8 +53,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") @@ -185,60 +183,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.functionType == other.functionType && - this.functionData == other.functionData && - this.origin == other.origin && - this.functionSchema == other.functionSchema && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - functionType, - functionData, - origin, - functionSchema, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, functionData=$functionData, origin=$origin, functionSchema=$functionSchema, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -514,18 +458,11 @@ private constructor( return true } - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global + return /* spotless:off */ other is FunctionData && this.prompt == other.prompt && this.code == other.code && this.global == other.global /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - ) + return /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ } override fun toString(): String { @@ -564,6 +501,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return FunctionData(prompt = it, _json = json) @@ -608,8 +546,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") @JsonProperty("type") @ExcludeMissing fun _type() = type @@ -627,26 +563,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -700,7 +616,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -737,6 +653,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Prompt && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Code.Builder::class) @@ -750,8 +686,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun data(): Data = data.getRequired("data") @@ -774,32 +708,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -901,13 +809,11 @@ private constructor( return true } - return other is Data && - this.bundle == other.bundle && - this.inline == other.inline + return /* spotless:off */ other is Data && this.bundle == other.bundle && this.inline == other.inline /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(bundle, inline) + return /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ } override fun toString(): String { @@ -941,6 +847,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Data(bundle = it, _json = json) } @@ -983,8 +890,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") @@ -1036,38 +941,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Bundle && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtimeContext, - location, - bundleId, - preview, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1175,7 +1048,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1212,6 +1085,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Bundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Inline.Builder::class) @@ -1226,8 +1119,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun runtimeContext(): RuntimeContext = @@ -1258,34 +1149,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Inline && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.code == other.code && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - code, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1363,8 +1226,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") @@ -1387,32 +1248,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1485,7 +1320,7 @@ private constructor( return true } - return other is Runtime && this.value == other.value + return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1531,6 +1366,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } class Type @@ -1547,7 +1402,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1584,6 +1439,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Inline && this.type == other.type && this.runtimeContext == other.runtimeContext && this.code == other.code && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, runtimeContext, code, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" } } @@ -1600,7 +1475,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1637,6 +1512,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && this.type == other.type && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, data, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Global.Builder::class) @@ -1650,8 +1545,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun name(): String = name.getRequired("name") @@ -1674,32 +1567,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1766,7 +1633,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1803,6 +1670,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" } } @@ -1819,7 +1706,7 @@ private constructor( return true } - return other is LogId && this.value == other.value + return /* spotless:off */ other is LogId && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1869,8 +1756,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun parameters(): JsonValue = parameters fun returns(): JsonValue = returns @@ -1893,32 +1778,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionSchema && - this.parameters == other.parameters && - this.returns == other.returns && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - parameters, - returns, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1966,6 +1825,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionSchema && this.parameters == other.parameters && this.returns == other.returns && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(parameters, returns, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } class FunctionType @@ -1981,7 +1860,7 @@ private constructor( return true } - return other is FunctionType && this.value == other.value + return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2047,8 +1926,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2061,23 +1938,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2108,6 +1968,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Origin.Builder::class) @@ -2122,8 +2001,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The object type that the ACL applies to */ fun objectType(): ObjectType = objectType.getRequired("object_type") @@ -2163,34 +2040,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.internal_ == other.internal_ && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - internal_, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2279,7 +2128,7 @@ private constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2376,5 +2225,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.internal_ == other.internal_ && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, internal_, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.id == other.id && this._xactId == other._xactId && this.projectId == other.projectId && this.logId == other.logId && this.orgId == other.orgId && this.name == other.name && this.slug == other.slug && this.description == other.description && this.created == other.created && this.promptData == other.promptData && this.tags == other.tags && this.metadata == other.metadata && this.functionType == other.functionType && this.functionData == other.functionData && this.origin == other.origin && this.functionSchema == other.functionSchema && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, _xactId, projectId, logId, orgId, name, slug, description, created, promptData, tags, metadata, functionType, functionData, origin, functionSchema, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, functionData=$functionData, origin=$origin, functionSchema=$functionSchema, additionalProperties=$additionalProperties}" } 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 47041902..d8f764c2 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 @@ -103,8 +103,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonProperty("function_data") fun functionData(): FunctionData? = functionData /** Name of the prompt */ @@ -138,48 +136,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCreateBody && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionSchema == other.functionSchema && - this.functionType == other.functionType && - this.origin == other.origin && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - functionData, - name, - projectId, - slug, - description, - functionSchema, - functionType, - origin, - promptData, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -282,6 +238,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionCreateBody && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -295,38 +271,11 @@ constructor( return true } - return other is FunctionCreateParams && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionSchema == other.functionSchema && - this.functionType == other.functionType && - this.origin == other.origin && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is FunctionCreateParams && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionData, - name, - projectId, - slug, - description, - functionSchema, - functionType, - origin, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -550,18 +499,11 @@ constructor( return true } - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global + return /* spotless:off */ other is FunctionData && this.prompt == other.prompt && this.code == other.code && this.global == other.global /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - ) + return /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ } override fun toString(): String { @@ -600,6 +542,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return FunctionData(prompt = it, _json = json) @@ -644,8 +587,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") @JsonProperty("type") @ExcludeMissing fun _type() = type @@ -663,26 +604,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -736,7 +657,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -773,6 +694,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Prompt && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Code.Builder::class) @@ -786,8 +727,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun data(): Data = data.getRequired("data") @@ -810,32 +749,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -937,13 +850,11 @@ constructor( return true } - return other is Data && - this.bundle == other.bundle && - this.inline == other.inline + return /* spotless:off */ other is Data && this.bundle == other.bundle && this.inline == other.inline /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(bundle, inline) + return /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ } override fun toString(): String { @@ -977,6 +888,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Data(bundle = it, _json = json) } @@ -1019,8 +931,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") @@ -1072,38 +982,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Bundle && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtimeContext, - location, - bundleId, - preview, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1208,7 +1086,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1245,6 +1123,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Bundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Inline.Builder::class) @@ -1259,8 +1157,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun runtimeContext(): RuntimeContext = @@ -1291,34 +1187,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Inline && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.code == other.code && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - code, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1396,8 +1264,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") @@ -1420,32 +1286,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1518,7 +1358,7 @@ constructor( return true } - return other is Runtime && this.value == other.value + return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1564,6 +1404,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } class Type @@ -1580,7 +1440,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1617,6 +1477,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Inline && this.type == other.type && this.runtimeContext == other.runtimeContext && this.code == other.code && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, runtimeContext, code, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" } } @@ -1633,7 +1513,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1670,6 +1550,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && this.type == other.type && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, data, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Global.Builder::class) @@ -1683,8 +1583,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun name(): String = name.getRequired("name") @@ -1707,32 +1605,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1799,7 +1671,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1836,6 +1708,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" } } @@ -1849,8 +1741,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonProperty("parameters") fun parameters(): JsonValue? = parameters @JsonProperty("returns") fun returns(): JsonValue? = returns @@ -1861,32 +1751,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionSchema && - this.parameters == other.parameters && - this.returns == other.returns && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - parameters, - returns, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1932,6 +1796,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionSchema && this.parameters == other.parameters && this.returns == other.returns && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(parameters, returns, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } class FunctionType @@ -1947,7 +1831,7 @@ constructor( return true } - return other is FunctionType && this.value == other.value + return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2013,8 +1897,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The object type that the ACL applies to */ @JsonProperty("object_type") fun objectType(): ObjectType? = objectType @@ -2033,34 +1915,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.internal_ == other.internal_ && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - internal_, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2132,7 +1986,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2229,5 +2083,25 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.internal_ == other.internal_ && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, internal_, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index 3c433643..bbadeeff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is FunctionDeleteParams && - this.functionId == other.functionId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is FunctionDeleteParams && this.functionId == other.functionId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(functionId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index cc968e6e..1e78cd12 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -94,8 +94,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Argument to the function, which can be any JSON serializable value */ @JsonProperty("input") fun input(): JsonValue? = input @@ -123,40 +121,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionInvokeBody && - this.input == other.input && - this.messages == other.messages && - this.mode == other.mode && - this.parent == other.parent && - this.stream == other.stream && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - messages, - mode, - parent, - stream, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionInvokeBody{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -230,6 +194,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionInvokeBody && this.input == other.input && this.messages == other.messages && this.mode == other.mode && this.parent == other.parent && this.stream == other.stream && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(input, messages, mode, parent, stream, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionInvokeBody{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -243,32 +227,11 @@ constructor( return true } - return other is FunctionInvokeParams && - this.functionId == other.functionId && - this.input == other.input && - this.messages == other.messages && - this.mode == other.mode && - this.parent == other.parent && - this.stream == other.stream && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is FunctionInvokeParams && this.functionId == other.functionId && this.input == other.input && this.messages == other.messages && this.mode == other.mode && this.parent == other.parent && this.stream == other.stream && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionId, - input, - messages, - mode, - parent, - stream, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(functionId, input, messages, mode, parent, stream, version, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -508,24 +471,11 @@ constructor( return true } - return other is Message && - this.system == other.system && - this.user == other.user && - this.assistant == other.assistant && - this.tool == other.tool && - this.function == other.function && - this.fallback == other.fallback + return /* spotless:off */ other is Message && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - system, - user, - assistant, - tool, - function, - fallback, - ) + return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ } override fun toString(): String { @@ -579,6 +529,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Message { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Message(system = it, _json = json) @@ -640,8 +591,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -669,34 +618,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is System && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -772,7 +693,7 @@ constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -809,6 +730,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = User.Builder::class) @@ -823,8 +764,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -852,34 +791,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is User && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -955,7 +866,7 @@ constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -997,41 +908,38 @@ constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val string: String? = null, - private val chatCompletionContentParts: List? = null, + private val text: String? = null, + private val array: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) + fun text(): Optional = Optional.ofNullable(text) - fun chatCompletionContentParts(): Optional> = - Optional.ofNullable(chatCompletionContentParts) + fun array(): Optional> = Optional.ofNullable(array) - fun isString(): Boolean = string != null + fun isText(): Boolean = text != null - fun isChatCompletionContentParts(): Boolean = chatCompletionContentParts != null + fun isArray(): Boolean = array != null - fun asString(): String = string.getOrThrow("string") + fun asText(): String = text.getOrThrow("text") - fun asChatCompletionContentParts(): List = - chatCompletionContentParts.getOrThrow("chatCompletionContentParts") + fun asArray(): List = array.getOrThrow("array") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - string != null -> visitor.visitString(string) - chatCompletionContentParts != null -> - visitor.visitChatCompletionContentParts(chatCompletionContentParts) + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) else -> visitor.unknown(_json) } } fun validate(): Content = apply { if (!validated) { - if (string == null && chatCompletionContentParts == null) { + if (text == null && array == null) { throw BraintrustInvalidDataException("Unknown Content: $_json") } validated = true @@ -1043,20 +951,17 @@ constructor( return true } - return other is Content && - this.string == other.string && - this.chatCompletionContentParts == other.chatCompletionContentParts + return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, chatCompletionContentParts) + return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ } override fun toString(): String { return when { - string != null -> "Content{string=$string}" - chatCompletionContentParts != null -> - "Content{chatCompletionContentParts=$chatCompletionContentParts}" + text != null -> "Content{text=$text}" + array != null -> "Content{array=$array}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -1064,21 +969,17 @@ constructor( companion object { - @JvmStatic fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofText(text: String) = Content(text = text) @JvmStatic - fun ofChatCompletionContentParts( - chatCompletionContentParts: List - ) = Content(chatCompletionContentParts = chatCompletionContentParts) + fun ofArray(array: List) = Content(array = array) } interface Visitor { - fun visitString(string: String): T + fun visitText(text: String): T - fun visitChatCompletionContentParts( - chatCompletionContentParts: List - ): T + fun visitArray(array: List): T fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Content: $json") @@ -1089,12 +990,13 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Content { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef>()) ?.let { - return Content(chatCompletionContentParts = it, _json = json) + return Content(array = it, _json = json) } return Content(_json = json) @@ -1109,9 +1011,8 @@ constructor( provider: SerializerProvider ) { when { - value.string != null -> generator.writeObject(value.string) - value.chatCompletionContentParts != null -> - generator.writeObject(value.chatCompletionContentParts) + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -1186,18 +1087,11 @@ constructor( return true } - return other is ChatCompletionContentPart && - this.chatCompletionContentPartText == - other.chatCompletionContentPartText && - this.chatCompletionContentPartImage == - other.chatCompletionContentPartImage + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - chatCompletionContentPartText, - chatCompletionContentPartImage - ) + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ } override fun toString(): String { @@ -1256,6 +1150,7 @@ constructor( node: JsonNode ): ChatCompletionContentPart { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } @@ -1302,6 +1197,26 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Assistant.Builder::class) @@ -1318,8 +1233,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) @@ -1359,38 +1272,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Assistant && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1491,7 +1372,7 @@ constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1540,8 +1421,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") @@ -1564,32 +1443,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1644,7 +1497,47 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Tool.Builder::class) @@ -1659,8 +1552,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -1689,34 +1580,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tool && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1794,7 +1657,7 @@ constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1831,6 +1694,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Function.Builder::class) @@ -1845,8 +1728,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun name(): String = name.getRequired("name") @@ -1874,34 +1755,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1977,7 +1830,7 @@ constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2014,6 +1867,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Fallback.Builder::class) @@ -2027,8 +1900,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) @@ -2051,32 +1922,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Fallback && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2143,7 +1988,7 @@ constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2180,6 +2025,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" } } @@ -2196,7 +2061,7 @@ constructor( return true } - return other is Mode && this.value == other.value + return /* spotless:off */ other is Mode && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2289,13 +2154,11 @@ constructor( return true } - return other is Parent && - this.spanParentStruct == other.spanParentStruct && - this.string == other.string + return /* spotless:off */ other is Parent && this.spanParentStruct == other.spanParentStruct && this.string == other.string /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(spanParentStruct, string) + return /* spotless:off */ Objects.hash(spanParentStruct, string) /* spotless:on */ } override fun toString(): String { @@ -2331,6 +2194,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Parent { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Parent(spanParentStruct = it, _json = json) @@ -2373,8 +2237,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun objectType(): ObjectType = objectType.getRequired("object_type") /** The id of the container object you are logging to */ @@ -2416,36 +2278,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanParentStruct && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.rowIds == other.rowIds && - this.propagatedEvent == other.propagatedEvent && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - rowIds, - propagatedEvent, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanParentStruct{objectType=$objectType, objectId=$objectId, rowIds=$rowIds, propagatedEvent=$propagatedEvent, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2541,7 +2373,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2595,8 +2427,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2609,25 +2439,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PropagatedEvent && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = - "PropagatedEvent{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2660,6 +2471,26 @@ constructor( fun build(): PropagatedEvent = PropagatedEvent(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PropagatedEvent && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PropagatedEvent{additionalProperties=$additionalProperties}" } /** Identifiers for the row to to log a subspan under */ @@ -2675,8 +2506,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The id of the row */ fun id(): String = id.getRequired("id") @@ -2710,34 +2539,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RowIds && - this.id == other.id && - this.spanId == other.spanId && - this.rootSpanId == other.rootSpanId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - spanId, - rootSpanId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RowIds{id=$id, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2807,7 +2608,47 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RowIds && this.id == other.id && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, spanId, rootSpanId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RowIds{id=$id, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanParentStruct && this.objectType == other.objectType && this.objectId == other.objectId && this.rowIds == other.rowIds && this.propagatedEvent == other.propagatedEvent && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, rowIds, propagatedEvent, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanParentStruct{objectType=$objectType, objectId=$objectId, rowIds=$rowIds, propagatedEvent=$propagatedEvent, additionalProperties=$additionalProperties}" } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 4d510eb4..da7f8dd4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -20,8 +20,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -34,24 +32,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionInvokeResponse && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "FunctionInvokeResponse{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -83,4 +63,23 @@ private constructor( fun build(): FunctionInvokeResponse = FunctionInvokeResponse(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionInvokeResponse && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "FunctionInvokeResponse{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 9b9e1cac..cd1d3a44 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is FunctionListPage && - this.functionsService == other.functionsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is FunctionListPage && this.functionsService == other.functionsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ } override fun toString() = @@ -127,13 +120,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 9daf7ae8..ba488e94 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is FunctionListPageAsync && - this.functionsService == other.functionsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is FunctionListPageAsync && this.functionsService == other.functionsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ } override fun toString() = @@ -134,13 +127,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 624cd773..20350b57 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -84,36 +84,11 @@ constructor( return true } - return other is FunctionListParams && - this.endingBefore == other.endingBefore && - this.functionName == other.functionName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.slug == other.slug && - this.startingAfter == other.startingAfter && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is FunctionListParams && this.endingBefore == other.endingBefore && this.functionName == other.functionName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.slug == other.slug && this.startingAfter == other.startingAfter && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - functionName, - ids, - limit, - orgName, - projectId, - projectName, - slug, - startingAfter, - version, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -186,7 +161,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -324,11 +299,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -362,6 +337,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } 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 8612e595..dcb49d58 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 @@ -103,8 +103,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonProperty("function_data") fun functionData(): FunctionData? = functionData /** Name of the prompt */ @@ -138,48 +136,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionReplaceBody && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionSchema == other.functionSchema && - this.functionType == other.functionType && - this.origin == other.origin && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - functionData, - name, - projectId, - slug, - description, - functionSchema, - functionType, - origin, - promptData, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -282,6 +238,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionReplaceBody && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -295,38 +271,11 @@ constructor( return true } - return other is FunctionReplaceParams && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionSchema == other.functionSchema && - this.functionType == other.functionType && - this.origin == other.origin && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is FunctionReplaceParams && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionData, - name, - projectId, - slug, - description, - functionSchema, - functionType, - origin, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -550,18 +499,11 @@ constructor( return true } - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global + return /* spotless:off */ other is FunctionData && this.prompt == other.prompt && this.code == other.code && this.global == other.global /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - ) + return /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ } override fun toString(): String { @@ -600,6 +542,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return FunctionData(prompt = it, _json = json) @@ -644,8 +587,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") @JsonProperty("type") @ExcludeMissing fun _type() = type @@ -663,26 +604,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -736,7 +657,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -773,6 +694,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Prompt && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Code.Builder::class) @@ -786,8 +727,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun data(): Data = data.getRequired("data") @@ -810,32 +749,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -937,13 +850,11 @@ constructor( return true } - return other is Data && - this.bundle == other.bundle && - this.inline == other.inline + return /* spotless:off */ other is Data && this.bundle == other.bundle && this.inline == other.inline /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(bundle, inline) + return /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ } override fun toString(): String { @@ -977,6 +888,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Data(bundle = it, _json = json) } @@ -1019,8 +931,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") @@ -1072,38 +982,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Bundle && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtimeContext, - location, - bundleId, - preview, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1208,7 +1086,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1245,6 +1123,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Bundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Inline.Builder::class) @@ -1259,8 +1157,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun runtimeContext(): RuntimeContext = @@ -1291,34 +1187,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Inline && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.code == other.code && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - code, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1396,8 +1264,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") @@ -1420,32 +1286,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1518,7 +1358,7 @@ constructor( return true } - return other is Runtime && this.value == other.value + return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1564,6 +1404,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } class Type @@ -1580,7 +1440,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1617,6 +1477,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Inline && this.type == other.type && this.runtimeContext == other.runtimeContext && this.code == other.code && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, runtimeContext, code, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" } } @@ -1633,7 +1513,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1670,6 +1550,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && this.type == other.type && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, data, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Global.Builder::class) @@ -1683,8 +1583,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun name(): String = name.getRequired("name") @@ -1707,32 +1605,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1799,7 +1671,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1836,6 +1708,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" } } @@ -1849,8 +1741,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonProperty("parameters") fun parameters(): JsonValue? = parameters @JsonProperty("returns") fun returns(): JsonValue? = returns @@ -1861,32 +1751,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionSchema && - this.parameters == other.parameters && - this.returns == other.returns && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - parameters, - returns, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1932,6 +1796,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionSchema && this.parameters == other.parameters && this.returns == other.returns && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(parameters, returns, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } class FunctionType @@ -1947,7 +1831,7 @@ constructor( return true } - return other is FunctionType && this.value == other.value + return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2013,8 +1897,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The object type that the ACL applies to */ @JsonProperty("object_type") fun objectType(): ObjectType? = objectType @@ -2033,34 +1915,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.internal_ == other.internal_ && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - internal_, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2132,7 +1986,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2229,5 +2083,25 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.internal_ == other.internal_ && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, internal_, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index 815fc34d..ada64538 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is FunctionRetrieveParams && - this.functionId == other.functionId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is FunctionRetrieveParams && this.functionId == other.functionId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(functionId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt index 78763bef..4c21b784 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt @@ -24,8 +24,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun name(): String = name.getRequired("name") @JsonProperty("name") @ExcludeMissing fun _name() = name @@ -43,26 +41,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionToolChoice && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "FunctionToolChoice{name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -102,4 +80,24 @@ private constructor( fun build(): FunctionToolChoice = FunctionToolChoice(name, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionToolChoice && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionToolChoice{name=$name, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 0c7e7c41..95cdbcab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -88,8 +88,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Textual description of the prompt */ @JsonProperty("description") fun description(): String? = description @@ -110,38 +108,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionUpdateBody && - this.description == other.description && - this.functionData == other.functionData && - this.name == other.name && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - description, - functionData, - name, - promptData, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -209,6 +175,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionUpdateBody && this.description == other.description && this.functionData == other.functionData && this.name == other.name && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(description, functionData, name, promptData, tags, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -222,30 +208,11 @@ constructor( return true } - return other is FunctionUpdateParams && - this.functionId == other.functionId && - this.description == other.description && - this.functionData == other.functionData && - this.name == other.name && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is FunctionUpdateParams && this.functionId == other.functionId && this.description == other.description && this.functionData == other.functionData && this.name == other.name && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - functionId, - description, - functionData, - name, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(functionId, description, functionData, name, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -458,20 +425,11 @@ constructor( return true } - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global && - this.nullableVariant == other.nullableVariant + return /* spotless:off */ other is FunctionData && this.prompt == other.prompt && this.code == other.code && this.global == other.global && this.nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - nullableVariant, - ) + return /* spotless:off */ Objects.hash(prompt, code, global, nullableVariant) /* spotless:on */ } override fun toString(): String { @@ -517,6 +475,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return FunctionData(prompt = it, _json = json) @@ -566,8 +525,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") @JsonProperty("type") @ExcludeMissing fun _type() = type @@ -585,26 +542,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -658,7 +595,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -695,6 +632,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Prompt && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Code.Builder::class) @@ -708,8 +665,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun data(): Data = data.getRequired("data") @@ -732,32 +687,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -859,13 +788,11 @@ constructor( return true } - return other is Data && - this.bundle == other.bundle && - this.inline == other.inline + return /* spotless:off */ other is Data && this.bundle == other.bundle && this.inline == other.inline /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(bundle, inline) + return /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ } override fun toString(): String { @@ -899,6 +826,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Data(bundle = it, _json = json) } @@ -941,8 +869,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") @@ -994,38 +920,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Bundle && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtimeContext, - location, - bundleId, - preview, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1130,7 +1024,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1167,6 +1061,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Bundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Inline.Builder::class) @@ -1181,8 +1095,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun runtimeContext(): RuntimeContext = @@ -1213,34 +1125,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Inline && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.code == other.code && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - code, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1318,8 +1202,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") @@ -1342,32 +1224,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1440,7 +1296,7 @@ constructor( return true } - return other is Runtime && this.value == other.value + return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1486,6 +1342,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } class Type @@ -1502,7 +1378,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1539,6 +1415,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Inline && this.type == other.type && this.runtimeContext == other.runtimeContext && this.code == other.code && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, runtimeContext, code, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" } } @@ -1555,7 +1451,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1592,6 +1488,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && this.type == other.type && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, data, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Global.Builder::class) @@ -1605,8 +1521,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun name(): String = name.getRequired("name") @@ -1629,32 +1543,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1721,7 +1609,7 @@ constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1758,6 +1646,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = NullableVariant.Builder::class) @@ -1769,8 +1677,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1783,24 +1689,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1833,6 +1721,25 @@ constructor( fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index e6427910..f82897d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -39,8 +39,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the group */ fun id(): String = id.getRequired("id") @@ -138,46 +136,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Group && - this.id == other.id && - this.orgId == other.orgId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.deletedAt == other.deletedAt && - this.memberUsers == other.memberUsers && - this.memberGroups == other.memberGroups && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberUsers, - memberGroups, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Group{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberUsers=$memberUsers, memberGroups=$memberGroups, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -330,4 +288,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Group && this.id == other.id && this.orgId == other.orgId && this.userId == other.userId && this.created == other.created && this.name == other.name && this.description == other.description && this.deletedAt == other.deletedAt && this.memberUsers == other.memberUsers && this.memberGroups == other.memberGroups && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, orgId, userId, created, name, description, deletedAt, memberUsers, memberGroups, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Group{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberUsers=$memberUsers, memberGroups=$memberGroups, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 50bdabcf..91245477 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -64,8 +64,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the group */ @JsonProperty("name") fun name(): String? = name @@ -96,38 +94,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupCreateBody && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -206,6 +172,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupCreateBody && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -219,28 +205,11 @@ constructor( return true } - return other is GroupCreateParams && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is GroupCreateParams && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 275bba9f..dd1df7ef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is GroupDeleteParams && - this.groupId == other.groupId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is GroupDeleteParams && this.groupId == other.groupId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - groupId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(groupId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 9d3d9ceb..1c96005e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is GroupListPage && - this.groupsService == other.groupsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is GroupListPage && this.groupsService == other.groupsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - groupsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ } override fun toString() = @@ -121,13 +114,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index cc058b58..3f977879 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is GroupListPageAsync && - this.groupsService == other.groupsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is GroupListPageAsync && this.groupsService == other.groupsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - groupsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ } override fun toString() = @@ -124,13 +117,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 99922e46..79f31933 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -68,28 +68,11 @@ constructor( return true } - return other is GroupListParams && - this.endingBefore == other.endingBefore && - this.groupName == other.groupName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is GroupListParams && this.endingBefore == other.endingBefore && this.groupName == other.groupName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - groupName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -154,7 +137,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -271,11 +254,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -309,6 +292,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index c7f5ad54..347027b9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -64,8 +64,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the group */ @JsonProperty("name") fun name(): String? = name @@ -96,38 +94,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupReplaceBody && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -206,6 +172,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupReplaceBody && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -219,28 +205,11 @@ constructor( return true } - return other is GroupReplaceParams && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is GroupReplaceParams && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index 7a68c3d6..a4b5bae1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is GroupRetrieveParams && - this.groupId == other.groupId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is GroupRetrieveParams && this.groupId == other.groupId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - groupId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(groupId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index ad6adecc..94ff5248 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -79,8 +79,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** A list of group IDs to add to the group's inheriting-from set */ @JsonProperty("add_member_groups") fun addMemberGroups(): List? = addMemberGroups @@ -107,40 +105,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupUpdateBody && - this.addMemberGroups == other.addMemberGroups && - this.addMemberUsers == other.addMemberUsers && - this.description == other.description && - this.name == other.name && - this.removeMemberGroups == other.removeMemberGroups && - this.removeMemberUsers == other.removeMemberUsers && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -223,6 +187,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupUpdateBody && this.addMemberGroups == other.addMemberGroups && this.addMemberUsers == other.addMemberUsers && this.description == other.description && this.name == other.name && this.removeMemberGroups == other.removeMemberGroups && this.removeMemberUsers == other.removeMemberUsers && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -236,32 +220,11 @@ constructor( return true } - return other is GroupUpdateParams && - this.groupId == other.groupId && - this.addMemberGroups == other.addMemberGroups && - this.addMemberUsers == other.addMemberUsers && - this.description == other.description && - this.name == other.name && - this.removeMemberGroups == other.removeMemberGroups && - this.removeMemberUsers == other.removeMemberUsers && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is GroupUpdateParams && this.groupId == other.groupId && this.addMemberGroups == other.addMemberGroups && this.addMemberUsers == other.addMemberUsers && this.description == other.description && this.name == other.name && this.removeMemberGroups == other.removeMemberGroups && this.removeMemberUsers == other.removeMemberUsers && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - groupId, - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(groupId, addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt index 5e2fade0..4445f55c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt @@ -34,8 +34,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ fun input(): JsonValue = input @@ -187,46 +185,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventMerge && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - expected, - metadata, - tags, - id, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -449,8 +407,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -463,23 +419,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -510,5 +449,44 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InsertDatasetEventMerge && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(input, expected, metadata, tags, id, created, _objectDelete, _isMerge, _mergePaths, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt index 2d77d5bd..62b686cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt @@ -34,8 +34,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ fun input(): JsonValue = input @@ -184,46 +182,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventReplace && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - expected, - metadata, - tags, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -442,8 +400,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -456,23 +412,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -503,5 +442,44 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InsertDatasetEventReplace && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._parentId == other._parentId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(input, expected, metadata, tags, id, created, _objectDelete, _isMerge, _parentId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 6646cb3e..4daad75e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -24,8 +24,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ @@ -49,26 +47,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertEventsResponse && - this.rowIds == other.rowIds && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(rowIds, additionalProperties) - } - return hashCode - } - - override fun toString() = - "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -119,4 +97,24 @@ private constructor( additionalProperties.toUnmodifiable() ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InsertEventsResponse && this.rowIds == other.rowIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(rowIds, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt index bfc1a9ff..a757f159 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt @@ -44,8 +44,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). * Later on, Braintrust will use the `input` to know whether two test cases are the same between @@ -316,60 +314,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventMerge && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -721,8 +665,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The function in code which created the experiment event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) @@ -761,34 +703,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -863,6 +777,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -881,8 +815,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -895,23 +827,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -942,6 +857,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } /** @@ -963,8 +897,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unix timestamp recording when the section of code which produced the experiment event * started @@ -1040,38 +972,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1189,6 +1089,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" } /** @@ -1209,8 +1129,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1223,23 +1141,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1270,6 +1171,25 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" } /** Human-identifying attributes of the span, such as name, type, etc. */ @@ -1284,8 +1204,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the span, for display purposes only */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -1312,32 +1230,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1407,7 +1299,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1474,5 +1366,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InsertExperimentEventMerge && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, datasetRecordId, created, _objectDelete, _isMerge, _mergePaths, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt index 41a1ffb7..f939b6da 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt @@ -44,8 +44,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). * Later on, Braintrust will use the `input` to know whether two test cases are the same between @@ -313,60 +311,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventReplace && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -714,8 +658,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The function in code which created the experiment event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) @@ -754,34 +696,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -856,6 +770,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -874,8 +808,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -888,23 +820,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -935,6 +850,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } /** @@ -956,8 +890,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unix timestamp recording when the section of code which produced the experiment event * started @@ -1033,38 +965,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1182,6 +1082,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" } /** @@ -1202,8 +1122,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1216,23 +1134,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1263,6 +1164,25 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" } /** Human-identifying attributes of the span, such as name, type, etc. */ @@ -1277,8 +1197,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the span, for display purposes only */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -1305,32 +1223,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1400,7 +1292,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1467,5 +1359,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InsertExperimentEventReplace && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._parentId == other._parentId && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, datasetRecordId, created, _objectDelete, _isMerge, _parentId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt index ed3b51be..5ec14eb3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt @@ -43,8 +43,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ fun input(): JsonValue = input @@ -291,58 +289,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventMerge && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -671,8 +617,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The function in code which created the project logs event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) @@ -711,34 +655,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -813,6 +729,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -831,8 +767,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -845,23 +779,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -892,6 +809,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } /** @@ -913,8 +849,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unix timestamp recording when the section of code which produced the project logs event * started @@ -990,38 +924,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1139,6 +1041,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" } /** @@ -1159,8 +1081,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1173,23 +1093,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1220,6 +1123,25 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" } /** Human-identifying attributes of the span, such as name, type, etc. */ @@ -1234,8 +1156,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the span, for display purposes only */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -1262,32 +1182,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1357,7 +1251,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1424,5 +1318,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InsertProjectLogsEventMerge && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, created, _objectDelete, _isMerge, _mergePaths, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt index 26089aee..8b1ee414 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt @@ -43,8 +43,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ fun input(): JsonValue = input @@ -288,58 +286,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventReplace && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -664,8 +610,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The function in code which created the project logs event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) @@ -704,34 +648,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -806,6 +722,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -824,8 +760,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -838,23 +772,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -885,6 +802,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } /** @@ -906,8 +842,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unix timestamp recording when the section of code which produced the project logs event * started @@ -983,38 +917,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1132,6 +1034,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" } /** @@ -1152,8 +1074,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1166,23 +1086,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1213,6 +1116,25 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" } /** Human-identifying attributes of the span, such as name, type, etc. */ @@ -1227,8 +1149,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the span, for display purposes only */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -1255,32 +1175,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1350,7 +1244,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1417,5 +1311,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InsertProjectLogsEventReplace && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._parentId == other._parentId && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, created, _objectDelete, _isMerge, _parentId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index 5927af4c..4336a5f1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -31,8 +31,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the metric */ fun name(): String = name.getRequired("name") @@ -87,40 +85,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MetricSummary && - this.name == other.name && - this.metric == other.metric && - this.unit == other.unit && - this.diff == other.diff && - this.improvements == other.improvements && - this.regressions == other.regressions && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - metric, - unit, - diff, - improvements, - regressions, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "MetricSummary{name=$name, metric=$metric, unit=$unit, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -220,4 +184,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MetricSummary && this.name == other.name && this.metric == other.metric && this.unit == other.unit && this.diff == other.diff && this.improvements == other.improvements && this.regressions == other.regressions && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, metric, unit, diff, improvements, regressions, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MetricSummary{name=$name, metric=$metric, unit=$unit, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index fcebfdc0..9c8a1620 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -40,8 +40,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The sampling rate for online scoring */ fun samplingRate(): Double = samplingRate.getRequired("sampling_rate") @@ -84,36 +82,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnlineScoreConfig && - this.samplingRate == other.samplingRate && - this.scorers == other.scorers && - this.applyToRootSpan == other.applyToRootSpan && - this.applyToSpanNames == other.applyToSpanNames && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - samplingRate, - scorers, - applyToRootSpan, - applyToSpanNames, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -249,11 +217,11 @@ private constructor( return true } - return other is Scorer && this.function == other.function && this.global == other.global + return /* spotless:off */ other is Scorer && this.function == other.function && this.global == other.global /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(function, global) + return /* spotless:off */ Objects.hash(function, global) /* spotless:on */ } override fun toString(): String { @@ -287,6 +255,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Scorer { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Scorer(function = it, _json = json) @@ -327,8 +296,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun id(): String = id.getRequired("id") @@ -351,32 +318,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.type == other.type && - this.id == other.id && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - id, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -443,7 +384,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -480,6 +421,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.type == other.type && this.id == other.id && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, id, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Global.Builder::class) @@ -493,8 +454,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun name(): String = name.getRequired("name") @@ -517,32 +476,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -609,7 +542,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -646,6 +579,46 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OnlineScoreConfig && this.samplingRate == other.samplingRate && this.scorers == other.scorers && this.applyToRootSpan == other.applyToRootSpan && this.applyToSpanNames == other.applyToSpanNames && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(samplingRate, scorers, applyToRootSpan, applyToSpanNames, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 44c9b609..a586fcb4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -32,8 +32,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the organization */ fun id(): String = id.getRequired("id") @@ -89,42 +87,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Organization && - this.id == other.id && - this.name == other.name && - this.apiUrl == other.apiUrl && - this.isUniversalApi == other.isUniversalApi && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.created == other.created && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - name, - apiUrl, - isUniversalApi, - proxyUrl, - realtimeUrl, - created, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Organization{id=$id, name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, created=$created, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -227,4 +189,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Organization && this.id == other.id && this.name == other.name && this.apiUrl == other.apiUrl && this.isUniversalApi == other.isUniversalApi && this.proxyUrl == other.proxyUrl && this.realtimeUrl == other.realtimeUrl && this.created == other.created && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, name, apiUrl, isUniversalApi, proxyUrl, realtimeUrl, created, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Organization{id=$id, name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, created=$created, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index 2a32949b..3e5294c1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is OrganizationDeleteParams && - this.organizationId == other.organizationId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is OrganizationDeleteParams && this.organizationId == other.organizationId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - organizationId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(organizationId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index ed6d9bd9..6555fc93 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is OrganizationListPage && - this.organizationsService == other.organizationsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is OrganizationListPage && this.organizationsService == other.organizationsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - organizationsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ } override fun toString() = @@ -131,13 +124,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index 5dc12993..1f73b9f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is OrganizationListPageAsync && - this.organizationsService == other.organizationsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is OrganizationListPageAsync && this.organizationsService == other.organizationsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - organizationsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ } override fun toString() = @@ -134,13 +127,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 76ac2962..fca42385 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -64,26 +64,11 @@ constructor( return true } - return other is OrganizationListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is OrganizationListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -143,7 +128,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -259,11 +244,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -297,6 +282,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index b97ce9e2..6cacca69 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -59,8 +59,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Users to invite to the organization */ @JsonProperty("invite_users") fun inviteUsers(): InviteUsers? = inviteUsers @@ -87,36 +85,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationMemberUpdateBody && - this.inviteUsers == other.inviteUsers && - this.orgId == other.orgId && - this.orgName == other.orgName && - this.removeUsers == other.removeUsers && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -187,6 +155,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OrganizationMemberUpdateBody && this.inviteUsers == other.inviteUsers && this.orgId == other.orgId && this.orgName == other.orgName && this.removeUsers == other.removeUsers && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -200,26 +188,11 @@ constructor( return true } - return other is OrganizationMemberUpdateParams && - this.inviteUsers == other.inviteUsers && - this.orgId == other.orgId && - this.orgName == other.orgName && - this.removeUsers == other.removeUsers && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is OrganizationMemberUpdateParams && this.inviteUsers == other.inviteUsers && this.orgId == other.orgId && this.orgName == other.orgName && this.removeUsers == other.removeUsers && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -355,8 +328,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Ids of existing users to invite */ @JsonProperty("ids") fun ids(): List? = ids @@ -384,42 +355,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InviteUsers && - this.ids == other.ids && - this.emails == other.emails && - this.sendInviteEmails == other.sendInviteEmails && - this.groupIds == other.groupIds && - this.groupNames == other.groupNames && - this.groupId == other.groupId && - this.groupName == other.groupName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - ids, - emails, - sendInviteEmails, - groupIds, - groupNames, - groupId, - groupName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupIds=$groupIds, groupNames=$groupNames, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -503,6 +438,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InviteUsers && this.ids == other.ids && this.emails == other.emails && this.sendInviteEmails == other.sendInviteEmails && this.groupIds == other.groupIds && this.groupNames == other.groupNames && this.groupId == other.groupId && this.groupName == other.groupName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(ids, emails, sendInviteEmails, groupIds, groupNames, groupId, groupName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupIds=$groupIds, groupNames=$groupNames, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" } /** Users to remove from the organization */ @@ -515,8 +470,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Ids of users to remove */ @JsonProperty("ids") fun ids(): List? = ids @@ -529,32 +482,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveUsers && - this.ids == other.ids && - this.emails == other.emails && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - ids, - emails, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -601,5 +528,25 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RemoveUsers && this.ids == other.ids && this.emails == other.emails && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(ids, emails, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 6999669c..63569b8a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is OrganizationRetrieveParams && - this.organizationId == other.organizationId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is OrganizationRetrieveParams && this.organizationId == other.organizationId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - organizationId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(organizationId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index a513fc50..468cef37 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -74,8 +74,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonProperty("api_url") fun apiUrl(): String? = apiUrl @JsonProperty("is_universal_api") fun isUniversalApi(): Boolean? = isUniversalApi @@ -93,38 +91,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationUpdateBody && - this.apiUrl == other.apiUrl && - this.isUniversalApi == other.isUniversalApi && - this.name == other.name && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -189,6 +155,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OrganizationUpdateBody && this.apiUrl == other.apiUrl && this.isUniversalApi == other.isUniversalApi && this.name == other.name && this.proxyUrl == other.proxyUrl && this.realtimeUrl == other.realtimeUrl && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -202,30 +188,11 @@ constructor( return true } - return other is OrganizationUpdateParams && - this.organizationId == other.organizationId && - this.apiUrl == other.apiUrl && - this.isUniversalApi == other.isUniversalApi && - this.name == other.name && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is OrganizationUpdateParams && this.organizationId == other.organizationId && this.apiUrl == other.apiUrl && this.isUniversalApi == other.isUniversalApi && this.name == other.name && this.proxyUrl == other.proxyUrl && this.realtimeUrl == other.realtimeUrl && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - organizationId, - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(organizationId, apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 3c0f52bc..f7948d50 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -29,8 +29,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun status(): Status = status.getRequired("status") /** @@ -62,32 +60,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchOrganizationMembersOutput && - this.status == other.status && - this.sendEmailError == other.sendEmailError && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - status, - sendEmailError, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchOrganizationMembersOutput{status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -163,7 +135,7 @@ private constructor( return true } - return other is Status && this.value == other.value + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -200,4 +172,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PatchOrganizationMembersOutput && this.status == other.status && this.sendEmailError == other.sendEmailError && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(status, sendEmailError, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PatchOrganizationMembersOutput{status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt index d1127b0d..5dc888a5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt @@ -34,8 +34,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Denotes the type of filter as a path-lookup filter */ fun type(): Type = type.getRequired("type") @@ -87,34 +85,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PathLookupFilter && - this.type == other.type && - this.path == other.path && - this.value == other.value && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - path, - value, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PathLookupFilter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -205,7 +175,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -242,4 +212,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PathLookupFilter && this.type == other.type && this.path == other.path && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, path, value, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PathLookupFilter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index abc37a0a..8b2ed686 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -32,8 +32,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the project */ fun id(): String = id.getRequired("id") @@ -95,42 +93,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Project && - this.id == other.id && - this.orgId == other.orgId && - this.name == other.name && - this.created == other.created && - this.deletedAt == other.deletedAt && - this.userId == other.userId && - this.settings == other.settings && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - orgId, - name, - created, - deletedAt, - userId, - settings, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -237,4 +199,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Project && this.id == other.id && this.orgId == other.orgId && this.name == other.name && this.created == other.created && this.deletedAt == other.deletedAt && this.userId == other.userId && this.settings == other.settings && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, orgId, name, created, deletedAt, userId, settings, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 6a037704..bcb55527 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -49,8 +49,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the project */ @JsonProperty("name") fun name(): String? = name @@ -67,32 +65,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectCreateBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -143,6 +115,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectCreateBody && this.name == other.name && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, orgName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -156,22 +148,11 @@ constructor( return true } - return other is ProjectCreateParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 830d84e9..132d0c2a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is ProjectDeleteParams && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectDeleteParams && this.projectId == other.projectId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index 11d4f3b9..fece2a7d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is ProjectListPage && - this.projectsService == other.projectsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ProjectListPage && this.projectsService == other.projectsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ } override fun toString() = @@ -127,13 +120,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 15bb897c..401fb412 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is ProjectListPageAsync && - this.projectsService == other.projectsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ProjectListPageAsync && this.projectsService == other.projectsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ } override fun toString() = @@ -134,13 +127,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 9cd5e09b..19ebdba0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -68,28 +68,11 @@ constructor( return true } - return other is ProjectListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ProjectListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -151,7 +134,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -271,11 +254,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -309,6 +292,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 5d6b1011..b94e9eb8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -50,8 +50,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** A list of project logs feedback items */ @JsonProperty("feedback") fun feedback(): List? = feedback @@ -61,26 +59,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -124,6 +102,26 @@ constructor( additionalProperties.toUnmodifiable() ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogFeedbackBody && this.feedback == other.feedback && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(feedback, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -137,22 +135,11 @@ constructor( return true } - return other is ProjectLogFeedbackParams && - this.projectId == other.projectId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectLogFeedbackParams && this.projectId == other.projectId && this.feedback == other.feedback && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectId, feedback, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 75f643a0..c24ff3ad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -58,26 +58,11 @@ constructor( return true } - return other is ProjectLogFetchParams && - this.projectId == other.projectId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ProjectLogFetchParams && this.projectId == other.projectId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index fe4aed35..8b156a99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -79,8 +79,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** * An opaque string to be used as a cursor for the next page of results, in order from * latest to earliest. @@ -159,40 +157,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -320,6 +284,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -333,32 +317,11 @@ constructor( return true } - return other is ProjectLogFetchPostParams && - this.projectId == other.projectId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index abe096e9..02042d61 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -61,8 +61,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** A list of project logs events to insert */ @JsonProperty("events") fun events(): List? = events @@ -72,26 +70,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -132,6 +110,26 @@ constructor( additionalProperties.toUnmodifiable() ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogInsertBody && this.events == other.events && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(events, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -145,22 +143,11 @@ constructor( return true } - return other is ProjectLogInsertParams && - this.projectId == other.projectId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectLogInsertParams && this.projectId == other.projectId && this.events == other.events && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectId, events, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -322,13 +309,11 @@ constructor( return true } - return other is Event && - this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && - this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge + return /* spotless:off */ other is Event && this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) + return /* spotless:off */ Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) /* spotless:on */ } override fun toString(): String { @@ -374,6 +359,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Event { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 7fec3828..baabf2e2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -47,8 +47,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you @@ -294,66 +292,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogsEvent && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.orgId == other.orgId && - this.projectId == other.projectId && - this.logId == other.logId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -690,7 +628,7 @@ private constructor( return true } - return other is LogId && this.value == other.value + return /* spotless:off */ other is LogId && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -745,8 +683,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The function in code which created the project logs event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) @@ -785,34 +721,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -887,6 +795,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -905,8 +833,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -919,23 +845,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -966,6 +875,25 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } /** @@ -987,8 +915,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * A unix timestamp recording when the section of code which produced the project logs event * started @@ -1064,38 +990,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1213,6 +1107,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" } /** @@ -1233,8 +1147,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1247,23 +1159,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1294,6 +1189,25 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" } /** Human-identifying attributes of the span, such as name, type, etc. */ @@ -1308,8 +1222,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the span, for display purposes only */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -1336,32 +1248,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1431,7 +1317,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1498,5 +1384,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogsEvent && this.id == other.id && this._xactId == other._xactId && this.created == other.created && this.orgId == other.orgId && this.projectId == other.projectId && this.logId == other.logId && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanId == other.spanId && this.spanParents == other.spanParents && this.rootSpanId == other.rootSpanId && this.spanAttributes == other.spanAttributes && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, _xactId, created, orgId, projectId, logId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, spanAttributes, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 37a0e287..8c8116df 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is ProjectRetrieveParams && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ProjectRetrieveParams && this.projectId == other.projectId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(projectId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun 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 41a70ed4..6f268c6e 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 @@ -46,8 +46,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the project score */ fun id(): String = id.getRequired("id") @@ -126,48 +124,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScore && - this.id == other.id && - this.projectId == other.projectId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.config == other.config && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - projectId, - userId, - created, - name, - description, - scoreType, - categories, - config, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectScore{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, scoreType=$scoreType, categories=$categories, config=$config, position=$position, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -308,9 +264,9 @@ private constructor( @JsonSerialize(using = Categories.Serializer::class) class Categories private constructor( - private val projectScoreCategories: List? = null, + private val categorical: List? = null, private val weighted: Weighted? = null, - private val strings: List? = null, + private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -318,29 +274,27 @@ private constructor( private var validated: Boolean = false /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): Optional> = - Optional.ofNullable(projectScoreCategories) + fun categorical(): Optional> = Optional.ofNullable(categorical) /** For weighted-type project scores, the weights of each score */ fun weighted(): Optional = Optional.ofNullable(weighted) /** For minimum-type project scores, the list of included scores */ - fun strings(): Optional> = Optional.ofNullable(strings) + fun minimum(): Optional> = Optional.ofNullable(minimum) fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isProjectScoreCategories(): Boolean = projectScoreCategories != null + fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null - fun isStrings(): Boolean = strings != null + fun isMinimum(): Boolean = minimum != null fun isNullableVariant(): Boolean = nullableVariant != null - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") + fun asCategorical(): List = categorical.getOrThrow("categorical") fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - fun asStrings(): List = strings.getOrThrow("strings") + fun asMinimum(): List = minimum.getOrThrow("minimum") fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") @@ -348,10 +302,9 @@ private constructor( fun accept(visitor: Visitor): T { return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) + categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) + minimum != null -> visitor.visitMinimum(minimum) nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } @@ -360,14 +313,14 @@ private constructor( fun validate(): Categories = apply { if (!validated) { if ( - projectScoreCategories == null && + categorical == null && weighted == null && - strings == null && + minimum == null && nullableVariant == null ) { throw BraintrustInvalidDataException("Unknown Categories: $_json") } - projectScoreCategories?.forEach { it.validate() } + categorical?.forEach { it.validate() } weighted?.validate() nullableVariant?.validate() validated = true @@ -379,28 +332,18 @@ private constructor( return true } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant + return /* spotless:off */ other is Categories && this.categorical == other.categorical && this.weighted == other.weighted && this.minimum == other.minimum && this.nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) + return /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ } override fun toString(): String { return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" + categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" + minimum != null -> "Categories{minimum=$minimum}" nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") @@ -410,12 +353,12 @@ private constructor( companion object { @JvmStatic - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) + fun ofCategorical(categorical: List) = + Categories(categorical = categorical) @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) + @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic fun ofNullableVariant(nullableVariant: NullableVariant) = @@ -424,11 +367,11 @@ private constructor( interface Visitor { - fun visitProjectScoreCategories(projectScoreCategories: List): T + fun visitCategorical(categorical: List): T fun visitWeighted(weighted: Weighted): T - fun visitStrings(strings: List): T + fun visitMinimum(minimum: List): T fun visitNullableVariant(nullableVariant: NullableVariant): T @@ -441,18 +384,19 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Categories { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } } ?.let { - return Categories(projectScoreCategories = it, _json = json) + return Categories(categorical = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Categories(weighted = it, _json = json) } tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) + return Categories(minimum = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -471,10 +415,9 @@ private constructor( provider: SerializerProvider ) { when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) + value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) + value.minimum != null -> generator.writeObject(value.minimum) value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") @@ -492,8 +435,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -506,23 +447,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Weighted && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Weighted{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -554,6 +478,25 @@ private constructor( fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Weighted && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = NullableVariant.Builder::class) @@ -565,8 +508,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -579,24 +520,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -629,6 +552,45 @@ private constructor( fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return /* spotless:off */ other is ProjectScore && this.id == other.id && this.projectId == other.projectId && this.userId == other.userId && this.created == other.created && this.name == other.name && this.description == other.description && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.position == other.position && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, projectId, userId, created, name, description, scoreType, categories, config, position, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectScore{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, scoreType=$scoreType, categories=$categories, config=$config, position=$position, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index e7c56679..b131ecb5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -26,8 +26,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the category */ fun name(): String = name.getRequired("name") @@ -54,32 +52,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreCategory && - this.name == other.name && - this.value == other.value && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - value, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -135,4 +107,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreCategory && this.name == other.name && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, value, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index af9b299e..b60f236b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -30,8 +30,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun multiSelect(): Optional = Optional.ofNullable(multiSelect.getNullable("multi_select")) @@ -61,34 +59,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreConfig && - this.multiSelect == other.multiSelect && - this.destination == other.destination && - this.online == other.online && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - multiSelect, - destination, - online, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectScoreConfig{multiSelect=$multiSelect, destination=$destination, online=$online, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -165,7 +135,7 @@ private constructor( return true } - return other is Destination && this.value == other.value + return /* spotless:off */ other is Destination && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -202,4 +172,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreConfig && this.multiSelect == other.multiSelect && this.destination == other.destination && this.online == other.online && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(multiSelect, destination, online, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectScoreConfig{multiSelect=$multiSelect, destination=$destination, online=$online, additionalProperties=$additionalProperties}" } 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 f2731c38..daf1406f 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 @@ -79,8 +79,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the project score */ @JsonProperty("name") fun name(): String? = name @@ -103,40 +101,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.config == other.config && - this.description == other.description && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - scoreType, - categories, - config, - description, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -209,6 +173,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreCreateBody && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -222,30 +206,11 @@ constructor( return true } - return other is ProjectScoreCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.config == other.config && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectScoreCreateParams && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - scoreType, - categories, - config, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -297,8 +262,8 @@ constructor( fun categories(categories: Categories) = apply { this.categories = categories } /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(projectScoreCategories: List) = apply { - this.categories = Categories.ofProjectScoreCategories(projectScoreCategories) + fun categoriesOfCategorical(categorical: List) = apply { + this.categories = Categories.ofCategorical(categorical) } /** For categorical-type project scores, the list of all categories */ @@ -307,8 +272,8 @@ constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(strings: List) = apply { - this.categories = Categories.ofStrings(strings) + fun categoriesOfMinimum(minimum: List) = apply { + this.categories = Categories.ofMinimum(minimum) } /** For categorical-type project scores, the list of all categories */ @@ -393,9 +358,9 @@ constructor( @JsonSerialize(using = Categories.Serializer::class) class Categories private constructor( - private val projectScoreCategories: List? = null, + private val categorical: List? = null, private val weighted: Weighted? = null, - private val strings: List? = null, + private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -403,29 +368,27 @@ constructor( private var validated: Boolean = false /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): Optional> = - Optional.ofNullable(projectScoreCategories) + fun categorical(): Optional> = Optional.ofNullable(categorical) /** For weighted-type project scores, the weights of each score */ fun weighted(): Optional = Optional.ofNullable(weighted) /** For minimum-type project scores, the list of included scores */ - fun strings(): Optional> = Optional.ofNullable(strings) + fun minimum(): Optional> = Optional.ofNullable(minimum) fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isProjectScoreCategories(): Boolean = projectScoreCategories != null + fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null - fun isStrings(): Boolean = strings != null + fun isMinimum(): Boolean = minimum != null fun isNullableVariant(): Boolean = nullableVariant != null - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") + fun asCategorical(): List = categorical.getOrThrow("categorical") fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - fun asStrings(): List = strings.getOrThrow("strings") + fun asMinimum(): List = minimum.getOrThrow("minimum") fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") @@ -433,10 +396,9 @@ constructor( fun accept(visitor: Visitor): T { return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) + categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) + minimum != null -> visitor.visitMinimum(minimum) nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } @@ -445,14 +407,14 @@ constructor( fun validate(): Categories = apply { if (!validated) { if ( - projectScoreCategories == null && + categorical == null && weighted == null && - strings == null && + minimum == null && nullableVariant == null ) { throw BraintrustInvalidDataException("Unknown Categories: $_json") } - projectScoreCategories?.forEach { it.validate() } + categorical?.forEach { it.validate() } weighted?.validate() nullableVariant?.validate() validated = true @@ -464,28 +426,18 @@ constructor( return true } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant + return /* spotless:off */ other is Categories && this.categorical == other.categorical && this.weighted == other.weighted && this.minimum == other.minimum && this.nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) + return /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ } override fun toString(): String { return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" + categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" + minimum != null -> "Categories{minimum=$minimum}" nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") @@ -495,12 +447,12 @@ constructor( companion object { @JvmStatic - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) + fun ofCategorical(categorical: List) = + Categories(categorical = categorical) @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) + @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic fun ofNullableVariant(nullableVariant: NullableVariant) = @@ -509,11 +461,11 @@ constructor( interface Visitor { - fun visitProjectScoreCategories(projectScoreCategories: List): T + fun visitCategorical(categorical: List): T fun visitWeighted(weighted: Weighted): T - fun visitStrings(strings: List): T + fun visitMinimum(minimum: List): T fun visitNullableVariant(nullableVariant: NullableVariant): T @@ -526,18 +478,19 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Categories { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } } ?.let { - return Categories(projectScoreCategories = it, _json = json) + return Categories(categorical = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Categories(weighted = it, _json = json) } tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) + return Categories(minimum = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -556,10 +509,9 @@ constructor( provider: SerializerProvider ) { when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) + value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) + value.minimum != null -> generator.writeObject(value.minimum) value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") @@ -577,8 +529,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -591,23 +541,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Weighted && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Weighted{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -639,6 +572,25 @@ constructor( fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Weighted && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = NullableVariant.Builder::class) @@ -650,8 +602,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -664,24 +614,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -714,6 +646,25 @@ constructor( fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 23ff689d..a528d830 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is ProjectScoreDeleteParams && - this.projectScoreId == other.projectScoreId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectScoreDeleteParams && this.projectScoreId == other.projectScoreId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectScoreId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index f638afa9..b7a3af06 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is ProjectScoreListPage && - this.projectScoresService == other.projectScoresService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ProjectScoreListPage && this.projectScoresService == other.projectScoresService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoresService, - params, - response, - ) + return /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ } override fun toString() = @@ -131,13 +124,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index 961d9012..6efe963c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is ProjectScoreListPageAsync && - this.projectScoresService == other.projectScoresService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ProjectScoreListPageAsync && this.projectScoresService == other.projectScoresService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoresService, - params, - response, - ) + return /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ } override fun toString() = @@ -134,13 +127,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = 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 a2d3f5fd..ab95668d 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 @@ -80,34 +80,11 @@ constructor( return true } - return other is ProjectScoreListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.projectScoreName == other.projectScoreName && - this.scoreType == other.scoreType && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ProjectScoreListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.projectScoreName == other.projectScoreName && this.scoreType == other.scoreType && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectScoreName, - scoreType, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -175,7 +152,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -203,7 +180,7 @@ constructor( } /** The type of the configured score */ - fun scoreType(projectScoreTypes: List) = apply { + fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = apply { this.scoreType = ScoreType.ofProjectScoreTypes(projectScoreTypes) } @@ -319,11 +296,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -357,6 +334,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } @@ -435,13 +413,11 @@ constructor( return true } - return other is ScoreType && - this.projectScoreType == other.projectScoreType && - this.projectScoreTypes == other.projectScoreTypes + return /* spotless:off */ other is ScoreType && this.projectScoreType == other.projectScoreType && this.projectScoreTypes == other.projectScoreTypes /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(projectScoreType, projectScoreTypes) + return /* spotless:off */ Objects.hash(projectScoreType, projectScoreTypes) /* spotless:on */ } override fun toString(): String { @@ -479,6 +455,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): ScoreType { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return ScoreType(projectScoreType = it, _json = json) } 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 0b4b5f51..b41f3386 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 @@ -79,8 +79,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the project score */ @JsonProperty("name") fun name(): String? = name @@ -103,40 +101,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.config == other.config && - this.description == other.description && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - scoreType, - categories, - config, - description, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -209,6 +173,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreReplaceBody && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -222,30 +206,11 @@ constructor( return true } - return other is ProjectScoreReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.config == other.config && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectScoreReplaceParams && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - scoreType, - categories, - config, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -297,8 +262,8 @@ constructor( fun categories(categories: Categories) = apply { this.categories = categories } /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(projectScoreCategories: List) = apply { - this.categories = Categories.ofProjectScoreCategories(projectScoreCategories) + fun categoriesOfCategorical(categorical: List) = apply { + this.categories = Categories.ofCategorical(categorical) } /** For categorical-type project scores, the list of all categories */ @@ -307,8 +272,8 @@ constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(strings: List) = apply { - this.categories = Categories.ofStrings(strings) + fun categoriesOfMinimum(minimum: List) = apply { + this.categories = Categories.ofMinimum(minimum) } /** For categorical-type project scores, the list of all categories */ @@ -393,9 +358,9 @@ constructor( @JsonSerialize(using = Categories.Serializer::class) class Categories private constructor( - private val projectScoreCategories: List? = null, + private val categorical: List? = null, private val weighted: Weighted? = null, - private val strings: List? = null, + private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -403,29 +368,27 @@ constructor( private var validated: Boolean = false /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): Optional> = - Optional.ofNullable(projectScoreCategories) + fun categorical(): Optional> = Optional.ofNullable(categorical) /** For weighted-type project scores, the weights of each score */ fun weighted(): Optional = Optional.ofNullable(weighted) /** For minimum-type project scores, the list of included scores */ - fun strings(): Optional> = Optional.ofNullable(strings) + fun minimum(): Optional> = Optional.ofNullable(minimum) fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isProjectScoreCategories(): Boolean = projectScoreCategories != null + fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null - fun isStrings(): Boolean = strings != null + fun isMinimum(): Boolean = minimum != null fun isNullableVariant(): Boolean = nullableVariant != null - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") + fun asCategorical(): List = categorical.getOrThrow("categorical") fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - fun asStrings(): List = strings.getOrThrow("strings") + fun asMinimum(): List = minimum.getOrThrow("minimum") fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") @@ -433,10 +396,9 @@ constructor( fun accept(visitor: Visitor): T { return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) + categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) + minimum != null -> visitor.visitMinimum(minimum) nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } @@ -445,14 +407,14 @@ constructor( fun validate(): Categories = apply { if (!validated) { if ( - projectScoreCategories == null && + categorical == null && weighted == null && - strings == null && + minimum == null && nullableVariant == null ) { throw BraintrustInvalidDataException("Unknown Categories: $_json") } - projectScoreCategories?.forEach { it.validate() } + categorical?.forEach { it.validate() } weighted?.validate() nullableVariant?.validate() validated = true @@ -464,28 +426,18 @@ constructor( return true } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant + return /* spotless:off */ other is Categories && this.categorical == other.categorical && this.weighted == other.weighted && this.minimum == other.minimum && this.nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) + return /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ } override fun toString(): String { return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" + categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" + minimum != null -> "Categories{minimum=$minimum}" nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") @@ -495,12 +447,12 @@ constructor( companion object { @JvmStatic - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) + fun ofCategorical(categorical: List) = + Categories(categorical = categorical) @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) + @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic fun ofNullableVariant(nullableVariant: NullableVariant) = @@ -509,11 +461,11 @@ constructor( interface Visitor { - fun visitProjectScoreCategories(projectScoreCategories: List): T + fun visitCategorical(categorical: List): T fun visitWeighted(weighted: Weighted): T - fun visitStrings(strings: List): T + fun visitMinimum(minimum: List): T fun visitNullableVariant(nullableVariant: NullableVariant): T @@ -526,18 +478,19 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Categories { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } } ?.let { - return Categories(projectScoreCategories = it, _json = json) + return Categories(categorical = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Categories(weighted = it, _json = json) } tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) + return Categories(minimum = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -556,10 +509,9 @@ constructor( provider: SerializerProvider ) { when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) + value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) + value.minimum != null -> generator.writeObject(value.minimum) value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") @@ -577,8 +529,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -591,23 +541,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Weighted && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Weighted{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -639,6 +572,25 @@ constructor( fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Weighted && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = NullableVariant.Builder::class) @@ -650,8 +602,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -664,24 +614,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -714,6 +646,25 @@ constructor( fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index cf6919d4..7ff755d1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is ProjectScoreRetrieveParams && - this.projectScoreId == other.projectScoreId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ProjectScoreRetrieveParams && this.projectScoreId == other.projectScoreId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(projectScoreId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = 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 index fb9ec5be..2d9449e0 100644 --- 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 @@ -21,7 +21,7 @@ private constructor( return true } - return other is ProjectScoreType && this.value == other.value + return /* spotless:off */ other is ProjectScoreType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() 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 3d7a8fa9..834c61b5 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 @@ -84,8 +84,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - @JsonProperty("categories") fun categories(): Categories? = categories @JsonProperty("config") fun config(): ProjectScoreConfig? = config @@ -105,38 +103,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreUpdateBody && - this.categories == other.categories && - this.config == other.config && - this.description == other.description && - this.name == other.name && - this.scoreType == other.scoreType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - categories, - config, - description, - name, - scoreType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectScoreUpdateBody{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -202,6 +168,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreUpdateBody && this.categories == other.categories && this.config == other.config && this.description == other.description && this.name == other.name && this.scoreType == other.scoreType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(categories, config, description, name, scoreType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectScoreUpdateBody{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -215,30 +201,11 @@ constructor( return true } - return other is ProjectScoreUpdateParams && - this.projectScoreId == other.projectScoreId && - this.categories == other.categories && - this.config == other.config && - this.description == other.description && - this.name == other.name && - this.scoreType == other.scoreType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectScoreUpdateParams && this.projectScoreId == other.projectScoreId && this.categories == other.categories && this.config == other.config && this.description == other.description && this.name == other.name && this.scoreType == other.scoreType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - categories, - config, - description, - name, - scoreType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectScoreId, categories, config, description, name, scoreType, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -284,8 +251,8 @@ constructor( fun categories(categories: Categories) = apply { this.categories = categories } /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(projectScoreCategories: List) = apply { - this.categories = Categories.ofProjectScoreCategories(projectScoreCategories) + fun categoriesOfCategorical(categorical: List) = apply { + this.categories = Categories.ofCategorical(categorical) } /** For categorical-type project scores, the list of all categories */ @@ -294,8 +261,8 @@ constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(strings: List) = apply { - this.categories = Categories.ofStrings(strings) + fun categoriesOfMinimum(minimum: List) = apply { + this.categories = Categories.ofMinimum(minimum) } /** For categorical-type project scores, the list of all categories */ @@ -386,9 +353,9 @@ constructor( @JsonSerialize(using = Categories.Serializer::class) class Categories private constructor( - private val projectScoreCategories: List? = null, + private val categorical: List? = null, private val weighted: Weighted? = null, - private val strings: List? = null, + private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -396,29 +363,27 @@ constructor( private var validated: Boolean = false /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): Optional> = - Optional.ofNullable(projectScoreCategories) + fun categorical(): Optional> = Optional.ofNullable(categorical) /** For weighted-type project scores, the weights of each score */ fun weighted(): Optional = Optional.ofNullable(weighted) /** For minimum-type project scores, the list of included scores */ - fun strings(): Optional> = Optional.ofNullable(strings) + fun minimum(): Optional> = Optional.ofNullable(minimum) fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isProjectScoreCategories(): Boolean = projectScoreCategories != null + fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null - fun isStrings(): Boolean = strings != null + fun isMinimum(): Boolean = minimum != null fun isNullableVariant(): Boolean = nullableVariant != null - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") + fun asCategorical(): List = categorical.getOrThrow("categorical") fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - fun asStrings(): List = strings.getOrThrow("strings") + fun asMinimum(): List = minimum.getOrThrow("minimum") fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") @@ -426,10 +391,9 @@ constructor( fun accept(visitor: Visitor): T { return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) + categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) + minimum != null -> visitor.visitMinimum(minimum) nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } @@ -438,14 +402,14 @@ constructor( fun validate(): Categories = apply { if (!validated) { if ( - projectScoreCategories == null && + categorical == null && weighted == null && - strings == null && + minimum == null && nullableVariant == null ) { throw BraintrustInvalidDataException("Unknown Categories: $_json") } - projectScoreCategories?.forEach { it.validate() } + categorical?.forEach { it.validate() } weighted?.validate() nullableVariant?.validate() validated = true @@ -457,28 +421,18 @@ constructor( return true } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant + return /* spotless:off */ other is Categories && this.categorical == other.categorical && this.weighted == other.weighted && this.minimum == other.minimum && this.nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) + return /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ } override fun toString(): String { return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" + categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" + minimum != null -> "Categories{minimum=$minimum}" nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") @@ -488,12 +442,12 @@ constructor( companion object { @JvmStatic - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) + fun ofCategorical(categorical: List) = + Categories(categorical = categorical) @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - @JvmStatic fun ofStrings(strings: List) = Categories(strings = strings) + @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic fun ofNullableVariant(nullableVariant: NullableVariant) = @@ -502,11 +456,11 @@ constructor( interface Visitor { - fun visitProjectScoreCategories(projectScoreCategories: List): T + fun visitCategorical(categorical: List): T fun visitWeighted(weighted: Weighted): T - fun visitStrings(strings: List): T + fun visitMinimum(minimum: List): T fun visitNullableVariant(nullableVariant: NullableVariant): T @@ -519,18 +473,19 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Categories { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef>()) { it.forEach { it.validate() } } ?.let { - return Categories(projectScoreCategories = it, _json = json) + return Categories(categorical = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Categories(weighted = it, _json = json) } tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) + return Categories(minimum = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -549,10 +504,9 @@ constructor( provider: SerializerProvider ) { when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) + value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) + value.minimum != null -> generator.writeObject(value.minimum) value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") @@ -570,8 +524,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -584,23 +536,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Weighted && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Weighted{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -632,6 +567,25 @@ constructor( fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Weighted && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = NullableVariant.Builder::class) @@ -643,8 +597,6 @@ constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -657,24 +609,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -707,6 +641,25 @@ constructor( fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index d4a8c8cb..d14a8707 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -25,8 +25,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** The key used to join two experiments (defaults to `input`). */ fun comparisonKey(): Optional = Optional.ofNullable(comparisonKey.getNullable("comparison_key")) @@ -47,26 +45,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectSettings && - this.comparisonKey == other.comparisonKey && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(comparisonKey, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -110,4 +88,24 @@ private constructor( fun build(): ProjectSettings = ProjectSettings(comparisonKey, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectSettings && this.comparisonKey == other.comparisonKey && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(comparisonKey, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 61b80ba9..aa10d385 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -36,8 +36,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the project tag */ fun id(): String = id.getRequired("id") @@ -98,42 +96,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTag && - this.id == other.id && - this.projectId == other.projectId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.color == other.color && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - projectId, - userId, - created, - name, - description, - color, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectTag{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -240,4 +202,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTag && this.id == other.id && this.projectId == other.projectId && this.userId == other.userId && this.created == other.created && this.name == other.name && this.description == other.description && this.color == other.color && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, projectId, userId, created, name, description, color, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectTag{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 9275324e..f31204d8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -59,8 +59,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the project tag */ @JsonProperty("name") fun name(): String? = name @@ -79,36 +77,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - color, - description, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -168,6 +136,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagCreateBody && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -181,26 +169,11 @@ constructor( return true } - return other is ProjectTagCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectTagCreateParams && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - color, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, projectId, color, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 26f9294d..71458816 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is ProjectTagDeleteParams && - this.projectTagId == other.projectTagId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectTagDeleteParams && this.projectTagId == other.projectTagId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectTagId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 065e040c..f93071d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is ProjectTagListPage && - this.projectTagsService == other.projectTagsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ProjectTagListPage && this.projectTagsService == other.projectTagsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectTagsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ } override fun toString() = @@ -131,13 +124,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 403a1798..aee77897 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is ProjectTagListPageAsync && - this.projectTagsService == other.projectTagsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ProjectTagListPageAsync && this.projectTagsService == other.projectTagsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectTagsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ } override fun toString() = @@ -134,13 +127,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 893d676e..9b43b54d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -76,32 +76,11 @@ constructor( return true } - return other is ProjectTagListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.projectTagName == other.projectTagName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ProjectTagListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.projectTagName == other.projectTagName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectTagName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -167,7 +146,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -295,11 +274,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -333,6 +312,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index 28a4613d..51a0bdba 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -59,8 +59,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the project tag */ @JsonProperty("name") fun name(): String? = name @@ -79,36 +77,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - color, - description, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -168,6 +136,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagReplaceBody && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -181,26 +169,11 @@ constructor( return true } - return other is ProjectTagReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectTagReplaceParams && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - color, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, projectId, color, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 1fa19f4b..90f5a22a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is ProjectTagRetrieveParams && - this.projectTagId == other.projectTagId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ProjectTagRetrieveParams && this.projectTagId == other.projectTagId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(projectTagId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index e8f94d38..3641ff1a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -64,8 +64,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Color of the tag for the UI */ @JsonProperty("color") fun color(): String? = color @@ -81,34 +79,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagUpdateBody && - this.color == other.color && - this.description == other.description && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - color, - description, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -161,6 +131,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagUpdateBody && this.color == other.color && this.description == other.description && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(color, description, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -174,26 +164,11 @@ constructor( return true } - return other is ProjectTagUpdateParams && - this.projectTagId == other.projectTagId && - this.color == other.color && - this.description == other.description && - this.name == other.name && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectTagUpdateParams && this.projectTagId == other.projectTagId && this.color == other.color && this.description == other.description && this.name == other.name && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - color, - description, - name, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectTagId, color, description, name, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index b9770377..505467b5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -59,8 +59,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the project */ @JsonProperty("name") fun name(): String? = name @@ -76,32 +74,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectUpdateBody && - this.name == other.name && - this.settings == other.settings && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - settings, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -151,6 +123,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectUpdateBody && this.name == other.name && this.settings == other.settings && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, settings, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -164,24 +156,11 @@ constructor( return true } - return other is ProjectUpdateParams && - this.projectId == other.projectId && - this.name == other.name && - this.settings == other.settings && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ProjectUpdateParams && this.projectId == other.projectId && this.name == other.name && this.settings == other.settings && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - projectId, - name, - settings, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(projectId, name, settings, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 3805046d..e4c891cf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -41,8 +41,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") @@ -155,54 +153,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.functionType == other.functionType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - functionType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -399,7 +349,7 @@ private constructor( return true } - return other is LogId && this.value == other.value + return /* spotless:off */ other is LogId && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -450,7 +400,7 @@ private constructor( return true } - return other is FunctionType && this.value == other.value + return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -516,8 +466,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -530,23 +478,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -577,5 +508,44 @@ private constructor( fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Prompt && this.id == other.id && this._xactId == other._xactId && this.projectId == other.projectId && this.logId == other.logId && this.orgId == other.orgId && this.name == other.name && this.slug == other.slug && this.description == other.description && this.created == other.created && this.promptData == other.promptData && this.tags == other.tags && this.metadata == other.metadata && this.functionType == other.functionType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, _xactId, projectId, logId, orgId, name, slug, description, created, promptData, tags, metadata, functionType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 5ed64365..d31c2b09 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -78,8 +78,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the prompt */ @JsonProperty("name") fun name(): String? = name @@ -106,42 +104,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -222,6 +184,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptCreateBody && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -235,32 +217,11 @@ constructor( return true } - return other is PromptCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is PromptCreateParams && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -409,7 +370,7 @@ constructor( return true } - return other is FunctionType && this.value == other.value + return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 05402b44..f3c3be56 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -42,8 +42,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -82,38 +80,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.parser == other.parser && - this.toolFunctions == other.toolFunctions && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - prompt, - options, - parser, - toolFunctions, - origin, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptData{prompt=$prompt, options=$options, parser=$parser, toolFunctions=$toolFunctions, origin=$origin, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -208,8 +174,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) fun params(): Optional = Optional.ofNullable(params.getNullable("params")) @@ -237,34 +201,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -421,22 +357,11 @@ private constructor( return true } - return other is Params && - this.openaiModelParams == other.openaiModelParams && - this.anthropicModelParams == other.anthropicModelParams && - this.googleModelParams == other.googleModelParams && - this.windowAiModelParams == other.windowAiModelParams && - this.jsCompletionParams == other.jsCompletionParams + return /* spotless:off */ other is Params && this.openaiModelParams == other.openaiModelParams && this.anthropicModelParams == other.anthropicModelParams && this.googleModelParams == other.googleModelParams && this.windowAiModelParams == other.windowAiModelParams && this.jsCompletionParams == other.jsCompletionParams /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - openaiModelParams, - anthropicModelParams, - googleModelParams, - windowAiModelParams, - jsCompletionParams, - ) + return /* spotless:off */ Objects.hash(openaiModelParams, anthropicModelParams, googleModelParams, windowAiModelParams, jsCompletionParams) /* spotless:on */ } override fun toString(): String { @@ -497,6 +422,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Params { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Params(openaiModelParams = it, _json = json) @@ -566,8 +492,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @@ -649,50 +573,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OpenAIModelParams && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -901,18 +781,11 @@ private constructor( return true } - return other is FunctionCall && - this.auto == other.auto && - this.none == other.none && - this.function == other.function + return /* spotless:off */ other is FunctionCall && this.auto == other.auto && this.none == other.none && this.function == other.function /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - auto, - none, - function, - ) + return /* spotless:off */ Objects.hash(auto, none, function) /* spotless:on */ } override fun toString(): String { @@ -952,6 +825,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return FunctionCall(auto = it, _json = json) } @@ -998,7 +872,7 @@ private constructor( return true } - return other is Auto && this.value == other.value + return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1050,7 +924,7 @@ private constructor( return true } - return other is None && this.value == other.value + return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1098,8 +972,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun name(): String = name.getRequired("name") @JsonProperty("name") @ExcludeMissing fun _name() = name @@ -1117,26 +989,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1178,6 +1030,26 @@ private constructor( fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" } } @@ -1191,8 +1063,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") @JsonProperty("type") @ExcludeMissing fun _type() = type @@ -1210,26 +1080,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1286,7 +1136,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1323,7 +1173,47 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ResponseFormat && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OpenAIModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.topP == other.topP && this.maxTokens == other.maxTokens && this.frequencyPenalty == other.frequencyPenalty && this.presencePenalty == other.presencePenalty && this.responseFormat == other.responseFormat && this.toolChoice == other.toolChoice && this.functionCall == other.functionCall && this.n == other.n && this.stop == other.stop && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, temperature, topP, maxTokens, frequencyPenalty, presencePenalty, responseFormat, toolChoice, functionCall, n, stop, additionalProperties) /* spotless:on */ + } + return hashCode } + + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @@ -1342,8 +1232,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @@ -1398,42 +1286,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AnthropicModelParams && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1543,6 +1395,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AnthropicModelParams && this.useCache == other.useCache && this.maxTokens == other.maxTokens && this.temperature == other.temperature && this.topP == other.topP && this.topK == other.topK && this.stopSequences == other.stopSequences && this.maxTokensToSample == other.maxTokensToSample && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, maxTokens, temperature, topP, topK, stopSequences, maxTokensToSample, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = GoogleModelParams.Builder::class) @@ -1559,8 +1431,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @@ -1603,38 +1473,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GoogleModelParams && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1719,6 +1557,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GoogleModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.maxOutputTokens == other.maxOutputTokens && this.topP == other.topP && this.topK == other.topK && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, temperature, maxOutputTokens, topP, topK, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @@ -1733,8 +1591,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @@ -1764,34 +1620,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is WindowAiModelParams && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1855,20 +1683,38 @@ private constructor( additionalProperties.toUnmodifiable(), ) } - } - - @JsonDeserialize(builder = JsCompletionParams.Builder::class) - @NoAutoDetect - class JsCompletionParams - private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is WindowAiModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.topK == other.topK && this.additionalProperties == other.additionalProperties /* spotless:on */ + } private var hashCode: Int = 0 + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, temperature, topK, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = JsCompletionParams.Builder::class) + @NoAutoDetect + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @@ -1887,26 +1733,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JsCompletionParams && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode - } - - override fun toString() = - "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -1947,8 +1773,48 @@ private constructor( fun build(): JsCompletionParams = JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is JsCompletionParams && this.useCache == other.useCache && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Options && this.model == other.model && this.params == other.params && this.position == other.position && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(model, params, position, additionalProperties) /* spotless:on */ } + return hashCode } + + override fun toString() = + "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Origin.Builder::class) @@ -1963,8 +1829,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun promptId(): Optional = Optional.ofNullable(promptId.getNullable("prompt_id")) fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) @@ -1993,34 +1857,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2083,6 +1919,26 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Origin && this.promptId == other.promptId && this.projectId == other.projectId && this.promptVersion == other.promptVersion && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(promptId, projectId, promptVersion, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Parser.Builder::class) @@ -2097,8 +1953,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun useCot(): Boolean = useCot.getRequired("use_cot") @@ -2126,34 +1980,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parser && - this.type == other.type && - this.useCot == other.useCot && - this.choiceScores == other.choiceScores && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - useCot, - choiceScores, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Parser{type=$type, useCot=$useCot, choiceScores=$choiceScores, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2226,8 +2052,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -2240,24 +2064,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ChoiceScores && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "ChoiceScores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2289,6 +2095,25 @@ private constructor( fun build(): ChoiceScores = ChoiceScores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChoiceScores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "ChoiceScores{additionalProperties=$additionalProperties}" } class Type @@ -2304,7 +2129,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2341,6 +2166,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Parser && this.type == other.type && this.useCot == other.useCot && this.choiceScores == other.choiceScores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, useCot, choiceScores, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Parser{type=$type, useCot=$useCot, choiceScores=$choiceScores, additionalProperties=$additionalProperties}" } @JsonDeserialize(using = Prompt.Deserializer::class) @@ -2401,18 +2246,11 @@ private constructor( return true } - return other is Prompt && - this.completion == other.completion && - this.chat == other.chat && - this.nullableVariant == other.nullableVariant + return /* spotless:off */ other is Prompt && this.completion == other.completion && this.chat == other.chat && this.nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - completion, - chat, - nullableVariant, - ) + return /* spotless:off */ Objects.hash(completion, chat, nullableVariant) /* spotless:on */ } override fun toString(): String { @@ -2453,6 +2291,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Prompt { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Prompt(completion = it, _json = json) @@ -2498,8 +2337,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun content(): String = content.getRequired("content") @@ -2522,32 +2359,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Completion && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2614,7 +2425,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2651,6 +2462,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Completion && this.type == other.type && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, content, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Chat.Builder::class) @@ -2665,8 +2496,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun messages(): List = messages.getRequired("messages") @@ -2694,34 +2523,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Chat && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -2878,24 +2679,11 @@ private constructor( return true } - return other is Message && - this.system == other.system && - this.user == other.user && - this.assistant == other.assistant && - this.tool == other.tool && - this.function == other.function && - this.fallback == other.fallback + return /* spotless:off */ other is Message && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - system, - user, - assistant, - tool, - function, - fallback, - ) + return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ } override fun toString(): String { @@ -2950,6 +2738,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Message { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Message(system = it, _json = json) @@ -3011,8 +2800,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) @@ -3041,37 +2828,9 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is System && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -3146,7 +2905,7 @@ private constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3183,6 +2942,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = User.Builder::class) @@ -3197,8 +2976,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) @@ -3227,34 +3004,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is User && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -3332,7 +3081,7 @@ private constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3374,46 +3123,39 @@ private constructor( @JsonSerialize(using = Content.Serializer::class) class Content private constructor( - private val string: String? = null, - private val chatCompletionContentParts: List? = - null, + private val text: String? = null, + private val array: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) + fun text(): Optional = Optional.ofNullable(text) - fun chatCompletionContentParts(): - Optional> = - Optional.ofNullable(chatCompletionContentParts) + fun array(): Optional> = + Optional.ofNullable(array) - fun isString(): Boolean = string != null + fun isText(): Boolean = text != null - fun isChatCompletionContentParts(): Boolean = - chatCompletionContentParts != null + fun isArray(): Boolean = array != null - fun asString(): String = string.getOrThrow("string") + fun asText(): String = text.getOrThrow("text") - fun asChatCompletionContentParts(): List = - chatCompletionContentParts.getOrThrow("chatCompletionContentParts") + fun asArray(): List = array.getOrThrow("array") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - string != null -> visitor.visitString(string) - chatCompletionContentParts != null -> - visitor.visitChatCompletionContentParts( - chatCompletionContentParts - ) + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) else -> visitor.unknown(_json) } } fun validate(): Content = apply { if (!validated) { - if (string == null && chatCompletionContentParts == null) { + if (text == null && array == null) { throw BraintrustInvalidDataException("Unknown Content: $_json") } validated = true @@ -3425,20 +3167,17 @@ private constructor( return true } - return other is Content && - this.string == other.string && - this.chatCompletionContentParts == other.chatCompletionContentParts + return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, chatCompletionContentParts) + return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ } override fun toString(): String { return when { - string != null -> "Content{string=$string}" - chatCompletionContentParts != null -> - "Content{chatCompletionContentParts=$chatCompletionContentParts}" + text != null -> "Content{text=$text}" + array != null -> "Content{array=$array}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } @@ -3446,21 +3185,18 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Content(string = string) + @JvmStatic fun ofText(text: String) = Content(text = text) @JvmStatic - fun ofChatCompletionContentParts( - chatCompletionContentParts: List - ) = Content(chatCompletionContentParts = chatCompletionContentParts) + fun ofArray(array: List) = + Content(array = array) } interface Visitor { - fun visitString(string: String): T + fun visitText(text: String): T - fun visitChatCompletionContentParts( - chatCompletionContentParts: List - ): T + fun visitArray(array: List): T fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Content: $json") @@ -3471,18 +3207,16 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Content { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) + return Content(text = it, _json = json) } tryDeserialize( node, jacksonTypeRef>() ) ?.let { - return Content( - chatCompletionContentParts = it, - _json = json - ) + return Content(array = it, _json = json) } return Content(_json = json) @@ -3497,9 +3231,8 @@ private constructor( provider: SerializerProvider ) { when { - value.string != null -> generator.writeObject(value.string) - value.chatCompletionContentParts != null -> - generator.writeObject(value.chatCompletionContentParts) + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Content") } @@ -3582,18 +3315,11 @@ private constructor( return true } - return other is ChatCompletionContentPart && - this.chatCompletionContentPartText == - other.chatCompletionContentPartText && - this.chatCompletionContentPartImage == - other.chatCompletionContentPartImage + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - chatCompletionContentPartText, - chatCompletionContentPartImage - ) + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ } override fun toString(): String { @@ -3657,6 +3383,7 @@ private constructor( node: JsonNode ): ChatCompletionContentPart { val json = JsonValue.fromJsonNode(node) + tryDeserialize( node, jacksonTypeRef() @@ -3715,6 +3442,26 @@ private constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Assistant.Builder::class) @@ -3731,8 +3478,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun role(): Role = role.getRequired("role") fun content(): Optional = @@ -3775,38 +3520,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Assistant && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -3910,7 +3623,7 @@ private constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3959,8 +3672,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") @@ -3983,32 +3694,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -4064,7 +3749,47 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Tool.Builder::class) @@ -4079,8 +3804,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) @@ -4110,34 +3833,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tool && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -4217,7 +3912,7 @@ private constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4254,6 +3949,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Function.Builder::class) @@ -4268,8 +3983,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) @@ -4298,34 +4011,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -4403,7 +4088,7 @@ private constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4440,6 +4125,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Fallback.Builder::class) @@ -4453,8 +4158,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun role(): Role = role.getRequired("role") fun content(): Optional = @@ -4478,32 +4181,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Fallback && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -4572,7 +4249,7 @@ private constructor( return true } - return other is Role && this.value == other.value + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4609,6 +4286,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" } } @@ -4625,7 +4322,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4662,6 +4359,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Chat && this.type == other.type && this.messages == other.messages && this.tools == other.tools && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, messages, tools, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = NullableVariant.Builder::class) @@ -4673,8 +4390,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -4687,24 +4402,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -4737,6 +4434,25 @@ private constructor( fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } @@ -4789,13 +4505,11 @@ private constructor( return true } - return other is ToolFunction && - this.function == other.function && - this.global == other.global + return /* spotless:off */ other is ToolFunction && this.function == other.function && this.global == other.global /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(function, global) + return /* spotless:off */ Objects.hash(function, global) /* spotless:on */ } override fun toString(): String { @@ -4829,6 +4543,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): ToolFunction { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return ToolFunction(function = it, _json = json) @@ -4869,8 +4584,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun id(): String = id.getRequired("id") @@ -4893,32 +4606,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.type == other.type && - this.id == other.id && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - id, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -4985,7 +4672,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -5022,6 +4709,26 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.type == other.type && this.id == other.id && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, id, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = Global.Builder::class) @@ -5035,8 +4742,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun name(): String = name.getRequired("name") @@ -5059,32 +4764,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -5151,7 +4830,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -5188,6 +4867,46 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptData && this.prompt == other.prompt && this.options == other.options && this.parser == other.parser && this.toolFunctions == other.toolFunctions && this.origin == other.origin && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(prompt, options, parser, toolFunctions, origin, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PromptData{prompt=$prompt, options=$options, parser=$parser, toolFunctions=$toolFunctions, origin=$origin, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 586d384a..197004ad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is PromptDeleteParams && - this.promptId == other.promptId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is PromptDeleteParams && this.promptId == other.promptId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - promptId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(promptId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index 43cda3c0..c7ca805e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is PromptListPage && - this.promptsService == other.promptsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is PromptListPage && this.promptsService == other.promptsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - promptsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ } override fun toString() = @@ -121,13 +114,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index 31a7d456..c55289e4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is PromptListPageAsync && - this.promptsService == other.promptsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is PromptListPageAsync && this.promptsService == other.promptsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - promptsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ } override fun toString() = @@ -124,13 +117,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 9dfce694..28984928 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -84,36 +84,11 @@ constructor( return true } - return other is PromptListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.promptName == other.promptName && - this.slug == other.slug && - this.startingAfter == other.startingAfter && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is PromptListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.promptName == other.promptName && this.slug == other.slug && this.startingAfter == other.startingAfter && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - promptName, - slug, - startingAfter, - version, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -183,7 +158,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -324,11 +299,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -362,6 +337,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index ae734d51..9b731273 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -78,8 +78,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the prompt */ @JsonProperty("name") fun name(): String? = name @@ -106,42 +104,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -222,6 +184,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptReplaceBody && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -235,32 +217,11 @@ constructor( return true } - return other is PromptReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is PromptReplaceParams && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -409,7 +370,7 @@ constructor( return true } - return other is FunctionType && this.value == other.value + return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 5fb7fad1..ace5c98d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is PromptRetrieveParams && - this.promptId == other.promptId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is PromptRetrieveParams && this.promptId == other.promptId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - promptId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(promptId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index 334bbcba..f03ef924 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -74,8 +74,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Textual description of the prompt */ @JsonProperty("description") fun description(): String? = description @@ -97,38 +95,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptUpdateBody && - this.description == other.description && - this.name == other.name && - this.promptData == other.promptData && - this.slug == other.slug && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - description, - name, - promptData, - slug, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -194,6 +160,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptUpdateBody && this.description == other.description && this.name == other.name && this.promptData == other.promptData && this.slug == other.slug && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(description, name, promptData, slug, tags, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -207,30 +193,11 @@ constructor( return true } - return other is PromptUpdateParams && - this.promptId == other.promptId && - this.description == other.description && - this.name == other.name && - this.promptData == other.promptData && - this.slug == other.slug && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is PromptUpdateParams && this.promptId == other.promptId && this.description == other.description && this.name == other.name && this.promptData == other.promptData && this.slug == other.slug && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - promptId, - description, - name, - promptData, - slug, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(promptId, description, name, promptData, slug, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index 6447c8f7..d57bd593 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -34,8 +34,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** SHA of most recent commit */ fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) @@ -119,46 +117,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RepoInfo && - this.commit == other.commit && - this.branch == other.branch && - this.tag == other.tag && - this.dirty == other.dirty && - this.authorName == other.authorName && - this.authorEmail == other.authorEmail && - this.commitMessage == other.commitMessage && - this.commitTime == other.commitTime && - this.gitDiff == other.gitDiff && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -299,4 +257,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RepoInfo && this.commit == other.commit && this.branch == other.branch && this.tag == other.tag && this.dirty == other.dirty && this.authorName == other.authorName && this.authorEmail == other.authorEmail && this.commitMessage == other.commitMessage && this.commitTime == other.commitTime && this.gitDiff == other.gitDiff && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(commit, branch, tag, dirty, authorName, authorEmail, commitMessage, commitTime, gitDiff, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" } 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 a5d749f1..610b1156 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 @@ -42,8 +42,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the role */ fun id(): String = id.getRequired("id") @@ -147,46 +145,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && - this.id == other.id && - this.orgId == other.orgId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.deletedAt == other.deletedAt && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberPermissions, - memberRoles, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Role{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberPermissions=$memberPermissions, memberRoles=$memberRoles, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -358,8 +316,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** * Each permission permits a certain type of operation on an object in the system * @@ -397,32 +353,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -507,7 +437,7 @@ private constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -600,7 +530,7 @@ private constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -698,5 +628,45 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.id == other.id && this.orgId == other.orgId && this.userId == other.userId && this.created == other.created && this.name == other.name && this.description == other.description && this.deletedAt == other.deletedAt && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, orgId, userId, created, name, description, deletedAt, memberPermissions, memberRoles, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Role{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberPermissions=$memberPermissions, memberRoles=$memberRoles, additionalProperties=$additionalProperties}" } 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 492f4055..4d55e6e5 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 @@ -69,8 +69,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the role */ @JsonProperty("name") fun name(): String? = name @@ -102,38 +100,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleCreateBody && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -212,6 +178,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleCreateBody && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -225,28 +211,11 @@ constructor( return true } - return other is RoleCreateParams && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is RoleCreateParams && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -402,8 +371,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** * Each permission permits a certain type of operation on an object in the system * @@ -421,32 +388,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -515,7 +456,7 @@ constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -608,7 +549,7 @@ constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -706,5 +647,25 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 8e8f313f..0423855c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -46,20 +46,11 @@ constructor( return true } - return other is RoleDeleteParams && - this.roleId == other.roleId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is RoleDeleteParams && this.roleId == other.roleId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - roleId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(roleId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index d49ae5dc..99125be5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is RoleListPage && - this.rolesService == other.rolesService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is RoleListPage && this.rolesService == other.rolesService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - rolesService, - params, - response, - ) + return /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ } override fun toString() = @@ -121,13 +114,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index a53c7f0f..14597025 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is RoleListPageAsync && - this.rolesService == other.rolesService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is RoleListPageAsync && this.rolesService == other.rolesService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - rolesService, - params, - response, - ) + return /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ } override fun toString() = @@ -124,13 +117,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 33910b59..44250688 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -68,28 +68,11 @@ constructor( return true } - return other is RoleListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.roleName == other.roleName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is RoleListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.roleName == other.roleName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - roleName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -151,7 +134,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -271,11 +254,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -309,6 +292,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } 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 68772fb6..a9d35087 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 @@ -69,8 +69,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the role */ @JsonProperty("name") fun name(): String? = name @@ -102,38 +100,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleReplaceBody && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -212,6 +178,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleReplaceBody && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -225,28 +211,11 @@ constructor( return true } - return other is RoleReplaceParams && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is RoleReplaceParams && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -402,8 +371,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** * Each permission permits a certain type of operation on an object in the system * @@ -421,32 +388,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -515,7 +456,7 @@ constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -608,7 +549,7 @@ constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -706,5 +647,25 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 9f1fbfef..7bcb1535 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is RoleRetrieveParams && - this.roleId == other.roleId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is RoleRetrieveParams && this.roleId == other.roleId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - roleId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(roleId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = 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 80f56383..edf284f2 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 @@ -85,8 +85,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** A list of permissions to add to the role */ @JsonProperty("add_member_permissions") fun addMemberPermissions(): List? = addMemberPermissions @@ -114,40 +112,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleUpdateBody && - this.addMemberPermissions == other.addMemberPermissions && - this.addMemberRoles == other.addMemberRoles && - this.description == other.description && - this.name == other.name && - this.removeMemberPermissions == other.removeMemberPermissions && - this.removeMemberRoles == other.removeMemberRoles && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -231,6 +195,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleUpdateBody && this.addMemberPermissions == other.addMemberPermissions && this.addMemberRoles == other.addMemberRoles && this.description == other.description && this.name == other.name && this.removeMemberPermissions == other.removeMemberPermissions && this.removeMemberRoles == other.removeMemberRoles && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -244,32 +228,11 @@ constructor( return true } - return other is RoleUpdateParams && - this.roleId == other.roleId && - this.addMemberPermissions == other.addMemberPermissions && - this.addMemberRoles == other.addMemberRoles && - this.description == other.description && - this.name == other.name && - this.removeMemberPermissions == other.removeMemberPermissions && - this.removeMemberRoles == other.removeMemberRoles && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is RoleUpdateParams && this.roleId == other.roleId && this.addMemberPermissions == other.addMemberPermissions && this.addMemberRoles == other.addMemberRoles && this.description == other.description && this.name == other.name && this.removeMemberPermissions == other.removeMemberPermissions && this.removeMemberRoles == other.removeMemberRoles && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - roleId, - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(roleId, addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -442,8 +405,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** * Each permission permits a certain type of operation on an object in the system * @@ -461,32 +422,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddMemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -555,7 +490,7 @@ constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -648,7 +583,7 @@ constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -746,6 +681,26 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddMemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = RemoveMemberPermission.Builder::class) @@ -757,8 +712,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** * Each permission permits a certain type of operation on an object in the system * @@ -776,32 +729,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveMemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -870,7 +797,7 @@ constructor( return true } - return other is Permission && this.value == other.value + return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -963,7 +890,7 @@ constructor( return true } - return other is RestrictObjectType && this.value == other.value + return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1061,5 +988,25 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RemoveMemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index 3eed5fbd..b274297a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -30,8 +30,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the score */ fun name(): String = name.getRequired("name") @@ -79,38 +77,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScoreSummary && - this.name == other.name && - this.score == other.score && - this.diff == other.diff && - this.improvements == other.improvements && - this.regressions == other.regressions && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - score, - diff, - improvements, - regressions, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ScoreSummary{name=$name, score=$score, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -199,4 +165,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScoreSummary && this.name == other.name && this.score == other.score && this.diff == other.diff && this.improvements == other.improvements && this.regressions == other.regressions && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, score, diff, improvements, regressions, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ScoreSummary{name=$name, score=$score, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt index 11d30316..8276a02d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt @@ -28,8 +28,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun index(): Long = index.getRequired("index") @@ -52,32 +50,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -143,7 +115,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -180,4 +152,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scorer && this.type == other.type && this.index == other.index && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, index, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 4b2fdaf6..de9121fa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -30,8 +30,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the project that the dataset belongs to */ fun projectName(): String = projectName.getRequired("project_name") @@ -80,38 +78,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SummarizeDatasetResponse && - this.projectName == other.projectName && - this.datasetName == other.datasetName && - this.projectUrl == other.projectUrl && - this.datasetUrl == other.datasetUrl && - this.dataSummary == other.dataSummary && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - datasetName, - projectUrl, - datasetUrl, - dataSummary, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SummarizeDatasetResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -202,4 +168,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SummarizeDatasetResponse && this.projectName == other.projectName && this.datasetName == other.datasetName && this.projectUrl == other.projectUrl && this.datasetUrl == other.datasetUrl && this.dataSummary == other.dataSummary && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(projectName, datasetName, projectUrl, datasetUrl, dataSummary, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SummarizeDatasetResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 8a391f6a..4048ae6c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -32,8 +32,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Name of the project that the experiment belongs to */ fun projectName(): String = projectName.getRequired("project_name") @@ -98,42 +96,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SummarizeExperimentResponse && - this.projectName == other.projectName && - this.experimentName == other.experimentName && - this.projectUrl == other.projectUrl && - this.experimentUrl == other.experimentUrl && - this.comparisonExperimentName == other.comparisonExperimentName && - this.scores == other.scores && - this.metrics == other.metrics && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - experimentName, - projectUrl, - experimentUrl, - comparisonExperimentName, - scores, - metrics, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SummarizeExperimentResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -262,8 +224,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -276,23 +236,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metrics{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -323,6 +266,25 @@ private constructor( fun build(): Metrics = Metrics(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metrics{additionalProperties=$additionalProperties}" } /** Summary of the experiment's scores */ @@ -335,8 +297,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -349,23 +309,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -396,5 +339,44 @@ private constructor( fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Scores{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SummarizeExperimentResponse && this.projectName == other.projectName && this.experimentName == other.experimentName && this.projectUrl == other.projectUrl && this.experimentUrl == other.experimentUrl && this.comparisonExperimentName == other.comparisonExperimentName && this.scores == other.scores && this.metrics == other.metrics && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(projectName, experimentName, projectUrl, experimentUrl, comparisonExperimentName, scores, metrics, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SummarizeExperimentResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt index 77b56f67..9a57685d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt @@ -27,8 +27,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") @JsonProperty("type") @ExcludeMissing fun _type() = type @@ -46,25 +44,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Task && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = "Task{type=$type, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -117,7 +96,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -154,4 +133,23 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Task && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Task{type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt index b650da4e..e1a73d35 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt @@ -83,18 +83,11 @@ private constructor( return true } - return other is ToolChoice && - this.auto == other.auto && - this.none == other.none && - this.function == other.function + return /* spotless:off */ other is ToolChoice && this.auto == other.auto && this.none == other.none && this.function == other.function /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - auto, - none, - function, - ) + return /* spotless:off */ Objects.hash(auto, none, function) /* spotless:on */ } override fun toString(): String { @@ -133,6 +126,7 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return ToolChoice(auto = it, _json = json) } @@ -178,7 +172,7 @@ private constructor( return true } - return other is Auto && this.value == other.value + return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -229,7 +223,7 @@ private constructor( return true } - return other is None && this.value == other.value + return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -278,8 +272,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun type(): Type = type.getRequired("type") fun function(): FunctionToolChoice = function.getRequired("function") @@ -302,32 +294,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -395,7 +361,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -432,5 +398,25 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.type == other.type && this.function == other.function && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, function, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 9575b9fa..957a80ca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -26,13 +26,11 @@ constructor( return true } - return other is TopLevelHelloWorldParams && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is TopLevelHelloWorldParams && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(additionalQueryParams, additionalHeaders) + return /* spotless:off */ Objects.hash(additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index c254ff9d..039c11c8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -31,8 +31,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the user */ fun id(): String = id.getRequired("id") @@ -87,40 +85,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is User && - this.id == other.id && - this.givenName == other.givenName && - this.familyName == other.familyName && - this.email == other.email && - this.avatarUrl == other.avatarUrl && - this.created == other.created && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - givenName, - familyName, - email, - avatarUrl, - created, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "User{id=$id, givenName=$givenName, familyName=$familyName, email=$email, avatarUrl=$avatarUrl, created=$created, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -218,4 +182,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is User && this.id == other.id && this.givenName == other.givenName && this.familyName == other.familyName && this.email == other.email && this.avatarUrl == other.avatarUrl && this.created == other.created && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, givenName, familyName, email, avatarUrl, created, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "User{id=$id, givenName=$givenName, familyName=$familyName, email=$email, avatarUrl=$avatarUrl, created=$created, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 75c893f9..388aad00 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is UserListPage && - this.usersService == other.usersService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is UserListPage && this.usersService == other.usersService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - usersService, - params, - response, - ) + return /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ } override fun toString() = @@ -121,13 +114,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 330014eb..e4f5560e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is UserListPageAsync && - this.usersService == other.usersService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is UserListPageAsync && this.usersService == other.usersService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - usersService, - params, - response, - ) + return /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ } override fun toString() = @@ -124,13 +117,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 48836250..ee2d46b6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -76,32 +76,11 @@ constructor( return true } - return other is UserListParams && - this.email == other.email && - this.endingBefore == other.endingBefore && - this.familyName == other.familyName && - this.givenName == other.givenName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is UserListParams && this.email == other.email && this.endingBefore == other.endingBefore && this.familyName == other.familyName && this.givenName == other.givenName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - email, - endingBefore, - familyName, - givenName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -158,7 +137,7 @@ constructor( * Email of the user to search for. You may pass the param multiple times to filter for more * than one email */ - fun email(strings: List) = apply { this.email = Email.ofStrings(strings) } + fun emailOfStrings(strings: List) = apply { this.email = Email.ofStrings(strings) } /** * Pagination cursor id. @@ -185,7 +164,7 @@ constructor( * Family name of the user to search for. You may pass the param multiple times to filter * for more than one family name */ - fun familyName(strings: List) = apply { + fun familyNameOfStrings(strings: List) = apply { this.familyName = FamilyName.ofStrings(strings) } @@ -205,7 +184,7 @@ constructor( * Given name of the user to search for. You may pass the param multiple times to filter for * more than one given name */ - fun givenName(strings: List) = apply { + fun givenNameOfStrings(strings: List) = apply { this.givenName = GivenName.ofStrings(strings) } @@ -225,7 +204,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -344,11 +323,11 @@ constructor( return true } - return other is Email && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Email && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -382,6 +361,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Email { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Email(string = it, _json = json) } @@ -457,13 +437,11 @@ constructor( return true } - return other is FamilyName && - this.string == other.string && - this.strings == other.strings + return /* spotless:off */ other is FamilyName && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -497,6 +475,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): FamilyName { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return FamilyName(string = it, _json = json) } @@ -572,13 +551,11 @@ constructor( return true } - return other is GivenName && - this.string == other.string && - this.strings == other.strings + return /* spotless:off */ other is GivenName && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -612,6 +589,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): GivenName { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return GivenName(string = it, _json = json) } @@ -687,11 +665,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -725,6 +703,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 5dfac4ef..32c8279c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -36,18 +36,11 @@ constructor( return true } - return other is UserRetrieveParams && - this.userId == other.userId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is UserRetrieveParams && this.userId == other.userId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - userId, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(userId, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun 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 84463eb2..79698b99 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 @@ -38,8 +38,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - /** Unique identifier for the view */ fun id(): String = id.getRequired("id") @@ -123,48 +121,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is View && - this.id == other.id && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.viewType == other.viewType && - this.name == other.name && - this.created == other.created && - this.viewData == other.viewData && - this.options == other.options && - this.userId == other.userId && - this.deletedAt == other.deletedAt && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - objectType, - objectId, - viewType, - name, - created, - viewData, - options, - userId, - deletedAt, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "View{id=$id, objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, created=$created, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -320,7 +276,7 @@ private constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -431,7 +387,7 @@ private constructor( return true } - return other is ViewType && this.value == other.value + return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -510,4 +466,24 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is View && this.id == other.id && this.objectType == other.objectType && this.objectId == other.objectId && this.viewType == other.viewType && this.name == other.name && this.created == other.created && this.viewData == other.viewData && this.options == other.options && this.userId == other.userId && this.deletedAt == other.deletedAt && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, objectType, objectId, viewType, name, created, viewData, options, userId, deletedAt, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "View{id=$id, objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, created=$created, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" } 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 25b8ec2f..1671609d 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 @@ -84,8 +84,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the view */ @JsonProperty("name") fun name(): String? = name @@ -116,44 +114,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewCreateBody && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -241,6 +201,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewCreateBody && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -254,34 +234,11 @@ constructor( return true } - return other is ViewCreateParams && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ViewCreateParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -431,7 +388,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -542,7 +499,7 @@ constructor( return true } - return other is ViewType && this.value == other.value + return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 1a019644..06bb2708 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -26,8 +26,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun search(): Optional = Optional.ofNullable(search.getNullable("search")) @JsonProperty("search") @ExcludeMissing fun _search() = search @@ -45,25 +43,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewData && - this.search == other.search && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(search, additionalProperties) - } - return hashCode - } - - override fun toString() = "ViewData{search=$search, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -102,4 +81,23 @@ private constructor( fun build(): ViewData = ViewData(search, additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewData && this.search == other.search && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(search, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "ViewData{search=$search, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index b64ebbc7..9381f892 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -28,8 +28,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun filter(): Optional> = Optional.ofNullable(filter.getNullable("filter")) fun tag(): Optional> = Optional.ofNullable(tag.getNullable("tag")) @@ -62,36 +60,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewDataSearch && - this.filter == other.filter && - this.tag == other.tag && - this.match == other.match && - this.sort == other.sort && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - filter, - tag, - match, - sort, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ViewDataSearch{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -161,4 +129,24 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewDataSearch && this.filter == other.filter && this.tag == other.tag && this.match == other.match && this.sort == other.sort && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(filter, tag, match, sort, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ViewDataSearch{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" } 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 60e9fa73..ec6007a6 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 @@ -62,8 +62,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The id of the object the view applies to */ @JsonProperty("object_id") fun objectId(): String? = objectId @@ -76,32 +74,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewDeleteBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectId, - objectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -149,6 +121,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewDeleteBody && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectId, objectType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -162,24 +154,11 @@ constructor( return true } - return other is ViewDeleteParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ViewDeleteParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -299,7 +278,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index 4fc74c4a..c6968b6b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -34,18 +34,11 @@ private constructor( return true } - return other is ViewListPage && - this.viewsService == other.viewsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ViewListPage && this.viewsService == other.viewsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - viewsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ } override fun toString() = @@ -121,13 +114,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index f781d4f4..305931bf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -35,18 +35,11 @@ private constructor( return true } - return other is ViewListPageAsync && - this.viewsService == other.viewsService && - this.params == other.params && - this.response == other.response + return /* spotless:off */ other is ViewListPageAsync && this.viewsService == other.viewsService && this.params == other.params && this.response == other.response /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - viewsService, - params, - response, - ) + return /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ } override fun toString() = @@ -124,13 +117,11 @@ private constructor( return true } - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ } override fun toString() = 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 4096d8c8..012100a8 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 @@ -79,32 +79,11 @@ constructor( return true } - return other is ViewListParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.startingAfter == other.startingAfter && - this.viewName == other.viewName && - this.viewType == other.viewType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ViewListParams && this.objectId == other.objectId && this.objectType == other.objectType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.startingAfter == other.startingAfter && this.viewName == other.viewName && this.viewType == other.viewType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - endingBefore, - ids, - limit, - startingAfter, - viewName, - viewType, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -176,7 +155,7 @@ constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } /** Limit the number of objects to return */ fun limit(limit: Long) = apply { this.limit = limit } @@ -264,7 +243,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -409,11 +388,11 @@ constructor( return true } - return other is Ids && this.string == other.string && this.strings == other.strings + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash(string, strings) + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ } override fun toString(): String { @@ -447,6 +426,7 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { return Ids(string = it, _json = json) } @@ -488,7 +468,7 @@ constructor( return true } - return other is ViewType && this.value == other.value + return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index f47bc870..816d8937 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -28,8 +28,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - fun columnVisibility(): Optional = Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) @@ -60,34 +58,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewOptions && - this.columnVisibility == other.columnVisibility && - this.columnOrder == other.columnOrder && - this.columnSizing == other.columnSizing && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - columnVisibility, - columnOrder, - columnSizing, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ViewOptions{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -165,8 +135,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -179,23 +147,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ColumnSizing && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -226,6 +177,25 @@ private constructor( fun build(): ColumnSizing = ColumnSizing(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ColumnSizing && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" } @JsonDeserialize(builder = ColumnVisibility.Builder::class) @@ -237,8 +207,6 @@ private constructor( private var validated: Boolean = false - private var hashCode: Int = 0 - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -251,24 +219,6 @@ private constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ColumnVisibility && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "ColumnVisibility{additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -299,5 +249,44 @@ private constructor( fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toUnmodifiable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ColumnVisibility && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "ColumnVisibility{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewOptions && this.columnVisibility == other.columnVisibility && this.columnOrder == other.columnOrder && this.columnSizing == other.columnSizing && this.additionalProperties == other.additionalProperties /* spotless:on */ } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(columnVisibility, columnOrder, columnSizing, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ViewOptions{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" } 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 e49681ca..c16c3983 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 @@ -84,8 +84,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** Name of the view */ @JsonProperty("name") fun name(): String? = name @@ -116,44 +114,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewReplaceBody && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -241,6 +201,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewReplaceBody && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -254,34 +234,11 @@ constructor( return true } - return other is ViewReplaceParams && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ViewReplaceParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -431,7 +388,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -542,7 +499,7 @@ constructor( return true } - return other is ViewType && this.value == other.value + return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() 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 b56ed968..d5c72ce1 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 @@ -54,22 +54,11 @@ constructor( return true } - return other is ViewRetrieveParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return /* spotless:off */ other is ViewRetrieveParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - additionalQueryParams, - additionalHeaders, - ) + return /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalQueryParams, additionalHeaders) /* spotless:on */ } override fun toString() = @@ -172,7 +161,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() 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 3bb1d99d..519c1fa3 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 @@ -88,8 +88,6 @@ constructor( private val additionalProperties: Map, ) { - private var hashCode: Int = 0 - /** The id of the object the view applies to */ @JsonProperty("object_id") fun objectId(): String? = objectId @@ -117,42 +115,6 @@ constructor( fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewUpdateBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.name == other.name && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.viewType == other.viewType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" - companion object { @JvmStatic fun builder() = Builder() @@ -233,6 +195,26 @@ constructor( additionalProperties.toUnmodifiable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewUpdateBody && this.objectId == other.objectId && this.objectType == other.objectType && this.name == other.name && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.viewType == other.viewType && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectId, objectType, name, options, userId, viewData, viewType, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -246,34 +228,11 @@ constructor( return true } - return other is ViewUpdateParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.name == other.name && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.viewType == other.viewType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + return /* spotless:off */ other is ViewUpdateParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.name == other.name && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.viewType == other.viewType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return /* spotless:off */ Objects.hash(viewId, objectId, objectType, name, options, userId, viewData, viewType, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ } override fun toString() = @@ -423,7 +382,7 @@ constructor( return true } - return other is ObjectType && this.value == other.value + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -534,7 +493,7 @@ constructor( return true } - return other is ViewType && this.value == other.value + return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 41c071d5..6edea0c2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclBatchUpdateParams @@ -17,10 +21,6 @@ import com.braintrustdata.api.models.AclFindAndDeleteParams import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class AclServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index 330c772b..e4cfe750 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams @@ -17,10 +21,6 @@ import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class AiSecretServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index 5228efa4..75a6af2d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams @@ -15,10 +19,6 @@ import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class ApiKeyServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index 7430668e..0dd2647b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams @@ -24,10 +28,6 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class DatasetServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index a2f9d114..40334775 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EnvVar import com.braintrustdata.api.models.EnvVarCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.EnvVarListResponse import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class EnvVarServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index 275cafcb..aa2dddda 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -4,16 +4,16 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class EvalServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 0517c864..3ae26dda 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams @@ -24,10 +28,6 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class ExperimentServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 006ad090..491cca41 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams @@ -18,10 +22,6 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class FunctionServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index aebfd0ae..0cb84f89 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class GroupServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 2ff92c1d..1f66e1c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import com.braintrustdata.api.services.async.organizations.MemberServiceAsync import com.braintrustdata.api.services.async.organizations.MemberServiceAsyncImpl -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class OrganizationServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index 8953beb8..8f592589 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class ProjectScoreServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index 02e1fd79..d064b194 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams @@ -17,10 +21,6 @@ import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams import com.braintrustdata.api.services.async.projects.LogServiceAsync import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class ProjectServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index 66372dea..7cc499c6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class ProjectTagServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index f892b1fd..6e56557a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class PromptServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index 87b3e814..837c6e66 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class RoleServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index 62a80406..759787bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -4,14 +4,14 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.stringHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class TopLevelServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 3cbcf8e1..246d614f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -4,6 +4,9 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler @@ -12,9 +15,6 @@ import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPageAsync import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class UserServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 9a9874ec..ddc3dad5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class ViewServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 73d5eaec..65480fe5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -4,16 +4,16 @@ package com.braintrustdata.api.services.async.organizations import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class MemberServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 23037f34..69a9dc3f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse @@ -15,10 +19,6 @@ import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler import java.util.concurrent.CompletableFuture class LogServiceAsyncImpl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index a7b51e01..9d266d42 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclBatchUpdateParams @@ -17,10 +21,6 @@ import com.braintrustdata.api.models.AclFindAndDeleteParams import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class AclServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index 2b0fadbc..f61b7be6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams @@ -17,10 +21,6 @@ import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class AiSecretServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index 5b705c68..0f6d80aa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams @@ -15,10 +19,6 @@ import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class ApiKeyServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index a7d2f6e1..4dc34521 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams @@ -24,10 +28,6 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class DatasetServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index 947656fd..34db366c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EnvVar import com.braintrustdata.api.models.EnvVarCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.EnvVarListResponse import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class EnvVarServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index 2811b4d7..f8a2f694 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -4,16 +4,16 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class EvalServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 1d80270a..df57dad1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams @@ -24,10 +28,6 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class ExperimentServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index d626758d..00bcbe94 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams @@ -18,10 +22,6 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class FunctionServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 352a97e9..080f21e2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class GroupServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index 786fc869..fd55f46a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import com.braintrustdata.api.services.blocking.organizations.MemberService import com.braintrustdata.api.services.blocking.organizations.MemberServiceImpl -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class OrganizationServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index 8adb60b6..9576e14a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class ProjectScoreServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 9a166368..1349bed5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams @@ -17,10 +21,6 @@ import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams import com.braintrustdata.api.services.blocking.projects.LogService import com.braintrustdata.api.services.blocking.projects.LogServiceImpl -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class ProjectServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 79ec9e72..daf6171e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class ProjectTagServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index 25e6d6b7..dc23ed4d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class PromptServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 5f49a6b3..ef6cba86 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class RoleServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 631eac96..59d5c939 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -4,14 +4,14 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.stringHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.stringHandler -import com.braintrustdata.api.services.withErrorHandler class TopLevelServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 28ff5d7a..b07330fe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -4,6 +4,9 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler @@ -12,9 +15,6 @@ import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class UserServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index f682e6d6..4f17ebf9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams @@ -16,10 +20,6 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class ViewServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index 749d7bf8..31901bd3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -4,16 +4,16 @@ package com.braintrustdata.api.services.blocking.organizations import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class MemberServiceImpl constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 9f21671a..5fc922bd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -4,9 +4,13 @@ package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse @@ -15,10 +19,6 @@ import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler class LogServiceImpl constructor( 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 a2b3b31e..5f1a5949 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 @@ -14,8 +14,10 @@ class ProjectScoreCreateParamsTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreType.SLIDER) - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreCreateParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() @@ -51,8 +53,10 @@ class ProjectScoreCreateParamsTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreType.SLIDER) - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreCreateParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() @@ -88,7 +92,7 @@ class ProjectScoreCreateParamsTest { assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) assertThat(body.categories()) .isEqualTo( - ProjectScoreCreateParams.Categories.ofProjectScoreCategories( + ProjectScoreCreateParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) ) ) 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 dd18f1f5..d3b3409c 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 @@ -14,8 +14,10 @@ class ProjectScoreReplaceParamsTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreType.SLIDER) - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreReplaceParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() @@ -51,8 +53,10 @@ class ProjectScoreReplaceParamsTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreType.SLIDER) - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreReplaceParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() @@ -88,7 +92,7 @@ class ProjectScoreReplaceParamsTest { assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) assertThat(body.categories()) .isEqualTo( - ProjectScoreReplaceParams.Categories.ofProjectScoreCategories( + ProjectScoreReplaceParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) ) ) 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 1ae89d7b..8cabac19 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 @@ -18,7 +18,7 @@ class ProjectScoreTest { .scoreType(ProjectScoreType.SLIDER) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .categories( - ProjectScore.Categories.ofProjectScoreCategories( + ProjectScore.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) ) ) @@ -59,7 +59,7 @@ class ProjectScoreTest { assertThat(projectScore.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(projectScore.categories()) .contains( - ProjectScore.Categories.ofProjectScoreCategories( + ProjectScore.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) ) ) 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 68073495..66c17521 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 @@ -12,8 +12,10 @@ class ProjectScoreUpdateParamsTest { fun createProjectScoreUpdateParams() { ProjectScoreUpdateParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreUpdateParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() @@ -49,8 +51,10 @@ class ProjectScoreUpdateParamsTest { val params = ProjectScoreUpdateParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreUpdateParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() @@ -85,7 +89,7 @@ class ProjectScoreUpdateParamsTest { assertThat(body).isNotNull assertThat(body.categories()) .isEqualTo( - ProjectScoreUpdateParams.Categories.ofProjectScoreCategories( + ProjectScoreUpdateParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).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 5a915482..7726d0da 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 @@ -26,8 +26,10 @@ class ProjectScoreServiceTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreType.SLIDER) - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreCreateParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() @@ -92,8 +94,10 @@ class ProjectScoreServiceTest { projectScoreService.update( ProjectScoreUpdateParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreUpdateParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() @@ -175,8 +179,10 @@ class ProjectScoreServiceTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreType.SLIDER) - .projectScoreCategories( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + .categories( + ProjectScoreReplaceParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + ) ) .config( ProjectScoreConfig.builder() diff --git a/buildSrc/src/main/kotlin/braintrust.java.gradle.kts b/buildSrc/src/main/kotlin/braintrust.java.gradle.kts index 53e63304..32a150ed 100755 --- a/buildSrc/src/main/kotlin/braintrust.java.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.java.gradle.kts @@ -19,6 +19,7 @@ configure { importOrder() removeUnusedImports() palantirJavaFormat() + toggleOffOn() } } diff --git a/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts b/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts index 267e3576..21c44eda 100755 --- a/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts @@ -16,6 +16,7 @@ kotlin { configure { kotlin { ktfmt().kotlinlangStyle() + toggleOffOn() } } From 02b0490c081fc51c4c11b12cf8592dc513ac7a1f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 21:50:09 +0000 Subject: [PATCH 02/87] feat(api): api update (#66) --- .../client/okhttp/BraintrustOkHttpClient.kt | 7 ++- .../okhttp/BraintrustOkHttpClientAsync.kt | 7 ++- .../api/client/okhttp/OkHttpClient.kt | 44 +++++-------------- .../api/client/BraintrustClient.kt | 2 - .../api/client/BraintrustClientAsync.kt | 2 - .../api/core/http/HttpClient.kt | 4 ++ .../api/core/http/RetryingHttpClient.kt | 2 - 7 files changed, 22 insertions(+), 46 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index ae986d28..83affecc 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -23,7 +23,7 @@ class BraintrustOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL - // default timeout for client is 1 minute + // The default timeout for the client is 1 minute. private var timeout: Duration = Duration.ofSeconds(60) private var proxy: Proxy? = null @@ -66,8 +66,8 @@ class BraintrustOkHttpClient private constructor() { fun fromEnv() = apply { clientOptions.fromEnv() } - fun build(): BraintrustClient { - return BraintrustClientImpl( + fun build(): BraintrustClient = + BraintrustClientImpl( clientOptions .httpClient( OkHttpClient.builder() @@ -78,6 +78,5 @@ class BraintrustOkHttpClient private constructor() { ) .build() ) - } } } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index d813b989..08d1b49f 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -23,7 +23,7 @@ class BraintrustOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL - // default timeout for client is 1 minute + // The default timeout for the client is 1 minute. private var timeout: Duration = Duration.ofSeconds(60) private var proxy: Proxy? = null @@ -66,8 +66,8 @@ class BraintrustOkHttpClientAsync private constructor() { fun fromEnv() = apply { clientOptions.fromEnv() } - fun build(): BraintrustClientAsync { - return BraintrustClientAsyncImpl( + fun build(): BraintrustClientAsync = + BraintrustClientAsyncImpl( clientOptions .httpClient( OkHttpClient.builder() @@ -78,6 +78,5 @@ class BraintrustOkHttpClientAsync private constructor() { ) .build() ) - } } } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index a7ca15a9..3e2d8180 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -66,7 +66,6 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } val call = getClient(requestOptions).newCall(request.toRequest()) - call.enqueue( object : Callback { override fun onResponse(call: Call, response: Response) { @@ -90,7 +89,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val private fun HttpRequest.toRequest(): Request { var body: RequestBody? = body?.toRequestBody() - // OkHttpClient always requires a request body for PUT and POST methods + // OkHttpClient always requires a request body for PUT and POST methods. if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) { body = "".toRequestBody() } @@ -118,21 +117,13 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val val length = contentLength() return object : RequestBody() { - override fun contentType(): MediaType? { - return mediaType - } + override fun contentType(): MediaType? = mediaType - override fun contentLength(): Long { - return length - } + override fun contentLength(): Long = length - override fun isOneShot(): Boolean { - return !repeatable() - } + override fun isOneShot(): Boolean = !repeatable() - override fun writeTo(sink: BufferedSink) { - writeTo(sink.outputStream()) - } + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) } } @@ -140,21 +131,13 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val val headers = headers.toHeaders() return object : HttpResponse { - override fun statusCode(): Int { - return code - } + override fun statusCode(): Int = code - override fun headers(): ListMultimap { - return headers - } + override fun headers(): ListMultimap = headers - override fun body(): InputStream { - return body!!.byteStream() - } + override fun body(): InputStream = body!!.byteStream() - override fun close() { - body!!.close() - } + override fun close() = body!!.close() } } @@ -163,9 +146,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) .arrayListValues() .build() - forEach { pair -> headers.put(pair.first, pair.second) } - return headers } @@ -176,7 +157,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder { private var baseUrl: HttpUrl? = null - // default timeout is 1 minute + // The default timeout is 1 minute. private var timeout: Duration = Duration.ofSeconds(60) private var proxy: Proxy? = null @@ -186,8 +167,8 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } - fun build(): OkHttpClient { - return OkHttpClient( + fun build(): OkHttpClient = + OkHttpClient( okhttp3.OkHttpClient.Builder() .connectTimeout(timeout) .readTimeout(timeout) @@ -197,6 +178,5 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .build(), checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }, ) - } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index 3424863b..f923ab46 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.client import com.braintrustdata.api.models.* diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index 94511fd9..bf2509b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.client import com.braintrustdata.api.models.* diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt index f4163046..2d8ef81e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt @@ -1,3 +1,5 @@ +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + package com.braintrustdata.api.core.http import com.braintrustdata.api.core.RequestOptions @@ -6,11 +8,13 @@ import java.util.concurrent.CompletableFuture interface HttpClient : AutoCloseable { + @JvmOverloads fun execute( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse + @JvmOverloads fun executeAsync( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 450eb8af..94a3fed0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -1,5 +1,3 @@ -@file:JvmSynthetic - package com.braintrustdata.api.core.http import com.braintrustdata.api.core.RequestOptions From 2ca59f78f8e775f10b4c09e040e7f55ec27612b1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 01:21:00 +0000 Subject: [PATCH 03/87] feat(api): api update (#67) --- .../api/core/http/RetryingHttpClient.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 94a3fed0..2ec0f53b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -124,15 +124,12 @@ private constructor( return executeWithRetries(request, requestOptions) } - override fun close() { - httpClient.close() - } + override fun close() = httpClient.close() - private fun isRetryable(request: HttpRequest): Boolean { + private fun isRetryable(request: HttpRequest): Boolean = // Some requests, such as when a request body is being streamed, cannot be retried because // the body data aren't available on subsequent attempts. - return request.body?.repeatable() ?: true - } + request.body?.repeatable() ?: true private fun setRetryCountHeader(request: HttpRequest, retries: Int) { request.headers.removeAll("x-stainless-retry-count") @@ -170,11 +167,10 @@ private constructor( } } - private fun shouldRetry(throwable: Throwable): Boolean { + private fun shouldRetry(throwable: Throwable): Boolean = // Only retry IOException and BraintrustIoException, other exceptions are not intended to be // retried. - return throwable is IOException || throwable is BraintrustIoException - } + throwable is IOException || throwable is BraintrustIoException private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: From 288a26dc55ba27313879a00ace18304408adefe9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:57:59 +0000 Subject: [PATCH 04/87] feat(api): api update (#68) --- .../src/main/kotlin/com/braintrustdata/api/core/Values.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 45e19b1c..1dfdbfa7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -142,6 +142,8 @@ sealed class JsonField { // This filter should not be used directly and should instead use the @ExcludeMissing annotation class IsMissing { override fun equals(other: Any?): Boolean = other is JsonMissing + + override fun hashCode(): Int = Objects.hash() } class Deserializer(private val type: JavaType? = null) : From a7c0606dca2139ba230c5d4813dcf76f1ec59d08 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:50:21 +0000 Subject: [PATCH 05/87] chore: rebuild project due to codegen change (#69) --- .../src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index a63ea9ec..4700499e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -108,6 +108,7 @@ private constructor( headers.put("X-Stainless-OS", getOsName()) headers.put("X-Stainless-OS-Version", getOsVersion()) headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) if (!apiKey.isNullOrEmpty()) { headers.put("Authorization", "Bearer ${apiKey}") From ccb8dd583d9783e0466503fa848a1ef5fd577e20 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:15:09 +0000 Subject: [PATCH 06/87] chore: rebuild project due to codegen change (#70) --- .../api/client/BraintrustClientAsyncImpl.kt | 64 +++++++++++++------ .../api/client/BraintrustClientImpl.kt | 56 ++++++++++------ .../braintrustdata/api/core/ClientOptions.kt | 23 +++++++ 3 files changed, 107 insertions(+), 36 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index d5a7c733..1165de16 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.client import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.getPackageVersion import com.braintrustdata.api.models.* import com.braintrustdata.api.services.async.* @@ -11,51 +12,78 @@ constructor( private val clientOptions: ClientOptions, ) : BraintrustClientAsync { + private val clientOptionsWithUserAgent = + if (clientOptions.headers.containsKey("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. private val sync: BraintrustClient by lazy { BraintrustClientImpl(clientOptions) } - private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptions) } + private val topLevel: TopLevelServiceAsync by lazy { + TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptions) } + private val projects: ProjectServiceAsync by lazy { + ProjectServiceAsyncImpl(clientOptionsWithUserAgent) + } private val experiments: ExperimentServiceAsync by lazy { - ExperimentServiceAsyncImpl(clientOptions) + ExperimentServiceAsyncImpl(clientOptionsWithUserAgent) } - private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) } + private val datasets: DatasetServiceAsync by lazy { + DatasetServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val prompts: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptions) } + private val prompts: PromptServiceAsync by lazy { + PromptServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptions) } + private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptionsWithUserAgent) } - private val groups: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptions) } + private val groups: GroupServiceAsync by lazy { + GroupServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val acls: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptions) } + private val acls: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptionsWithUserAgent) } - private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptions) } + private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptionsWithUserAgent) } private val projectScores: ProjectScoreServiceAsync by lazy { - ProjectScoreServiceAsyncImpl(clientOptions) + ProjectScoreServiceAsyncImpl(clientOptionsWithUserAgent) } private val projectTags: ProjectTagServiceAsync by lazy { - ProjectTagServiceAsyncImpl(clientOptions) + ProjectTagServiceAsyncImpl(clientOptionsWithUserAgent) } - private val functions: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptions) } + private val functions: FunctionServiceAsync by lazy { + FunctionServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptions) } + private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptionsWithUserAgent) } private val organizations: OrganizationServiceAsync by lazy { - OrganizationServiceAsyncImpl(clientOptions) + OrganizationServiceAsyncImpl(clientOptionsWithUserAgent) } - private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptions) } + private val apiKeys: ApiKeyServiceAsync by lazy { + ApiKeyServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val aiSecrets: AiSecretServiceAsync by lazy { AiSecretServiceAsyncImpl(clientOptions) } + private val aiSecrets: AiSecretServiceAsync by lazy { + AiSecretServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val envVars: EnvVarServiceAsync by lazy { EnvVarServiceAsyncImpl(clientOptions) } + private val envVars: EnvVarServiceAsync by lazy { + EnvVarServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val evals: EvalServiceAsync by lazy { EvalServiceAsyncImpl(clientOptions) } + private val evals: EvalServiceAsync by lazy { EvalServiceAsyncImpl(clientOptionsWithUserAgent) } override fun sync(): BraintrustClient = sync diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index e770915e..482983f8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.client import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.getPackageVersion import com.braintrustdata.api.models.* import com.braintrustdata.api.services.blocking.* @@ -11,47 +12,66 @@ constructor( private val clientOptions: ClientOptions, ) : BraintrustClient { + private val clientOptionsWithUserAgent = + if (clientOptions.headers.containsKey("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. private val async: BraintrustClientAsync by lazy { BraintrustClientAsyncImpl(clientOptions) } - private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptions) } + private val topLevel: TopLevelService by lazy { + TopLevelServiceImpl(clientOptionsWithUserAgent) + } - private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptions) } + private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) } - private val experiments: ExperimentService by lazy { ExperimentServiceImpl(clientOptions) } + private val experiments: ExperimentService by lazy { + ExperimentServiceImpl(clientOptionsWithUserAgent) + } - private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptions) } + private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptionsWithUserAgent) } - private val prompts: PromptService by lazy { PromptServiceImpl(clientOptions) } + private val prompts: PromptService by lazy { PromptServiceImpl(clientOptionsWithUserAgent) } - private val roles: RoleService by lazy { RoleServiceImpl(clientOptions) } + private val roles: RoleService by lazy { RoleServiceImpl(clientOptionsWithUserAgent) } - private val groups: GroupService by lazy { GroupServiceImpl(clientOptions) } + private val groups: GroupService by lazy { GroupServiceImpl(clientOptionsWithUserAgent) } - private val acls: AclService by lazy { AclServiceImpl(clientOptions) } + private val acls: AclService by lazy { AclServiceImpl(clientOptionsWithUserAgent) } - private val users: UserService by lazy { UserServiceImpl(clientOptions) } + private val users: UserService by lazy { UserServiceImpl(clientOptionsWithUserAgent) } private val projectScores: ProjectScoreService by lazy { - ProjectScoreServiceImpl(clientOptions) + ProjectScoreServiceImpl(clientOptionsWithUserAgent) } - private val projectTags: ProjectTagService by lazy { ProjectTagServiceImpl(clientOptions) } + private val projectTags: ProjectTagService by lazy { + ProjectTagServiceImpl(clientOptionsWithUserAgent) + } - private val functions: FunctionService by lazy { FunctionServiceImpl(clientOptions) } + private val functions: FunctionService by lazy { + FunctionServiceImpl(clientOptionsWithUserAgent) + } - private val views: ViewService by lazy { ViewServiceImpl(clientOptions) } + private val views: ViewService by lazy { ViewServiceImpl(clientOptionsWithUserAgent) } private val organizations: OrganizationService by lazy { - OrganizationServiceImpl(clientOptions) + OrganizationServiceImpl(clientOptionsWithUserAgent) } - private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptions) } + private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptionsWithUserAgent) } - private val aiSecrets: AiSecretService by lazy { AiSecretServiceImpl(clientOptions) } + private val aiSecrets: AiSecretService by lazy { + AiSecretServiceImpl(clientOptionsWithUserAgent) + } - private val envVars: EnvVarService by lazy { EnvVarServiceImpl(clientOptions) } + private val envVars: EnvVarService by lazy { EnvVarServiceImpl(clientOptionsWithUserAgent) } - private val evals: EvalService by lazy { EvalServiceImpl(clientOptions) } + private val evals: EvalService by lazy { EvalServiceImpl(clientOptionsWithUserAgent) } override fun async(): BraintrustClientAsync = async diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 4700499e..93a4f613 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -19,8 +19,11 @@ private constructor( @get:JvmName("headers") val headers: ListMultimap, @get:JvmName("queryParams") val queryParams: ListMultimap, @get:JvmName("responseValidation") val responseValidation: Boolean, + @get:JvmName("maxRetries") val maxRetries: Int, ) { + fun toBuilder() = Builder().from(this) + companion object { const val PRODUCTION_URL = "https://api.braintrust.dev" @@ -42,6 +45,25 @@ private constructor( private var maxRetries: Int = 2 private var apiKey: String? = null + @JvmSynthetic + internal fun from(clientOptions: ClientOptions) = apply { + httpClient = clientOptions.httpClient + jsonMapper = clientOptions.jsonMapper + clock = clientOptions.clock + baseUrl = clientOptions.baseUrl + headers = + clientOptions.headers.asMap().mapValuesTo(mutableMapOf()) { (_, value) -> + value.toMutableList() + } + queryParams = + clientOptions.queryParams.asMap().mapValuesTo(mutableMapOf()) { (_, value) -> + value.toMutableList() + } + responseValidation = clientOptions.responseValidation + maxRetries = clientOptions.maxRetries + apiKey = clientOptions.apiKey + } + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } @@ -129,6 +151,7 @@ private constructor( headers.toUnmodifiable(), queryParams.toUnmodifiable(), responseValidation, + maxRetries, ) } } From 0c35214c2e1b903f741cf39c6a4d7289b13b6271 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 19:10:23 +0000 Subject: [PATCH 07/87] chore: rebuild project due to codegen change (#71) --- .../main/kotlin/com/braintrustdata/api/core/ClientOptions.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 93a4f613..3ccabbe4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -11,6 +11,7 @@ import java.time.Clock class ClientOptions private constructor( + private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @@ -47,7 +48,7 @@ private constructor( @JvmSynthetic internal fun from(clientOptions: ClientOptions) = apply { - httpClient = clientOptions.httpClient + httpClient = clientOptions.originalHttpClient jsonMapper = clientOptions.jsonMapper clock = clientOptions.clock baseUrl = clientOptions.baseUrl @@ -139,6 +140,7 @@ private constructor( this.queryParams.forEach(queryParams::replaceValues) return ClientOptions( + httpClient!!, RetryingHttpClient.builder() .httpClient(httpClient!!) .clock(clock) From b6c9f43a2a14533b88d39666809b5ee7ce670504 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:31:05 +0000 Subject: [PATCH 08/87] chore(api): manual updates (#72) --- .../api/models/ChatCompletionContentPart.kt | 166 ++++++++++++++ .../api/models/FunctionInvokeParams.kt | 178 --------------- .../braintrustdata/api/models/PromptData.kt | 203 ------------------ 3 files changed, 166 insertions(+), 381 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt new file mode 100644 index 00000000..35a3f312 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) +@JsonSerialize(using = ChatCompletionContentPart.Serializer::class) +class ChatCompletionContentPart +private constructor( + private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, + private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if (chatCompletionContentPartText == null && chatCompletionContentPartImage == null) { + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $_json") + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = ChatCompletionContentPart(chatCompletionContentPartText = chatCompletionContentPartText) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") + } + } + + class Deserializer : + BaseDeserializer(ChatCompletionContentPart::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : BaseSerializer(ChatCompletionContentPart::class) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject(value.chatCompletionContentPartText) + value.chatCompletionContentPartImage != null -> + generator.writeObject(value.chatCompletionContentPartImage) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 1e78cd12..6c16f962 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -1018,184 +1018,6 @@ constructor( } } } - - @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) - @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = - null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = - chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = - chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText( - chatCompletionContentPartText - ) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage( - chatCompletionContentPartImage - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && - chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = chatCompletionContentPartText - ) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - } - } } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index f3c3be56..b6262022 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -3238,209 +3238,6 @@ private constructor( } } } - - @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) - @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( - private val chatCompletionContentPartText: - ChatCompletionContentPartText? = - null, - private val chatCompletionContentPartImage: - ChatCompletionContentPartImage? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): - Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): - Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = - chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = - chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow( - "chatCompletionContentPartText" - ) - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow( - "chatCompletionContentPartImage" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText( - chatCompletionContentPartText - ) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage( - chatCompletionContentPartImage - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && - chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = - chatCompletionContentPartText - ) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = - chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize( - node, - jacksonTypeRef() - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize( - node, - jacksonTypeRef() - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject( - value.chatCompletionContentPartText - ) - value.chatCompletionContentPartImage != null -> - generator.writeObject( - value.chatCompletionContentPartImage - ) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) - } - } - } - } } override fun equals(other: Any?): Boolean { From a7a6379e2b4e7a8944aa89df8de05ca116db8af8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:51:14 +0000 Subject: [PATCH 09/87] chore: rebuild project due to codegen change (#73) --- .../braintrustdata/api/core/ClientOptions.kt | 13 ++++-- .../api/core/PhantomReachable.kt | 46 +++++++++++++++++++ .../http/PhantomReachableClosingHttpClient.kt | 21 +++++++++ .../api/core/PhantomReachableTest.kt | 27 +++++++++++ 4 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PhantomReachable.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 3ccabbe4..77f87fc8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.core import com.braintrustdata.api.core.http.HttpClient +import com.braintrustdata.api.core.http.PhantomReachableClosingHttpClient import com.braintrustdata.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper import com.google.common.collect.ArrayListMultimap @@ -141,11 +142,13 @@ private constructor( return ClientOptions( httpClient!!, - RetryingHttpClient.builder() - .httpClient(httpClient!!) - .clock(clock) - .maxRetries(maxRetries) - .build(), + PhantomReachableClosingHttpClient( + RetryingHttpClient.builder() + .httpClient(httpClient!!) + .clock(clock) + .maxRetries(maxRetries) + .build() + ), jsonMapper ?: jsonMapper(), clock, baseUrl, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PhantomReachable.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PhantomReachable.kt new file mode 100644 index 00000000..d3f62aab --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PhantomReachable.kt @@ -0,0 +1,46 @@ +@file:JvmName("PhantomReachable") + +package com.braintrustdata.api.core + +import com.braintrustdata.api.errors.BraintrustException +import java.lang.reflect.InvocationTargetException + +/** + * Closes [closeable] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable) { + check(observed !== closeable) { + "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" + } + closeWhenPhantomReachable?.let { it(observed, closeable::close) } +} + +private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy { + try { + val cleanerClass = Class.forName("java.lang.ref.Cleaner") + val cleanerCreate = cleanerClass.getMethod("create") + val cleanerRegister = + cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) + val cleanerObject = cleanerCreate.invoke(null); + + { observed, closeable -> + try { + cleanerRegister.invoke(cleanerObject, observed, Runnable { closeable.close() }) + } catch (e: ReflectiveOperationException) { + if (e is InvocationTargetException) { + when (val cause = e.cause) { + is RuntimeException, + is Error -> throw cause + } + } + throw BraintrustException("Unexpected reflective invocation failure", e) + } + } + } catch (e: ReflectiveOperationException) { + // We're running Java 8, which has no Cleaner. + null + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt new file mode 100644 index 00000000..3f4673df --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt @@ -0,0 +1,21 @@ +package com.braintrustdata.api.core.http + +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.closeWhenPhantomReachable +import java.util.concurrent.CompletableFuture + +internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { + init { + closeWhenPhantomReachable(this, httpClient) + } + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse = + httpClient.execute(request, requestOptions) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions + ): CompletableFuture = httpClient.executeAsync(request, requestOptions) + + override fun close() = httpClient.close() +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt new file mode 100644 index 00000000..adf8a799 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt @@ -0,0 +1,27 @@ +package com.braintrustdata.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PhantomReachableTest { + + @Test + fun closeWhenPhantomReachable_whenObservedIsGarbageCollected_closesCloseable() { + var closed = false + val closeable = AutoCloseable { closed = true } + + closeWhenPhantomReachable( + // Pass an inline object for the object to observe so that it becomes immediately + // unreachable. + Any(), + closeable + ) + + assertThat(closed).isFalse() + + System.gc() + Thread.sleep(3000) + + assertThat(closed).isTrue() + } +} From d665d0f6cfd44d1bee4ea5dd02d00c0a63203b0c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:53:21 +0000 Subject: [PATCH 10/87] chore: rebuild project due to codegen change (#74) --- .../src/main/kotlin/com/braintrustdata/api/core/Utils.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index dd23bef7..a138ea8b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -9,13 +9,8 @@ import com.google.common.collect.Multimaps import java.util.Collections @JvmSynthetic -internal fun T?.getOrThrow(name: String): T { - if (this == null) { - throw BraintrustInvalidDataException("'${name}' is not present") - } - - return this -} +internal fun T?.getOrThrow(name: String): T = + this ?: throw BraintrustInvalidDataException("`${name}` is not present") @JvmSynthetic internal fun List.toUnmodifiable(): List { From 9ac566913ab54368b5e1eb10c5e6c20fc86ff75a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 20:32:50 +0000 Subject: [PATCH 11/87] chore: rebuild project due to codegen change (#75) --- .../kotlin/com/braintrustdata/api/core/Utils.kt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index a138ea8b..795c75cd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -39,18 +39,4 @@ internal fun ListMultimap.toUnmodifiable(): ListMultimap { return Multimaps.unmodifiableListMultimap(this) } -@JvmSynthetic -internal fun ListMultimap.getRequiredHeader(header: String): String { - val value = - entries() - .stream() - .filter { entry -> entry.key.equals(header, ignoreCase = true) } - .map { entry -> entry.value } - .findFirst() - if (!value.isPresent) { - throw BraintrustInvalidDataException("Could not find $header header") - } - return value.get() -} - internal interface Enum From 6498c997bc0fb2ae68e842ab6b69110115fa458b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:08:39 +0000 Subject: [PATCH 12/87] chore: rebuild project due to codegen change (#76) --- .../com/braintrustdata/api/core/http/RetryingHttpClient.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 2ec0f53b..09bb15ae 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.core.http import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustIoException -import com.google.common.util.concurrent.MoreExecutors import java.io.IOException import java.time.Clock import java.time.Duration @@ -116,8 +115,10 @@ private constructor( executeWithRetries(request, requestOptions) } }, - MoreExecutors.directExecutor() - ) + ) { + // Run in the same thread. + it.run() + } .thenCompose(Function.identity()) } From 7c9b2adb46f8e24d9a3c908400596d96795b8ede Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 01:37:10 +0000 Subject: [PATCH 13/87] chore: rebuild project due to codegen change (#77) --- .../main/kotlin/com/braintrustdata/api/models/ProjectScore.kt | 4 ++++ .../com/braintrustdata/api/models/ProjectScoreCreateParams.kt | 2 ++ .../braintrustdata/api/models/ProjectScoreReplaceParams.kt | 2 ++ .../com/braintrustdata/api/models/ProjectScoreUpdateParams.kt | 2 ++ 4 files changed, 10 insertions(+) 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 6f268c6e..56f66f2a 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 @@ -67,6 +67,7 @@ private constructor( /** The type of the configured score */ fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") + /** For categorical-type project scores, the list of all categories */ fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) @@ -95,6 +96,7 @@ private constructor( /** The type of the configured score */ @JsonProperty("score_type") @ExcludeMissing fun _scoreType() = scoreType + /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @ExcludeMissing fun _categories() = categories @JsonProperty("config") @ExcludeMissing fun _config() = config @@ -210,8 +212,10 @@ private constructor( @ExcludeMissing fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) + /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @ExcludeMissing fun categories(categories: JsonField) = apply { this.categories = categories } 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 daf1406f..2f1ecf6e 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 @@ -88,6 +88,7 @@ constructor( /** The type of the configured score */ @JsonProperty("score_type") fun scoreType(): ProjectScoreType? = scoreType + /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") fun categories(): Categories? = categories @JsonProperty("config") fun config(): ProjectScoreConfig? = config @@ -138,6 +139,7 @@ constructor( @JsonProperty("score_type") fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") fun categories(categories: Categories) = apply { this.categories = categories } 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 b41f3386..8bddbd07 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 @@ -88,6 +88,7 @@ constructor( /** The type of the configured score */ @JsonProperty("score_type") fun scoreType(): ProjectScoreType? = scoreType + /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") fun categories(): Categories? = categories @JsonProperty("config") fun config(): ProjectScoreConfig? = config @@ -138,6 +139,7 @@ constructor( @JsonProperty("score_type") fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") fun categories(categories: Categories) = apply { this.categories = categories } 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 834c61b5..69b8a900 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 @@ -84,6 +84,7 @@ constructor( private val additionalProperties: Map, ) { + /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") fun categories(): Categories? = categories @JsonProperty("config") fun config(): ProjectScoreConfig? = config @@ -127,6 +128,7 @@ constructor( additionalProperties(projectScoreUpdateBody.additionalProperties) } + /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") fun categories(categories: Categories) = apply { this.categories = categories } From fa5ee1f34562b8ac88122f183ee307aec99ff496 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:57:34 +0000 Subject: [PATCH 14/87] chore: rebuild project due to codegen change (#78) --- .../braintrustdata/api/core/ClientOptions.kt | 54 ++-- .../com/braintrustdata/api/core/Utils.kt | 32 +- .../com/braintrustdata/api/core/Values.kt | 4 +- .../api/core/http/BinaryResponseContent.kt | 16 - .../braintrustdata/api/core/http/Headers.kt | 92 ++++++ .../api/core/http/HttpRequest.kt | 6 +- .../api/errors/BraintrustError.kt | 4 +- .../com/braintrustdata/api/models/Acl.kt | 4 +- .../api/models/AclBatchUpdateParams.kt | 22 +- .../api/models/AclBatchUpdateResponse.kt | 8 +- .../api/models/AclCreateParams.kt | 10 +- .../api/models/AclDeleteParams.kt | 8 +- .../api/models/AclFindAndDeleteParams.kt | 10 +- .../braintrustdata/api/models/AclListPage.kt | 4 +- .../api/models/AclListPageAsync.kt | 4 +- .../api/models/AclListParams.kt | 8 +- .../api/models/AclRetrieveParams.kt | 6 +- .../com/braintrustdata/api/models/AiSecret.kt | 6 +- .../api/models/AiSecretCreateParams.kt | 12 +- .../api/models/AiSecretDeleteParams.kt | 8 +- .../api/models/AiSecretFindAndDeleteParams.kt | 10 +- .../api/models/AiSecretListPage.kt | 4 +- .../api/models/AiSecretListPageAsync.kt | 4 +- .../api/models/AiSecretListParams.kt | 8 +- .../api/models/AiSecretReplaceParams.kt | 12 +- .../api/models/AiSecretRetrieveParams.kt | 6 +- .../api/models/AiSecretUpdateParams.kt | 12 +- .../com/braintrustdata/api/models/ApiKey.kt | 4 +- .../api/models/ApiKeyCreateParams.kt | 10 +- .../api/models/ApiKeyDeleteParams.kt | 8 +- .../api/models/ApiKeyListPage.kt | 4 +- .../api/models/ApiKeyListPageAsync.kt | 4 +- .../api/models/ApiKeyListParams.kt | 8 +- .../api/models/ApiKeyRetrieveParams.kt | 6 +- .../models/ChatCompletionContentPartImage.kt | 6 +- .../models/ChatCompletionContentPartText.kt | 4 +- .../models/ChatCompletionMessageToolCall.kt | 6 +- .../braintrustdata/api/models/CodeBundle.kt | 10 +- .../api/models/CreateApiKeyOutput.kt | 4 +- .../api/models/CrossObjectInsertResponse.kt | 10 +- .../braintrustdata/api/models/DataSummary.kt | 4 +- .../com/braintrustdata/api/models/Dataset.kt | 6 +- .../api/models/DatasetCreateParams.kt | 10 +- .../api/models/DatasetDeleteParams.kt | 8 +- .../braintrustdata/api/models/DatasetEvent.kt | 8 +- .../api/models/DatasetFeedbackParams.kt | 15 +- .../api/models/DatasetFetchParams.kt | 8 +- .../api/models/DatasetFetchPostParams.kt | 14 +- .../api/models/DatasetInsertParams.kt | 15 +- .../api/models/DatasetListPage.kt | 4 +- .../api/models/DatasetListPageAsync.kt | 4 +- .../api/models/DatasetListParams.kt | 8 +- .../api/models/DatasetRetrieveParams.kt | 6 +- .../api/models/DatasetSummarizeParams.kt | 8 +- .../api/models/DatasetUpdateParams.kt | 12 +- .../com/braintrustdata/api/models/EnvVar.kt | 4 +- .../api/models/EnvVarCreateParams.kt | 10 +- .../api/models/EnvVarDeleteParams.kt | 8 +- .../api/models/EnvVarListParams.kt | 8 +- .../api/models/EnvVarListResponse.kt | 7 +- .../api/models/EnvVarReplaceParams.kt | 10 +- .../api/models/EnvVarRetrieveParams.kt | 6 +- .../api/models/EnvVarUpdateParams.kt | 10 +- .../api/models/EvalCreateParams.kt | 49 ++-- .../braintrustdata/api/models/Experiment.kt | 6 +- .../api/models/ExperimentCreateParams.kt | 12 +- .../api/models/ExperimentDeleteParams.kt | 8 +- .../api/models/ExperimentEvent.kt | 18 +- .../api/models/ExperimentFeedbackParams.kt | 15 +- .../api/models/ExperimentFetchParams.kt | 8 +- .../api/models/ExperimentFetchPostParams.kt | 14 +- .../api/models/ExperimentInsertParams.kt | 15 +- .../api/models/ExperimentListPage.kt | 4 +- .../api/models/ExperimentListPageAsync.kt | 4 +- .../api/models/ExperimentListParams.kt | 8 +- .../api/models/ExperimentRetrieveParams.kt | 6 +- .../api/models/ExperimentSummarizeParams.kt | 8 +- .../api/models/ExperimentUpdateParams.kt | 12 +- .../api/models/FeedbackDatasetItem.kt | 6 +- .../api/models/FeedbackExperimentItem.kt | 8 +- .../api/models/FeedbackProjectLogsItem.kt | 8 +- .../api/models/FeedbackResponseSchema.kt | 4 +- .../api/models/FetchDatasetEventsResponse.kt | 6 +- .../models/FetchExperimentEventsResponse.kt | 6 +- .../models/FetchProjectLogsEventsResponse.kt | 6 +- .../com/braintrustdata/api/models/Function.kt | 24 +- .../api/models/FunctionCreateParams.kt | 30 +- .../api/models/FunctionDeleteParams.kt | 8 +- .../api/models/FunctionInvokeParams.kt | 36 +-- .../api/models/FunctionInvokeResponse.kt | 4 +- .../api/models/FunctionListPage.kt | 4 +- .../api/models/FunctionListPageAsync.kt | 4 +- .../api/models/FunctionListParams.kt | 8 +- .../api/models/FunctionReplaceParams.kt | 30 +- .../api/models/FunctionRetrieveParams.kt | 6 +- .../api/models/FunctionToolChoice.kt | 4 +- .../api/models/FunctionUpdateParams.kt | 29 +- .../com/braintrustdata/api/models/Group.kt | 8 +- .../api/models/GroupCreateParams.kt | 18 +- .../api/models/GroupDeleteParams.kt | 8 +- .../api/models/GroupListPage.kt | 4 +- .../api/models/GroupListPageAsync.kt | 4 +- .../api/models/GroupListParams.kt | 8 +- .../api/models/GroupReplaceParams.kt | 18 +- .../api/models/GroupRetrieveParams.kt | 6 +- .../api/models/GroupUpdateParams.kt | 26 +- .../api/models/InsertDatasetEventMerge.kt | 10 +- .../api/models/InsertDatasetEventReplace.kt | 8 +- .../api/models/InsertEventsResponse.kt | 6 +- .../api/models/InsertExperimentEventMerge.kt | 18 +- .../models/InsertExperimentEventReplace.kt | 16 +- .../api/models/InsertProjectLogsEventMerge.kt | 18 +- .../models/InsertProjectLogsEventReplace.kt | 16 +- .../api/models/MetricSummary.kt | 4 +- .../api/models/OnlineScoreConfig.kt | 12 +- .../braintrustdata/api/models/Organization.kt | 4 +- .../api/models/OrganizationDeleteParams.kt | 8 +- .../api/models/OrganizationListPage.kt | 4 +- .../api/models/OrganizationListPageAsync.kt | 4 +- .../api/models/OrganizationListParams.kt | 8 +- .../models/OrganizationMemberUpdateParams.kt | 26 +- .../api/models/OrganizationRetrieveParams.kt | 6 +- .../api/models/OrganizationUpdateParams.kt | 10 +- .../models/PatchOrganizationMembersOutput.kt | 4 +- .../api/models/PathLookupFilter.kt | 6 +- .../com/braintrustdata/api/models/Project.kt | 4 +- .../api/models/ProjectCreateParams.kt | 10 +- .../api/models/ProjectDeleteParams.kt | 8 +- .../api/models/ProjectListPage.kt | 4 +- .../api/models/ProjectListPageAsync.kt | 4 +- .../api/models/ProjectListParams.kt | 8 +- .../api/models/ProjectLogFeedbackParams.kt | 15 +- .../api/models/ProjectLogFetchParams.kt | 8 +- .../api/models/ProjectLogFetchPostParams.kt | 14 +- .../api/models/ProjectLogInsertParams.kt | 15 +- .../api/models/ProjectLogsEvent.kt | 18 +- .../api/models/ProjectRetrieveParams.kt | 6 +- .../braintrustdata/api/models/ProjectScore.kt | 9 +- .../api/models/ProjectScoreCategory.kt | 4 +- .../api/models/ProjectScoreConfig.kt | 4 +- .../api/models/ProjectScoreCreateParams.kt | 15 +- .../api/models/ProjectScoreDeleteParams.kt | 8 +- .../api/models/ProjectScoreListPage.kt | 4 +- .../api/models/ProjectScoreListPageAsync.kt | 4 +- .../api/models/ProjectScoreListParams.kt | 8 +- .../api/models/ProjectScoreReplaceParams.kt | 15 +- .../api/models/ProjectScoreRetrieveParams.kt | 6 +- .../api/models/ProjectScoreUpdateParams.kt | 15 +- .../api/models/ProjectSettings.kt | 4 +- .../braintrustdata/api/models/ProjectTag.kt | 4 +- .../api/models/ProjectTagCreateParams.kt | 10 +- .../api/models/ProjectTagDeleteParams.kt | 8 +- .../api/models/ProjectTagListPage.kt | 4 +- .../api/models/ProjectTagListPageAsync.kt | 4 +- .../api/models/ProjectTagListParams.kt | 8 +- .../api/models/ProjectTagReplaceParams.kt | 10 +- .../api/models/ProjectTagRetrieveParams.kt | 6 +- .../api/models/ProjectTagUpdateParams.kt | 10 +- .../api/models/ProjectUpdateParams.kt | 10 +- .../com/braintrustdata/api/models/Prompt.kt | 8 +- .../api/models/PromptCreateParams.kt | 14 +- .../braintrustdata/api/models/PromptData.kt | 61 ++-- .../api/models/PromptDeleteParams.kt | 8 +- .../api/models/PromptListPage.kt | 4 +- .../api/models/PromptListPageAsync.kt | 4 +- .../api/models/PromptListParams.kt | 8 +- .../api/models/PromptReplaceParams.kt | 14 +- .../api/models/PromptRetrieveParams.kt | 6 +- .../api/models/PromptUpdateParams.kt | 14 +- .../com/braintrustdata/api/models/RepoInfo.kt | 4 +- .../com/braintrustdata/api/models/Role.kt | 10 +- .../api/models/RoleCreateParams.kt | 20 +- .../api/models/RoleDeleteParams.kt | 8 +- .../braintrustdata/api/models/RoleListPage.kt | 4 +- .../api/models/RoleListPageAsync.kt | 4 +- .../api/models/RoleListParams.kt | 8 +- .../api/models/RoleReplaceParams.kt | 20 +- .../api/models/RoleRetrieveParams.kt | 6 +- .../api/models/RoleUpdateParams.kt | 30 +- .../braintrustdata/api/models/ScoreSummary.kt | 4 +- .../com/braintrustdata/api/models/Scorer.kt | 4 +- .../api/models/SummarizeDatasetResponse.kt | 4 +- .../api/models/SummarizeExperimentResponse.kt | 8 +- .../com/braintrustdata/api/models/Task.kt | 4 +- .../braintrustdata/api/models/ToolChoice.kt | 4 +- .../api/models/TopLevelHelloWorldParams.kt | 6 +- .../com/braintrustdata/api/models/User.kt | 4 +- .../braintrustdata/api/models/UserListPage.kt | 4 +- .../api/models/UserListPageAsync.kt | 4 +- .../api/models/UserListParams.kt | 8 +- .../api/models/UserRetrieveParams.kt | 6 +- .../com/braintrustdata/api/models/View.kt | 4 +- .../api/models/ViewCreateParams.kt | 10 +- .../com/braintrustdata/api/models/ViewData.kt | 4 +- .../api/models/ViewDataSearch.kt | 12 +- .../api/models/ViewDeleteParams.kt | 10 +- .../braintrustdata/api/models/ViewListPage.kt | 4 +- .../api/models/ViewListPageAsync.kt | 4 +- .../api/models/ViewListParams.kt | 8 +- .../braintrustdata/api/models/ViewOptions.kt | 10 +- .../api/models/ViewReplaceParams.kt | 10 +- .../api/models/ViewRetrieveParams.kt | 8 +- .../api/models/ViewUpdateParams.kt | 10 +- .../braintrustdata/api/services/Handlers.kt | 186 ------------ .../api/services/HttpRequestBodies.kt | 114 -------- .../api/core/http/HeadersTest.kt | 274 ++++++++++++++++++ .../api/core/http/SerializerTest.kt | 2 +- 207 files changed, 1320 insertions(+), 1306 deletions(-) delete mode 100755 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt delete mode 100755 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt delete mode 100755 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/HttpRequestBodies.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 77f87fc8..3a266f69 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -17,11 +17,11 @@ private constructor( @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @get:JvmName("baseUrl") val baseUrl: String, - @get:JvmName("apiKey") val apiKey: String?, @get:JvmName("headers") val headers: ListMultimap, @get:JvmName("queryParams") val queryParams: ListMultimap, @get:JvmName("responseValidation") val responseValidation: Boolean, @get:JvmName("maxRetries") val maxRetries: Int, + @get:JvmName("apiKey") val apiKey: String?, ) { fun toBuilder() = Builder().from(this) @@ -38,11 +38,11 @@ private constructor( class Builder { private var httpClient: HttpClient? = null - private var jsonMapper: JsonMapper? = null + private var jsonMapper: JsonMapper = jsonMapper() private var clock: Clock = Clock.systemUTC() private var baseUrl: String = PRODUCTION_URL - private var headers: MutableMap> = mutableMapOf() - private var queryParams: MutableMap> = mutableMapOf() + private var headers: ListMultimap = ArrayListMultimap.create() + private var queryParams: ListMultimap = ArrayListMultimap.create() private var responseValidation: Boolean = false private var maxRetries: Int = 2 private var apiKey: String? = null @@ -53,14 +53,8 @@ private constructor( jsonMapper = clientOptions.jsonMapper clock = clientOptions.clock baseUrl = clientOptions.baseUrl - headers = - clientOptions.headers.asMap().mapValuesTo(mutableMapOf()) { (_, value) -> - value.toMutableList() - } - queryParams = - clientOptions.queryParams.asMap().mapValuesTo(mutableMapOf()) { (_, value) -> - value.toMutableList() - } + headers = ArrayListMultimap.create(clientOptions.headers) + queryParams = ArrayListMultimap.create(clientOptions.queryParams) responseValidation = clientOptions.responseValidation maxRetries = clientOptions.maxRetries apiKey = clientOptions.apiKey @@ -70,47 +64,43 @@ private constructor( fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } - fun clock(clock: Clock) = apply { this.clock = clock } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun headers(headers: Map>) = apply { this.headers.clear() putAllHeaders(headers) } - fun putHeader(name: String, value: String) = apply { - this.headers.getOrPut(name) { mutableListOf() }.add(value) - } + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } fun putHeaders(name: String, values: Iterable) = apply { - this.headers.getOrPut(name) { mutableListOf() }.addAll(values) + headers.putAll(name, values) } fun putAllHeaders(headers: Map>) = apply { - headers.forEach(this::putHeaders) + headers.forEach(::putHeaders) } - fun removeHeader(name: String) = apply { this.headers.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { headers.removeAll(name) } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() putAllQueryParams(queryParams) } - fun putQueryParam(name: String, value: String) = apply { - this.queryParams.getOrPut(name) { mutableListOf() }.add(value) - } + fun putQueryParam(name: String, value: String) = apply { queryParams.put(name, value) } fun putQueryParams(name: String, values: Iterable) = apply { - this.queryParams.getOrPut(name) { mutableListOf() }.addAll(values) + queryParams.putAll(name, values) } fun putAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(this::putQueryParams) + queryParams.forEach(::putQueryParams) } - fun removeQueryParam(name: String) = apply { this.queryParams.put(name, mutableListOf()) } + fun removeQueryParam(name: String) = apply { queryParams.removeAll(name) } fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -137,8 +127,8 @@ private constructor( if (!apiKey.isNullOrEmpty()) { headers.put("Authorization", "Bearer ${apiKey}") } - this.headers.forEach(headers::replaceValues) - this.queryParams.forEach(queryParams::replaceValues) + this.headers.asMap().forEach(headers::replaceValues) + this.queryParams.asMap().forEach(queryParams::replaceValues) return ClientOptions( httpClient!!, @@ -149,14 +139,14 @@ private constructor( .maxRetries(maxRetries) .build() ), - jsonMapper ?: jsonMapper(), + jsonMapper, clock, baseUrl, - apiKey, - headers.toUnmodifiable(), - queryParams.toUnmodifiable(), + headers.toImmutable(), + queryParams.toImmutable(), responseValidation, maxRetries, + apiKey, ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 795c75cd..499786b9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -5,38 +5,28 @@ package com.braintrustdata.api.core import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.google.common.collect.ImmutableListMultimap import com.google.common.collect.ListMultimap -import com.google.common.collect.Multimaps import java.util.Collections +import java.util.SortedMap @JvmSynthetic internal fun T?.getOrThrow(name: String): T = this ?: throw BraintrustInvalidDataException("`${name}` is not present") @JvmSynthetic -internal fun List.toUnmodifiable(): List { - if (isEmpty()) { - return Collections.emptyList() - } - - return Collections.unmodifiableList(this) -} +internal fun List.toImmutable(): List = + if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) @JvmSynthetic -internal fun Map.toUnmodifiable(): Map { - if (isEmpty()) { - return Collections.emptyMap() - } - - return Collections.unmodifiableMap(this) -} +internal fun Map.toImmutable(): Map = + if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap()) @JvmSynthetic -internal fun ListMultimap.toUnmodifiable(): ListMultimap { - if (isEmpty()) { - return ImmutableListMultimap.of() - } +internal fun , V> SortedMap.toImmutable(): SortedMap = + if (isEmpty()) Collections.emptySortedMap() + else Collections.unmodifiableSortedMap(toSortedMap(comparator())) - return Multimaps.unmodifiableListMultimap(this) -} +@JvmSynthetic +internal fun ListMultimap.toImmutable(): ListMultimap = + ImmutableListMultimap.copyOf(this) internal interface Enum diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 1dfdbfa7..48703257 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -389,7 +389,7 @@ private constructor( override fun toString() = values.toString() companion object { - @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toUnmodifiable()) + @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) } } @@ -415,7 +415,7 @@ private constructor( companion object { @JsonCreator @JvmStatic - fun of(values: Map) = JsonObject(values.toUnmodifiable()) + fun of(values: Map) = JsonObject(values.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt deleted file mode 100755 index c10ab40f..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.braintrustdata.api.core.http - -import java.io.IOException -import java.io.InputStream -import java.io.OutputStream -import java.lang.AutoCloseable -import java.util.Optional - -interface BinaryResponseContent : AutoCloseable { - - fun contentType(): Optional - - fun body(): InputStream - - @Throws(IOException::class) fun writeTo(outputStream: OutputStream) -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt new file mode 100644 index 00000000..2f344105 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt @@ -0,0 +1,92 @@ +package com.braintrustdata.api.core.http + +import com.braintrustdata.api.core.toImmutable +import java.util.TreeMap + +class Headers +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun names(): Set = map.keys + + fun values(name: String): List = map[name].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private val map: MutableMap> = + TreeMap(String.CASE_INSENSITIVE_ORDER) + private var size: Int = 0 + + fun put(name: String, value: String) = apply { + map.getOrPut(name) { mutableListOf() }.add(value) + size++ + } + + fun put(name: String, values: Iterable) = apply { values.forEach { put(name, it) } } + + fun putAll(headers: Map>) = apply { headers.forEach(::put) } + + fun putAll(headers: Headers) = apply { + headers.names().forEach { put(it, headers.values(it)) } + } + + fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } + + fun removeAll(names: Set) = apply { names.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun replace(name: String, value: String) = apply { + remove(name) + put(name, value) + } + + fun replace(name: String, values: Iterable) = apply { + remove(name) + put(name, values) + } + + fun replaceAll(headers: Map>) = apply { + headers.forEach(::replace) + } + + fun replaceAll(headers: Headers) = apply { + headers.names().forEach { replace(it, headers.values(it)) } + } + + fun build() = + Headers( + map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> + values.toImmutable() + } + .toImmutable(), + size + ) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && map == other.map + } + + override fun toString(): String = "Headers{map=$map}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index 4662ece7..340f33d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -1,6 +1,6 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ListMultimap import com.google.common.collect.Multimap @@ -83,8 +83,8 @@ private constructor( HttpRequest( checkNotNull(method) { "`method` is required but was not set" }, url, - pathSegments.toUnmodifiable(), - queryParams.toUnmodifiable(), + pathSegments.toImmutable(), + queryParams.toImmutable(), headers, body, ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index aa821e80..29925864 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.databind.annotation.JsonDeserialize @@ -62,6 +62,6 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): BraintrustError = BraintrustError(additionalProperties.toUnmodifiable()) + fun build(): BraintrustError = BraintrustError(additionalProperties.toImmutable()) } } 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 25b577be..5dc79cec 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 @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -317,7 +317,7 @@ private constructor( roleId, _objectOrgId, created, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 f41f20ec..be172f2e 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -145,9 +145,9 @@ constructor( fun build(): AclBatchUpdateBody = AclBatchUpdateBody( - addAcls?.toUnmodifiable(), - removeAcls?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + addAcls?.toImmutable(), + removeAcls?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -328,11 +328,11 @@ constructor( fun build(): AclBatchUpdateParams = AclBatchUpdateParams( - if (addAcls.size == 0) null else addAcls.toUnmodifiable(), - if (removeAcls.size == 0) null else removeAcls.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (addAcls.size == 0) null else addAcls.toImmutable(), + if (removeAcls.size == 0) null else removeAcls.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -493,7 +493,7 @@ constructor( permission, restrictObjectType, roleId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -991,7 +991,7 @@ constructor( permission, restrictObjectType, roleId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index 48ad5d75..a9055b0d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -175,9 +175,9 @@ private constructor( fun build(): AclBatchUpdateResponse = AclBatchUpdateResponse( - addedAcls.map { it.toUnmodifiable() }, - removedAcls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + addedAcls.map { it.toImmutable() }, + removedAcls.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } 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 82944d42..ef8f99be 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -221,7 +221,7 @@ constructor( restrictObjectType, roleId, userId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -400,9 +400,9 @@ constructor( restrictObjectType, roleId, userId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 93e7f1e1..fac4c02a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): AclDeleteParams = AclDeleteParams( checkNotNull(aclId) { "`aclId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 7d334fa5..2d8a55c3 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -221,7 +221,7 @@ constructor( restrictObjectType, roleId, userId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -400,9 +400,9 @@ constructor( restrictObjectType, roleId, userId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index 86271fa0..2e952c62 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.AclService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -150,7 +150,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index 05369260..681e3c3a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.AclServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -153,7 +153,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } 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 70a432dd..799893b9 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 @@ -9,7 +9,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator @@ -57,7 +57,7 @@ constructor( this.limit?.let { params.put("limit", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -205,8 +205,8 @@ constructor( ids, limit, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 11b1ce01..145ffc77 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): AclRetrieveParams = AclRetrieveParams( checkNotNull(aclId) { "`aclId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt index 8543661d..fcd4b525 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -189,7 +189,7 @@ private constructor( type, metadata, previewSecret, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -242,7 +242,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index c8ac3207..20666ab6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -157,7 +157,7 @@ constructor( orgName, secret, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -315,9 +315,9 @@ constructor( orgName, secret, type, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -362,7 +362,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index 5403ba52..239f8ab3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): AiSecretDeleteParams = AiSecretDeleteParams( checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 064eb2fa..2e8aa872 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -112,7 +112,7 @@ constructor( AiSecretFindAndDeleteBody( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -251,9 +251,9 @@ constructor( AiSecretFindAndDeleteParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index a0e9abfc..23448015 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.AiSecretService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -156,7 +156,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 7b2b31aa..1a91a044 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.AiSecretServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -163,7 +163,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 4be9c8dc..1388bdbe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -58,7 +58,7 @@ constructor( this.orgName?.let { params.put("org_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -219,8 +219,8 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 130b0aef..1301136a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -157,7 +157,7 @@ constructor( orgName, secret, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -315,9 +315,9 @@ constructor( orgName, secret, type, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -362,7 +362,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index c4d8d0e2..d8fc8a97 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 449d0223..ad973d8d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -136,7 +136,7 @@ constructor( name, secret, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -286,9 +286,9 @@ constructor( name, secret, type, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -333,7 +333,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 78072843..3442296e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -175,7 +175,7 @@ private constructor( previewName, userId, orgId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 79d4d800..04374360 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -112,7 +112,7 @@ constructor( ApiKeyCreateBody( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -251,9 +251,9 @@ constructor( ApiKeyCreateParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index 337d12c8..3793cc0e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 5a79da82..46913160 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.ApiKeyService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -150,7 +150,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index b3d2f9a4..dc2c5d58 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.ApiKeyServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -153,7 +153,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index bf72099b..8cc30c18 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -54,7 +54,7 @@ constructor( this.orgName?.let { params.put("org_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -202,8 +202,8 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 1a577eb5..b4b1b0d5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index cd41c589..2e7b9f90 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -99,7 +99,7 @@ private constructor( ChatCompletionContentPartImage( imageUrl, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -184,7 +184,7 @@ private constructor( ImageUrl( url, detail, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index 0a46ca17..f8787516 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -99,7 +99,7 @@ private constructor( ChatCompletionContentPartText( text, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index dbe33932..5327e7f0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -111,7 +111,7 @@ private constructor( id, function, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -196,7 +196,7 @@ private constructor( Function( arguments, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index 844b82b2..cc2574a6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -145,7 +145,7 @@ private constructor( location, bundleId, preview, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -363,7 +363,7 @@ private constructor( type, evalName, position, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -639,7 +639,7 @@ private constructor( Function( type, index, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -797,7 +797,7 @@ private constructor( RuntimeContext( runtime, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index aa08e7f4..733e9d8d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -194,7 +194,7 @@ private constructor( userId, orgId, key, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index b4f6ca10..88cf8bd4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -127,7 +127,7 @@ private constructor( experiment, dataset, projectLogs, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -181,7 +181,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Dataset = Dataset(additionalProperties.toUnmodifiable()) + fun build(): Dataset = Dataset(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -254,7 +254,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Experiment = Experiment(additionalProperties.toUnmodifiable()) + fun build(): Experiment = Experiment(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -327,7 +327,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogs = ProjectLogs(additionalProperties.toUnmodifiable()) + fun build(): ProjectLogs = ProjectLogs(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index b09f0838..b07ee919 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -82,7 +82,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DataSummary = DataSummary(totalRecords, additionalProperties.toUnmodifiable()) + fun build(): DataSummary = DataSummary(totalRecords, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 325b230e..df03f7a7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -219,7 +219,7 @@ private constructor( deletedAt, userId, metadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -273,7 +273,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 5390c300..84e5deb3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -119,7 +119,7 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, description, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -260,9 +260,9 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index aa332eff..1355cf43 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): DatasetDeleteParams = DatasetDeleteParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 08d204b8..cdc81f4c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -344,10 +344,10 @@ private constructor( input, expected, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, spanId, rootSpanId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -407,7 +407,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index b3fbe140..3b9ee122 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -96,8 +96,8 @@ constructor( fun build(): DatasetFeedbackBody = DatasetFeedbackBody( checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + .toImmutable(), + additionalProperties.toImmutable() ) } @@ -237,11 +237,10 @@ constructor( fun build(): DatasetFeedbackParams = DatasetFeedbackParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 6202841f..afaa9da2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -37,7 +37,7 @@ constructor( this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } this.version?.let { params.put("version", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -200,8 +200,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 945c769d..3781f559 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -276,12 +276,12 @@ constructor( fun build(): DatasetFetchPostBody = DatasetFetchPostBody( cursor, - filters?.toUnmodifiable(), + filters?.toImmutable(), limit, maxRootSpanId, maxXactId, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -508,14 +508,14 @@ constructor( DatasetFetchPostParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toUnmodifiable(), + if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index ef809f0f..57d030a3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -105,9 +105,8 @@ constructor( fun build(): DatasetInsertBody = DatasetInsertBody( - checkNotNull(events) { "`events` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + additionalProperties.toImmutable() ) } @@ -247,10 +246,10 @@ constructor( fun build(): DatasetInsertParams = DatasetInsertParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index 636f0fbf..6e878af8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.DatasetService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -156,7 +156,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index b0a51d0c..75bfa66f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.DatasetServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -163,7 +163,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 2f4645b3..89d040ca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -62,7 +62,7 @@ constructor( this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -222,8 +222,8 @@ constructor( projectId, projectName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index 833cc3fc..b8079c17 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): DatasetRetrieveParams = DatasetRetrieveParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index bc730d6d..377115e8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -25,7 +25,7 @@ constructor( val params = mutableMapOf>() this.summarizeData?.let { params.put("summarize_data", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -131,8 +131,8 @@ constructor( DatasetSummarizeParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, summarizeData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 148e70e1..6a567c8b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -129,7 +129,7 @@ constructor( description, metadata, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -276,9 +276,9 @@ constructor( description, metadata, name, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -324,7 +324,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index f6242dc9..483a52a5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -182,7 +182,7 @@ private constructor( name, created, used, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 56aeae21..9eee9beb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -137,7 +137,7 @@ constructor( checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -284,9 +284,9 @@ constructor( checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, value, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index e3e82fb3..def79a86 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): EnvVarDeleteParams = EnvVarDeleteParams( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } 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 9dcaf1d1..377c8226 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 @@ -9,7 +9,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator @@ -53,7 +53,7 @@ constructor( this.objectId?.let { params.put("object_id", listOf(it.toString())) } this.objectType?.let { params.put("object_type", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -183,8 +183,8 @@ constructor( limit, objectId, objectType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 22112cd4..983be40d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -82,10 +82,7 @@ private constructor( } fun build(): EnvVarListResponse = - EnvVarListResponse( - objects.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) + EnvVarListResponse(objects.map { it.toImmutable() }, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index cb7eb09d..b673f7af 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -137,7 +137,7 @@ constructor( checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -284,9 +284,9 @@ constructor( checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, value, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 764d154d..32689ef5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index e502769a..d6646700 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -113,7 +113,7 @@ constructor( EnvVarUpdateBody( checkNotNull(name) { "`name` is required but was not set" }, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -254,9 +254,9 @@ constructor( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, value, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 0ef11ee3..9c9213dd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -207,13 +207,12 @@ constructor( EvalCreateBody( checkNotNull(data) { "`data` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(scores) { "`scores` is required but was not set" } - .toUnmodifiable(), + checkNotNull(scores) { "`scores` is required but was not set" }.toImmutable(), checkNotNull(task) { "`task` is required but was not set" }, experimentName, metadata, stream, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -423,14 +422,14 @@ constructor( EvalCreateParams( checkNotNull(data) { "`data` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(scores) { "`scores` is required but was not set" }.toUnmodifiable(), + checkNotNull(scores) { "`scores` is required but was not set" }.toImmutable(), checkNotNull(task) { "`task` is required but was not set" }, experimentName, metadata, stream, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -622,7 +621,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetId = DatasetId(datasetId, additionalProperties.toUnmodifiable()) + fun build(): DatasetId = DatasetId(datasetId, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -733,7 +732,7 @@ constructor( ProjectDatasetName( projectName, datasetName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1059,7 +1058,7 @@ constructor( FunctionId( functionId, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1196,7 +1195,7 @@ constructor( projectName, slug, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1306,7 +1305,7 @@ constructor( } fun build(): GlobalFunction = - GlobalFunction(globalFunction, additionalProperties.toUnmodifiable()) + GlobalFunction(globalFunction, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1451,7 +1450,7 @@ constructor( promptSessionId, promptSessionFunctionId, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1585,7 +1584,7 @@ constructor( inlineContext, code, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1671,7 +1670,7 @@ constructor( InlineContext( runtime, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1870,7 +1869,7 @@ constructor( InlinePrompt( inlinePrompt, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2195,7 +2194,7 @@ constructor( FunctionId( functionId, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2332,7 +2331,7 @@ constructor( projectName, slug, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2442,7 +2441,7 @@ constructor( } fun build(): GlobalFunction = - GlobalFunction(globalFunction, additionalProperties.toUnmodifiable()) + GlobalFunction(globalFunction, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2587,7 +2586,7 @@ constructor( promptSessionId, promptSessionFunctionId, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2721,7 +2720,7 @@ constructor( inlineContext, code, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2807,7 +2806,7 @@ constructor( InlineContext( runtime, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3006,7 +3005,7 @@ constructor( InlinePrompt( inlinePrompt, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3077,7 +3076,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 7d6d775b..76a90944 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -364,7 +364,7 @@ private constructor( public_, userId, metadata, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -418,7 +418,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index df88f2a2..446b35d3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -250,7 +250,7 @@ constructor( name, public_, repoInfo, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -445,9 +445,9 @@ constructor( name, public_, repoInfo, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -493,7 +493,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index d1522848..90a4dcb0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): ExperimentDeleteParams = ExperimentDeleteParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index debb6043..a2b19b1e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -633,14 +633,14 @@ private constructor( error, scores, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, metrics, context, spanId, - spanParents.map { it.toUnmodifiable() }, + spanParents.map { it.toImmutable() }, rootSpanId, spanAttributes, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -770,7 +770,7 @@ private constructor( callerFunctionname, callerFilename, callerLineno, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -851,7 +851,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1082,7 +1082,7 @@ private constructor( promptTokens, completionTokens, tokens, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1165,7 +1165,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1278,7 +1278,7 @@ private constructor( SpanAttributes( name, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 8b2a759e..d6fc77c1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -98,8 +98,8 @@ constructor( fun build(): ExperimentFeedbackBody = ExperimentFeedbackBody( checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + .toImmutable(), + additionalProperties.toImmutable() ) } @@ -239,11 +239,10 @@ constructor( fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index cb530419..8e86da70 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -37,7 +37,7 @@ constructor( this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } this.version?.let { params.put("version", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -200,8 +200,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 36eafdcb..c0fa53ba 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -276,12 +276,12 @@ constructor( fun build(): ExperimentFetchPostBody = ExperimentFetchPostBody( cursor, - filters?.toUnmodifiable(), + filters?.toImmutable(), limit, maxRootSpanId, maxXactId, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -508,14 +508,14 @@ constructor( ExperimentFetchPostParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toUnmodifiable(), + if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 728d5bdb..cc86d923 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -105,9 +105,8 @@ constructor( fun build(): ExperimentInsertBody = ExperimentInsertBody( - checkNotNull(events) { "`events` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + additionalProperties.toImmutable() ) } @@ -247,10 +246,10 @@ constructor( fun build(): ExperimentInsertParams = ExperimentInsertParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 4e6b5d8f..84f15d25 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.ExperimentService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -160,7 +160,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index ff0a1487..9b7089c9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.ExperimentServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -163,7 +163,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index a2b8bb99..3e6a63f0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -62,7 +62,7 @@ constructor( this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -222,8 +222,8 @@ constructor( projectId, projectName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index ebb46148..3d683823 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 8923ed07..1c7fa7dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -31,7 +31,7 @@ constructor( } this.summarizeScores?.let { params.put("summarize_scores", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -153,8 +153,8 @@ constructor( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, comparisonExperimentId, summarizeScores, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 37a22a12..5f690c3e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -222,7 +222,7 @@ constructor( name, public_, repoInfo, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -407,9 +407,9 @@ constructor( name, public_, repoInfo, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -455,7 +455,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 3422a014..180d5da5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -167,7 +167,7 @@ private constructor( comment, metadata, source, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -224,7 +224,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index f05a762a..9a7f2303 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -223,7 +223,7 @@ private constructor( comment, metadata, source, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -280,7 +280,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -356,7 +356,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 776bee1a..46b6f743 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -223,7 +223,7 @@ private constructor( comment, metadata, source, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -280,7 +280,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -356,7 +356,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index a14a83a4..f97ba0b6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -81,7 +81,7 @@ private constructor( } fun build(): FeedbackResponseSchema = - FeedbackResponseSchema(status, additionalProperties.toUnmodifiable()) + FeedbackResponseSchema(status, additionalProperties.toImmutable()) } class Status diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 6d3bd511..671c2340 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -122,9 +122,9 @@ private constructor( fun build(): FetchDatasetEventsResponse = FetchDatasetEventsResponse( - events.map { it.toUnmodifiable() }, + events.map { it.toImmutable() }, cursor, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 6be52808..e8874422 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -122,9 +122,9 @@ private constructor( fun build(): FetchExperimentEventsResponse = FetchExperimentEventsResponse( - events.map { it.toUnmodifiable() }, + events.map { it.toImmutable() }, cursor, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 49bebdf3..84c37b04 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -122,9 +122,9 @@ private constructor( fun build(): FetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse( - events.map { it.toUnmodifiable() }, + events.map { it.toImmutable() }, cursor, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 b81f35c2..b6981e01 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 @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -390,13 +390,13 @@ private constructor( description, created, promptData, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, metadata, functionType, functionData, origin, functionSchema, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -600,7 +600,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) + fun build(): Prompt = Prompt(type, additionalProperties.toImmutable()) } class Type @@ -757,7 +757,7 @@ private constructor( Code( type, data, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1030,7 +1030,7 @@ private constructor( bundleId, preview, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1211,7 +1211,7 @@ private constructor( type, runtimeContext, code, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1302,7 +1302,7 @@ private constructor( RuntimeContext( runtime, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1616,7 +1616,7 @@ private constructor( Global( type, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1822,7 +1822,7 @@ private constructor( FunctionSchema( parameters, returns, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1966,7 +1966,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2111,7 +2111,7 @@ private constructor( objectType, objectId, internal_, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 d8f764c2..e898103d 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 @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.CodeBundle.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -234,8 +234,8 @@ constructor( functionType, origin, promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + tags?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -434,10 +434,10 @@ constructor( functionType, origin, promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (tags.size == 0) null else tags.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -641,7 +641,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) + fun build(): Prompt = Prompt(type, additionalProperties.toImmutable()) } class Type @@ -798,7 +798,7 @@ constructor( Code( type, data, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1068,7 +1068,7 @@ constructor( bundleId, preview, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1249,7 +1249,7 @@ constructor( type, runtimeContext, code, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1340,7 +1340,7 @@ constructor( RuntimeContext( runtime, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1654,7 +1654,7 @@ constructor( Global( type, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1793,7 +1793,7 @@ constructor( FunctionSchema( parameters, returns, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1969,7 +1969,7 @@ constructor( checkNotNull(objectType) { "`objectType` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, internal_, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index bbadeeff..70c05266 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): FunctionDeleteParams = FunctionDeleteParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 6c16f962..d7eff11a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -186,12 +186,12 @@ constructor( fun build(): FunctionInvokeBody = FunctionInvokeBody( input, - messages?.toUnmodifiable(), + messages?.toImmutable(), mode, parent, stream, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -368,14 +368,14 @@ constructor( FunctionInvokeParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, input, - if (messages.size == 0) null else messages.toUnmodifiable(), + if (messages.size == 0) null else messages.toImmutable(), mode, parent, stream, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -676,7 +676,7 @@ constructor( content, role, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -849,7 +849,7 @@ constructor( content, role, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1176,8 +1176,8 @@ constructor( content, functionCall, name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + toolCalls.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1316,7 +1316,7 @@ constructor( FunctionCall( arguments, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1462,7 +1462,7 @@ constructor( content, role, toolCallId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1635,7 +1635,7 @@ constructor( content, name, role, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1793,7 +1793,7 @@ constructor( Fallback( role, content, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2178,7 +2178,7 @@ constructor( objectId, rowIds, propagatedEvent, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2291,7 +2291,7 @@ constructor( } fun build(): PropagatedEvent = - PropagatedEvent(additionalProperties.toUnmodifiable()) + PropagatedEvent(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2427,7 +2427,7 @@ constructor( id, spanId, rootSpanId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index da7f8dd4..854fbf3f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.databind.annotation.JsonDeserialize @@ -61,7 +61,7 @@ private constructor( } fun build(): FunctionInvokeResponse = - FunctionInvokeResponse(additionalProperties.toUnmodifiable()) + FunctionInvokeResponse(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index cd1d3a44..033c109b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.FunctionService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -156,7 +156,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index ba488e94..7a907505 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.FunctionServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -163,7 +163,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 20350b57..771a250d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -70,7 +70,7 @@ constructor( this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } this.version?.let { params.put("version", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -247,8 +247,8 @@ constructor( slug, startingAfter, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 dcb49d58..5b591105 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 @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.CodeBundle.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -234,8 +234,8 @@ constructor( functionType, origin, promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + tags?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -434,10 +434,10 @@ constructor( functionType, origin, promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (tags.size == 0) null else tags.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -641,7 +641,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) + fun build(): Prompt = Prompt(type, additionalProperties.toImmutable()) } class Type @@ -798,7 +798,7 @@ constructor( Code( type, data, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1068,7 +1068,7 @@ constructor( bundleId, preview, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1249,7 +1249,7 @@ constructor( type, runtimeContext, code, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1340,7 +1340,7 @@ constructor( RuntimeContext( runtime, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1654,7 +1654,7 @@ constructor( Global( type, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1793,7 +1793,7 @@ constructor( FunctionSchema( parameters, returns, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1969,7 +1969,7 @@ constructor( checkNotNull(objectType) { "`objectType` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, internal_, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index ada64538..24c84097 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): FunctionRetrieveParams = FunctionRetrieveParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt index 4c21b784..6964d2bf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -78,7 +78,7 @@ private constructor( } fun build(): FunctionToolChoice = - FunctionToolChoice(name, additionalProperties.toUnmodifiable()) + FunctionToolChoice(name, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 95cdbcab..3e6be905 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.CodeBundle.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -171,8 +171,8 @@ constructor( functionData, name, promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + tags?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -351,10 +351,10 @@ constructor( functionData, name, promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (tags.size == 0) null else tags.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -579,7 +579,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) + fun build(): Prompt = Prompt(type, additionalProperties.toImmutable()) } class Type @@ -736,7 +736,7 @@ constructor( Code( type, data, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1006,7 +1006,7 @@ constructor( bundleId, preview, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1187,7 +1187,7 @@ constructor( type, runtimeContext, code, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1278,7 +1278,7 @@ constructor( RuntimeContext( runtime, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1592,7 +1592,7 @@ constructor( Global( type, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1718,8 +1718,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index f82897d5..ad3cac21 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -283,9 +283,9 @@ private constructor( name, description, deletedAt, - memberUsers.map { it.toUnmodifiable() }, - memberGroups.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + memberUsers.map { it.toImmutable() }, + memberGroups.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 91245477..35722c3f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -166,10 +166,10 @@ constructor( GroupCreateBody( checkNotNull(name) { "`name` is required but was not set" }, description, - memberGroups?.toUnmodifiable(), - memberUsers?.toUnmodifiable(), + memberGroups?.toImmutable(), + memberUsers?.toImmutable(), orgName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -345,12 +345,12 @@ constructor( GroupCreateParams( checkNotNull(name) { "`name` is required but was not set" }, description, - if (memberGroups.size == 0) null else memberGroups.toUnmodifiable(), - if (memberUsers.size == 0) null else memberUsers.toUnmodifiable(), + if (memberGroups.size == 0) null else memberGroups.toImmutable(), + if (memberUsers.size == 0) null else memberUsers.toImmutable(), orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index dd1df7ef..edb55533 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): GroupDeleteParams = GroupDeleteParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 1c96005e..fd65dbbe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.GroupService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -150,7 +150,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index 3f977879..b4ba90ad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.GroupServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -153,7 +153,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 79f31933..f2ccc6d9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -54,7 +54,7 @@ constructor( this.orgName?.let { params.put("org_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -202,8 +202,8 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 347027b9..bcb78789 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -166,10 +166,10 @@ constructor( GroupReplaceBody( checkNotNull(name) { "`name` is required but was not set" }, description, - memberGroups?.toUnmodifiable(), - memberUsers?.toUnmodifiable(), + memberGroups?.toImmutable(), + memberUsers?.toImmutable(), orgName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -345,12 +345,12 @@ constructor( GroupReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, description, - if (memberGroups.size == 0) null else memberGroups.toUnmodifiable(), - if (memberUsers.size == 0) null else memberUsers.toUnmodifiable(), + if (memberGroups.size == 0) null else memberGroups.toImmutable(), + if (memberUsers.size == 0) null else memberUsers.toImmutable(), orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index a4b5bae1..efd1b184 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): GroupRetrieveParams = GroupRetrieveParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 94ff5248..375a08d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -178,13 +178,13 @@ constructor( fun build(): GroupUpdateBody = GroupUpdateBody( - addMemberGroups?.toUnmodifiable(), - addMemberUsers?.toUnmodifiable(), + addMemberGroups?.toImmutable(), + addMemberUsers?.toImmutable(), description, name, - removeMemberGroups?.toUnmodifiable(), - removeMemberUsers?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + removeMemberGroups?.toImmutable(), + removeMemberUsers?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -375,15 +375,15 @@ constructor( fun build(): GroupUpdateParams = GroupUpdateParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, - if (addMemberGroups.size == 0) null else addMemberGroups.toUnmodifiable(), - if (addMemberUsers.size == 0) null else addMemberUsers.toUnmodifiable(), + if (addMemberGroups.size == 0) null else addMemberGroups.toImmutable(), + if (addMemberUsers.size == 0) null else addMemberUsers.toImmutable(), description, name, - if (removeMemberGroups.size == 0) null else removeMemberGroups.toUnmodifiable(), - if (removeMemberUsers.size == 0) null else removeMemberUsers.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (removeMemberGroups.size == 0) null else removeMemberGroups.toImmutable(), + if (removeMemberUsers.size == 0) null else removeMemberUsers.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt index 4445f55c..d2f57519 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -381,13 +381,13 @@ private constructor( input, expected, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, id, created, _objectDelete, _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + _mergePaths.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -447,7 +447,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt index 62b686cb..7e0e8227 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -374,13 +374,13 @@ private constructor( input, expected, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, id, created, _objectDelete, _isMerge, _parentId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -440,7 +440,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 4daad75e..49e6a262 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -93,8 +93,8 @@ private constructor( fun build(): InsertEventsResponse = InsertEventsResponse( - rowIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() + rowIds.map { it.toImmutable() }, + additionalProperties.toImmutable() ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt index a757f159..347e678b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -634,7 +634,7 @@ private constructor( error, scores, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, metrics, context, spanAttributes, @@ -643,8 +643,8 @@ private constructor( created, _objectDelete, _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + _mergePaths.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -774,7 +774,7 @@ private constructor( callerFunctionname, callerFilename, callerLineno, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -855,7 +855,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1086,7 +1086,7 @@ private constructor( promptTokens, completionTokens, tokens, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1169,7 +1169,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1282,7 +1282,7 @@ private constructor( SpanAttributes( name, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt index f939b6da..534b5552 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -627,7 +627,7 @@ private constructor( error, scores, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, metrics, context, spanAttributes, @@ -637,7 +637,7 @@ private constructor( _objectDelete, _isMerge, _parentId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -767,7 +767,7 @@ private constructor( callerFunctionname, callerFilename, callerLineno, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -848,7 +848,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1079,7 +1079,7 @@ private constructor( promptTokens, completionTokens, tokens, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1162,7 +1162,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1275,7 +1275,7 @@ private constructor( SpanAttributes( name, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt index 5ec14eb3..d6b9ec48 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -587,7 +587,7 @@ private constructor( error, scores, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, metrics, context, spanAttributes, @@ -595,8 +595,8 @@ private constructor( created, _objectDelete, _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + _mergePaths.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -726,7 +726,7 @@ private constructor( callerFunctionname, callerFilename, callerLineno, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -807,7 +807,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1038,7 +1038,7 @@ private constructor( promptTokens, completionTokens, tokens, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1121,7 +1121,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1234,7 +1234,7 @@ private constructor( SpanAttributes( name, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt index 8b1ee414..077294aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -580,7 +580,7 @@ private constructor( error, scores, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, metrics, context, spanAttributes, @@ -589,7 +589,7 @@ private constructor( _objectDelete, _isMerge, _parentId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -719,7 +719,7 @@ private constructor( callerFunctionname, callerFilename, callerLineno, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -800,7 +800,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1031,7 +1031,7 @@ private constructor( promptTokens, completionTokens, tokens, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1114,7 +1114,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1227,7 +1227,7 @@ private constructor( SpanAttributes( name, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index 4336a5f1..029e9b9c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -181,7 +181,7 @@ private constructor( diff, improvements, regressions, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 9c8a1620..79c3826c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -161,10 +161,10 @@ private constructor( fun build(): OnlineScoreConfig = OnlineScoreConfig( samplingRate, - scorers.map { it.toUnmodifiable() }, + scorers.map { it.toImmutable() }, applyToRootSpan, - applyToSpanNames.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + applyToSpanNames.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -367,7 +367,7 @@ private constructor( Function( type, id, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -525,7 +525,7 @@ private constructor( Global( type, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index a586fcb4..1baae702 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -186,7 +186,7 @@ private constructor( proxyUrl, realtimeUrl, created, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index 3e5294c1..8867b84a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): OrganizationDeleteParams = OrganizationDeleteParams( checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index 6555fc93..d9617280 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.OrganizationService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -160,7 +160,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index 1f73b9f9..e3e67824 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.OrganizationServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -163,7 +163,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index fca42385..1d93a5a4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -50,7 +50,7 @@ constructor( this.orgName?.let { params.put("org_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -192,8 +192,8 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 6cacca69..31d58e68 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -152,7 +152,7 @@ constructor( orgId, orgName, removeUsers, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -307,9 +307,9 @@ constructor( orgId, orgName, removeUsers, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -428,14 +428,14 @@ constructor( fun build(): InviteUsers = InviteUsers( - ids?.toUnmodifiable(), - emails?.toUnmodifiable(), + ids?.toImmutable(), + emails?.toImmutable(), sendInviteEmails, - groupIds?.toUnmodifiable(), - groupNames?.toUnmodifiable(), + groupIds?.toImmutable(), + groupNames?.toImmutable(), groupId, groupName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -523,9 +523,9 @@ constructor( fun build(): RemoveUsers = RemoveUsers( - ids?.toUnmodifiable(), - emails?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + ids?.toImmutable(), + emails?.toImmutable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 63569b8a..b55457db 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 468cef37..c3e24b6e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -152,7 +152,7 @@ constructor( name, proxyUrl, realtimeUrl, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -307,9 +307,9 @@ constructor( name, proxyUrl, realtimeUrl, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index f7948d50..7b98d59d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -118,7 +118,7 @@ private constructor( PatchOrganizationMembersOutput( status, sendEmailError, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt index 5dc888a5..84540bbc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -156,9 +156,9 @@ private constructor( fun build(): PathLookupFilter = PathLookupFilter( type, - path.map { it.toUnmodifiable() }, + path.map { it.toImmutable() }, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 8b2ed686..d5339198 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -196,7 +196,7 @@ private constructor( deletedAt, userId, settings, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index bcb55527..9d8ce8a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -112,7 +112,7 @@ constructor( ProjectCreateBody( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -251,9 +251,9 @@ constructor( ProjectCreateParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 132d0c2a..779b3b69 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): ProjectDeleteParams = ProjectDeleteParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index fece2a7d..5635ae73 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.ProjectService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -156,7 +156,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 401fb412..a019b26b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.ProjectServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -163,7 +163,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 19ebdba0..6abf8388 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -54,7 +54,7 @@ constructor( this.projectName?.let { params.put("project_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -202,8 +202,8 @@ constructor( orgName, projectName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index b94e9eb8..953e3ef1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -98,8 +98,8 @@ constructor( fun build(): ProjectLogFeedbackBody = ProjectLogFeedbackBody( checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + .toImmutable(), + additionalProperties.toImmutable() ) } @@ -239,11 +239,10 @@ constructor( fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index c24ff3ad..ac72c562 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -37,7 +37,7 @@ constructor( this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } this.version?.let { params.put("version", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -200,8 +200,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 8b156a99..016acf59 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -276,12 +276,12 @@ constructor( fun build(): ProjectLogFetchPostBody = ProjectLogFetchPostBody( cursor, - filters?.toUnmodifiable(), + filters?.toImmutable(), limit, maxRootSpanId, maxXactId, version, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -508,14 +508,14 @@ constructor( ProjectLogFetchPostParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toUnmodifiable(), + if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 02042d61..a1ea28fc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -105,9 +105,8 @@ constructor( fun build(): ProjectLogInsertBody = ProjectLogInsertBody( - checkNotNull(events) { "`events` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() + checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + additionalProperties.toImmutable() ) } @@ -247,10 +246,10 @@ constructor( fun build(): ProjectLogInsertParams = ProjectLogInsertParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index baabf2e2..4b00e9ed 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -604,14 +604,14 @@ private constructor( error, scores, metadata, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, metrics, context, spanId, - spanParents.map { it.toUnmodifiable() }, + spanParents.map { it.toImmutable() }, rootSpanId, spanAttributes, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -792,7 +792,7 @@ private constructor( callerFunctionname, callerFilename, callerLineno, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -873,7 +873,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1104,7 +1104,7 @@ private constructor( promptTokens, completionTokens, tokens, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1187,7 +1187,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1300,7 +1300,7 @@ private constructor( SpanAttributes( name, type, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 8c8116df..d9b3f9e0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): ProjectRetrieveParams = ProjectRetrieveParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 56f66f2a..50a0170c 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 @@ -10,7 +10,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -260,7 +260,7 @@ private constructor( categories, config, position, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -480,7 +480,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) + fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -553,8 +553,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index b131ecb5..79db9fbd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -104,7 +104,7 @@ private constructor( ProjectScoreCategory( name, value, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index b60f236b..1bf51379 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -118,7 +118,7 @@ private constructor( multiSelect, destination, online, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 2f1ecf6e..40c97d84 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 @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -172,7 +172,7 @@ constructor( categories, config, description, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -350,9 +350,9 @@ constructor( categories, config, description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -572,7 +572,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) + fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -645,8 +645,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index a528d830..8b3ff920 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index b7a3af06..ce5bf53e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.ProjectScoreService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -160,7 +160,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index 6efe963c..1f09685c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.ProjectScoreServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -163,7 +163,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } 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 ab95668d..dfce9e0b 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -66,7 +66,7 @@ constructor( this.scoreType?.let { params.put("score_type", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -244,8 +244,8 @@ constructor( projectScoreName, scoreType, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 8bddbd07..86277fbd 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 @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -172,7 +172,7 @@ constructor( categories, config, description, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -350,9 +350,9 @@ constructor( categories, config, description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -572,7 +572,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) + fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -645,8 +645,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 7ff755d1..37919485 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 69b8a900..6cf1c061 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 @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -167,7 +167,7 @@ constructor( description, name, scoreType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -345,9 +345,9 @@ constructor( description, name, scoreType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -567,7 +567,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) + fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -640,8 +640,7 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index d14a8707..dddda0c9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -86,7 +86,7 @@ private constructor( } fun build(): ProjectSettings = - ProjectSettings(comparisonKey, additionalProperties.toUnmodifiable()) + ProjectSettings(comparisonKey, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index aa10d385..55a488a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -199,7 +199,7 @@ private constructor( name, description, color, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index f31204d8..fc5ebb1f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -133,7 +133,7 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, color, description, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -280,9 +280,9 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, color, description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 71458816..3580cb93 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index f93071d5..ac4fbfea 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.ProjectTagService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -160,7 +160,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index aee77897..2ba47420 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.ProjectTagServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -163,7 +163,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 9b43b54d..8f83d31c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -62,7 +62,7 @@ constructor( this.projectTagName?.let { params.put("project_tag_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -222,8 +222,8 @@ constructor( projectName, projectTagName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index 51a0bdba..1be2b74e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -133,7 +133,7 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, color, description, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -280,9 +280,9 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, color, description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 90f5a22a..68ffb3fc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 3641ff1a..3add1220 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -128,7 +128,7 @@ constructor( color, description, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -275,9 +275,9 @@ constructor( color, description, name, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index 505467b5..f550e9de 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -120,7 +120,7 @@ constructor( ProjectUpdateBody( name, settings, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -264,9 +264,9 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, name, settings, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index e4c891cf..438b3ad8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -329,10 +329,10 @@ private constructor( description, created, promptData, - tags.map { it.toUnmodifiable() }, + tags.map { it.toImmutable() }, metadata, functionType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -506,7 +506,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index d31c2b09..0ae9e9c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -180,8 +180,8 @@ constructor( description, functionType, promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + tags?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -350,10 +350,10 @@ constructor( description, functionType, promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (tags.size == 0) null else tags.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index b6262022..f131d577 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -156,9 +156,9 @@ private constructor( prompt, options, parser, - toolFunctions.map { it.toUnmodifiable() }, + toolFunctions.map { it.toImmutable() }, origin, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -258,7 +258,7 @@ private constructor( model, params, position, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -720,8 +720,8 @@ private constructor( toolChoice, functionCall, n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + stop.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -1028,7 +1028,7 @@ private constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) + Function(name, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1119,7 +1119,7 @@ private constructor( ) = apply { this.additionalProperties.putAll(additionalProperties) } fun build(): ResponseFormat = - ResponseFormat(type, additionalProperties.toUnmodifiable()) + ResponseFormat(type, additionalProperties.toImmutable()) } class Type @@ -1390,9 +1390,9 @@ private constructor( temperature, topP, topK, - stopSequences.map { it.toUnmodifiable() }, + stopSequences.map { it.toImmutable() }, maxTokensToSample, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1554,7 +1554,7 @@ private constructor( maxOutputTokens, topP, topK, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1680,7 +1680,7 @@ private constructor( useCache, temperature, topK, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -1771,7 +1771,7 @@ private constructor( } fun build(): JsCompletionParams = - JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) + JsCompletionParams(useCache, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1916,7 +1916,7 @@ private constructor( promptId, projectId, promptVersion, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2039,7 +2039,7 @@ private constructor( type, useCot, choiceScores, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2093,7 +2093,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ChoiceScores = ChoiceScores(additionalProperties.toUnmodifiable()) + fun build(): ChoiceScores = ChoiceScores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2408,7 +2408,7 @@ private constructor( Completion( type, content, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2581,9 +2581,9 @@ private constructor( fun build(): Chat = Chat( type, - messages.map { it.toUnmodifiable() }, + messages.map { it.toImmutable() }, tools, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -2887,7 +2887,7 @@ private constructor( content, role, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3063,7 +3063,7 @@ private constructor( content, role, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3401,8 +3401,8 @@ private constructor( content, functionCall, name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + toolCalls.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -3543,7 +3543,7 @@ private constructor( FunctionCall( arguments, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3691,7 +3691,7 @@ private constructor( content, role, toolCallId, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -3867,7 +3867,7 @@ private constructor( content, name, role, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4028,7 +4028,7 @@ private constructor( Fallback( role, content, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4228,8 +4228,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -4452,7 +4451,7 @@ private constructor( Function( type, id, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -4610,7 +4609,7 @@ private constructor( Global( type, name, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 197004ad..84239868 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): PromptDeleteParams = PromptDeleteParams( checkNotNull(promptId) { "`promptId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index c7ca805e..0e8d72a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.PromptService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -150,7 +150,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index c55289e4..c7aa8ec6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.PromptServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -153,7 +153,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 28984928..d7d2c273 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -70,7 +70,7 @@ constructor( this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } this.version?.let { params.put("version", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -247,8 +247,8 @@ constructor( slug, startingAfter, version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 9b731273..32cbcf9e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -180,8 +180,8 @@ constructor( description, functionType, promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + tags?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -350,10 +350,10 @@ constructor( description, functionType, promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (tags.size == 0) null else tags.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index ace5c98d..4d7b1c25 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): PromptRetrieveParams = PromptRetrieveParams( checkNotNull(promptId) { "`promptId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index f03ef924..f219fa4c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -156,8 +156,8 @@ constructor( name, promptData, slug, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + tags?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -321,10 +321,10 @@ constructor( name, promptData, slug, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + if (tags.size == 0) null else tags.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index d57bd593..135364d3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -254,7 +254,7 @@ private constructor( commitMessage, commitTime, gitDiff, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 610b1156..9f311854 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 @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -299,9 +299,9 @@ private constructor( name, description, deletedAt, - memberPermissions.map { it.toUnmodifiable() }, - memberRoles.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + memberPermissions.map { it.toImmutable() }, + memberRoles.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @@ -420,7 +420,7 @@ private constructor( MemberPermission( permission, restrictObjectType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 4d55e6e5..ed2bbe33 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -172,10 +172,10 @@ constructor( RoleCreateBody( checkNotNull(name) { "`name` is required but was not set" }, description, - memberPermissions?.toUnmodifiable(), - memberRoles?.toUnmodifiable(), + memberPermissions?.toImmutable(), + memberRoles?.toImmutable(), orgName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -353,12 +353,12 @@ constructor( RoleCreateParams( checkNotNull(name) { "`name` is required but was not set" }, description, - if (memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), - if (memberRoles.size == 0) null else memberRoles.toUnmodifiable(), + if (memberPermissions.size == 0) null else memberPermissions.toImmutable(), + if (memberRoles.size == 0) null else memberRoles.toImmutable(), orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -439,7 +439,7 @@ constructor( MemberPermission( checkNotNull(permission) { "`permission` is required but was not set" }, restrictObjectType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 0423855c..3d3e82d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional @@ -139,9 +139,9 @@ constructor( fun build(): RoleDeleteParams = RoleDeleteParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index 99125be5..b78f7bec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.RoleService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -150,7 +150,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index 14597025..452fb9b6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.RoleServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -153,7 +153,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 44250688..0d0b9824 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -54,7 +54,7 @@ constructor( this.roleName?.let { params.put("role_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -202,8 +202,8 @@ constructor( orgName, roleName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 a9d35087..a46e8966 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -172,10 +172,10 @@ constructor( RoleReplaceBody( checkNotNull(name) { "`name` is required but was not set" }, description, - memberPermissions?.toUnmodifiable(), - memberRoles?.toUnmodifiable(), + memberPermissions?.toImmutable(), + memberRoles?.toImmutable(), orgName, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -353,12 +353,12 @@ constructor( RoleReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, description, - if (memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), - if (memberRoles.size == 0) null else memberRoles.toUnmodifiable(), + if (memberPermissions.size == 0) null else memberPermissions.toImmutable(), + if (memberRoles.size == 0) null else memberRoles.toImmutable(), orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -439,7 +439,7 @@ constructor( MemberPermission( checkNotNull(permission) { "`permission` is required but was not set" }, restrictObjectType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 7bcb1535..31122bef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): RoleRetrieveParams = RoleRetrieveParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 edf284f2..6fa82247 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -186,13 +186,13 @@ constructor( fun build(): RoleUpdateBody = RoleUpdateBody( - addMemberPermissions?.toUnmodifiable(), - addMemberRoles?.toUnmodifiable(), + addMemberPermissions?.toImmutable(), + addMemberRoles?.toImmutable(), description, name, - removeMemberPermissions?.toUnmodifiable(), - removeMemberRoles?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), + removeMemberPermissions?.toImmutable(), + removeMemberRoles?.toImmutable(), + additionalProperties.toImmutable(), ) } @@ -383,16 +383,16 @@ constructor( fun build(): RoleUpdateParams = RoleUpdateParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, - if (addMemberPermissions.size == 0) null else addMemberPermissions.toUnmodifiable(), - if (addMemberRoles.size == 0) null else addMemberRoles.toUnmodifiable(), + if (addMemberPermissions.size == 0) null else addMemberPermissions.toImmutable(), + if (addMemberRoles.size == 0) null else addMemberRoles.toImmutable(), description, name, if (removeMemberPermissions.size == 0) null - else removeMemberPermissions.toUnmodifiable(), - if (removeMemberRoles.size == 0) null else removeMemberRoles.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + else removeMemberPermissions.toImmutable(), + if (removeMemberRoles.size == 0) null else removeMemberRoles.toImmutable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } @@ -473,7 +473,7 @@ constructor( AddMemberPermission( checkNotNull(permission) { "`permission` is required but was not set" }, restrictObjectType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -780,7 +780,7 @@ constructor( RemoveMemberPermission( checkNotNull(permission) { "`permission` is required but was not set" }, restrictObjectType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index b274297a..7d0c76cf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -162,7 +162,7 @@ private constructor( diff, improvements, regressions, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt index 8276a02d..9ddb4683 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -98,7 +98,7 @@ private constructor( Scorer( type, index, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index de9121fa..178d3cc7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -165,7 +165,7 @@ private constructor( projectUrl, datasetUrl, dataSummary, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 4048ae6c..1a2564f4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -210,7 +210,7 @@ private constructor( comparisonExperimentName, scores, metrics, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -264,7 +264,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metrics = Metrics(additionalProperties.toUnmodifiable()) + fun build(): Metrics = Metrics(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -337,7 +337,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) + fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt index 9a57685d..9b854bee 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -80,7 +80,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Task = Task(type, additionalProperties.toUnmodifiable()) + fun build(): Task = Task(type, additionalProperties.toImmutable()) } class Type diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt index e1a73d35..f4f2197a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt @@ -11,7 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -344,7 +344,7 @@ private constructor( Function( type, function, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 957a80ca..66a34ed3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -97,8 +97,8 @@ constructor( fun build(): TopLevelHelloWorldParams = TopLevelHelloWorldParams( - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable() + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable() ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index 039c11c8..b3563520 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -179,7 +179,7 @@ private constructor( email, avatarUrl, created, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 388aad00..8a7c8b9a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.UserService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -150,7 +150,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index e4f5560e..3698364c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.UserServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -153,7 +153,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index ee2d46b6..7f5a0e82 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -62,7 +62,7 @@ constructor( this.orgName?.let { params.put("org_name", listOf(it.toString())) } this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -271,8 +271,8 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 32c8279c..65d235d6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import java.util.Objects @@ -113,8 +113,8 @@ constructor( fun build(): UserRetrieveParams = UserRetrieveParams( checkNotNull(userId) { "`userId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } } 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 79698b99..7a28ec96 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 @@ -8,7 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -259,7 +259,7 @@ private constructor( options, userId, deletedAt, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } 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 1671609d..19f48c82 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -198,7 +198,7 @@ constructor( options, userId, viewData, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -369,9 +369,9 @@ constructor( options, userId, viewData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 06bb2708..80c4da3f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -79,7 +79,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewData = ViewData(search, additionalProperties.toUnmodifiable()) + fun build(): ViewData = ViewData(search, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 9381f892..881c8201 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -122,11 +122,11 @@ private constructor( fun build(): ViewDataSearch = ViewDataSearch( - filter.map { it.toUnmodifiable() }, - tag.map { it.toUnmodifiable() }, - match.map { it.toUnmodifiable() }, - sort.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), + filter.map { it.toImmutable() }, + tag.map { it.toImmutable() }, + match.map { it.toImmutable() }, + sort.map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } 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 ec6007a6..47a98109 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -118,7 +118,7 @@ constructor( ViewDeleteBody( checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -259,9 +259,9 @@ constructor( checkNotNull(viewId) { "`viewId` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index c6968b6b..33f66db2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.blocking.ViewService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -150,7 +150,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index 305931bf..eb9f0a24 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.services.async.ViewServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -153,7 +153,7 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toUnmodifiable()) + fun build() = Response(objects, additionalProperties.toImmutable()) } } 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 012100a8..92ef1a8b 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 @@ -9,7 +9,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator @@ -65,7 +65,7 @@ constructor( this.viewName?.let { params.put("view_name", listOf(it.toString())) } this.viewType?.let { params.put("view_type", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -225,8 +225,8 @@ constructor( startingAfter, viewName, viewType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 816d8937..eeb08af4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty @@ -120,9 +120,9 @@ private constructor( fun build(): ViewOptions = ViewOptions( columnVisibility, - columnOrder.map { it.toUnmodifiable() }, + columnOrder.map { it.toImmutable() }, columnSizing, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -175,7 +175,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ColumnSizing = ColumnSizing(additionalProperties.toUnmodifiable()) + fun build(): ColumnSizing = ColumnSizing(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -247,7 +247,7 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toUnmodifiable()) + fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 c16c3983..020d436f 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -198,7 +198,7 @@ constructor( options, userId, viewData, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -369,9 +369,9 @@ constructor( options, userId, viewData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } 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 d5c72ce1..022cb326 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 @@ -6,7 +6,7 @@ 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.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator @@ -33,7 +33,7 @@ constructor( this.objectId.let { params.put("object_id", listOf(it.toString())) } this.objectType.let { params.put("object_type", listOf(it.toString())) } params.putAll(additionalQueryParams) - return params.toUnmodifiable() + return params.toImmutable() } @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders @@ -143,8 +143,8 @@ constructor( checkNotNull(viewId) { "`viewId` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), ) } 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 519c1fa3..c0874f72 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 @@ -7,7 +7,7 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -192,7 +192,7 @@ constructor( userId, viewData, viewType, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } @@ -363,9 +363,9 @@ constructor( userId, viewData, viewType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt deleted file mode 100755 index 8ac9e3df..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt +++ /dev/null @@ -1,186 +0,0 @@ -@file:JvmName("Handlers") - -package com.braintrustdata.api.services - -import com.braintrustdata.api.core.http.BinaryResponseContent -import com.braintrustdata.api.core.http.HttpResponse -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BadRequestException -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.errors.BraintrustException -import com.braintrustdata.api.errors.InternalServerException -import com.braintrustdata.api.errors.NotFoundException -import com.braintrustdata.api.errors.PermissionDeniedException -import com.braintrustdata.api.errors.RateLimitException -import com.braintrustdata.api.errors.UnauthorizedException -import com.braintrustdata.api.errors.UnexpectedStatusCodeException -import com.braintrustdata.api.errors.UnprocessableEntityException -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ListMultimap -import java.io.ByteArrayInputStream -import java.io.InputStream -import java.io.OutputStream -import java.util.Optional - -@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandler - -private object EmptyHandler : Handler { - override fun handle(response: HttpResponse): Void? = null -} - -@JvmSynthetic internal fun stringHandler(): Handler = StringHandler - -@JvmSynthetic internal fun binaryHandler(): Handler = BinaryHandler - -private object StringHandler : Handler { - override fun handle(response: HttpResponse): String { - return response.body().readBytes().toString(Charsets.UTF_8) - } -} - -private object BinaryHandler : Handler { - override fun handle(response: HttpResponse): BinaryResponseContent { - return object : BinaryResponseContent { - override fun contentType(): Optional = - Optional.ofNullable(response.headers().get("Content-Type").firstOrNull()) - - override fun body(): InputStream = response.body() - - override fun close() = response.close() - - override fun writeTo(outputStream: OutputStream) { - response.body().copyTo(outputStream) - } - } - } -} - -@JvmSynthetic -internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler { - return object : Handler { - override fun handle(response: HttpResponse): T { - try { - return jsonMapper.readValue(response.body(), jacksonTypeRef()) - } catch (e: Exception) { - throw BraintrustException("Error reading response", e) - } - } - } -} - -@JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { - val handler = jsonHandler(jsonMapper) - - return object : Handler { - override fun handle(response: HttpResponse): BraintrustError { - try { - return handler.handle(response) - } catch (e: Exception) { - return BraintrustError.builder().build() - } - } - } -} - -@JvmSynthetic -internal fun Handler.withErrorHandler(errorHandler: Handler): Handler { - return object : Handler { - override fun handle(response: HttpResponse): T { - when (val statusCode = response.statusCode()) { - in 200..299 -> { - return this@withErrorHandler.handle(response) - } - 400 -> { - val buffered = response.buffered() - throw BadRequestException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 401 -> { - val buffered = response.buffered() - throw UnauthorizedException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 403 -> { - val buffered = response.buffered() - throw PermissionDeniedException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 404 -> { - val buffered = response.buffered() - throw NotFoundException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 422 -> { - val buffered = response.buffered() - throw UnprocessableEntityException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - 429 -> { - val buffered = response.buffered() - throw RateLimitException( - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - in 500..599 -> { - val buffered = response.buffered() - throw InternalServerException( - statusCode, - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - else -> { - val buffered = response.buffered() - throw UnexpectedStatusCodeException( - statusCode, - buffered.headers(), - StringHandler.handle(buffered), - errorHandler.handle(buffered), - ) - } - } - } - } -} - -private fun HttpResponse.buffered(): HttpResponse { - val body = body().readBytes() - - return object : HttpResponse { - override fun statusCode(): Int { - return this@buffered.statusCode() - } - - override fun headers(): ListMultimap { - return this@buffered.headers() - } - - override fun body(): InputStream { - return ByteArrayInputStream(body) - } - - override fun close() { - this@buffered.close() - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/HttpRequestBodies.kt deleted file mode 100755 index 4312ec38..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/HttpRequestBodies.kt +++ /dev/null @@ -1,114 +0,0 @@ -@file:JvmName("HttpRequestBodies") - -package com.braintrustdata.api.services - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.MultipartFormValue -import com.braintrustdata.api.core.http.HttpRequestBody -import com.braintrustdata.api.errors.BraintrustException -import com.fasterxml.jackson.databind.json.JsonMapper -import java.io.ByteArrayOutputStream -import java.io.OutputStream -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder - -@JvmSynthetic -internal inline fun json( - jsonMapper: JsonMapper, - value: T, -): HttpRequestBody { - return object : HttpRequestBody { - private var cachedBytes: ByteArray? = null - - private fun serialize(): ByteArray { - if (cachedBytes != null) return cachedBytes!! - - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, value) - cachedBytes = buffer.toByteArray() - return cachedBytes!! - } catch (e: Exception) { - throw BraintrustException("Error writing request", e) - } - } - - override fun writeTo(outputStream: OutputStream) { - outputStream.write(serialize()) - } - - override fun contentType(): String = "application/json" - - override fun contentLength(): Long { - return serialize().size.toLong() - } - - override fun repeatable(): Boolean = true - - override fun close() {} - } -} - -@JvmSynthetic -internal fun multipartFormData( - jsonMapper: JsonMapper, - parts: Array?> -): HttpRequestBody { - val builder = MultipartEntityBuilder.create() - parts.forEach { part -> - if (part?.value != null) { - when (part.value) { - is JsonValue -> { - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, part.value) - } catch (e: Exception) { - throw BraintrustException("Error serializing value to json", e) - } - builder.addBinaryBody( - part.name, - buffer.toByteArray(), - part.contentType, - part.filename - ) - } - is Boolean -> - builder.addTextBody( - part.name, - if (part.value) "true" else "false", - part.contentType - ) - is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is ByteArray -> - builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) - is String -> builder.addTextBody(part.name, part.value, part.contentType) - is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - else -> - throw IllegalArgumentException( - "Unsupported content type: ${part.value::class.java.simpleName}" - ) - } - } - } - val entity = builder.build() - - return object : HttpRequestBody { - override fun writeTo(outputStream: OutputStream) { - try { - return entity.writeTo(outputStream) - } catch (e: Exception) { - throw BraintrustException("Error writing request", e) - } - } - - override fun contentType(): String = entity.contentType - - override fun contentLength(): Long = -1 - - override fun repeatable(): Boolean = entity.isRepeatable - - override fun close() = entity.close() - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt new file mode 100644 index 00000000..30156281 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt @@ -0,0 +1,274 @@ +package com.braintrustdata.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.assertj.core.api.Assumptions.assumeThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HeadersTest { + + enum class TestCase( + val headers: Headers, + val expectedMap: Map>, + val expectedSize: Int + ) { + EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), + PUT_ONE( + Headers.builder().put("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1 + ), + PUT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2 + ), + MULTIPLE_PUT( + Headers.builder().put("name1", "value").put("name2", "value").build(), + expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), + expectedSize = 2 + ), + MULTIPLE_PUT_SAME_NAME( + Headers.builder().put("name", "value1").put("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2 + ), + MULTIPLE_PUT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .put("name", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4 + ), + PUT_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .put("NAME", "value2") + .put("nAmE", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3 + ), + PUT_ALL_MAP( + Headers.builder() + .putAll( + mapOf( + "name1" to listOf("value1", "value2"), + "name2" to listOf("value1", "value2") + ) + ) + .build(), + expectedMap = + mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), + expectedSize = 4 + ), + PUT_ALL_HEADERS( + Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1 + ), + PUT_ALL_CASE_INSENSITIVE( + Headers.builder() + .putAll( + mapOf( + "name" to listOf("value1"), + "NAME" to listOf("value2"), + "nAmE" to listOf("value3") + ) + ) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3 + ), + REMOVE_ABSENT( + Headers.builder().remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REMOVE_PRESENT_ONE( + Headers.builder().put("name", "value").remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REMOVE_PRESENT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REMOVE_CASE_INSENSITIVE( + Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REMOVE_ALL( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("name1", "name2", "name3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REMOVE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("NAME1", "nAmE3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + CLEAR( + Headers.builder().put("name1", "value").put("name2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REPLACE_ONE_ABSENT( + Headers.builder().replace("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1 + ), + REPLACE_ONE_PRESENT_ONE( + Headers.builder().put("name", "value1").replace("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value2")), + expectedSize = 1 + ), + REPLACE_ONE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value3")), + expectedSize = 1 + ), + REPLACE_MULTIPLE_ABSENT( + Headers.builder().replace("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2 + ), + REPLACE_MULTIPLE_PRESENT_ONE( + Headers.builder() + .put("name", "value1") + .replace("name", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("name" to listOf("value2", "value3")), + expectedSize = 2 + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("name" to listOf("value3", "value4")), + expectedSize = 2 + ), + REPLACE_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .replace("NAME", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("NAME" to listOf("value2", "value3")), + expectedSize = 2 + ), + REPLACE_ALL_MAP( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(mapOf("name1" to listOf("value2"), "name3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2") + ), + expectedSize = 3 + ), + REPLACE_ALL_HEADERS( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(Headers.builder().put("name1", "value2").put("name3", "value2").build()) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2") + ), + expectedSize = 3 + ), + REPLACE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) + .build(), + expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), + expectedSize = 2 + ) + } + + @ParameterizedTest + @EnumSource + fun namesAndValues(testCase: TestCase) { + val map = mutableMapOf>() + val headers = testCase.headers + headers.names().forEach { name -> map[name] = headers.values(name) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun caseInsensitiveNames(testCase: TestCase) { + val headers = testCase.headers + + for (name in headers.names()) { + assertThat(headers.values(name)).isEqualTo(headers.values(name.lowercase())) + assertThat(headers.values(name)).isEqualTo(headers.values(name.uppercase())) + } + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.headers.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } + + @ParameterizedTest + @EnumSource + fun namesAreImmutable(testCase: TestCase) { + val headers = testCase.headers + val headerNamesCopy = headers.names().toSet() + + val throwable = catchThrowable { + (headers.names() as MutableSet).add("another name") + } + + assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) + assertThat(headers.names()).isEqualTo(headerNamesCopy) + } + + @ParameterizedTest + @EnumSource + fun valuesAreImmutable(testCase: TestCase) { + val headers = testCase.headers + assumeThat(headers.size).isNotEqualTo(0) + val name = headers.names().first() + val headerValuesCopy = headers.values(name).toList() + + val throwable = catchThrowable { + (headers.values(name) as MutableList).add("another value") + } + + assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) + assertThat(headers.values(name)).isEqualTo(headerValuesCopy) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt index f1c1f965..fa99908e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt @@ -92,7 +92,7 @@ internal class SerializerTest { fun build(): ClassWithBooleanFieldPrefixedWithIs = ClassWithBooleanFieldPrefixedWithIs( isActive, - additionalProperties.toUnmodifiable(), + additionalProperties.toImmutable(), ) } } From 9e17de04225a4a334fe068f5cbd7e3116c765782 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 19:13:44 +0000 Subject: [PATCH 15/87] chore: rebuild project due to codegen change (#79) --- .../api/core/http/QueryParams.kt | 86 +++++++ .../api/core/http/QueryParamsTest.kt | 212 ++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt new file mode 100644 index 00000000..97a2b094 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt @@ -0,0 +1,86 @@ +package com.braintrustdata.api.core.http + +import com.braintrustdata.api.core.toImmutable + +class QueryParams +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun keys(): Set = map.keys + + fun values(key: String): List = map[key].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private val map: MutableMap> = mutableMapOf() + private var size: Int = 0 + + fun put(key: String, value: String) = apply { + map.getOrPut(key) { mutableListOf() }.add(value) + size++ + } + + fun put(key: String, values: Iterable) = apply { values.forEach { put(key, it) } } + + fun putAll(queryParams: Map>) = apply { + queryParams.forEach(::put) + } + + fun putAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { put(it, queryParams.values(it)) } + } + + fun replace(key: String, value: String) = apply { + remove(key) + put(key, value) + } + + fun replace(key: String, values: Iterable) = apply { + remove(key) + put(key, values) + } + + fun replaceAll(queryParams: Map>) = apply { + queryParams.forEach(::replace) + } + + fun replaceAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { replace(it, queryParams.values(it)) } + } + + fun remove(key: String) = apply { size -= map.remove(key).orEmpty().size } + + fun removeAll(keys: Set) = apply { keys.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QueryParams && map == other.map + } + + override fun toString(): String = "QueryParams{map=$map}" +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt new file mode 100644 index 00000000..bc1d36a0 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt @@ -0,0 +1,212 @@ +package com.braintrustdata.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.assertj.core.api.Assumptions.assumeThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class QueryParamsTest { + + enum class TestCase( + val queryParams: QueryParams, + val expectedMap: Map>, + val expectedSize: Int + ) { + EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), + PUT_ONE( + QueryParams.builder().put("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1 + ), + PUT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2 + ), + MULTIPLE_PUT( + QueryParams.builder().put("key1", "value").put("key2", "value").build(), + expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), + expectedSize = 2 + ), + MULTIPLE_PUT_SAME_NAME( + QueryParams.builder().put("key", "value1").put("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2 + ), + MULTIPLE_PUT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .put("key", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4 + ), + PUT_ALL_MAP( + QueryParams.builder() + .putAll( + mapOf( + "key1" to listOf("value1", "value2"), + "key2" to listOf("value1", "value2") + ) + ) + .build(), + expectedMap = + mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), + expectedSize = 4 + ), + PUT_ALL_HEADERS( + QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1 + ), + REMOVE_ABSENT( + QueryParams.builder().remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REMOVE_PRESENT_ONE( + QueryParams.builder().put("key", "value").remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REMOVE_PRESENT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REMOVE_ALL( + QueryParams.builder() + .put("key1", "value") + .put("key3", "value") + .removeAll(setOf("key1", "key2", "key3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + CLEAR( + QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0 + ), + REPLACE_ONE_ABSENT( + QueryParams.builder().replace("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1 + ), + REPLACE_ONE_PRESENT_ONE( + QueryParams.builder().put("key", "value1").replace("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value2")), + expectedSize = 1 + ), + REPLACE_ONE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", "value3") + .build(), + expectedMap = mapOf("key" to listOf("value3")), + expectedSize = 1 + ), + REPLACE_MULTIPLE_ABSENT( + QueryParams.builder().replace("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2 + ), + REPLACE_MULTIPLE_PRESENT_ONE( + QueryParams.builder() + .put("key", "value1") + .replace("key", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("key" to listOf("value2", "value3")), + expectedSize = 2 + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("key" to listOf("value3", "value4")), + expectedSize = 2 + ), + REPLACE_ALL_MAP( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll(mapOf("key1" to listOf("value2"), "key3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2") + ), + expectedSize = 3 + ), + REPLACE_ALL_HEADERS( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll( + QueryParams.builder().put("key1", "value2").put("key3", "value2").build() + ) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2") + ), + expectedSize = 3 + ) + } + + @ParameterizedTest + @EnumSource + fun keysAndValues(testCase: TestCase) { + val map = mutableMapOf>() + val queryParams = testCase.queryParams + queryParams.keys().forEach { key -> map[key] = queryParams.values(key) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.queryParams.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } + + @ParameterizedTest + @EnumSource + fun keysAreImmutable(testCase: TestCase) { + val queryParams = testCase.queryParams + val queryParamKeysCopy = queryParams.keys().toSet() + + val throwable = catchThrowable { + (queryParams.keys() as MutableSet).add("another key") + } + + assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) + assertThat(queryParams.keys()).isEqualTo(queryParamKeysCopy) + } + + @ParameterizedTest + @EnumSource + fun valuesAreImmutable(testCase: TestCase) { + val queryParams = testCase.queryParams + assumeThat(queryParams.size).isNotEqualTo(0) + val key = queryParams.keys().first() + val queryParamValuesCopy = queryParams.values(key).toList() + + val throwable = catchThrowable { + (queryParams.values(key) as MutableList).add("another value") + } + + assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) + assertThat(queryParams.values(key)).isEqualTo(queryParamValuesCopy) + } +} From 223ed2e21d18538cff3875f3697b2c0ded1b4ad3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 22:54:13 +0000 Subject: [PATCH 16/87] chore: rebuild project due to codegen change (#80) --- .../client/okhttp/BraintrustOkHttpClient.kt | 18 ++++++++++++++++++ .../okhttp/BraintrustOkHttpClientAsync.kt | 18 ++++++++++++++++++ .../braintrustdata/api/core/ClientOptions.kt | 8 ++++---- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 83affecc..baa76a5f 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -52,6 +52,24 @@ class BraintrustOkHttpClient private constructor() { fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) } + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) } + fun timeout(timeout: Duration) = apply { this.timeout = timeout } fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index 08d1b49f..4aa21373 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -52,6 +52,24 @@ class BraintrustOkHttpClientAsync private constructor() { fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) } + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) } + fun timeout(timeout: Duration) = apply { this.timeout = timeout } fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 3a266f69..993bdf93 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -90,17 +90,17 @@ private constructor( putAllQueryParams(queryParams) } - fun putQueryParam(name: String, value: String) = apply { queryParams.put(name, value) } + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - queryParams.putAll(name, values) + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.putAll(key, values) } fun putAllQueryParams(queryParams: Map>) = apply { queryParams.forEach(::putQueryParams) } - fun removeQueryParam(name: String) = apply { queryParams.removeAll(name) } + fun removeQueryParam(key: String) = apply { queryParams.removeAll(key) } fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation From 44f5fbe68fcb12f0d08a091c88c39bf87f8855af Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:38:05 +0000 Subject: [PATCH 17/87] chore: rebuild project due to codegen change (#81) --- .../api/models/AclBatchUpdateParams.kt | 79 ++++++++++--------- .../api/models/AclCreateParams.kt | 79 ++++++++++--------- .../api/models/AclDeleteParams.kt | 79 ++++++++++--------- .../api/models/AclFindAndDeleteParams.kt | 79 ++++++++++--------- .../api/models/AclListParams.kt | 77 ++++++++++-------- .../api/models/AclRetrieveParams.kt | 79 ++++++++++--------- .../api/models/AiSecretCreateParams.kt | 79 ++++++++++--------- .../api/models/AiSecretDeleteParams.kt | 79 ++++++++++--------- .../api/models/AiSecretFindAndDeleteParams.kt | 79 ++++++++++--------- .../api/models/AiSecretListParams.kt | 77 ++++++++++-------- .../api/models/AiSecretReplaceParams.kt | 79 ++++++++++--------- .../api/models/AiSecretRetrieveParams.kt | 79 ++++++++++--------- .../api/models/AiSecretUpdateParams.kt | 79 ++++++++++--------- .../api/models/ApiKeyCreateParams.kt | 79 ++++++++++--------- .../api/models/ApiKeyDeleteParams.kt | 79 ++++++++++--------- .../api/models/ApiKeyListParams.kt | 77 ++++++++++-------- .../api/models/ApiKeyRetrieveParams.kt | 79 ++++++++++--------- .../api/models/DatasetCreateParams.kt | 79 ++++++++++--------- .../api/models/DatasetDeleteParams.kt | 79 ++++++++++--------- .../api/models/DatasetFeedbackParams.kt | 79 ++++++++++--------- .../api/models/DatasetFetchParams.kt | 79 ++++++++++--------- .../api/models/DatasetFetchPostParams.kt | 79 ++++++++++--------- .../api/models/DatasetInsertParams.kt | 79 ++++++++++--------- .../api/models/DatasetListParams.kt | 77 ++++++++++-------- .../api/models/DatasetRetrieveParams.kt | 79 ++++++++++--------- .../api/models/DatasetSummarizeParams.kt | 79 ++++++++++--------- .../api/models/DatasetUpdateParams.kt | 79 ++++++++++--------- .../api/models/EnvVarCreateParams.kt | 79 ++++++++++--------- .../api/models/EnvVarDeleteParams.kt | 79 ++++++++++--------- .../api/models/EnvVarListParams.kt | 77 ++++++++++-------- .../api/models/EnvVarReplaceParams.kt | 79 ++++++++++--------- .../api/models/EnvVarRetrieveParams.kt | 79 ++++++++++--------- .../api/models/EnvVarUpdateParams.kt | 79 ++++++++++--------- .../api/models/EvalCreateParams.kt | 79 ++++++++++--------- .../api/models/ExperimentCreateParams.kt | 79 ++++++++++--------- .../api/models/ExperimentDeleteParams.kt | 79 ++++++++++--------- .../api/models/ExperimentFeedbackParams.kt | 79 ++++++++++--------- .../api/models/ExperimentFetchParams.kt | 79 ++++++++++--------- .../api/models/ExperimentFetchPostParams.kt | 79 ++++++++++--------- .../api/models/ExperimentInsertParams.kt | 79 ++++++++++--------- .../api/models/ExperimentListParams.kt | 77 ++++++++++-------- .../api/models/ExperimentRetrieveParams.kt | 79 ++++++++++--------- .../api/models/ExperimentSummarizeParams.kt | 79 ++++++++++--------- .../api/models/ExperimentUpdateParams.kt | 79 ++++++++++--------- .../api/models/FunctionCreateParams.kt | 79 ++++++++++--------- .../api/models/FunctionDeleteParams.kt | 79 ++++++++++--------- .../api/models/FunctionInvokeParams.kt | 79 ++++++++++--------- .../api/models/FunctionListParams.kt | 77 ++++++++++-------- .../api/models/FunctionReplaceParams.kt | 79 ++++++++++--------- .../api/models/FunctionRetrieveParams.kt | 79 ++++++++++--------- .../api/models/FunctionUpdateParams.kt | 79 ++++++++++--------- .../api/models/GroupCreateParams.kt | 79 ++++++++++--------- .../api/models/GroupDeleteParams.kt | 79 ++++++++++--------- .../api/models/GroupListParams.kt | 77 ++++++++++-------- .../api/models/GroupReplaceParams.kt | 79 ++++++++++--------- .../api/models/GroupRetrieveParams.kt | 79 ++++++++++--------- .../api/models/GroupUpdateParams.kt | 79 ++++++++++--------- .../api/models/OrganizationDeleteParams.kt | 79 ++++++++++--------- .../api/models/OrganizationListParams.kt | 77 ++++++++++-------- .../models/OrganizationMemberUpdateParams.kt | 79 ++++++++++--------- .../api/models/OrganizationRetrieveParams.kt | 79 ++++++++++--------- .../api/models/OrganizationUpdateParams.kt | 79 ++++++++++--------- .../api/models/ProjectCreateParams.kt | 79 ++++++++++--------- .../api/models/ProjectDeleteParams.kt | 79 ++++++++++--------- .../api/models/ProjectListParams.kt | 77 ++++++++++-------- .../api/models/ProjectLogFeedbackParams.kt | 79 ++++++++++--------- .../api/models/ProjectLogFetchParams.kt | 79 ++++++++++--------- .../api/models/ProjectLogFetchPostParams.kt | 79 ++++++++++--------- .../api/models/ProjectLogInsertParams.kt | 79 ++++++++++--------- .../api/models/ProjectRetrieveParams.kt | 79 ++++++++++--------- .../api/models/ProjectScoreCreateParams.kt | 79 ++++++++++--------- .../api/models/ProjectScoreDeleteParams.kt | 79 ++++++++++--------- .../api/models/ProjectScoreListParams.kt | 77 ++++++++++-------- .../api/models/ProjectScoreReplaceParams.kt | 79 ++++++++++--------- .../api/models/ProjectScoreRetrieveParams.kt | 79 ++++++++++--------- .../api/models/ProjectScoreUpdateParams.kt | 79 ++++++++++--------- .../api/models/ProjectTagCreateParams.kt | 79 ++++++++++--------- .../api/models/ProjectTagDeleteParams.kt | 79 ++++++++++--------- .../api/models/ProjectTagListParams.kt | 77 ++++++++++-------- .../api/models/ProjectTagReplaceParams.kt | 79 ++++++++++--------- .../api/models/ProjectTagRetrieveParams.kt | 79 ++++++++++--------- .../api/models/ProjectTagUpdateParams.kt | 79 ++++++++++--------- .../api/models/ProjectUpdateParams.kt | 79 ++++++++++--------- .../api/models/PromptCreateParams.kt | 79 ++++++++++--------- .../api/models/PromptDeleteParams.kt | 79 ++++++++++--------- .../api/models/PromptListParams.kt | 77 ++++++++++-------- .../api/models/PromptReplaceParams.kt | 79 ++++++++++--------- .../api/models/PromptRetrieveParams.kt | 79 ++++++++++--------- .../api/models/PromptUpdateParams.kt | 79 ++++++++++--------- .../api/models/RoleCreateParams.kt | 79 ++++++++++--------- .../api/models/RoleDeleteParams.kt | 79 ++++++++++--------- .../api/models/RoleListParams.kt | 77 ++++++++++-------- .../api/models/RoleReplaceParams.kt | 79 ++++++++++--------- .../api/models/RoleRetrieveParams.kt | 79 ++++++++++--------- .../api/models/RoleUpdateParams.kt | 79 ++++++++++--------- .../api/models/TopLevelHelloWorldParams.kt | 77 ++++++++++-------- .../api/models/UserListParams.kt | 77 ++++++++++-------- .../api/models/UserRetrieveParams.kt | 79 ++++++++++--------- .../api/models/ViewCreateParams.kt | 79 ++++++++++--------- .../api/models/ViewDeleteParams.kt | 79 ++++++++++--------- .../api/models/ViewListParams.kt | 77 ++++++++++-------- .../api/models/ViewReplaceParams.kt | 79 ++++++++++--------- .../api/models/ViewRetrieveParams.kt | 79 ++++++++++--------- .../api/models/ViewUpdateParams.kt | 79 ++++++++++--------- 104 files changed, 4455 insertions(+), 3727 deletions(-) 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 be172f2e..7f22bf65 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -22,8 +24,8 @@ class AclBatchUpdateParams constructor( private val addAcls: List?, private val removeAcls: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -40,10 +42,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = AclBatchUpdateBody.Builder::class) @NoAutoDetect class AclBatchUpdateBody @@ -172,10 +174,10 @@ constructor( "AclBatchUpdateBody{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -183,15 +185,15 @@ constructor( return true } - return /* spotless:off */ other is AclBatchUpdateParams && this.addAcls == other.addAcls && this.removeAcls == other.removeAcls && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateParams && this.addAcls == other.addAcls && this.removeAcls == other.removeAcls && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AclBatchUpdateParams{addAcls=$addAcls, removeAcls=$removeAcls, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AclBatchUpdateParams{addAcls=$addAcls, removeAcls=$removeAcls, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -205,16 +207,16 @@ constructor( private var addAcls: MutableList = mutableListOf() private var removeAcls: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { this.addAcls(aclBatchUpdateParams.addAcls ?: listOf()) this.removeAcls(aclBatchUpdateParams.removeAcls ?: listOf()) - additionalQueryParams(aclBatchUpdateParams.additionalQueryParams) additionalHeaders(aclBatchUpdateParams.additionalHeaders) + additionalQueryParams(aclBatchUpdateParams.additionalQueryParams) additionalBodyProperties(aclBatchUpdateParams.additionalBodyProperties) } @@ -272,45 +274,44 @@ constructor( */ fun addRemoveAcl(removeAcl: RemoveAcl) = apply { this.removeAcls.add(removeAcl) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -330,8 +331,14 @@ constructor( AclBatchUpdateParams( if (addAcls.size == 0) null else addAcls.toImmutable(), if (removeAcls.size == 0) null else removeAcls.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 ef8f99be..ecebec68 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +29,8 @@ constructor( private val restrictObjectType: RestrictObjectType?, private val roleId: String?, private val userId: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -60,10 +62,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + /** * An ACL grants a certain permission or role to a certain user or group on an object. * @@ -246,10 +248,10 @@ constructor( "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -257,15 +259,15 @@ constructor( return true } - return /* spotless:off */ other is AclCreateParams && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclCreateParams && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -284,8 +286,8 @@ constructor( private var restrictObjectType: RestrictObjectType? = null private var roleId: String? = null private var userId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -297,8 +299,8 @@ constructor( this.restrictObjectType = aclCreateParams.restrictObjectType this.roleId = aclCreateParams.roleId this.userId = aclCreateParams.userId - additionalQueryParams(aclCreateParams.additionalQueryParams) additionalHeaders(aclCreateParams.additionalHeaders) + additionalQueryParams(aclCreateParams.additionalQueryParams) additionalBodyProperties(aclCreateParams.additionalBodyProperties) } @@ -337,45 +339,44 @@ constructor( */ fun userId(userId: String) = apply { this.userId = userId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -400,8 +401,14 @@ constructor( restrictObjectType, roleId, userId, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index fac4c02a..083ccabe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class AclDeleteParams constructor( private val aclId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> aclId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is AclDeleteParams && this.aclId == other.aclId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclDeleteParams && this.aclId == other.aclId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aclId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AclDeleteParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var aclId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclDeleteParams: AclDeleteParams) = apply { this.aclId = aclDeleteParams.aclId - additionalQueryParams(aclDeleteParams.additionalQueryParams) additionalHeaders(aclDeleteParams.additionalHeaders) + additionalQueryParams(aclDeleteParams.additionalQueryParams) additionalBodyProperties(aclDeleteParams.additionalBodyProperties) } /** Acl id */ fun aclId(aclId: String) = apply { this.aclId = aclId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): AclDeleteParams = AclDeleteParams( checkNotNull(aclId) { "`aclId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 2d8a55c3..9a5648c5 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +29,8 @@ constructor( private val restrictObjectType: RestrictObjectType?, private val roleId: String?, private val userId: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -60,10 +62,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + /** * An ACL grants a certain permission or role to a certain user or group on an object. * @@ -246,10 +248,10 @@ constructor( "AclFindAndDeleteBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -257,15 +259,15 @@ constructor( return true } - return /* spotless:off */ other is AclFindAndDeleteParams && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclFindAndDeleteParams && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AclFindAndDeleteParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AclFindAndDeleteParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -284,8 +286,8 @@ constructor( private var restrictObjectType: RestrictObjectType? = null private var roleId: String? = null private var userId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -297,8 +299,8 @@ constructor( this.restrictObjectType = aclFindAndDeleteParams.restrictObjectType this.roleId = aclFindAndDeleteParams.roleId this.userId = aclFindAndDeleteParams.userId - additionalQueryParams(aclFindAndDeleteParams.additionalQueryParams) additionalHeaders(aclFindAndDeleteParams.additionalHeaders) + additionalQueryParams(aclFindAndDeleteParams.additionalQueryParams) additionalBodyProperties(aclFindAndDeleteParams.additionalBodyProperties) } @@ -337,45 +339,44 @@ constructor( */ fun userId(userId: String) = apply { this.userId = userId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -400,8 +401,14 @@ constructor( restrictObjectType, roleId, userId, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 799893b9..ac870990 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 @@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -31,8 +33,8 @@ constructor( private val ids: Ids?, private val limit: Long?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun objectId(): String = objectId @@ -47,6 +49,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -60,26 +64,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AclListParams && this.objectId == other.objectId && this.objectType == other.objectType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is AclListParams && this.objectId == other.objectId && this.objectType == other.objectType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -97,8 +99,8 @@ constructor( private var ids: Ids? = null private var limit: Long? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(aclListParams: AclListParams) = apply { @@ -108,8 +110,8 @@ constructor( this.ids = aclListParams.ids this.limit = aclListParams.limit this.startingAfter = aclListParams.startingAfter - additionalQueryParams(aclListParams.additionalQueryParams) additionalHeaders(aclListParams.additionalHeaders) + additionalQueryParams(aclListParams.additionalQueryParams) } /** The id of the object the ACL applies to */ @@ -157,45 +159,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): AclListParams = AclListParams( @@ -205,8 +206,14 @@ constructor( ids, limit, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 145ffc77..d184e4cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class AclRetrieveParams constructor( private val aclId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun aclId(): String = aclId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> aclId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AclRetrieveParams && this.aclId == other.aclId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is AclRetrieveParams && this.aclId == other.aclId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aclId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "AclRetrieveParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var aclId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(aclRetrieveParams: AclRetrieveParams) = apply { this.aclId = aclRetrieveParams.aclId - additionalQueryParams(aclRetrieveParams.additionalQueryParams) additionalHeaders(aclRetrieveParams.additionalHeaders) + additionalQueryParams(aclRetrieveParams.additionalQueryParams) } /** Acl id */ fun aclId(aclId: String) = apply { this.aclId = aclId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): AclRetrieveParams = AclRetrieveParams( checkNotNull(aclId) { "`aclId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 20666ab6..11816b69 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -21,8 +23,8 @@ constructor( private val orgName: String?, private val secret: String?, private val type: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -48,10 +50,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = AiSecretCreateBody.Builder::class) @NoAutoDetect class AiSecretCreateBody @@ -182,10 +184,10 @@ constructor( "AiSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -193,15 +195,15 @@ constructor( return true } - return /* spotless:off */ other is AiSecretCreateParams && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretCreateParams && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AiSecretCreateParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretCreateParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -218,8 +220,8 @@ constructor( private var orgName: String? = null private var secret: String? = null private var type: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -229,8 +231,8 @@ constructor( this.orgName = aiSecretCreateParams.orgName this.secret = aiSecretCreateParams.secret this.type = aiSecretCreateParams.type - additionalQueryParams(aiSecretCreateParams.additionalQueryParams) additionalHeaders(aiSecretCreateParams.additionalHeaders) + additionalQueryParams(aiSecretCreateParams.additionalQueryParams) additionalBodyProperties(aiSecretCreateParams.additionalBodyProperties) } @@ -254,45 +256,44 @@ constructor( fun type(type: String) = apply { this.type = type } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -315,8 +316,14 @@ constructor( orgName, secret, type, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index 239f8ab3..64b9fe6d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class AiSecretDeleteParams constructor( private val aiSecretId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> aiSecretId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is AiSecretDeleteParams && this.aiSecretId == other.aiSecretId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretDeleteParams && this.aiSecretId == other.aiSecretId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var aiSecretId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretDeleteParams: AiSecretDeleteParams) = apply { this.aiSecretId = aiSecretDeleteParams.aiSecretId - additionalQueryParams(aiSecretDeleteParams.additionalQueryParams) additionalHeaders(aiSecretDeleteParams.additionalHeaders) + additionalQueryParams(aiSecretDeleteParams.additionalQueryParams) additionalBodyProperties(aiSecretDeleteParams.additionalBodyProperties) } /** AiSecret id */ fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): AiSecretDeleteParams = AiSecretDeleteParams( checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 2e8aa872..0c7d03e6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -18,8 +20,8 @@ class AiSecretFindAndDeleteParams constructor( private val name: String, private val orgName: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -36,10 +38,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = AiSecretFindAndDeleteBody.Builder::class) @NoAutoDetect class AiSecretFindAndDeleteBody @@ -137,10 +139,10 @@ constructor( "AiSecretFindAndDeleteBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -148,15 +150,15 @@ constructor( return true } - return /* spotless:off */ other is AiSecretFindAndDeleteParams && this.name == other.name && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretFindAndDeleteParams && this.name == other.name && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AiSecretFindAndDeleteParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretFindAndDeleteParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -170,16 +172,16 @@ constructor( private var name: String? = null private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = apply { this.name = aiSecretFindAndDeleteParams.name this.orgName = aiSecretFindAndDeleteParams.orgName - additionalQueryParams(aiSecretFindAndDeleteParams.additionalQueryParams) additionalHeaders(aiSecretFindAndDeleteParams.additionalHeaders) + additionalQueryParams(aiSecretFindAndDeleteParams.additionalQueryParams) additionalBodyProperties(aiSecretFindAndDeleteParams.additionalBodyProperties) } @@ -193,45 +195,44 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -251,8 +252,14 @@ constructor( AiSecretFindAndDeleteParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 1388bdbe..e41c45bf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -29,8 +31,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun aiSecretName(): Optional = Optional.ofNullable(aiSecretName) @@ -47,6 +49,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -61,26 +65,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AiSecretListParams && this.aiSecretName == other.aiSecretName && this.aiSecretType == other.aiSecretType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is AiSecretListParams && this.aiSecretName == other.aiSecretName && this.aiSecretType == other.aiSecretType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -99,8 +101,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(aiSecretListParams: AiSecretListParams) = apply { @@ -111,8 +113,8 @@ constructor( this.limit = aiSecretListParams.limit this.orgName = aiSecretListParams.orgName this.startingAfter = aiSecretListParams.startingAfter - additionalQueryParams(aiSecretListParams.additionalQueryParams) additionalHeaders(aiSecretListParams.additionalHeaders) + additionalQueryParams(aiSecretListParams.additionalQueryParams) } /** Name of the ai_secret to search for */ @@ -170,45 +172,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): AiSecretListParams = AiSecretListParams( @@ -219,8 +220,14 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 1301136a..a39c9b1f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -21,8 +23,8 @@ constructor( private val orgName: String?, private val secret: String?, private val type: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -48,10 +50,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = AiSecretReplaceBody.Builder::class) @NoAutoDetect class AiSecretReplaceBody @@ -182,10 +184,10 @@ constructor( "AiSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -193,15 +195,15 @@ constructor( return true } - return /* spotless:off */ other is AiSecretReplaceParams && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretReplaceParams && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AiSecretReplaceParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretReplaceParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -218,8 +220,8 @@ constructor( private var orgName: String? = null private var secret: String? = null private var type: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -229,8 +231,8 @@ constructor( this.orgName = aiSecretReplaceParams.orgName this.secret = aiSecretReplaceParams.secret this.type = aiSecretReplaceParams.type - additionalQueryParams(aiSecretReplaceParams.additionalQueryParams) additionalHeaders(aiSecretReplaceParams.additionalHeaders) + additionalQueryParams(aiSecretReplaceParams.additionalQueryParams) additionalBodyProperties(aiSecretReplaceParams.additionalBodyProperties) } @@ -254,45 +256,44 @@ constructor( fun type(type: String) = apply { this.type = type } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -315,8 +316,14 @@ constructor( orgName, secret, type, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index d8fc8a97..73359665 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class AiSecretRetrieveParams constructor( private val aiSecretId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun aiSecretId(): String = aiSecretId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> aiSecretId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AiSecretRetrieveParams && this.aiSecretId == other.aiSecretId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is AiSecretRetrieveParams && this.aiSecretId == other.aiSecretId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var aiSecretId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = apply { this.aiSecretId = aiSecretRetrieveParams.aiSecretId - additionalQueryParams(aiSecretRetrieveParams.additionalQueryParams) additionalHeaders(aiSecretRetrieveParams.additionalHeaders) + additionalQueryParams(aiSecretRetrieveParams.additionalQueryParams) } /** AiSecret id */ fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index ad973d8d..00246b15 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -21,8 +23,8 @@ constructor( private val name: String?, private val secret: String?, private val type: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -47,10 +49,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> aiSecretId @@ -161,10 +163,10 @@ constructor( "AiSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -172,15 +174,15 @@ constructor( return true } - return /* spotless:off */ other is AiSecretUpdateParams && this.aiSecretId == other.aiSecretId && this.metadata == other.metadata && this.name == other.name && this.secret == other.secret && this.type == other.type && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretUpdateParams && this.aiSecretId == other.aiSecretId && this.metadata == other.metadata && this.name == other.name && this.secret == other.secret && this.type == other.type && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretId, metadata, name, secret, type, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(aiSecretId, metadata, name, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "AiSecretUpdateParams{aiSecretId=$aiSecretId, metadata=$metadata, name=$name, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretUpdateParams{aiSecretId=$aiSecretId, metadata=$metadata, name=$name, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -197,8 +199,8 @@ constructor( private var name: String? = null private var secret: String? = null private var type: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -208,8 +210,8 @@ constructor( this.name = aiSecretUpdateParams.name this.secret = aiSecretUpdateParams.secret this.type = aiSecretUpdateParams.type - additionalQueryParams(aiSecretUpdateParams.additionalQueryParams) additionalHeaders(aiSecretUpdateParams.additionalHeaders) + additionalQueryParams(aiSecretUpdateParams.additionalQueryParams) additionalBodyProperties(aiSecretUpdateParams.additionalBodyProperties) } @@ -225,45 +227,44 @@ constructor( fun type(type: String) = apply { this.type = type } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -286,8 +287,14 @@ constructor( name, secret, type, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 04374360..cc908e0f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -18,8 +20,8 @@ class ApiKeyCreateParams constructor( private val name: String, private val orgName: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -36,10 +38,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = ApiKeyCreateBody.Builder::class) @NoAutoDetect class ApiKeyCreateBody @@ -137,10 +139,10 @@ constructor( "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -148,15 +150,15 @@ constructor( return true } - return /* spotless:off */ other is ApiKeyCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -170,16 +172,16 @@ constructor( private var name: String? = null private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { this.name = apiKeyCreateParams.name this.orgName = apiKeyCreateParams.orgName - additionalQueryParams(apiKeyCreateParams.additionalQueryParams) additionalHeaders(apiKeyCreateParams.additionalHeaders) + additionalQueryParams(apiKeyCreateParams.additionalQueryParams) additionalBodyProperties(apiKeyCreateParams.additionalBodyProperties) } @@ -193,45 +195,44 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -251,8 +252,14 @@ constructor( ApiKeyCreateParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index 3793cc0e..8d977987 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ApiKeyDeleteParams constructor( private val apiKeyId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> apiKeyId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is ApiKeyDeleteParams && this.apiKeyId == other.apiKeyId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyDeleteParams && this.apiKeyId == other.apiKeyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(apiKeyId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var apiKeyId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = apply { this.apiKeyId = apiKeyDeleteParams.apiKeyId - additionalQueryParams(apiKeyDeleteParams.additionalQueryParams) additionalHeaders(apiKeyDeleteParams.additionalHeaders) + additionalQueryParams(apiKeyDeleteParams.additionalQueryParams) additionalBodyProperties(apiKeyDeleteParams.additionalBodyProperties) } /** ApiKey id */ fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 8cc30c18..5eecc3ee 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +30,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun apiKeyName(): Optional = Optional.ofNullable(apiKeyName) @@ -44,6 +46,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -57,26 +61,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ApiKeyListParams && this.apiKeyName == other.apiKeyName && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ApiKeyListParams && this.apiKeyName == other.apiKeyName && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -94,8 +96,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(apiKeyListParams: ApiKeyListParams) = apply { @@ -105,8 +107,8 @@ constructor( this.limit = apiKeyListParams.limit this.orgName = apiKeyListParams.orgName this.startingAfter = apiKeyListParams.startingAfter - additionalQueryParams(apiKeyListParams.additionalQueryParams) additionalHeaders(apiKeyListParams.additionalHeaders) + additionalQueryParams(apiKeyListParams.additionalQueryParams) } /** Name of the api_key to search for */ @@ -154,45 +156,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ApiKeyListParams = ApiKeyListParams( @@ -202,8 +203,14 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index b4b1b0d5..1d959ee1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ApiKeyRetrieveParams constructor( private val apiKeyId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun apiKeyId(): String = apiKeyId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> apiKeyId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ApiKeyRetrieveParams && this.apiKeyId == other.apiKeyId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ApiKeyRetrieveParams && this.apiKeyId == other.apiKeyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(apiKeyId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var apiKeyId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = apply { this.apiKeyId = apiKeyRetrieveParams.apiKeyId - additionalQueryParams(apiKeyRetrieveParams.additionalQueryParams) additionalHeaders(apiKeyRetrieveParams.additionalHeaders) + additionalQueryParams(apiKeyRetrieveParams.additionalQueryParams) } /** ApiKey id */ fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 84e5deb3..ca40f09c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -19,8 +21,8 @@ constructor( private val name: String, private val projectId: String, private val description: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -40,10 +42,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = DatasetCreateBody.Builder::class) @NoAutoDetect class DatasetCreateBody @@ -144,10 +146,10 @@ constructor( "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -155,15 +157,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetCreateParams && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetCreateParams && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, projectId, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetCreateParams{name=$name, projectId=$projectId, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "DatasetCreateParams{name=$name, projectId=$projectId, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -178,8 +180,8 @@ constructor( private var name: String? = null private var projectId: String? = null private var description: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -187,8 +189,8 @@ constructor( this.name = datasetCreateParams.name this.projectId = datasetCreateParams.projectId this.description = datasetCreateParams.description - additionalQueryParams(datasetCreateParams.additionalQueryParams) additionalHeaders(datasetCreateParams.additionalHeaders) + additionalQueryParams(datasetCreateParams.additionalQueryParams) additionalBodyProperties(datasetCreateParams.additionalBodyProperties) } @@ -201,45 +203,44 @@ constructor( /** Textual description of the dataset */ fun description(description: String) = apply { this.description = description } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -260,8 +261,14 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, description, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 1355cf43..61cf905b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class DatasetDeleteParams constructor( private val datasetId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> datasetId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetDeleteParams && this.datasetId == other.datasetId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetDeleteParams && this.datasetId == other.datasetId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetDeleteParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var datasetId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetDeleteParams: DatasetDeleteParams) = apply { this.datasetId = datasetDeleteParams.datasetId - additionalQueryParams(datasetDeleteParams.additionalQueryParams) additionalHeaders(datasetDeleteParams.additionalHeaders) + additionalQueryParams(datasetDeleteParams.additionalQueryParams) additionalBodyProperties(datasetDeleteParams.additionalBodyProperties) } /** Dataset id */ fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): DatasetDeleteParams = DatasetDeleteParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 3b9ee122..6eee3ec7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -11,14 +11,16 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class DatasetFeedbackParams constructor( private val datasetId: String, private val feedback: List, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -31,10 +33,10 @@ constructor( return DatasetFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> datasetId @@ -122,10 +124,10 @@ constructor( "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -133,15 +135,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetFeedbackParams && this.datasetId == other.datasetId && this.feedback == other.feedback && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFeedbackParams && this.datasetId == other.datasetId && this.feedback == other.feedback && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, feedback, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -155,16 +157,16 @@ constructor( private var datasetId: String? = null private var feedback: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = apply { this.datasetId = datasetFeedbackParams.datasetId this.feedback(datasetFeedbackParams.feedback) - additionalQueryParams(datasetFeedbackParams.additionalQueryParams) additionalHeaders(datasetFeedbackParams.additionalHeaders) + additionalQueryParams(datasetFeedbackParams.additionalQueryParams) additionalBodyProperties(datasetFeedbackParams.additionalBodyProperties) } @@ -180,45 +182,44 @@ constructor( /** A list of dataset feedback items */ fun addFeedback(feedback: FeedbackDatasetItem) = apply { this.feedback.add(feedback) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -238,8 +239,14 @@ constructor( DatasetFeedbackParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index afaa9da2..4b341065 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -15,8 +17,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun datasetId(): String = datasetId @@ -29,6 +31,8 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -40,8 +44,6 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - fun getPathParam(index: Int): String { return when (index) { 0 -> datasetId @@ -49,24 +51,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DatasetFetchParams && this.datasetId == other.datasetId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is DatasetFetchParams && this.datasetId == other.datasetId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -83,8 +85,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(datasetFetchParams: DatasetFetchParams) = apply { @@ -93,8 +95,8 @@ constructor( this.maxRootSpanId = datasetFetchParams.maxRootSpanId this.maxXactId = datasetFetchParams.maxXactId this.version = datasetFetchParams.version - additionalQueryParams(datasetFetchParams.additionalQueryParams) additionalHeaders(datasetFetchParams.additionalHeaders) + additionalQueryParams(datasetFetchParams.additionalQueryParams) } /** Dataset id */ @@ -153,45 +155,44 @@ constructor( */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): DatasetFetchParams = DatasetFetchParams( @@ -200,8 +201,14 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 3781f559..cd9f503c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +25,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -55,10 +57,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> datasetId @@ -306,10 +308,10 @@ constructor( "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -317,15 +319,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -344,8 +346,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -357,8 +359,8 @@ constructor( this.maxRootSpanId = datasetFetchPostParams.maxRootSpanId this.maxXactId = datasetFetchPostParams.maxXactId this.version = datasetFetchPostParams.version - additionalQueryParams(datasetFetchPostParams.additionalQueryParams) additionalHeaders(datasetFetchPostParams.additionalHeaders) + additionalQueryParams(datasetFetchPostParams.additionalQueryParams) additionalBodyProperties(datasetFetchPostParams.additionalBodyProperties) } @@ -450,45 +452,44 @@ constructor( */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -513,8 +514,14 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 57d030a3..c307270e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -21,6 +21,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +30,8 @@ class DatasetInsertParams constructor( private val datasetId: String, private val events: List, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -42,10 +44,10 @@ constructor( return DatasetInsertBody(events, additionalBodyProperties) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> datasetId @@ -131,10 +133,10 @@ constructor( "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -142,15 +144,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetInsertParams && this.datasetId == other.datasetId && this.events == other.events && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetInsertParams && this.datasetId == other.datasetId && this.events == other.events && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, events, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -164,16 +166,16 @@ constructor( private var datasetId: String? = null private var events: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetInsertParams: DatasetInsertParams) = apply { this.datasetId = datasetInsertParams.datasetId this.events(datasetInsertParams.events) - additionalQueryParams(datasetInsertParams.additionalQueryParams) additionalHeaders(datasetInsertParams.additionalHeaders) + additionalQueryParams(datasetInsertParams.additionalQueryParams) additionalBodyProperties(datasetInsertParams.additionalBodyProperties) } @@ -189,45 +191,44 @@ constructor( /** A list of dataset events to insert */ fun addEvent(event: Event) = apply { this.events.add(event) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -247,8 +248,14 @@ constructor( DatasetInsertParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 89d040ca..9e5d4917 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +32,8 @@ constructor( private val projectId: String?, private val projectName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun datasetName(): Optional = Optional.ofNullable(datasetName) @@ -50,6 +52,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -65,26 +69,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DatasetListParams && this.datasetName == other.datasetName && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is DatasetListParams && this.datasetName == other.datasetName && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -104,8 +106,8 @@ constructor( private var projectId: String? = null private var projectName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(datasetListParams: DatasetListParams) = apply { @@ -117,8 +119,8 @@ constructor( this.projectId = datasetListParams.projectId this.projectName = datasetListParams.projectName this.startingAfter = datasetListParams.startingAfter - additionalQueryParams(datasetListParams.additionalQueryParams) additionalHeaders(datasetListParams.additionalHeaders) + additionalQueryParams(datasetListParams.additionalQueryParams) } /** Name of the dataset to search for */ @@ -172,45 +174,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): DatasetListParams = DatasetListParams( @@ -222,8 +223,14 @@ constructor( projectId, projectName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index b8079c17..c655ee2a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class DatasetRetrieveParams constructor( private val datasetId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun datasetId(): String = datasetId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> datasetId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DatasetRetrieveParams && this.datasetId == other.datasetId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is DatasetRetrieveParams && this.datasetId == other.datasetId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "DatasetRetrieveParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var datasetId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = apply { this.datasetId = datasetRetrieveParams.datasetId - additionalQueryParams(datasetRetrieveParams.additionalQueryParams) additionalHeaders(datasetRetrieveParams.additionalHeaders) + additionalQueryParams(datasetRetrieveParams.additionalQueryParams) } /** Dataset id */ fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): DatasetRetrieveParams = DatasetRetrieveParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 377115e8..f06c713d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -12,14 +14,16 @@ class DatasetSummarizeParams constructor( private val datasetId: String, private val summarizeData: Boolean?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun datasetId(): String = datasetId fun summarizeData(): Optional = Optional.ofNullable(summarizeData) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -28,8 +32,6 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - fun getPathParam(index: Int): String { return when (index) { 0 -> datasetId @@ -37,24 +39,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DatasetSummarizeParams && this.datasetId == other.datasetId && this.summarizeData == other.summarizeData && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is DatasetSummarizeParams && this.datasetId == other.datasetId && this.summarizeData == other.summarizeData && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -68,15 +70,15 @@ constructor( private var datasetId: String? = null private var summarizeData: Boolean? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = apply { this.datasetId = datasetSummarizeParams.datasetId this.summarizeData = datasetSummarizeParams.summarizeData - additionalQueryParams(datasetSummarizeParams.additionalQueryParams) additionalHeaders(datasetSummarizeParams.additionalHeaders) + additionalQueryParams(datasetSummarizeParams.additionalQueryParams) } /** Dataset id */ @@ -87,52 +89,57 @@ constructor( */ fun summarizeData(summarizeData: Boolean) = apply { this.summarizeData = summarizeData } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): DatasetSummarizeParams = DatasetSummarizeParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, summarizeData, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 6a567c8b..a244c576 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -20,8 +22,8 @@ constructor( private val description: String?, private val metadata: Metadata?, private val name: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -43,10 +45,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> datasetId @@ -154,10 +156,10 @@ constructor( "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -165,15 +167,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetUpdateParams && this.datasetId == other.datasetId && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetUpdateParams && this.datasetId == other.datasetId && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, description, metadata, name, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, description, metadata, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -189,8 +191,8 @@ constructor( private var description: String? = null private var metadata: Metadata? = null private var name: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -199,8 +201,8 @@ constructor( this.description = datasetUpdateParams.description this.metadata = datasetUpdateParams.metadata this.name = datasetUpdateParams.name - additionalQueryParams(datasetUpdateParams.additionalQueryParams) additionalHeaders(datasetUpdateParams.additionalHeaders) + additionalQueryParams(datasetUpdateParams.additionalQueryParams) additionalBodyProperties(datasetUpdateParams.additionalBodyProperties) } @@ -216,45 +218,44 @@ constructor( /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = apply { this.name = name } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -276,8 +277,14 @@ constructor( description, metadata, name, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 9eee9beb..ee6f89b7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -24,8 +26,8 @@ constructor( private val objectId: String, private val objectType: ObjectType, private val value: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -48,10 +50,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = EnvVarCreateBody.Builder::class) @NoAutoDetect class EnvVarCreateBody @@ -162,10 +164,10 @@ constructor( "EnvVarCreateBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -173,15 +175,15 @@ constructor( return true } - return /* spotless:off */ other is EnvVarCreateParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarCreateParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "EnvVarCreateParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "EnvVarCreateParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -197,8 +199,8 @@ constructor( private var objectId: String? = null private var objectType: ObjectType? = null private var value: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -207,8 +209,8 @@ constructor( this.objectId = envVarCreateParams.objectId this.objectType = envVarCreateParams.objectType this.value = envVarCreateParams.value - additionalQueryParams(envVarCreateParams.additionalQueryParams) additionalHeaders(envVarCreateParams.additionalHeaders) + additionalQueryParams(envVarCreateParams.additionalQueryParams) additionalBodyProperties(envVarCreateParams.additionalBodyProperties) } @@ -224,45 +226,44 @@ constructor( /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String) = apply { this.value = value } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -284,8 +285,14 @@ constructor( checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, value, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index def79a86..8c1a7ec5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class EnvVarDeleteParams constructor( private val envVarId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> envVarId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is EnvVarDeleteParams && this.envVarId == other.envVarId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarDeleteParams && this.envVarId == other.envVarId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(envVarId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "EnvVarDeleteParams{envVarId=$envVarId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var envVarId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVarDeleteParams: EnvVarDeleteParams) = apply { this.envVarId = envVarDeleteParams.envVarId - additionalQueryParams(envVarDeleteParams.additionalQueryParams) additionalHeaders(envVarDeleteParams.additionalHeaders) + additionalQueryParams(envVarDeleteParams.additionalQueryParams) additionalBodyProperties(envVarDeleteParams.additionalBodyProperties) } /** EnvVar id */ fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): EnvVarDeleteParams = EnvVarDeleteParams( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 377c8226..4662d882 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 @@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +32,8 @@ constructor( private val limit: Long?, private val objectId: String?, private val objectType: ObjectType?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun envVarName(): Optional = Optional.ofNullable(envVarName) @@ -44,6 +46,8 @@ constructor( fun objectType(): Optional = Optional.ofNullable(objectType) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -56,26 +60,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is EnvVarListParams && this.envVarName == other.envVarName && this.ids == other.ids && this.limit == other.limit && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is EnvVarListParams && this.envVarName == other.envVarName && this.ids == other.ids && this.limit == other.limit && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -92,8 +94,8 @@ constructor( private var limit: Long? = null private var objectId: String? = null private var objectType: ObjectType? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(envVarListParams: EnvVarListParams) = apply { @@ -102,8 +104,8 @@ constructor( this.limit = envVarListParams.limit this.objectId = envVarListParams.objectId this.objectType = envVarListParams.objectType - additionalQueryParams(envVarListParams.additionalQueryParams) additionalHeaders(envVarListParams.additionalHeaders) + additionalQueryParams(envVarListParams.additionalQueryParams) } /** Name of the env_var to search for */ @@ -136,45 +138,44 @@ constructor( /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): EnvVarListParams = EnvVarListParams( @@ -183,8 +184,14 @@ constructor( limit, objectId, objectType, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index b673f7af..9a6059c0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -24,8 +26,8 @@ constructor( private val objectId: String, private val objectType: ObjectType, private val value: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -48,10 +50,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = EnvVarReplaceBody.Builder::class) @NoAutoDetect class EnvVarReplaceBody @@ -162,10 +164,10 @@ constructor( "EnvVarReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -173,15 +175,15 @@ constructor( return true } - return /* spotless:off */ other is EnvVarReplaceParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarReplaceParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "EnvVarReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "EnvVarReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -197,8 +199,8 @@ constructor( private var objectId: String? = null private var objectType: ObjectType? = null private var value: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -207,8 +209,8 @@ constructor( this.objectId = envVarReplaceParams.objectId this.objectType = envVarReplaceParams.objectType this.value = envVarReplaceParams.value - additionalQueryParams(envVarReplaceParams.additionalQueryParams) additionalHeaders(envVarReplaceParams.additionalHeaders) + additionalQueryParams(envVarReplaceParams.additionalQueryParams) additionalBodyProperties(envVarReplaceParams.additionalBodyProperties) } @@ -224,45 +226,44 @@ constructor( /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String) = apply { this.value = value } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -284,8 +285,14 @@ constructor( checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, value, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 32689ef5..bf058cb9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class EnvVarRetrieveParams constructor( private val envVarId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun envVarId(): String = envVarId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> envVarId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is EnvVarRetrieveParams && this.envVarId == other.envVarId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is EnvVarRetrieveParams && this.envVarId == other.envVarId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(envVarId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "EnvVarRetrieveParams{envVarId=$envVarId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var envVarId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = apply { this.envVarId = envVarRetrieveParams.envVarId - additionalQueryParams(envVarRetrieveParams.additionalQueryParams) additionalHeaders(envVarRetrieveParams.additionalHeaders) + additionalQueryParams(envVarRetrieveParams.additionalQueryParams) } /** EnvVar id */ fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index d6646700..0d7ac841 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -19,8 +21,8 @@ constructor( private val envVarId: String, private val name: String, private val value: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -39,10 +41,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> envVarId @@ -138,10 +140,10 @@ constructor( "EnvVarUpdateBody{name=$name, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -149,15 +151,15 @@ constructor( return true } - return /* spotless:off */ other is EnvVarUpdateParams && this.envVarId == other.envVarId && this.name == other.name && this.value == other.value && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarUpdateParams && this.envVarId == other.envVarId && this.name == other.name && this.value == other.value && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(envVarId, name, value, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(envVarId, name, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "EnvVarUpdateParams{envVarId=$envVarId, name=$name, value=$value, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "EnvVarUpdateParams{envVarId=$envVarId, name=$name, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -172,8 +174,8 @@ constructor( private var envVarId: String? = null private var name: String? = null private var value: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -181,8 +183,8 @@ constructor( this.envVarId = envVarUpdateParams.envVarId this.name = envVarUpdateParams.name this.value = envVarUpdateParams.value - additionalQueryParams(envVarUpdateParams.additionalQueryParams) additionalHeaders(envVarUpdateParams.additionalHeaders) + additionalQueryParams(envVarUpdateParams.additionalQueryParams) additionalBodyProperties(envVarUpdateParams.additionalBodyProperties) } @@ -195,45 +197,44 @@ constructor( /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String) = apply { this.value = value } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -254,8 +255,14 @@ constructor( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, value, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 9c9213dd..f96e32eb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -25,6 +25,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -37,8 +39,8 @@ constructor( private val experimentName: String?, private val metadata: Metadata?, private val stream: Boolean?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -70,10 +72,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = EvalCreateBody.Builder::class) @NoAutoDetect class EvalCreateBody @@ -237,10 +239,10 @@ constructor( "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, experimentName=$experimentName, metadata=$metadata, stream=$stream, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -248,15 +250,15 @@ constructor( return true } - return /* spotless:off */ other is EvalCreateParams && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.experimentName == other.experimentName && this.metadata == other.metadata && this.stream == other.stream && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EvalCreateParams && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.experimentName == other.experimentName && this.metadata == other.metadata && this.stream == other.stream && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(data, projectId, scores, task, experimentName, metadata, stream, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(data, projectId, scores, task, experimentName, metadata, stream, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "EvalCreateParams{data=$data, projectId=$projectId, scores=$scores, task=$task, experimentName=$experimentName, metadata=$metadata, stream=$stream, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "EvalCreateParams{data=$data, projectId=$projectId, scores=$scores, task=$task, experimentName=$experimentName, metadata=$metadata, stream=$stream, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -275,8 +277,8 @@ constructor( private var experimentName: String? = null private var metadata: Metadata? = null private var stream: Boolean? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -288,8 +290,8 @@ constructor( this.experimentName = evalCreateParams.experimentName this.metadata = evalCreateParams.metadata this.stream = evalCreateParams.stream - additionalQueryParams(evalCreateParams.additionalQueryParams) additionalHeaders(evalCreateParams.additionalHeaders) + additionalQueryParams(evalCreateParams.additionalQueryParams) additionalBodyProperties(evalCreateParams.additionalBodyProperties) } @@ -364,45 +366,44 @@ constructor( */ fun stream(stream: Boolean) = apply { this.stream = stream } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -427,8 +428,14 @@ constructor( experimentName, metadata, stream, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 446b35d3..007eae32 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -26,8 +28,8 @@ constructor( private val name: String?, private val public_: Boolean?, private val repoInfo: RepoInfo?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -68,10 +70,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = ExperimentCreateBody.Builder::class) @NoAutoDetect class ExperimentCreateBody @@ -275,10 +277,10 @@ constructor( "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -286,15 +288,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentCreateParams && this.projectId == other.projectId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.ensureNew == other.ensureNew && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentCreateParams && this.projectId == other.projectId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.ensureNew == other.ensureNew && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -316,8 +318,8 @@ constructor( private var name: String? = null private var public_: Boolean? = null private var repoInfo: RepoInfo? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -332,8 +334,8 @@ constructor( this.name = experimentCreateParams.name this.public_ = experimentCreateParams.public_ this.repoInfo = experimentCreateParams.repoInfo - additionalQueryParams(experimentCreateParams.additionalQueryParams) additionalHeaders(experimentCreateParams.additionalHeaders) + additionalQueryParams(experimentCreateParams.additionalQueryParams) additionalBodyProperties(experimentCreateParams.additionalBodyProperties) } @@ -379,45 +381,44 @@ constructor( /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -445,8 +446,14 @@ constructor( name, public_, repoInfo, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 90a4dcb0..0fd48b98 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ExperimentDeleteParams constructor( private val experimentId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> experimentId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentDeleteParams && this.experimentId == other.experimentId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentDeleteParams && this.experimentId == other.experimentId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentDeleteParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var experimentId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentDeleteParams: ExperimentDeleteParams) = apply { this.experimentId = experimentDeleteParams.experimentId - additionalQueryParams(experimentDeleteParams.additionalQueryParams) additionalHeaders(experimentDeleteParams.additionalHeaders) + additionalQueryParams(experimentDeleteParams.additionalQueryParams) additionalBodyProperties(experimentDeleteParams.additionalBodyProperties) } /** Experiment id */ fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): ExperimentDeleteParams = ExperimentDeleteParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index d6fc77c1..aa261cf2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -11,14 +11,16 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ExperimentFeedbackParams constructor( private val experimentId: String, private val feedback: List, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -31,10 +33,10 @@ constructor( return ExperimentFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> experimentId @@ -124,10 +126,10 @@ constructor( "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -135,15 +137,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFeedbackParams && this.experimentId == other.experimentId && this.feedback == other.feedback && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFeedbackParams && this.experimentId == other.experimentId && this.feedback == other.feedback && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, feedback, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -157,16 +159,16 @@ constructor( private var experimentId: String? = null private var feedback: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = apply { this.experimentId = experimentFeedbackParams.experimentId this.feedback(experimentFeedbackParams.feedback) - additionalQueryParams(experimentFeedbackParams.additionalQueryParams) additionalHeaders(experimentFeedbackParams.additionalHeaders) + additionalQueryParams(experimentFeedbackParams.additionalQueryParams) additionalBodyProperties(experimentFeedbackParams.additionalBodyProperties) } @@ -182,45 +184,44 @@ constructor( /** A list of experiment feedback items */ fun addFeedback(feedback: FeedbackExperimentItem) = apply { this.feedback.add(feedback) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -240,8 +241,14 @@ constructor( ExperimentFeedbackParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 8e86da70..ed8745d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -15,8 +17,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun experimentId(): String = experimentId @@ -29,6 +31,8 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -40,8 +44,6 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - fun getPathParam(index: Int): String { return when (index) { 0 -> experimentId @@ -49,24 +51,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ExperimentFetchParams && this.experimentId == other.experimentId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchParams && this.experimentId == other.experimentId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -83,8 +85,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(experimentFetchParams: ExperimentFetchParams) = apply { @@ -93,8 +95,8 @@ constructor( this.maxRootSpanId = experimentFetchParams.maxRootSpanId this.maxXactId = experimentFetchParams.maxXactId this.version = experimentFetchParams.version - additionalQueryParams(experimentFetchParams.additionalQueryParams) additionalHeaders(experimentFetchParams.additionalHeaders) + additionalQueryParams(experimentFetchParams.additionalQueryParams) } /** Experiment id */ @@ -153,45 +155,44 @@ constructor( */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ExperimentFetchParams = ExperimentFetchParams( @@ -200,8 +201,14 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index c0fa53ba..78a75332 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +25,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -55,10 +57,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> experimentId @@ -306,10 +308,10 @@ constructor( "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -317,15 +319,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -344,8 +346,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -357,8 +359,8 @@ constructor( this.maxRootSpanId = experimentFetchPostParams.maxRootSpanId this.maxXactId = experimentFetchPostParams.maxXactId this.version = experimentFetchPostParams.version - additionalQueryParams(experimentFetchPostParams.additionalQueryParams) additionalHeaders(experimentFetchPostParams.additionalHeaders) + additionalQueryParams(experimentFetchPostParams.additionalQueryParams) additionalBodyProperties(experimentFetchPostParams.additionalBodyProperties) } @@ -450,45 +452,44 @@ constructor( */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -513,8 +514,14 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index cc86d923..91b39073 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -21,6 +21,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +30,8 @@ class ExperimentInsertParams constructor( private val experimentId: String, private val events: List, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -42,10 +44,10 @@ constructor( return ExperimentInsertBody(events, additionalBodyProperties) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> experimentId @@ -131,10 +133,10 @@ constructor( "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -142,15 +144,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentInsertParams && this.experimentId == other.experimentId && this.events == other.events && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentInsertParams && this.experimentId == other.experimentId && this.events == other.events && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, events, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -164,16 +166,16 @@ constructor( private var experimentId: String? = null private var events: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentInsertParams: ExperimentInsertParams) = apply { this.experimentId = experimentInsertParams.experimentId this.events(experimentInsertParams.events) - additionalQueryParams(experimentInsertParams.additionalQueryParams) additionalHeaders(experimentInsertParams.additionalHeaders) + additionalQueryParams(experimentInsertParams.additionalQueryParams) additionalBodyProperties(experimentInsertParams.additionalBodyProperties) } @@ -189,45 +191,44 @@ constructor( /** A list of experiment events to insert */ fun addEvent(event: Event) = apply { this.events.add(event) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -247,8 +248,14 @@ constructor( ExperimentInsertParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 3e6a63f0..c205dff8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +32,8 @@ constructor( private val projectId: String?, private val projectName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -50,6 +52,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -65,26 +69,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ExperimentListParams && this.endingBefore == other.endingBefore && this.experimentName == other.experimentName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ExperimentListParams && this.endingBefore == other.endingBefore && this.experimentName == other.experimentName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -104,8 +106,8 @@ constructor( private var projectId: String? = null private var projectName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(experimentListParams: ExperimentListParams) = apply { @@ -117,8 +119,8 @@ constructor( this.projectId = experimentListParams.projectId this.projectName = experimentListParams.projectName this.startingAfter = experimentListParams.startingAfter - additionalQueryParams(experimentListParams.additionalQueryParams) additionalHeaders(experimentListParams.additionalHeaders) + additionalQueryParams(experimentListParams.additionalQueryParams) } /** @@ -172,45 +174,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ExperimentListParams = ExperimentListParams( @@ -222,8 +223,14 @@ constructor( projectId, projectName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 3d683823..f5035fc8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ExperimentRetrieveParams constructor( private val experimentId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun experimentId(): String = experimentId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> experimentId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ExperimentRetrieveParams && this.experimentId == other.experimentId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ExperimentRetrieveParams && this.experimentId == other.experimentId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ExperimentRetrieveParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var experimentId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = apply { this.experimentId = experimentRetrieveParams.experimentId - additionalQueryParams(experimentRetrieveParams.additionalQueryParams) additionalHeaders(experimentRetrieveParams.additionalHeaders) + additionalQueryParams(experimentRetrieveParams.additionalQueryParams) } /** Experiment id */ fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 1c7fa7dc..ce1527b1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -13,8 +15,8 @@ constructor( private val experimentId: String, private val comparisonExperimentId: String?, private val summarizeScores: Boolean?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun experimentId(): String = experimentId @@ -23,6 +25,8 @@ constructor( fun summarizeScores(): Optional = Optional.ofNullable(summarizeScores) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -34,8 +38,6 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - fun getPathParam(index: Int): String { return when (index) { 0 -> experimentId @@ -43,24 +45,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ExperimentSummarizeParams && this.experimentId == other.experimentId && this.comparisonExperimentId == other.comparisonExperimentId && this.summarizeScores == other.summarizeScores && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ExperimentSummarizeParams && this.experimentId == other.experimentId && this.comparisonExperimentId == other.comparisonExperimentId && this.summarizeScores == other.summarizeScores && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -75,16 +77,16 @@ constructor( private var experimentId: String? = null private var comparisonExperimentId: String? = null private var summarizeScores: Boolean? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = apply { this.experimentId = experimentSummarizeParams.experimentId this.comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId this.summarizeScores = experimentSummarizeParams.summarizeScores - additionalQueryParams(experimentSummarizeParams.additionalQueryParams) additionalHeaders(experimentSummarizeParams.additionalHeaders) + additionalQueryParams(experimentSummarizeParams.additionalQueryParams) } /** Experiment id */ @@ -108,53 +110,58 @@ constructor( this.summarizeScores = summarizeScores } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, comparisonExperimentId, summarizeScores, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 5f690c3e..e503141a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -25,8 +27,8 @@ constructor( private val name: String?, private val public_: Boolean?, private val repoInfo: RepoInfo?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -63,10 +65,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> experimentId @@ -247,10 +249,10 @@ constructor( "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -258,15 +260,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentUpdateParams && this.experimentId == other.experimentId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentUpdateParams && this.experimentId == other.experimentId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -287,8 +289,8 @@ constructor( private var name: String? = null private var public_: Boolean? = null private var repoInfo: RepoInfo? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -302,8 +304,8 @@ constructor( this.name = experimentUpdateParams.name this.public_ = experimentUpdateParams.public_ this.repoInfo = experimentUpdateParams.repoInfo - additionalQueryParams(experimentUpdateParams.additionalQueryParams) additionalHeaders(experimentUpdateParams.additionalHeaders) + additionalQueryParams(experimentUpdateParams.additionalQueryParams) additionalBodyProperties(experimentUpdateParams.additionalBodyProperties) } @@ -342,45 +344,44 @@ constructor( /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -407,8 +408,14 @@ constructor( name, public_, repoInfo, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 e898103d..796eb04f 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 @@ -25,6 +25,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -40,8 +42,8 @@ constructor( private val origin: Origin?, private val promptData: PromptData?, private val tags: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -82,10 +84,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = FunctionCreateBody.Builder::class) @NoAutoDetect class FunctionCreateBody @@ -260,10 +262,10 @@ constructor( "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -271,15 +273,15 @@ constructor( return true } - return /* spotless:off */ other is FunctionCreateParams && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCreateParams && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -301,8 +303,8 @@ constructor( private var origin: Origin? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -317,8 +319,8 @@ constructor( this.origin = functionCreateParams.origin this.promptData = functionCreateParams.promptData this.tags(functionCreateParams.tags ?: listOf()) - additionalQueryParams(functionCreateParams.additionalQueryParams) additionalHeaders(functionCreateParams.additionalHeaders) + additionalQueryParams(functionCreateParams.additionalQueryParams) additionalBodyProperties(functionCreateParams.additionalBodyProperties) } @@ -369,45 +371,44 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -435,8 +436,14 @@ constructor( origin, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index 70c05266..2e8f8fb9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class FunctionDeleteParams constructor( private val functionId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> functionId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is FunctionDeleteParams && this.functionId == other.functionId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionDeleteParams && this.functionId == other.functionId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "FunctionDeleteParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var functionId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionDeleteParams: FunctionDeleteParams) = apply { this.functionId = functionDeleteParams.functionId - additionalQueryParams(functionDeleteParams.additionalQueryParams) additionalHeaders(functionDeleteParams.additionalHeaders) + additionalQueryParams(functionDeleteParams.additionalQueryParams) additionalBodyProperties(functionDeleteParams.additionalBodyProperties) } /** Function id */ fun functionId(functionId: String) = apply { this.functionId = functionId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): FunctionDeleteParams = FunctionDeleteParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index d7eff11a..b0318807 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -25,6 +25,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -37,8 +39,8 @@ constructor( private val parent: Parent?, private val stream: Boolean?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -69,10 +71,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> functionId @@ -216,10 +218,10 @@ constructor( "FunctionInvokeBody{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -227,15 +229,15 @@ constructor( return true } - return /* spotless:off */ other is FunctionInvokeParams && this.functionId == other.functionId && this.input == other.input && this.messages == other.messages && this.mode == other.mode && this.parent == other.parent && this.stream == other.stream && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeParams && this.functionId == other.functionId && this.input == other.input && this.messages == other.messages && this.mode == other.mode && this.parent == other.parent && this.stream == other.stream && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, input, messages, mode, parent, stream, version, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(functionId, input, messages, mode, parent, stream, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "FunctionInvokeParams{functionId=$functionId, input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionInvokeParams{functionId=$functionId, input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -254,8 +256,8 @@ constructor( private var parent: Parent? = null private var stream: Boolean? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -267,8 +269,8 @@ constructor( this.parent = functionInvokeParams.parent this.stream = functionInvokeParams.stream this.version = functionInvokeParams.version - additionalQueryParams(functionInvokeParams.additionalQueryParams) additionalHeaders(functionInvokeParams.additionalHeaders) + additionalQueryParams(functionInvokeParams.additionalQueryParams) additionalBodyProperties(functionInvokeParams.additionalBodyProperties) } @@ -310,45 +312,44 @@ constructor( /** The version of the function */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -373,8 +374,14 @@ constructor( parent, stream, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 771a250d..8b0ab35d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -32,8 +34,8 @@ constructor( private val slug: String?, private val startingAfter: String?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -56,6 +58,8 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -73,26 +77,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is FunctionListParams && this.endingBefore == other.endingBefore && this.functionName == other.functionName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.slug == other.slug && this.startingAfter == other.startingAfter && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is FunctionListParams && this.endingBefore == other.endingBefore && this.functionName == other.functionName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.slug == other.slug && this.startingAfter == other.startingAfter && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -114,8 +116,8 @@ constructor( private var slug: String? = null private var startingAfter: String? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(functionListParams: FunctionListParams) = apply { @@ -129,8 +131,8 @@ constructor( this.slug = functionListParams.slug this.startingAfter = functionListParams.startingAfter this.version = functionListParams.version - additionalQueryParams(functionListParams.additionalQueryParams) additionalHeaders(functionListParams.additionalHeaders) + additionalQueryParams(functionListParams.additionalQueryParams) } /** @@ -195,45 +197,44 @@ constructor( */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): FunctionListParams = FunctionListParams( @@ -247,8 +248,14 @@ constructor( slug, startingAfter, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } 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 5b591105..0b60036e 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 @@ -25,6 +25,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -40,8 +42,8 @@ constructor( private val origin: Origin?, private val promptData: PromptData?, private val tags: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -82,10 +84,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = FunctionReplaceBody.Builder::class) @NoAutoDetect class FunctionReplaceBody @@ -260,10 +262,10 @@ constructor( "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -271,15 +273,15 @@ constructor( return true } - return /* spotless:off */ other is FunctionReplaceParams && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionReplaceParams && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -301,8 +303,8 @@ constructor( private var origin: Origin? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -317,8 +319,8 @@ constructor( this.origin = functionReplaceParams.origin this.promptData = functionReplaceParams.promptData this.tags(functionReplaceParams.tags ?: listOf()) - additionalQueryParams(functionReplaceParams.additionalQueryParams) additionalHeaders(functionReplaceParams.additionalHeaders) + additionalQueryParams(functionReplaceParams.additionalQueryParams) additionalBodyProperties(functionReplaceParams.additionalBodyProperties) } @@ -369,45 +371,44 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -435,8 +436,14 @@ constructor( origin, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index 24c84097..b85103f3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class FunctionRetrieveParams constructor( private val functionId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun functionId(): String = functionId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> functionId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is FunctionRetrieveParams && this.functionId == other.functionId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is FunctionRetrieveParams && this.functionId == other.functionId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "FunctionRetrieveParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var functionId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(functionRetrieveParams: FunctionRetrieveParams) = apply { this.functionId = functionRetrieveParams.functionId - additionalQueryParams(functionRetrieveParams.additionalQueryParams) additionalHeaders(functionRetrieveParams.additionalHeaders) + additionalQueryParams(functionRetrieveParams.additionalQueryParams) } /** Function id */ fun functionId(functionId: String) = apply { this.functionId = functionId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): FunctionRetrieveParams = FunctionRetrieveParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 3e6be905..5cb65c15 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -25,6 +25,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -36,8 +38,8 @@ constructor( private val name: String?, private val promptData: PromptData?, private val tags: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -65,10 +67,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> functionId @@ -197,10 +199,10 @@ constructor( "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -208,15 +210,15 @@ constructor( return true } - return /* spotless:off */ other is FunctionUpdateParams && this.functionId == other.functionId && this.description == other.description && this.functionData == other.functionData && this.name == other.name && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionUpdateParams && this.functionId == other.functionId && this.description == other.description && this.functionData == other.functionData && this.name == other.name && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, description, functionData, name, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(functionId, description, functionData, name, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -234,8 +236,8 @@ constructor( private var name: String? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -246,8 +248,8 @@ constructor( this.name = functionUpdateParams.name this.promptData = functionUpdateParams.promptData this.tags(functionUpdateParams.tags ?: listOf()) - additionalQueryParams(functionUpdateParams.additionalQueryParams) additionalHeaders(functionUpdateParams.additionalHeaders) + additionalQueryParams(functionUpdateParams.additionalQueryParams) additionalBodyProperties(functionUpdateParams.additionalBodyProperties) } @@ -290,45 +292,44 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -352,8 +353,14 @@ constructor( name, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 35722c3f..306ff7dd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -21,8 +23,8 @@ constructor( private val memberGroups: List?, private val memberUsers: List?, private val orgName: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -48,10 +50,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = GroupCreateBody.Builder::class) @NoAutoDetect class GroupCreateBody @@ -194,10 +196,10 @@ constructor( "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -205,15 +207,15 @@ constructor( return true } - return /* spotless:off */ other is GroupCreateParams && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupCreateParams && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -230,8 +232,8 @@ constructor( private var memberGroups: MutableList = mutableListOf() private var memberUsers: MutableList = mutableListOf() private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -241,8 +243,8 @@ constructor( this.memberGroups(groupCreateParams.memberGroups ?: listOf()) this.memberUsers(groupCreateParams.memberUsers ?: listOf()) this.orgName = groupCreateParams.orgName - additionalQueryParams(groupCreateParams.additionalQueryParams) additionalHeaders(groupCreateParams.additionalHeaders) + additionalQueryParams(groupCreateParams.additionalQueryParams) additionalBodyProperties(groupCreateParams.additionalBodyProperties) } @@ -287,45 +289,44 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -348,8 +349,14 @@ constructor( if (memberGroups.size == 0) null else memberGroups.toImmutable(), if (memberUsers.size == 0) null else memberUsers.toImmutable(), orgName, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index edb55533..4ae78997 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class GroupDeleteParams constructor( private val groupId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> groupId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is GroupDeleteParams && this.groupId == other.groupId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupDeleteParams && this.groupId == other.groupId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(groupId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "GroupDeleteParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var groupId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(groupDeleteParams: GroupDeleteParams) = apply { this.groupId = groupDeleteParams.groupId - additionalQueryParams(groupDeleteParams.additionalQueryParams) additionalHeaders(groupDeleteParams.additionalHeaders) + additionalQueryParams(groupDeleteParams.additionalQueryParams) additionalBodyProperties(groupDeleteParams.additionalBodyProperties) } /** Group id */ fun groupId(groupId: String) = apply { this.groupId = groupId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): GroupDeleteParams = GroupDeleteParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index f2ccc6d9..7b809ded 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +30,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -44,6 +46,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -57,26 +61,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupListParams && this.endingBefore == other.endingBefore && this.groupName == other.groupName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is GroupListParams && this.endingBefore == other.endingBefore && this.groupName == other.groupName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -94,8 +96,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(groupListParams: GroupListParams) = apply { @@ -105,8 +107,8 @@ constructor( this.limit = groupListParams.limit this.orgName = groupListParams.orgName this.startingAfter = groupListParams.startingAfter - additionalQueryParams(groupListParams.additionalQueryParams) additionalHeaders(groupListParams.additionalHeaders) + additionalQueryParams(groupListParams.additionalQueryParams) } /** @@ -154,45 +156,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): GroupListParams = GroupListParams( @@ -202,8 +203,14 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index bcb78789..0d5c481e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -21,8 +23,8 @@ constructor( private val memberGroups: List?, private val memberUsers: List?, private val orgName: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -48,10 +50,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = GroupReplaceBody.Builder::class) @NoAutoDetect class GroupReplaceBody @@ -194,10 +196,10 @@ constructor( "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -205,15 +207,15 @@ constructor( return true } - return /* spotless:off */ other is GroupReplaceParams && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupReplaceParams && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -230,8 +232,8 @@ constructor( private var memberGroups: MutableList = mutableListOf() private var memberUsers: MutableList = mutableListOf() private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -241,8 +243,8 @@ constructor( this.memberGroups(groupReplaceParams.memberGroups ?: listOf()) this.memberUsers(groupReplaceParams.memberUsers ?: listOf()) this.orgName = groupReplaceParams.orgName - additionalQueryParams(groupReplaceParams.additionalQueryParams) additionalHeaders(groupReplaceParams.additionalHeaders) + additionalQueryParams(groupReplaceParams.additionalQueryParams) additionalBodyProperties(groupReplaceParams.additionalBodyProperties) } @@ -287,45 +289,44 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -348,8 +349,14 @@ constructor( if (memberGroups.size == 0) null else memberGroups.toImmutable(), if (memberUsers.size == 0) null else memberUsers.toImmutable(), orgName, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index efd1b184..bc6f746d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class GroupRetrieveParams constructor( private val groupId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun groupId(): String = groupId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> groupId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupRetrieveParams && this.groupId == other.groupId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is GroupRetrieveParams && this.groupId == other.groupId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(groupId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "GroupRetrieveParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var groupId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(groupRetrieveParams: GroupRetrieveParams) = apply { this.groupId = groupRetrieveParams.groupId - additionalQueryParams(groupRetrieveParams.additionalQueryParams) additionalHeaders(groupRetrieveParams.additionalHeaders) + additionalQueryParams(groupRetrieveParams.additionalQueryParams) } /** Group id */ fun groupId(groupId: String) = apply { this.groupId = groupId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): GroupRetrieveParams = GroupRetrieveParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 375a08d2..9956810a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +25,8 @@ constructor( private val name: String?, private val removeMemberGroups: List?, private val removeMemberUsers: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -55,10 +57,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> groupId @@ -209,10 +211,10 @@ constructor( "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -220,15 +222,15 @@ constructor( return true } - return /* spotless:off */ other is GroupUpdateParams && this.groupId == other.groupId && this.addMemberGroups == other.addMemberGroups && this.addMemberUsers == other.addMemberUsers && this.description == other.description && this.name == other.name && this.removeMemberGroups == other.removeMemberGroups && this.removeMemberUsers == other.removeMemberUsers && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupUpdateParams && this.groupId == other.groupId && this.addMemberGroups == other.addMemberGroups && this.addMemberUsers == other.addMemberUsers && this.description == other.description && this.name == other.name && this.removeMemberGroups == other.removeMemberGroups && this.removeMemberUsers == other.removeMemberUsers && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(groupId, addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(groupId, addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -247,8 +249,8 @@ constructor( private var name: String? = null private var removeMemberGroups: MutableList = mutableListOf() private var removeMemberUsers: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -260,8 +262,8 @@ constructor( this.name = groupUpdateParams.name this.removeMemberGroups(groupUpdateParams.removeMemberGroups ?: listOf()) this.removeMemberUsers(groupUpdateParams.removeMemberUsers ?: listOf()) - additionalQueryParams(groupUpdateParams.additionalQueryParams) additionalHeaders(groupUpdateParams.additionalHeaders) + additionalQueryParams(groupUpdateParams.additionalQueryParams) additionalBodyProperties(groupUpdateParams.additionalBodyProperties) } @@ -318,45 +320,44 @@ constructor( this.removeMemberUsers.add(removeMemberUser) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -381,8 +382,14 @@ constructor( name, if (removeMemberGroups.size == 0) null else removeMemberGroups.toImmutable(), if (removeMemberUsers.size == 0) null else removeMemberUsers.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index 8867b84a..88338059 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class OrganizationDeleteParams constructor( private val organizationId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> organizationId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is OrganizationDeleteParams && this.organizationId == other.organizationId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationDeleteParams && this.organizationId == other.organizationId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(organizationId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "OrganizationDeleteParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var organizationId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(organizationDeleteParams: OrganizationDeleteParams) = apply { this.organizationId = organizationDeleteParams.organizationId - additionalQueryParams(organizationDeleteParams.additionalQueryParams) additionalHeaders(organizationDeleteParams.additionalHeaders) + additionalQueryParams(organizationDeleteParams.additionalQueryParams) additionalBodyProperties(organizationDeleteParams.additionalBodyProperties) } /** Organization id */ fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): OrganizationDeleteParams = OrganizationDeleteParams( checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 1d93a5a4..f6875732 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +29,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -41,6 +43,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -53,26 +57,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is OrganizationListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is OrganizationListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -89,8 +91,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(organizationListParams: OrganizationListParams) = apply { @@ -99,8 +101,8 @@ constructor( this.limit = organizationListParams.limit this.orgName = organizationListParams.orgName this.startingAfter = organizationListParams.startingAfter - additionalQueryParams(organizationListParams.additionalQueryParams) additionalHeaders(organizationListParams.additionalHeaders) + additionalQueryParams(organizationListParams.additionalQueryParams) } /** @@ -145,45 +147,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): OrganizationListParams = OrganizationListParams( @@ -192,8 +193,14 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 31d58e68..373033ae 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -20,8 +22,8 @@ constructor( private val orgId: String?, private val orgName: String?, private val removeUsers: RemoveUsers?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -44,10 +46,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = OrganizationMemberUpdateBody.Builder::class) @NoAutoDetect class OrganizationMemberUpdateBody @@ -177,10 +179,10 @@ constructor( "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -188,15 +190,15 @@ constructor( return true } - return /* spotless:off */ other is OrganizationMemberUpdateParams && this.inviteUsers == other.inviteUsers && this.orgId == other.orgId && this.orgName == other.orgName && this.removeUsers == other.removeUsers && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationMemberUpdateParams && this.inviteUsers == other.inviteUsers && this.orgId == other.orgId && this.orgName == other.orgName && this.removeUsers == other.removeUsers && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -212,8 +214,8 @@ constructor( private var orgId: String? = null private var orgName: String? = null private var removeUsers: RemoveUsers? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -222,8 +224,8 @@ constructor( this.orgId = organizationMemberUpdateParams.orgId this.orgName = organizationMemberUpdateParams.orgName this.removeUsers = organizationMemberUpdateParams.removeUsers - additionalQueryParams(organizationMemberUpdateParams.additionalQueryParams) additionalHeaders(organizationMemberUpdateParams.additionalHeaders) + additionalQueryParams(organizationMemberUpdateParams.additionalQueryParams) additionalBodyProperties(organizationMemberUpdateParams.additionalBodyProperties) } @@ -247,45 +249,44 @@ constructor( /** Users to remove from the organization */ fun removeUsers(removeUsers: RemoveUsers) = apply { this.removeUsers = removeUsers } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -307,8 +308,14 @@ constructor( orgId, orgName, removeUsers, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index b55457db..a9013b45 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class OrganizationRetrieveParams constructor( private val organizationId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun organizationId(): String = organizationId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> organizationId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is OrganizationRetrieveParams && this.organizationId == other.organizationId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is OrganizationRetrieveParams && this.organizationId == other.organizationId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(organizationId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "OrganizationRetrieveParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var organizationId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = apply { this.organizationId = organizationRetrieveParams.organizationId - additionalQueryParams(organizationRetrieveParams.additionalQueryParams) additionalHeaders(organizationRetrieveParams.additionalHeaders) + additionalQueryParams(organizationRetrieveParams.additionalQueryParams) } /** Organization id */ fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index c3e24b6e..1a8616f8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -22,8 +24,8 @@ constructor( private val name: String?, private val proxyUrl: String?, private val realtimeUrl: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -51,10 +53,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> organizationId @@ -177,10 +179,10 @@ constructor( "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -188,15 +190,15 @@ constructor( return true } - return /* spotless:off */ other is OrganizationUpdateParams && this.organizationId == other.organizationId && this.apiUrl == other.apiUrl && this.isUniversalApi == other.isUniversalApi && this.name == other.name && this.proxyUrl == other.proxyUrl && this.realtimeUrl == other.realtimeUrl && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationUpdateParams && this.organizationId == other.organizationId && this.apiUrl == other.apiUrl && this.isUniversalApi == other.isUniversalApi && this.name == other.name && this.proxyUrl == other.proxyUrl && this.realtimeUrl == other.realtimeUrl && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(organizationId, apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(organizationId, apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -214,8 +216,8 @@ constructor( private var name: String? = null private var proxyUrl: String? = null private var realtimeUrl: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -226,8 +228,8 @@ constructor( this.name = organizationUpdateParams.name this.proxyUrl = organizationUpdateParams.proxyUrl this.realtimeUrl = organizationUpdateParams.realtimeUrl - additionalQueryParams(organizationUpdateParams.additionalQueryParams) additionalHeaders(organizationUpdateParams.additionalHeaders) + additionalQueryParams(organizationUpdateParams.additionalQueryParams) additionalBodyProperties(organizationUpdateParams.additionalBodyProperties) } @@ -245,45 +247,44 @@ constructor( fun realtimeUrl(realtimeUrl: String) = apply { this.realtimeUrl = realtimeUrl } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -307,8 +308,14 @@ constructor( name, proxyUrl, realtimeUrl, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 9d8ce8a0..b9be1699 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -18,8 +20,8 @@ class ProjectCreateParams constructor( private val name: String, private val orgName: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -36,10 +38,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = ProjectCreateBody.Builder::class) @NoAutoDetect class ProjectCreateBody @@ -137,10 +139,10 @@ constructor( "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -148,15 +150,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -170,16 +172,16 @@ constructor( private var name: String? = null private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectCreateParams: ProjectCreateParams) = apply { this.name = projectCreateParams.name this.orgName = projectCreateParams.orgName - additionalQueryParams(projectCreateParams.additionalQueryParams) additionalHeaders(projectCreateParams.additionalHeaders) + additionalQueryParams(projectCreateParams.additionalQueryParams) additionalBodyProperties(projectCreateParams.additionalBodyProperties) } @@ -193,45 +195,44 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -251,8 +252,14 @@ constructor( ProjectCreateParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 779b3b69..1171dcd2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ProjectDeleteParams constructor( private val projectId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectDeleteParams && this.projectId == other.projectId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDeleteParams && this.projectId == other.projectId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectDeleteParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var projectId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectDeleteParams: ProjectDeleteParams) = apply { this.projectId = projectDeleteParams.projectId - additionalQueryParams(projectDeleteParams.additionalQueryParams) additionalHeaders(projectDeleteParams.additionalHeaders) + additionalQueryParams(projectDeleteParams.additionalQueryParams) additionalBodyProperties(projectDeleteParams.additionalBodyProperties) } /** Project id */ fun projectId(projectId: String) = apply { this.projectId = projectId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): ProjectDeleteParams = ProjectDeleteParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 6abf8388..07a4735c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +30,8 @@ constructor( private val orgName: String?, private val projectName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -44,6 +46,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -57,26 +61,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ProjectListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -94,8 +96,8 @@ constructor( private var orgName: String? = null private var projectName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(projectListParams: ProjectListParams) = apply { @@ -105,8 +107,8 @@ constructor( this.orgName = projectListParams.orgName this.projectName = projectListParams.projectName this.startingAfter = projectListParams.startingAfter - additionalQueryParams(projectListParams.additionalQueryParams) additionalHeaders(projectListParams.additionalHeaders) + additionalQueryParams(projectListParams.additionalQueryParams) } /** @@ -154,45 +156,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ProjectListParams = ProjectListParams( @@ -202,8 +203,14 @@ constructor( orgName, projectName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 953e3ef1..07356296 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -11,14 +11,16 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ProjectLogFeedbackParams constructor( private val projectId: String, private val feedback: List, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -31,10 +33,10 @@ constructor( return ProjectLogFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectId @@ -124,10 +126,10 @@ constructor( "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -135,15 +137,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFeedbackParams && this.projectId == other.projectId && this.feedback == other.feedback && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFeedbackParams && this.projectId == other.projectId && this.feedback == other.feedback && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, feedback, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -157,16 +159,16 @@ constructor( private var projectId: String? = null private var feedback: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = apply { this.projectId = projectLogFeedbackParams.projectId this.feedback(projectLogFeedbackParams.feedback) - additionalQueryParams(projectLogFeedbackParams.additionalQueryParams) additionalHeaders(projectLogFeedbackParams.additionalHeaders) + additionalQueryParams(projectLogFeedbackParams.additionalQueryParams) additionalBodyProperties(projectLogFeedbackParams.additionalBodyProperties) } @@ -182,45 +184,44 @@ constructor( /** A list of project logs feedback items */ fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { this.feedback.add(feedback) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -240,8 +241,14 @@ constructor( ProjectLogFeedbackParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index ac72c562..902e783f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -15,8 +17,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun projectId(): String = projectId @@ -29,6 +31,8 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -40,8 +44,6 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - fun getPathParam(index: Int): String { return when (index) { 0 -> projectId @@ -49,24 +51,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectLogFetchParams && this.projectId == other.projectId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchParams && this.projectId == other.projectId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -83,8 +85,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(projectLogFetchParams: ProjectLogFetchParams) = apply { @@ -93,8 +95,8 @@ constructor( this.maxRootSpanId = projectLogFetchParams.maxRootSpanId this.maxXactId = projectLogFetchParams.maxXactId this.version = projectLogFetchParams.version - additionalQueryParams(projectLogFetchParams.additionalQueryParams) additionalHeaders(projectLogFetchParams.additionalHeaders) + additionalQueryParams(projectLogFetchParams.additionalQueryParams) } /** Project id */ @@ -153,45 +155,44 @@ constructor( */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ProjectLogFetchParams = ProjectLogFetchParams( @@ -200,8 +201,14 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 016acf59..5676e1f2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +25,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -55,10 +57,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectId @@ -306,10 +308,10 @@ constructor( "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -317,15 +319,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -344,8 +346,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -357,8 +359,8 @@ constructor( this.maxRootSpanId = projectLogFetchPostParams.maxRootSpanId this.maxXactId = projectLogFetchPostParams.maxXactId this.version = projectLogFetchPostParams.version - additionalQueryParams(projectLogFetchPostParams.additionalQueryParams) additionalHeaders(projectLogFetchPostParams.additionalHeaders) + additionalQueryParams(projectLogFetchPostParams.additionalQueryParams) additionalBodyProperties(projectLogFetchPostParams.additionalBodyProperties) } @@ -450,45 +452,44 @@ constructor( */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -513,8 +514,14 @@ constructor( maxRootSpanId, maxXactId, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index a1ea28fc..e511fdb9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -21,6 +21,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +30,8 @@ class ProjectLogInsertParams constructor( private val projectId: String, private val events: List, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -42,10 +44,10 @@ constructor( return ProjectLogInsertBody(events, additionalBodyProperties) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectId @@ -131,10 +133,10 @@ constructor( "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -142,15 +144,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogInsertParams && this.projectId == other.projectId && this.events == other.events && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogInsertParams && this.projectId == other.projectId && this.events == other.events && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, events, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -164,16 +166,16 @@ constructor( private var projectId: String? = null private var events: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogInsertParams: ProjectLogInsertParams) = apply { this.projectId = projectLogInsertParams.projectId this.events(projectLogInsertParams.events) - additionalQueryParams(projectLogInsertParams.additionalQueryParams) additionalHeaders(projectLogInsertParams.additionalHeaders) + additionalQueryParams(projectLogInsertParams.additionalQueryParams) additionalBodyProperties(projectLogInsertParams.additionalBodyProperties) } @@ -189,45 +191,44 @@ constructor( /** A list of project logs events to insert */ fun addEvent(event: Event) = apply { this.events.add(event) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -247,8 +248,14 @@ constructor( ProjectLogInsertParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index d9b3f9e0..29802bc9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ProjectRetrieveParams constructor( private val projectId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun projectId(): String = projectId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectRetrieveParams && this.projectId == other.projectId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ProjectRetrieveParams && this.projectId == other.projectId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ProjectRetrieveParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var projectId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(projectRetrieveParams: ProjectRetrieveParams) = apply { this.projectId = projectRetrieveParams.projectId - additionalQueryParams(projectRetrieveParams.additionalQueryParams) additionalHeaders(projectRetrieveParams.additionalHeaders) + additionalQueryParams(projectRetrieveParams.additionalQueryParams) } /** Project id */ fun projectId(projectId: String) = apply { this.projectId = projectId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ProjectRetrieveParams = ProjectRetrieveParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } 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 40c97d84..6a4bbf75 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 @@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -31,8 +33,8 @@ constructor( private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -61,10 +63,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + /** A project score is a user-configured score, which can be manually-labeled through the UI */ @JsonDeserialize(builder = ProjectScoreCreateBody.Builder::class) @NoAutoDetect @@ -197,10 +199,10 @@ constructor( "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -208,15 +210,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreCreateParams && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCreateParams && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -234,8 +236,8 @@ constructor( private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -246,8 +248,8 @@ constructor( this.categories = projectScoreCreateParams.categories this.config = projectScoreCreateParams.config this.description = projectScoreCreateParams.description - additionalQueryParams(projectScoreCreateParams.additionalQueryParams) additionalHeaders(projectScoreCreateParams.additionalHeaders) + additionalQueryParams(projectScoreCreateParams.additionalQueryParams) additionalBodyProperties(projectScoreCreateParams.additionalBodyProperties) } @@ -288,45 +290,44 @@ constructor( /** Textual description of the project score */ fun description(description: String) = apply { this.description = description } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -350,8 +351,14 @@ constructor( categories, config, description, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 8b3ff920..7689da11 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ProjectScoreDeleteParams constructor( private val projectScoreId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectScoreId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreDeleteParams && this.projectScoreId == other.projectScoreId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreDeleteParams && this.projectScoreId == other.projectScoreId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoreId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var projectScoreId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreDeleteParams: ProjectScoreDeleteParams) = apply { this.projectScoreId = projectScoreDeleteParams.projectScoreId - additionalQueryParams(projectScoreDeleteParams.additionalQueryParams) additionalHeaders(projectScoreDeleteParams.additionalHeaders) + additionalQueryParams(projectScoreDeleteParams.additionalQueryParams) additionalBodyProperties(projectScoreDeleteParams.additionalBodyProperties) } /** ProjectScore id */ fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 dfce9e0b..7b9da333 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 @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -31,8 +33,8 @@ constructor( private val projectScoreName: String?, private val scoreType: ScoreType?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -53,6 +55,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -69,26 +73,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectScoreListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.projectScoreName == other.projectScoreName && this.scoreType == other.scoreType && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.projectScoreName == other.projectScoreName && this.scoreType == other.scoreType && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -109,8 +111,8 @@ constructor( private var projectScoreName: String? = null private var scoreType: ScoreType? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(projectScoreListParams: ProjectScoreListParams) = apply { @@ -123,8 +125,8 @@ constructor( this.projectScoreName = projectScoreListParams.projectScoreName this.scoreType = projectScoreListParams.scoreType this.startingAfter = projectScoreListParams.startingAfter - additionalQueryParams(projectScoreListParams.additionalQueryParams) additionalHeaders(projectScoreListParams.additionalHeaders) + additionalQueryParams(projectScoreListParams.additionalQueryParams) } /** @@ -193,45 +195,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ProjectScoreListParams = ProjectScoreListParams( @@ -244,8 +245,14 @@ constructor( projectScoreName, scoreType, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } 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 86277fbd..84b8d9cb 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 @@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -31,8 +33,8 @@ constructor( private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -61,10 +63,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + /** A project score is a user-configured score, which can be manually-labeled through the UI */ @JsonDeserialize(builder = ProjectScoreReplaceBody.Builder::class) @NoAutoDetect @@ -197,10 +199,10 @@ constructor( "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -208,15 +210,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreReplaceParams && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreReplaceParams && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -234,8 +236,8 @@ constructor( private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -246,8 +248,8 @@ constructor( this.categories = projectScoreReplaceParams.categories this.config = projectScoreReplaceParams.config this.description = projectScoreReplaceParams.description - additionalQueryParams(projectScoreReplaceParams.additionalQueryParams) additionalHeaders(projectScoreReplaceParams.additionalHeaders) + additionalQueryParams(projectScoreReplaceParams.additionalQueryParams) additionalBodyProperties(projectScoreReplaceParams.additionalBodyProperties) } @@ -288,45 +290,44 @@ constructor( /** Textual description of the project score */ fun description(description: String) = apply { this.description = description } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -350,8 +351,14 @@ constructor( categories, config, description, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 37919485..7805bfa5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ProjectScoreRetrieveParams constructor( private val projectScoreId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun projectScoreId(): String = projectScoreId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectScoreId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectScoreRetrieveParams && this.projectScoreId == other.projectScoreId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ProjectScoreRetrieveParams && this.projectScoreId == other.projectScoreId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoreId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var projectScoreId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = apply { this.projectScoreId = projectScoreRetrieveParams.projectScoreId - additionalQueryParams(projectScoreRetrieveParams.additionalQueryParams) additionalHeaders(projectScoreRetrieveParams.additionalHeaders) + additionalQueryParams(projectScoreRetrieveParams.additionalQueryParams) } /** ProjectScore id */ fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } 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 6cf1c061..20ddf3f6 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 @@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -31,8 +33,8 @@ constructor( private val description: String?, private val name: String?, private val scoreType: ProjectScoreType?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -60,10 +62,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectScoreId @@ -192,10 +194,10 @@ constructor( "ProjectScoreUpdateBody{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -203,15 +205,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreUpdateParams && this.projectScoreId == other.projectScoreId && this.categories == other.categories && this.config == other.config && this.description == other.description && this.name == other.name && this.scoreType == other.scoreType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreUpdateParams && this.projectScoreId == other.projectScoreId && this.categories == other.categories && this.config == other.config && this.description == other.description && this.name == other.name && this.scoreType == other.scoreType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoreId, categories, config, description, name, scoreType, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectScoreId, categories, config, description, name, scoreType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -229,8 +231,8 @@ constructor( private var description: String? = null private var name: String? = null private var scoreType: ProjectScoreType? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -241,8 +243,8 @@ constructor( this.description = projectScoreUpdateParams.description this.name = projectScoreUpdateParams.name this.scoreType = projectScoreUpdateParams.scoreType - additionalQueryParams(projectScoreUpdateParams.additionalQueryParams) additionalHeaders(projectScoreUpdateParams.additionalHeaders) + additionalQueryParams(projectScoreUpdateParams.additionalQueryParams) additionalBodyProperties(projectScoreUpdateParams.additionalBodyProperties) } @@ -283,45 +285,44 @@ constructor( /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -345,8 +346,14 @@ constructor( description, name, scoreType, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index fc5ebb1f..81166f6d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -20,8 +22,8 @@ constructor( private val projectId: String, private val color: String?, private val description: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -44,10 +46,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = ProjectTagCreateBody.Builder::class) @NoAutoDetect class ProjectTagCreateBody @@ -158,10 +160,10 @@ constructor( "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -169,15 +171,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagCreateParams && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagCreateParams && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, color, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -193,8 +195,8 @@ constructor( private var projectId: String? = null private var color: String? = null private var description: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -203,8 +205,8 @@ constructor( this.projectId = projectTagCreateParams.projectId this.color = projectTagCreateParams.color this.description = projectTagCreateParams.description - additionalQueryParams(projectTagCreateParams.additionalQueryParams) additionalHeaders(projectTagCreateParams.additionalHeaders) + additionalQueryParams(projectTagCreateParams.additionalQueryParams) additionalBodyProperties(projectTagCreateParams.additionalBodyProperties) } @@ -220,45 +222,44 @@ constructor( /** Textual description of the project tag */ fun description(description: String) = apply { this.description = description } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -280,8 +281,14 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, color, description, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 3580cb93..97b409dd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ProjectTagDeleteParams constructor( private val projectTagId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectTagId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagDeleteParams && this.projectTagId == other.projectTagId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagDeleteParams && this.projectTagId == other.projectTagId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectTagId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var projectTagId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectTagDeleteParams: ProjectTagDeleteParams) = apply { this.projectTagId = projectTagDeleteParams.projectTagId - additionalQueryParams(projectTagDeleteParams.additionalQueryParams) additionalHeaders(projectTagDeleteParams.additionalHeaders) + additionalQueryParams(projectTagDeleteParams.additionalQueryParams) additionalBodyProperties(projectTagDeleteParams.additionalBodyProperties) } /** ProjectTag id */ fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 8f83d31c..800cb8cc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +32,8 @@ constructor( private val projectName: String?, private val projectTagName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -50,6 +52,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -65,26 +69,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectTagListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.projectTagName == other.projectTagName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ProjectTagListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.projectTagName == other.projectTagName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -104,8 +106,8 @@ constructor( private var projectName: String? = null private var projectTagName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(projectTagListParams: ProjectTagListParams) = apply { @@ -117,8 +119,8 @@ constructor( this.projectName = projectTagListParams.projectName this.projectTagName = projectTagListParams.projectTagName this.startingAfter = projectTagListParams.startingAfter - additionalQueryParams(projectTagListParams.additionalQueryParams) additionalHeaders(projectTagListParams.additionalHeaders) + additionalQueryParams(projectTagListParams.additionalQueryParams) } /** @@ -172,45 +174,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ProjectTagListParams = ProjectTagListParams( @@ -222,8 +223,14 @@ constructor( projectName, projectTagName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index 1be2b74e..e64d658d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -20,8 +22,8 @@ constructor( private val projectId: String, private val color: String?, private val description: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -44,10 +46,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = ProjectTagReplaceBody.Builder::class) @NoAutoDetect class ProjectTagReplaceBody @@ -158,10 +160,10 @@ constructor( "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -169,15 +171,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagReplaceParams && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagReplaceParams && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, color, description, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -193,8 +195,8 @@ constructor( private var projectId: String? = null private var color: String? = null private var description: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -203,8 +205,8 @@ constructor( this.projectId = projectTagReplaceParams.projectId this.color = projectTagReplaceParams.color this.description = projectTagReplaceParams.description - additionalQueryParams(projectTagReplaceParams.additionalQueryParams) additionalHeaders(projectTagReplaceParams.additionalHeaders) + additionalQueryParams(projectTagReplaceParams.additionalQueryParams) additionalBodyProperties(projectTagReplaceParams.additionalBodyProperties) } @@ -220,45 +222,44 @@ constructor( /** Textual description of the project tag */ fun description(description: String) = apply { this.description = description } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -280,8 +281,14 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, color, description, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 68ffb3fc..915496a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ProjectTagRetrieveParams constructor( private val projectTagId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun projectTagId(): String = projectTagId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectTagId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectTagRetrieveParams && this.projectTagId == other.projectTagId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ProjectTagRetrieveParams && this.projectTagId == other.projectTagId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectTagId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var projectTagId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = apply { this.projectTagId = projectTagRetrieveParams.projectTagId - additionalQueryParams(projectTagRetrieveParams.additionalQueryParams) additionalHeaders(projectTagRetrieveParams.additionalHeaders) + additionalQueryParams(projectTagRetrieveParams.additionalQueryParams) } /** ProjectTag id */ fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 3add1220..9581b037 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -20,8 +22,8 @@ constructor( private val color: String?, private val description: String?, private val name: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -43,10 +45,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectTagId @@ -153,10 +155,10 @@ constructor( "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -164,15 +166,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagUpdateParams && this.projectTagId == other.projectTagId && this.color == other.color && this.description == other.description && this.name == other.name && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagUpdateParams && this.projectTagId == other.projectTagId && this.color == other.color && this.description == other.description && this.name == other.name && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectTagId, color, description, name, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectTagId, color, description, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -188,8 +190,8 @@ constructor( private var color: String? = null private var description: String? = null private var name: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -198,8 +200,8 @@ constructor( this.color = projectTagUpdateParams.color this.description = projectTagUpdateParams.description this.name = projectTagUpdateParams.name - additionalQueryParams(projectTagUpdateParams.additionalQueryParams) additionalHeaders(projectTagUpdateParams.additionalHeaders) + additionalQueryParams(projectTagUpdateParams.additionalQueryParams) additionalBodyProperties(projectTagUpdateParams.additionalBodyProperties) } @@ -215,45 +217,44 @@ constructor( /** Name of the project tag */ fun name(name: String) = apply { this.name = name } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -275,8 +276,14 @@ constructor( color, description, name, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index f550e9de..85b9222f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -19,8 +21,8 @@ constructor( private val projectId: String, private val name: String?, private val settings: ProjectSettings?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -39,10 +41,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> projectId @@ -145,10 +147,10 @@ constructor( "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -156,15 +158,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectUpdateParams && this.projectId == other.projectId && this.name == other.name && this.settings == other.settings && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectUpdateParams && this.projectId == other.projectId && this.name == other.name && this.settings == other.settings && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, name, settings, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, name, settings, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -179,8 +181,8 @@ constructor( private var projectId: String? = null private var name: String? = null private var settings: ProjectSettings? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -188,8 +190,8 @@ constructor( this.projectId = projectUpdateParams.projectId this.name = projectUpdateParams.name this.settings = projectUpdateParams.settings - additionalQueryParams(projectUpdateParams.additionalQueryParams) additionalHeaders(projectUpdateParams.additionalHeaders) + additionalQueryParams(projectUpdateParams.additionalQueryParams) additionalBodyProperties(projectUpdateParams.additionalBodyProperties) } @@ -205,45 +207,44 @@ constructor( */ fun settings(settings: ProjectSettings) = apply { this.settings = settings } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -264,8 +265,14 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, name, settings, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 0ae9e9c5..40bb5029 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +29,8 @@ constructor( private val functionType: FunctionType?, private val promptData: PromptData?, private val tags: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -60,10 +62,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = PromptCreateBody.Builder::class) @NoAutoDetect class PromptCreateBody @@ -206,10 +208,10 @@ constructor( "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -217,15 +219,15 @@ constructor( return true } - return /* spotless:off */ other is PromptCreateParams && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptCreateParams && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -244,8 +246,8 @@ constructor( private var functionType: FunctionType? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -257,8 +259,8 @@ constructor( this.functionType = promptCreateParams.functionType this.promptData = promptCreateParams.promptData this.tags(promptCreateParams.tags ?: listOf()) - additionalQueryParams(promptCreateParams.additionalQueryParams) additionalHeaders(promptCreateParams.additionalHeaders) + additionalQueryParams(promptCreateParams.additionalQueryParams) additionalBodyProperties(promptCreateParams.additionalBodyProperties) } @@ -288,45 +290,44 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -351,8 +352,14 @@ constructor( functionType, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 84239868..bbcef9d1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class PromptDeleteParams constructor( private val promptId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> promptId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is PromptDeleteParams && this.promptId == other.promptId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptDeleteParams && this.promptId == other.promptId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(promptId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "PromptDeleteParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var promptId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptDeleteParams: PromptDeleteParams) = apply { this.promptId = promptDeleteParams.promptId - additionalQueryParams(promptDeleteParams.additionalQueryParams) additionalHeaders(promptDeleteParams.additionalHeaders) + additionalQueryParams(promptDeleteParams.additionalQueryParams) additionalBodyProperties(promptDeleteParams.additionalBodyProperties) } /** Prompt id */ fun promptId(promptId: String) = apply { this.promptId = promptId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): PromptDeleteParams = PromptDeleteParams( checkNotNull(promptId) { "`promptId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index d7d2c273..f39f840c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -32,8 +34,8 @@ constructor( private val slug: String?, private val startingAfter: String?, private val version: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -56,6 +58,8 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -73,26 +77,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PromptListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.promptName == other.promptName && this.slug == other.slug && this.startingAfter == other.startingAfter && this.version == other.version && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is PromptListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.promptName == other.promptName && this.slug == other.slug && this.startingAfter == other.startingAfter && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -114,8 +116,8 @@ constructor( private var slug: String? = null private var startingAfter: String? = null private var version: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(promptListParams: PromptListParams) = apply { @@ -129,8 +131,8 @@ constructor( this.slug = promptListParams.slug this.startingAfter = promptListParams.startingAfter this.version = promptListParams.version - additionalQueryParams(promptListParams.additionalQueryParams) additionalHeaders(promptListParams.additionalHeaders) + additionalQueryParams(promptListParams.additionalQueryParams) } /** @@ -195,45 +197,44 @@ constructor( */ fun version(version: String) = apply { this.version = version } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): PromptListParams = PromptListParams( @@ -247,8 +248,14 @@ constructor( slug, startingAfter, version, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 32cbcf9e..a6830d7d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +29,8 @@ constructor( private val functionType: FunctionType?, private val promptData: PromptData?, private val tags: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -60,10 +62,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = PromptReplaceBody.Builder::class) @NoAutoDetect class PromptReplaceBody @@ -206,10 +208,10 @@ constructor( "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -217,15 +219,15 @@ constructor( return true } - return /* spotless:off */ other is PromptReplaceParams && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptReplaceParams && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -244,8 +246,8 @@ constructor( private var functionType: FunctionType? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -257,8 +259,8 @@ constructor( this.functionType = promptReplaceParams.functionType this.promptData = promptReplaceParams.promptData this.tags(promptReplaceParams.tags ?: listOf()) - additionalQueryParams(promptReplaceParams.additionalQueryParams) additionalHeaders(promptReplaceParams.additionalHeaders) + additionalQueryParams(promptReplaceParams.additionalQueryParams) additionalBodyProperties(promptReplaceParams.additionalBodyProperties) } @@ -288,45 +290,44 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -351,8 +352,14 @@ constructor( functionType, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 4d7b1c25..039b6090 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class PromptRetrieveParams constructor( private val promptId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun promptId(): String = promptId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> promptId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PromptRetrieveParams && this.promptId == other.promptId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is PromptRetrieveParams && this.promptId == other.promptId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(promptId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "PromptRetrieveParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var promptId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(promptRetrieveParams: PromptRetrieveParams) = apply { this.promptId = promptRetrieveParams.promptId - additionalQueryParams(promptRetrieveParams.additionalQueryParams) additionalHeaders(promptRetrieveParams.additionalHeaders) + additionalQueryParams(promptRetrieveParams.additionalQueryParams) } /** Prompt id */ fun promptId(promptId: String) = apply { this.promptId = promptId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): PromptRetrieveParams = PromptRetrieveParams( checkNotNull(promptId) { "`promptId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index f219fa4c..3d7e2682 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -22,8 +24,8 @@ constructor( private val promptData: PromptData?, private val slug: String?, private val tags: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -51,10 +53,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> promptId @@ -182,10 +184,10 @@ constructor( "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -193,15 +195,15 @@ constructor( return true } - return /* spotless:off */ other is PromptUpdateParams && this.promptId == other.promptId && this.description == other.description && this.name == other.name && this.promptData == other.promptData && this.slug == other.slug && this.tags == other.tags && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptUpdateParams && this.promptId == other.promptId && this.description == other.description && this.name == other.name && this.promptData == other.promptData && this.slug == other.slug && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(promptId, description, name, promptData, slug, tags, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(promptId, description, name, promptData, slug, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -219,8 +221,8 @@ constructor( private var promptData: PromptData? = null private var slug: String? = null private var tags: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -231,8 +233,8 @@ constructor( this.promptData = promptUpdateParams.promptData this.slug = promptUpdateParams.slug this.tags(promptUpdateParams.tags ?: listOf()) - additionalQueryParams(promptUpdateParams.additionalQueryParams) additionalHeaders(promptUpdateParams.additionalHeaders) + additionalQueryParams(promptUpdateParams.additionalQueryParams) additionalBodyProperties(promptUpdateParams.additionalBodyProperties) } @@ -260,45 +262,44 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -322,8 +323,14 @@ constructor( promptData, slug, if (tags.size == 0) null else tags.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 ed2bbe33..771591a2 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -25,8 +27,8 @@ constructor( private val memberPermissions: List?, private val memberRoles: List?, private val orgName: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -53,10 +55,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = RoleCreateBody.Builder::class) @NoAutoDetect class RoleCreateBody @@ -200,10 +202,10 @@ constructor( "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -211,15 +213,15 @@ constructor( return true } - return /* spotless:off */ other is RoleCreateParams && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleCreateParams && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -236,8 +238,8 @@ constructor( private var memberPermissions: MutableList = mutableListOf() private var memberRoles: MutableList = mutableListOf() private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -247,8 +249,8 @@ constructor( this.memberPermissions(roleCreateParams.memberPermissions ?: listOf()) this.memberRoles(roleCreateParams.memberRoles ?: listOf()) this.orgName = roleCreateParams.orgName - additionalQueryParams(roleCreateParams.additionalQueryParams) additionalHeaders(roleCreateParams.additionalHeaders) + additionalQueryParams(roleCreateParams.additionalQueryParams) additionalBodyProperties(roleCreateParams.additionalBodyProperties) } @@ -295,45 +297,44 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -356,8 +357,14 @@ constructor( if (memberPermissions.size == 0) null else memberPermissions.toImmutable(), if (memberRoles.size == 0) null else memberRoles.toImmutable(), orgName, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 3d3e82d4..2dad945d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -6,14 +6,16 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class RoleDeleteParams constructor( private val roleId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -24,10 +26,10 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> roleId @@ -35,10 +37,10 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -46,15 +48,15 @@ constructor( return true } - return /* spotless:off */ other is RoleDeleteParams && this.roleId == other.roleId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleDeleteParams && this.roleId == other.roleId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(roleId, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "RoleDeleteParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -67,60 +69,59 @@ constructor( class Builder { private var roleId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(roleDeleteParams: RoleDeleteParams) = apply { this.roleId = roleDeleteParams.roleId - additionalQueryParams(roleDeleteParams.additionalQueryParams) additionalHeaders(roleDeleteParams.additionalHeaders) + additionalQueryParams(roleDeleteParams.additionalQueryParams) additionalBodyProperties(roleDeleteParams.additionalBodyProperties) } /** Role id */ fun roleId(roleId: String) = apply { this.roleId = roleId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -139,8 +140,14 @@ constructor( fun build(): RoleDeleteParams = RoleDeleteParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 0d0b9824..24ebe125 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +30,8 @@ constructor( private val orgName: String?, private val roleName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -44,6 +46,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -57,26 +61,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RoleListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.roleName == other.roleName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is RoleListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.roleName == other.roleName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -94,8 +96,8 @@ constructor( private var orgName: String? = null private var roleName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(roleListParams: RoleListParams) = apply { @@ -105,8 +107,8 @@ constructor( this.orgName = roleListParams.orgName this.roleName = roleListParams.roleName this.startingAfter = roleListParams.startingAfter - additionalQueryParams(roleListParams.additionalQueryParams) additionalHeaders(roleListParams.additionalHeaders) + additionalQueryParams(roleListParams.additionalQueryParams) } /** @@ -154,45 +156,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): RoleListParams = RoleListParams( @@ -202,8 +203,14 @@ constructor( orgName, roleName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } 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 a46e8966..8a93e099 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -25,8 +27,8 @@ constructor( private val memberPermissions: List?, private val memberRoles: List?, private val orgName: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -53,10 +55,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = RoleReplaceBody.Builder::class) @NoAutoDetect class RoleReplaceBody @@ -200,10 +202,10 @@ constructor( "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -211,15 +213,15 @@ constructor( return true } - return /* spotless:off */ other is RoleReplaceParams && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleReplaceParams && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -236,8 +238,8 @@ constructor( private var memberPermissions: MutableList = mutableListOf() private var memberRoles: MutableList = mutableListOf() private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -247,8 +249,8 @@ constructor( this.memberPermissions(roleReplaceParams.memberPermissions ?: listOf()) this.memberRoles(roleReplaceParams.memberRoles ?: listOf()) this.orgName = roleReplaceParams.orgName - additionalQueryParams(roleReplaceParams.additionalQueryParams) additionalHeaders(roleReplaceParams.additionalHeaders) + additionalQueryParams(roleReplaceParams.additionalQueryParams) additionalBodyProperties(roleReplaceParams.additionalBodyProperties) } @@ -295,45 +297,44 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -356,8 +357,14 @@ constructor( if (memberPermissions.size == 0) null else memberPermissions.toImmutable(), if (memberRoles.size == 0) null else memberRoles.toImmutable(), orgName, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 31122bef..eb8ace7d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class RoleRetrieveParams constructor( private val roleId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun roleId(): String = roleId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> roleId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RoleRetrieveParams && this.roleId == other.roleId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is RoleRetrieveParams && this.roleId == other.roleId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(roleId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "RoleRetrieveParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var roleId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(roleRetrieveParams: RoleRetrieveParams) = apply { this.roleId = roleRetrieveParams.roleId - additionalQueryParams(roleRetrieveParams.additionalQueryParams) additionalHeaders(roleRetrieveParams.additionalHeaders) + additionalQueryParams(roleRetrieveParams.additionalQueryParams) } /** Role id */ fun roleId(roleId: String) = apply { this.roleId = roleId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): RoleRetrieveParams = RoleRetrieveParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } 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 6fa82247..b65623d3 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +29,8 @@ constructor( private val name: String?, private val removeMemberPermissions: List?, private val removeMemberRoles: List?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -61,10 +63,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> roleId @@ -217,10 +219,10 @@ constructor( "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -228,15 +230,15 @@ constructor( return true } - return /* spotless:off */ other is RoleUpdateParams && this.roleId == other.roleId && this.addMemberPermissions == other.addMemberPermissions && this.addMemberRoles == other.addMemberRoles && this.description == other.description && this.name == other.name && this.removeMemberPermissions == other.removeMemberPermissions && this.removeMemberRoles == other.removeMemberRoles && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleUpdateParams && this.roleId == other.roleId && this.addMemberPermissions == other.addMemberPermissions && this.addMemberRoles == other.addMemberRoles && this.description == other.description && this.name == other.name && this.removeMemberPermissions == other.removeMemberPermissions && this.removeMemberRoles == other.removeMemberRoles && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(roleId, addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(roleId, addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -255,8 +257,8 @@ constructor( private var name: String? = null private var removeMemberPermissions: MutableList = mutableListOf() private var removeMemberRoles: MutableList = mutableListOf() - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -268,8 +270,8 @@ constructor( this.name = roleUpdateParams.name this.removeMemberPermissions(roleUpdateParams.removeMemberPermissions ?: listOf()) this.removeMemberRoles(roleUpdateParams.removeMemberRoles ?: listOf()) - additionalQueryParams(roleUpdateParams.additionalQueryParams) additionalHeaders(roleUpdateParams.additionalHeaders) + additionalQueryParams(roleUpdateParams.additionalQueryParams) additionalBodyProperties(roleUpdateParams.additionalBodyProperties) } @@ -326,45 +328,44 @@ constructor( this.removeMemberRoles.add(removeMemberRole) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -390,8 +391,14 @@ constructor( if (removeMemberPermissions.size == 0) null else removeMemberPermissions.toImmutable(), if (removeMemberRoles.size == 0) null else removeMemberRoles.toImmutable(), - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 66a34ed3..851063ca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -5,36 +5,38 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class TopLevelHelloWorldParams constructor( - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is TopLevelHelloWorldParams && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is TopLevelHelloWorldParams && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "TopLevelHelloWorldParams{additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -46,59 +48,64 @@ constructor( @NoAutoDetect class Builder { - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = apply { - additionalQueryParams(topLevelHelloWorldParams.additionalQueryParams) additionalHeaders(topLevelHelloWorldParams.additionalHeaders) + additionalQueryParams(topLevelHelloWorldParams.additionalQueryParams) } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): TopLevelHelloWorldParams = TopLevelHelloWorldParams( - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable() + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable() ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 7f5a0e82..4a30dab5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +32,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun email(): Optional = Optional.ofNullable(email) @@ -50,6 +52,8 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -65,26 +69,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UserListParams && this.email == other.email && this.endingBefore == other.endingBefore && this.familyName == other.familyName && this.givenName == other.givenName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is UserListParams && this.email == other.email && this.endingBefore == other.endingBefore && this.familyName == other.familyName && this.givenName == other.givenName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -104,8 +106,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(userListParams: UserListParams) = apply { @@ -117,8 +119,8 @@ constructor( this.limit = userListParams.limit this.orgName = userListParams.orgName this.startingAfter = userListParams.startingAfter - additionalQueryParams(userListParams.additionalQueryParams) additionalHeaders(userListParams.additionalHeaders) + additionalQueryParams(userListParams.additionalQueryParams) } /** @@ -221,45 +223,44 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): UserListParams = UserListParams( @@ -271,8 +272,14 @@ constructor( limit, orgName, startingAfter, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 65d235d6..076af28d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -5,21 +5,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class UserRetrieveParams constructor( private val userId: String, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun userId(): String = userId - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> userId @@ -27,24 +29,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UserRetrieveParams && this.userId == other.userId && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is UserRetrieveParams && this.userId == other.userId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(userId, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "UserRetrieveParams{userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -57,64 +59,69 @@ constructor( class Builder { private var userId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(userRetrieveParams: UserRetrieveParams) = apply { this.userId = userRetrieveParams.userId - additionalQueryParams(userRetrieveParams.additionalQueryParams) additionalHeaders(userRetrieveParams.additionalHeaders) + additionalQueryParams(userRetrieveParams.additionalQueryParams) } /** User id */ fun userId(userId: String) = apply { this.userId = userId } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): UserRetrieveParams = UserRetrieveParams( checkNotNull(userId) { "`userId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } } 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 19f48c82..b95f47f4 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -29,8 +31,8 @@ constructor( private val options: ViewOptions?, private val userId: String?, private val viewData: ViewData?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -65,10 +67,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = ViewCreateBody.Builder::class) @NoAutoDetect class ViewCreateBody @@ -223,10 +225,10 @@ constructor( "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -234,15 +236,15 @@ constructor( return true } - return /* spotless:off */ other is ViewCreateParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewCreateParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -262,8 +264,8 @@ constructor( private var options: ViewOptions? = null private var userId: String? = null private var viewData: ViewData? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -276,8 +278,8 @@ constructor( this.options = viewCreateParams.options this.userId = viewCreateParams.userId this.viewData = viewCreateParams.viewData - additionalQueryParams(viewCreateParams.additionalQueryParams) additionalHeaders(viewCreateParams.additionalHeaders) + additionalQueryParams(viewCreateParams.additionalQueryParams) additionalBodyProperties(viewCreateParams.additionalBodyProperties) } @@ -305,45 +307,44 @@ constructor( /** The view definition */ fun viewData(viewData: ViewData) = apply { this.viewData = viewData } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -369,8 +370,14 @@ constructor( options, userId, viewData, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 47a98109..2818ee84 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ViewDeleteParams @@ -22,8 +24,8 @@ constructor( private val viewId: String, private val objectId: String, private val objectType: ObjectType, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -42,10 +44,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> viewId @@ -143,10 +145,10 @@ constructor( "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -154,15 +156,15 @@ constructor( return true } - return /* spotless:off */ other is ViewDeleteParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewDeleteParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -177,8 +179,8 @@ constructor( private var viewId: String? = null private var objectId: String? = null private var objectType: ObjectType? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -186,8 +188,8 @@ constructor( this.viewId = viewDeleteParams.viewId this.objectId = viewDeleteParams.objectId this.objectType = viewDeleteParams.objectType - additionalQueryParams(viewDeleteParams.additionalQueryParams) additionalHeaders(viewDeleteParams.additionalHeaders) + additionalQueryParams(viewDeleteParams.additionalQueryParams) additionalBodyProperties(viewDeleteParams.additionalBodyProperties) } @@ -200,45 +202,44 @@ constructor( /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -259,8 +260,14 @@ constructor( checkNotNull(viewId) { "`viewId` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 92ef1a8b..c89abca0 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 @@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -33,8 +35,8 @@ constructor( private val startingAfter: String?, private val viewName: String?, private val viewType: ViewType?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun objectId(): String = objectId @@ -53,6 +55,8 @@ constructor( fun viewType(): Optional = Optional.ofNullable(viewType) + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -68,26 +72,24 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Map> = additionalHeaders fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ViewListParams && this.objectId == other.objectId && this.objectType == other.objectType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.startingAfter == other.startingAfter && this.viewName == other.viewName && this.viewType == other.viewType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ViewListParams && this.objectId == other.objectId && this.objectType == other.objectType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.startingAfter == other.startingAfter && this.viewName == other.viewName && this.viewType == other.viewType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -107,8 +109,8 @@ constructor( private var startingAfter: String? = null private var viewName: String? = null private var viewType: ViewType? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(viewListParams: ViewListParams) = apply { @@ -120,8 +122,8 @@ constructor( this.startingAfter = viewListParams.startingAfter this.viewName = viewListParams.viewName this.viewType = viewListParams.viewType - additionalQueryParams(viewListParams.additionalQueryParams) additionalHeaders(viewListParams.additionalHeaders) + additionalQueryParams(viewListParams.additionalQueryParams) } /** The id of the object the ACL applies to */ @@ -175,45 +177,44 @@ constructor( /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType) = apply { this.viewType = viewType } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ViewListParams = ViewListParams( @@ -225,8 +226,14 @@ constructor( startingAfter, viewName, viewType, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } 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 020d436f..7a52e0b3 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -29,8 +31,8 @@ constructor( private val options: ViewOptions?, private val userId: String?, private val viewData: ViewData?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -65,10 +67,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JsonDeserialize(builder = ViewReplaceBody.Builder::class) @NoAutoDetect class ViewReplaceBody @@ -223,10 +225,10 @@ constructor( "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -234,15 +236,15 @@ constructor( return true } - return /* spotless:off */ other is ViewReplaceParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewReplaceParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -262,8 +264,8 @@ constructor( private var options: ViewOptions? = null private var userId: String? = null private var viewData: ViewData? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -276,8 +278,8 @@ constructor( this.options = viewReplaceParams.options this.userId = viewReplaceParams.userId this.viewData = viewReplaceParams.viewData - additionalQueryParams(viewReplaceParams.additionalQueryParams) additionalHeaders(viewReplaceParams.additionalHeaders) + additionalQueryParams(viewReplaceParams.additionalQueryParams) additionalBodyProperties(viewReplaceParams.additionalBodyProperties) } @@ -305,45 +307,44 @@ constructor( /** The view definition */ fun viewData(viewData: ViewData) = apply { this.viewData = viewData } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -369,8 +370,14 @@ constructor( options, userId, viewData, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } 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 022cb326..52f6595f 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 @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects class ViewRetrieveParams @@ -17,8 +19,8 @@ constructor( private val viewId: String, private val objectId: String, private val objectType: ObjectType, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, ) { fun viewId(): String = viewId @@ -27,6 +29,8 @@ constructor( fun objectType(): ObjectType = objectType + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> { val params = mutableMapOf>() @@ -36,8 +40,6 @@ constructor( return params.toImmutable() } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders - fun getPathParam(index: Int): String { return when (index) { 0 -> viewId @@ -45,24 +47,24 @@ constructor( } } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ViewRetrieveParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders /* spotless:on */ + return /* spotless:off */ other is ViewRetrieveParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalQueryParams, additionalHeaders) /* spotless:on */ + return /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ } override fun toString() = - "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" fun toBuilder() = Builder().from(this) @@ -77,16 +79,16 @@ constructor( private var viewId: String? = null private var objectId: String? = null private var objectType: ObjectType? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() @JvmSynthetic internal fun from(viewRetrieveParams: ViewRetrieveParams) = apply { this.viewId = viewRetrieveParams.viewId this.objectId = viewRetrieveParams.objectId this.objectType = viewRetrieveParams.objectType - additionalQueryParams(viewRetrieveParams.additionalQueryParams) additionalHeaders(viewRetrieveParams.additionalHeaders) + additionalQueryParams(viewRetrieveParams.additionalQueryParams) } /** View id */ @@ -98,53 +100,58 @@ constructor( /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun build(): ViewRetrieveParams = ViewRetrieveParams( checkNotNull(viewId) { "`viewId` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), ) } 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 c0874f72..033caefe 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 @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +30,8 @@ constructor( private val userId: String?, private val viewData: ViewData?, private val viewType: ViewType?, - private val additionalQueryParams: Map>, private val additionalHeaders: Map>, + private val additionalQueryParams: Map>, private val additionalBodyProperties: Map, ) { @@ -63,10 +65,10 @@ constructor( ) } - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + fun getPathParam(index: Int): String { return when (index) { 0 -> viewId @@ -217,10 +219,10 @@ constructor( "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" } - fun _additionalQueryParams(): Map> = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { @@ -228,15 +230,15 @@ constructor( return true } - return /* spotless:off */ other is ViewUpdateParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.name == other.name && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.viewType == other.viewType && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewUpdateParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.name == other.name && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.viewType == other.viewType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(viewId, objectId, objectType, name, options, userId, viewData, viewType, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(viewId, objectId, objectType, name, options, userId, viewData, viewType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -256,8 +258,8 @@ constructor( private var userId: String? = null private var viewData: ViewData? = null private var viewType: ViewType? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalHeaders: ListMultimap = ArrayListMultimap.create() + private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -270,8 +272,8 @@ constructor( this.userId = viewUpdateParams.userId this.viewData = viewUpdateParams.viewData this.viewType = viewUpdateParams.viewType - additionalQueryParams(viewUpdateParams.additionalQueryParams) additionalHeaders(viewUpdateParams.additionalHeaders) + additionalQueryParams(viewUpdateParams.additionalQueryParams) additionalBodyProperties(viewUpdateParams.additionalBodyProperties) } @@ -299,45 +301,44 @@ constructor( /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType) = apply { this.viewType = viewType } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.putAll(name, values) } - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } + fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) } - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.putAll(key, values) } - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::putAdditionalQueryParams) + } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -363,8 +364,14 @@ constructor( userId, viewData, viewType, - additionalQueryParams.mapValues { it.value.toImmutable() }.toImmutable(), - additionalHeaders.mapValues { it.value.toImmutable() }.toImmutable(), + additionalHeaders + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), + additionalQueryParams + .asMap() + .mapValues { it.value.toList().toImmutable() } + .toImmutable(), additionalBodyProperties.toImmutable(), ) } From c9d6eae2658ce543a3ccba996373b923e4371cd7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 04:04:04 +0000 Subject: [PATCH 18/87] chore: rebuild project due to codegen change (#83) --- .../client/okhttp/BraintrustOkHttpClient.kt | 34 +++++++++++++++- .../okhttp/BraintrustOkHttpClientAsync.kt | 34 +++++++++++++++- .../braintrustdata/api/core/ClientOptions.kt | 32 ++++++++++++++- .../api/models/AclBatchUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/AclCreateParams.kt | 39 ++++++++++++++++++- .../api/models/AclDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/AclFindAndDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/AclListParams.kt | 39 ++++++++++++++++++- .../api/models/AclRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/AiSecretCreateParams.kt | 39 ++++++++++++++++++- .../api/models/AiSecretDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/AiSecretFindAndDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/AiSecretListParams.kt | 39 ++++++++++++++++++- .../api/models/AiSecretReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/AiSecretRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/AiSecretUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/ApiKeyCreateParams.kt | 39 ++++++++++++++++++- .../api/models/ApiKeyDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/ApiKeyListParams.kt | 39 ++++++++++++++++++- .../api/models/ApiKeyRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetCreateParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetFeedbackParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetFetchParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetFetchPostParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetInsertParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetListParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetSummarizeParams.kt | 39 ++++++++++++++++++- .../api/models/DatasetUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/EnvVarCreateParams.kt | 39 ++++++++++++++++++- .../api/models/EnvVarDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/EnvVarListParams.kt | 39 ++++++++++++++++++- .../api/models/EnvVarReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/EnvVarRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/EnvVarUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/EvalCreateParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentCreateParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentFeedbackParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentFetchParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentFetchPostParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentInsertParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentListParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentSummarizeParams.kt | 39 ++++++++++++++++++- .../api/models/ExperimentUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/FunctionCreateParams.kt | 39 ++++++++++++++++++- .../api/models/FunctionDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/FunctionInvokeParams.kt | 39 ++++++++++++++++++- .../api/models/FunctionListParams.kt | 39 ++++++++++++++++++- .../api/models/FunctionReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/FunctionRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/FunctionUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/GroupCreateParams.kt | 39 ++++++++++++++++++- .../api/models/GroupDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/GroupListParams.kt | 39 ++++++++++++++++++- .../api/models/GroupReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/GroupRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/GroupUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/OrganizationDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/OrganizationListParams.kt | 39 ++++++++++++++++++- .../models/OrganizationMemberUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/OrganizationRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/OrganizationUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectCreateParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectListParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectLogFeedbackParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectLogFetchParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectLogFetchPostParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectLogInsertParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectScoreCreateParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectScoreDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectScoreListParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectScoreReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectScoreRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectScoreUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectTagCreateParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectTagDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectTagListParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectTagReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectTagRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectTagUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/ProjectUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/PromptCreateParams.kt | 39 ++++++++++++++++++- .../api/models/PromptDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/PromptListParams.kt | 39 ++++++++++++++++++- .../api/models/PromptReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/PromptRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/PromptUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/RoleCreateParams.kt | 39 ++++++++++++++++++- .../api/models/RoleDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/RoleListParams.kt | 39 ++++++++++++++++++- .../api/models/RoleReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/RoleRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/RoleUpdateParams.kt | 39 ++++++++++++++++++- .../api/models/TopLevelHelloWorldParams.kt | 39 ++++++++++++++++++- .../api/models/UserListParams.kt | 39 ++++++++++++++++++- .../api/models/UserRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/ViewCreateParams.kt | 39 ++++++++++++++++++- .../api/models/ViewDeleteParams.kt | 39 ++++++++++++++++++- .../api/models/ViewListParams.kt | 39 ++++++++++++++++++- .../api/models/ViewReplaceParams.kt | 39 ++++++++++++++++++- .../api/models/ViewRetrieveParams.kt | 39 ++++++++++++++++++- .../api/models/ViewUpdateParams.kt | 39 ++++++++++++++++++- 107 files changed, 3942 insertions(+), 214 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index baa76a5f..70d40171 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -50,7 +50,21 @@ class BraintrustOkHttpClient private constructor() { clientOptions.putAllHeaders(headers) } - fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) } + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } fun queryParams(queryParams: Map>) = apply { clientOptions.queryParams(queryParams) @@ -68,7 +82,23 @@ class BraintrustOkHttpClient private constructor() { clientOptions.putAllQueryParams(queryParams) } - fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) } + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } fun timeout(timeout: Duration) = apply { this.timeout = timeout } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index 4aa21373..ccdffb50 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -50,7 +50,21 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.putAllHeaders(headers) } - fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) } + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } fun queryParams(queryParams: Map>) = apply { clientOptions.queryParams(queryParams) @@ -68,7 +82,23 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.putAllQueryParams(queryParams) } - fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) } + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } fun timeout(timeout: Duration) = apply { this.timeout = timeout } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 993bdf93..5d1433ab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -83,7 +83,21 @@ private constructor( headers.forEach(::putHeaders) } - fun removeHeader(name: String) = apply { headers.removeAll(name) } + fun replaceHeaders(name: String, value: String) = apply { + headers.replaceValues(name, listOf(value)) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replaceValues(name, values) + } + + fun replaceAllHeaders(headers: Map>) = apply { + headers.forEach(::replaceHeaders) + } + + fun removeHeaders(name: String) = apply { headers.removeAll(name) } + + fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -100,7 +114,21 @@ private constructor( queryParams.forEach(::putQueryParams) } - fun removeQueryParam(key: String) = apply { queryParams.removeAll(key) } + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replaceValues(key, listOf(value)) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replaceValues(key, values) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + queryParams.forEach(::replaceQueryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) } + + fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) } fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation 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 7f22bf65..a7f5bcf5 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 @@ -291,7 +291,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -311,7 +327,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 ecebec68..0f5be566 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 @@ -356,7 +356,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -376,7 +392,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 083ccabe..ad87f817 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 9a5648c5..b263e327 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 @@ -356,7 +356,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -376,7 +392,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 ac870990..cc829a79 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 @@ -176,7 +176,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -196,7 +212,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): AclListParams = AclListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index d184e4cb..c4c21dd0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): AclRetrieveParams = AclRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 11816b69..092f01bf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -273,7 +273,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -293,7 +309,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index 64b9fe6d..c682f62a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 0c7d03e6..97f35a06 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -212,7 +212,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -232,7 +248,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index e41c45bf..0e29489a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -189,7 +189,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -209,7 +225,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): AiSecretListParams = AiSecretListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index a39c9b1f..12a1e676 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -273,7 +273,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -293,7 +309,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index 73359665..16c6b131 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 00246b15..7f588897 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -244,7 +244,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -264,7 +280,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index cc908e0f..34a8d02f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -212,7 +212,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -232,7 +248,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index 8d977987..aa48c683 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 5eecc3ee..6b21ab00 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -173,7 +173,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -193,7 +209,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ApiKeyListParams = ApiKeyListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 1d959ee1..e81ef421 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index ca40f09c..f0554c63 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -220,7 +220,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -240,7 +256,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 61cf905b..ce3dc162 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 6eee3ec7..30b15d57 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -199,7 +199,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -219,7 +235,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 4b341065..67475f5a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -172,7 +172,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -192,7 +208,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): DatasetFetchParams = DatasetFetchParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index cd9f503c..f4b7d08d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -469,7 +469,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -489,7 +505,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index c307270e..e24f119c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -208,7 +208,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -228,7 +244,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 9e5d4917..a8ef3d43 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -191,7 +191,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -211,7 +227,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): DatasetListParams = DatasetListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index c655ee2a..a7b08373 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): DatasetRetrieveParams = DatasetRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index f06c713d..89e1114e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -106,7 +106,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +142,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): DatasetSummarizeParams = DatasetSummarizeParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index a244c576..9ab22108 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -235,7 +235,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -255,7 +271,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index ee6f89b7..473d3a1c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -243,7 +243,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -263,7 +279,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index 8c1a7ec5..eafa2681 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 4662d882..01d0fe60 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 @@ -155,7 +155,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -175,7 +191,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): EnvVarListParams = EnvVarListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index 9a6059c0..609b5963 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -243,7 +243,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -263,7 +279,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index bf058cb9..9cb4e604 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 0d7ac841..1ab10d09 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -214,7 +214,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -234,7 +250,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index f96e32eb..bdb50926 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -383,7 +383,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -403,7 +419,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 007eae32..16b49e5f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -398,7 +398,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -418,7 +434,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 0fd48b98..a40a00dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index aa261cf2..b8a5606f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -201,7 +201,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -221,7 +237,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index ed8745d4..aa956336 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -172,7 +172,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -192,7 +208,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ExperimentFetchParams = ExperimentFetchParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 78a75332..d5709258 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -469,7 +469,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -489,7 +505,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 91b39073..63e386ae 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -208,7 +208,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -228,7 +244,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index c205dff8..e8e66eb7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -191,7 +191,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -211,7 +227,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ExperimentListParams = ExperimentListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index f5035fc8..db28d8eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index ce1527b1..64cc5196 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -127,7 +127,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -147,7 +163,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index e503141a..ac471ac3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -361,7 +361,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -381,7 +397,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 796eb04f..a3d2997d 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 @@ -388,7 +388,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -408,7 +424,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index 2e8f8fb9..b53501f6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index b0318807..71f145d8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -329,7 +329,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -349,7 +365,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 8b0ab35d..03c0839b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -214,7 +214,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -234,7 +250,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): FunctionListParams = FunctionListParams( 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 0b60036e..8582f78a 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 @@ -388,7 +388,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -408,7 +424,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index b85103f3..89285fff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): FunctionRetrieveParams = FunctionRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 5cb65c15..a2030306 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -309,7 +309,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -329,7 +345,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 306ff7dd..2e3ff423 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -306,7 +306,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -326,7 +342,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 4ae78997..3d63e146 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 7b809ded..7cc1ad3d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -173,7 +173,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -193,7 +209,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): GroupListParams = GroupListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 0d5c481e..8c50b24d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -306,7 +306,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -326,7 +342,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index bc6f746d..9e59ae3a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): GroupRetrieveParams = GroupRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 9956810a..58f9ed59 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -337,7 +337,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -357,7 +373,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index 88338059..f65fce38 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index f6875732..d9063c1e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -164,7 +164,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -184,7 +200,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): OrganizationListParams = OrganizationListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 373033ae..072c6d37 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -266,7 +266,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -286,7 +302,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index a9013b45..82a8bd73 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 1a8616f8..fc6a35dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -264,7 +264,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -284,7 +300,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index b9be1699..59025386 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -212,7 +212,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -232,7 +248,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 1171dcd2..423c82d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 07a4735c..85e2029e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -173,7 +173,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -193,7 +209,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ProjectListParams = ProjectListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 07356296..b0a5f671 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -201,7 +201,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -221,7 +237,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 902e783f..672f8c76 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -172,7 +172,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -192,7 +208,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ProjectLogFetchParams = ProjectLogFetchParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 5676e1f2..7ae62080 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -469,7 +469,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -489,7 +505,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index e511fdb9..efc37d16 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -208,7 +208,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -228,7 +244,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 29802bc9..bc39a96a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ProjectRetrieveParams = ProjectRetrieveParams( 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 6a4bbf75..cdf5c6ad 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 @@ -307,7 +307,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -327,7 +343,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 7689da11..20e82350 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 7b9da333..419b144f 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 @@ -212,7 +212,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -232,7 +248,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ProjectScoreListParams = ProjectScoreListParams( 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 84b8d9cb..3c2518ed 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 @@ -307,7 +307,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -327,7 +343,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 7805bfa5..6f4e12e9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( 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 20ddf3f6..0b4132e5 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 @@ -302,7 +302,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -322,7 +338,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 81166f6d..6d572736 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -239,7 +239,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -259,7 +275,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 97b409dd..33c4ee34 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 800cb8cc..4b5bb3b1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -191,7 +191,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -211,7 +227,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ProjectTagListParams = ProjectTagListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index e64d658d..999d0053 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -239,7 +239,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -259,7 +275,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 915496a0..2230b362 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 9581b037..ae81927d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -234,7 +234,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -254,7 +270,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index 85b9222f..ad726f9c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -224,7 +224,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -244,7 +260,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 40bb5029..aee368d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -307,7 +307,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -327,7 +343,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index bbcef9d1..5ab56d93 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index f39f840c..cb46ad9e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -214,7 +214,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -234,7 +250,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): PromptListParams = PromptListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index a6830d7d..4411e224 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -307,7 +307,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -327,7 +343,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 039b6090..a58b30f3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): PromptRetrieveParams = PromptRetrieveParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index 3d7e2682..b9608ed6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -279,7 +279,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -299,7 +315,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 771591a2..c5f3ad80 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 @@ -314,7 +314,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -334,7 +350,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 2dad945d..92f3fde6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -101,7 +101,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -121,7 +137,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 24ebe125..e9567b53 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -173,7 +173,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -193,7 +209,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): RoleListParams = RoleListParams( 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 8a93e099..438eda1b 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 @@ -314,7 +314,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -334,7 +350,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index eb8ace7d..b419c81e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): RoleRetrieveParams = RoleRetrieveParams( 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 b65623d3..99271e9e 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 @@ -345,7 +345,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -365,7 +381,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 851063ca..deb37c20 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -74,7 +74,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -94,7 +110,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): TopLevelHelloWorldParams = TopLevelHelloWorldParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 4a30dab5..949c1ba2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -240,7 +240,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -260,7 +276,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): UserListParams = UserListParams( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 076af28d..0ef3a94e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -89,7 +89,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -109,7 +125,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): UserRetrieveParams = UserRetrieveParams( 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 b95f47f4..b3c69ae5 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 @@ -324,7 +324,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -344,7 +360,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 2818ee84..6de0c612 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 @@ -219,7 +219,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -239,7 +255,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 c89abca0..0a61d97d 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 @@ -194,7 +194,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -214,7 +230,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ViewListParams = ViewListParams( 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 7a52e0b3..948ec85e 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 @@ -324,7 +324,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -344,7 +360,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() 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 52f6595f..a3efb22d 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 @@ -117,7 +117,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -137,7 +153,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun build(): ViewRetrieveParams = ViewRetrieveParams( 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 033caefe..6dae3f4f 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 @@ -318,7 +318,23 @@ constructor( additionalHeaders.forEach(::putAdditionalHeaders) } - fun removeAdditionalHeader(name: String) = apply { additionalHeaders.removeAll(name) } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replaceValues(name, listOf(value)) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replaceValues(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(::replaceAdditionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + names.forEach(::removeAdditionalHeaders) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -338,7 +354,26 @@ constructor( additionalQueryParams.forEach(::putAdditionalQueryParams) } - fun removeAdditionalQueryParam(key: String) = apply { additionalQueryParams.removeAll(key) } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replaceValues(key, listOf(value)) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replaceValues(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + additionalQueryParams.forEach(::replaceAdditionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { + additionalQueryParams.removeAll(key) + } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + keys.forEach(::removeAdditionalQueryParams) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() From 8f2a24b0683f51df845f3a433d66994288149e6a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:07:36 +0000 Subject: [PATCH 19/87] chore: rebuild project due to codegen change (#84) --- .../api/core/http/HttpRequest.kt | 81 ++++++++++++------- .../api/services/async/AclServiceAsyncImpl.kt | 48 +++++------ .../async/AiSecretServiceAsyncImpl.kt | 56 ++++++------- .../services/async/ApiKeyServiceAsyncImpl.kt | 32 ++++---- .../services/async/DatasetServiceAsyncImpl.kt | 80 +++++++++--------- .../services/async/EnvVarServiceAsyncImpl.kt | 48 +++++------ .../services/async/EvalServiceAsyncImpl.kt | 8 +- .../async/ExperimentServiceAsyncImpl.kt | 80 +++++++++--------- .../async/FunctionServiceAsyncImpl.kt | 56 ++++++------- .../services/async/GroupServiceAsyncImpl.kt | 48 +++++------ .../async/OrganizationServiceAsyncImpl.kt | 32 ++++---- .../async/ProjectScoreServiceAsyncImpl.kt | 48 +++++------ .../services/async/ProjectServiceAsyncImpl.kt | 40 ++++----- .../async/ProjectTagServiceAsyncImpl.kt | 48 +++++------ .../services/async/PromptServiceAsyncImpl.kt | 48 +++++------ .../services/async/RoleServiceAsyncImpl.kt | 48 +++++------ .../async/TopLevelServiceAsyncImpl.kt | 8 +- .../services/async/UserServiceAsyncImpl.kt | 16 ++-- .../services/async/ViewServiceAsyncImpl.kt | 48 +++++------ .../organizations/MemberServiceAsyncImpl.kt | 8 +- .../async/projects/LogServiceAsyncImpl.kt | 32 ++++---- .../api/services/blocking/AclServiceImpl.kt | 48 +++++------ .../services/blocking/AiSecretServiceImpl.kt | 56 ++++++------- .../services/blocking/ApiKeyServiceImpl.kt | 32 ++++---- .../services/blocking/DatasetServiceImpl.kt | 80 +++++++++--------- .../services/blocking/EnvVarServiceImpl.kt | 48 +++++------ .../api/services/blocking/EvalServiceImpl.kt | 8 +- .../blocking/ExperimentServiceImpl.kt | 80 +++++++++--------- .../services/blocking/FunctionServiceImpl.kt | 56 ++++++------- .../api/services/blocking/GroupServiceImpl.kt | 48 +++++------ .../blocking/OrganizationServiceImpl.kt | 32 ++++---- .../blocking/ProjectScoreServiceImpl.kt | 48 +++++------ .../services/blocking/ProjectServiceImpl.kt | 40 ++++----- .../blocking/ProjectTagServiceImpl.kt | 48 +++++------ .../services/blocking/PromptServiceImpl.kt | 48 +++++------ .../api/services/blocking/RoleServiceImpl.kt | 48 +++++------ .../services/blocking/TopLevelServiceImpl.kt | 8 +- .../api/services/blocking/UserServiceImpl.kt | 16 ++-- .../api/services/blocking/ViewServiceImpl.kt | 48 +++++------ .../organizations/MemberServiceImpl.kt | 8 +- .../blocking/projects/LogServiceImpl.kt | 32 ++++---- 41 files changed, 886 insertions(+), 859 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index 340f33d7..2420ddf2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -3,7 +3,6 @@ package com.braintrustdata.api.core.http import com.braintrustdata.api.core.toImmutable import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ListMultimap -import com.google.common.collect.Multimap import com.google.common.collect.MultimapBuilder class HttpRequest @@ -11,13 +10,13 @@ private constructor( @get:JvmName("method") val method: HttpMethod, @get:JvmName("url") val url: String?, @get:JvmName("pathSegments") val pathSegments: List, - @get:JvmName("queryParams") val queryParams: ListMultimap, @get:JvmName("headers") val headers: ListMultimap, + @get:JvmName("queryParams") val queryParams: ListMultimap, @get:JvmName("body") val body: HttpRequestBody?, ) { override fun toString(): String = - "HttpRequest{method=$method, pathSegments=$pathSegments, queryParams=$queryParams, headers=$headers, body=$body}" + "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" companion object { @JvmStatic fun builder() = Builder() @@ -27,56 +26,84 @@ private constructor( private var method: HttpMethod? = null private var url: String? = null - private var pathSegments: MutableList = ArrayList() - private var queryParams: ListMultimap = ArrayListMultimap.create() - private var body: HttpRequestBody? = null + private var pathSegments: MutableList = mutableListOf() private var headers: ListMultimap = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).arrayListValues().build() + private var queryParams: ListMultimap = ArrayListMultimap.create() + private var body: HttpRequestBody? = null fun method(method: HttpMethod) = apply { this.method = method } fun url(url: String) = apply { this.url = url } - fun addPathSegment(pathSegment: String) = apply { this.pathSegments.add(pathSegment) } + fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } fun addPathSegments(vararg pathSegments: String) = apply { - for (pathSegment in pathSegments) { - this.pathSegments.add(pathSegment) - } + this.pathSegments.addAll(pathSegments) } - fun putQueryParam(name: String, value: String) = apply { - this.queryParams.replaceValues(name, listOf(value)) + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) } - fun putQueryParams(name: String, values: Iterable) = apply { - this.queryParams.replaceValues(name, values) + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + headers.putAll(name, values) } - fun putAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(this::putQueryParams) + fun putAllHeaders(headers: Map>) = apply { + headers.forEach(::putHeaders) } - fun putAllQueryParams(queryParams: Multimap) = apply { - queryParams.asMap().forEach(this::putQueryParams) + fun replaceHeaders(name: String, value: String) = apply { + headers.replaceValues(name, listOf(value)) } - fun putHeader(name: String, value: String) = apply { - this.headers.replaceValues(name, listOf(value)) + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replaceValues(name, values) } - fun putHeaders(name: String, values: Iterable) = apply { - this.headers.replaceValues(name, values) + fun replaceAllHeaders(headers: Map>) = apply { + headers.forEach(::replaceHeaders) } - fun putAllHeaders(headers: Map>) = apply { - headers.forEach(this::putHeaders) + fun removeHeaders(name: String) = apply { headers.removeAll(name) } + + fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) } - fun putAllHeaders(headers: Multimap) = apply { - headers.asMap().forEach(this::putHeaders) + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.putAll(key, values) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + queryParams.forEach(::putQueryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replaceValues(key, listOf(value)) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replaceValues(key, values) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + queryParams.forEach(::replaceQueryParams) } + fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) } + + fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) } + fun body(body: HttpRequestBody) = apply { this.body = body } fun build(): HttpRequest = @@ -84,8 +111,8 @@ private constructor( checkNotNull(method) { "`method` is required but was not set" }, url, pathSegments.toImmutable(), - queryParams.toImmutable(), headers, + queryParams.toImmutable(), body, ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 6edea0c2..0779d5ef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -45,10 +45,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -75,10 +75,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -108,10 +108,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -138,10 +138,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -171,10 +171,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl", "batch-update") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -201,10 +201,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index e4cfe750..9b2ca289 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -45,10 +45,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -75,10 +75,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -108,10 +108,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -142,10 +142,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -172,10 +172,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -202,10 +202,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -235,10 +235,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index 75a6af2d..b765ea25 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -43,10 +43,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -73,10 +73,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -106,10 +106,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -136,10 +136,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index 0dd2647b..dd899f0b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -52,10 +52,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -82,10 +82,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -115,10 +115,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -149,10 +149,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -179,10 +179,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -209,10 +209,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -243,10 +243,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -276,10 +276,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -306,10 +306,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -337,10 +337,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index 40334775..7fc576fe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -44,10 +44,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -74,10 +74,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -107,10 +107,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -140,10 +140,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -169,10 +169,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -202,10 +202,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index aa2dddda..7e36490c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -42,10 +42,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "eval") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 3ae26dda..97ae98d9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -52,10 +52,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -82,10 +82,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -115,10 +115,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -149,10 +149,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -179,10 +179,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -209,10 +209,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -243,10 +243,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -276,10 +276,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -306,10 +306,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -337,10 +337,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 491cca41..8a4c14fa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -46,10 +46,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -76,10 +76,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -109,10 +109,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -143,10 +143,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -173,10 +173,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -203,10 +203,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -231,10 +231,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index 0cb84f89..cbf816b0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -44,10 +44,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -74,10 +74,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -107,10 +107,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -141,10 +141,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -171,10 +171,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -204,10 +204,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 1f66e1c3..a39ecc9c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -45,10 +45,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -78,10 +78,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -112,10 +112,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -142,10 +142,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index 8f592589..a96f8bbe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -45,10 +45,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -75,10 +75,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -108,10 +108,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -142,10 +142,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -172,10 +172,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -206,10 +206,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index d064b194..33b735d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -49,10 +49,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -79,10 +79,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -112,10 +112,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -146,10 +146,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -176,10 +176,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index 7cc499c6..7ca246a4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -44,10 +44,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -74,10 +74,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -107,10 +107,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -141,10 +141,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -171,10 +171,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -205,10 +205,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 6e56557a..8a9723a2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -44,10 +44,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -74,10 +74,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -107,10 +107,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -141,10 +141,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -171,10 +171,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -204,10 +204,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index 837c6e66..d113a03d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -44,10 +44,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -74,10 +74,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -107,10 +107,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -141,10 +141,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -171,10 +171,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -204,10 +204,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index 759787bd..cac07a65 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -32,10 +32,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 246d614f..03cbbf79 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -36,10 +36,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -69,10 +69,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index ddc3dad5..79da3e5d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -44,10 +44,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -74,10 +74,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -107,10 +107,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -141,10 +141,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -171,10 +171,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -204,10 +204,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 65480fe5..89348dae 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -36,10 +36,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 69a9dc3f..82fb7f12 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -40,10 +40,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -74,10 +74,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response -> @@ -107,10 +107,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -137,10 +137,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index 9d266d42..b5a947e5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -41,10 +41,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -67,10 +67,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -95,10 +95,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -121,10 +121,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -153,10 +153,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl", "batch-update") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -182,10 +182,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index f61b7be6..9f5ce473 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -41,10 +41,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -70,10 +70,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -99,10 +99,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -132,10 +132,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -158,10 +158,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -187,10 +187,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -216,10 +216,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index 0f6d80aa..56c2de94 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -42,10 +42,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -68,10 +68,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -97,10 +97,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -123,10 +123,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 4dc34521..deb7df96 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -48,10 +48,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -74,10 +74,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -103,10 +103,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -133,10 +133,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -159,10 +159,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -188,10 +188,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -221,10 +221,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -253,10 +253,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -282,10 +282,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -312,10 +312,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index 34db366c..56381c22 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -40,10 +40,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -66,10 +66,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -95,10 +95,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -127,10 +127,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -152,10 +152,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -181,10 +181,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index f8a2f694..9ea44d18 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -41,10 +41,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "eval") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index df57dad1..158ffd38 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -51,10 +51,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -80,10 +80,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -112,10 +112,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -145,10 +145,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -174,10 +174,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -203,10 +203,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -236,10 +236,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -268,10 +268,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -297,10 +297,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -327,10 +327,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 00bcbe94..57b63f36 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -42,10 +42,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -71,10 +71,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -100,10 +100,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -133,10 +133,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -159,10 +159,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -188,10 +188,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -212,10 +212,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 080f21e2..59e96aa0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -40,10 +40,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -66,10 +66,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -95,10 +95,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -124,10 +124,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -150,10 +150,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -179,10 +179,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index fd55f46a..8adea90e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -44,10 +44,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -76,10 +76,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -109,10 +109,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -138,10 +138,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index 9576e14a..f1fc18f7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -44,10 +44,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -73,10 +73,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -105,10 +105,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -138,10 +138,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -167,10 +167,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -200,10 +200,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 1349bed5..487799ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -45,10 +45,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -71,10 +71,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -100,10 +100,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -130,10 +130,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -156,10 +156,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index daf6171e..6358af7a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -43,10 +43,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -72,10 +72,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -104,10 +104,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -137,10 +137,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -166,10 +166,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -199,10 +199,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index dc23ed4d..94e8e0be 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -40,10 +40,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -66,10 +66,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -95,10 +95,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -125,10 +125,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -151,10 +151,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -180,10 +180,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index ef6cba86..81314aae 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -40,10 +40,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -66,10 +66,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -95,10 +95,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -124,10 +124,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -150,10 +150,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -179,10 +179,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 59d5c939..c20802be 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -31,10 +31,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response.use { helloWorldHandler.handle(it) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index b07330fe..dfb59811 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -32,10 +32,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -60,10 +60,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 4f17ebf9..62f6abff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -40,10 +40,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -66,10 +66,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -95,10 +95,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -124,10 +124,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -150,10 +150,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -179,10 +179,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index 31901bd3..5777be65 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -35,10 +35,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 5fc922bd..1cd65e5c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -39,10 +39,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -72,10 +72,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> response @@ -104,10 +104,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -133,10 +133,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) + .putAllQueryParams(clientOptions.queryParams.asMap()) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers.asMap()) + .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> From d83611fa8e3155f295f276573235d1bfd6f68371 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Thu, 7 Nov 2024 17:07:39 +0000 Subject: [PATCH 20/87] chore: rebuild project due to codegen change (#86) --- .../build.gradle.kts | 1 - .../client/okhttp/BraintrustOkHttpClient.kt | 18 +++ .../okhttp/BraintrustOkHttpClientAsync.kt | 18 +++ .../api/client/okhttp/OkHttpClient.kt | 25 ++-- braintrust-java-core/build.gradle.kts | 1 - .../api/client/BraintrustClientAsyncImpl.kt | 2 +- .../api/client/BraintrustClientImpl.kt | 2 +- .../braintrustdata/api/core/ClientOptions.kt | 88 ++++++++------ .../com/braintrustdata/api/core/Utils.kt | 6 - .../api/core/handlers/ErrorHandler.kt | 4 +- .../api/core/http/HttpRequest.kt | 82 ++++++++----- .../api/core/http/HttpResponse.kt | 3 +- .../api/core/http/RetryingHttpClient.kt | 50 ++++---- .../api/errors/BadRequestException.kt | 4 +- .../api/errors/BraintrustServiceException.kt | 6 +- .../api/errors/InternalServerException.kt | 4 +- .../api/errors/NotFoundException.kt | 4 +- .../api/errors/PermissionDeniedException.kt | 4 +- .../api/errors/RateLimitException.kt | 4 +- .../api/errors/UnauthorizedException.kt | 4 +- .../errors/UnexpectedStatusCodeException.kt | 4 +- .../errors/UnprocessableEntityException.kt | 4 +- .../api/models/AclBatchUpdateParams.kt | 98 +++++++++------ .../api/models/AclCreateParams.kt | 98 +++++++++------ .../api/models/AclDeleteParams.kt | 98 +++++++++------ .../api/models/AclFindAndDeleteParams.kt | 98 +++++++++------ .../api/models/AclListParams.kt | 105 +++++++++------- .../api/models/AclRetrieveParams.kt | 87 ++++++++------ .../api/models/AiSecretCreateParams.kt | 98 +++++++++------ .../api/models/AiSecretDeleteParams.kt | 98 +++++++++------ .../api/models/AiSecretFindAndDeleteParams.kt | 98 +++++++++------ .../api/models/AiSecretListParams.kt | 107 ++++++++++------- .../api/models/AiSecretReplaceParams.kt | 98 +++++++++------ .../api/models/AiSecretRetrieveParams.kt | 87 ++++++++------ .../api/models/AiSecretUpdateParams.kt | 98 +++++++++------ .../api/models/ApiKeyCreateParams.kt | 98 +++++++++------ .../api/models/ApiKeyDeleteParams.kt | 98 +++++++++------ .../api/models/ApiKeyListParams.kt | 105 +++++++++------- .../api/models/ApiKeyRetrieveParams.kt | 87 ++++++++------ .../api/models/DatasetCreateParams.kt | 98 +++++++++------ .../api/models/DatasetDeleteParams.kt | 98 +++++++++------ .../api/models/DatasetFeedbackParams.kt | 98 +++++++++------ .../api/models/DatasetFetchParams.kt | 101 +++++++++------- .../api/models/DatasetFetchPostParams.kt | 98 +++++++++------ .../api/models/DatasetInsertParams.kt | 98 +++++++++------ .../api/models/DatasetListParams.kt | 109 ++++++++++------- .../api/models/DatasetRetrieveParams.kt | 87 ++++++++------ .../api/models/DatasetSummarizeParams.kt | 95 +++++++++------ .../api/models/DatasetUpdateParams.kt | 98 +++++++++------ .../api/models/EnvVarCreateParams.kt | 98 +++++++++------ .../api/models/EnvVarDeleteParams.kt | 98 +++++++++------ .../api/models/EnvVarListParams.kt | 103 +++++++++------- .../api/models/EnvVarReplaceParams.kt | 98 +++++++++------ .../api/models/EnvVarRetrieveParams.kt | 87 ++++++++------ .../api/models/EnvVarUpdateParams.kt | 98 +++++++++------ .../api/models/EvalCreateParams.kt | 98 +++++++++------ .../api/models/ExperimentCreateParams.kt | 98 +++++++++------ .../api/models/ExperimentDeleteParams.kt | 98 +++++++++------ .../api/models/ExperimentFeedbackParams.kt | 98 +++++++++------ .../api/models/ExperimentFetchParams.kt | 101 +++++++++------- .../api/models/ExperimentFetchPostParams.kt | 98 +++++++++------ .../api/models/ExperimentInsertParams.kt | 98 +++++++++------ .../api/models/ExperimentListParams.kt | 109 ++++++++++------- .../api/models/ExperimentRetrieveParams.kt | 87 ++++++++------ .../api/models/ExperimentSummarizeParams.kt | 97 ++++++++------- .../api/models/ExperimentUpdateParams.kt | 98 +++++++++------ .../api/models/FunctionCreateParams.kt | 98 +++++++++------ .../api/models/FunctionDeleteParams.kt | 98 +++++++++------ .../api/models/FunctionInvokeParams.kt | 98 +++++++++------ .../api/models/FunctionListParams.kt | 113 ++++++++++-------- .../api/models/FunctionReplaceParams.kt | 98 +++++++++------ .../api/models/FunctionRetrieveParams.kt | 87 ++++++++------ .../api/models/FunctionUpdateParams.kt | 98 +++++++++------ .../api/models/GroupCreateParams.kt | 98 +++++++++------ .../api/models/GroupDeleteParams.kt | 98 +++++++++------ .../api/models/GroupListParams.kt | 105 +++++++++------- .../api/models/GroupReplaceParams.kt | 98 +++++++++------ .../api/models/GroupRetrieveParams.kt | 87 ++++++++------ .../api/models/GroupUpdateParams.kt | 98 +++++++++------ .../api/models/OrganizationDeleteParams.kt | 98 +++++++++------ .../api/models/OrganizationListParams.kt | 103 +++++++++------- .../models/OrganizationMemberUpdateParams.kt | 98 +++++++++------ .../api/models/OrganizationRetrieveParams.kt | 87 ++++++++------ .../api/models/OrganizationUpdateParams.kt | 98 +++++++++------ .../api/models/ProjectCreateParams.kt | 98 +++++++++------ .../api/models/ProjectDeleteParams.kt | 98 +++++++++------ .../api/models/ProjectListParams.kt | 105 +++++++++------- .../api/models/ProjectLogFeedbackParams.kt | 98 +++++++++------ .../api/models/ProjectLogFetchParams.kt | 101 +++++++++------- .../api/models/ProjectLogFetchPostParams.kt | 98 +++++++++------ .../api/models/ProjectLogInsertParams.kt | 98 +++++++++------ .../api/models/ProjectRetrieveParams.kt | 87 ++++++++------ .../api/models/ProjectScoreCreateParams.kt | 98 +++++++++------ .../api/models/ProjectScoreDeleteParams.kt | 98 +++++++++------ .../api/models/ProjectScoreListParams.kt | 111 +++++++++-------- .../api/models/ProjectScoreReplaceParams.kt | 98 +++++++++------ .../api/models/ProjectScoreRetrieveParams.kt | 87 ++++++++------ .../api/models/ProjectScoreUpdateParams.kt | 98 +++++++++------ .../api/models/ProjectTagCreateParams.kt | 98 +++++++++------ .../api/models/ProjectTagDeleteParams.kt | 98 +++++++++------ .../api/models/ProjectTagListParams.kt | 109 ++++++++++------- .../api/models/ProjectTagReplaceParams.kt | 98 +++++++++------ .../api/models/ProjectTagRetrieveParams.kt | 87 ++++++++------ .../api/models/ProjectTagUpdateParams.kt | 98 +++++++++------ .../api/models/ProjectUpdateParams.kt | 98 +++++++++------ .../api/models/PromptCreateParams.kt | 98 +++++++++------ .../api/models/PromptDeleteParams.kt | 98 +++++++++------ .../api/models/PromptListParams.kt | 113 ++++++++++-------- .../api/models/PromptReplaceParams.kt | 98 +++++++++------ .../api/models/PromptRetrieveParams.kt | 87 ++++++++------ .../api/models/PromptUpdateParams.kt | 98 +++++++++------ .../api/models/RoleCreateParams.kt | 98 +++++++++------ .../api/models/RoleDeleteParams.kt | 98 +++++++++------ .../api/models/RoleListParams.kt | 105 +++++++++------- .../api/models/RoleReplaceParams.kt | 98 +++++++++------ .../api/models/RoleRetrieveParams.kt | 87 ++++++++------ .../api/models/RoleUpdateParams.kt | 98 +++++++++------ .../api/models/TopLevelHelloWorldParams.kt | 88 ++++++++------ .../api/models/UserListParams.kt | 109 ++++++++++------- .../api/models/UserRetrieveParams.kt | 87 ++++++++------ .../api/models/ViewCreateParams.kt | 98 +++++++++------ .../api/models/ViewDeleteParams.kt | 98 +++++++++------ .../api/models/ViewListParams.kt | 109 ++++++++++------- .../api/models/ViewReplaceParams.kt | 98 +++++++++------ .../api/models/ViewRetrieveParams.kt | 97 ++++++++------- .../api/models/ViewUpdateParams.kt | 98 +++++++++------ .../api/services/async/AclServiceAsyncImpl.kt | 24 ++-- .../async/AiSecretServiceAsyncImpl.kt | 28 ++--- .../services/async/ApiKeyServiceAsyncImpl.kt | 16 +-- .../services/async/DatasetServiceAsyncImpl.kt | 40 +++---- .../services/async/EnvVarServiceAsyncImpl.kt | 24 ++-- .../services/async/EvalServiceAsyncImpl.kt | 4 +- .../async/ExperimentServiceAsyncImpl.kt | 40 +++---- .../async/FunctionServiceAsyncImpl.kt | 28 ++--- .../services/async/GroupServiceAsyncImpl.kt | 24 ++-- .../async/OrganizationServiceAsyncImpl.kt | 16 +-- .../async/ProjectScoreServiceAsyncImpl.kt | 24 ++-- .../services/async/ProjectServiceAsyncImpl.kt | 20 ++-- .../async/ProjectTagServiceAsyncImpl.kt | 24 ++-- .../services/async/PromptServiceAsyncImpl.kt | 24 ++-- .../services/async/RoleServiceAsyncImpl.kt | 24 ++-- .../async/TopLevelServiceAsyncImpl.kt | 4 +- .../services/async/UserServiceAsyncImpl.kt | 8 +- .../services/async/ViewServiceAsyncImpl.kt | 24 ++-- .../organizations/MemberServiceAsyncImpl.kt | 4 +- .../async/projects/LogServiceAsyncImpl.kt | 16 +-- .../api/services/blocking/AclServiceImpl.kt | 24 ++-- .../services/blocking/AiSecretServiceImpl.kt | 28 ++--- .../services/blocking/ApiKeyServiceImpl.kt | 16 +-- .../services/blocking/DatasetServiceImpl.kt | 40 +++---- .../services/blocking/EnvVarServiceImpl.kt | 24 ++-- .../api/services/blocking/EvalServiceImpl.kt | 4 +- .../blocking/ExperimentServiceImpl.kt | 40 +++---- .../services/blocking/FunctionServiceImpl.kt | 28 ++--- .../api/services/blocking/GroupServiceImpl.kt | 24 ++-- .../blocking/OrganizationServiceImpl.kt | 16 +-- .../blocking/ProjectScoreServiceImpl.kt | 24 ++-- .../services/blocking/ProjectServiceImpl.kt | 20 ++-- .../blocking/ProjectTagServiceImpl.kt | 24 ++-- .../services/blocking/PromptServiceImpl.kt | 24 ++-- .../api/services/blocking/RoleServiceImpl.kt | 24 ++-- .../services/blocking/TopLevelServiceImpl.kt | 4 +- .../api/services/blocking/UserServiceImpl.kt | 8 +- .../api/services/blocking/ViewServiceImpl.kt | 24 ++-- .../organizations/MemberServiceImpl.kt | 4 +- .../blocking/projects/LogServiceImpl.kt | 16 +-- .../api/core/http/HttpRequestTest.kt | 22 ---- .../api/models/AclListParamsTest.kt | 25 ++-- .../api/models/AiSecretListParamsTest.kt | 25 ++-- .../api/models/ApiKeyListParamsTest.kt | 21 ++-- .../api/models/DatasetFetchParamsTest.kt | 17 +-- .../api/models/DatasetListParamsTest.kt | 27 ++--- .../api/models/DatasetSummarizeParamsTest.kt | 11 +- .../api/models/EnvVarListParamsTest.kt | 19 +-- .../api/models/ExperimentFetchParamsTest.kt | 17 +-- .../api/models/ExperimentListParamsTest.kt | 27 ++--- .../models/ExperimentSummarizeParamsTest.kt | 13 +- .../api/models/FunctionListParamsTest.kt | 31 +++-- .../api/models/GroupListParamsTest.kt | 21 ++-- .../api/models/OrganizationListParamsTest.kt | 22 ++-- .../api/models/ProjectListParamsTest.kt | 23 ++-- .../api/models/ProjectLogFetchParamsTest.kt | 17 +-- .../api/models/ProjectScoreListParamsTest.kt | 32 +++-- .../api/models/ProjectTagListParamsTest.kt | 27 ++--- .../api/models/PromptListParamsTest.kt | 29 ++--- .../api/models/RoleListParamsTest.kt | 21 ++-- .../api/models/UserListParamsTest.kt | 25 ++-- .../api/models/ViewListParamsTest.kt | 29 ++--- .../api/models/ViewRetrieveParamsTest.kt | 17 +-- .../api/services/ErrorHandlingTest.kt | 83 +++++++------ 190 files changed, 7179 insertions(+), 4765 deletions(-) delete mode 100755 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt diff --git a/braintrust-java-client-okhttp/build.gradle.kts b/braintrust-java-client-okhttp/build.gradle.kts index 8c72bdc3..61e72e31 100755 --- a/braintrust-java-client-okhttp/build.gradle.kts +++ b/braintrust-java-client-okhttp/build.gradle.kts @@ -6,7 +6,6 @@ plugins { dependencies { api(project(":braintrust-java-core")) - implementation("com.google.guava:guava:33.0.0-jre") implementation("com.squareup.okhttp3:okhttp:4.12.0") testImplementation(kotlin("test")) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 70d40171..f180e456 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.client.okhttp import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.BraintrustClientImpl import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.fasterxml.jackson.databind.json.JsonMapper import java.net.Proxy import java.time.Clock @@ -36,6 +38,8 @@ class BraintrustOkHttpClient private constructor() { fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + fun headers(headers: Map>) = apply { clientOptions.headers(headers) } @@ -46,6 +50,8 @@ class BraintrustOkHttpClient private constructor() { clientOptions.putHeaders(name, values) } + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + fun putAllHeaders(headers: Map>) = apply { clientOptions.putAllHeaders(headers) } @@ -58,6 +64,8 @@ class BraintrustOkHttpClient private constructor() { clientOptions.replaceHeaders(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + fun replaceAllHeaders(headers: Map>) = apply { clientOptions.replaceAllHeaders(headers) } @@ -66,6 +74,8 @@ class BraintrustOkHttpClient private constructor() { fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + fun queryParams(queryParams: Map>) = apply { clientOptions.queryParams(queryParams) } @@ -78,6 +88,10 @@ class BraintrustOkHttpClient private constructor() { clientOptions.putQueryParams(key, values) } + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + fun putAllQueryParams(queryParams: Map>) = apply { clientOptions.putAllQueryParams(queryParams) } @@ -90,6 +104,10 @@ class BraintrustOkHttpClient private constructor() { clientOptions.replaceQueryParams(key, values) } + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + fun replaceAllQueryParams(queryParams: Map>) = apply { clientOptions.replaceAllQueryParams(queryParams) } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index ccdffb50..f1c04318 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.client.okhttp import com.braintrustdata.api.client.BraintrustClientAsync import com.braintrustdata.api.client.BraintrustClientAsyncImpl import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.fasterxml.jackson.databind.json.JsonMapper import java.net.Proxy import java.time.Clock @@ -36,6 +38,8 @@ class BraintrustOkHttpClientAsync private constructor() { fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + fun headers(headers: Map>) = apply { clientOptions.headers(headers) } @@ -46,6 +50,8 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.putHeaders(name, values) } + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + fun putAllHeaders(headers: Map>) = apply { clientOptions.putAllHeaders(headers) } @@ -58,6 +64,8 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.replaceHeaders(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + fun replaceAllHeaders(headers: Map>) = apply { clientOptions.replaceAllHeaders(headers) } @@ -66,6 +74,8 @@ class BraintrustOkHttpClientAsync private constructor() { fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + fun queryParams(queryParams: Map>) = apply { clientOptions.queryParams(queryParams) } @@ -78,6 +88,10 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.putQueryParams(key, values) } + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + fun putAllQueryParams(queryParams: Map>) = apply { clientOptions.putAllQueryParams(queryParams) } @@ -90,6 +104,10 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.replaceQueryParams(key, values) } + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + fun replaceAllQueryParams(queryParams: Map>) = apply { clientOptions.replaceAllQueryParams(queryParams) } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index 3e2d8180..f052fc61 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -1,14 +1,13 @@ package com.braintrustdata.api.client.okhttp import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpClient import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpRequestBody import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.errors.BraintrustIoException -import com.google.common.collect.ListMultimap -import com.google.common.collect.MultimapBuilder import java.io.IOException import java.io.InputStream import java.net.Proxy @@ -16,7 +15,6 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.Headers import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType @@ -95,7 +93,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } val builder = Request.Builder().url(toUrl()).method(method.name, body) - headers.forEach(builder::header) + headers.names().forEach { name -> + headers.values(name).forEach { builder.header(name, it) } + } return builder.build() } @@ -107,7 +107,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val val builder = baseUrl.newBuilder() pathSegments.forEach(builder::addPathSegment) - queryParams.forEach(builder::addQueryParameter) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } return builder.toString() } @@ -133,7 +135,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val return object : HttpResponse { override fun statusCode(): Int = code - override fun headers(): ListMultimap = headers + override fun headers(): Headers = headers override fun body(): InputStream = body!!.byteStream() @@ -141,13 +143,10 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } } - private fun Headers.toHeaders(): ListMultimap { - val headers = - MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) - .arrayListValues() - .build() - forEach { pair -> headers.put(pair.first, pair.second) } - return headers + private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() } companion object { diff --git a/braintrust-java-core/build.gradle.kts b/braintrust-java-core/build.gradle.kts index 8688a46e..0e9c34a5 100755 --- a/braintrust-java-core/build.gradle.kts +++ b/braintrust-java-core/build.gradle.kts @@ -6,7 +6,6 @@ plugins { dependencies { api("com.fasterxml.jackson.core:jackson-core:2.14.3") api("com.fasterxml.jackson.core:jackson-databind:2.14.3") - api("com.google.guava:guava:33.0.0-jre") implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.3") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3") diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index 1165de16..2ad9d939 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -13,7 +13,7 @@ constructor( ) : BraintrustClientAsync { private val clientOptionsWithUserAgent = - if (clientOptions.headers.containsKey("User-Agent")) clientOptions + if (clientOptions.headers.names().contains("User-Agent")) clientOptions else clientOptions .toBuilder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index 482983f8..d99bed3d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -13,7 +13,7 @@ constructor( ) : BraintrustClient { private val clientOptionsWithUserAgent = - if (clientOptions.headers.containsKey("User-Agent")) clientOptions + if (clientOptions.headers.names().contains("User-Agent")) clientOptions else clientOptions .toBuilder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 5d1433ab..f7568abf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -2,12 +2,12 @@ package com.braintrustdata.api.core +import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpClient import com.braintrustdata.api.core.http.PhantomReachableClosingHttpClient +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.time.Clock class ClientOptions @@ -17,8 +17,8 @@ private constructor( @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @get:JvmName("baseUrl") val baseUrl: String, - @get:JvmName("headers") val headers: ListMultimap, - @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, @get:JvmName("maxRetries") val maxRetries: Int, @get:JvmName("apiKey") val apiKey: String?, @@ -41,8 +41,8 @@ private constructor( private var jsonMapper: JsonMapper = jsonMapper() private var clock: Clock = Clock.systemUTC() private var baseUrl: String = PRODUCTION_URL - private var headers: ListMultimap = ArrayListMultimap.create() - private var queryParams: ListMultimap = ArrayListMultimap.create() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false private var maxRetries: Int = 2 private var apiKey: String? = null @@ -53,8 +53,8 @@ private constructor( jsonMapper = clientOptions.jsonMapper clock = clientOptions.clock baseUrl = clientOptions.baseUrl - headers = ArrayListMultimap.create(clientOptions.headers) - queryParams = ArrayListMultimap.create(clientOptions.queryParams) + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() responseValidation = clientOptions.responseValidation maxRetries = clientOptions.maxRetries apiKey = clientOptions.apiKey @@ -68,6 +68,11 @@ private constructor( fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + fun headers(headers: Map>) = apply { this.headers.clear() putAllHeaders(headers) @@ -75,29 +80,34 @@ private constructor( fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - fun putHeaders(name: String, values: Iterable) = apply { - headers.putAll(name, values) - } + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } fun putAllHeaders(headers: Map>) = apply { - headers.forEach(::putHeaders) + this.headers.putAll(headers) } - fun replaceHeaders(name: String, value: String) = apply { - headers.replaceValues(name, listOf(value)) - } + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replaceValues(name, values) + headers.replace(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + fun replaceAllHeaders(headers: Map>) = apply { - headers.forEach(::replaceHeaders) + this.headers.replaceAll(headers) } - fun removeHeaders(name: String) = apply { headers.removeAll(name) } + fun removeHeaders(name: String) = apply { headers.remove(name) } - fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) } + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -107,28 +117,36 @@ private constructor( fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.putAll(key, values) + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) } fun putAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::putQueryParams) + this.queryParams.putAll(queryParams) } fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replaceValues(key, listOf(value)) + queryParams.replace(key, value) } fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replaceValues(key, values) + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) } fun replaceAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::replaceQueryParams) + this.queryParams.replaceAll(queryParams) } - fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) } + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) } + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -143,8 +161,8 @@ private constructor( fun build(): ClientOptions { checkNotNull(httpClient) { "`httpClient` is required but was not set" } - val headers = ArrayListMultimap.create() - val queryParams = ArrayListMultimap.create() + val headers = Headers.builder() + val queryParams = QueryParams.builder() headers.put("X-Stainless-Lang", "java") headers.put("X-Stainless-Arch", getOsArch()) headers.put("X-Stainless-OS", getOsName()) @@ -152,11 +170,13 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - if (!apiKey.isNullOrEmpty()) { - headers.put("Authorization", "Bearer ${apiKey}") + apiKey?.let { + if (!it.isEmpty()) { + headers.put("Authorization", "Bearer $it") + } } - this.headers.asMap().forEach(headers::replaceValues) - this.queryParams.asMap().forEach(queryParams::replaceValues) + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) return ClientOptions( httpClient!!, @@ -170,8 +190,8 @@ private constructor( jsonMapper, clock, baseUrl, - headers.toImmutable(), - queryParams.toImmutable(), + headers.build(), + queryParams.build(), responseValidation, maxRetries, apiKey, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 499786b9..2706f7d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -3,8 +3,6 @@ package com.braintrustdata.api.core import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.google.common.collect.ImmutableListMultimap -import com.google.common.collect.ListMultimap import java.util.Collections import java.util.SortedMap @@ -25,8 +23,4 @@ internal fun , V> SortedMap.toImmutable(): SortedMap ListMultimap.toImmutable(): ListMultimap = - ImmutableListMultimap.copyOf(this) - internal interface Enum diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt index 62010fbb..12cfc384 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.core.handlers +import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BadRequestException @@ -14,7 +15,6 @@ import com.braintrustdata.api.errors.UnauthorizedException import com.braintrustdata.api.errors.UnexpectedStatusCodeException import com.braintrustdata.api.errors.UnprocessableEntityException import com.fasterxml.jackson.databind.json.JsonMapper -import com.google.common.collect.ListMultimap import java.io.ByteArrayInputStream import java.io.InputStream @@ -116,7 +116,7 @@ private fun HttpResponse.buffered(): HttpResponse { return object : HttpResponse { override fun statusCode(): Int = this@buffered.statusCode() - override fun headers(): ListMultimap = this@buffered.headers() + override fun headers(): Headers = this@buffered.headers() override fun body(): InputStream = ByteArrayInputStream(body) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index 2420ddf2..b6878c7f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -1,20 +1,19 @@ package com.braintrustdata.api.core.http import com.braintrustdata.api.core.toImmutable -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap -import com.google.common.collect.MultimapBuilder class HttpRequest private constructor( @get:JvmName("method") val method: HttpMethod, @get:JvmName("url") val url: String?, @get:JvmName("pathSegments") val pathSegments: List, - @get:JvmName("headers") val headers: ListMultimap, - @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("body") val body: HttpRequestBody?, ) { + fun toBuilder(): Builder = Builder().from(this) + override fun toString(): String = "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" @@ -27,11 +26,20 @@ private constructor( private var method: HttpMethod? = null private var url: String? = null private var pathSegments: MutableList = mutableListOf() - private var headers: ListMultimap = - MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).arrayListValues().build() - private var queryParams: ListMultimap = ArrayListMultimap.create() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() private var body: HttpRequestBody? = null + @JvmSynthetic + internal fun from(request: HttpRequest) = apply { + method = request.method + url = request.url + pathSegments = request.pathSegments.toMutableList() + headers = request.headers.toBuilder() + queryParams = request.queryParams.toBuilder() + body = request.body + } + fun method(method: HttpMethod) = apply { this.method = method } fun url(url: String) = apply { this.url = url } @@ -42,6 +50,11 @@ private constructor( this.pathSegments.addAll(pathSegments) } + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + fun headers(headers: Map>) = apply { this.headers.clear() putAllHeaders(headers) @@ -49,29 +62,34 @@ private constructor( fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - fun putHeaders(name: String, values: Iterable) = apply { - headers.putAll(name, values) - } + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } fun putAllHeaders(headers: Map>) = apply { - headers.forEach(::putHeaders) + this.headers.putAll(headers) } - fun replaceHeaders(name: String, value: String) = apply { - headers.replaceValues(name, listOf(value)) - } + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replaceValues(name, values) + headers.replace(name, values) } + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + fun replaceAllHeaders(headers: Map>) = apply { - headers.forEach(::replaceHeaders) + this.headers.replaceAll(headers) } - fun removeHeaders(name: String) = apply { headers.removeAll(name) } + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } - fun removeAllHeaders(names: Set) = apply { names.forEach(::removeHeaders) } + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -81,28 +99,36 @@ private constructor( fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.putAll(key, values) + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) } fun putAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::putQueryParams) + this.queryParams.putAll(queryParams) } fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replaceValues(key, listOf(value)) + queryParams.replace(key, value) } fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replaceValues(key, values) + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) } fun replaceAllQueryParams(queryParams: Map>) = apply { - queryParams.forEach(::replaceQueryParams) + this.queryParams.replaceAll(queryParams) } - fun removeQueryParams(key: String) = apply { queryParams.removeAll(key) } + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - fun removeAllQueryParams(keys: Set) = apply { keys.forEach(::removeQueryParams) } + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } fun body(body: HttpRequestBody) = apply { this.body = body } @@ -111,8 +137,8 @@ private constructor( checkNotNull(method) { "`method` is required but was not set" }, url, pathSegments.toImmutable(), - headers, - queryParams.toImmutable(), + headers.build(), + queryParams.build(), body, ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt index 333dda67..150bd762 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt @@ -1,6 +1,5 @@ package com.braintrustdata.api.core.http -import com.google.common.collect.ListMultimap import java.io.InputStream import java.lang.AutoCloseable @@ -8,7 +7,7 @@ interface HttpResponse : AutoCloseable { fun statusCode(): Int - fun headers(): ListMultimap + fun headers(): Headers fun body(): InputStream diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 09bb15ae..0d1679b5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -35,21 +35,22 @@ private constructor( return httpClient.execute(request, requestOptions) } - maybeAddIdempotencyHeader(request) + var modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. - val shouldSendRetryCount = !request.headers.containsKey("x-stainless-retry-count") + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") var retries = 0 while (true) { if (shouldSendRetryCount) { - setRetryCountHeader(request, retries) + modifiedRequest = setRetryCountHeader(modifiedRequest, retries) } val response = try { - val response = httpClient.execute(request, requestOptions) + val response = httpClient.execute(modifiedRequest, requestOptions) if (++retries > maxRetries || !shouldRetry(response)) { return response } @@ -76,10 +77,11 @@ private constructor( return httpClient.executeAsync(request, requestOptions) } - maybeAddIdempotencyHeader(request) + val modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. - val shouldSendRetryCount = !request.headers.containsKey("x-stainless-retry-count") + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") var retries = 0 @@ -87,12 +89,11 @@ private constructor( request: HttpRequest, requestOptions: RequestOptions, ): CompletableFuture { - if (shouldSendRetryCount) { - setRetryCountHeader(request, retries) - } + val requestWithRetryCount = + if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request return httpClient - .executeAsync(request, requestOptions) + .executeAsync(requestWithRetryCount, requestOptions) .handleAsync( fun( response: HttpResponse?, @@ -112,7 +113,7 @@ private constructor( val backoffMillis = getRetryBackoffMillis(retries, response) return sleepAsync(backoffMillis.toMillis()).thenCompose { - executeWithRetries(request, requestOptions) + executeWithRetries(requestWithRetryCount, requestOptions) } }, ) { @@ -122,7 +123,7 @@ private constructor( .thenCompose(Function.identity()) } - return executeWithRetries(request, requestOptions) + return executeWithRetries(modifiedRequest, requestOptions) } override fun close() = httpClient.close() @@ -132,23 +133,26 @@ private constructor( // the body data aren't available on subsequent attempts. request.body?.repeatable() ?: true - private fun setRetryCountHeader(request: HttpRequest, retries: Int) { - request.headers.removeAll("x-stainless-retry-count") - request.headers.put("x-stainless-retry-count", retries.toString()) - } + private fun setRetryCountHeader(request: HttpRequest, retries: Int): HttpRequest = + request.toBuilder().replaceHeaders("X-Stainless-Retry-Count", retries.toString()).build() private fun idempotencyKey(): String = "stainless-java-retry-${UUID.randomUUID()}" - private fun maybeAddIdempotencyHeader(request: HttpRequest) { - if (idempotencyHeader != null && !request.headers.containsKey(idempotencyHeader)) { - // Set a header to uniquely identify the request when retried - request.headers.put(idempotencyHeader, idempotencyKey()) + private fun maybeAddIdempotencyHeader(request: HttpRequest): HttpRequest { + if (idempotencyHeader == null || request.headers.names().contains(idempotencyHeader)) { + return request } + + return request + .toBuilder() + // Set a header to uniquely identify the request when retried. + .putHeader(idempotencyHeader, idempotencyKey()) + .build() } private fun shouldRetry(response: HttpResponse): Boolean { // Note: this is not a standard header - val shouldRetryHeader = response.headers().get("x-should-retry").getOrNull(0) + val shouldRetryHeader = response.headers().values("X-Should-Retry").getOrNull(0) val statusCode = response.statusCode() return when { @@ -180,11 +184,11 @@ private constructor( ?.headers() ?.let { headers -> headers - .get("Retry-After-Ms") + .values("Retry-After-Ms") .getOrNull(0) ?.toFloatOrNull() ?.times(TimeUnit.MILLISECONDS.toNanos(1)) - ?: headers.get("Retry-After").getOrNull(0)?.let { retryAfter -> + ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { ChronoUnit.MILLIS.between( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt index a373ba5e..07641724 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt @@ -1,9 +1,9 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers class BadRequestException( - headers: ListMultimap, + headers: Headers, body: String, error: BraintrustError, ) : BraintrustServiceException(400, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt index 35d9249b..5c545f07 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt @@ -1,12 +1,12 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers abstract class BraintrustServiceException @JvmOverloads constructor( private val statusCode: Int, - private val headers: ListMultimap, + private val headers: Headers, private val body: String, private val error: BraintrustError, message: String = "$statusCode: $error", @@ -15,7 +15,7 @@ constructor( fun statusCode(): Int = statusCode - fun headers(): ListMultimap = headers + fun headers(): Headers = headers fun body(): String = body diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt index e43239e8..36cc4432 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt @@ -1,10 +1,10 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers class InternalServerException( statusCode: Int, - headers: ListMultimap, + headers: Headers, body: String, error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt index 8e879cbf..f99a4eed 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt @@ -1,9 +1,9 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers class NotFoundException( - headers: ListMultimap, + headers: Headers, body: String, error: BraintrustError, ) : BraintrustServiceException(404, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt index 98c6f33e..7f7ea797 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt @@ -1,9 +1,9 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers class PermissionDeniedException( - headers: ListMultimap, + headers: Headers, body: String, error: BraintrustError, ) : BraintrustServiceException(403, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt index d98aed03..59a00393 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt @@ -1,9 +1,9 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers class RateLimitException( - headers: ListMultimap, + headers: Headers, body: String, error: BraintrustError, ) : BraintrustServiceException(429, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt index 72236499..8bc7c82e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt @@ -1,9 +1,9 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers class UnauthorizedException( - headers: ListMultimap, + headers: Headers, body: String, error: BraintrustError, ) : BraintrustServiceException(401, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt index 7482559f..7aa10d9b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt @@ -1,10 +1,10 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers class UnexpectedStatusCodeException( statusCode: Int, - headers: ListMultimap, + headers: Headers, body: String, error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt index 095b1fcf..35dad36e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt @@ -1,9 +1,9 @@ package com.braintrustdata.api.errors -import com.google.common.collect.ListMultimap +import com.braintrustdata.api.core.http.Headers class UnprocessableEntityException( - headers: ListMultimap, + headers: Headers, body: String, error: BraintrustError, ) : BraintrustServiceException(422, headers, body, error) 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 a7f5bcf5..f1a6977c 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -24,8 +24,8 @@ class AclBatchUpdateParams constructor( private val addAcls: List?, private val removeAcls: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -42,9 +42,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = AclBatchUpdateBody.Builder::class) @NoAutoDetect @@ -174,9 +174,9 @@ constructor( "AclBatchUpdateBody{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -207,8 +207,8 @@ constructor( private var addAcls: MutableList = mutableListOf() private var removeAcls: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -274,6 +274,11 @@ constructor( */ fun addRemoveAcl(removeAcl: RemoveAcl) = apply { this.removeAcls.add(removeAcl) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -284,29 +289,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -319,42 +337,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -362,18 +386,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AclBatchUpdateParams = AclBatchUpdateParams( if (addAcls.size == 0) null else addAcls.toImmutable(), if (removeAcls.size == 0) null else removeAcls.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 0f5be566..58858ff4 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -29,8 +29,8 @@ constructor( private val restrictObjectType: RestrictObjectType?, private val roleId: String?, private val userId: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -62,9 +62,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -248,9 +248,9 @@ constructor( "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -286,8 +286,8 @@ constructor( private var restrictObjectType: RestrictObjectType? = null private var roleId: String? = null private var userId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -339,6 +339,11 @@ constructor( */ fun userId(userId: String) = apply { this.userId = userId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -349,29 +354,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -384,42 +402,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -427,6 +451,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AclCreateParams = AclCreateParams( checkNotNull(objectId) { "`objectId` is required but was not set" }, @@ -436,14 +468,8 @@ constructor( restrictObjectType, roleId, userId, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index ad87f817..4c951af3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class AclDeleteParams constructor( private val aclId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var aclId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Acl id */ fun aclId(aclId: String) = apply { this.aclId = aclId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AclDeleteParams = AclDeleteParams( checkNotNull(aclId) { "`aclId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 b263e327..5dfc524d 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -29,8 +29,8 @@ constructor( private val restrictObjectType: RestrictObjectType?, private val roleId: String?, private val userId: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -62,9 +62,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -248,9 +248,9 @@ constructor( "AclFindAndDeleteBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -286,8 +286,8 @@ constructor( private var restrictObjectType: RestrictObjectType? = null private var roleId: String? = null private var userId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -339,6 +339,11 @@ constructor( */ fun userId(userId: String) = apply { this.userId = userId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -349,29 +354,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -384,42 +402,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -427,6 +451,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AclFindAndDeleteParams = AclFindAndDeleteParams( checkNotNull(objectId) { "`objectId` is required but was not set" }, @@ -436,14 +468,8 @@ constructor( restrictObjectType, roleId, userId, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 cc829a79..990fdc7d 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 @@ -9,7 +9,8 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator @@ -20,8 +21,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -33,8 +32,8 @@ constructor( private val ids: Ids?, private val limit: Long?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun objectId(): String = objectId @@ -49,24 +48,24 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { params.put("object_id", listOf(it.toString())) } - this.objectType.let { params.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } + this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -99,8 +98,8 @@ constructor( private var ids: Ids? = null private var limit: Long? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(aclListParams: AclListParams) = apply { @@ -159,6 +158,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -169,29 +173,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -204,33 +221,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): AclListParams = @@ -241,14 +264,8 @@ constructor( ids, limit, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index c4c21dd0..66f18f2d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class AclRetrieveParams constructor( private val aclId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun aclId(): String = aclId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var aclId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(aclRetrieveParams: AclRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Acl id */ fun aclId(aclId: String) = apply { this.aclId = aclId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): AclRetrieveParams = AclRetrieveParams( checkNotNull(aclId) { "`aclId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 092f01bf..29ceb91c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +23,8 @@ constructor( private val orgName: String?, private val secret: String?, private val type: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -50,9 +50,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = AiSecretCreateBody.Builder::class) @NoAutoDetect @@ -184,9 +184,9 @@ constructor( "AiSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -220,8 +220,8 @@ constructor( private var orgName: String? = null private var secret: String? = null private var type: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -256,6 +256,11 @@ constructor( fun type(type: String) = apply { this.type = type } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -266,29 +271,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -301,42 +319,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -344,6 +368,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AiSecretCreateParams = AiSecretCreateParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -351,14 +383,8 @@ constructor( orgName, secret, type, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index c682f62a..c10eddd4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class AiSecretDeleteParams constructor( private val aiSecretId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var aiSecretId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** AiSecret id */ fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AiSecretDeleteParams = AiSecretDeleteParams( checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 97f35a06..a8d4c8df 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -20,8 +20,8 @@ class AiSecretFindAndDeleteParams constructor( private val name: String, private val orgName: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -38,9 +38,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = AiSecretFindAndDeleteBody.Builder::class) @NoAutoDetect @@ -139,9 +139,9 @@ constructor( "AiSecretFindAndDeleteBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -172,8 +172,8 @@ constructor( private var name: String? = null private var orgName: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -195,6 +195,11 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -205,29 +210,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -240,42 +258,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -283,18 +307,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AiSecretFindAndDeleteParams = AiSecretFindAndDeleteParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 0e29489a..53a51901 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -31,8 +30,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun aiSecretName(): Optional = Optional.ofNullable(aiSecretName) @@ -49,25 +48,25 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.aiSecretName?.let { params.put("ai_secret_name", listOf(it.toString())) } - this.aiSecretType?.let { params.put("ai_secret_type", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.aiSecretName?.let { queryParams.put("ai_secret_name", listOf(it.toString())) } + this.aiSecretType?.let { queryParams.put("ai_secret_type", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -101,8 +100,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(aiSecretListParams: AiSecretListParams) = apply { @@ -172,6 +171,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -182,29 +186,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -217,33 +234,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): AiSecretListParams = @@ -255,14 +278,8 @@ constructor( limit, orgName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 12a1e676..ca225346 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +23,8 @@ constructor( private val orgName: String?, private val secret: String?, private val type: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -50,9 +50,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = AiSecretReplaceBody.Builder::class) @NoAutoDetect @@ -184,9 +184,9 @@ constructor( "AiSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -220,8 +220,8 @@ constructor( private var orgName: String? = null private var secret: String? = null private var type: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -256,6 +256,11 @@ constructor( fun type(type: String) = apply { this.type = type } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -266,29 +271,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -301,42 +319,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -344,6 +368,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AiSecretReplaceParams = AiSecretReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -351,14 +383,8 @@ constructor( orgName, secret, type, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index 16c6b131..0d784169 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class AiSecretRetrieveParams constructor( private val aiSecretId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun aiSecretId(): String = aiSecretId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var aiSecretId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** AiSecret id */ fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 7f588897..0dd8675d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +23,8 @@ constructor( private val name: String?, private val secret: String?, private val type: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -49,9 +49,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -163,9 +163,9 @@ constructor( "AiSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -199,8 +199,8 @@ constructor( private var name: String? = null private var secret: String? = null private var type: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -227,6 +227,11 @@ constructor( fun type(type: String) = apply { this.type = type } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -237,29 +242,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -272,42 +290,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -315,6 +339,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): AiSecretUpdateParams = AiSecretUpdateParams( checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, @@ -322,14 +354,8 @@ constructor( name, secret, type, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 34a8d02f..9be22c2d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -20,8 +20,8 @@ class ApiKeyCreateParams constructor( private val name: String, private val orgName: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -38,9 +38,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = ApiKeyCreateBody.Builder::class) @NoAutoDetect @@ -139,9 +139,9 @@ constructor( "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -172,8 +172,8 @@ constructor( private var name: String? = null private var orgName: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -195,6 +195,11 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -205,29 +210,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -240,42 +258,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -283,18 +307,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ApiKeyCreateParams = ApiKeyCreateParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index aa48c683..66660bb0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ApiKeyDeleteParams constructor( private val apiKeyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var apiKeyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** ApiKey id */ fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 6b21ab00..c332e427 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +29,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun apiKeyName(): Optional = Optional.ofNullable(apiKeyName) @@ -46,24 +45,24 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.apiKeyName?.let { params.put("api_key_name", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.apiKeyName?.let { queryParams.put("api_key_name", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -96,8 +95,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(apiKeyListParams: ApiKeyListParams) = apply { @@ -156,6 +155,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -166,29 +170,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -201,33 +218,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ApiKeyListParams = @@ -238,14 +261,8 @@ constructor( limit, orgName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index e81ef421..4928c895 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ApiKeyRetrieveParams constructor( private val apiKeyId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun apiKeyId(): String = apiKeyId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var apiKeyId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** ApiKey id */ fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index f0554c63..76c613a1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -21,8 +21,8 @@ constructor( private val name: String, private val projectId: String, private val description: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -42,9 +42,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = DatasetCreateBody.Builder::class) @NoAutoDetect @@ -146,9 +146,9 @@ constructor( "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -180,8 +180,8 @@ constructor( private var name: String? = null private var projectId: String? = null private var description: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -203,6 +203,11 @@ constructor( /** Textual description of the dataset */ fun description(description: String) = apply { this.description = description } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -213,29 +218,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -248,42 +266,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -291,19 +315,21 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): DatasetCreateParams = DatasetCreateParams( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, description, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index ce3dc162..06816587 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class DatasetDeleteParams constructor( private val datasetId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var datasetId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Dataset id */ fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): DatasetDeleteParams = DatasetDeleteParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 30b15d57..b52c83cf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -5,22 +5,22 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class DatasetFeedbackParams constructor( private val datasetId: String, private val feedback: List, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -33,9 +33,9 @@ constructor( return DatasetFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -124,9 +124,9 @@ constructor( "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -157,8 +157,8 @@ constructor( private var datasetId: String? = null private var feedback: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -182,6 +182,11 @@ constructor( /** A list of dataset feedback items */ fun addFeedback(feedback: FeedbackDatasetItem) = apply { this.feedback.add(feedback) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -192,29 +197,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -227,42 +245,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -270,18 +294,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): DatasetFeedbackParams = DatasetFeedbackParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 67475f5a..bf83ae7e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -3,10 +3,9 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -17,8 +16,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun datasetId(): String = datasetId @@ -31,17 +30,17 @@ constructor( fun version(): Optional = Optional.ofNullable(version) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -51,9 +50,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -85,8 +84,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(datasetFetchParams: DatasetFetchParams) = apply { @@ -155,6 +154,11 @@ constructor( */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -165,29 +169,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -200,33 +217,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): DatasetFetchParams = @@ -236,14 +259,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index f4b7d08d..6683ecc8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -25,8 +25,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -57,9 +57,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -308,9 +308,9 @@ constructor( "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -346,8 +346,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -452,6 +452,11 @@ constructor( */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -462,29 +467,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -497,42 +515,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -540,6 +564,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): DatasetFetchPostParams = DatasetFetchPostParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, @@ -549,14 +581,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index e24f119c..9a0e9a89 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -8,6 +8,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -21,8 +23,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +30,8 @@ class DatasetInsertParams constructor( private val datasetId: String, private val events: List, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -44,9 +44,9 @@ constructor( return DatasetInsertBody(events, additionalBodyProperties) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -133,9 +133,9 @@ constructor( "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -166,8 +166,8 @@ constructor( private var datasetId: String? = null private var events: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -191,6 +191,11 @@ constructor( /** A list of dataset events to insert */ fun addEvent(event: Event) = apply { this.events.add(event) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -201,29 +206,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -236,42 +254,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -279,18 +303,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): DatasetInsertParams = DatasetInsertParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index a8ef3d43..1c2181a2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -32,8 +31,8 @@ constructor( private val projectId: String?, private val projectName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun datasetName(): Optional = Optional.ofNullable(datasetName) @@ -52,26 +51,26 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.datasetName?.let { params.put("dataset_name", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.datasetName?.let { queryParams.put("dataset_name", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -106,8 +105,8 @@ constructor( private var projectId: String? = null private var projectName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(datasetListParams: DatasetListParams) = apply { @@ -174,6 +173,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -184,29 +188,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -219,33 +236,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): DatasetListParams = @@ -258,14 +281,8 @@ constructor( projectId, projectName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index a7b08373..0d016465 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class DatasetRetrieveParams constructor( private val datasetId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun datasetId(): String = datasetId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var datasetId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Dataset id */ fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): DatasetRetrieveParams = DatasetRetrieveParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 89e1114e..9de8c6a4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -3,10 +3,9 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -14,22 +13,22 @@ class DatasetSummarizeParams constructor( private val datasetId: String, private val summarizeData: Boolean?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun datasetId(): String = datasetId fun summarizeData(): Optional = Optional.ofNullable(summarizeData) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.summarizeData?.let { params.put("summarize_data", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.summarizeData?.let { queryParams.put("summarize_data", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -39,9 +38,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -70,8 +69,8 @@ constructor( private var datasetId: String? = null private var summarizeData: Boolean? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = apply { @@ -89,6 +88,11 @@ constructor( */ fun summarizeData(summarizeData: Boolean) = apply { this.summarizeData = summarizeData } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -99,29 +103,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -134,47 +151,47 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): DatasetSummarizeParams = DatasetSummarizeParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, summarizeData, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 9ab22108..62f06677 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -22,8 +22,8 @@ constructor( private val description: String?, private val metadata: Metadata?, private val name: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -45,9 +45,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -156,9 +156,9 @@ constructor( "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -191,8 +191,8 @@ constructor( private var description: String? = null private var metadata: Metadata? = null private var name: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -218,6 +218,11 @@ constructor( /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = apply { this.name = name } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -228,29 +233,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -263,42 +281,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -306,20 +330,22 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): DatasetUpdateParams = DatasetUpdateParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, description, metadata, name, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 473d3a1c..7b8a695f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -26,8 +26,8 @@ constructor( private val objectId: String, private val objectType: ObjectType, private val value: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -50,9 +50,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = EnvVarCreateBody.Builder::class) @NoAutoDetect @@ -164,9 +164,9 @@ constructor( "EnvVarCreateBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -199,8 +199,8 @@ constructor( private var objectId: String? = null private var objectType: ObjectType? = null private var value: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -226,6 +226,11 @@ constructor( /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String) = apply { this.value = value } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -236,29 +241,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -271,42 +289,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -314,20 +338,22 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): EnvVarCreateParams = EnvVarCreateParams( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, value, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index eafa2681..f2419595 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class EnvVarDeleteParams constructor( private val envVarId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var envVarId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** EnvVar id */ fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): EnvVarDeleteParams = EnvVarDeleteParams( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 01d0fe60..3c30e2fa 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 @@ -9,7 +9,8 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator @@ -20,8 +21,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -32,8 +31,8 @@ constructor( private val limit: Long?, private val objectId: String?, private val objectType: ObjectType?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun envVarName(): Optional = Optional.ofNullable(envVarName) @@ -46,23 +45,23 @@ constructor( fun objectType(): Optional = Optional.ofNullable(objectType) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.envVarName?.let { params.put("env_var_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.objectId?.let { params.put("object_id", listOf(it.toString())) } - this.objectType?.let { params.put("object_type", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.envVarName?.let { queryParams.put("env_var_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.objectId?.let { queryParams.put("object_id", listOf(it.toString())) } + this.objectType?.let { queryParams.put("object_type", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -94,8 +93,8 @@ constructor( private var limit: Long? = null private var objectId: String? = null private var objectType: ObjectType? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(envVarListParams: EnvVarListParams) = apply { @@ -138,6 +137,11 @@ constructor( /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -148,29 +152,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -183,33 +200,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): EnvVarListParams = @@ -219,14 +242,8 @@ constructor( limit, objectId, objectType, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index 609b5963..7ee9c316 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -26,8 +26,8 @@ constructor( private val objectId: String, private val objectType: ObjectType, private val value: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -50,9 +50,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = EnvVarReplaceBody.Builder::class) @NoAutoDetect @@ -164,9 +164,9 @@ constructor( "EnvVarReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -199,8 +199,8 @@ constructor( private var objectId: String? = null private var objectType: ObjectType? = null private var value: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -226,6 +226,11 @@ constructor( /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String) = apply { this.value = value } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -236,29 +241,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -271,42 +289,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -314,20 +338,22 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): EnvVarReplaceParams = EnvVarReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, value, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 9cb4e604..d9e34fd0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class EnvVarRetrieveParams constructor( private val envVarId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun envVarId(): String = envVarId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var envVarId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** EnvVar id */ fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 1ab10d09..fb35e464 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -21,8 +21,8 @@ constructor( private val envVarId: String, private val name: String, private val value: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -41,9 +41,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -140,9 +140,9 @@ constructor( "EnvVarUpdateBody{name=$name, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -174,8 +174,8 @@ constructor( private var envVarId: String? = null private var name: String? = null private var value: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -197,6 +197,11 @@ constructor( /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String) = apply { this.value = value } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -207,29 +212,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -242,42 +260,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -285,19 +309,21 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): EnvVarUpdateParams = EnvVarUpdateParams( checkNotNull(envVarId) { "`envVarId` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, value, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index bdb50926..625539b3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -11,6 +11,8 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -25,8 +27,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -39,8 +39,8 @@ constructor( private val experimentName: String?, private val metadata: Metadata?, private val stream: Boolean?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -72,9 +72,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = EvalCreateBody.Builder::class) @NoAutoDetect @@ -239,9 +239,9 @@ constructor( "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, experimentName=$experimentName, metadata=$metadata, stream=$stream, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -277,8 +277,8 @@ constructor( private var experimentName: String? = null private var metadata: Metadata? = null private var stream: Boolean? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -366,6 +366,11 @@ constructor( */ fun stream(stream: Boolean) = apply { this.stream = stream } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -376,29 +381,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -411,42 +429,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -454,6 +478,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): EvalCreateParams = EvalCreateParams( checkNotNull(data) { "`data` is required but was not set" }, @@ -463,14 +495,8 @@ constructor( experimentName, metadata, stream, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 16b49e5f..b7e02f37 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -28,8 +28,8 @@ constructor( private val name: String?, private val public_: Boolean?, private val repoInfo: RepoInfo?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -70,9 +70,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = ExperimentCreateBody.Builder::class) @NoAutoDetect @@ -277,9 +277,9 @@ constructor( "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -318,8 +318,8 @@ constructor( private var name: String? = null private var public_: Boolean? = null private var repoInfo: RepoInfo? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -381,6 +381,11 @@ constructor( /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -391,29 +396,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -426,42 +444,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -469,6 +493,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ExperimentCreateParams = ExperimentCreateParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, @@ -481,14 +513,8 @@ constructor( name, public_, repoInfo, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index a40a00dc..9e961da8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ExperimentDeleteParams constructor( private val experimentId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var experimentId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Experiment id */ fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ExperimentDeleteParams = ExperimentDeleteParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index b8a5606f..363f5507 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -5,22 +5,22 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ExperimentFeedbackParams constructor( private val experimentId: String, private val feedback: List, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -33,9 +33,9 @@ constructor( return ExperimentFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -126,9 +126,9 @@ constructor( "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -159,8 +159,8 @@ constructor( private var experimentId: String? = null private var feedback: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -184,6 +184,11 @@ constructor( /** A list of experiment feedback items */ fun addFeedback(feedback: FeedbackExperimentItem) = apply { this.feedback.add(feedback) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -194,29 +199,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -229,42 +247,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -272,18 +296,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index aa956336..4e305c4b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -3,10 +3,9 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -17,8 +16,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun experimentId(): String = experimentId @@ -31,17 +30,17 @@ constructor( fun version(): Optional = Optional.ofNullable(version) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -51,9 +50,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -85,8 +84,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(experimentFetchParams: ExperimentFetchParams) = apply { @@ -155,6 +154,11 @@ constructor( */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -165,29 +169,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -200,33 +217,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ExperimentFetchParams = @@ -236,14 +259,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index d5709258..91fac9f8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -25,8 +25,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -57,9 +57,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -308,9 +308,9 @@ constructor( "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -346,8 +346,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -452,6 +452,11 @@ constructor( */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -462,29 +467,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -497,42 +515,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -540,6 +564,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ExperimentFetchPostParams = ExperimentFetchPostParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, @@ -549,14 +581,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 63e386ae..7c3b8465 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -8,6 +8,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -21,8 +23,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +30,8 @@ class ExperimentInsertParams constructor( private val experimentId: String, private val events: List, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -44,9 +44,9 @@ constructor( return ExperimentInsertBody(events, additionalBodyProperties) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -133,9 +133,9 @@ constructor( "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -166,8 +166,8 @@ constructor( private var experimentId: String? = null private var events: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -191,6 +191,11 @@ constructor( /** A list of experiment events to insert */ fun addEvent(event: Event) = apply { this.events.add(event) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -201,29 +206,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -236,42 +254,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -279,18 +303,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ExperimentInsertParams = ExperimentInsertParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index e8e66eb7..9533744d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -32,8 +31,8 @@ constructor( private val projectId: String?, private val projectName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -52,26 +51,26 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.experimentName?.let { params.put("experiment_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.experimentName?.let { queryParams.put("experiment_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -106,8 +105,8 @@ constructor( private var projectId: String? = null private var projectName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(experimentListParams: ExperimentListParams) = apply { @@ -174,6 +173,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -184,29 +188,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -219,33 +236,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ExperimentListParams = @@ -258,14 +281,8 @@ constructor( projectId, projectName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index db28d8eb..e3497fed 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ExperimentRetrieveParams constructor( private val experimentId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun experimentId(): String = experimentId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var experimentId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Experiment id */ fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 64cc5196..98615e1e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -3,10 +3,9 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -15,8 +14,8 @@ constructor( private val experimentId: String, private val comparisonExperimentId: String?, private val summarizeScores: Boolean?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun experimentId(): String = experimentId @@ -25,17 +24,17 @@ constructor( fun summarizeScores(): Optional = Optional.ofNullable(summarizeScores) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() this.comparisonExperimentId?.let { - params.put("comparison_experiment_id", listOf(it.toString())) + queryParams.put("comparison_experiment_id", listOf(it.toString())) } - this.summarizeScores?.let { params.put("summarize_scores", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + this.summarizeScores?.let { queryParams.put("summarize_scores", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -45,9 +44,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -77,8 +76,8 @@ constructor( private var experimentId: String? = null private var comparisonExperimentId: String? = null private var summarizeScores: Boolean? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = apply { @@ -110,6 +109,11 @@ constructor( this.summarizeScores = summarizeScores } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -120,29 +124,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -155,33 +172,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ExperimentSummarizeParams = @@ -189,14 +212,8 @@ constructor( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, comparisonExperimentId, summarizeScores, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index ac471ac3..132704ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +27,8 @@ constructor( private val name: String?, private val public_: Boolean?, private val repoInfo: RepoInfo?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -65,9 +65,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -249,9 +249,9 @@ constructor( "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -289,8 +289,8 @@ constructor( private var name: String? = null private var public_: Boolean? = null private var repoInfo: RepoInfo? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -344,6 +344,11 @@ constructor( /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -354,29 +359,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -389,42 +407,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -432,6 +456,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ExperimentUpdateParams = ExperimentUpdateParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, @@ -443,14 +475,8 @@ constructor( name, public_, repoInfo, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 a3d2997d..13801a1a 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 @@ -11,6 +11,8 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.CodeBundle.* @@ -25,8 +27,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -42,8 +42,8 @@ constructor( private val origin: Origin?, private val promptData: PromptData?, private val tags: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -84,9 +84,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = FunctionCreateBody.Builder::class) @NoAutoDetect @@ -262,9 +262,9 @@ constructor( "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -303,8 +303,8 @@ constructor( private var origin: Origin? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -371,6 +371,11 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -381,29 +386,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -416,42 +434,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -459,6 +483,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): FunctionCreateParams = FunctionCreateParams( checkNotNull(functionData) { "`functionData` is required but was not set" }, @@ -471,14 +503,8 @@ constructor( origin, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index b53501f6..6893c593 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class FunctionDeleteParams constructor( private val functionId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var functionId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Function id */ fun functionId(functionId: String) = apply { this.functionId = functionId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): FunctionDeleteParams = FunctionDeleteParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 71f145d8..fbfc004b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -11,6 +11,8 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -25,8 +27,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -39,8 +39,8 @@ constructor( private val parent: Parent?, private val stream: Boolean?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -71,9 +71,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -218,9 +218,9 @@ constructor( "FunctionInvokeBody{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -256,8 +256,8 @@ constructor( private var parent: Parent? = null private var stream: Boolean? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -312,6 +312,11 @@ constructor( /** The version of the function */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -322,29 +327,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -357,42 +375,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -400,6 +424,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): FunctionInvokeParams = FunctionInvokeParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, @@ -409,14 +441,8 @@ constructor( parent, stream, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 03c0839b..43e271b9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -34,8 +33,8 @@ constructor( private val slug: String?, private val startingAfter: String?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -58,28 +57,28 @@ constructor( fun version(): Optional = Optional.ofNullable(version) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.functionName?.let { params.put("function_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.slug?.let { params.put("slug", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.functionName?.let { queryParams.put("function_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.slug?.let { queryParams.put("slug", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -116,8 +115,8 @@ constructor( private var slug: String? = null private var startingAfter: String? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(functionListParams: FunctionListParams) = apply { @@ -197,6 +196,11 @@ constructor( */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -207,29 +211,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -242,33 +259,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): FunctionListParams = @@ -283,14 +306,8 @@ constructor( slug, startingAfter, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } 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 8582f78a..9803f28f 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 @@ -11,6 +11,8 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.CodeBundle.* @@ -25,8 +27,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -42,8 +42,8 @@ constructor( private val origin: Origin?, private val promptData: PromptData?, private val tags: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -84,9 +84,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = FunctionReplaceBody.Builder::class) @NoAutoDetect @@ -262,9 +262,9 @@ constructor( "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -303,8 +303,8 @@ constructor( private var origin: Origin? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -371,6 +371,11 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -381,29 +386,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -416,42 +434,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -459,6 +483,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): FunctionReplaceParams = FunctionReplaceParams( checkNotNull(functionData) { "`functionData` is required but was not set" }, @@ -471,14 +503,8 @@ constructor( origin, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index 89285fff..53a8d298 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class FunctionRetrieveParams constructor( private val functionId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun functionId(): String = functionId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var functionId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(functionRetrieveParams: FunctionRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Function id */ fun functionId(functionId: String) = apply { this.functionId = functionId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): FunctionRetrieveParams = FunctionRetrieveParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index a2030306..a8ad9451 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -11,6 +11,8 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.CodeBundle.* @@ -25,8 +27,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -38,8 +38,8 @@ constructor( private val name: String?, private val promptData: PromptData?, private val tags: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -67,9 +67,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -199,9 +199,9 @@ constructor( "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -236,8 +236,8 @@ constructor( private var name: String? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -292,6 +292,11 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -302,29 +307,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -337,42 +355,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -380,6 +404,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): FunctionUpdateParams = FunctionUpdateParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, @@ -388,14 +420,8 @@ constructor( name, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 2e3ff423..b92715d8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +23,8 @@ constructor( private val memberGroups: List?, private val memberUsers: List?, private val orgName: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -50,9 +50,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = GroupCreateBody.Builder::class) @NoAutoDetect @@ -196,9 +196,9 @@ constructor( "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -232,8 +232,8 @@ constructor( private var memberGroups: MutableList = mutableListOf() private var memberUsers: MutableList = mutableListOf() private var orgName: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -289,6 +289,11 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -299,29 +304,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -334,42 +352,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -377,6 +401,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): GroupCreateParams = GroupCreateParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -384,14 +416,8 @@ constructor( if (memberGroups.size == 0) null else memberGroups.toImmutable(), if (memberUsers.size == 0) null else memberUsers.toImmutable(), orgName, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 3d63e146..ca61cba4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class GroupDeleteParams constructor( private val groupId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var groupId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Group id */ fun groupId(groupId: String) = apply { this.groupId = groupId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): GroupDeleteParams = GroupDeleteParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 7cc1ad3d..26e4a7b2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +29,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -46,24 +45,24 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.groupName?.let { params.put("group_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.groupName?.let { queryParams.put("group_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -96,8 +95,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(groupListParams: GroupListParams) = apply { @@ -156,6 +155,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -166,29 +170,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -201,33 +218,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): GroupListParams = @@ -238,14 +261,8 @@ constructor( limit, orgName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 8c50b24d..4aa47aa2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -23,8 +23,8 @@ constructor( private val memberGroups: List?, private val memberUsers: List?, private val orgName: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -50,9 +50,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = GroupReplaceBody.Builder::class) @NoAutoDetect @@ -196,9 +196,9 @@ constructor( "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -232,8 +232,8 @@ constructor( private var memberGroups: MutableList = mutableListOf() private var memberUsers: MutableList = mutableListOf() private var orgName: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -289,6 +289,11 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -299,29 +304,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -334,42 +352,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -377,6 +401,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): GroupReplaceParams = GroupReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -384,14 +416,8 @@ constructor( if (memberGroups.size == 0) null else memberGroups.toImmutable(), if (memberUsers.size == 0) null else memberUsers.toImmutable(), orgName, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index 9e59ae3a..6c2c4ca9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class GroupRetrieveParams constructor( private val groupId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun groupId(): String = groupId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var groupId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(groupRetrieveParams: GroupRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Group id */ fun groupId(groupId: String) = apply { this.groupId = groupId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): GroupRetrieveParams = GroupRetrieveParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 58f9ed59..cec4e959 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -25,8 +25,8 @@ constructor( private val name: String?, private val removeMemberGroups: List?, private val removeMemberUsers: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -57,9 +57,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -211,9 +211,9 @@ constructor( "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -249,8 +249,8 @@ constructor( private var name: String? = null private var removeMemberGroups: MutableList = mutableListOf() private var removeMemberUsers: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -320,6 +320,11 @@ constructor( this.removeMemberUsers.add(removeMemberUser) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -330,29 +335,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -365,42 +383,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -408,6 +432,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): GroupUpdateParams = GroupUpdateParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, @@ -417,14 +449,8 @@ constructor( name, if (removeMemberGroups.size == 0) null else removeMemberGroups.toImmutable(), if (removeMemberUsers.size == 0) null else removeMemberUsers.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index f65fce38..a50158c1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class OrganizationDeleteParams constructor( private val organizationId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var organizationId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Organization id */ fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): OrganizationDeleteParams = OrganizationDeleteParams( checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index d9063c1e..ab003151 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -29,8 +28,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -43,23 +42,23 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -91,8 +90,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(organizationListParams: OrganizationListParams) = apply { @@ -147,6 +146,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -157,29 +161,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -192,33 +209,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): OrganizationListParams = @@ -228,14 +251,8 @@ constructor( limit, orgName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 072c6d37..0c945564 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -22,8 +22,8 @@ constructor( private val orgId: String?, private val orgName: String?, private val removeUsers: RemoveUsers?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -46,9 +46,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = OrganizationMemberUpdateBody.Builder::class) @NoAutoDetect @@ -179,9 +179,9 @@ constructor( "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -214,8 +214,8 @@ constructor( private var orgId: String? = null private var orgName: String? = null private var removeUsers: RemoveUsers? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -249,6 +249,11 @@ constructor( /** Users to remove from the organization */ fun removeUsers(removeUsers: RemoveUsers) = apply { this.removeUsers = removeUsers } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -259,29 +264,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -294,42 +312,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -337,20 +361,22 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): OrganizationMemberUpdateParams = OrganizationMemberUpdateParams( inviteUsers, orgId, orgName, removeUsers, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 82a8bd73..3ef4e2e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class OrganizationRetrieveParams constructor( private val organizationId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun organizationId(): String = organizationId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var organizationId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Organization id */ fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index fc6a35dc..84441ed9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -24,8 +24,8 @@ constructor( private val name: String?, private val proxyUrl: String?, private val realtimeUrl: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -53,9 +53,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -179,9 +179,9 @@ constructor( "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -216,8 +216,8 @@ constructor( private var name: String? = null private var proxyUrl: String? = null private var realtimeUrl: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -247,6 +247,11 @@ constructor( fun realtimeUrl(realtimeUrl: String) = apply { this.realtimeUrl = realtimeUrl } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -257,29 +262,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -292,42 +310,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -335,6 +359,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): OrganizationUpdateParams = OrganizationUpdateParams( checkNotNull(organizationId) { "`organizationId` is required but was not set" }, @@ -343,14 +375,8 @@ constructor( name, proxyUrl, realtimeUrl, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 59025386..fc4b9fa6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -20,8 +20,8 @@ class ProjectCreateParams constructor( private val name: String, private val orgName: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -38,9 +38,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = ProjectCreateBody.Builder::class) @NoAutoDetect @@ -139,9 +139,9 @@ constructor( "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -172,8 +172,8 @@ constructor( private var name: String? = null private var orgName: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -195,6 +195,11 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -205,29 +210,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -240,42 +258,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -283,18 +307,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectCreateParams = ProjectCreateParams( checkNotNull(name) { "`name` is required but was not set" }, orgName, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 423c82d7..cd8ed199 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ProjectDeleteParams constructor( private val projectId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var projectId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Project id */ fun projectId(projectId: String) = apply { this.projectId = projectId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectDeleteParams = ProjectDeleteParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 85e2029e..a8bb107a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +29,8 @@ constructor( private val orgName: String?, private val projectName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -46,24 +45,24 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -96,8 +95,8 @@ constructor( private var orgName: String? = null private var projectName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(projectListParams: ProjectListParams) = apply { @@ -156,6 +155,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -166,29 +170,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -201,33 +218,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ProjectListParams = @@ -238,14 +261,8 @@ constructor( orgName, projectName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index b0a5f671..67750730 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -5,22 +5,22 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ProjectLogFeedbackParams constructor( private val projectId: String, private val feedback: List, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -33,9 +33,9 @@ constructor( return ProjectLogFeedbackBody(feedback, additionalBodyProperties) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -126,9 +126,9 @@ constructor( "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -159,8 +159,8 @@ constructor( private var projectId: String? = null private var feedback: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -184,6 +184,11 @@ constructor( /** A list of project logs feedback items */ fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { this.feedback.add(feedback) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -194,29 +199,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -229,42 +247,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -272,18 +296,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 672f8c76..7d62f4eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -3,10 +3,9 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -17,8 +16,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun projectId(): String = projectId @@ -31,17 +30,17 @@ constructor( fun version(): Optional = Optional.ofNullable(version) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -51,9 +50,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -85,8 +84,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(projectLogFetchParams: ProjectLogFetchParams) = apply { @@ -155,6 +154,11 @@ constructor( */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -165,29 +169,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -200,33 +217,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ProjectLogFetchParams = @@ -236,14 +259,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 7ae62080..a2fa80bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -25,8 +25,8 @@ constructor( private val maxRootSpanId: String?, private val maxXactId: String?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -57,9 +57,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -308,9 +308,9 @@ constructor( "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -346,8 +346,8 @@ constructor( private var maxRootSpanId: String? = null private var maxXactId: String? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -452,6 +452,11 @@ constructor( */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -462,29 +467,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -497,42 +515,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -540,6 +564,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectLogFetchPostParams = ProjectLogFetchPostParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, @@ -549,14 +581,8 @@ constructor( maxRootSpanId, maxXactId, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index efc37d16..ae1211cc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -8,6 +8,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -21,8 +23,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +30,8 @@ class ProjectLogInsertParams constructor( private val projectId: String, private val events: List, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -44,9 +44,9 @@ constructor( return ProjectLogInsertBody(events, additionalBodyProperties) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -133,9 +133,9 @@ constructor( "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -166,8 +166,8 @@ constructor( private var projectId: String? = null private var events: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -191,6 +191,11 @@ constructor( /** A list of project logs events to insert */ fun addEvent(event: Event) = apply { this.events.add(event) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -201,29 +206,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -236,42 +254,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -279,18 +303,20 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectLogInsertParams = ProjectLogInsertParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index bc39a96a..a5f686d8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ProjectRetrieveParams constructor( private val projectId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun projectId(): String = projectId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var projectId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(projectRetrieveParams: ProjectRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Project id */ fun projectId(projectId: String) = apply { this.projectId = projectId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ProjectRetrieveParams = ProjectRetrieveParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } 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 cdf5c6ad..237a7440 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 @@ -8,6 +8,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -20,8 +22,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -33,8 +33,8 @@ constructor( private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -63,9 +63,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams /** A project score is a user-configured score, which can be manually-labeled through the UI */ @JsonDeserialize(builder = ProjectScoreCreateBody.Builder::class) @@ -199,9 +199,9 @@ constructor( "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -236,8 +236,8 @@ constructor( private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -290,6 +290,11 @@ constructor( /** Textual description of the project score */ fun description(description: String) = apply { this.description = description } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -300,29 +305,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -335,42 +353,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -378,6 +402,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectScoreCreateParams = ProjectScoreCreateParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -386,14 +418,8 @@ constructor( categories, config, description, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 20e82350..1b8a417f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ProjectScoreDeleteParams constructor( private val projectScoreId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var projectScoreId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** ProjectScore id */ fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 419b144f..40ba8c94 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 @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -33,8 +32,8 @@ constructor( private val projectScoreName: String?, private val scoreType: ScoreType?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -55,27 +54,27 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.projectScoreName?.let { params.put("project_score_name", listOf(it.toString())) } - this.scoreType?.let { params.put("score_type", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.projectScoreName?.let { queryParams.put("project_score_name", listOf(it.toString())) } + this.scoreType?.let { queryParams.put("score_type", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -111,8 +110,8 @@ constructor( private var projectScoreName: String? = null private var scoreType: ScoreType? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(projectScoreListParams: ProjectScoreListParams) = apply { @@ -195,6 +194,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -205,29 +209,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -240,33 +257,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ProjectScoreListParams = @@ -280,14 +303,8 @@ constructor( projectScoreName, scoreType, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } 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 3c2518ed..6b7d82d6 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 @@ -8,6 +8,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -20,8 +22,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -33,8 +33,8 @@ constructor( private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -63,9 +63,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams /** A project score is a user-configured score, which can be manually-labeled through the UI */ @JsonDeserialize(builder = ProjectScoreReplaceBody.Builder::class) @@ -199,9 +199,9 @@ constructor( "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -236,8 +236,8 @@ constructor( private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -290,6 +290,11 @@ constructor( /** Textual description of the project score */ fun description(description: String) = apply { this.description = description } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -300,29 +305,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -335,42 +353,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -378,6 +402,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectScoreReplaceParams = ProjectScoreReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -386,14 +418,8 @@ constructor( categories, config, description, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 6f4e12e9..963b0cee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ProjectScoreRetrieveParams constructor( private val projectScoreId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun projectScoreId(): String = projectScoreId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var projectScoreId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** ProjectScore id */ fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } 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 0b4132e5..b6e0e621 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 @@ -8,6 +8,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -20,8 +22,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -33,8 +33,8 @@ constructor( private val description: String?, private val name: String?, private val scoreType: ProjectScoreType?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -62,9 +62,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -194,9 +194,9 @@ constructor( "ProjectScoreUpdateBody{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -231,8 +231,8 @@ constructor( private var description: String? = null private var name: String? = null private var scoreType: ProjectScoreType? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -285,6 +285,11 @@ constructor( /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -295,29 +300,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -330,42 +348,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -373,6 +397,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectScoreUpdateParams = ProjectScoreUpdateParams( checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, @@ -381,14 +413,8 @@ constructor( description, name, scoreType, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 6d572736..9321520d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -22,8 +22,8 @@ constructor( private val projectId: String, private val color: String?, private val description: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -46,9 +46,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = ProjectTagCreateBody.Builder::class) @NoAutoDetect @@ -160,9 +160,9 @@ constructor( "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -195,8 +195,8 @@ constructor( private var projectId: String? = null private var color: String? = null private var description: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -222,6 +222,11 @@ constructor( /** Textual description of the project tag */ fun description(description: String) = apply { this.description = description } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -232,29 +237,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -267,42 +285,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -310,20 +334,22 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectTagCreateParams = ProjectTagCreateParams( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, color, description, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 33c4ee34..34a96215 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class ProjectTagDeleteParams constructor( private val projectTagId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var projectTagId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** ProjectTag id */ fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 4b5bb3b1..b7d71d99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -32,8 +31,8 @@ constructor( private val projectName: String?, private val projectTagName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -52,26 +51,26 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.projectTagName?.let { params.put("project_tag_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.projectTagName?.let { queryParams.put("project_tag_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -106,8 +105,8 @@ constructor( private var projectName: String? = null private var projectTagName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(projectTagListParams: ProjectTagListParams) = apply { @@ -174,6 +173,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -184,29 +188,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -219,33 +236,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ProjectTagListParams = @@ -258,14 +281,8 @@ constructor( projectName, projectTagName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index 999d0053..a8b692f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -22,8 +22,8 @@ constructor( private val projectId: String, private val color: String?, private val description: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -46,9 +46,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = ProjectTagReplaceBody.Builder::class) @NoAutoDetect @@ -160,9 +160,9 @@ constructor( "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -195,8 +195,8 @@ constructor( private var projectId: String? = null private var color: String? = null private var description: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -222,6 +222,11 @@ constructor( /** Textual description of the project tag */ fun description(description: String) = apply { this.description = description } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -232,29 +237,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -267,42 +285,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -310,20 +334,22 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectTagReplaceParams = ProjectTagReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, color, description, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 2230b362..44302f60 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ProjectTagRetrieveParams constructor( private val projectTagId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun projectTagId(): String = projectTagId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var projectTagId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** ProjectTag id */ fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index ae81927d..7cfcd4bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -22,8 +22,8 @@ constructor( private val color: String?, private val description: String?, private val name: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -45,9 +45,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -155,9 +155,9 @@ constructor( "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -190,8 +190,8 @@ constructor( private var color: String? = null private var description: String? = null private var name: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -217,6 +217,11 @@ constructor( /** Name of the project tag */ fun name(name: String) = apply { this.name = name } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -227,29 +232,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -262,42 +280,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -305,20 +329,22 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectTagUpdateParams = ProjectTagUpdateParams( checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, color, description, name, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index ad726f9c..2d75d5c2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -21,8 +21,8 @@ constructor( private val projectId: String, private val name: String?, private val settings: ProjectSettings?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -41,9 +41,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -147,9 +147,9 @@ constructor( "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -181,8 +181,8 @@ constructor( private var projectId: String? = null private var name: String? = null private var settings: ProjectSettings? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -207,6 +207,11 @@ constructor( */ fun settings(settings: ProjectSettings) = apply { this.settings = settings } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -217,29 +222,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -252,42 +270,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -295,19 +319,21 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ProjectUpdateParams = ProjectUpdateParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, name, settings, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index aee368d7..2d136623 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -29,8 +29,8 @@ constructor( private val functionType: FunctionType?, private val promptData: PromptData?, private val tags: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -62,9 +62,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = PromptCreateBody.Builder::class) @NoAutoDetect @@ -208,9 +208,9 @@ constructor( "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -246,8 +246,8 @@ constructor( private var functionType: FunctionType? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -290,6 +290,11 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -300,29 +305,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -335,42 +353,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -378,6 +402,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): PromptCreateParams = PromptCreateParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -387,14 +419,8 @@ constructor( functionType, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 5ab56d93..7762e85a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class PromptDeleteParams constructor( private val promptId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var promptId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Prompt id */ fun promptId(promptId: String) = apply { this.promptId = promptId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): PromptDeleteParams = PromptDeleteParams( checkNotNull(promptId) { "`promptId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index cb46ad9e..12a3ed32 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -34,8 +33,8 @@ constructor( private val slug: String?, private val startingAfter: String?, private val version: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -58,28 +57,28 @@ constructor( fun version(): Optional = Optional.ofNullable(version) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.promptName?.let { params.put("prompt_name", listOf(it.toString())) } - this.slug?.let { params.put("slug", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.promptName?.let { queryParams.put("prompt_name", listOf(it.toString())) } + this.slug?.let { queryParams.put("slug", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -116,8 +115,8 @@ constructor( private var slug: String? = null private var startingAfter: String? = null private var version: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(promptListParams: PromptListParams) = apply { @@ -197,6 +196,11 @@ constructor( */ fun version(version: String) = apply { this.version = version } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -207,29 +211,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -242,33 +259,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): PromptListParams = @@ -283,14 +306,8 @@ constructor( slug, startingAfter, version, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 4411e224..d56b8967 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -29,8 +29,8 @@ constructor( private val functionType: FunctionType?, private val promptData: PromptData?, private val tags: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -62,9 +62,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = PromptReplaceBody.Builder::class) @NoAutoDetect @@ -208,9 +208,9 @@ constructor( "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -246,8 +246,8 @@ constructor( private var functionType: FunctionType? = null private var promptData: PromptData? = null private var tags: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -290,6 +290,11 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -300,29 +305,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -335,42 +353,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -378,6 +402,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): PromptReplaceParams = PromptReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -387,14 +419,8 @@ constructor( functionType, promptData, if (tags.size == 0) null else tags.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index a58b30f3..e664bced 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class PromptRetrieveParams constructor( private val promptId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun promptId(): String = promptId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var promptId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(promptRetrieveParams: PromptRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Prompt id */ fun promptId(promptId: String) = apply { this.promptId = promptId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): PromptRetrieveParams = PromptRetrieveParams( checkNotNull(promptId) { "`promptId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index b9608ed6..70a69e55 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -5,14 +5,14 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -24,8 +24,8 @@ constructor( private val promptData: PromptData?, private val slug: String?, private val tags: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -53,9 +53,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -184,9 +184,9 @@ constructor( "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -221,8 +221,8 @@ constructor( private var promptData: PromptData? = null private var slug: String? = null private var tags: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -262,6 +262,11 @@ constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { this.tags.add(tag) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -272,29 +277,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -307,42 +325,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -350,6 +374,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): PromptUpdateParams = PromptUpdateParams( checkNotNull(promptId) { "`promptId` is required but was not set" }, @@ -358,14 +390,8 @@ constructor( promptData, slug, if (tags.size == 0) null else tags.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 c5f3ad80..ad873cf6 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +27,8 @@ constructor( private val memberPermissions: List?, private val memberRoles: List?, private val orgName: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -55,9 +55,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = RoleCreateBody.Builder::class) @NoAutoDetect @@ -202,9 +202,9 @@ constructor( "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -238,8 +238,8 @@ constructor( private var memberPermissions: MutableList = mutableListOf() private var memberRoles: MutableList = mutableListOf() private var orgName: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -297,6 +297,11 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -307,29 +312,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -342,42 +360,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -385,6 +409,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): RoleCreateParams = RoleCreateParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -392,14 +424,8 @@ constructor( if (memberPermissions.size == 0) null else memberPermissions.toImmutable(), if (memberRoles.size == 0) null else memberRoles.toImmutable(), orgName, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 92f3fde6..811df939 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -4,18 +4,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional class RoleDeleteParams constructor( private val roleId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -26,9 +26,9 @@ constructor( return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -37,9 +37,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -69,8 +69,8 @@ constructor( class Builder { private var roleId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,6 +84,11 @@ constructor( /** Role id */ fun roleId(roleId: String) = apply { this.roleId = roleId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -94,29 +99,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -129,42 +147,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -172,17 +196,19 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): RoleDeleteParams = RoleDeleteParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index e9567b53..96d37f2c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +29,8 @@ constructor( private val orgName: String?, private val roleName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -46,24 +45,24 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.roleName?.let { params.put("role_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.roleName?.let { queryParams.put("role_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -96,8 +95,8 @@ constructor( private var orgName: String? = null private var roleName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(roleListParams: RoleListParams) = apply { @@ -156,6 +155,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -166,29 +170,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -201,33 +218,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): RoleListParams = @@ -238,14 +261,8 @@ constructor( orgName, roleName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } 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 438eda1b..22623159 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -27,8 +27,8 @@ constructor( private val memberPermissions: List?, private val memberRoles: List?, private val orgName: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -55,9 +55,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = RoleReplaceBody.Builder::class) @NoAutoDetect @@ -202,9 +202,9 @@ constructor( "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -238,8 +238,8 @@ constructor( private var memberPermissions: MutableList = mutableListOf() private var memberRoles: MutableList = mutableListOf() private var orgName: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -297,6 +297,11 @@ constructor( */ fun orgName(orgName: String) = apply { this.orgName = orgName } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -307,29 +312,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -342,42 +360,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -385,6 +409,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): RoleReplaceParams = RoleReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -392,14 +424,8 @@ constructor( if (memberPermissions.size == 0) null else memberPermissions.toImmutable(), if (memberRoles.size == 0) null else memberRoles.toImmutable(), orgName, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index b419c81e..f5a74fb3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class RoleRetrieveParams constructor( private val roleId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun roleId(): String = roleId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var roleId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(roleRetrieveParams: RoleRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** Role id */ fun roleId(roleId: String) = apply { this.roleId = roleId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): RoleRetrieveParams = RoleRetrieveParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } 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 99271e9e..2c50afe7 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -29,8 +29,8 @@ constructor( private val name: String?, private val removeMemberPermissions: List?, private val removeMemberRoles: List?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -63,9 +63,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -219,9 +219,9 @@ constructor( "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -257,8 +257,8 @@ constructor( private var name: String? = null private var removeMemberPermissions: MutableList = mutableListOf() private var removeMemberRoles: MutableList = mutableListOf() - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -328,6 +328,11 @@ constructor( this.removeMemberRoles.add(removeMemberRole) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -338,29 +343,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -373,42 +391,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -416,6 +440,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): RoleUpdateParams = RoleUpdateParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, @@ -426,14 +458,8 @@ constructor( if (removeMemberPermissions.size == 0) null else removeMemberPermissions.toImmutable(), if (removeMemberRoles.size == 0) null else removeMemberRoles.toImmutable(), - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index deb37c20..ceb54600 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -3,25 +3,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class TopLevelHelloWorldParams constructor( - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -48,8 +47,8 @@ constructor( @NoAutoDetect class Builder { - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = apply { @@ -57,6 +56,11 @@ constructor( additionalQueryParams(topLevelHelloWorldParams.additionalQueryParams) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -67,29 +71,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -102,45 +119,42 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): TopLevelHelloWorldParams = - TopLevelHelloWorldParams( - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable() - ) + TopLevelHelloWorldParams(additionalHeaders.build(), additionalQueryParams.build()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 949c1ba2..f6db409d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -7,7 +7,8 @@ import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator @@ -17,8 +18,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -32,8 +31,8 @@ constructor( private val limit: Long?, private val orgName: String?, private val startingAfter: String?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun email(): Optional = Optional.ofNullable(email) @@ -52,26 +51,26 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.email?.let { params.put("email", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.familyName?.let { params.put("family_name", listOf(it.toString())) } - this.givenName?.let { params.put("given_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.email?.let { queryParams.put("email", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.familyName?.let { queryParams.put("family_name", listOf(it.toString())) } + this.givenName?.let { queryParams.put("given_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -106,8 +105,8 @@ constructor( private var limit: Long? = null private var orgName: String? = null private var startingAfter: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(userListParams: UserListParams) = apply { @@ -223,6 +222,11 @@ constructor( */ fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -233,29 +237,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -268,33 +285,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): UserListParams = @@ -307,14 +330,8 @@ constructor( limit, orgName, startingAfter, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 0ef3a94e..4b7e3af7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -3,24 +3,23 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class UserRetrieveParams constructor( private val userId: String, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun userId(): String = userId - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -29,9 +28,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -59,8 +58,8 @@ constructor( class Builder { private var userId: String? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(userRetrieveParams: UserRetrieveParams) = apply { @@ -72,6 +71,11 @@ constructor( /** User id */ fun userId(userId: String) = apply { this.userId = userId } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -82,29 +86,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -117,46 +134,46 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): UserRetrieveParams = UserRetrieveParams( checkNotNull(userId) { "`userId` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } } 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 b3c69ae5..1db69dfc 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -31,8 +31,8 @@ constructor( private val options: ViewOptions?, private val userId: String?, private val viewData: ViewData?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -67,9 +67,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = ViewCreateBody.Builder::class) @NoAutoDetect @@ -225,9 +225,9 @@ constructor( "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -264,8 +264,8 @@ constructor( private var options: ViewOptions? = null private var userId: String? = null private var viewData: ViewData? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -307,6 +307,11 @@ constructor( /** The view definition */ fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -317,29 +322,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -352,42 +370,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -395,6 +419,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ViewCreateParams = ViewCreateParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -405,14 +437,8 @@ constructor( options, userId, viewData, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 6de0c612..2e29f940 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ViewDeleteParams @@ -24,8 +24,8 @@ constructor( private val viewId: String, private val objectId: String, private val objectType: ObjectType, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -44,9 +44,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -145,9 +145,9 @@ constructor( "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -179,8 +179,8 @@ constructor( private var viewId: String? = null private var objectId: String? = null private var objectType: ObjectType? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -202,6 +202,11 @@ constructor( /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -212,29 +217,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -247,42 +265,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -290,19 +314,21 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ViewDeleteParams = ViewDeleteParams( checkNotNull(viewId) { "`viewId` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 0a61d97d..fbfbab78 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 @@ -9,7 +9,8 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator @@ -20,8 +21,6 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -35,8 +34,8 @@ constructor( private val startingAfter: String?, private val viewName: String?, private val viewType: ViewType?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun objectId(): String = objectId @@ -55,26 +54,26 @@ constructor( fun viewType(): Optional = Optional.ofNullable(viewType) - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { params.put("object_id", listOf(it.toString())) } - this.objectType.let { params.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - this.viewName?.let { params.put("view_name", listOf(it.toString())) } - this.viewType?.let { params.put("view_type", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } + this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + this.viewName?.let { queryParams.put("view_name", listOf(it.toString())) } + this.viewType?.let { queryParams.put("view_type", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -109,8 +108,8 @@ constructor( private var startingAfter: String? = null private var viewName: String? = null private var viewType: ViewType? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(viewListParams: ViewListParams) = apply { @@ -177,6 +176,11 @@ constructor( /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -187,29 +191,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -222,33 +239,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ViewListParams = @@ -261,14 +284,8 @@ constructor( startingAfter, viewName, viewType, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } 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 948ec85e..3ec104a8 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -31,8 +31,8 @@ constructor( private val options: ViewOptions?, private val userId: String?, private val viewData: ViewData?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -67,9 +67,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @JsonDeserialize(builder = ViewReplaceBody.Builder::class) @NoAutoDetect @@ -225,9 +225,9 @@ constructor( "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -264,8 +264,8 @@ constructor( private var options: ViewOptions? = null private var userId: String? = null private var viewData: ViewData? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -307,6 +307,11 @@ constructor( /** The view definition */ fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -317,29 +322,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -352,42 +370,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -395,6 +419,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ViewReplaceParams = ViewReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, @@ -405,14 +437,8 @@ constructor( options, userId, viewData, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } 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 a3efb22d..e88ec622 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 @@ -6,12 +6,11 @@ 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.toImmutable +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects class ViewRetrieveParams @@ -19,8 +18,8 @@ constructor( private val viewId: String, private val objectId: String, private val objectType: ObjectType, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, ) { fun viewId(): String = viewId @@ -29,15 +28,15 @@ constructor( fun objectType(): ObjectType = objectType - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { params.put("object_id", listOf(it.toString())) } - this.objectType.let { params.put("object_type", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toImmutable() + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } + this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { @@ -47,9 +46,9 @@ constructor( } } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -79,8 +78,8 @@ constructor( private var viewId: String? = null private var objectId: String? = null private var objectType: ObjectType? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(viewRetrieveParams: ViewRetrieveParams) = apply { @@ -100,6 +99,11 @@ constructor( /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -110,29 +114,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -145,33 +162,39 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun build(): ViewRetrieveParams = @@ -179,14 +202,8 @@ constructor( checkNotNull(viewId) { "`viewId` is required but was not set" }, checkNotNull(objectId) { "`objectId` is required but was not set" }, checkNotNull(objectType) { "`objectType` is required but was not set" }, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } 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 6dae3f4f..b95d336e 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 @@ -7,6 +7,8 @@ import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* @@ -15,8 +17,6 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.google.common.collect.ArrayListMultimap -import com.google.common.collect.ListMultimap import java.util.Objects import java.util.Optional @@ -30,8 +30,8 @@ constructor( private val userId: String?, private val viewData: ViewData?, private val viewType: ViewType?, - private val additionalHeaders: Map>, - private val additionalQueryParams: Map>, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) { @@ -65,9 +65,9 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -219,9 +219,9 @@ constructor( "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Map> = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - fun _additionalQueryParams(): Map> = additionalQueryParams + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -258,8 +258,8 @@ constructor( private var userId: String? = null private var viewData: ViewData? = null private var viewType: ViewType? = null - private var additionalHeaders: ListMultimap = ArrayListMultimap.create() - private var additionalQueryParams: ListMultimap = ArrayListMultimap.create() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -301,6 +301,11 @@ constructor( /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + fun additionalHeaders(additionalHeaders: Map>) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -311,29 +316,42 @@ constructor( } fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.putAll(name, values) + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::putAdditionalHeaders) + this.additionalHeaders.putAll(additionalHeaders) } fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replaceValues(name, listOf(value)) + additionalHeaders.replace(name, value) } fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replaceValues(name, values) + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(::replaceAdditionalHeaders) + this.additionalHeaders.replaceAll(additionalHeaders) } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.removeAll(name) } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } fun removeAllAdditionalHeaders(names: Set) = apply { - names.forEach(::removeAdditionalHeaders) + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) } fun additionalQueryParams(additionalQueryParams: Map>) = apply { @@ -346,42 +364,48 @@ constructor( } fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.putAll(key, values) + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::putAdditionalQueryParams) + this.additionalQueryParams.putAll(additionalQueryParams) } fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replaceValues(key, listOf(value)) + additionalQueryParams.replace(key, value) } fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replaceValues(key, values) + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(::replaceAdditionalQueryParams) + this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { - additionalQueryParams.removeAll(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } fun removeAllAdditionalQueryParams(keys: Set) = apply { - keys.forEach(::removeAdditionalQueryParams) + additionalQueryParams.removeAll(keys) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) + putAllAdditionalBodyProperties(additionalBodyProperties) } fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) + additionalBodyProperties.put(key, value) } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = @@ -389,6 +413,14 @@ constructor( this.additionalBodyProperties.putAll(additionalBodyProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + fun build(): ViewUpdateParams = ViewUpdateParams( checkNotNull(viewId) { "`viewId` is required but was not set" }, @@ -399,14 +431,8 @@ constructor( userId, viewData, viewType, - additionalHeaders - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), - additionalQueryParams - .asMap() - .mapValues { it.value.toList().toImmutable() } - .toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 0779d5ef..32a8700c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -45,9 +45,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -75,9 +75,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -108,9 +108,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -138,9 +138,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -171,9 +171,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl", "batch-update") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -201,9 +201,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index 9b2ca289..eb4a1a92 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -45,9 +45,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -75,9 +75,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -108,9 +108,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -142,9 +142,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -172,9 +172,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -202,9 +202,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -235,9 +235,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index b765ea25..3eb4c34e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -43,9 +43,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -73,9 +73,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -106,9 +106,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -136,9 +136,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index dd899f0b..6e3ff5f3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -52,9 +52,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -82,9 +82,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -115,9 +115,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -149,9 +149,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -179,9 +179,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -209,9 +209,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -243,9 +243,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -276,9 +276,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -306,9 +306,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -337,9 +337,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index 7fc576fe..7a62395d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -44,9 +44,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -74,9 +74,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -107,9 +107,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -140,9 +140,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -169,9 +169,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -202,9 +202,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index 7e36490c..441ad750 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -42,9 +42,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "eval") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 97ae98d9..85cf7c39 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -52,9 +52,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -82,9 +82,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -115,9 +115,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -149,9 +149,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -179,9 +179,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -209,9 +209,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -243,9 +243,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -276,9 +276,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -306,9 +306,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -337,9 +337,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 8a4c14fa..8c1ebb62 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -46,9 +46,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -76,9 +76,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -109,9 +109,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -143,9 +143,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -173,9 +173,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -203,9 +203,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -231,9 +231,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index cbf816b0..ee69b25e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -44,9 +44,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -74,9 +74,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -107,9 +107,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -141,9 +141,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -171,9 +171,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -204,9 +204,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index a39ecc9c..c4901660 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -45,9 +45,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -78,9 +78,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -112,9 +112,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -142,9 +142,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index a96f8bbe..ae17a3a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -45,9 +45,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -75,9 +75,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -108,9 +108,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -142,9 +142,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -172,9 +172,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -206,9 +206,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index 33b735d2..f7a7a8e2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -49,9 +49,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -79,9 +79,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -112,9 +112,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -146,9 +146,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -176,9 +176,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index 7ca246a4..08ee7044 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -44,9 +44,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -74,9 +74,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -107,9 +107,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -141,9 +141,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -171,9 +171,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -205,9 +205,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 8a9723a2..83b6a06f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -44,9 +44,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -74,9 +74,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -107,9 +107,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -141,9 +141,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -171,9 +171,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -204,9 +204,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index d113a03d..386cecbc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -44,9 +44,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -74,9 +74,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -107,9 +107,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -141,9 +141,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -171,9 +171,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -204,9 +204,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index cac07a65..68b9e154 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -32,9 +32,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 03cbbf79..fb6da392 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -36,9 +36,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -69,9 +69,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 79da3e5d..f0f3ced4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -44,9 +44,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -74,9 +74,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -107,9 +107,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -141,9 +141,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -171,9 +171,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -204,9 +204,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 89348dae..4597e448 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -36,9 +36,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 82fb7f12..c670e0aa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -40,9 +40,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -74,9 +74,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response @@ -107,9 +107,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -137,9 +137,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index b5a947e5..0d325f0c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -41,9 +41,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -67,9 +67,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -95,9 +95,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -121,9 +121,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -153,9 +153,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl", "batch-update") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -182,9 +182,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index 9f5ce473..d13101d7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -41,9 +41,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -70,9 +70,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -99,9 +99,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -132,9 +132,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -158,9 +158,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -187,9 +187,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -216,9 +216,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index 56c2de94..63e0f79d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -42,9 +42,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -68,9 +68,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -97,9 +97,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -123,9 +123,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index deb7df96..24f60d84 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -48,9 +48,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -74,9 +74,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -103,9 +103,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -133,9 +133,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -159,9 +159,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -188,9 +188,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -221,9 +221,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -253,9 +253,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -282,9 +282,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -312,9 +312,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index 56381c22..ba1b5b89 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -40,9 +40,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -66,9 +66,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -95,9 +95,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -127,9 +127,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -152,9 +152,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -181,9 +181,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index 9ea44d18..3f1e2147 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -41,9 +41,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "eval") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 158ffd38..4ba8e72b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -51,9 +51,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -80,9 +80,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -112,9 +112,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -145,9 +145,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -174,9 +174,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -203,9 +203,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -236,9 +236,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -268,9 +268,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -297,9 +297,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -327,9 +327,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 57b63f36..8e2ff2ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -42,9 +42,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -71,9 +71,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -100,9 +100,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -133,9 +133,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -159,9 +159,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -188,9 +188,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -212,9 +212,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 59e96aa0..8f0f3c23 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -40,9 +40,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -66,9 +66,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -95,9 +95,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -124,9 +124,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -150,9 +150,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -179,9 +179,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index 8adea90e..3a0795fc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -44,9 +44,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -76,9 +76,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -109,9 +109,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -138,9 +138,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index f1fc18f7..0dd24e78 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -44,9 +44,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -73,9 +73,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -105,9 +105,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -138,9 +138,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -167,9 +167,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -200,9 +200,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 487799ec..2cb38111 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -45,9 +45,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -71,9 +71,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -100,9 +100,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -130,9 +130,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -156,9 +156,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 6358af7a..1246432d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -43,9 +43,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -72,9 +72,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -104,9 +104,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -137,9 +137,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -166,9 +166,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -199,9 +199,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index 94e8e0be..93acdfe1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -40,9 +40,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -66,9 +66,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -95,9 +95,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -125,9 +125,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -151,9 +151,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -180,9 +180,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 81314aae..60cfc01e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -40,9 +40,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -66,9 +66,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -95,9 +95,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -124,9 +124,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -150,9 +150,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -179,9 +179,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index c20802be..f6dc73dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -31,9 +31,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index dfb59811..79360d9b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -32,9 +32,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -60,9 +60,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 62f6abff..4747d2fd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -40,9 +40,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -66,9 +66,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -95,9 +95,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -124,9 +124,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -150,9 +150,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -179,9 +179,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index 5777be65..7f8086ba 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -35,9 +35,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 1cd65e5c..677368f8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -39,9 +39,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -72,9 +72,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .build() return clientOptions.httpClient.execute(request, requestOptions).let { response -> @@ -104,9 +104,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() @@ -133,9 +133,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams.asMap()) + .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers.asMap()) + .putAllHeaders(clientOptions.headers) .replaceAllHeaders(params.getHeaders()) .body(json(clientOptions.jsonMapper, params.getBody())) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt deleted file mode 100755 index 8c937928..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.braintrustdata.api.core.http - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class HttpRequestTest { - - @Test - fun caseInsensitiveHeadersAccessors() { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .putHeader("something_lowercase", "lowercase") - .putHeader("Something_Capitalized", "Capitalized") - .putHeader("SOMETHING_UPPERCASE", "UPPERCASE") - .build() - assertThat(request.headers.get("SOMETHING_LOWERCASE").getOrNull(0)).isEqualTo("lowercase") - assertThat(request.headers.get("something_capitalized").getOrNull(0)) - .isEqualTo("Capitalized") - assertThat(request.headers.get("Something_Uppercase").getOrNull(0)).isEqualTo("UPPERCASE") - } -} 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 cc02b4b4..0953fa59 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,17 +32,17 @@ class AclListParamsTest { .limit(123L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(AclListParams.ObjectType.ORGANIZATION.toString())) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -51,9 +52,9 @@ class AclListParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclListParams.ObjectType.ORGANIZATION) .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(AclListParams.ObjectType.ORGANIZATION.toString())) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt index 27820e93..bb1dd611 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -33,29 +34,27 @@ class AiSecretListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("ai_secret_name", listOf("ai_secret_name")) + val expected = QueryParams.builder() + expected.put("ai_secret_name", "ai_secret_name") expected.put( "ai_secret_type", - listOf(AiSecretListParams.AiSecretType.ofString("string").toString()) + AiSecretListParams.AiSecretType.ofString("string").toString() ) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf( - AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) + AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = AiSecretListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index e749c8e0..10c5936f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,23 +32,23 @@ class ApiKeyListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("api_key_name", listOf("api_key_name")) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("api_key_name", "api_key_name") + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ApiKeyListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index 260bb3bb..cc537185 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,20 +30,20 @@ class DatasetFetchParamsTest { .maxXactId("max_xact_id") .version("version") .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("limit", "123") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index d0963d5e..89973320 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -35,27 +36,25 @@ class DatasetListParamsTest { .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("dataset_name", listOf("dataset_name")) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("dataset_name", "dataset_name") + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf( - DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) + DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = DatasetListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index db5cbef2..a4d6224d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -23,9 +24,9 @@ class DatasetSummarizeParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .summarizeData(true) .build() - val expected = mutableMapOf>() - expected.put("summarize_data", listOf("true")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("summarize_data", "true") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -34,8 +35,8 @@ class DatasetSummarizeParamsTest { DatasetSummarizeParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test 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 f95a36d6..7c9ac87b 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,22 +30,22 @@ class EnvVarListParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarListParams.ObjectType.ORGANIZATION) .build() - val expected = mutableMapOf>() - expected.put("env_var_name", listOf("env_var_name")) + val expected = QueryParams.builder() + expected.put("env_var_name", "env_var_name") expected.put( "ids", - listOf(EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(EnvVarListParams.ObjectType.ORGANIZATION.toString())) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = EnvVarListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index 138cbb6a..65cde54d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,12 +30,12 @@ class ExperimentFetchParamsTest { .maxXactId("max_xact_id") .version("version") .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("limit", "123") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -43,8 +44,8 @@ class ExperimentFetchParamsTest { ExperimentFetchParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 2168e880..738a0197 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -35,27 +36,25 @@ class ExperimentListParamsTest { .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("experiment_name", listOf("experiment_name")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("experiment_name", "experiment_name") expected.put( "ids", - listOf( - ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) + ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ExperimentListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index d813806c..fe05c8ec 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -25,10 +26,10 @@ class ExperimentSummarizeParamsTest { .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .summarizeScores(true) .build() - val expected = mutableMapOf>() - expected.put("comparison_experiment_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("summarize_scores", listOf("true")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("summarize_scores", "true") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -37,8 +38,8 @@ class ExperimentSummarizeParamsTest { ExperimentSummarizeParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 5e560da4..7593f144 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -39,29 +40,27 @@ class FunctionListParamsTest { .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .version("version") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("function_name", listOf("function_name")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("function_name", "function_name") expected.put( "ids", - listOf( - FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) + FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("slug", listOf("slug")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("slug", "slug") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("version", "version") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = FunctionListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index 33587c15..6953b0c4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,23 +32,23 @@ class GroupListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("group_name", listOf("group_name")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("group_name", "group_name") expected.put( "ids", - listOf(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = GroupListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index 59b904b0..d62a5248 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,25 +30,22 @@ class OrganizationListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf( - OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .toString() - ) + OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = OrganizationListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 233ceaa7..33006eaa 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,25 +32,23 @@ class ProjectListParamsTest { .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf( - ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) + ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ProjectListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index c84026c0..16937d36 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,12 +30,12 @@ class ProjectLogFetchParamsTest { .maxXactId("max_xact_id") .version("version") .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("limit", "123") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -43,8 +44,8 @@ class ProjectLogFetchParamsTest { ProjectLogFetchParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test 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 7832ecb6..07d5dd28 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -39,35 +40,32 @@ class ProjectScoreListParamsTest { ) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf( - ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .toString() - ) + ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("project_score_name", listOf("project_score_name")) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("project_score_name", "project_score_name") expected.put( "score_type", - listOf( + ProjectScoreListParams.ScoreType.ofProjectScoreType(ProjectScoreType.SLIDER) .toString() - ) + ) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ProjectScoreListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index 091272bb..09aa0048 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -35,27 +36,25 @@ class ProjectTagListParamsTest { .projectTagName("project_tag_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf( - ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) + ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("project_tag_name", listOf("project_tag_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("project_tag_name", "project_tag_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = ProjectTagListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index a2c57163..81adc194 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -39,27 +40,27 @@ class PromptListParamsTest { .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .version("version") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("prompt_name", listOf("prompt_name")) - expected.put("slug", listOf("slug")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("prompt_name", "prompt_name") + expected.put("slug", "slug") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("version", "version") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = PromptListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 2db9679b..1080806c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,23 +32,23 @@ class RoleListParamsTest { .roleName("role_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("role_name", listOf("role_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("role_name", "role_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = RoleListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 45d5d6ce..fa8ed3a0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -35,25 +36,25 @@ class UserListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = mutableMapOf>() - expected.put("email", listOf(UserListParams.Email.ofString("string").toString())) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("family_name", listOf(UserListParams.FamilyName.ofString("string").toString())) - expected.put("given_name", listOf(UserListParams.GivenName.ofString("string").toString())) + val expected = QueryParams.builder() + expected.put("email", UserListParams.Email.ofString("string").toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("family_name", UserListParams.FamilyName.ofString("string").toString()) + expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) expected.put( "ids", - listOf(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test fun getQueryParamsWithoutOptionalFields() { val params = UserListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } 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 5b3094b1..ece2791b 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -35,19 +36,19 @@ class ViewListParamsTest { .viewName("view_name") .viewType(ViewListParams.ViewType.PROJECTS) .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(ViewListParams.ObjectType.ORGANIZATION.toString())) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - listOf(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", listOf("123")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("view_name", listOf("view_name")) - expected.put("view_type", listOf(ViewListParams.ViewType.PROJECTS.toString())) - assertThat(params.getQueryParams()).isEqualTo(expected) + expected.put("limit", "123") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("view_name", "view_name") + expected.put("view_type", ViewListParams.ViewType.PROJECTS.toString()) + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -57,9 +58,9 @@ class ViewListParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewListParams.ObjectType.ORGANIZATION) .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(ViewListParams.ObjectType.ORGANIZATION.toString())) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } } 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 c381863a..de373498 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -25,10 +26,10 @@ class ViewRetrieveParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(ViewRetrieveParams.ObjectType.ORGANIZATION.toString())) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test @@ -39,10 +40,10 @@ class ViewRetrieveParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(ViewRetrieveParams.ObjectType.ORGANIZATION.toString())) - assertThat(params.getQueryParams()).isEqualTo(expected) + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + assertThat(params.getQueryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 58a2b8f5..6bf60116 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.jsonMapper import com.braintrustdata.api.errors.BadRequestException import com.braintrustdata.api.errors.BraintrustError @@ -22,12 +23,11 @@ import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.put import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import com.google.common.collect.ImmutableListMultimap -import com.google.common.collect.ListMultimap import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy @@ -86,7 +86,7 @@ class ErrorHandlingTest { assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> - assertBadRequest(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) + assertBadRequest(e, Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR) }) } @@ -101,7 +101,7 @@ class ErrorHandlingTest { assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> - assertUnauthorized(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) + assertUnauthorized(e, Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR) }) } @@ -116,7 +116,11 @@ class ErrorHandlingTest { assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> - assertPermissionDenied(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) + assertPermissionDenied( + e, + Headers.builder().put("Foo", "Bar").build(), + BRAINTRUST_ERROR + ) }) } @@ -131,7 +135,7 @@ class ErrorHandlingTest { assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> - assertNotFound(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) + assertNotFound(e, Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR) }) } @@ -148,7 +152,7 @@ class ErrorHandlingTest { .satisfies({ e -> assertUnprocessableEntity( e, - ImmutableListMultimap.of("Foo", "Bar"), + Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR ) }) @@ -165,7 +169,7 @@ class ErrorHandlingTest { assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> - assertRateLimit(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) + assertRateLimit(e, Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR) }) } @@ -180,7 +184,11 @@ class ErrorHandlingTest { assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> - assertInternalServer(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) + assertInternalServer( + e, + Headers.builder().put("Foo", "Bar").build(), + BRAINTRUST_ERROR + ) }) } @@ -198,7 +206,7 @@ class ErrorHandlingTest { assertUnexpectedStatusCodeException( e, 999, - ImmutableListMultimap.of("Foo", "Bar"), + Headers.builder().put("Foo", "Bar").build(), toJson(BRAINTRUST_ERROR) ) }) @@ -226,7 +234,7 @@ class ErrorHandlingTest { assertThatThrownBy({ client.projects().create(params) }) .satisfies({ e -> - assertBadRequest(e, ImmutableListMultimap.of(), BraintrustError.builder().build()) + assertBadRequest(e, Headers.builder().build(), BraintrustError.builder().build()) }) } @@ -237,7 +245,7 @@ class ErrorHandlingTest { private fun assertUnexpectedStatusCodeException( throwable: Throwable, statusCode: Int, - headers: ListMultimap, + headers: Headers, responseBody: ByteArray ) { assertThat(throwable) @@ -247,41 +255,33 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(statusCode) assertThat(e.body()).isEqualTo(String(responseBody)) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } - private fun assertBadRequest( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { + private fun assertBadRequest(throwable: Throwable, headers: Headers, error: BraintrustError) { assertThat(throwable) .asInstanceOf(InstanceOfAssertFactories.throwable(BadRequestException::class.java)) .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(400) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } - private fun assertUnauthorized( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { + private fun assertUnauthorized(throwable: Throwable, headers: Headers, error: BraintrustError) { assertThat(throwable) .asInstanceOf(InstanceOfAssertFactories.throwable(UnauthorizedException::class.java)) .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(401) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } private fun assertPermissionDenied( throwable: Throwable, - headers: ListMultimap, + headers: Headers, error: BraintrustError ) { assertThat(throwable) @@ -291,27 +291,23 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(403) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } - private fun assertNotFound( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { + private fun assertNotFound(throwable: Throwable, headers: Headers, error: BraintrustError) { assertThat(throwable) .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(404) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } private fun assertUnprocessableEntity( throwable: Throwable, - headers: ListMultimap, + headers: Headers, error: BraintrustError ) { assertThat(throwable) @@ -321,27 +317,23 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(422) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } - private fun assertRateLimit( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { + private fun assertRateLimit(throwable: Throwable, headers: Headers, error: BraintrustError) { assertThat(throwable) .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(429) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } private fun assertInternalServer( throwable: Throwable, - headers: ListMultimap, + headers: Headers, error: BraintrustError ) { assertThat(throwable) @@ -349,7 +341,12 @@ class ErrorHandlingTest { .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(500) assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) + assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) }) } + + private fun Headers.toMap(): Map> = + mutableMapOf>().also { map -> + names().forEach { map[it] = values(it) } + } } From 2e62835d07807e4e1aa018180fac6ca3de574e8e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 02:33:19 +0000 Subject: [PATCH 21/87] chore: rebuild project due to codegen change (#88) --- .../api/errors/BraintrustError.kt | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index 29925864..87dcc685 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -13,14 +13,12 @@ import java.util.Objects @JsonDeserialize(builder = BraintrustError.Builder::class) @NoAutoDetect class BraintrustError -constructor( - private val additionalProperties: Map, +private constructor( + @JsonAnyGetter + @get:JvmName("additionalProperties") + val additionalProperties: Map, ) { - @JsonAnyGetter fun additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder() - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -35,6 +33,8 @@ constructor( override fun toString() = "BraintrustError{additionalProperties=$additionalProperties}" + fun toBuilder() = Builder().from(this) + companion object { @JvmStatic fun builder() = Builder() @@ -44,24 +44,31 @@ constructor( private var additionalProperties: MutableMap = mutableMapOf() - fun from(error: BraintrustError) = apply { - additionalProperties(error.additionalProperties) + @JvmSynthetic + internal fun from(braintrustError: BraintrustError) = apply { + additionalProperties = braintrustError.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): BraintrustError = BraintrustError(additionalProperties.toImmutable()) } } From e35332464b9e4a83bef95f90866c0de79bc8c0ff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 03:49:03 +0000 Subject: [PATCH 22/87] chore: rebuild project due to codegen change (#90) --- braintrust-java-client-okhttp/build.gradle.kts | 1 - braintrust-java-core/build.gradle.kts | 2 -- .../kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt | 1 - 3 files changed, 4 deletions(-) diff --git a/braintrust-java-client-okhttp/build.gradle.kts b/braintrust-java-client-okhttp/build.gradle.kts index 61e72e31..f708b5aa 100755 --- a/braintrust-java-client-okhttp/build.gradle.kts +++ b/braintrust-java-client-okhttp/build.gradle.kts @@ -10,5 +10,4 @@ dependencies { testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.25.3") - testImplementation("org.slf4j:slf4j-simple:2.0.12") } diff --git a/braintrust-java-core/build.gradle.kts b/braintrust-java-core/build.gradle.kts index 0e9c34a5..4301ae91 100755 --- a/braintrust-java-core/build.gradle.kts +++ b/braintrust-java-core/build.gradle.kts @@ -18,8 +18,6 @@ dependencies { testImplementation(project(":braintrust-java-client-okhttp")) testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") testImplementation("org.assertj:assertj-core:3.25.3") - testImplementation("org.assertj:assertj-guava:3.25.3") - testImplementation("org.slf4j:slf4j-simple:2.0.12") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 6bf60116..ebdc9eec 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -32,7 +32,6 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.assertj.core.api.InstanceOfAssertFactories -import org.assertj.guava.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test From 5e9b07e8f84aff42457a97000302fa2e890282b2 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Wed, 20 Nov 2024 23:33:08 +0000 Subject: [PATCH 23/87] feat(api): manual updates (#91) --- .stats.yml | 4 +- SECURITY.md | 2 +- .../api/client/BraintrustClient.kt | 2 + .../api/client/BraintrustClientAsync.kt | 2 + .../api/client/BraintrustClientAsyncImpl.kt | 6 + .../api/client/BraintrustClientImpl.kt | 6 + .../com/braintrustdata/api/models/Acl.kt | 44 +- .../api/models/AclBatchUpdateParams.kt | 42 +- .../api/models/AclCreateParams.kt | 32 +- .../api/models/AclFindAndDeleteParams.kt | 32 +- .../api/models/ChatCompletionContentPart.kt | 166 -- .../braintrustdata/api/models/CodeBundle.kt | 331 +++- .../api/models/DatasetCreateParams.kt | 98 +- .../braintrustdata/api/models/DatasetEvent.kt | 283 ++- .../api/models/EvalCreateParams.kt | 503 ++++- .../api/models/ExperimentEvent.kt | 340 +++- .../api/models/ExperimentInsertResponse.kt | 160 ++ .../api/models/FunctionInvokeParams.kt | 178 ++ .../api/models/FunctionToolChoice.kt | 103 - .../api/models/InsertExperimentEventMerge.kt | 60 +- .../models/InsertExperimentEventReplace.kt | 60 +- .../api/models/InsertProjectLogsEventMerge.kt | 60 +- .../models/InsertProjectLogsEventReplace.kt | 60 +- .../api/models/ProjectLogInsertResponse.kt | 160 ++ .../api/models/ProjectLogsEvent.kt | 340 +++- .../braintrustdata/api/models/ProjectScore.kt | 93 +- .../api/models/ProjectScoreCreateParams.kt | 100 +- .../api/models/ProjectScoreListParams.kt | 167 +- .../api/models/ProjectScoreReplaceParams.kt | 100 +- .../api/models/ProjectScoreType.kt | 84 - .../api/models/ProjectScoreUpdateParams.kt | 100 +- .../braintrustdata/api/models/PromptData.kt | 1696 ++++++++++++++++- .../com/braintrustdata/api/models/Scorer.kt | 175 -- .../braintrustdata/api/models/SpanIFrame.kt | 277 +++ .../api/models/SpanIframeCreateParams.kt | 386 ++++ .../api/models/SpanIframeDeleteParams.kt | 215 +++ .../api/models/SpanIframeListPage.kt | 188 ++ .../api/models/SpanIframeListPageAsync.kt | 198 ++ .../api/models/SpanIframeListParams.kt | 382 ++++ .../api/models/SpanIframeReplaceParams.kt | 386 ++++ .../api/models/SpanIframeRetrieveParams.kt | 179 ++ .../api/models/SpanIframeUpdateParams.kt | 360 ++++ .../com/braintrustdata/api/models/Task.kt | 155 -- .../braintrustdata/api/models/ToolChoice.kt | 422 ---- .../services/async/ExperimentServiceAsync.kt | 4 +- .../async/ExperimentServiceAsyncImpl.kt | 9 +- .../services/async/FunctionServiceAsync.kt | 3 +- .../async/FunctionServiceAsyncImpl.kt | 3 +- .../services/async/SpanIframeServiceAsync.kt | 74 + .../async/SpanIframeServiceAsyncImpl.kt | 224 +++ .../async/projects/LogServiceAsync.kt | 4 +- .../async/projects/LogServiceAsyncImpl.kt | 9 +- .../services/blocking/ExperimentService.kt | 4 +- .../blocking/ExperimentServiceImpl.kt | 9 +- .../api/services/blocking/FunctionService.kt | 3 +- .../services/blocking/FunctionServiceImpl.kt | 3 +- .../services/blocking/SpanIframeService.kt | 73 + .../blocking/SpanIframeServiceImpl.kt | 217 +++ .../services/blocking/projects/LogService.kt | 4 +- .../blocking/projects/LogServiceImpl.kt | 9 +- .../api/models/CodeBundleTest.kt | 14 +- .../api/models/DatasetCreateParamsTest.kt | 13 +- .../api/models/DatasetEventTest.kt | 19 + .../api/models/EvalCreateParamsTest.kt | 77 + .../api/models/ExperimentCreateParamsTest.kt | 6 +- .../api/models/ExperimentEventTest.kt | 25 + .../api/models/ExperimentInsertParamsTest.kt | 9 + .../models/FetchDatasetEventsResponseTest.kt | 18 + .../FetchExperimentEventsResponseTest.kt | 24 + .../FetchProjectLogsEventsResponseTest.kt | 24 + .../api/models/FunctionCreateParamsTest.kt | 102 +- .../api/models/FunctionReplaceParamsTest.kt | 102 +- .../braintrustdata/api/models/FunctionTest.kt | 55 +- .../api/models/FunctionToolChoiceTest.kt | 16 - .../api/models/FunctionUpdateParamsTest.kt | 82 +- .../api/models/GroupCreateParamsTest.kt | 10 +- .../api/models/GroupReplaceParamsTest.kt | 10 +- .../api/models/GroupUpdateParamsTest.kt | 6 +- .../models/InsertExperimentEventMergeTest.kt | 6 + .../InsertExperimentEventReplaceTest.kt | 6 + .../models/InsertProjectLogsEventMergeTest.kt | 6 + .../InsertProjectLogsEventReplaceTest.kt | 6 + .../api/models/ProjectCreateParamsTest.kt | 10 +- .../api/models/ProjectLogInsertParamsTest.kt | 9 + .../api/models/ProjectLogsEventTest.kt | 25 + .../models/ProjectScoreCreateParamsTest.kt | 10 +- .../api/models/ProjectScoreListParamsTest.kt | 18 +- .../models/ProjectScoreReplaceParamsTest.kt | 10 +- .../api/models/ProjectScoreTest.kt | 4 +- .../models/ProjectScoreUpdateParamsTest.kt | 6 +- .../api/models/PromptCreateParamsTest.kt | 102 +- .../api/models/PromptDataTest.kt | 49 +- .../api/models/PromptReplaceParamsTest.kt | 102 +- .../braintrustdata/api/models/PromptTest.kt | 55 +- .../api/models/PromptUpdateParamsTest.kt | 82 +- .../api/models/RoleCreateParamsTest.kt | 10 +- .../api/models/RoleReplaceParamsTest.kt | 10 +- .../api/models/RoleUpdateParamsTest.kt | 6 +- .../braintrustdata/api/models/ScorerTest.kt | 17 - .../api/models/SpanIFrameTest.kt | 37 + .../api/models/SpanIframeCreateParamsTest.kt | 55 + .../api/models/SpanIframeDeleteParamsTest.kt | 30 + .../api/models/SpanIframeListParamsTest.kt | 54 + .../api/models/SpanIframeReplaceParamsTest.kt | 55 + .../models/SpanIframeRetrieveParamsTest.kt | 30 + .../api/models/SpanIframeUpdateParamsTest.kt | 59 + .../com/braintrustdata/api/models/TaskTest.kt | 16 - .../api/services/ErrorHandlingTest.kt | 22 +- .../api/services/ServiceParamsTest.kt | 2 +- .../services/blocking/DatasetServiceTest.kt | 3 +- .../api/services/blocking/EvalServiceTest.kt | 25 + .../blocking/ExperimentServiceTest.kt | 10 +- .../services/blocking/FunctionServiceTest.kt | 95 +- .../api/services/blocking/GroupServiceTest.kt | 6 +- .../blocking/ProjectScoreServiceTest.kt | 6 +- .../services/blocking/ProjectServiceTest.kt | 2 +- .../services/blocking/PromptServiceTest.kt | 95 +- .../api/services/blocking/RoleServiceTest.kt | 6 +- .../blocking/SpanIframeServiceTest.kt | 128 ++ .../blocking/projects/LogServiceTest.kt | 8 +- .../main/kotlin/braintrust.publish.gradle.kts | 2 +- 121 files changed, 9556 insertions(+), 1740 deletions(-) delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionToolChoiceTest.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScorerTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TaskTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt diff --git a/.stats.yml b/.stats.yml index ac9200d3..b229724a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 104 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-9d216c8243fe39ba2ffe3bffaab0dba53f1c04b7216d22f9072f6611233de0c7.yml +configured_endpoints: 110 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-360c6d1b34acf77d5a439e1c0e6a071223701d1461538d6b06da1598e5e2b742.yml diff --git a/SECURITY.md b/SECURITY.md index 5702c21d..9e161b9a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -20,7 +20,7 @@ or products provided by Braintrust please follow the respective company's securi ### Braintrust Terms and Policies -Please contact info-test@braintrustdata.com for any questions or concerns regarding security of our services. +Please contact info@braintrustdata.com for any questions or concerns regarding security of our services. --- diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index f923ab46..9f688451 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -31,6 +31,8 @@ interface BraintrustClient { fun projectTags(): ProjectTagService + fun spanIframes(): SpanIframeService + fun functions(): FunctionService fun views(): ViewService diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index bf2509b3..eea2d753 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -31,6 +31,8 @@ interface BraintrustClientAsync { fun projectTags(): ProjectTagServiceAsync + fun spanIframes(): SpanIframeServiceAsync + fun functions(): FunctionServiceAsync fun views(): ViewServiceAsync diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index 2ad9d939..e334c9bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -61,6 +61,10 @@ constructor( ProjectTagServiceAsyncImpl(clientOptionsWithUserAgent) } + private val spanIframes: SpanIframeServiceAsync by lazy { + SpanIframeServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val functions: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -109,6 +113,8 @@ constructor( override fun projectTags(): ProjectTagServiceAsync = projectTags + override fun spanIframes(): SpanIframeServiceAsync = spanIframes + override fun functions(): FunctionServiceAsync = functions override fun views(): ViewServiceAsync = views diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index d99bed3d..8e1b73e7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -53,6 +53,10 @@ constructor( ProjectTagServiceImpl(clientOptionsWithUserAgent) } + private val spanIframes: SpanIframeService by lazy { + SpanIframeServiceImpl(clientOptionsWithUserAgent) + } + private val functions: FunctionService by lazy { FunctionServiceImpl(clientOptionsWithUserAgent) } @@ -97,6 +101,8 @@ constructor( override fun projectTags(): ProjectTagService = projectTags + override fun spanIframes(): SpanIframeService = spanIframes + override fun functions(): FunctionService = functions override fun views(): ViewService = views 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 5dc79cec..3b094948 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 @@ -67,15 +67,14 @@ private constructor( */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) - /** The object type that the ACL applies to */ + /** + * 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 = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) @@ -107,14 +106,13 @@ private constructor( */ @JsonProperty("group_id") @ExcludeMissing fun _groupId() = groupId - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") @ExcludeMissing fun _permission() = permission - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType() = restrictObjectType @@ -234,27 +232,25 @@ private constructor( @ExcludeMissing fun groupId(groupId: JsonField) = apply { this.groupId = groupId } - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission) = permission(JsonField.of(permission)) - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") @ExcludeMissing fun permission(permission: JsonField) = apply { this.permission = permission } - /** The object type that the ACL applies to */ + /** + * 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) = restrictObjectType(JsonField.of(restrictObjectType)) - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") @ExcludeMissing fun restrictObjectType(restrictObjectType: JsonField) = apply { 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 f1a6977c..583e8229 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 @@ -446,14 +446,13 @@ constructor( */ @JsonProperty("group_id") fun groupId(): String? = groupId - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") fun permission(): Permission? = permission - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") fun restrictObjectType(): RestrictObjectType? = restrictObjectType @@ -518,15 +517,15 @@ constructor( fun groupId(groupId: String) = apply { this.groupId = groupId } /** - * 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 + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") fun permission(permission: Permission) = apply { this.permission = permission } - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just + * the specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { this.restrictObjectType = restrictObjectType @@ -944,14 +943,13 @@ constructor( */ @JsonProperty("group_id") fun groupId(): String? = groupId - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") fun permission(): Permission? = permission - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") fun restrictObjectType(): RestrictObjectType? = restrictObjectType @@ -1016,15 +1014,15 @@ constructor( fun groupId(groupId: String) = apply { this.groupId = groupId } /** - * 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 + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") fun permission(permission: Permission) = apply { this.permission = permission } - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just + * the specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { this.restrictObjectType = restrictObjectType 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 58858ff4..71cf1b88 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 @@ -102,14 +102,13 @@ constructor( */ @JsonProperty("group_id") fun groupId(): String? = groupId - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") fun permission(): Permission? = permission - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") fun restrictObjectType(): RestrictObjectType? = restrictObjectType @@ -174,15 +173,15 @@ constructor( fun groupId(groupId: String) = apply { this.groupId = groupId } /** - * 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 + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") fun permission(permission: Permission) = apply { this.permission = permission } - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just + * the specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { this.restrictObjectType = restrictObjectType @@ -316,14 +315,13 @@ constructor( */ fun groupId(groupId: String) = apply { this.groupId = groupId } - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission) = apply { this.permission = permission } - /** The object type that the ACL applies to */ + /** + * 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 { this.restrictObjectType = restrictObjectType } 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 5dfc524d..31777cde 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 @@ -102,14 +102,13 @@ constructor( */ @JsonProperty("group_id") fun groupId(): String? = groupId - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") fun permission(): Permission? = permission - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") fun restrictObjectType(): RestrictObjectType? = restrictObjectType @@ -174,15 +173,15 @@ constructor( fun groupId(groupId: String) = apply { this.groupId = groupId } /** - * 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 + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") fun permission(permission: Permission) = apply { this.permission = permission } - /** The object type that the ACL applies to */ + /** + * When setting a permission directly, optionally restricts the permission grant to just + * the specified object type. Cannot be set alongside a `role_id`. + */ @JsonProperty("restrict_object_type") fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { this.restrictObjectType = restrictObjectType @@ -316,14 +315,13 @@ constructor( */ fun groupId(groupId: String) = apply { this.groupId = groupId } - /** - * 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 - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission) = apply { this.permission = permission } - /** The object type that the ACL applies to */ + /** + * 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 { this.restrictObjectType = restrictObjectType } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt deleted file mode 100644 index 35a3f312..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt +++ /dev/null @@ -1,166 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) -@JsonSerialize(using = ChatCompletionContentPart.Serializer::class) -class ChatCompletionContentPart -private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if (chatCompletionContentPartText == null && chatCompletionContentPartImage == null) { - throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $_json") - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = ChatCompletionContentPart(chatCompletionContentPartText = chatCompletionContentPartText) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") - } - } - - class Deserializer : - BaseDeserializer(ChatCompletionContentPart::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : BaseSerializer(ChatCompletionContentPart::class) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index cc2574a6..4c5d6997 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -371,22 +371,22 @@ private constructor( @JsonSerialize(using = Position.Serializer::class) class Position private constructor( - private val task: Task? = null, + private val type: Type? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun task(): Optional = Optional.ofNullable(task) + fun type(): Optional = Optional.ofNullable(type) fun scorer(): Optional = Optional.ofNullable(scorer) - fun isTask(): Boolean = task != null + fun isType(): Boolean = type != null fun isScorer(): Boolean = scorer != null - fun asTask(): Task = task.getOrThrow("task") + fun asType(): Type = type.getOrThrow("type") fun asScorer(): Scorer = scorer.getOrThrow("scorer") @@ -394,7 +394,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - task != null -> visitor.visitTask(task) + type != null -> visitor.visitType(type) scorer != null -> visitor.visitScorer(scorer) else -> visitor.unknown(_json) } @@ -402,10 +402,10 @@ private constructor( fun validate(): Position = apply { if (!validated) { - if (task == null && scorer == null) { + if (type == null && scorer == null) { throw BraintrustInvalidDataException("Unknown Position: $_json") } - task?.validate() + type?.validate() scorer?.validate() validated = true } @@ -416,16 +416,16 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.task == other.task && this.scorer == other.scorer /* spotless:on */ + return /* spotless:off */ other is Position && this.type == other.type && this.scorer == other.scorer /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(task, scorer) /* spotless:on */ + return /* spotless:off */ Objects.hash(type, scorer) /* spotless:on */ } override fun toString(): String { return when { - task != null -> "Position{task=$task}" + type != null -> "Position{type=$type}" scorer != null -> "Position{scorer=$scorer}" _json != null -> "Position{_unknown=$_json}" else -> throw IllegalStateException("Invalid Position") @@ -434,14 +434,14 @@ private constructor( companion object { - @JvmStatic fun ofTask(task: Task) = Position(task = task) + @JvmStatic fun ofType(type: Type) = Position(type = type) @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) } interface Visitor { - fun visitTask(task: Task): T + fun visitType(type: Type): T fun visitScorer(scorer: Scorer): T @@ -455,9 +455,9 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Position { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Position(task = it, _json = json) + return Position(type = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -476,13 +476,314 @@ private constructor( provider: SerializerProvider ) { when { - value.task != null -> generator.writeObject(value.task) + value.type != null -> generator.writeObject(value.type) value.scorer != null -> generator.writeObject(value.scorer) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Position") } } } + + @JsonDeserialize(builder = Type.Builder::class) + @NoAutoDetect + class Type + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Type = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties(type.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Type = Type(type, additionalProperties.toImmutable()) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + TASK, + } + + enum class Value { + TASK, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TASK -> Known.TASK + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Type{type=$type, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Scorer.Builder::class) + @NoAutoDetect + class Scorer + private constructor( + private val type: JsonField, + private val index: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + fun index(): Long = index.getRequired("index") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("index") @ExcludeMissing fun _index() = index + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Scorer = apply { + if (!validated) { + type() + index() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var index: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(scorer: Scorer) = apply { + this.type = scorer.type + this.index = scorer.index + additionalProperties(scorer.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun index(index: Long) = index(JsonField.of(index)) + + @JsonProperty("index") + @ExcludeMissing + fun index(index: JsonField) = apply { this.index = index } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Scorer = + Scorer( + type, + index, + additionalProperties.toImmutable(), + ) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SCORER = Type(JsonField.of("scorer")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + SCORER, + } + + enum class Value { + SCORER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Scorer && this.type == other.type && this.index == other.index && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, index, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + } } class Type diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 76c613a1..ef0cf74b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -21,6 +21,7 @@ constructor( private val name: String, private val projectId: String, private val description: String?, + private val metadata: Metadata?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -32,12 +33,15 @@ constructor( fun description(): Optional = Optional.ofNullable(description) + fun metadata(): Optional = Optional.ofNullable(metadata) + @JvmSynthetic internal fun getBody(): DatasetCreateBody { return DatasetCreateBody( name, projectId, description, + metadata, additionalBodyProperties, ) } @@ -53,6 +57,7 @@ constructor( private val name: String?, private val projectId: String?, private val description: String?, + private val metadata: Metadata?, private val additionalProperties: Map, ) { @@ -65,6 +70,9 @@ constructor( /** Textual description of the dataset */ @JsonProperty("description") fun description(): String? = description + /** User-controlled metadata about the dataset */ + @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -81,6 +89,7 @@ constructor( private var name: String? = null private var projectId: String? = null private var description: String? = null + private var metadata: Metadata? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -88,6 +97,7 @@ constructor( this.name = datasetCreateBody.name this.projectId = datasetCreateBody.projectId this.description = datasetCreateBody.description + this.metadata = datasetCreateBody.metadata additionalProperties(datasetCreateBody.additionalProperties) } @@ -102,6 +112,10 @@ constructor( @JsonProperty("description") fun description(description: String) = apply { this.description = description } + /** User-controlled metadata about the dataset */ + @JsonProperty("metadata") + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -121,6 +135,7 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, description, + metadata, additionalProperties.toImmutable(), ) } @@ -130,20 +145,20 @@ constructor( return true } - return /* spotless:off */ other is DatasetCreateBody && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetCreateBody && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.metadata == other.metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, description, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(name, projectId, description, metadata, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, additionalProperties=$additionalProperties}" + "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -157,15 +172,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetCreateParams && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetCreateParams && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.metadata == other.metadata && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(name, projectId, description, metadata, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetCreateParams{name=$name, projectId=$projectId, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetCreateParams{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -180,6 +195,7 @@ constructor( private var name: String? = null private var projectId: String? = null private var description: String? = null + private var metadata: Metadata? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -189,6 +205,7 @@ constructor( this.name = datasetCreateParams.name this.projectId = datasetCreateParams.projectId this.description = datasetCreateParams.description + this.metadata = datasetCreateParams.metadata additionalHeaders(datasetCreateParams.additionalHeaders) additionalQueryParams(datasetCreateParams.additionalQueryParams) additionalBodyProperties(datasetCreateParams.additionalBodyProperties) @@ -203,6 +220,9 @@ constructor( /** Textual description of the dataset */ fun description(description: String) = apply { this.description = description } + /** User-controlled metadata about the dataset */ + fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -328,9 +348,75 @@ constructor( checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, description, + metadata, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + /** User-controlled metadata about the dataset */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index cdc81f4c..dd89283a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -2,14 +2,17 @@ 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 import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect 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 import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime @@ -31,6 +34,8 @@ private constructor( private val tags: JsonField>, private val spanId: JsonField, private val rootSpanId: JsonField, + private val isRoot: JsonField, + private val origin: JsonField, private val additionalProperties: Map, ) { @@ -89,6 +94,12 @@ private constructor( /** The `span_id` of the root of the trace this dataset event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") + /** Whether this span is a root span */ + fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) + + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate * one for you @@ -142,6 +153,12 @@ private constructor( /** The `span_id` of the root of the trace this dataset event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + /** Whether this span is a root span */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot() = isRoot + + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -159,6 +176,8 @@ private constructor( tags() spanId() rootSpanId() + isRoot() + origin().map { it.validate() } validated = true } } @@ -183,6 +202,8 @@ private constructor( private var tags: JsonField> = JsonMissing.of() private var spanId: JsonField = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() + private var isRoot: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -198,6 +219,8 @@ private constructor( this.tags = datasetEvent.tags this.spanId = datasetEvent.spanId this.rootSpanId = datasetEvent.rootSpanId + this.isRoot = datasetEvent.isRoot + this.origin = datasetEvent.origin additionalProperties(datasetEvent.additionalProperties) } @@ -320,6 +343,22 @@ private constructor( @ExcludeMissing fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean) = isRoot(JsonField.of(isRoot)) + + /** Whether this span is a root span */ + @JsonProperty("is_root") + @ExcludeMissing + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + + /** Indicates the event was copied from another object. */ + fun origin(origin: Origin) = origin(JsonField.of(origin)) + + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") + @ExcludeMissing + fun origin(origin: JsonField) = apply { this.origin = origin } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -347,6 +386,8 @@ private constructor( tags.map { it.toImmutable() }, spanId, rootSpanId, + isRoot, + origin, additionalProperties.toImmutable(), ) } @@ -430,23 +471,259 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** Indicates the event was copied from another object. */ + @JsonDeserialize(builder = Origin.Builder::class) + @NoAutoDetect + class Origin + private constructor( + private val objectType: JsonField, + private val objectId: JsonField, + private val id: JsonField, + private val _xactId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** Type of the object the event is originating from. */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** ID of the object the event is originating from. */ + fun objectId(): String = objectId.getRequired("object_id") + + /** ID of the original event. */ + fun id(): String = id.getRequired("id") + + /** Transaction ID of the original event. */ + fun _xactId(): String = _xactId.getRequired("_xact_id") + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + + /** ID of the original event. */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** Transaction ID of the original event. */ + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Origin = apply { + if (!validated) { + objectType() + objectId() + id() + _xactId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objectType: JsonField = JsonMissing.of() + private var objectId: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var _xactId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(origin: Origin) = apply { + this.objectType = origin.objectType + this.objectId = origin.objectId + this.id = origin.id + this._xactId = origin._xactId + additionalProperties(origin.additionalProperties) + } + + /** Type of the object the event is originating from. */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") + @ExcludeMissing + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** ID of the object the event is originating from. */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") + @ExcludeMissing + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** ID of the original event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** ID of the original event. */ + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** Transaction ID of the original event. */ + fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) + + /** Transaction ID of the original event. */ + @JsonProperty("_xact_id") + @ExcludeMissing + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Origin = + Origin( + objectType, + objectId, + id, + _xactId, + additionalProperties.toImmutable(), + ) + } + + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + + @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + + @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + + @JvmField val PROJECT_LOGS = ObjectType(JsonField.of("project_logs")) + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + } + + enum class Value { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + FUNCTION -> Value.FUNCTION + PROMPT_SESSION -> Value.PROMPT_SESSION + PROJECT_LOGS -> Value.PROJECT_LOGS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + FUNCTION -> Known.FUNCTION + PROMPT_SESSION -> Known.PROMPT_SESSION + PROJECT_LOGS -> Known.PROJECT_LOGS + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.id == other.id && this._xactId == other._xactId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, id, _xactId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DatasetEvent && this.id == other.id && this._xactId == other._xactId && this.created == other.created && this.projectId == other.projectId && this.datasetId == other.datasetId && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetEvent && this.id == other.id && this._xactId == other._xactId && this.created == other.created && this.projectId == other.projectId && this.datasetId == other.datasetId && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.isRoot == other.isRoot && this.origin == other.origin && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, _xactId, created, projectId, datasetId, input, expected, metadata, tags, spanId, rootSpanId, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, _xactId, created, projectId, datasetId, input, expected, metadata, tags, spanId, rootSpanId, isRoot, origin, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" + "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, isRoot=$isRoot, origin=$origin, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 625539b3..300e3d10 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -36,9 +36,17 @@ constructor( private val projectId: String, private val scores: List, private val task: Task, + private val baseExperimentId: String?, + private val baseExperimentName: String?, private val experimentName: String?, + private val gitMetadataSettings: GitMetadataSettings?, + private val isPublic: Boolean?, + private val maxConcurrency: Double?, private val metadata: Metadata?, + private val repoInfo: RepoInfo?, private val stream: Boolean?, + private val timeout: Double?, + private val trialCount: Double?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -52,12 +60,29 @@ constructor( fun task(): Task = task + fun baseExperimentId(): Optional = Optional.ofNullable(baseExperimentId) + + fun baseExperimentName(): Optional = Optional.ofNullable(baseExperimentName) + fun experimentName(): Optional = Optional.ofNullable(experimentName) + fun gitMetadataSettings(): Optional = + Optional.ofNullable(gitMetadataSettings) + + fun isPublic(): Optional = Optional.ofNullable(isPublic) + + fun maxConcurrency(): Optional = Optional.ofNullable(maxConcurrency) + fun metadata(): Optional = Optional.ofNullable(metadata) + fun repoInfo(): Optional = Optional.ofNullable(repoInfo) + fun stream(): Optional = Optional.ofNullable(stream) + fun timeout(): Optional = Optional.ofNullable(timeout) + + fun trialCount(): Optional = Optional.ofNullable(trialCount) + @JvmSynthetic internal fun getBody(): EvalCreateBody { return EvalCreateBody( @@ -65,9 +90,17 @@ constructor( projectId, scores, task, + baseExperimentId, + baseExperimentName, experimentName, + gitMetadataSettings, + isPublic, + maxConcurrency, metadata, + repoInfo, stream, + timeout, + trialCount, additionalBodyProperties, ) } @@ -84,9 +117,17 @@ constructor( private val projectId: String?, private val scores: List?, private val task: Task?, + private val baseExperimentId: String?, + private val baseExperimentName: String?, private val experimentName: String?, + private val gitMetadataSettings: GitMetadataSettings?, + private val isPublic: Boolean?, + private val maxConcurrency: Double?, private val metadata: Metadata?, + private val repoInfo: RepoInfo?, private val stream: Boolean?, + private val timeout: Double?, + private val trialCount: Double?, private val additionalProperties: Map, ) { @@ -102,18 +143,49 @@ constructor( /** The function to evaluate */ @JsonProperty("task") fun task(): Task? = task + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + @JsonProperty("base_experiment_id") fun baseExperimentId(): String? = baseExperimentId + + /** + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + @JsonProperty("base_experiment_name") fun baseExperimentName(): String? = baseExperimentName + /** * An optional name for the experiment created by this eval. If it conflicts with an * existing experiment, it will be suffixed with a unique identifier. */ @JsonProperty("experiment_name") fun experimentName(): String? = experimentName + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + @JsonProperty("git_metadata_settings") + fun gitMetadataSettings(): GitMetadataSettings? = gitMetadataSettings + + /** Whether the experiment should be public. Defaults to false. */ + @JsonProperty("is_public") fun isPublic(): Boolean? = isPublic + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. + */ + @JsonProperty("max_concurrency") fun maxConcurrency(): Double? = maxConcurrency + /** * Optional experiment-level metadata to store about the evaluation. You can later use this * to slice & dice across experiments. */ @JsonProperty("metadata") fun metadata(): Metadata? = metadata + /** Metadata about the state of the repo when the experiment was created */ + @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo + /** * Whether to stream the results of the eval. If true, the request will return two events: * one to indicate the experiment has started, and another upon completion. If false, the @@ -121,6 +193,19 @@ constructor( */ @JsonProperty("stream") fun stream(): Boolean? = stream + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. + */ + @JsonProperty("timeout") fun timeout(): Double? = timeout + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. + */ + @JsonProperty("trial_count") fun trialCount(): Double? = trialCount + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -138,9 +223,17 @@ constructor( private var projectId: String? = null private var scores: List? = null private var task: Task? = null + private var baseExperimentId: String? = null + private var baseExperimentName: String? = null private var experimentName: String? = null + private var gitMetadataSettings: GitMetadataSettings? = null + private var isPublic: Boolean? = null + private var maxConcurrency: Double? = null private var metadata: Metadata? = null + private var repoInfo: RepoInfo? = null private var stream: Boolean? = null + private var timeout: Double? = null + private var trialCount: Double? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -149,9 +242,17 @@ constructor( this.projectId = evalCreateBody.projectId this.scores = evalCreateBody.scores this.task = evalCreateBody.task + this.baseExperimentId = evalCreateBody.baseExperimentId + this.baseExperimentName = evalCreateBody.baseExperimentName this.experimentName = evalCreateBody.experimentName + this.gitMetadataSettings = evalCreateBody.gitMetadataSettings + this.isPublic = evalCreateBody.isPublic + this.maxConcurrency = evalCreateBody.maxConcurrency this.metadata = evalCreateBody.metadata + this.repoInfo = evalCreateBody.repoInfo this.stream = evalCreateBody.stream + this.timeout = evalCreateBody.timeout + this.trialCount = evalCreateBody.trialCount additionalProperties(evalCreateBody.additionalProperties) } @@ -168,6 +269,24 @@ constructor( /** The function to evaluate */ @JsonProperty("task") fun task(task: Task) = apply { this.task = task } + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + @JsonProperty("base_experiment_id") + fun baseExperimentId(baseExperimentId: String) = apply { + this.baseExperimentId = baseExperimentId + } + + /** + * An optional experiment name to use as a base. If specified, the new experiment will + * be summarized and compared to this experiment. + */ + @JsonProperty("base_experiment_name") + fun baseExperimentName(baseExperimentName: String) = apply { + this.baseExperimentName = baseExperimentName + } + /** * An optional name for the experiment created by this eval. If it conflicts with an * existing experiment, it will be suffixed with a unique identifier. @@ -177,6 +296,28 @@ constructor( this.experimentName = experimentName } + /** + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. + */ + @JsonProperty("git_metadata_settings") + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings) = apply { + this.gitMetadataSettings = gitMetadataSettings + } + + /** Whether the experiment should be public. Defaults to false. */ + @JsonProperty("is_public") + fun isPublic(isPublic: Boolean) = apply { this.isPublic = isPublic } + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. + */ + @JsonProperty("max_concurrency") + fun maxConcurrency(maxConcurrency: Double) = apply { + this.maxConcurrency = maxConcurrency + } + /** * Optional experiment-level metadata to store about the evaluation. You can later use * this to slice & dice across experiments. @@ -184,6 +325,10 @@ constructor( @JsonProperty("metadata") fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + /** Metadata about the state of the repo when the experiment was created */ + @JsonProperty("repo_info") + fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + /** * Whether to stream the results of the eval. If true, the request will return two * events: one to indicate the experiment has started, and another upon completion. If @@ -191,6 +336,20 @@ constructor( */ @JsonProperty("stream") fun stream(stream: Boolean) = apply { this.stream = stream } + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, + * in which case there is no timeout. + */ + @JsonProperty("timeout") fun timeout(timeout: Double) = apply { this.timeout = timeout } + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger + * aggregate measure and a sense of the variance in the results. + */ + @JsonProperty("trial_count") + fun trialCount(trialCount: Double) = apply { this.trialCount = trialCount } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -211,9 +370,17 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(scores) { "`scores` is required but was not set" }.toImmutable(), checkNotNull(task) { "`task` is required but was not set" }, + baseExperimentId, + baseExperimentName, experimentName, + gitMetadataSettings, + isPublic, + maxConcurrency, metadata, + repoInfo, stream, + timeout, + trialCount, additionalProperties.toImmutable(), ) } @@ -223,20 +390,20 @@ constructor( return true } - return /* spotless:off */ other is EvalCreateBody && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.experimentName == other.experimentName && this.metadata == other.metadata && this.stream == other.stream && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EvalCreateBody && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.baseExperimentId == other.baseExperimentId && this.baseExperimentName == other.baseExperimentName && this.experimentName == other.experimentName && this.gitMetadataSettings == other.gitMetadataSettings && this.isPublic == other.isPublic && this.maxConcurrency == other.maxConcurrency && this.metadata == other.metadata && this.repoInfo == other.repoInfo && this.stream == other.stream && this.timeout == other.timeout && this.trialCount == other.trialCount && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(data, projectId, scores, task, experimentName, metadata, stream, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, experimentName=$experimentName, metadata=$metadata, stream=$stream, additionalProperties=$additionalProperties}" + "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -250,15 +417,15 @@ constructor( return true } - return /* spotless:off */ other is EvalCreateParams && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.experimentName == other.experimentName && this.metadata == other.metadata && this.stream == other.stream && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EvalCreateParams && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.baseExperimentId == other.baseExperimentId && this.baseExperimentName == other.baseExperimentName && this.experimentName == other.experimentName && this.gitMetadataSettings == other.gitMetadataSettings && this.isPublic == other.isPublic && this.maxConcurrency == other.maxConcurrency && this.metadata == other.metadata && this.repoInfo == other.repoInfo && this.stream == other.stream && this.timeout == other.timeout && this.trialCount == other.trialCount && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(data, projectId, scores, task, experimentName, metadata, stream, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "EvalCreateParams{data=$data, projectId=$projectId, scores=$scores, task=$task, experimentName=$experimentName, metadata=$metadata, stream=$stream, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "EvalCreateParams{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -274,9 +441,17 @@ constructor( private var projectId: String? = null private var scores: MutableList = mutableListOf() private var task: Task? = null + private var baseExperimentId: String? = null + private var baseExperimentName: String? = null private var experimentName: String? = null + private var gitMetadataSettings: GitMetadataSettings? = null + private var isPublic: Boolean? = null + private var maxConcurrency: Double? = null private var metadata: Metadata? = null + private var repoInfo: RepoInfo? = null private var stream: Boolean? = null + private var timeout: Double? = null + private var trialCount: Double? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -287,9 +462,17 @@ constructor( this.projectId = evalCreateParams.projectId this.scores(evalCreateParams.scores) this.task = evalCreateParams.task + this.baseExperimentId = evalCreateParams.baseExperimentId + this.baseExperimentName = evalCreateParams.baseExperimentName this.experimentName = evalCreateParams.experimentName + this.gitMetadataSettings = evalCreateParams.gitMetadataSettings + this.isPublic = evalCreateParams.isPublic + this.maxConcurrency = evalCreateParams.maxConcurrency this.metadata = evalCreateParams.metadata + this.repoInfo = evalCreateParams.repoInfo this.stream = evalCreateParams.stream + this.timeout = evalCreateParams.timeout + this.trialCount = evalCreateParams.trialCount additionalHeaders(evalCreateParams.additionalHeaders) additionalQueryParams(evalCreateParams.additionalQueryParams) additionalBodyProperties(evalCreateParams.additionalBodyProperties) @@ -347,18 +530,54 @@ constructor( this.task = Task.ofInlinePrompt(inlinePrompt) } + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentId(baseExperimentId: String) = apply { + this.baseExperimentId = baseExperimentId + } + + /** + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentName(baseExperimentName: String) = apply { + this.baseExperimentName = baseExperimentName + } + /** * An optional name for the experiment created by this eval. If it conflicts with an * existing experiment, it will be suffixed with a unique identifier. */ fun experimentName(experimentName: String) = apply { this.experimentName = experimentName } + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings) = apply { + this.gitMetadataSettings = gitMetadataSettings + } + + /** Whether the experiment should be public. Defaults to false. */ + fun isPublic(isPublic: Boolean) = apply { this.isPublic = isPublic } + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. + */ + fun maxConcurrency(maxConcurrency: Double) = apply { this.maxConcurrency = maxConcurrency } + /** * Optional experiment-level metadata to store about the evaluation. You can later use this * to slice & dice across experiments. */ fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + /** * Whether to stream the results of the eval. If true, the request will return two events: * one to indicate the experiment has started, and another upon completion. If false, the @@ -366,6 +585,19 @@ constructor( */ fun stream(stream: Boolean) = apply { this.stream = stream } + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. + */ + fun timeout(timeout: Double) = apply { this.timeout = timeout } + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. + */ + fun trialCount(trialCount: Double) = apply { this.trialCount = trialCount } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -492,9 +724,17 @@ constructor( checkNotNull(projectId) { "`projectId` is required but was not set" }, checkNotNull(scores) { "`scores` is required but was not set" }.toImmutable(), checkNotNull(task) { "`task` is required but was not set" }, + baseExperimentId, + baseExperimentName, experimentName, + gitMetadataSettings, + isPublic, + maxConcurrency, metadata, + repoInfo, stream, + timeout, + trialCount, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -3099,6 +3339,257 @@ constructor( } } + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + @JsonDeserialize(builder = GitMetadataSettings.Builder::class) + @NoAutoDetect + class GitMetadataSettings + private constructor( + private val collect: Collect?, + private val fields: List?, + private val additionalProperties: Map, + ) { + + @JsonProperty("collect") fun collect(): Collect? = collect + + @JsonProperty("fields") fun fields(): List? = fields + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var collect: Collect? = null + private var fields: List? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitMetadataSettings: GitMetadataSettings) = apply { + this.collect = gitMetadataSettings.collect + this.fields = gitMetadataSettings.fields + additionalProperties(gitMetadataSettings.additionalProperties) + } + + @JsonProperty("collect") + fun collect(collect: Collect) = apply { this.collect = collect } + + @JsonProperty("fields") fun fields(fields: List) = apply { this.fields = fields } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): GitMetadataSettings = + GitMetadataSettings( + checkNotNull(collect) { "`collect` is required but was not set" }, + fields?.toImmutable(), + additionalProperties.toImmutable(), + ) + } + + class Collect + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Collect && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ALL = Collect(JsonField.of("all")) + + @JvmField val NONE = Collect(JsonField.of("none")) + + @JvmField val SOME = Collect(JsonField.of("some")) + + @JvmStatic fun of(value: String) = Collect(JsonField.of(value)) + } + + enum class Known { + ALL, + NONE, + SOME, + } + + enum class Value { + ALL, + NONE, + SOME, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ALL -> Value.ALL + NONE -> Value.NONE + SOME -> Value.SOME + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ALL -> Known.ALL + NONE -> Known.NONE + SOME -> Known.SOME + else -> throw BraintrustInvalidDataException("Unknown Collect: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Field + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Field && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val COMMIT = Field(JsonField.of("commit")) + + @JvmField val BRANCH = Field(JsonField.of("branch")) + + @JvmField val TAG = Field(JsonField.of("tag")) + + @JvmField val DIRTY = Field(JsonField.of("dirty")) + + @JvmField val AUTHOR_NAME = Field(JsonField.of("author_name")) + + @JvmField val AUTHOR_EMAIL = Field(JsonField.of("author_email")) + + @JvmField val COMMIT_MESSAGE = Field(JsonField.of("commit_message")) + + @JvmField val COMMIT_TIME = Field(JsonField.of("commit_time")) + + @JvmField val GIT_DIFF = Field(JsonField.of("git_diff")) + + @JvmStatic fun of(value: String) = Field(JsonField.of(value)) + } + + enum class Known { + COMMIT, + BRANCH, + TAG, + DIRTY, + AUTHOR_NAME, + AUTHOR_EMAIL, + COMMIT_MESSAGE, + COMMIT_TIME, + GIT_DIFF, + } + + enum class Value { + COMMIT, + BRANCH, + TAG, + DIRTY, + AUTHOR_NAME, + AUTHOR_EMAIL, + COMMIT_MESSAGE, + COMMIT_TIME, + GIT_DIFF, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + COMMIT -> Value.COMMIT + BRANCH -> Value.BRANCH + TAG -> Value.TAG + DIRTY -> Value.DIRTY + AUTHOR_NAME -> Value.AUTHOR_NAME + AUTHOR_EMAIL -> Value.AUTHOR_EMAIL + COMMIT_MESSAGE -> Value.COMMIT_MESSAGE + COMMIT_TIME -> Value.COMMIT_TIME + GIT_DIFF -> Value.GIT_DIFF + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + COMMIT -> Known.COMMIT + BRANCH -> Known.BRANCH + TAG -> Known.TAG + DIRTY -> Known.DIRTY + AUTHOR_NAME -> Known.AUTHOR_NAME + AUTHOR_EMAIL -> Known.AUTHOR_EMAIL + COMMIT_MESSAGE -> Known.COMMIT_MESSAGE + COMMIT_TIME -> Known.COMMIT_TIME + GIT_DIFF -> Known.GIT_DIFF + else -> throw BraintrustInvalidDataException("Unknown Field: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitMetadataSettings && this.collect == other.collect && this.fields == other.fields && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(collect, fields, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GitMetadataSettings{collect=$collect, fields=$fields, additionalProperties=$additionalProperties}" + } + /** * Optional experiment-level metadata to store about the evaluation. You can later use this to * slice & dice across experiments. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index a2b19b1e..4de93e47 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -42,6 +42,8 @@ private constructor( private val spanParents: JsonField>, private val rootSpanId: JsonField, private val spanAttributes: JsonField, + private val isRoot: JsonField, + private val origin: JsonField, private val additionalProperties: Map, ) { @@ -164,6 +166,12 @@ private constructor( fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + /** Whether this span is a root span */ + fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) + + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** * A unique identifier for the experiment event. If you don't provide one, BrainTrust will * generate one for you @@ -278,6 +286,12 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + /** Whether this span is a root span */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot() = isRoot + + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -303,6 +317,8 @@ private constructor( spanParents() rootSpanId() spanAttributes().map { it.validate() } + isRoot() + origin().map { it.validate() } validated = true } } @@ -335,6 +351,8 @@ private constructor( private var spanParents: JsonField> = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() private var spanAttributes: JsonField = JsonMissing.of() + private var isRoot: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -358,6 +376,8 @@ private constructor( this.spanParents = experimentEvent.spanParents this.rootSpanId = experimentEvent.rootSpanId this.spanAttributes = experimentEvent.spanAttributes + this.isRoot = experimentEvent.isRoot + this.origin = experimentEvent.origin additionalProperties(experimentEvent.additionalProperties) } @@ -605,6 +625,22 @@ private constructor( this.spanAttributes = spanAttributes } + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean) = isRoot(JsonField.of(isRoot)) + + /** Whether this span is a root span */ + @JsonProperty("is_root") + @ExcludeMissing + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + + /** Indicates the event was copied from another object. */ + fun origin(origin: Origin) = origin(JsonField.of(origin)) + + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") + @ExcludeMissing + fun origin(origin: JsonField) = apply { this.origin = origin } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -640,6 +676,8 @@ private constructor( spanParents.map { it.toImmutable() }, rootSpanId, spanAttributes, + isRoot, + origin, additionalProperties.toImmutable(), ) } @@ -888,6 +926,9 @@ private constructor( private val promptTokens: JsonField, private val completionTokens: JsonField, private val tokens: JsonField, + private val callerFunctionname: JsonValue, + private val callerFilename: JsonValue, + private val callerLineno: JsonValue, private val additionalProperties: Map, ) { @@ -922,6 +963,15 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + /** This metric is deprecated */ + fun callerFunctionname(): JsonValue = callerFunctionname + + /** This metric is deprecated */ + fun callerFilename(): JsonValue = callerFilename + + /** This metric is deprecated */ + fun callerLineno(): JsonValue = callerLineno + /** * A unix timestamp recording when the section of code which produced the experiment event * started @@ -951,6 +1001,17 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** This metric is deprecated */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -962,6 +1023,9 @@ private constructor( promptTokens() completionTokens() tokens() + callerFunctionname() + callerFilename() + callerLineno() validated = true } } @@ -980,6 +1044,9 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var completionTokens: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -989,6 +1056,9 @@ private constructor( this.promptTokens = metrics.promptTokens this.completionTokens = metrics.completionTokens this.tokens = metrics.tokens + this.callerFunctionname = metrics.callerFunctionname + this.callerFilename = metrics.callerFilename + this.callerLineno = metrics.callerLineno additionalProperties(metrics.additionalProperties) } @@ -1061,6 +1131,25 @@ private constructor( @ExcludeMissing fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -1082,29 +1171,268 @@ private constructor( promptTokens, completionTokens, tokens, + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + } + + /** Indicates the event was copied from another object. */ + @JsonDeserialize(builder = Origin.Builder::class) + @NoAutoDetect + class Origin + private constructor( + private val objectType: JsonField, + private val objectId: JsonField, + private val id: JsonField, + private val _xactId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** Type of the object the event is originating from. */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** ID of the object the event is originating from. */ + fun objectId(): String = objectId.getRequired("object_id") + + /** ID of the original event. */ + fun id(): String = id.getRequired("id") + + /** Transaction ID of the original event. */ + fun _xactId(): String = _xactId.getRequired("_xact_id") + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + + /** ID of the original event. */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** Transaction ID of the original event. */ + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Origin = apply { + if (!validated) { + objectType() + objectId() + id() + _xactId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objectType: JsonField = JsonMissing.of() + private var objectId: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var _xactId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(origin: Origin) = apply { + this.objectType = origin.objectType + this.objectId = origin.objectId + this.id = origin.id + this._xactId = origin._xactId + additionalProperties(origin.additionalProperties) + } + + /** Type of the object the event is originating from. */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") + @ExcludeMissing + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** ID of the object the event is originating from. */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") + @ExcludeMissing + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** ID of the original event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** ID of the original event. */ + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** Transaction ID of the original event. */ + fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) + + /** Transaction ID of the original event. */ + @JsonProperty("_xact_id") + @ExcludeMissing + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Origin = + Origin( + objectType, + objectId, + id, + _xactId, additionalProperties.toImmutable(), ) } + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + + @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + + @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + + @JvmField val PROJECT_LOGS = ObjectType(JsonField.of("project_logs")) + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + } + + enum class Value { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + FUNCTION -> Value.FUNCTION + PROMPT_SESSION -> Value.PROMPT_SESSION + PROJECT_LOGS -> Value.PROJECT_LOGS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + FUNCTION -> Known.FUNCTION + PROMPT_SESSION -> Known.PROMPT_SESSION + PROJECT_LOGS -> Known.PROJECT_LOGS + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.id == other.id && this._xactId == other._xactId && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, id, _xactId, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" } /** @@ -1389,18 +1717,18 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentEvent && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this._xactId == other._xactId && this.created == other.created && this.projectId == other.projectId && this.experimentId == other.experimentId && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanId == other.spanId && this.spanParents == other.spanParents && this.rootSpanId == other.rootSpanId && this.spanAttributes == other.spanAttributes && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentEvent && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this._xactId == other._xactId && this.created == other.created && this.projectId == other.projectId && this.experimentId == other.experimentId && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanId == other.spanId && this.spanParents == other.spanParents && this.rootSpanId == other.rootSpanId && this.spanAttributes == other.spanAttributes && this.isRoot == other.isRoot && this.origin == other.origin && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, datasetRecordId, _xactId, created, projectId, experimentId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, spanAttributes, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, datasetRecordId, _xactId, created, projectId, experimentId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, spanAttributes, isRoot, origin, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, isRoot=$isRoot, origin=$origin, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt new file mode 100644 index 00000000..b4bf81b7 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toImmutable +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects + +@JsonDeserialize(builder = ExperimentInsertResponse.Builder::class) +@NoAutoDetect +class ExperimentInsertResponse +private constructor( + private val rowIds: JsonField>, + private val serializedSpanSlugs: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + fun rowIds(): List = rowIds.getRequired("row_ids") + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + fun serializedSpanSlugs(): List = + serializedSpanSlugs.getRequired("serialized_span_slugs") + + fun toInsertEventsResponse(): InsertEventsResponse = + InsertEventsResponse.builder().rowIds(rowIds).build() + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + @JsonProperty("serialized_span_slugs") + @ExcludeMissing + fun _serializedSpanSlugs() = serializedSpanSlugs + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ExperimentInsertResponse = apply { + if (!validated) { + rowIds() + serializedSpanSlugs() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var rowIds: JsonField> = JsonMissing.of() + private var serializedSpanSlugs: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(experimentInsertResponse: ExperimentInsertResponse) = apply { + this.rowIds = experimentInsertResponse.rowIds + this.serializedSpanSlugs = experimentInsertResponse.serializedSpanSlugs + additionalProperties(experimentInsertResponse.additionalProperties) + } + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + @JsonProperty("row_ids") + @ExcludeMissing + fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + fun serializedSpanSlugs(serializedSpanSlugs: List) = + serializedSpanSlugs(JsonField.of(serializedSpanSlugs)) + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + @JsonProperty("serialized_span_slugs") + @ExcludeMissing + fun serializedSpanSlugs(serializedSpanSlugs: JsonField>) = apply { + this.serializedSpanSlugs = serializedSpanSlugs + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExperimentInsertResponse = + ExperimentInsertResponse( + rowIds.map { it.toImmutable() }, + serializedSpanSlugs.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentInsertResponse && this.rowIds == other.rowIds && this.serializedSpanSlugs == other.serializedSpanSlugs && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(rowIds, serializedSpanSlugs, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ExperimentInsertResponse{rowIds=$rowIds, serializedSpanSlugs=$serializedSpanSlugs, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index fbfc004b..8d58dec8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -1086,6 +1086,184 @@ constructor( } } } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val chatCompletionContentPartText: ChatCompletionContentPartText? = + null, + private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = + null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = + chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = + chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText( + chatCompletionContentPartText + ) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage( + chatCompletionContentPartImage + ) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if ( + chatCompletionContentPartText == null && + chatCompletionContentPartImage == null + ) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = + ChatCompletionContentPart( + chatCompletionContentPartText = chatCompletionContentPartText + ) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) + } + } + + class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject(value.chatCompletionContentPartText) + value.chatCompletionContentPartImage != null -> + generator.writeObject(value.chatCompletionContentPartImage) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + } + } } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt deleted file mode 100644 index 6964d2bf..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionToolChoice.kt +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = FunctionToolChoice.Builder::class) -@NoAutoDetect -class FunctionToolChoice -private constructor( - private val name: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): FunctionToolChoice = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(functionToolChoice: FunctionToolChoice) = apply { - this.name = functionToolChoice.name - additionalProperties(functionToolChoice.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): FunctionToolChoice = - FunctionToolChoice(name, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionToolChoice && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "FunctionToolChoice{name=$name, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt index 347e678b..752c52bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt @@ -892,6 +892,9 @@ private constructor( private val promptTokens: JsonField, private val completionTokens: JsonField, private val tokens: JsonField, + private val callerFunctionname: JsonValue, + private val callerFilename: JsonValue, + private val callerLineno: JsonValue, private val additionalProperties: Map, ) { @@ -926,6 +929,15 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + /** This metric is deprecated */ + fun callerFunctionname(): JsonValue = callerFunctionname + + /** This metric is deprecated */ + fun callerFilename(): JsonValue = callerFilename + + /** This metric is deprecated */ + fun callerLineno(): JsonValue = callerLineno + /** * A unix timestamp recording when the section of code which produced the experiment event * started @@ -955,6 +967,17 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** This metric is deprecated */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -966,6 +989,9 @@ private constructor( promptTokens() completionTokens() tokens() + callerFunctionname() + callerFilename() + callerLineno() validated = true } } @@ -984,6 +1010,9 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var completionTokens: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -993,6 +1022,9 @@ private constructor( this.promptTokens = metrics.promptTokens this.completionTokens = metrics.completionTokens this.tokens = metrics.tokens + this.callerFunctionname = metrics.callerFunctionname + this.callerFilename = metrics.callerFilename + this.callerLineno = metrics.callerLineno additionalProperties(metrics.additionalProperties) } @@ -1065,6 +1097,25 @@ private constructor( @ExcludeMissing fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -1086,6 +1137,9 @@ private constructor( promptTokens, completionTokens, tokens, + callerFunctionname, + callerFilename, + callerLineno, additionalProperties.toImmutable(), ) } @@ -1095,20 +1149,20 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt index 534b5552..1bbce65c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt @@ -885,6 +885,9 @@ private constructor( private val promptTokens: JsonField, private val completionTokens: JsonField, private val tokens: JsonField, + private val callerFunctionname: JsonValue, + private val callerFilename: JsonValue, + private val callerLineno: JsonValue, private val additionalProperties: Map, ) { @@ -919,6 +922,15 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + /** This metric is deprecated */ + fun callerFunctionname(): JsonValue = callerFunctionname + + /** This metric is deprecated */ + fun callerFilename(): JsonValue = callerFilename + + /** This metric is deprecated */ + fun callerLineno(): JsonValue = callerLineno + /** * A unix timestamp recording when the section of code which produced the experiment event * started @@ -948,6 +960,17 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** This metric is deprecated */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -959,6 +982,9 @@ private constructor( promptTokens() completionTokens() tokens() + callerFunctionname() + callerFilename() + callerLineno() validated = true } } @@ -977,6 +1003,9 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var completionTokens: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -986,6 +1015,9 @@ private constructor( this.promptTokens = metrics.promptTokens this.completionTokens = metrics.completionTokens this.tokens = metrics.tokens + this.callerFunctionname = metrics.callerFunctionname + this.callerFilename = metrics.callerFilename + this.callerLineno = metrics.callerLineno additionalProperties(metrics.additionalProperties) } @@ -1058,6 +1090,25 @@ private constructor( @ExcludeMissing fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -1079,6 +1130,9 @@ private constructor( promptTokens, completionTokens, tokens, + callerFunctionname, + callerFilename, + callerLineno, additionalProperties.toImmutable(), ) } @@ -1088,20 +1142,20 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt index d6b9ec48..77edee4f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt @@ -844,6 +844,9 @@ private constructor( private val promptTokens: JsonField, private val completionTokens: JsonField, private val tokens: JsonField, + private val callerFunctionname: JsonValue, + private val callerFilename: JsonValue, + private val callerLineno: JsonValue, private val additionalProperties: Map, ) { @@ -878,6 +881,15 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + /** This metric is deprecated */ + fun callerFunctionname(): JsonValue = callerFunctionname + + /** This metric is deprecated */ + fun callerFilename(): JsonValue = callerFilename + + /** This metric is deprecated */ + fun callerLineno(): JsonValue = callerLineno + /** * A unix timestamp recording when the section of code which produced the project logs event * started @@ -907,6 +919,17 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** This metric is deprecated */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -918,6 +941,9 @@ private constructor( promptTokens() completionTokens() tokens() + callerFunctionname() + callerFilename() + callerLineno() validated = true } } @@ -936,6 +962,9 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var completionTokens: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -945,6 +974,9 @@ private constructor( this.promptTokens = metrics.promptTokens this.completionTokens = metrics.completionTokens this.tokens = metrics.tokens + this.callerFunctionname = metrics.callerFunctionname + this.callerFilename = metrics.callerFilename + this.callerLineno = metrics.callerLineno additionalProperties(metrics.additionalProperties) } @@ -1017,6 +1049,25 @@ private constructor( @ExcludeMissing fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -1038,6 +1089,9 @@ private constructor( promptTokens, completionTokens, tokens, + callerFunctionname, + callerFilename, + callerLineno, additionalProperties.toImmutable(), ) } @@ -1047,20 +1101,20 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt index 077294aa..352b16ff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt @@ -837,6 +837,9 @@ private constructor( private val promptTokens: JsonField, private val completionTokens: JsonField, private val tokens: JsonField, + private val callerFunctionname: JsonValue, + private val callerFilename: JsonValue, + private val callerLineno: JsonValue, private val additionalProperties: Map, ) { @@ -871,6 +874,15 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + /** This metric is deprecated */ + fun callerFunctionname(): JsonValue = callerFunctionname + + /** This metric is deprecated */ + fun callerFilename(): JsonValue = callerFilename + + /** This metric is deprecated */ + fun callerLineno(): JsonValue = callerLineno + /** * A unix timestamp recording when the section of code which produced the project logs event * started @@ -900,6 +912,17 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** This metric is deprecated */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -911,6 +934,9 @@ private constructor( promptTokens() completionTokens() tokens() + callerFunctionname() + callerFilename() + callerLineno() validated = true } } @@ -929,6 +955,9 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var completionTokens: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -938,6 +967,9 @@ private constructor( this.promptTokens = metrics.promptTokens this.completionTokens = metrics.completionTokens this.tokens = metrics.tokens + this.callerFunctionname = metrics.callerFunctionname + this.callerFilename = metrics.callerFilename + this.callerLineno = metrics.callerLineno additionalProperties(metrics.additionalProperties) } @@ -1010,6 +1042,25 @@ private constructor( @ExcludeMissing fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -1031,6 +1082,9 @@ private constructor( promptTokens, completionTokens, tokens, + callerFunctionname, + callerFilename, + callerLineno, additionalProperties.toImmutable(), ) } @@ -1040,20 +1094,20 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt new file mode 100644 index 00000000..e529d36e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toImmutable +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects + +@JsonDeserialize(builder = ProjectLogInsertResponse.Builder::class) +@NoAutoDetect +class ProjectLogInsertResponse +private constructor( + private val rowIds: JsonField>, + private val serializedSpanSlugs: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + fun rowIds(): List = rowIds.getRequired("row_ids") + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + fun serializedSpanSlugs(): List = + serializedSpanSlugs.getRequired("serialized_span_slugs") + + fun toInsertEventsResponse(): InsertEventsResponse = + InsertEventsResponse.builder().rowIds(rowIds).build() + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + @JsonProperty("serialized_span_slugs") + @ExcludeMissing + fun _serializedSpanSlugs() = serializedSpanSlugs + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectLogInsertResponse = apply { + if (!validated) { + rowIds() + serializedSpanSlugs() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var rowIds: JsonField> = JsonMissing.of() + private var serializedSpanSlugs: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectLogInsertResponse: ProjectLogInsertResponse) = apply { + this.rowIds = projectLogInsertResponse.rowIds + this.serializedSpanSlugs = projectLogInsertResponse.serializedSpanSlugs + additionalProperties(projectLogInsertResponse.additionalProperties) + } + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + @JsonProperty("row_ids") + @ExcludeMissing + fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + fun serializedSpanSlugs(serializedSpanSlugs: List) = + serializedSpanSlugs(JsonField.of(serializedSpanSlugs)) + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + @JsonProperty("serialized_span_slugs") + @ExcludeMissing + fun serializedSpanSlugs(serializedSpanSlugs: JsonField>) = apply { + this.serializedSpanSlugs = serializedSpanSlugs + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ProjectLogInsertResponse = + ProjectLogInsertResponse( + rowIds.map { it.toImmutable() }, + serializedSpanSlugs.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogInsertResponse && this.rowIds == other.rowIds && this.serializedSpanSlugs == other.serializedSpanSlugs && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(rowIds, serializedSpanSlugs, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectLogInsertResponse{rowIds=$rowIds, serializedSpanSlugs=$serializedSpanSlugs, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 4b00e9ed..08cd1ead 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -41,7 +41,9 @@ private constructor( private val spanId: JsonField, private val spanParents: JsonField>, private val rootSpanId: JsonField, + private val isRoot: JsonField, private val spanAttributes: JsonField, + private val origin: JsonField, private val additionalProperties: Map, ) { @@ -151,10 +153,16 @@ private constructor( /** The `span_id` of the root of the trace this project logs event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") + /** Whether this span is a root span */ + fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) + /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you @@ -258,9 +266,15 @@ private constructor( /** The `span_id` of the root of the trace this project logs event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + /** Whether this span is a root span */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot() = isRoot + /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -285,7 +299,9 @@ private constructor( spanId() spanParents() rootSpanId() + isRoot() spanAttributes().map { it.validate() } + origin().map { it.validate() } validated = true } } @@ -317,7 +333,9 @@ private constructor( private var spanId: JsonField = JsonMissing.of() private var spanParents: JsonField> = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() + private var isRoot: JsonField = JsonMissing.of() private var spanAttributes: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -340,7 +358,9 @@ private constructor( this.spanId = projectLogsEvent.spanId this.spanParents = projectLogsEvent.spanParents this.rootSpanId = projectLogsEvent.rootSpanId + this.isRoot = projectLogsEvent.isRoot this.spanAttributes = projectLogsEvent.spanAttributes + this.origin = projectLogsEvent.origin additionalProperties(projectLogsEvent.additionalProperties) } @@ -565,6 +585,14 @@ private constructor( @ExcludeMissing fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean) = isRoot(JsonField.of(isRoot)) + + /** Whether this span is a root span */ + @JsonProperty("is_root") + @ExcludeMissing + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) @@ -576,6 +604,14 @@ private constructor( this.spanAttributes = spanAttributes } + /** Indicates the event was copied from another object. */ + fun origin(origin: Origin) = origin(JsonField.of(origin)) + + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") + @ExcludeMissing + fun origin(origin: JsonField) = apply { this.origin = origin } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -610,7 +646,9 @@ private constructor( spanId, spanParents.map { it.toImmutable() }, rootSpanId, + isRoot, spanAttributes, + origin, additionalProperties.toImmutable(), ) } @@ -910,6 +948,9 @@ private constructor( private val promptTokens: JsonField, private val completionTokens: JsonField, private val tokens: JsonField, + private val callerFunctionname: JsonValue, + private val callerFilename: JsonValue, + private val callerLineno: JsonValue, private val additionalProperties: Map, ) { @@ -944,6 +985,15 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) + /** This metric is deprecated */ + fun callerFunctionname(): JsonValue = callerFunctionname + + /** This metric is deprecated */ + fun callerFilename(): JsonValue = callerFilename + + /** This metric is deprecated */ + fun callerLineno(): JsonValue = callerLineno + /** * A unix timestamp recording when the section of code which produced the project logs event * started @@ -973,6 +1023,17 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname() = callerFunctionname + + /** This metric is deprecated */ + @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -984,6 +1045,9 @@ private constructor( promptTokens() completionTokens() tokens() + callerFunctionname() + callerFilename() + callerLineno() validated = true } } @@ -1002,6 +1066,9 @@ private constructor( private var promptTokens: JsonField = JsonMissing.of() private var completionTokens: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1011,6 +1078,9 @@ private constructor( this.promptTokens = metrics.promptTokens this.completionTokens = metrics.completionTokens this.tokens = metrics.tokens + this.callerFunctionname = metrics.callerFunctionname + this.callerFilename = metrics.callerFilename + this.callerLineno = metrics.callerLineno additionalProperties(metrics.additionalProperties) } @@ -1083,6 +1153,25 @@ private constructor( @ExcludeMissing fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") + @ExcludeMissing + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -1104,29 +1193,268 @@ private constructor( promptTokens, completionTokens, tokens, + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + } + + /** Indicates the event was copied from another object. */ + @JsonDeserialize(builder = Origin.Builder::class) + @NoAutoDetect + class Origin + private constructor( + private val objectType: JsonField, + private val objectId: JsonField, + private val id: JsonField, + private val _xactId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** Type of the object the event is originating from. */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** ID of the object the event is originating from. */ + fun objectId(): String = objectId.getRequired("object_id") + + /** ID of the original event. */ + fun id(): String = id.getRequired("id") + + /** Transaction ID of the original event. */ + fun _xactId(): String = _xactId.getRequired("_xact_id") + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + + /** ID of the original event. */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** Transaction ID of the original event. */ + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Origin = apply { + if (!validated) { + objectType() + objectId() + id() + _xactId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objectType: JsonField = JsonMissing.of() + private var objectId: JsonField = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var _xactId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(origin: Origin) = apply { + this.objectType = origin.objectType + this.objectId = origin.objectId + this.id = origin.id + this._xactId = origin._xactId + additionalProperties(origin.additionalProperties) + } + + /** Type of the object the event is originating from. */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") + @ExcludeMissing + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** ID of the object the event is originating from. */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") + @ExcludeMissing + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** ID of the original event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** ID of the original event. */ + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** Transaction ID of the original event. */ + fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) + + /** Transaction ID of the original event. */ + @JsonProperty("_xact_id") + @ExcludeMissing + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Origin = + Origin( + objectType, + objectId, + id, + _xactId, additionalProperties.toImmutable(), ) } + class ObjectType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + + @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + + @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + + @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + + @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + + @JvmField val PROJECT_LOGS = ObjectType(JsonField.of("project_logs")) + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + enum class Known { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + } + + enum class Value { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + FUNCTION -> Value.FUNCTION + PROMPT_SESSION -> Value.PROMPT_SESSION + PROJECT_LOGS -> Value.PROJECT_LOGS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + FUNCTION -> Known.FUNCTION + PROMPT_SESSION -> Known.PROMPT_SESSION + PROJECT_LOGS -> Known.PROJECT_LOGS + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.id == other.id && this._xactId == other._xactId && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(objectType, objectId, id, _xactId, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" } /** @@ -1411,18 +1739,18 @@ private constructor( return true } - return /* spotless:off */ other is ProjectLogsEvent && this.id == other.id && this._xactId == other._xactId && this.created == other.created && this.orgId == other.orgId && this.projectId == other.projectId && this.logId == other.logId && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanId == other.spanId && this.spanParents == other.spanParents && this.rootSpanId == other.rootSpanId && this.spanAttributes == other.spanAttributes && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogsEvent && this.id == other.id && this._xactId == other._xactId && this.created == other.created && this.orgId == other.orgId && this.projectId == other.projectId && this.logId == other.logId && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanId == other.spanId && this.spanParents == other.spanParents && this.rootSpanId == other.rootSpanId && this.isRoot == other.isRoot && this.spanAttributes == other.spanAttributes && this.origin == other.origin && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, _xactId, created, orgId, projectId, logId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, spanAttributes, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, _xactId, created, orgId, projectId, logId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, isRoot, spanAttributes, origin, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, isRoot=$isRoot, spanAttributes=$spanAttributes, origin=$origin, additionalProperties=$additionalProperties}" } 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 50a0170c..757c5b2d 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,6 +4,7 @@ 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 @@ -14,6 +15,7 @@ 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 import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -37,7 +39,7 @@ private constructor( private val created: JsonField, private val name: JsonField, private val description: JsonField, - private val scoreType: JsonField, + private val scoreType: JsonField, private val categories: JsonField, private val config: JsonField, private val position: JsonField, @@ -65,7 +67,7 @@ private constructor( Optional.ofNullable(description.getNullable("description")) /** The type of the configured score */ - fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") + fun scoreType(): ScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ fun categories(): Optional = @@ -139,7 +141,7 @@ private constructor( private var created: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var scoreType: JsonField = JsonMissing.of() + private var scoreType: JsonField = JsonMissing.of() private var categories: JsonField = JsonMissing.of() private var config: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() @@ -205,12 +207,12 @@ private constructor( fun description(description: JsonField) = apply { this.description = description } /** The type of the configured score */ - fun scoreType(scoreType: ProjectScoreType) = scoreType(JsonField.of(scoreType)) + fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ @JsonProperty("score_type") @ExcludeMissing - 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.of(categories)) @@ -264,6 +266,87 @@ private constructor( ) } + class ScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScoreType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SLIDER = ScoreType(JsonField.of("slider")) + + @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) + + @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) + + @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) + + @JvmField val MAXIMUM = ScoreType(JsonField.of("maximum")) + + @JvmField val ONLINE = ScoreType(JsonField.of("online")) + + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + MAXIMUM -> Value.MAXIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + MAXIMUM -> Known.MAXIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) class Categories 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 237a7440..60058737 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,9 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow @@ -14,6 +16,7 @@ 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 import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -29,7 +32,7 @@ class ProjectScoreCreateParams constructor( private val name: String, private val projectId: String, - private val scoreType: ProjectScoreType, + private val scoreType: ScoreType, private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, @@ -42,7 +45,7 @@ constructor( fun projectId(): String = projectId - fun scoreType(): ProjectScoreType = scoreType + fun scoreType(): ScoreType = scoreType fun categories(): Optional = Optional.ofNullable(categories) @@ -74,7 +77,7 @@ constructor( internal constructor( private val name: String?, private val projectId: String?, - private val scoreType: ProjectScoreType?, + private val scoreType: ScoreType?, private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, @@ -88,7 +91,7 @@ constructor( @JsonProperty("project_id") fun projectId(): String? = projectId /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ProjectScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") fun categories(): Categories? = categories @@ -113,7 +116,7 @@ constructor( private var name: String? = null private var projectId: String? = null - private var scoreType: ProjectScoreType? = null + private var scoreType: ScoreType? = null private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null @@ -139,7 +142,7 @@ constructor( /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @@ -232,7 +235,7 @@ constructor( private var name: String? = null private var projectId: String? = null - private var scoreType: ProjectScoreType? = null + private var scoreType: ScoreType? = null private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null @@ -260,7 +263,7 @@ constructor( fun projectId(projectId: String) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = apply { this.categories = categories } @@ -424,6 +427,87 @@ constructor( ) } + class ScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScoreType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SLIDER = ScoreType(JsonField.of("slider")) + + @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) + + @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) + + @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) + + @JvmField val MAXIMUM = ScoreType(JsonField.of("maximum")) + + @JvmField val ONLINE = ScoreType(JsonField.of("online")) + + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + MAXIMUM -> Value.MAXIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + MAXIMUM -> Known.MAXIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) class Categories 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 40ba8c94..7fcf0fe2 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,6 +4,8 @@ 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.getOrThrow @@ -11,6 +13,7 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -176,7 +179,7 @@ constructor( fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } /** The type of the configured score */ - fun scoreType(projectScoreType: ProjectScoreType) = apply { + fun scoreType(projectScoreType: ScoreType.ProjectScoreType) = apply { this.scoreType = ScoreType.ofProjectScoreType(projectScoreType) } @@ -542,5 +545,167 @@ constructor( } } } + + class ProjectScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SLIDER = ProjectScoreType(JsonField.of("slider")) + + @JvmField val CATEGORICAL = ProjectScoreType(JsonField.of("categorical")) + + @JvmField val WEIGHTED = ProjectScoreType(JsonField.of("weighted")) + + @JvmField val MINIMUM = ProjectScoreType(JsonField.of("minimum")) + + @JvmField val MAXIMUM = ProjectScoreType(JsonField.of("maximum")) + + @JvmField val ONLINE = ProjectScoreType(JsonField.of("online")) + + @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + MAXIMUM -> Value.MAXIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + MAXIMUM -> Known.MAXIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class ProjectScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SLIDER = ProjectScoreType(JsonField.of("slider")) + + @JvmField val CATEGORICAL = ProjectScoreType(JsonField.of("categorical")) + + @JvmField val WEIGHTED = ProjectScoreType(JsonField.of("weighted")) + + @JvmField val MINIMUM = ProjectScoreType(JsonField.of("minimum")) + + @JvmField val MAXIMUM = ProjectScoreType(JsonField.of("maximum")) + + @JvmField val ONLINE = ProjectScoreType(JsonField.of("online")) + + @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + MAXIMUM -> Value.MAXIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + MAXIMUM -> Known.MAXIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } } } 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 6b7d82d6..99729d33 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,9 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow @@ -14,6 +16,7 @@ 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 import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -29,7 +32,7 @@ class ProjectScoreReplaceParams constructor( private val name: String, private val projectId: String, - private val scoreType: ProjectScoreType, + private val scoreType: ScoreType, private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, @@ -42,7 +45,7 @@ constructor( fun projectId(): String = projectId - fun scoreType(): ProjectScoreType = scoreType + fun scoreType(): ScoreType = scoreType fun categories(): Optional = Optional.ofNullable(categories) @@ -74,7 +77,7 @@ constructor( internal constructor( private val name: String?, private val projectId: String?, - private val scoreType: ProjectScoreType?, + private val scoreType: ScoreType?, private val categories: Categories?, private val config: ProjectScoreConfig?, private val description: String?, @@ -88,7 +91,7 @@ constructor( @JsonProperty("project_id") fun projectId(): String? = projectId /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ProjectScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") fun categories(): Categories? = categories @@ -113,7 +116,7 @@ constructor( private var name: String? = null private var projectId: String? = null - private var scoreType: ProjectScoreType? = null + private var scoreType: ScoreType? = null private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null @@ -139,7 +142,7 @@ constructor( /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @@ -232,7 +235,7 @@ constructor( private var name: String? = null private var projectId: String? = null - private var scoreType: ProjectScoreType? = null + private var scoreType: ScoreType? = null private var categories: Categories? = null private var config: ProjectScoreConfig? = null private var description: String? = null @@ -260,7 +263,7 @@ constructor( fun projectId(projectId: String) = apply { this.projectId = projectId } /** The type of the configured score */ - fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = apply { this.categories = categories } @@ -424,6 +427,87 @@ constructor( ) } + class ScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScoreType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SLIDER = ScoreType(JsonField.of("slider")) + + @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) + + @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) + + @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) + + @JvmField val MAXIMUM = ScoreType(JsonField.of("maximum")) + + @JvmField val ONLINE = ScoreType(JsonField.of("online")) + + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + MAXIMUM -> Value.MAXIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + MAXIMUM -> Known.MAXIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) class Categories 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 deleted file mode 100644 index 2d9449e0..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt +++ /dev/null @@ -1,84 +0,0 @@ -// 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.core.JsonValue -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator - -class ProjectScoreType -@JsonCreator -private constructor( - private val value: JsonField, -) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreType && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SLIDER = ProjectScoreType(JsonField.of("slider")) - - @JvmField val CATEGORICAL = ProjectScoreType(JsonField.of("categorical")) - - @JvmField val WEIGHTED = ProjectScoreType(JsonField.of("weighted")) - - @JvmField val MINIMUM = ProjectScoreType(JsonField.of("minimum")) - - @JvmField val ONLINE = ProjectScoreType(JsonField.of("online")) - - @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - ONLINE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() -} 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 b6e0e621..5f942fad 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,9 @@ 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.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.getOrThrow @@ -14,6 +16,7 @@ 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 import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -32,7 +35,7 @@ constructor( private val config: ProjectScoreConfig?, private val description: String?, private val name: String?, - private val scoreType: ProjectScoreType?, + private val scoreType: ScoreType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -48,7 +51,7 @@ constructor( fun name(): Optional = Optional.ofNullable(name) - fun scoreType(): Optional = Optional.ofNullable(scoreType) + fun scoreType(): Optional = Optional.ofNullable(scoreType) @JvmSynthetic internal fun getBody(): ProjectScoreUpdateBody { @@ -82,7 +85,7 @@ constructor( private val config: ProjectScoreConfig?, private val description: String?, private val name: String?, - private val scoreType: ProjectScoreType?, + private val scoreType: ScoreType?, private val additionalProperties: Map, ) { @@ -98,7 +101,7 @@ constructor( @JsonProperty("name") fun name(): String? = name /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ProjectScoreType? = scoreType + @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType @JsonAnyGetter @ExcludeMissing @@ -117,7 +120,7 @@ constructor( private var config: ProjectScoreConfig? = null private var description: String? = null private var name: String? = null - private var scoreType: ProjectScoreType? = null + private var scoreType: ScoreType? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -146,7 +149,7 @@ constructor( /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -230,7 +233,7 @@ constructor( private var config: ProjectScoreConfig? = null private var description: String? = null private var name: String? = null - private var scoreType: ProjectScoreType? = null + private var scoreType: ScoreType? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -283,7 +286,7 @@ constructor( fun name(name: String) = apply { this.name = name } /** The type of the configured score */ - fun scoreType(scoreType: ProjectScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -731,4 +734,85 @@ constructor( override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } + + class ScoreType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScoreType && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SLIDER = ScoreType(JsonField.of("slider")) + + @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) + + @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) + + @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) + + @JvmField val MAXIMUM = ScoreType(JsonField.of("maximum")) + + @JvmField val ONLINE = ScoreType(JsonField.of("online")) + + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) + } + + enum class Known { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + } + + enum class Value { + SLIDER, + CATEGORICAL, + WEIGHTED, + MINIMUM, + MAXIMUM, + ONLINE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + MAXIMUM -> Value.MAXIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + MAXIMUM -> Known.MAXIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index f131d577..d7dd2178 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -562,7 +562,7 @@ private constructor( maxTokens() frequencyPenalty() presencePenalty() - responseFormat().map { it.validate() } + responseFormat() toolChoice() functionCall() n() @@ -1053,76 +1053,1197 @@ private constructor( } } - @JsonDeserialize(builder = ResponseFormat.Builder::class) - @NoAutoDetect + @JsonDeserialize(using = ResponseFormat.Deserializer::class) + @JsonSerialize(using = ResponseFormat.Serializer::class) class ResponseFormat private constructor( - private val type: JsonField, - private val additionalProperties: Map, + private val jsonObject: JsonObject? = null, + private val jsonSchema: JsonSchema? = null, + private val text: Text? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun type(): Type = type.getRequired("type") + fun jsonObject(): Optional = Optional.ofNullable(jsonObject) + + fun jsonSchema(): Optional = Optional.ofNullable(jsonSchema) + + fun text(): Optional = Optional.ofNullable(text) + + fun nullableVariant(): Optional = + Optional.ofNullable(nullableVariant) + + fun isJsonObject(): Boolean = jsonObject != null + + fun isJsonSchema(): Boolean = jsonSchema != null + + fun isText(): Boolean = text != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asJsonObject(): JsonObject = jsonObject.getOrThrow("jsonObject") + + fun asJsonSchema(): JsonSchema = jsonSchema.getOrThrow("jsonSchema") + + fun asText(): Text = text.getOrThrow("text") + + fun asNullableVariant(): NullableVariant = + nullableVariant.getOrThrow("nullableVariant") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + jsonObject != null -> visitor.visitJsonObject(jsonObject) + jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) + text != null -> visitor.visitText(text) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } + } + + fun validate(): ResponseFormat = apply { + if (!validated) { + if ( + jsonObject == null && + jsonSchema == null && + text == null && + nullableVariant == null + ) { + throw BraintrustInvalidDataException( + "Unknown ResponseFormat: $_json" + ) + } + jsonObject?.validate() + jsonSchema?.validate() + text?.validate() + nullableVariant?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ResponseFormat && this.jsonObject == other.jsonObject && this.jsonSchema == other.jsonSchema && this.text == other.text && this.nullableVariant == other.nullableVariant /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ + } + + override fun toString(): String { + return when { + jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" + jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" + text != null -> "ResponseFormat{text=$text}" + nullableVariant != null -> + "ResponseFormat{nullableVariant=$nullableVariant}" + _json != null -> "ResponseFormat{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ResponseFormat") + } + } + + companion object { + + @JvmStatic + fun ofJsonObject(jsonObject: JsonObject) = + ResponseFormat(jsonObject = jsonObject) + + @JvmStatic + fun ofJsonSchema(jsonSchema: JsonSchema) = + ResponseFormat(jsonSchema = jsonSchema) + + @JvmStatic fun ofText(text: Text) = ResponseFormat(text = text) + + @JvmStatic + fun ofNullableVariant(nullableVariant: NullableVariant) = + ResponseFormat(nullableVariant = nullableVariant) + } + + interface Visitor { + + fun visitJsonObject(jsonObject: JsonObject): T + + fun visitJsonSchema(jsonSchema: JsonSchema): T + + fun visitText(text: Text): T + + fun visitNullableVariant(nullableVariant: NullableVariant): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") + } + } + + class Deserializer : BaseDeserializer(ResponseFormat::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ResponseFormat { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(jsonObject = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(jsonSchema = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ResponseFormat(nullableVariant = it, _json = json) + } + + return ResponseFormat(_json = json) + } + } + + class Serializer : BaseSerializer(ResponseFormat::class) { + + override fun serialize( + value: ResponseFormat, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.jsonObject != null -> generator.writeObject(value.jsonObject) + value.jsonSchema != null -> generator.writeObject(value.jsonSchema) + value.text != null -> generator.writeObject(value.text) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ResponseFormat") + } + } + } + + @JsonDeserialize(builder = JsonObject.Builder::class) + @NoAutoDetect + class JsonObject + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): JsonObject = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(jsonObject: JsonObject) = apply { + this.type = jsonObject.type + additionalProperties(jsonObject.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): JsonObject = + JsonObject(type, additionalProperties.toImmutable()) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + JSON_OBJECT, + } + + enum class Value { + JSON_OBJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is JsonObject && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "JsonObject{type=$type, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = JsonSchema.Builder::class) + @NoAutoDetect + class JsonSchema + private constructor( + private val type: JsonField, + private val jsonSchema: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + fun jsonSchema(): JsonSchema = jsonSchema.getRequired("json_schema") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("json_schema") @ExcludeMissing fun _jsonSchema() = jsonSchema + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): JsonSchema = apply { + if (!validated) { + type() + jsonSchema().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var jsonSchema: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(jsonSchema: JsonSchema) = apply { + this.type = jsonSchema.type + this.jsonSchema = jsonSchema.jsonSchema + additionalProperties(jsonSchema.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun jsonSchema(jsonSchema: JsonSchema) = + jsonSchema(JsonField.of(jsonSchema)) + + @JsonProperty("json_schema") + @ExcludeMissing + fun jsonSchema(jsonSchema: JsonField) = apply { + this.jsonSchema = jsonSchema + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): JsonSchema = + JsonSchema( + type, + jsonSchema, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = JsonSchema.Builder::class) + @NoAutoDetect + class JsonSchema + private constructor( + private val name: JsonField, + private val description: JsonField, + private val schema: JsonField, + private val strict: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun name(): String = name.getRequired("name") + + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + fun schema(): Optional = + Optional.ofNullable(schema.getNullable("schema")) + + fun strict(): Optional = + Optional.ofNullable(strict.getNullable("strict")) + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("description") + @ExcludeMissing + fun _description() = description + + @JsonProperty("schema") @ExcludeMissing fun _schema() = schema + + @JsonProperty("strict") @ExcludeMissing fun _strict() = strict + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): JsonSchema = apply { + if (!validated) { + name() + description() + schema().map { it.validate() } + strict() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var schema: JsonField = JsonMissing.of() + private var strict: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(jsonSchema: JsonSchema) = apply { + this.name = jsonSchema.name + this.description = jsonSchema.description + this.schema = jsonSchema.schema + this.strict = jsonSchema.strict + additionalProperties(jsonSchema.additionalProperties) + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun description(description: String) = + description(JsonField.of(description)) + + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { + this.description = description + } + + fun schema(schema: Schema) = schema(JsonField.of(schema)) + + @JsonProperty("schema") + @ExcludeMissing + fun schema(schema: JsonField) = apply { + this.schema = schema + } + + fun strict(strict: Boolean) = strict(JsonField.of(strict)) + + @JsonProperty("strict") + @ExcludeMissing + fun strict(strict: JsonField) = apply { + this.strict = strict + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): JsonSchema = + JsonSchema( + name, + description, + schema, + strict, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = Schema.Builder::class) + @NoAutoDetect + class Schema + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Schema = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(schema: Schema) = apply { + additionalProperties(schema.additionalProperties) + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Schema = Schema(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schema && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Schema{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is JsonSchema && this.name == other.name && this.description == other.description && this.schema == other.schema && this.strict == other.strict && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, description, schema, strict, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "JsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val JSON_SCHEMA = Type(JsonField.of("json_schema")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + JSON_SCHEMA, + } + + enum class Value { + JSON_SCHEMA, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + JSON_SCHEMA -> Value.JSON_SCHEMA + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + JSON_SCHEMA -> Known.JSON_SCHEMA + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is JsonSchema && this.type == other.type && this.jsonSchema == other.jsonSchema && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, jsonSchema, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "JsonSchema{type=$type, jsonSchema=$jsonSchema, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Text.Builder::class) + @NoAutoDetect + class Text + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Text = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(text: Text) = apply { + this.type = text.type + additionalProperties(text.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Text = Text(type, additionalProperties.toImmutable()) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TEXT = Type(JsonField.of("text")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + TEXT, + } + + enum class Value { + TEXT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Text && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Text{type=$type, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = NullableVariant.Builder::class) + @NoAutoDetect + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): NullableVariant = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): NullableVariant = + NullableVariant(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(using = ToolChoice.Deserializer::class) + @JsonSerialize(using = ToolChoice.Serializer::class) + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val required: Required? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun required(): Optional = Optional.ofNullable(required) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isRequired(): Boolean = required != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asRequired(): Required = required.getOrThrow("required") + + fun asFunction(): Function = function.getOrThrow("function") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + required != null -> visitor.visitRequired(required) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } + } + + fun validate(): ToolChoice = apply { + if (!validated) { + if ( + auto == null && none == null && required == null && function == null + ) { + throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") + } + function?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ToolChoice && this.auto == other.auto && this.none == other.none && this.required == other.required && this.function == other.function /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(auto, none, required, function) /* spotless:on */ + } + + override fun toString(): String { + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + required != null -> "ToolChoice{required=$required}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } + } + + companion object { + + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) + + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) + + @JvmStatic + fun ofRequired(required: Required) = ToolChoice(required = required) + + @JvmStatic + fun ofFunction(function: Function) = ToolChoice(function = function) + } + + interface Visitor { + + fun visitAuto(auto: Auto): T + + fun visitNone(none: None): T + + fun visitRequired(required: Required): T + + fun visitFunction(function: Function): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + } + } + + class Deserializer : BaseDeserializer(ToolChoice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(required = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } + + return ToolChoice(_json = json) + } + } + + class Serializer : BaseSerializer(ToolChoice::class) { + + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.required != null -> generator.writeObject(value.required) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } + } + } + + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AUTO = Auto(JsonField.of("auto")) + + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) + } + + enum class Known { + AUTO, + } + + enum class Value { + AUTO, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> throw BraintrustInvalidDataException("Unknown Auto: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { - @JsonProperty("type") @ExcludeMissing fun _type() = type + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): ResponseFormat = apply { - if (!validated) { - type() - validated = true + return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ } - } - - fun toBuilder() = Builder().from(this) - companion object { + override fun hashCode() = value.hashCode() - @JvmStatic fun builder() = Builder() - } + override fun toString() = value.toString() - class Builder { + companion object { - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + @JvmField val NONE = None(JsonField.of("none")) - @JvmSynthetic - internal fun from(responseFormat: ResponseFormat) = apply { - this.type = responseFormat.type - additionalProperties(responseFormat.additionalProperties) + @JvmStatic fun of(value: String) = None(JsonField.of(value)) } - fun type(type: Type) = type(JsonField.of(type)) + enum class Known { + NONE, + } - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + enum class Value { + NONE, + _UNKNOWN, + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN } - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> throw BraintrustInvalidDataException("Unknown None: $value") + } - fun build(): ResponseFormat = - ResponseFormat(type, additionalProperties.toImmutable()) + fun asString(): String = _value().asStringOrThrow() } - class Type + class Required @JsonCreator private constructor( private val value: JsonField, @@ -1136,7 +2257,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Required && this.value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1145,54 +2266,290 @@ private constructor( companion object { - @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) + @JvmField val REQUIRED = Required(JsonField.of("required")) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun of(value: String) = Required(JsonField.of(value)) } enum class Known { - JSON_OBJECT, + REQUIRED, } enum class Value { - JSON_OBJECT, + REQUIRED, _UNKNOWN, } fun value(): Value = when (this) { - JSON_OBJECT -> Value.JSON_OBJECT + REQUIRED -> Value.REQUIRED else -> Value._UNKNOWN } fun known(): Known = when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") + REQUIRED -> Known.REQUIRED + else -> + throw BraintrustInvalidDataException("Unknown Required: $value") } fun asString(): String = _value().asStringOrThrow() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + fun function(): Function = function.getRequired("function") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("function") @ExcludeMissing fun _function() = function + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + type() + function().validate() + validated = true + } } - return /* spotless:off */ other is ResponseFormat && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } + fun toBuilder() = Builder().from(this) - private var hashCode: Int = 0 + companion object { - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + @JvmStatic fun builder() = Builder() } - return hashCode - } - override fun toString() = - "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + class Builder { + + private var type: JsonField = JsonMissing.of() + private var function: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun function(function: Function) = function(JsonField.of(function)) + + @JsonProperty("function") + @ExcludeMissing + fun function(function: JsonField) = apply { + this.function = function + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Function = + Function( + type, + function, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun name(): String = name.getRequired("name") + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Function = apply { + if (!validated) { + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Function = + Function(name, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> + throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.type == other.type && this.function == other.function && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, function, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { @@ -3238,6 +4595,209 @@ private constructor( } } } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val chatCompletionContentPartText: + ChatCompletionContentPartText? = + null, + private val chatCompletionContentPartImage: + ChatCompletionContentPartImage? = + null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): + Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): + Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = + chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = + chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow( + "chatCompletionContentPartText" + ) + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow( + "chatCompletionContentPartImage" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText( + chatCompletionContentPartText + ) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage( + chatCompletionContentPartImage + ) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if ( + chatCompletionContentPartText == null && + chatCompletionContentPartImage == null + ) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid ChatCompletionContentPart" + ) + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = + ChatCompletionContentPart( + chatCompletionContentPartText = + chatCompletionContentPartText + ) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = + chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) + } + } + + class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject( + value.chatCompletionContentPartText + ) + value.chatCompletionContentPartImage != null -> + generator.writeObject( + value.chatCompletionContentPartImage + ) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid ChatCompletionContentPart" + ) + } + } + } + } } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt deleted file mode 100644 index 9ddb4683..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Scorer.kt +++ /dev/null @@ -1,175 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -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 -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = Scorer.Builder::class) -@NoAutoDetect -class Scorer -private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") - - fun index(): Long = index.getRequired("index") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("index") @ExcludeMissing fun _index() = index - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scorer = apply { - if (!validated) { - type() - index() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var index: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scorer: Scorer) = apply { - this.type = scorer.type - this.index = scorer.index - additionalProperties(scorer.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun index(index: Long) = index(JsonField.of(index)) - - @JsonProperty("index") - @ExcludeMissing - fun index(index: JsonField) = apply { this.index = index } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SCORER = Type(JsonField.of("scorer")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - SCORER, - } - - enum class Value { - SCORER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Scorer && this.type == other.type && this.index == other.index && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, index, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt new file mode 100644 index 00000000..53141d9b --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -0,0 +1,277 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toImmutable +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = SpanIFrame.Builder::class) +@NoAutoDetect +class SpanIFrame +private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val deletedAt: JsonField, + private val name: JsonField, + private val description: JsonField, + private val url: JsonField, + private val postMessage: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** Unique identifier for the span iframe */ + fun id(): String = id.getRequired("id") + + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Identifies the user who created the span iframe */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** Date of span iframe creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** Date of span iframe deletion, or null if the span iframe is still active */ + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) + + /** Name of the span iframe */ + fun name(): String = name.getRequired("name") + + /** Textual description of the span iframe */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** URL to embed the project viewer in an iframe */ + fun url(): String = url.getRequired("url") + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. + */ + fun postMessage(): Optional = + Optional.ofNullable(postMessage.getNullable("post_message")) + + /** Unique identifier for the span iframe */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** Unique identifier for the project that the span iframe belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + + /** Identifies the user who created the span iframe */ + @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + + /** Date of span iframe creation */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** Date of span iframe deletion, or null if the span iframe is still active */ + @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + + /** Name of the span iframe */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Textual description of the span iframe */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") @ExcludeMissing fun _url() = url + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. + */ + @JsonProperty("post_message") @ExcludeMissing fun _postMessage() = postMessage + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SpanIFrame = apply { + if (!validated) { + id() + projectId() + userId() + created() + deletedAt() + name() + description() + url() + postMessage() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var projectId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var deletedAt: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var postMessage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanIFrame: SpanIFrame) = apply { + this.id = spanIFrame.id + this.projectId = spanIFrame.projectId + this.userId = spanIFrame.userId + this.created = spanIFrame.created + this.deletedAt = spanIFrame.deletedAt + this.name = spanIFrame.name + this.description = spanIFrame.description + this.url = spanIFrame.url + this.postMessage = spanIFrame.postMessage + additionalProperties(spanIFrame.additionalProperties) + } + + /** Unique identifier for the span iframe */ + fun id(id: String) = id(JsonField.of(id)) + + /** Unique identifier for the span iframe */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the span iframe belongs under */ + @JsonProperty("project_id") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Identifies the user who created the span iframe */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** Identifies the user who created the span iframe */ + @JsonProperty("user_id") + @ExcludeMissing + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** Date of span iframe creation */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** Date of span iframe creation */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** Date of span iframe deletion, or null if the span iframe is still active */ + fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + + /** Date of span iframe deletion, or null if the span iframe is still active */ + @JsonProperty("deleted_at") + @ExcludeMissing + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + + /** Name of the span iframe */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span iframe */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the span iframe */ + fun description(description: String) = description(JsonField.of(description)) + + /** Textual description of the span iframe */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** URL to embed the project viewer in an iframe */ + fun url(url: String) = url(JsonField.of(url)) + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") + @ExcludeMissing + fun url(url: JsonField) = apply { this.url = url } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = postMessage(JsonField.of(postMessage)) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") + @ExcludeMissing + fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanIFrame = + SpanIFrame( + id, + projectId, + userId, + created, + deletedAt, + name, + description, + url, + postMessage, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIFrame && this.id == other.id && this.projectId == other.projectId && this.userId == other.userId && this.created == other.created && this.deletedAt == other.deletedAt && this.name == other.name && this.description == other.description && this.url == other.url && this.postMessage == other.postMessage && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, projectId, userId, created, deletedAt, name, description, url, postMessage, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanIFrame{id=$id, projectId=$projectId, userId=$userId, created=$created, deletedAt=$deletedAt, name=$name, description=$description, url=$url, postMessage=$postMessage, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt new file mode 100644 index 00000000..617ccfe1 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -0,0 +1,386 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams +import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects +import java.util.Optional + +class SpanIframeCreateParams +constructor( + private val name: String, + private val projectId: String, + private val url: String, + private val description: String?, + private val postMessage: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) { + + fun name(): String = name + + fun projectId(): String = projectId + + fun url(): String = url + + fun description(): Optional = Optional.ofNullable(description) + + fun postMessage(): Optional = Optional.ofNullable(postMessage) + + @JvmSynthetic + internal fun getBody(): SpanIframeCreateBody { + return SpanIframeCreateBody( + name, + projectId, + url, + description, + postMessage, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + + @JsonDeserialize(builder = SpanIframeCreateBody.Builder::class) + @NoAutoDetect + class SpanIframeCreateBody + internal constructor( + private val name: String?, + private val projectId: String?, + private val url: String?, + private val description: String?, + private val postMessage: Boolean?, + private val additionalProperties: Map, + ) { + + /** Name of the span iframe */ + @JsonProperty("name") fun name(): String? = name + + /** Unique identifier for the project that the span iframe belongs under */ + @JsonProperty("project_id") fun projectId(): String? = projectId + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") fun url(): String? = url + + /** Textual description of the span iframe */ + @JsonProperty("description") fun description(): String? = description + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") fun postMessage(): Boolean? = postMessage + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: String? = null + private var projectId: String? = null + private var url: String? = null + private var description: String? = null + private var postMessage: Boolean? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanIframeCreateBody: SpanIframeCreateBody) = apply { + this.name = spanIframeCreateBody.name + this.projectId = spanIframeCreateBody.projectId + this.url = spanIframeCreateBody.url + this.description = spanIframeCreateBody.description + this.postMessage = spanIframeCreateBody.postMessage + additionalProperties(spanIframeCreateBody.additionalProperties) + } + + /** Name of the span iframe */ + @JsonProperty("name") fun name(name: String) = apply { this.name = name } + + /** Unique identifier for the project that the span iframe belongs under */ + @JsonProperty("project_id") + fun projectId(projectId: String) = apply { this.projectId = projectId } + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") fun url(url: String) = apply { this.url = url } + + /** Textual description of the span iframe */ + @JsonProperty("description") + fun description(description: String) = apply { this.description = description } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") + fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanIframeCreateBody = + SpanIframeCreateBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(url) { "`url` is required but was not set" }, + description, + postMessage, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeCreateBody && this.name == other.name && this.projectId == other.projectId && this.url == other.url && this.description == other.description && this.postMessage == other.postMessage && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanIframeCreateBody{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + } + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeCreateParams && this.name == other.name && this.projectId == other.projectId && this.url == other.url && this.description == other.description && this.postMessage == other.postMessage && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + } + + override fun toString() = + "SpanIframeCreateParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var name: String? = null + private var projectId: String? = null + private var url: String? = null + private var description: String? = null + private var postMessage: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = apply { + this.name = spanIframeCreateParams.name + this.projectId = spanIframeCreateParams.projectId + this.url = spanIframeCreateParams.url + this.description = spanIframeCreateParams.description + this.postMessage = spanIframeCreateParams.postMessage + additionalHeaders(spanIframeCreateParams.additionalHeaders) + additionalQueryParams(spanIframeCreateParams.additionalQueryParams) + additionalBodyProperties(spanIframeCreateParams.additionalBodyProperties) + } + + /** Name of the span iframe */ + fun name(name: String) = apply { this.name = name } + + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(projectId: String) = apply { this.projectId = projectId } + + /** URL to embed the project viewer in an iframe */ + fun url(url: String) = apply { this.url = url } + + /** Textual description of the span iframe */ + fun description(description: String) = apply { this.description = description } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + fun build(): SpanIframeCreateParams = + SpanIframeCreateParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(url) { "`url` is required but was not set" }, + description, + postMessage, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt new file mode 100644 index 00000000..de9931dc --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -0,0 +1,215 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams +import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models.* +import java.util.Objects +import java.util.Optional + +class SpanIframeDeleteParams +constructor( + private val spanIframeId: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) { + + fun spanIframeId(): String = spanIframeId + + @JvmSynthetic + internal fun getBody(): Optional> { + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + } + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> spanIframeId + else -> "" + } + } + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeDeleteParams && this.spanIframeId == other.spanIframeId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + } + + override fun toString() = + "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var spanIframeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanIframeDeleteParams: SpanIframeDeleteParams) = apply { + this.spanIframeId = spanIframeDeleteParams.spanIframeId + additionalHeaders(spanIframeDeleteParams.additionalHeaders) + additionalQueryParams(spanIframeDeleteParams.additionalQueryParams) + additionalBodyProperties(spanIframeDeleteParams.additionalBodyProperties) + } + + /** SpanIframe id */ + fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + fun build(): SpanIframeDeleteParams = + SpanIframeDeleteParams( + checkNotNull(spanIframeId) { "`spanIframeId` is required but was not set" }, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt new file mode 100644 index 00000000..2de2b0f6 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.services.blocking.SpanIframeService +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects +import java.util.Optional +import java.util.stream.Stream +import java.util.stream.StreamSupport + +class SpanIframeListPage +private constructor( + private val spanIframesService: SpanIframeService, + private val params: SpanIframeListParams, + private val response: Response, +) { + + fun response(): Response = response + + fun objects(): List = response().objects() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeListPage && this.spanIframesService == other.spanIframesService && this.params == other.params && this.response == other.response /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ + } + + override fun toString() = + "SpanIframeListPage{spanIframesService=$spanIframesService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return !objects().isEmpty() + } + + fun getNextPageParams(): Optional { + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + SpanIframeListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + SpanIframeListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } + } + + fun getNextPage(): Optional { + return getNextPageParams().map { spanIframesService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + @JvmStatic + fun of( + spanIframesService: SpanIframeService, + params: SpanIframeListParams, + response: Response + ) = + SpanIframeListPage( + spanIframesService, + params, + response, + ) + } + + @JsonDeserialize(builder = Response.Builder::class) + @NoAutoDetect + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun objects(): List = objects.getNullable("objects") ?: listOf() + + @JsonProperty("objects") + fun _objects(): Optional>> = Optional.ofNullable(objects) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Response = apply { + if (!validated) { + objects().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ + } + + override fun toString() = + "SpanIframeListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objects: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } + + fun objects(objects: List) = objects(JsonField.of(objects)) + + @JsonProperty("objects") + fun objects(objects: JsonField>) = apply { this.objects = objects } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun build() = Response(objects, additionalProperties.toImmutable()) + } + } + + class AutoPager + constructor( + private val firstPage: SpanIframeListPage, + ) : Iterable { + + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 + } + } + + fun stream(): Stream { + return StreamSupport.stream(spliterator(), false) + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt new file mode 100644 index 00000000..c79d5014 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.services.async.SpanIframeServiceAsync +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate + +class SpanIframeListPageAsync +private constructor( + private val spanIframesService: SpanIframeServiceAsync, + private val params: SpanIframeListParams, + private val response: Response, +) { + + fun response(): Response = response + + fun objects(): List = response().objects() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeListPageAsync && this.spanIframesService == other.spanIframesService && this.params == other.params && this.response == other.response /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ + } + + override fun toString() = + "SpanIframeListPageAsync{spanIframesService=$spanIframesService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return !objects().isEmpty() + } + + fun getNextPageParams(): Optional { + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + SpanIframeListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + SpanIframeListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } + } + + fun getNextPage(): CompletableFuture> { + return getNextPageParams() + .map { spanIframesService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + @JvmStatic + fun of( + spanIframesService: SpanIframeServiceAsync, + params: SpanIframeListParams, + response: Response + ) = + SpanIframeListPageAsync( + spanIframesService, + params, + response, + ) + } + + @JsonDeserialize(builder = Response.Builder::class) + @NoAutoDetect + class Response + constructor( + private val objects: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun objects(): List = objects.getNullable("objects") ?: listOf() + + @JsonProperty("objects") + fun _objects(): Optional>> = Optional.ofNullable(objects) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Response = apply { + if (!validated) { + objects().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ + } + + override fun toString() = + "SpanIframeListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var objects: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } + + fun objects(objects: List) = objects(JsonField.of(objects)) + + @JsonProperty("objects") + fun objects(objects: JsonField>) = apply { this.objects = objects } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun build() = Response(objects, additionalProperties.toImmutable()) + } + } + + class AutoPager + constructor( + private val firstPage: SpanIframeListPageAsync, + ) { + + fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun CompletableFuture>.forEach( + action: (SpanIFrame) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) + } + + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt new file mode 100644 index 00000000..824669af --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -0,0 +1,382 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +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.braintrustdata.api.models.* +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +class SpanIframeListParams +constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val spanIframeName: String?, + private val startingAfter: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) { + + fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + + fun ids(): Optional = Optional.ofNullable(ids) + + fun limit(): Optional = Optional.ofNullable(limit) + + fun orgName(): Optional = Optional.ofNullable(orgName) + + fun spanIframeName(): Optional = Optional.ofNullable(spanIframeName) + + fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic + internal fun getQueryParams(): QueryParams { + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.spanIframeName?.let { queryParams.put("span_iframe_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() + } + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.spanIframeName == other.spanIframeName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, spanIframeName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + } + + override fun toString() = + "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var endingBefore: String? = null + private var ids: Ids? = null + private var limit: Long? = null + private var orgName: String? = null + private var spanIframeName: String? = null + private var startingAfter: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(spanIframeListParams: SpanIframeListParams) = apply { + this.endingBefore = spanIframeListParams.endingBefore + this.ids = spanIframeListParams.ids + this.limit = spanIframeListParams.limit + this.orgName = spanIframeListParams.orgName + this.spanIframeName = spanIframeListParams.spanIframeName + this.startingAfter = spanIframeListParams.startingAfter + additionalHeaders(spanIframeListParams.additionalHeaders) + additionalQueryParams(spanIframeListParams.additionalQueryParams) + } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(ids: Ids) = apply { this.ids = ids } + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = apply { this.limit = limit } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: String) = apply { this.orgName = orgName } + + /** Name of the span_iframe to search for */ + fun spanIframeName(spanIframeName: String) = apply { this.spanIframeName = spanIframeName } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun build(): SpanIframeListParams = + SpanIframeListParams( + endingBefore, + ids, + limit, + orgName, + spanIframeName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + @JsonDeserialize(using = Ids.Deserializer::class) + @JsonSerialize(using = Ids.Serializer::class) + class Ids + private constructor( + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Ids = apply { + if (!validated) { + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ + } + + override fun toString(): String { + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Ids(string = string) + + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Ids: $json") + } + } + + class Deserializer : BaseDeserializer(Ids::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Ids { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) + } + } + + class Serializer : BaseSerializer(Ids::class) { + + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt new file mode 100644 index 00000000..2a43dde3 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -0,0 +1,386 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams +import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects +import java.util.Optional + +class SpanIframeReplaceParams +constructor( + private val name: String, + private val projectId: String, + private val url: String, + private val description: String?, + private val postMessage: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) { + + fun name(): String = name + + fun projectId(): String = projectId + + fun url(): String = url + + fun description(): Optional = Optional.ofNullable(description) + + fun postMessage(): Optional = Optional.ofNullable(postMessage) + + @JvmSynthetic + internal fun getBody(): SpanIframeReplaceBody { + return SpanIframeReplaceBody( + name, + projectId, + url, + description, + postMessage, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + + @JsonDeserialize(builder = SpanIframeReplaceBody.Builder::class) + @NoAutoDetect + class SpanIframeReplaceBody + internal constructor( + private val name: String?, + private val projectId: String?, + private val url: String?, + private val description: String?, + private val postMessage: Boolean?, + private val additionalProperties: Map, + ) { + + /** Name of the span iframe */ + @JsonProperty("name") fun name(): String? = name + + /** Unique identifier for the project that the span iframe belongs under */ + @JsonProperty("project_id") fun projectId(): String? = projectId + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") fun url(): String? = url + + /** Textual description of the span iframe */ + @JsonProperty("description") fun description(): String? = description + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") fun postMessage(): Boolean? = postMessage + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: String? = null + private var projectId: String? = null + private var url: String? = null + private var description: String? = null + private var postMessage: Boolean? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanIframeReplaceBody: SpanIframeReplaceBody) = apply { + this.name = spanIframeReplaceBody.name + this.projectId = spanIframeReplaceBody.projectId + this.url = spanIframeReplaceBody.url + this.description = spanIframeReplaceBody.description + this.postMessage = spanIframeReplaceBody.postMessage + additionalProperties(spanIframeReplaceBody.additionalProperties) + } + + /** Name of the span iframe */ + @JsonProperty("name") fun name(name: String) = apply { this.name = name } + + /** Unique identifier for the project that the span iframe belongs under */ + @JsonProperty("project_id") + fun projectId(projectId: String) = apply { this.projectId = projectId } + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") fun url(url: String) = apply { this.url = url } + + /** Textual description of the span iframe */ + @JsonProperty("description") + fun description(description: String) = apply { this.description = description } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") + fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanIframeReplaceBody = + SpanIframeReplaceBody( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(url) { "`url` is required but was not set" }, + description, + postMessage, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeReplaceBody && this.name == other.name && this.projectId == other.projectId && this.url == other.url && this.description == other.description && this.postMessage == other.postMessage && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanIframeReplaceBody{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + } + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeReplaceParams && this.name == other.name && this.projectId == other.projectId && this.url == other.url && this.description == other.description && this.postMessage == other.postMessage && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + } + + override fun toString() = + "SpanIframeReplaceParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var name: String? = null + private var projectId: String? = null + private var url: String? = null + private var description: String? = null + private var postMessage: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = apply { + this.name = spanIframeReplaceParams.name + this.projectId = spanIframeReplaceParams.projectId + this.url = spanIframeReplaceParams.url + this.description = spanIframeReplaceParams.description + this.postMessage = spanIframeReplaceParams.postMessage + additionalHeaders(spanIframeReplaceParams.additionalHeaders) + additionalQueryParams(spanIframeReplaceParams.additionalQueryParams) + additionalBodyProperties(spanIframeReplaceParams.additionalBodyProperties) + } + + /** Name of the span iframe */ + fun name(name: String) = apply { this.name = name } + + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(projectId: String) = apply { this.projectId = projectId } + + /** URL to embed the project viewer in an iframe */ + fun url(url: String) = apply { this.url = url } + + /** Textual description of the span iframe */ + fun description(description: String) = apply { this.description = description } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + fun build(): SpanIframeReplaceParams = + SpanIframeReplaceParams( + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(url) { "`url` is required but was not set" }, + description, + postMessage, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt new file mode 100644 index 00000000..35e8ee94 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams +import com.braintrustdata.api.models.* +import java.util.Objects + +class SpanIframeRetrieveParams +constructor( + private val spanIframeId: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) { + + fun spanIframeId(): String = spanIframeId + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> spanIframeId + else -> "" + } + } + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeRetrieveParams && this.spanIframeId == other.spanIframeId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams) /* spotless:on */ + } + + override fun toString() = + "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var spanIframeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(spanIframeRetrieveParams: SpanIframeRetrieveParams) = apply { + this.spanIframeId = spanIframeRetrieveParams.spanIframeId + additionalHeaders(spanIframeRetrieveParams.additionalHeaders) + additionalQueryParams(spanIframeRetrieveParams.additionalQueryParams) + } + + /** SpanIframe id */ + fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun build(): SpanIframeRetrieveParams = + SpanIframeRetrieveParams( + checkNotNull(spanIframeId) { "`spanIframeId` is required but was not set" }, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt new file mode 100644 index 00000000..0e3af93e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -0,0 +1,360 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams +import com.braintrustdata.api.core.toImmutable +import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects +import java.util.Optional + +class SpanIframeUpdateParams +constructor( + private val spanIframeId: String, + private val name: String?, + private val postMessage: Boolean?, + private val url: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) { + + fun spanIframeId(): String = spanIframeId + + fun name(): Optional = Optional.ofNullable(name) + + fun postMessage(): Optional = Optional.ofNullable(postMessage) + + fun url(): Optional = Optional.ofNullable(url) + + @JvmSynthetic + internal fun getBody(): SpanIframeUpdateBody { + return SpanIframeUpdateBody( + name, + postMessage, + url, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> spanIframeId + else -> "" + } + } + + @JsonDeserialize(builder = SpanIframeUpdateBody.Builder::class) + @NoAutoDetect + class SpanIframeUpdateBody + internal constructor( + private val name: String?, + private val postMessage: Boolean?, + private val url: String?, + private val additionalProperties: Map, + ) { + + /** Name of the span iframe */ + @JsonProperty("name") fun name(): String? = name + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") fun postMessage(): Boolean? = postMessage + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") fun url(): String? = url + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: String? = null + private var postMessage: Boolean? = null + private var url: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanIframeUpdateBody: SpanIframeUpdateBody) = apply { + this.name = spanIframeUpdateBody.name + this.postMessage = spanIframeUpdateBody.postMessage + this.url = spanIframeUpdateBody.url + additionalProperties(spanIframeUpdateBody.additionalProperties) + } + + /** Name of the span iframe */ + @JsonProperty("name") fun name(name: String) = apply { this.name = name } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") + fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") fun url(url: String) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanIframeUpdateBody = + SpanIframeUpdateBody( + name, + postMessage, + url, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeUpdateBody && this.name == other.name && this.postMessage == other.postMessage && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, postMessage, url, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanIframeUpdateBody{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" + } + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeUpdateParams && this.spanIframeId == other.spanIframeId && this.name == other.name && this.postMessage == other.postMessage && this.url == other.url && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(spanIframeId, name, postMessage, url, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + } + + override fun toString() = + "SpanIframeUpdateParams{spanIframeId=$spanIframeId, name=$name, postMessage=$postMessage, url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var spanIframeId: String? = null + private var name: String? = null + private var postMessage: Boolean? = null + private var url: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = apply { + this.spanIframeId = spanIframeUpdateParams.spanIframeId + this.name = spanIframeUpdateParams.name + this.postMessage = spanIframeUpdateParams.postMessage + this.url = spanIframeUpdateParams.url + additionalHeaders(spanIframeUpdateParams.additionalHeaders) + additionalQueryParams(spanIframeUpdateParams.additionalQueryParams) + additionalBodyProperties(spanIframeUpdateParams.additionalBodyProperties) + } + + /** SpanIframe id */ + fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + + /** Name of the span iframe */ + fun name(name: String) = apply { this.name = name } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + + /** URL to embed the project viewer in an iframe */ + fun url(url: String) = apply { this.url = url } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + fun build(): SpanIframeUpdateParams = + SpanIframeUpdateParams( + checkNotNull(spanIframeId) { "`spanIframeId` is required but was not set" }, + name, + postMessage, + url, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt deleted file mode 100644 index 9b854bee..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Task.kt +++ /dev/null @@ -1,155 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -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 -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = Task.Builder::class) -@NoAutoDetect -class Task -private constructor( - private val type: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Task = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(task: Task) = apply { - this.type = task.type - additionalProperties(task.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Task = Task(type, additionalProperties.toImmutable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - TASK, - } - - enum class Value { - TASK, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Task && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = "Task{type=$type, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt deleted file mode 100644 index f4f2197a..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ToolChoice.kt +++ /dev/null @@ -1,422 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -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 -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(using = ToolChoice.Deserializer::class) -@JsonSerialize(using = ToolChoice.Serializer::class) -class ToolChoice -private constructor( - private val auto: Auto? = null, - private val none: None? = null, - private val function: Function? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun auto(): Optional = Optional.ofNullable(auto) - - fun none(): Optional = Optional.ofNullable(none) - - fun function(): Optional = Optional.ofNullable(function) - - fun isAuto(): Boolean = auto != null - - fun isNone(): Boolean = none != null - - fun isFunction(): Boolean = function != null - - fun asAuto(): Auto = auto.getOrThrow("auto") - - fun asNone(): None = none.getOrThrow("none") - - fun asFunction(): Function = function.getOrThrow("function") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - auto != null -> visitor.visitAuto(auto) - none != null -> visitor.visitNone(none) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } - } - - fun validate(): ToolChoice = apply { - if (!validated) { - if (auto == null && none == null && function == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - function?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ToolChoice && this.auto == other.auto && this.none == other.none && this.function == other.function /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(auto, none, function) /* spotless:on */ - } - - override fun toString(): String { - return when { - auto != null -> "ToolChoice{auto=$auto}" - none != null -> "ToolChoice{none=$none}" - function != null -> "ToolChoice{function=$function}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - - companion object { - - @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - - @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) - - @JvmStatic fun ofFunction(function: Function) = ToolChoice(function = function) - } - - interface Visitor { - - fun visitAuto(auto: Auto): T - - fun visitNone(none: None): T - - fun visitFunction(function: Function): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") - } - } - - class Deserializer : BaseDeserializer(ToolChoice::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(auto = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(none = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolChoice(function = it, _json = json) - } - - return ToolChoice(_json = json) - } - } - - class Serializer : BaseSerializer(ToolChoice::class) { - - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.auto != null -> generator.writeObject(value.auto) - value.none != null -> generator.writeObject(value.none) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - } - - class Auto - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Auto(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) - } - - enum class Known { - AUTO, - } - - enum class Value { - AUTO, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown Auto: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class None - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = None(JsonField.of("none")) - - @JvmStatic fun of(value: String) = None(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown None: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") - - fun function(): FunctionToolChoice = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Function = apply { - if (!validated) { - type() - function().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.type = function.type - this.function = function.function - additionalProperties(function.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: FunctionToolChoice) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function( - type, - function, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Function && this.type == other.type && this.function == other.function && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, function, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index ab9161c7..b96278ab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -12,6 +12,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -19,7 +20,6 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture @@ -102,7 +102,7 @@ interface ExperimentServiceAsync { fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Summarize experiment */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 85cf7c39..4468bf15 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -26,7 +27,6 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture @@ -294,14 +294,15 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index 59c3bcaf..4f6dae32 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -15,6 +15,7 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import java.util.Optional import java.util.concurrent.CompletableFuture interface FunctionServiceAsync { @@ -69,7 +70,7 @@ interface FunctionServiceAsync { fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture> /** * Create or replace function. If there is an existing function in the project with the same diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 8c1ebb62..18a8522f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import java.util.Optional import java.util.concurrent.CompletableFuture class FunctionServiceAsyncImpl @@ -198,7 +199,7 @@ constructor( override fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt new file mode 100644 index 00000000..3ce9449a --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.models.SpanIFrame +import com.braintrustdata.api.models.SpanIframeCreateParams +import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListPageAsync +import com.braintrustdata.api.models.SpanIframeListParams +import com.braintrustdata.api.models.SpanIframeReplaceParams +import com.braintrustdata.api.models.SpanIframeRetrieveParams +import com.braintrustdata.api.models.SpanIframeUpdateParams +import java.util.concurrent.CompletableFuture + +interface SpanIframeServiceAsync { + + /** + * Create a new span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will return the existing span_iframe unmodified + */ + @JvmOverloads + fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Get a span_iframe object by its id */ + @JvmOverloads + fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** + * Partially update a span_iframe object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ + @JvmOverloads + fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ + @JvmOverloads + fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Delete a span_iframe object by its id */ + @JvmOverloads + fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** + * Create or replace span_iframe. If there is an existing span_iframe with the same name as the + * one specified in the request, will replace the existing span_iframe with the provided fields + */ + @JvmOverloads + fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt new file mode 100644 index 00000000..53c59a72 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.models.SpanIFrame +import com.braintrustdata.api.models.SpanIframeCreateParams +import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListPageAsync +import com.braintrustdata.api.models.SpanIframeListParams +import com.braintrustdata.api.models.SpanIframeReplaceParams +import com.braintrustdata.api.models.SpanIframeRetrieveParams +import com.braintrustdata.api.models.SpanIframeUpdateParams +import java.util.concurrent.CompletableFuture + +class SpanIframeServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : SpanIframeServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Create a new span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will return the existing span_iframe unmodified + */ + override fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get a span_iframe object by its id */ + override fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Partially update a span_iframe object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ + override fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ + override fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { SpanIframeListPageAsync.of(this, params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Delete a span_iframe object by its id */ + override fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Create or replace span_iframe. If there is an existing span_iframe with the same name as the + * one specified in the request, will replace the existing span_iframe with the provided fields + */ + override fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index e799ba08..321b599c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture interface LogServiceAsync { @@ -48,5 +48,5 @@ interface LogServiceAsync { fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index c670e0aa..eda101b7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -14,11 +14,11 @@ import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture class LogServiceAsyncImpl @@ -125,14 +125,15 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index daf9bb69..24ead7fd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -12,6 +12,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -19,7 +20,6 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse interface ExperimentService { @@ -101,7 +101,7 @@ interface ExperimentService { fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + ): ExperimentInsertResponse /** Summarize experiment */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 4ba8e72b..c5e92523 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -19,6 +19,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -26,7 +27,6 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse class ExperimentServiceImpl @@ -285,14 +285,15 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): InsertEventsResponse { + ): ExperimentInsertResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 12d58d53..33f0e993 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -15,6 +15,7 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import java.util.Optional interface FunctionService { @@ -68,7 +69,7 @@ interface FunctionService { fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none() - ): FunctionInvokeResponse + ): Optional /** * Create or replace function. If there is an existing function in the project with the same diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 8e2ff2ec..934e083c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -22,6 +22,7 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import java.util.Optional class FunctionServiceImpl constructor( @@ -183,7 +184,7 @@ constructor( override fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions - ): FunctionInvokeResponse { + ): Optional { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt new file mode 100644 index 00000000..26033908 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.models.SpanIFrame +import com.braintrustdata.api.models.SpanIframeCreateParams +import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListPage +import com.braintrustdata.api.models.SpanIframeListParams +import com.braintrustdata.api.models.SpanIframeReplaceParams +import com.braintrustdata.api.models.SpanIframeRetrieveParams +import com.braintrustdata.api.models.SpanIframeUpdateParams + +interface SpanIframeService { + + /** + * Create a new span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will return the existing span_iframe unmodified + */ + @JvmOverloads + fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): SpanIFrame + + /** Get a span_iframe object by its id */ + @JvmOverloads + fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): SpanIFrame + + /** + * Partially update a span_iframe object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ + @JvmOverloads + fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): SpanIFrame + + /** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ + @JvmOverloads + fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): SpanIframeListPage + + /** Delete a span_iframe object by its id */ + @JvmOverloads + fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): SpanIFrame + + /** + * Create or replace span_iframe. If there is an existing span_iframe with the same name as the + * one specified in the request, will replace the existing span_iframe with the provided fields + */ + @JvmOverloads + fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions = RequestOptions.none() + ): SpanIFrame +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt new file mode 100644 index 00000000..5d542791 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.handlers.errorHandler +import com.braintrustdata.api.core.handlers.jsonHandler +import com.braintrustdata.api.core.handlers.withErrorHandler +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.json +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.models.SpanIFrame +import com.braintrustdata.api.models.SpanIframeCreateParams +import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListPage +import com.braintrustdata.api.models.SpanIframeListParams +import com.braintrustdata.api.models.SpanIframeReplaceParams +import com.braintrustdata.api.models.SpanIframeRetrieveParams +import com.braintrustdata.api.models.SpanIframeUpdateParams + +class SpanIframeServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : SpanIframeService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Create a new span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will return the existing span_iframe unmodified + */ + override fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions + ): SpanIFrame { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get a span_iframe object by its id */ + override fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions + ): SpanIFrame { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Partially update a span_iframe object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ + override fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions + ): SpanIFrame { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ + override fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions + ): SpanIframeListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { SpanIframeListPage.of(this, params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Delete a span_iframe object by its id */ + override fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions + ): SpanIFrame { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { deleteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Create or replace span_iframe. If there is an existing span_iframe with the same name as the + * one specified in the request, will replace the existing span_iframe with the provided fields + */ + override fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions + ): SpanIFrame { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { replaceHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index 796bb9e8..cd4f4c96 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertResponse interface LogService { @@ -47,5 +47,5 @@ interface LogService { fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + ): ProjectLogInsertResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 677368f8..a7b5ed35 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -14,11 +14,11 @@ import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertResponse class LogServiceImpl constructor( @@ -121,14 +121,15 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): InsertEventsResponse { + ): ProjectLogInsertResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt index 539185e1..8b8ede41 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt @@ -17,8 +17,12 @@ class CodeBundleTest { CodeBundle.Location.Experiment.builder() .evalName("eval_name") .position( - CodeBundle.Location.Experiment.Position.ofTask( - Task.builder().type(Task.Type.TASK).build() + CodeBundle.Location.Experiment.Position.ofType( + CodeBundle.Location.Experiment.Position.Type.builder() + .type( + CodeBundle.Location.Experiment.Position.Type.Type.TASK + ) + .build() ) ) .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) @@ -41,8 +45,10 @@ class CodeBundleTest { CodeBundle.Location.Experiment.builder() .evalName("eval_name") .position( - CodeBundle.Location.Experiment.Position.ofTask( - Task.builder().type(Task.Type.TASK).build() + CodeBundle.Location.Experiment.Position.ofType( + CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.Type.TASK) + .build() ) ) .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index cd299934..aa92e1c3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -11,9 +11,10 @@ class DatasetCreateParamsTest { @Test fun createDatasetCreateParams() { DatasetCreateParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") + .metadata(DatasetCreateParams.Metadata.builder().build()) .build() } @@ -21,27 +22,29 @@ class DatasetCreateParamsTest { fun getBody() { val params = DatasetCreateParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") + .metadata(DatasetCreateParams.Metadata.builder().build()) .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.description()).isEqualTo("description") + assertThat(body.metadata()).isEqualTo(DatasetCreateParams.Metadata.builder().build()) } @Test fun getBodyWithoutOptionalFields() { val params = DatasetCreateParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt index 3ac2cceb..4249590b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -22,7 +22,16 @@ class DatasetEventTest { .spanId("span_id") .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(DatasetEvent.Metadata.builder().build()) + .origin( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .tags(listOf("string")) .build() assertThat(datasetEvent).isNotNull @@ -36,7 +45,17 @@ class DatasetEventTest { assertThat(datasetEvent.spanId()).isEqualTo("span_id") assertThat(datasetEvent._expected()).isEqualTo(JsonNull.of()) assertThat(datasetEvent._input()).isEqualTo(JsonNull.of()) + assertThat(datasetEvent.isRoot()).contains(true) assertThat(datasetEvent.metadata()).contains(DatasetEvent.Metadata.builder().build()) + assertThat(datasetEvent.origin()) + .contains( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) assertThat(datasetEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index 84d240e6..df685f8f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -35,9 +35,34 @@ class EvalCreateParamsTest { .build() ) ) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") .experimentName("experiment_name") + .gitMetadataSettings( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .fields(listOf(EvalCreateParams.GitMetadataSettings.Field.COMMIT)) + .build() + ) + .isPublic(true) + .maxConcurrency(42.23) .metadata(EvalCreateParams.Metadata.builder().build()) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) .stream(true) + .timeout(42.23) + .trialCount(42.23) .build() } @@ -69,9 +94,34 @@ class EvalCreateParamsTest { .build() ) ) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") .experimentName("experiment_name") + .gitMetadataSettings( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .fields(listOf(EvalCreateParams.GitMetadataSettings.Field.COMMIT)) + .build() + ) + .isPublic(true) + .maxConcurrency(42.23) .metadata(EvalCreateParams.Metadata.builder().build()) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) .stream(true) + .timeout(42.23) + .trialCount(42.23) .build() val body = params.getBody() assertThat(body).isNotNull @@ -102,9 +152,36 @@ class EvalCreateParamsTest { .build() ) ) + assertThat(body.baseExperimentId()).isEqualTo("base_experiment_id") + assertThat(body.baseExperimentName()).isEqualTo("base_experiment_name") assertThat(body.experimentName()).isEqualTo("experiment_name") + assertThat(body.gitMetadataSettings()) + .isEqualTo( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .fields(listOf(EvalCreateParams.GitMetadataSettings.Field.COMMIT)) + .build() + ) + assertThat(body.isPublic()).isEqualTo(true) + assertThat(body.maxConcurrency()).isEqualTo(42.23) assertThat(body.metadata()).isEqualTo(EvalCreateParams.Metadata.builder().build()) + assertThat(body.repoInfo()) + .isEqualTo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) assertThat(body.stream()).isEqualTo(true) + assertThat(body.timeout()).isEqualTo(42.23) + assertThat(body.trialCount()).isEqualTo(42.23) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 35e96747..27054310 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -18,7 +18,7 @@ class ExperimentCreateParamsTest { .description("description") .ensureNew(true) .metadata(ExperimentCreateParams.Metadata.builder().build()) - .name("name") + .name("x") .public_(true) .repoInfo( RepoInfo.builder() @@ -47,7 +47,7 @@ class ExperimentCreateParamsTest { .description("description") .ensureNew(true) .metadata(ExperimentCreateParams.Metadata.builder().build()) - .name("name") + .name("x") .public_(true) .repoInfo( RepoInfo.builder() @@ -72,7 +72,7 @@ class ExperimentCreateParamsTest { assertThat(body.description()).isEqualTo("description") assertThat(body.ensureNew()).isEqualTo(true) assertThat(body.metadata()).isEqualTo(ExperimentCreateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.public_()).isEqualTo(true) assertThat(body.repoInfo()) .isEqualTo( 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 8c65509a..75216ef1 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 @@ -31,9 +31,13 @@ class ExperimentEventTest { .error(JsonNull.of()) .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(ExperimentEvent.Metadata.builder().build()) .metrics( ExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -41,6 +45,14 @@ class ExperimentEventTest { .tokens(123L) .build() ) + .origin( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .output(JsonNull.of()) .scores(ExperimentEvent.Scores.builder().build()) .spanAttributes( @@ -73,10 +85,14 @@ class ExperimentEventTest { assertThat(experimentEvent._error()).isEqualTo(JsonNull.of()) assertThat(experimentEvent._expected()).isEqualTo(JsonNull.of()) assertThat(experimentEvent._input()).isEqualTo(JsonNull.of()) + assertThat(experimentEvent.isRoot()).contains(true) assertThat(experimentEvent.metadata()).contains(ExperimentEvent.Metadata.builder().build()) assertThat(experimentEvent.metrics()) .contains( ExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -84,6 +100,15 @@ class ExperimentEventTest { .tokens(123L) .build() ) + assertThat(experimentEvent.origin()) + .contains( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) assertThat(experimentEvent._output()).isEqualTo(JsonNull.of()) assertThat(experimentEvent.scores()).contains(ExperimentEvent.Scores.builder().build()) assertThat(experimentEvent.spanAttributes()) 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 80fced9c..a5e47101 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 @@ -37,6 +37,9 @@ class ExperimentInsertParamsTest { .metadata(InsertExperimentEventReplace.Metadata.builder().build()) .metrics( InsertExperimentEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -88,6 +91,9 @@ class ExperimentInsertParamsTest { .metadata(InsertExperimentEventReplace.Metadata.builder().build()) .metrics( InsertExperimentEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -135,6 +141,9 @@ class ExperimentInsertParamsTest { .metadata(InsertExperimentEventReplace.Metadata.builder().build()) .metrics( InsertExperimentEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt index 220705b1..edc1f179 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -25,7 +25,16 @@ class FetchDatasetEventsResponseTest { .spanId("span_id") .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(DatasetEvent.Metadata.builder().build()) + .origin( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .tags(listOf("string")) .build() ) @@ -45,7 +54,16 @@ class FetchDatasetEventsResponseTest { .spanId("span_id") .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(DatasetEvent.Metadata.builder().build()) + .origin( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .tags(listOf("string")) .build() ) 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 3674eabf..da7f86c9 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 @@ -34,9 +34,13 @@ class FetchExperimentEventsResponseTest { .error(JsonNull.of()) .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(ExperimentEvent.Metadata.builder().build()) .metrics( ExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -44,6 +48,14 @@ class FetchExperimentEventsResponseTest { .tokens(123L) .build() ) + .origin( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .output(JsonNull.of()) .scores(ExperimentEvent.Scores.builder().build()) .spanAttributes( @@ -81,9 +93,13 @@ class FetchExperimentEventsResponseTest { .error(JsonNull.of()) .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(ExperimentEvent.Metadata.builder().build()) .metrics( ExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -91,6 +107,14 @@ class FetchExperimentEventsResponseTest { .tokens(123L) .build() ) + .origin( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .output(JsonNull.of()) .scores(ExperimentEvent.Scores.builder().build()) .spanAttributes( 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 c34a05b2..cbbef1a6 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 @@ -34,9 +34,13 @@ class FetchProjectLogsEventsResponseTest { .error(JsonNull.of()) .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(ProjectLogsEvent.Metadata.builder().build()) .metrics( ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -44,6 +48,14 @@ class FetchProjectLogsEventsResponseTest { .tokens(123L) .build() ) + .origin( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .output(JsonNull.of()) .scores(ProjectLogsEvent.Scores.builder().build()) .spanAttributes( @@ -81,9 +93,13 @@ class FetchProjectLogsEventsResponseTest { .error(JsonNull.of()) .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(ProjectLogsEvent.Metadata.builder().build()) .metrics( ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -91,6 +107,14 @@ class FetchProjectLogsEventsResponseTest { .tokens(123L) .build() ) + .origin( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .output(JsonNull.of()) .scores(ProjectLogsEvent.Scores.builder().build()) .spanAttributes( 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 c5cc94d4..1e391994 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 @@ -19,9 +19,9 @@ class FunctionCreateParamsTest { .build() ) ) - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionSchema( FunctionCreateParams.FunctionSchema.builder() @@ -61,18 +61,33 @@ class FunctionCreateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -130,9 +145,9 @@ class FunctionCreateParamsTest { .build() ) ) - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionSchema( FunctionCreateParams.FunctionSchema.builder() @@ -173,18 +188,34 @@ class FunctionCreateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -239,9 +270,9 @@ class FunctionCreateParamsTest { .build() ) ) - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + assertThat(body.slug()).isEqualTo("x") assertThat(body.description()).isEqualTo("description") assertThat(body.functionSchema()) .isEqualTo( @@ -284,18 +315,33 @@ class FunctionCreateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -352,9 +398,9 @@ class FunctionCreateParamsTest { .build() ) ) - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .build() val body = params.getBody() assertThat(body).isNotNull @@ -366,8 +412,8 @@ class FunctionCreateParamsTest { .build() ) ) - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + assertThat(body.slug()).isEqualTo("x") } } 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 3afb5a00..5836c0b4 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 @@ -19,9 +19,9 @@ class FunctionReplaceParamsTest { .build() ) ) - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionSchema( FunctionReplaceParams.FunctionSchema.builder() @@ -61,18 +61,33 @@ class FunctionReplaceParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -130,9 +145,9 @@ class FunctionReplaceParamsTest { .build() ) ) - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionSchema( FunctionReplaceParams.FunctionSchema.builder() @@ -173,18 +188,34 @@ class FunctionReplaceParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -239,9 +270,9 @@ class FunctionReplaceParamsTest { .build() ) ) - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + assertThat(body.slug()).isEqualTo("x") assertThat(body.description()).isEqualTo("description") assertThat(body.functionSchema()) .isEqualTo( @@ -284,18 +315,33 @@ class FunctionReplaceParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -352,9 +398,9 @@ class FunctionReplaceParamsTest { .build() ) ) - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .build() val body = params.getBody() assertThat(body).isNotNull @@ -366,8 +412,8 @@ class FunctionReplaceParamsTest { .build() ) ) - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + assertThat(body.slug()).isEqualTo("x") } } 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 566aec42..d1b8e471 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 @@ -69,18 +69,34 @@ class FunctionTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -185,18 +201,33 @@ class FunctionTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionToolChoiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionToolChoiceTest.kt deleted file mode 100644 index 6321b346..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionToolChoiceTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class FunctionToolChoiceTest { - - @Test - fun createFunctionToolChoice() { - val functionToolChoice = FunctionToolChoice.builder().name("name").build() - assertThat(functionToolChoice).isNotNull - assertThat(functionToolChoice.name()).isEqualTo("name") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index e5763185..6fc5f740 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -45,18 +45,33 @@ class FunctionUpdateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -142,18 +157,34 @@ class FunctionUpdateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -235,18 +266,33 @@ class FunctionUpdateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index b7b98eb3..4b672ac6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -11,7 +11,7 @@ class GroupCreateParamsTest { @Test fun createGroupCreateParams() { GroupCreateParams.builder() - .name("name") + .name("x") .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -23,7 +23,7 @@ class GroupCreateParamsTest { fun getBody() { val params = GroupCreateParams.builder() - .name("name") + .name("x") .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -31,7 +31,7 @@ class GroupCreateParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.description()).isEqualTo("description") assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -40,9 +40,9 @@ class GroupCreateParamsTest { @Test fun getBodyWithoutOptionalFields() { - val params = GroupCreateParams.builder().name("name").build() + val params = GroupCreateParams.builder().name("x").build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index 4bc2570a..99a651e9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -11,7 +11,7 @@ class GroupReplaceParamsTest { @Test fun createGroupReplaceParams() { GroupReplaceParams.builder() - .name("name") + .name("x") .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -23,7 +23,7 @@ class GroupReplaceParamsTest { fun getBody() { val params = GroupReplaceParams.builder() - .name("name") + .name("x") .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -31,7 +31,7 @@ class GroupReplaceParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.description()).isEqualTo("description") assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -40,9 +40,9 @@ class GroupReplaceParamsTest { @Test fun getBodyWithoutOptionalFields() { - val params = GroupReplaceParams.builder().name("name").build() + val params = GroupReplaceParams.builder().name("x").build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index f84d7191..e0bc5b14 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -15,7 +15,7 @@ class GroupUpdateParamsTest { .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .description("description") - .name("name") + .name("x") .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() @@ -29,7 +29,7 @@ class GroupUpdateParamsTest { .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .description("description") - .name("name") + .name("x") .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() @@ -38,7 +38,7 @@ class GroupUpdateParamsTest { assertThat(body.addMemberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.addMemberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.removeMemberGroups()) .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.removeMemberUsers()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt index 59aee6e3..0aa4757e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt @@ -32,6 +32,9 @@ class InsertExperimentEventMergeTest { .metadata(InsertExperimentEventMerge.Metadata.builder().build()) .metrics( InsertExperimentEventMerge.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -73,6 +76,9 @@ class InsertExperimentEventMergeTest { assertThat(insertExperimentEventMerge.metrics()) .contains( InsertExperimentEventMerge.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt index 0de4d47c..c6cce2d7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt @@ -32,6 +32,9 @@ class InsertExperimentEventReplaceTest { .metadata(InsertExperimentEventReplace.Metadata.builder().build()) .metrics( InsertExperimentEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -73,6 +76,9 @@ class InsertExperimentEventReplaceTest { assertThat(insertExperimentEventReplace.metrics()) .contains( InsertExperimentEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt index 64e559b8..39f7e545 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt @@ -31,6 +31,9 @@ class InsertProjectLogsEventMergeTest { .metadata(InsertProjectLogsEventMerge.Metadata.builder().build()) .metrics( InsertProjectLogsEventMerge.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -72,6 +75,9 @@ class InsertProjectLogsEventMergeTest { assertThat(insertProjectLogsEventMerge.metrics()) .contains( InsertProjectLogsEventMerge.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt index be86dc18..09b08af4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt @@ -31,6 +31,9 @@ class InsertProjectLogsEventReplaceTest { .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) .metrics( InsertProjectLogsEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -71,6 +74,9 @@ class InsertProjectLogsEventReplaceTest { assertThat(insertProjectLogsEventReplace.metrics()) .contains( InsertProjectLogsEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index 10928d7b..745c9b01 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -10,23 +10,23 @@ class ProjectCreateParamsTest { @Test fun createProjectCreateParams() { - ProjectCreateParams.builder().name("name").orgName("org_name").build() + ProjectCreateParams.builder().name("x").orgName("org_name").build() } @Test fun getBody() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = ProjectCreateParams.builder().name("name").build() + val params = ProjectCreateParams.builder().name("x").build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") } } 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 4540c135..8e3a2ce2 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 @@ -36,6 +36,9 @@ class ProjectLogInsertParamsTest { .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) .metrics( InsertProjectLogsEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -86,6 +89,9 @@ class ProjectLogInsertParamsTest { .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) .metrics( InsertProjectLogsEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -132,6 +138,9 @@ class ProjectLogInsertParamsTest { .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) .metrics( InsertProjectLogsEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) 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 34b0430b..37ffb683 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 @@ -31,9 +31,13 @@ class ProjectLogsEventTest { .error(JsonNull.of()) .expected(JsonNull.of()) .input(JsonNull.of()) + .isRoot(true) .metadata(ProjectLogsEvent.Metadata.builder().build()) .metrics( ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -41,6 +45,14 @@ class ProjectLogsEventTest { .tokens(123L) .build() ) + .origin( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) .output(JsonNull.of()) .scores(ProjectLogsEvent.Scores.builder().build()) .spanAttributes( @@ -73,11 +85,15 @@ class ProjectLogsEventTest { assertThat(projectLogsEvent._error()).isEqualTo(JsonNull.of()) assertThat(projectLogsEvent._expected()).isEqualTo(JsonNull.of()) assertThat(projectLogsEvent._input()).isEqualTo(JsonNull.of()) + assertThat(projectLogsEvent.isRoot()).contains(true) assertThat(projectLogsEvent.metadata()) .contains(ProjectLogsEvent.Metadata.builder().build()) assertThat(projectLogsEvent.metrics()) .contains( ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -85,6 +101,15 @@ class ProjectLogsEventTest { .tokens(123L) .build() ) + assertThat(projectLogsEvent.origin()) + .contains( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) assertThat(projectLogsEvent._output()).isEqualTo(JsonNull.of()) assertThat(projectLogsEvent.scores()).contains(ProjectLogsEvent.Scores.builder().build()) assertThat(projectLogsEvent.spanAttributes()) 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 5f1a5949..72943820 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(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) .categories( ProjectScoreCreateParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -52,7 +52,7 @@ class ProjectScoreCreateParamsTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) .categories( ProjectScoreCreateParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -89,7 +89,7 @@ class ProjectScoreCreateParamsTest { assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) assertThat(body.categories()) .isEqualTo( ProjectScoreCreateParams.Categories.ofCategorical( @@ -129,12 +129,12 @@ class ProjectScoreCreateParamsTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) .build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.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 07d5dd28..b47368d1 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 @@ -19,7 +19,11 @@ class ProjectScoreListParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ofProjectScoreType(ProjectScoreType.SLIDER)) + .scoreType( + ProjectScoreListParams.ScoreType.ofProjectScoreType( + ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER + ) + ) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @@ -36,7 +40,9 @@ class ProjectScoreListParamsTest { .projectName("project_name") .projectScoreName("project_score_name") .scoreType( - ProjectScoreListParams.ScoreType.ofProjectScoreType(ProjectScoreType.SLIDER) + ProjectScoreListParams.ScoreType.ofProjectScoreType( + ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER + ) ) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -53,10 +59,10 @@ class ProjectScoreListParamsTest { expected.put("project_score_name", "project_score_name") expected.put( "score_type", - - ProjectScoreListParams.ScoreType.ofProjectScoreType(ProjectScoreType.SLIDER) - .toString() - + ProjectScoreListParams.ScoreType.ofProjectScoreType( + ProjectScoreListParams.ProjectScoreType.SLIDER.toString() + ) + .toString() ) expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(params.getQueryParams()).isEqualTo(expected.build()) 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 d3b3409c..d24b9895 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(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) .categories( ProjectScoreReplaceParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -52,7 +52,7 @@ class ProjectScoreReplaceParamsTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) .categories( ProjectScoreReplaceParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -89,7 +89,7 @@ class ProjectScoreReplaceParamsTest { assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) assertThat(body.categories()) .isEqualTo( ProjectScoreReplaceParams.Categories.ofCategorical( @@ -129,12 +129,12 @@ class ProjectScoreReplaceParamsTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) .build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.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 8cabac19..4fd8e414 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(ProjectScoreType.SLIDER) + .scoreType(ProjectScore.ScoreType.SLIDER) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .categories( ProjectScore.Categories.ofCategorical( @@ -55,7 +55,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(ProjectScoreType.SLIDER) + assertThat(projectScore.scoreType()).isEqualTo(ProjectScore.ScoreType.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 66c17521..64e20ccc 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 @@ -42,7 +42,7 @@ class ProjectScoreUpdateParamsTest { ) .description("description") .name("name") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) .build() } @@ -83,7 +83,7 @@ class ProjectScoreUpdateParamsTest { ) .description("description") .name("name") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) .build() val body = params.getBody() assertThat(body).isNotNull @@ -119,7 +119,7 @@ class ProjectScoreUpdateParamsTest { ) assertThat(body.description()).isEqualTo("description") assertThat(body.name()).isEqualTo("name") - assertThat(body.scoreType()).isEqualTo(ProjectScoreType.SLIDER) + assertThat(body.scoreType()).isEqualTo(ProjectScoreUpdateParams.ScoreType.SLIDER) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index f7b21942..1baf3939 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -11,9 +11,9 @@ class PromptCreateParamsTest { @Test fun createPromptCreateParams() { PromptCreateParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionType(PromptCreateParams.FunctionType.LLM) .promptData( @@ -40,18 +40,33 @@ class PromptCreateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -102,9 +117,9 @@ class PromptCreateParamsTest { fun getBody() { val params = PromptCreateParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionType(PromptCreateParams.FunctionType.LLM) .promptData( @@ -132,18 +147,34 @@ class PromptCreateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -190,9 +221,9 @@ class PromptCreateParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + assertThat(body.slug()).isEqualTo("x") assertThat(body.description()).isEqualTo("description") assertThat(body.functionType()).isEqualTo(PromptCreateParams.FunctionType.LLM) assertThat(body.promptData()) @@ -220,18 +251,33 @@ class PromptCreateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -281,14 +327,14 @@ class PromptCreateParamsTest { fun getBodyWithoutOptionalFields() { val params = PromptCreateParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index ac9b23aa..872bde94 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -32,18 +32,32 @@ class PromptDataTest { .presencePenalty(42.23) .responseFormat( PromptData.Options.Params.OpenAIModelParams.ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -106,18 +120,29 @@ class PromptDataTest { .presencePenalty(42.23) .responseFormat( PromptData.Options.Params.OpenAIModelParams.ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto( + PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 3031f48e..705c3dc6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -11,9 +11,9 @@ class PromptReplaceParamsTest { @Test fun createPromptReplaceParams() { PromptReplaceParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionType(PromptReplaceParams.FunctionType.LLM) .promptData( @@ -40,18 +40,33 @@ class PromptReplaceParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -102,9 +117,9 @@ class PromptReplaceParamsTest { fun getBody() { val params = PromptReplaceParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionType(PromptReplaceParams.FunctionType.LLM) .promptData( @@ -132,18 +147,34 @@ class PromptReplaceParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -190,9 +221,9 @@ class PromptReplaceParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + assertThat(body.slug()).isEqualTo("x") assertThat(body.description()).isEqualTo("description") assertThat(body.functionType()).isEqualTo(PromptReplaceParams.FunctionType.LLM) assertThat(body.promptData()) @@ -220,18 +251,33 @@ class PromptReplaceParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -281,14 +327,14 @@ class PromptReplaceParamsTest { fun getBodyWithoutOptionalFields() { val params = PromptReplaceParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index cfdb0275..c10b4197 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -48,18 +48,34 @@ class PromptTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -141,18 +157,33 @@ class PromptTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index c75ca8b0..574f9e45 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -38,18 +38,33 @@ class PromptUpdateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -129,18 +144,34 @@ class PromptUpdateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -215,18 +246,33 @@ class PromptUpdateParamsTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams.ToolChoice + .ofAuto( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() 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 e4500a98..ab989df1 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 @@ -11,7 +11,7 @@ class RoleCreateParamsTest { @Test fun createRoleCreateParams() { RoleCreateParams.builder() - .name("name") + .name("x") .description("description") .memberPermissions( listOf( @@ -32,7 +32,7 @@ class RoleCreateParamsTest { fun getBody() { val params = RoleCreateParams.builder() - .name("name") + .name("x") .description("description") .memberPermissions( listOf( @@ -49,7 +49,7 @@ class RoleCreateParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.description()).isEqualTo("description") assertThat(body.memberPermissions()) .isEqualTo( @@ -68,9 +68,9 @@ class RoleCreateParamsTest { @Test fun getBodyWithoutOptionalFields() { - val params = RoleCreateParams.builder().name("name").build() + val params = RoleCreateParams.builder().name("x").build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") } } 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 299ccd32..2609c52f 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 @@ -11,7 +11,7 @@ class RoleReplaceParamsTest { @Test fun createRoleReplaceParams() { RoleReplaceParams.builder() - .name("name") + .name("x") .description("description") .memberPermissions( listOf( @@ -32,7 +32,7 @@ class RoleReplaceParamsTest { fun getBody() { val params = RoleReplaceParams.builder() - .name("name") + .name("x") .description("description") .memberPermissions( listOf( @@ -49,7 +49,7 @@ class RoleReplaceParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.description()).isEqualTo("description") assertThat(body.memberPermissions()) .isEqualTo( @@ -68,9 +68,9 @@ class RoleReplaceParamsTest { @Test fun getBodyWithoutOptionalFields() { - val params = RoleReplaceParams.builder().name("name").build() + val params = RoleReplaceParams.builder().name("x").build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") } } 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 46274c48..081e5a52 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 @@ -24,7 +24,7 @@ class RoleUpdateParamsTest { ) .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .description("description") - .name("name") + .name("x") .removeMemberPermissions( listOf( RoleUpdateParams.RemoveMemberPermission.builder() @@ -56,7 +56,7 @@ class RoleUpdateParamsTest { ) .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .description("description") - .name("name") + .name("x") .removeMemberPermissions( listOf( RoleUpdateParams.RemoveMemberPermission.builder() @@ -85,7 +85,7 @@ class RoleUpdateParamsTest { ) assertThat(body.addMemberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).isEqualTo("x") assertThat(body.removeMemberPermissions()) .isEqualTo( listOf( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScorerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScorerTest.kt deleted file mode 100644 index 3c30d63c..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScorerTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ScorerTest { - - @Test - fun createScorer() { - val scorer = Scorer.builder().index(123L).type(Scorer.Type.SCORER).build() - assertThat(scorer).isNotNull - assertThat(scorer.index()).isEqualTo(123L) - assertThat(scorer.type()).isEqualTo(Scorer.Type.SCORER) - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt new file mode 100644 index 00000000..a972b937 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SpanIFrameTest { + + @Test + fun createSpanIFrame() { + val spanIFrame = + SpanIFrame.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .postMessage(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(spanIFrame).isNotNull + assertThat(spanIFrame.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(spanIFrame.name()).isEqualTo("name") + assertThat(spanIFrame.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(spanIFrame.url()).isEqualTo("url") + assertThat(spanIFrame.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(spanIFrame.deletedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(spanIFrame.description()).contains("description") + assertThat(spanIFrame.postMessage()).contains(true) + assertThat(spanIFrame.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt new file mode 100644 index 00000000..67738f2e --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SpanIframeCreateParamsTest { + + @Test + fun createSpanIframeCreateParams() { + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + } + + @Test + fun getBody() { + val params = + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + assertThat(body.description()).isEqualTo("description") + assertThat(body.postMessage()).isEqualTo(true) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt new file mode 100644 index 00000000..16288ccf --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SpanIframeDeleteParamsTest { + + @Test + fun createSpanIframeDeleteParams() { + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt new file mode 100644 index 00000000..0b86e244 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.http.QueryParams +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SpanIframeListParamsTest { + + @Test + fun createSpanIframeListParams() { + SpanIframeListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .spanIframeName("span_iframe_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getQueryParams() { + val params = + SpanIframeListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .spanIframeName("span_iframe_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ) + expected.put("limit", "123") + expected.put("org_name", "org_name") + expected.put("span_iframe_name", "span_iframe_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params.getQueryParams()).isEqualTo(expected.build()) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = SpanIframeListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params.getQueryParams()).isEqualTo(expected.build()) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt new file mode 100644 index 00000000..a6700e57 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SpanIframeReplaceParamsTest { + + @Test + fun createSpanIframeReplaceParams() { + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + } + + @Test + fun getBody() { + val params = + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + assertThat(body.description()).isEqualTo("description") + assertThat(body.postMessage()).isEqualTo(true) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt new file mode 100644 index 00000000..6624ae3b --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SpanIframeRetrieveParamsTest { + + @Test + fun createSpanIframeRetrieveParams() { + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt new file mode 100644 index 00000000..d1d84057 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SpanIframeUpdateParamsTest { + + @Test + fun createSpanIframeUpdateParams() { + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + } + + @Test + fun getBody() { + val params = + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.postMessage()).isEqualTo(true) + assertThat(body.url()).isEqualTo("url") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TaskTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TaskTest.kt deleted file mode 100644 index c8ec14d7..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TaskTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class TaskTest { - - @Test - fun createTask() { - val task = Task.builder().type(Task.Type.TASK).build() - assertThat(task).isNotNull - assertThat(task.type()).isEqualTo(Task.Type.TASK) - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index ebdc9eec..313eef1e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -56,7 +56,7 @@ class ErrorHandlingTest { @Test fun projectsCreate200() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() val expected = Project.builder() @@ -76,7 +76,7 @@ class ErrorHandlingTest { @Test fun projectsCreate400() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor( post(anyUrl()) @@ -91,7 +91,7 @@ class ErrorHandlingTest { @Test fun projectsCreate401() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor( post(anyUrl()) @@ -106,7 +106,7 @@ class ErrorHandlingTest { @Test fun projectsCreate403() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor( post(anyUrl()) @@ -125,7 +125,7 @@ class ErrorHandlingTest { @Test fun projectsCreate404() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor( post(anyUrl()) @@ -140,7 +140,7 @@ class ErrorHandlingTest { @Test fun projectsCreate422() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor( post(anyUrl()) @@ -159,7 +159,7 @@ class ErrorHandlingTest { @Test fun projectsCreate429() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor( post(anyUrl()) @@ -174,7 +174,7 @@ class ErrorHandlingTest { @Test fun projectsCreate500() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor( post(anyUrl()) @@ -193,7 +193,7 @@ class ErrorHandlingTest { @Test fun unexpectedStatusCode() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor( post(anyUrl()) @@ -213,7 +213,7 @@ class ErrorHandlingTest { @Test fun invalidBody() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor(post(anyUrl()).willReturn(status(200).withBody("Not JSON"))) @@ -227,7 +227,7 @@ class ErrorHandlingTest { @Test fun invalidErrorBody() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() stubFor(post(anyUrl()).willReturn(status(400).withBody("Not JSON"))) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt index d1c75949..d353dd1f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt @@ -57,7 +57,7 @@ class ServiceParamsTest { val params = ProjectCreateParams.builder() - .name("name") + .name("x") .orgName("org_name") .additionalHeaders(additionalHeaders) .additionalBodyProperties(additionalBodyProperties) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index 8a9ef54d..413a951b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -25,9 +25,10 @@ class DatasetServiceTest { val dataset = datasetService.create( DatasetCreateParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") + .metadata(DatasetCreateParams.Metadata.builder().build()) .build() ) println(dataset) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index c2ee858f..05975beb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -48,9 +48,34 @@ class EvalServiceTest { .build() ) ) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") .experimentName("experiment_name") + .gitMetadataSettings( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .fields(listOf(EvalCreateParams.GitMetadataSettings.Field.COMMIT)) + .build() + ) + .isPublic(true) + .maxConcurrency(42.23) .metadata(EvalCreateParams.Metadata.builder().build()) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) .stream(true) + .timeout(42.23) + .trialCount(42.23) .build() ) println(summarizeExperimentResponse) 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 878d2ace..2b5aac61 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 @@ -32,7 +32,7 @@ class ExperimentServiceTest { .description("description") .ensureNew(true) .metadata(ExperimentCreateParams.Metadata.builder().build()) - .name("name") + .name("x") .public_(true) .repoInfo( RepoInfo.builder() @@ -232,7 +232,7 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val insertEventsResponse = + val experimentInsertResponse = experimentService.insert( ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -261,6 +261,9 @@ class ExperimentServiceTest { ) .metrics( InsertExperimentEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -285,8 +288,7 @@ class ExperimentServiceTest { ) .build() ) - println(insertEventsResponse) - insertEventsResponse.validate() + println(experimentInsertResponse) } @Test 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 91a974ad..d40772bf 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 @@ -31,9 +31,9 @@ class FunctionServiceTest { .build() ) ) - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionSchema( FunctionCreateParams.FunctionSchema.builder() @@ -75,19 +75,36 @@ class FunctionServiceTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params .OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -202,19 +219,36 @@ class FunctionServiceTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params .OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -368,9 +402,9 @@ class FunctionServiceTest { .build() ) ) - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionSchema( FunctionReplaceParams.FunctionSchema.builder() @@ -412,19 +446,36 @@ class FunctionServiceTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params .OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index 197a6890..5f1645db 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -23,7 +23,7 @@ class GroupServiceTest { val group = groupService.create( GroupCreateParams.builder() - .name("name") + .name("x") .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -67,7 +67,7 @@ class GroupServiceTest { .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .description("description") - .name("name") + .name("x") .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .build() @@ -116,7 +116,7 @@ class GroupServiceTest { val group = groupService.replace( GroupReplaceParams.builder() - .name("name") + .name("x") .description("description") .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) 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 7726d0da..43cccc02 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 @@ -25,7 +25,7 @@ class ProjectScoreServiceTest { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) .categories( ProjectScoreCreateParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) @@ -127,7 +127,7 @@ class ProjectScoreServiceTest { ) .description("description") .name("name") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) .build() ) println(projectScore) @@ -178,7 +178,7 @@ class ProjectScoreServiceTest { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreType.SLIDER) + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) .categories( ProjectScoreReplaceParams.Categories.ofCategorical( listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index b0793622..77a28f8e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -22,7 +22,7 @@ class ProjectServiceTest { val projectService = client.projects() val project = projectService.create( - ProjectCreateParams.builder().name("name").orgName("org_name").build() + ProjectCreateParams.builder().name("x").orgName("org_name").build() ) println(project) project.validate() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index bb5693ea..c5370402 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -23,9 +23,9 @@ class PromptServiceTest { val prompt = promptService.create( PromptCreateParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionType(PromptCreateParams.FunctionType.LLM) .promptData( @@ -54,19 +54,36 @@ class PromptServiceTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params .OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -174,19 +191,36 @@ class PromptServiceTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params .OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .build() @@ -279,9 +313,9 @@ class PromptServiceTest { val prompt = promptService.replace( PromptReplaceParams.builder() - .name("name") + .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") + .slug("x") .description("description") .functionType(PromptReplaceParams.FunctionType.LLM) .promptData( @@ -310,19 +344,36 @@ class PromptServiceTest { .responseFormat( PromptData.Options.Params.OpenAIModelParams .ResponseFormat - .builder() - .type( + .ofJsonObject( PromptData.Options.Params .OpenAIModelParams .ResponseFormat - .Type - .JSON_OBJECT + .JsonObject + .builder() + .type( + PromptData.Options.Params + .OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() ) - .build() ) .stop(listOf("string")) .temperature(42.23) - .toolChoice(ToolChoice.ofAuto(ToolChoice.Auto.AUTO)) + .toolChoice( + PromptData.Options.Params.OpenAIModelParams + .ToolChoice + .ofAuto( + PromptData.Options.Params + .OpenAIModelParams + .ToolChoice + .Auto + .AUTO + ) + ) .topP(42.23) .useCache(true) .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 20cdf599..3478e6f4 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 @@ -23,7 +23,7 @@ class RoleServiceTest { val role = roleService.create( RoleCreateParams.builder() - .name("name") + .name("x") .description("description") .memberPermissions( listOf( @@ -85,7 +85,7 @@ class RoleServiceTest { ) .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) .description("description") - .name("name") + .name("x") .removeMemberPermissions( listOf( RoleUpdateParams.RemoveMemberPermission.builder() @@ -146,7 +146,7 @@ class RoleServiceTest { val role = roleService.replace( RoleReplaceParams.builder() - .name("name") + .name("x") .description("description") .memberPermissions( listOf( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt new file mode 100644 index 00000000..a08406db --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.blocking + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.SpanIframeListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class SpanIframeServiceTest { + + @Test + fun callCreate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + val spanIFrame = + spanIframeService.create( + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + ) + println(spanIFrame) + spanIFrame.validate() + } + + @Test + fun callRetrieve() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + val spanIFrame = + spanIframeService.retrieve( + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(spanIFrame) + spanIFrame.validate() + } + + @Test + fun callUpdate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + val spanIFrame = + spanIframeService.update( + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + ) + println(spanIFrame) + spanIFrame.validate() + } + + @Test + fun callList() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + val response = spanIframeService.list(SpanIframeListParams.builder().build()) + println(response) + response.objects().forEach { it.validate() } + } + + @Test + fun callDelete() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + val spanIFrame = + spanIframeService.delete( + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(spanIFrame) + spanIFrame.validate() + } + + @Test + fun callReplace() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + val spanIFrame = + spanIframeService.replace( + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + ) + println(spanIFrame) + spanIFrame.validate() + } +} 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 21c25964..e1ea6e91 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 @@ -105,7 +105,7 @@ class LogServiceTest { .apiKey("My API Key") .build() val logService = client.projects().logs() - val insertEventsResponse = + val projectLogInsertResponse = logService.insert( ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -133,6 +133,9 @@ class LogServiceTest { ) .metrics( InsertProjectLogsEventReplace.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) .completionTokens(123L) .end(42.23) .promptTokens(123L) @@ -158,7 +161,6 @@ class LogServiceTest { ) .build() ) - println(insertEventsResponse) - insertEventsResponse.validate() + println(projectLogInsertResponse) } } diff --git a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts index 4913adb6..cf06fbdd 100755 --- a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts @@ -41,7 +41,7 @@ configure { developers { developer { name.set("Braintrust") - email.set("info-test@braintrustdata.com") + email.set("info@braintrustdata.com") } } From 3c635adb8c1d2e6e26f20e764ac5b9de50b4f2db Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Wed, 20 Nov 2024 23:46:28 +0000 Subject: [PATCH 24/87] feat(api): manual updates (#93) --- .stats.yml | 2 +- .../braintrustdata/api/models/DatasetEvent.kt | 8 +- .../api/models/DatasetInsertParams.kt | 164 +- .../api/models/ExperimentEvent.kt | 204 +- .../api/models/ExperimentInsertParams.kt | 170 +- .../api/models/InsertDatasetEvent.kt | 810 +++++ .../api/models/InsertDatasetEventMerge.kt | 492 --- .../api/models/InsertDatasetEventReplace.kt | 485 --- ...EventMerge.kt => InsertExperimentEvent.kt} | 607 ++-- .../models/InsertExperimentEventReplace.kt | 1457 -------- ...ventMerge.kt => InsertProjectLogsEvent.kt} | 605 ++-- .../models/InsertProjectLogsEventReplace.kt | 1409 -------- .../api/models/ProjectLogInsertParams.kt | 172 +- .../api/models/ProjectLogsEvent.kt | 204 +- .../braintrustdata/api/models/PromptData.kt | 3022 +---------------- .../api/models/PromptOptions.kt | 3004 ++++++++++++++++ .../api/models/SpanAttributes.kt | 215 ++ .../api/models/DatasetInsertParamsTest.kt | 105 +- .../api/models/ExperimentEventTest.kt | 12 +- .../api/models/ExperimentInsertParamsTest.kt | 231 +- .../FetchExperimentEventsResponseTest.kt | 9 +- .../FetchProjectLogsEventsResponseTest.kt | 9 +- .../api/models/FunctionCreateParamsTest.kt | 66 +- .../api/models/FunctionReplaceParamsTest.kt | 66 +- .../braintrustdata/api/models/FunctionTest.kt | 44 +- .../api/models/FunctionUpdateParamsTest.kt | 66 +- .../api/models/InsertDatasetEventMergeTest.kt | 39 - .../models/InsertDatasetEventReplaceTest.kt | 39 - .../api/models/InsertDatasetEventTest.kt | 47 + .../models/InsertExperimentEventMergeTest.kt | 101 - .../InsertExperimentEventReplaceTest.kt | 101 - .../api/models/InsertExperimentEventTest.kt | 101 + .../models/InsertProjectLogsEventMergeTest.kt | 100 - .../InsertProjectLogsEventReplaceTest.kt | 99 - .../api/models/InsertProjectLogsEventTest.kt | 99 + .../api/models/ProjectLogInsertParamsTest.kt | 227 +- .../api/models/ProjectLogsEventTest.kt | 12 +- .../api/models/PromptCreateParamsTest.kt | 66 +- .../api/models/PromptDataTest.kt | 57 +- .../api/models/PromptOptionsTest.kt | 96 + .../api/models/PromptReplaceParamsTest.kt | 66 +- .../braintrustdata/api/models/PromptTest.kt | 44 +- .../api/models/PromptUpdateParamsTest.kt | 66 +- .../api/models/SpanAttributesTest.kt | 18 + .../services/blocking/DatasetServiceTest.kt | 28 +- .../blocking/ExperimentServiceTest.kt | 90 +- .../services/blocking/FunctionServiceTest.kt | 69 +- .../services/blocking/PromptServiceTest.kt | 69 +- .../blocking/projects/LogServiceTest.kt | 89 +- 49 files changed, 5841 insertions(+), 9520 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt delete mode 100755 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt delete mode 100755 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{InsertExperimentEventMerge.kt => InsertExperimentEvent.kt} (68%) mode change 100755 => 100644 delete mode 100755 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{InsertProjectLogsEventMerge.kt => InsertProjectLogsEvent.kt} (68%) mode change 100755 => 100644 delete mode 100755 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt delete mode 100755 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt delete mode 100755 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt delete mode 100755 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt delete mode 100755 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt delete mode 100755 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt delete mode 100755 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt diff --git a/.stats.yml b/.stats.yml index b229724a..4ed71f89 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-360c6d1b34acf77d5a439e1c0e6a071223701d1461538d6b06da1598e5e2b742.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-6970b65779234e307010f4471a87cb7afa22919dc2c3ee63cf63cb9979c3eafd.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index dd89283a..6dfe64a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -91,7 +91,7 @@ private constructor( */ fun spanId(): String = spanId.getRequired("span_id") - /** The `span_id` of the root of the trace this dataset event belongs to */ + /** A unique identifier for the trace this dataset event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** Whether this span is a root span */ @@ -150,7 +150,7 @@ private constructor( */ @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId - /** The `span_id` of the root of the trace this dataset event belongs to */ + /** A unique identifier for the trace this dataset event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId /** Whether this span is a root span */ @@ -335,10 +335,10 @@ private constructor( @ExcludeMissing fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - /** The `span_id` of the root of the trace this dataset event belongs to */ + /** A unique identifier for the trace this dataset event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** The `span_id` of the root of the trace this dataset event belongs to */ + /** A unique identifier for the trace this dataset event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 9a0e9a89..7c0b4337 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -2,34 +2,23 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects -import java.util.Optional class DatasetInsertParams constructor( private val datasetId: String, - private val events: List, + private val events: List, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -37,7 +26,7 @@ constructor( fun datasetId(): String = datasetId - fun events(): List = events + fun events(): List = events @JvmSynthetic internal fun getBody(): DatasetInsertBody { @@ -59,12 +48,12 @@ constructor( @NoAutoDetect class DatasetInsertBody internal constructor( - private val events: List?, + private val events: List?, private val additionalProperties: Map, ) { /** A list of dataset events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -79,7 +68,7 @@ constructor( class Builder { - private var events: List? = null + private var events: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -89,7 +78,8 @@ constructor( } /** A list of dataset events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -165,7 +155,7 @@ constructor( class Builder { private var datasetId: String? = null - private var events: MutableList = mutableListOf() + private var events: MutableList = mutableListOf() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -183,13 +173,13 @@ constructor( fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset events to insert */ - fun events(events: List) = apply { + fun events(events: List) = apply { this.events.clear() this.events.addAll(events) } /** A list of dataset events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: InsertDatasetEvent) = apply { this.events.add(event) } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -320,138 +310,4 @@ constructor( additionalBodyProperties.toImmutable(), ) } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, - private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertDatasetEventReplace(): Optional = - Optional.ofNullable(insertDatasetEventReplace) - - fun insertDatasetEventMerge(): Optional = - Optional.ofNullable(insertDatasetEventMerge) - - fun isInsertDatasetEventReplace(): Boolean = insertDatasetEventReplace != null - - fun isInsertDatasetEventMerge(): Boolean = insertDatasetEventMerge != null - - fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = - insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") - - fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = - insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - insertDatasetEventReplace != null -> - visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) - insertDatasetEventMerge != null -> - visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertDatasetEventReplace?.validate() - insertDatasetEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && this.insertDatasetEventReplace == other.insertDatasetEventReplace && this.insertDatasetEventMerge == other.insertDatasetEventMerge /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) /* spotless:on */ - } - - override fun toString(): String { - return when { - insertDatasetEventReplace != null -> - "Event{insertDatasetEventReplace=$insertDatasetEventReplace}" - insertDatasetEventMerge != null -> - "Event{insertDatasetEventMerge=$insertDatasetEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - @JvmStatic - fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = - Event(insertDatasetEventReplace = insertDatasetEventReplace) - - @JvmStatic - fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = - Event(insertDatasetEventMerge = insertDatasetEventMerge) - } - - interface Visitor { - - fun visitInsertDatasetEventReplace( - insertDatasetEventReplace: InsertDatasetEventReplace - ): T - - fun visitInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertDatasetEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertDatasetEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertDatasetEventReplace != null -> - generator.writeObject(value.insertDatasetEventReplace) - value.insertDatasetEventMerge != null -> - generator.writeObject(value.insertDatasetEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index 4de93e47..9ba8b444 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -159,7 +159,7 @@ private constructor( fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** The `span_id` of the root of the trace this experiment event belongs to */ + /** A unique identifier for the trace this experiment event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** Human-identifying attributes of the span, such as name, type, etc. */ @@ -280,7 +280,7 @@ private constructor( */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents - /** The `span_id` of the root of the trace this experiment event belongs to */ + /** A unique identifier for the trace this experiment event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId /** Human-identifying attributes of the span, such as name, type, etc. */ @@ -606,10 +606,10 @@ private constructor( this.spanParents = spanParents } - /** The `span_id` of the root of the trace this experiment event belongs to */ + /** A unique identifier for the trace this experiment event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** The `span_id` of the root of the trace this experiment event belongs to */ + /** A unique identifier for the trace this experiment event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } @@ -1516,202 +1516,6 @@ private constructor( override fun toString() = "Scores{additionalProperties=$additionalProperties}" } - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - 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 - } - - 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") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 7c3b8465..df3e98ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -2,34 +2,23 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects -import java.util.Optional class ExperimentInsertParams constructor( private val experimentId: String, - private val events: List, + private val events: List, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -37,7 +26,7 @@ constructor( fun experimentId(): String = experimentId - fun events(): List = events + fun events(): List = events @JvmSynthetic internal fun getBody(): ExperimentInsertBody { @@ -59,12 +48,12 @@ constructor( @NoAutoDetect class ExperimentInsertBody internal constructor( - private val events: List?, + private val events: List?, private val additionalProperties: Map, ) { /** A list of experiment events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -79,7 +68,7 @@ constructor( class Builder { - private var events: List? = null + private var events: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -89,7 +78,8 @@ constructor( } /** A list of experiment events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -165,7 +155,7 @@ constructor( class Builder { private var experimentId: String? = null - private var events: MutableList = mutableListOf() + private var events: MutableList = mutableListOf() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -183,13 +173,13 @@ constructor( fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment events to insert */ - fun events(events: List) = apply { + fun events(events: List) = apply { this.events.clear() this.events.addAll(events) } /** A list of experiment events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: InsertExperimentEvent) = apply { this.events.add(event) } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -320,144 +310,4 @@ constructor( additionalBodyProperties.toImmutable(), ) } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, - private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertExperimentEventReplace(): Optional = - Optional.ofNullable(insertExperimentEventReplace) - - fun insertExperimentEventMerge(): Optional = - Optional.ofNullable(insertExperimentEventMerge) - - fun isInsertExperimentEventReplace(): Boolean = insertExperimentEventReplace != null - - fun isInsertExperimentEventMerge(): Boolean = insertExperimentEventMerge != null - - fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = - insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") - - fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = - insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - insertExperimentEventReplace != null -> - visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) - insertExperimentEventMerge != null -> - visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertExperimentEventReplace?.validate() - insertExperimentEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && this.insertExperimentEventReplace == other.insertExperimentEventReplace && this.insertExperimentEventMerge == other.insertExperimentEventMerge /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) /* spotless:on */ - } - - override fun toString(): String { - return when { - insertExperimentEventReplace != null -> - "Event{insertExperimentEventReplace=$insertExperimentEventReplace}" - insertExperimentEventMerge != null -> - "Event{insertExperimentEventMerge=$insertExperimentEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - @JvmStatic - fun ofInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ) = Event(insertExperimentEventReplace = insertExperimentEventReplace) - - @JvmStatic - fun ofInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ) = Event(insertExperimentEventMerge = insertExperimentEventMerge) - } - - interface Visitor { - - fun visitInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ): T - - fun visitInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertExperimentEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertExperimentEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertExperimentEventReplace != null -> - generator.writeObject(value.insertExperimentEventReplace) - value.insertExperimentEventMerge != null -> - generator.writeObject(value.insertExperimentEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt new file mode 100644 index 00000000..d597b616 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -0,0 +1,810 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toImmutable +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +/** A dataset event */ +@JsonDeserialize(builder = InsertDatasetEvent.Builder::class) +@NoAutoDetect +class InsertDatasetEvent +private constructor( + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val _parentId: JsonField, + private val spanId: JsonField, + private val rootSpanId: JsonField, + private val spanParents: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + fun input(): JsonValue = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + fun expected(): JsonValue = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you + */ + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** The timestamp the dataset event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + @JsonProperty("input") @ExcludeMissing fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you + */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** The timestamp the dataset event was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset + */ + @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InsertDatasetEvent = apply { + if (!validated) { + input() + expected() + metadata().map { it.validate() } + tags() + id() + created() + _objectDelete() + _isMerge() + _mergePaths() + _parentId() + spanId() + rootSpanId() + spanParents() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var input: JsonValue = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var _objectDelete: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _mergePaths: JsonField>> = JsonMissing.of() + private var _parentId: JsonField = JsonMissing.of() + private var spanId: JsonField = JsonMissing.of() + private var rootSpanId: JsonField = JsonMissing.of() + private var spanParents: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(insertDatasetEvent: InsertDatasetEvent) = apply { + this.input = insertDatasetEvent.input + this.expected = insertDatasetEvent.expected + this.metadata = insertDatasetEvent.metadata + this.tags = insertDatasetEvent.tags + this.id = insertDatasetEvent.id + this.created = insertDatasetEvent.created + this._objectDelete = insertDatasetEvent._objectDelete + this._isMerge = insertDatasetEvent._isMerge + this._mergePaths = insertDatasetEvent._mergePaths + this._parentId = insertDatasetEvent._parentId + this.spanId = insertDatasetEvent.spanId + this.rootSpanId = insertDatasetEvent.rootSpanId + this.spanParents = insertDatasetEvent.spanParents + additionalProperties(insertDatasetEvent.additionalProperties) + } + + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + */ + @JsonProperty("input") + @ExcludeMissing + fun input(input: JsonValue) = apply { this.input = input } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) + */ + @JsonProperty("expected") + @ExcludeMissing + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you + */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** The timestamp the dataset event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** The timestamp the dataset event was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @JsonProperty("_is_merge") + @ExcludeMissing + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + @JsonProperty("_merge_paths") + @ExcludeMissing + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths + } + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("_parent_id") + @ExcludeMissing + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_id") + @ExcludeMissing + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("root_span_id") + @ExcludeMissing + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_parents") + @ExcludeMissing + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InsertDatasetEvent = + InsertDatasetEvent( + input, + expected, + metadata, + tags.map { it.toImmutable() }, + id, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toImmutable() }, + _parentId, + spanId, + rootSpanId, + spanParents.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonDeserialize(builder = Metadata.Builder::class) + @NoAutoDetect + class Metadata + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties(metadata.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InsertDatasetEvent && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this._parentId == other._parentId && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.spanParents == other.spanParents && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(input, expected, metadata, tags, id, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "InsertDatasetEvent{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt deleted file mode 100755 index d2f57519..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt +++ /dev/null @@ -1,492 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = InsertDatasetEventMerge.Builder::class) -@NoAutoDetect -class InsertDatasetEventMerge -private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) - */ - fun expected(): JsonValue = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** The timestamp the dataset event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) - - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertDatasetEventMerge = apply { - if (!validated) { - input() - expected() - metadata().map { it.validate() } - tags() - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _mergePaths: JsonField>> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertDatasetEventMerge: InsertDatasetEventMerge) = apply { - this.input = insertDatasetEventMerge.input - this.expected = insertDatasetEventMerge.expected - this.metadata = insertDatasetEventMerge.metadata - this.tags = insertDatasetEventMerge.tags - this.id = insertDatasetEventMerge.id - this.created = insertDatasetEventMerge.created - this._objectDelete = insertDatasetEventMerge._objectDelete - this._isMerge = insertDatasetEventMerge._isMerge - this._mergePaths = insertDatasetEventMerge._mergePaths - additionalProperties(insertDatasetEventMerge.additionalProperties) - } - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the dataset event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ - fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) - - /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InsertDatasetEventMerge = - InsertDatasetEventMerge( - input, - expected, - metadata, - tags.map { it.toImmutable() }, - id, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InsertDatasetEventMerge && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, expected, metadata, tags, id, created, _objectDelete, _isMerge, _mergePaths, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt deleted file mode 100755 index 7e0e8227..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt +++ /dev/null @@ -1,485 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = InsertDatasetEventReplace.Builder::class) -@NoAutoDetect -class InsertDatasetEventReplace -private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) - */ - fun expected(): JsonValue = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** The timestamp the dataset event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) - - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertDatasetEventReplace = apply { - if (!validated) { - input() - expected() - metadata().map { it.validate() } - tags() - id() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _parentId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertDatasetEventReplace: InsertDatasetEventReplace) = apply { - this.input = insertDatasetEventReplace.input - this.expected = insertDatasetEventReplace.expected - this.metadata = insertDatasetEventReplace.metadata - this.tags = insertDatasetEventReplace.tags - this.id = insertDatasetEventReplace.id - this.created = insertDatasetEventReplace.created - this._objectDelete = insertDatasetEventReplace._objectDelete - this._isMerge = insertDatasetEventReplace._isMerge - this._parentId = insertDatasetEventReplace._parentId - additionalProperties(insertDatasetEventReplace.additionalProperties) - } - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the dataset event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InsertDatasetEventReplace = - InsertDatasetEventReplace( - input, - expected, - metadata, - tags.map { it.toImmutable() }, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toImmutable(), - ) - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InsertDatasetEventReplace && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._parentId == other._parentId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, expected, metadata, tags, id, created, _objectDelete, _isMerge, _parentId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt old mode 100755 new mode 100644 similarity index 68% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 752c52bc..89520f8d --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -2,26 +2,24 @@ 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 import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect 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 import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = InsertExperimentEventMerge.Builder::class) +/** An experiment event */ +@JsonDeserialize(builder = InsertExperimentEvent.Builder::class) @NoAutoDetect -class InsertExperimentEventMerge +class InsertExperimentEvent private constructor( private val input: JsonValue, private val output: JsonValue, @@ -39,6 +37,10 @@ private constructor( private val _objectDelete: JsonField, private val _isMerge: JsonField, private val _mergePaths: JsonField>>, + private val _parentId: JsonField, + private val spanId: JsonField, + private val rootSpanId: JsonField, + private val spanParents: JsonField>, private val additionalProperties: Map, ) { @@ -141,7 +143,8 @@ private constructor( /** * The `_is_merge` field controls how the row is merged with any existing row with the same id * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": @@ -149,12 +152,12 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") + fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, @@ -167,6 +170,77 @@ private constructor( fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) + /** * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). * Later on, Braintrust will use the `input` to know whether two test cases are the same between @@ -261,7 +335,8 @@ private constructor( /** * The `_is_merge` field controls how the row is merged with any existing row with the same id * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": @@ -272,9 +347,9 @@ private constructor( @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, @@ -286,11 +361,81 @@ private constructor( */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): InsertExperimentEventMerge = apply { + fun validate(): InsertExperimentEvent = apply { if (!validated) { input() output() @@ -308,6 +453,10 @@ private constructor( _objectDelete() _isMerge() _mergePaths() + _parentId() + spanId() + rootSpanId() + spanParents() validated = true } } @@ -337,27 +486,35 @@ private constructor( private var _objectDelete: JsonField = JsonMissing.of() private var _isMerge: JsonField = JsonMissing.of() private var _mergePaths: JsonField>> = JsonMissing.of() + private var _parentId: JsonField = JsonMissing.of() + private var spanId: JsonField = JsonMissing.of() + private var rootSpanId: JsonField = JsonMissing.of() + private var spanParents: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertExperimentEventMerge: InsertExperimentEventMerge) = apply { - this.input = insertExperimentEventMerge.input - this.output = insertExperimentEventMerge.output - this.expected = insertExperimentEventMerge.expected - this.error = insertExperimentEventMerge.error - this.scores = insertExperimentEventMerge.scores - this.metadata = insertExperimentEventMerge.metadata - this.tags = insertExperimentEventMerge.tags - this.metrics = insertExperimentEventMerge.metrics - this.context = insertExperimentEventMerge.context - this.spanAttributes = insertExperimentEventMerge.spanAttributes - this.id = insertExperimentEventMerge.id - this.datasetRecordId = insertExperimentEventMerge.datasetRecordId - this.created = insertExperimentEventMerge.created - this._objectDelete = insertExperimentEventMerge._objectDelete - this._isMerge = insertExperimentEventMerge._isMerge - this._mergePaths = insertExperimentEventMerge._mergePaths - additionalProperties(insertExperimentEventMerge.additionalProperties) + internal fun from(insertExperimentEvent: InsertExperimentEvent) = apply { + this.input = insertExperimentEvent.input + this.output = insertExperimentEvent.output + this.expected = insertExperimentEvent.expected + this.error = insertExperimentEvent.error + this.scores = insertExperimentEvent.scores + this.metadata = insertExperimentEvent.metadata + this.tags = insertExperimentEvent.tags + this.metrics = insertExperimentEvent.metrics + this.context = insertExperimentEvent.context + this.spanAttributes = insertExperimentEvent.spanAttributes + this.id = insertExperimentEvent.id + this.datasetRecordId = insertExperimentEvent.datasetRecordId + this.created = insertExperimentEvent.created + this._objectDelete = insertExperimentEvent._objectDelete + this._isMerge = insertExperimentEvent._isMerge + this._mergePaths = insertExperimentEvent._mergePaths + this._parentId = insertExperimentEvent._parentId + this.spanId = insertExperimentEvent.spanId + this.rootSpanId = insertExperimentEvent.rootSpanId + this.spanParents = insertExperimentEvent.spanParents + additionalProperties(insertExperimentEvent.additionalProperties) } /** @@ -550,7 +707,7 @@ private constructor( * The `_is_merge` field controls how the row is merged with any existing row with the same * id in the DB. By default (or when set to `false`), the existing row is completely * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * row, if one is found. If no existing row is found, the new row is inserted as is. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": @@ -564,7 +721,7 @@ private constructor( * The `_is_merge` field controls how the row is merged with any existing row with the same * id in the DB. By default (or when set to `false`), the existing row is completely * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * row, if one is found. If no existing row is found, the new row is inserted as is. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": @@ -577,10 +734,9 @@ private constructor( fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": @@ -593,10 +749,9 @@ private constructor( fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": @@ -612,6 +767,162 @@ private constructor( this._mergePaths = _mergePaths } + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("_parent_id") + @ExcludeMissing + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_id") + @ExcludeMissing + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("root_span_id") + @ExcludeMissing + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_parents") + @ExcludeMissing + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -626,8 +937,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertExperimentEventMerge = - InsertExperimentEventMerge( + fun build(): InsertExperimentEvent = + InsertExperimentEvent( input, output, expected, @@ -644,6 +955,10 @@ private constructor( _objectDelete, _isMerge, _mergePaths.map { it.toImmutable() }, + _parentId, + spanId, + rootSpanId, + spanParents.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -1246,219 +1561,23 @@ private constructor( override fun toString() = "Scores{additionalProperties=$additionalProperties}" } - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - 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 - } - - 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") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InsertExperimentEventMerge && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertExperimentEvent && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this._parentId == other._parentId && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.spanParents == other.spanParents && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, datasetRecordId, created, _objectDelete, _isMerge, _mergePaths, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, datasetRecordId, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + "InsertExperimentEvent{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt deleted file mode 100755 index 1bbce65c..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt +++ /dev/null @@ -1,1457 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -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 -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = InsertExperimentEventReplace.Builder::class) -@NoAutoDetect -class InsertExperimentEventReplace -private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val datasetRecordId: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models - */ - fun expected(): JsonValue = expected - - /** The error that occurred, if any. */ - fun error(): JsonValue = error - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - - /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event - */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) - - /** The timestamp the experiment event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId - - /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertExperimentEventReplace = apply { - if (!validated) { - input() - output() - expected() - error() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - datasetRecordId() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var error: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _parentId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertExperimentEventReplace: InsertExperimentEventReplace) = apply { - this.input = insertExperimentEventReplace.input - this.output = insertExperimentEventReplace.output - this.expected = insertExperimentEventReplace.expected - this.error = insertExperimentEventReplace.error - this.scores = insertExperimentEventReplace.scores - this.metadata = insertExperimentEventReplace.metadata - this.tags = insertExperimentEventReplace.tags - this.metrics = insertExperimentEventReplace.metrics - this.context = insertExperimentEventReplace.context - this.spanAttributes = insertExperimentEventReplace.spanAttributes - this.id = insertExperimentEventReplace.id - this.datasetRecordId = insertExperimentEventReplace.datasetRecordId - this.created = insertExperimentEventReplace.created - this._objectDelete = insertExperimentEventReplace._objectDelete - this._isMerge = insertExperimentEventReplace._isMerge - this._parentId = insertExperimentEventReplace._parentId - additionalProperties(insertExperimentEventReplace.additionalProperties) - } - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - - /** The timestamp the experiment event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment - */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InsertExperimentEventReplace = - InsertExperimentEventReplace( - input, - output, - expected, - error, - scores, - metadata, - tags.map { it.toImmutable() }, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toImmutable(), - ) - } - - /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - - /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val callerFunctionname: JsonValue, - private val callerFilename: JsonValue, - private val callerLineno: JsonValue, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** - * A unix timestamp recording when the section of code which produced the experiment event - * started - */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - - /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished - */ - fun end(): Optional = Optional.ofNullable(end.getNullable("end")) - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) - - /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) - */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - - /** This metric is deprecated */ - fun callerFunctionname(): JsonValue = callerFunctionname - - /** This metric is deprecated */ - fun callerFilename(): JsonValue = callerFilename - - /** This metric is deprecated */ - fun callerLineno(): JsonValue = callerLineno - - /** - * A unix timestamp recording when the section of code which produced the experiment event - * started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** This metric is deprecated */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var callerFunctionname: JsonValue = JsonMissing.of() - private var callerFilename: JsonValue = JsonMissing.of() - private var callerLineno: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - this.callerFunctionname = metrics.callerFunctionname - this.callerFilename = metrics.callerFilename - this.callerLineno = metrics.callerLineno - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } - - /** This metric is deprecated */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } - - /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Scores = Scores(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - 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 - } - - 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") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InsertExperimentEventReplace && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._parentId == other._parentId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, datasetRecordId, created, _objectDelete, _isMerge, _parentId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt old mode 100755 new mode 100644 similarity index 68% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index 77edee4f..2a01fd2b --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -2,26 +2,24 @@ 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 import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect 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 import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = InsertProjectLogsEventMerge.Builder::class) +/** A project logs event */ +@JsonDeserialize(builder = InsertProjectLogsEvent.Builder::class) @NoAutoDetect -class InsertProjectLogsEventMerge +class InsertProjectLogsEvent private constructor( private val input: JsonValue, private val output: JsonValue, @@ -38,6 +36,10 @@ private constructor( private val _objectDelete: JsonField, private val _isMerge: JsonField, private val _mergePaths: JsonField>>, + private val _parentId: JsonField, + private val spanId: JsonField, + private val rootSpanId: JsonField, + private val spanParents: JsonField>, private val additionalProperties: Map, ) { @@ -128,7 +130,8 @@ private constructor( /** * The `_is_merge` field controls how the row is merged with any existing row with the same id * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": @@ -136,12 +139,12 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") + fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, @@ -154,6 +157,77 @@ private constructor( fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ @JsonProperty("input") @ExcludeMissing fun _input() = input @@ -237,7 +311,8 @@ private constructor( /** * The `_is_merge` field controls how the row is merged with any existing row with the same id * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": @@ -248,9 +323,9 @@ private constructor( @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, @@ -262,11 +337,81 @@ private constructor( */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): InsertProjectLogsEventMerge = apply { + fun validate(): InsertProjectLogsEvent = apply { if (!validated) { input() output() @@ -283,6 +428,10 @@ private constructor( _objectDelete() _isMerge() _mergePaths() + _parentId() + spanId() + rootSpanId() + spanParents() validated = true } } @@ -311,26 +460,34 @@ private constructor( private var _objectDelete: JsonField = JsonMissing.of() private var _isMerge: JsonField = JsonMissing.of() private var _mergePaths: JsonField>> = JsonMissing.of() + private var _parentId: JsonField = JsonMissing.of() + private var spanId: JsonField = JsonMissing.of() + private var rootSpanId: JsonField = JsonMissing.of() + private var spanParents: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertProjectLogsEventMerge: InsertProjectLogsEventMerge) = apply { - this.input = insertProjectLogsEventMerge.input - this.output = insertProjectLogsEventMerge.output - this.expected = insertProjectLogsEventMerge.expected - this.error = insertProjectLogsEventMerge.error - this.scores = insertProjectLogsEventMerge.scores - this.metadata = insertProjectLogsEventMerge.metadata - this.tags = insertProjectLogsEventMerge.tags - this.metrics = insertProjectLogsEventMerge.metrics - this.context = insertProjectLogsEventMerge.context - this.spanAttributes = insertProjectLogsEventMerge.spanAttributes - this.id = insertProjectLogsEventMerge.id - this.created = insertProjectLogsEventMerge.created - this._objectDelete = insertProjectLogsEventMerge._objectDelete - this._isMerge = insertProjectLogsEventMerge._isMerge - this._mergePaths = insertProjectLogsEventMerge._mergePaths - additionalProperties(insertProjectLogsEventMerge.additionalProperties) + internal fun from(insertProjectLogsEvent: InsertProjectLogsEvent) = apply { + this.input = insertProjectLogsEvent.input + this.output = insertProjectLogsEvent.output + this.expected = insertProjectLogsEvent.expected + this.error = insertProjectLogsEvent.error + this.scores = insertProjectLogsEvent.scores + this.metadata = insertProjectLogsEvent.metadata + this.tags = insertProjectLogsEvent.tags + this.metrics = insertProjectLogsEvent.metrics + this.context = insertProjectLogsEvent.context + this.spanAttributes = insertProjectLogsEvent.spanAttributes + this.id = insertProjectLogsEvent.id + this.created = insertProjectLogsEvent.created + this._objectDelete = insertProjectLogsEvent._objectDelete + this._isMerge = insertProjectLogsEvent._isMerge + this._mergePaths = insertProjectLogsEvent._mergePaths + this._parentId = insertProjectLogsEvent._parentId + this.spanId = insertProjectLogsEvent.spanId + this.rootSpanId = insertProjectLogsEvent.rootSpanId + this.spanParents = insertProjectLogsEvent.spanParents + additionalProperties(insertProjectLogsEvent.additionalProperties) } /** @@ -503,7 +660,7 @@ private constructor( * The `_is_merge` field controls how the row is merged with any existing row with the same * id in the DB. By default (or when set to `false`), the existing row is completely * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * row, if one is found. If no existing row is found, the new row is inserted as is. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": @@ -517,7 +674,7 @@ private constructor( * The `_is_merge` field controls how the row is merged with any existing row with the same * id in the DB. By default (or when set to `false`), the existing row is completely * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * row, if one is found. If no existing row is found, the new row is inserted as is. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": @@ -530,10 +687,9 @@ private constructor( fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": @@ -546,10 +702,9 @@ private constructor( fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": @@ -565,6 +720,162 @@ private constructor( this._mergePaths = _mergePaths } + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("_parent_id") + @ExcludeMissing + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_id") + @ExcludeMissing + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("root_span_id") + @ExcludeMissing + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + @JsonProperty("span_parents") + @ExcludeMissing + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -579,8 +890,8 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertProjectLogsEventMerge = - InsertProjectLogsEventMerge( + fun build(): InsertProjectLogsEvent = + InsertProjectLogsEvent( input, output, expected, @@ -596,6 +907,10 @@ private constructor( _objectDelete, _isMerge, _mergePaths.map { it.toImmutable() }, + _parentId, + spanId, + rootSpanId, + spanParents.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -1198,219 +1513,23 @@ private constructor( override fun toString() = "Scores{additionalProperties=$additionalProperties}" } - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - 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 - } - - 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") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InsertProjectLogsEventMerge && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertProjectLogsEvent && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this._parentId == other._parentId && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.spanParents == other.spanParents && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, created, _objectDelete, _isMerge, _mergePaths, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + "InsertProjectLogsEvent{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt deleted file mode 100755 index 352b16ff..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt +++ /dev/null @@ -1,1409 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -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 -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = InsertProjectLogsEventReplace.Builder::class) -@NoAutoDetect -class InsertProjectLogsEventReplace -private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. - */ - fun expected(): JsonValue = expected - - /** The error that occurred, if any. */ - fun error(): JsonValue = error - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced - */ - fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - - /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event - */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** The timestamp the project logs event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) - - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertProjectLogsEventReplace = apply { - if (!validated) { - input() - output() - expected() - error() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var error: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _parentId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insertProjectLogsEventReplace: InsertProjectLogsEventReplace) = apply { - this.input = insertProjectLogsEventReplace.input - this.output = insertProjectLogsEventReplace.output - this.expected = insertProjectLogsEventReplace.expected - this.error = insertProjectLogsEventReplace.error - this.scores = insertProjectLogsEventReplace.scores - this.metadata = insertProjectLogsEventReplace.metadata - this.tags = insertProjectLogsEventReplace.tags - this.metrics = insertProjectLogsEventReplace.metrics - this.context = insertProjectLogsEventReplace.context - this.spanAttributes = insertProjectLogsEventReplace.spanAttributes - this.id = insertProjectLogsEventReplace.id - this.created = insertProjectLogsEventReplace.created - this._objectDelete = insertProjectLogsEventReplace._objectDelete - this._isMerge = insertProjectLogsEventReplace._isMerge - this._parentId = insertProjectLogsEventReplace._parentId - additionalProperties(insertProjectLogsEventReplace.additionalProperties) - } - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the project logs event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs - */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs - */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InsertProjectLogsEventReplace = - InsertProjectLogsEventReplace( - input, - output, - expected, - error, - scores, - metadata, - tags.map { it.toImmutable() }, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toImmutable(), - ) - } - - /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - - /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val callerFunctionname: JsonValue, - private val callerFilename: JsonValue, - private val callerLineno: JsonValue, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** - * A unix timestamp recording when the section of code which produced the project logs event - * started - */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - - /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished - */ - fun end(): Optional = Optional.ofNullable(end.getNullable("end")) - - /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) - */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) - - /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) - */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) - - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - - /** This metric is deprecated */ - fun callerFunctionname(): JsonValue = callerFunctionname - - /** This metric is deprecated */ - fun callerFilename(): JsonValue = callerFilename - - /** This metric is deprecated */ - fun callerLineno(): JsonValue = callerLineno - - /** - * A unix timestamp recording when the section of code which produced the project logs event - * started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** This metric is deprecated */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var callerFunctionname: JsonValue = JsonMissing.of() - private var callerFilename: JsonValue = JsonMissing.of() - private var callerLineno: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - this.callerFunctionname = metrics.callerFunctionname - this.callerFilename = metrics.callerFilename - this.callerLineno = metrics.callerLineno - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } - - /** This metric is deprecated */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } - - /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Scores = Scores(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - 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 - } - - 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") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InsertProjectLogsEventReplace && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._parentId == other._parentId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, created, _objectDelete, _isMerge, _parentId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index ae1211cc..9938c488 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -2,34 +2,23 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects -import java.util.Optional class ProjectLogInsertParams constructor( private val projectId: String, - private val events: List, + private val events: List, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -37,7 +26,7 @@ constructor( fun projectId(): String = projectId - fun events(): List = events + fun events(): List = events @JvmSynthetic internal fun getBody(): ProjectLogInsertBody { @@ -59,12 +48,12 @@ constructor( @NoAutoDetect class ProjectLogInsertBody internal constructor( - private val events: List?, + private val events: List?, private val additionalProperties: Map, ) { /** A list of project logs events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -79,7 +68,7 @@ constructor( class Builder { - private var events: List? = null + private var events: List? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -89,7 +78,8 @@ constructor( } /** A list of project logs events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { this.events = events } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -165,7 +155,7 @@ constructor( class Builder { private var projectId: String? = null - private var events: MutableList = mutableListOf() + private var events: MutableList = mutableListOf() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -183,13 +173,13 @@ constructor( fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs events to insert */ - fun events(events: List) = apply { + fun events(events: List) = apply { this.events.clear() this.events.addAll(events) } /** A list of project logs events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: InsertProjectLogsEvent) = apply { this.events.add(event) } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -320,146 +310,4 @@ constructor( additionalBodyProperties.toImmutable(), ) } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, - private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertProjectLogsEventReplace(): Optional = - Optional.ofNullable(insertProjectLogsEventReplace) - - fun insertProjectLogsEventMerge(): Optional = - Optional.ofNullable(insertProjectLogsEventMerge) - - fun isInsertProjectLogsEventReplace(): Boolean = insertProjectLogsEventReplace != null - - fun isInsertProjectLogsEventMerge(): Boolean = insertProjectLogsEventMerge != null - - fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = - insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") - - fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = - insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - insertProjectLogsEventReplace != null -> - visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) - insertProjectLogsEventMerge != null -> - visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertProjectLogsEventReplace?.validate() - insertProjectLogsEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Event && this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) /* spotless:on */ - } - - override fun toString(): String { - return when { - insertProjectLogsEventReplace != null -> - "Event{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" - insertProjectLogsEventMerge != null -> - "Event{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - @JvmStatic - fun ofInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ) = Event(insertProjectLogsEventReplace = insertProjectLogsEventReplace) - - @JvmStatic - fun ofInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ) = Event(insertProjectLogsEventMerge = insertProjectLogsEventMerge) - } - - interface Visitor { - - fun visitInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ): T - - fun visitInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertProjectLogsEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertProjectLogsEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertProjectLogsEventReplace != null -> - generator.writeObject(value.insertProjectLogsEventReplace) - value.insertProjectLogsEventMerge != null -> - generator.writeObject(value.insertProjectLogsEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 08cd1ead..66972205 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -150,7 +150,7 @@ private constructor( fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** The `span_id` of the root of the trace this project logs event belongs to */ + /** A unique identifier for the trace this project logs event belongs to */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** Whether this span is a root span */ @@ -263,7 +263,7 @@ private constructor( */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents - /** The `span_id` of the root of the trace this project logs event belongs to */ + /** A unique identifier for the trace this project logs event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId /** Whether this span is a root span */ @@ -577,10 +577,10 @@ private constructor( this.spanParents = spanParents } - /** The `span_id` of the root of the trace this project logs event belongs to */ + /** A unique identifier for the trace this project logs event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** The `span_id` of the root of the trace this project logs event belongs to */ + /** A unique identifier for the trace this project logs event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } @@ -1538,202 +1538,6 @@ private constructor( override fun toString() = "Scores{additionalProperties=$additionalProperties}" } - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Name of the span, for display purposes only */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** Type of the span, for display purposes only */ - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val LLM = Type(JsonField.of("llm")) - - @JvmField val SCORE = Type(JsonField.of("score")) - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmField val EVAL = Type(JsonField.of("eval")) - - @JvmField val TASK = Type(JsonField.of("task")) - - @JvmField val TOOL = Type(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - 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 - } - - 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") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index d7dd2178..539d5a13 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -33,7 +33,7 @@ import java.util.Optional class PromptData private constructor( private val prompt: JsonField, - private val options: JsonField, + private val options: JsonField, private val parser: JsonField, private val toolFunctions: JsonField>, private val origin: JsonField, @@ -44,7 +44,7 @@ private constructor( fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - fun options(): Optional = Optional.ofNullable(options.getNullable("options")) + fun options(): Optional = Optional.ofNullable(options.getNullable("options")) fun parser(): Optional = Optional.ofNullable(parser.getNullable("parser")) @@ -88,7 +88,7 @@ private constructor( class Builder { private var prompt: JsonField = JsonMissing.of() - private var options: JsonField = JsonMissing.of() + private var options: JsonField = JsonMissing.of() private var parser: JsonField = JsonMissing.of() private var toolFunctions: JsonField> = JsonMissing.of() private var origin: JsonField = JsonMissing.of() @@ -110,11 +110,11 @@ private constructor( @ExcludeMissing fun prompt(prompt: JsonField) = apply { this.prompt = prompt } - fun options(options: Options) = options(JsonField.of(options)) + fun options(options: PromptOptions) = options(JsonField.of(options)) @JsonProperty("options") @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = apply { this.options = options } fun parser(parser: Parser) = parser(JsonField.of(parser)) @@ -162,3018 +162,6 @@ private constructor( ) } - @JsonDeserialize(builder = Options.Builder::class) - @NoAutoDetect - class Options - private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - - fun params(): Optional = Optional.ofNullable(params.getNullable("params")) - - fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - - @JsonProperty("model") @ExcludeMissing fun _model() = model - - @JsonProperty("params") @ExcludeMissing fun _params() = params - - @JsonProperty("position") @ExcludeMissing fun _position() = position - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Options = apply { - if (!validated) { - model() - params() - position() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var model: JsonField = JsonMissing.of() - private var params: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - this.model = options.model - this.params = options.params - this.position = options.position - additionalProperties(options.additionalProperties) - } - - fun model(model: String) = model(JsonField.of(model)) - - @JsonProperty("model") - @ExcludeMissing - fun model(model: JsonField) = apply { this.model = model } - - fun params(params: Params) = params(JsonField.of(params)) - - @JsonProperty("params") - @ExcludeMissing - fun params(params: JsonField) = apply { this.params = params } - - fun position(position: String) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Options = - Options( - model, - params, - position, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Params.Deserializer::class) - @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( - private val openaiModelParams: OpenAIModelParams? = null, - private val anthropicModelParams: AnthropicModelParams? = null, - private val googleModelParams: GoogleModelParams? = null, - private val windowAiModelParams: WindowAiModelParams? = null, - private val jsCompletionParams: JsCompletionParams? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun openaiModelParams(): Optional = - Optional.ofNullable(openaiModelParams) - - fun anthropicModelParams(): Optional = - Optional.ofNullable(anthropicModelParams) - - fun googleModelParams(): Optional = - Optional.ofNullable(googleModelParams) - - fun windowAiModelParams(): Optional = - Optional.ofNullable(windowAiModelParams) - - fun jsCompletionParams(): Optional = - Optional.ofNullable(jsCompletionParams) - - fun isOpenAIModelParams(): Boolean = openaiModelParams != null - - fun isAnthropicModelParams(): Boolean = anthropicModelParams != null - - fun isGoogleModelParams(): Boolean = googleModelParams != null - - fun isWindowAiModelParams(): Boolean = windowAiModelParams != null - - fun isJsCompletionParams(): Boolean = jsCompletionParams != null - - fun asOpenAIModelParams(): OpenAIModelParams = - openaiModelParams.getOrThrow("openaiModelParams") - - fun asAnthropicModelParams(): AnthropicModelParams = - anthropicModelParams.getOrThrow("anthropicModelParams") - - fun asGoogleModelParams(): GoogleModelParams = - googleModelParams.getOrThrow("googleModelParams") - - fun asWindowAiModelParams(): WindowAiModelParams = - windowAiModelParams.getOrThrow("windowAiModelParams") - - fun asJsCompletionParams(): JsCompletionParams = - jsCompletionParams.getOrThrow("jsCompletionParams") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - openaiModelParams != null -> visitor.visitOpenAIModelParams(openaiModelParams) - anthropicModelParams != null -> - visitor.visitAnthropicModelParams(anthropicModelParams) - googleModelParams != null -> visitor.visitGoogleModelParams(googleModelParams) - windowAiModelParams != null -> - visitor.visitWindowAiModelParams(windowAiModelParams) - jsCompletionParams != null -> - visitor.visitJsCompletionParams(jsCompletionParams) - else -> visitor.unknown(_json) - } - } - - fun validate(): Params = apply { - if (!validated) { - if ( - openaiModelParams == null && - anthropicModelParams == null && - googleModelParams == null && - windowAiModelParams == null && - jsCompletionParams == null - ) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - openaiModelParams?.validate() - anthropicModelParams?.validate() - googleModelParams?.validate() - windowAiModelParams?.validate() - jsCompletionParams?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Params && this.openaiModelParams == other.openaiModelParams && this.anthropicModelParams == other.anthropicModelParams && this.googleModelParams == other.googleModelParams && this.windowAiModelParams == other.windowAiModelParams && this.jsCompletionParams == other.jsCompletionParams /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(openaiModelParams, anthropicModelParams, googleModelParams, windowAiModelParams, jsCompletionParams) /* spotless:on */ - } - - override fun toString(): String { - return when { - openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" - anthropicModelParams != null -> - "Params{anthropicModelParams=$anthropicModelParams}" - googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" - windowAiModelParams != null -> - "Params{windowAiModelParams=$windowAiModelParams}" - jsCompletionParams != null -> "Params{jsCompletionParams=$jsCompletionParams}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } - } - - companion object { - - @JvmStatic - fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = - Params(openaiModelParams = openaiModelParams) - - @JvmStatic - fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = - Params(anthropicModelParams = anthropicModelParams) - - @JvmStatic - fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = - Params(googleModelParams = googleModelParams) - - @JvmStatic - fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = - Params(windowAiModelParams = windowAiModelParams) - - @JvmStatic - fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = - Params(jsCompletionParams = jsCompletionParams) - } - - interface Visitor { - - fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T - - fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T - - fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T - - fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T - - fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") - } - } - - class Deserializer : BaseDeserializer(Params::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(openaiModelParams = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(anthropicModelParams = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(googleModelParams = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(windowAiModelParams = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(jsCompletionParams = it, _json = json) - } - - return Params(_json = json) - } - } - - class Serializer : BaseSerializer(Params::class) { - - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.openaiModelParams != null -> - generator.writeObject(value.openaiModelParams) - value.anthropicModelParams != null -> - generator.writeObject(value.anthropicModelParams) - value.googleModelParams != null -> - generator.writeObject(value.googleModelParams) - value.windowAiModelParams != null -> - generator.writeObject(value.windowAiModelParams) - value.jsCompletionParams != null -> - generator.writeObject(value.jsCompletionParams) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } - } - } - - @JsonDeserialize(builder = OpenAIModelParams.Builder::class) - @NoAutoDetect - class OpenAIModelParams - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun maxTokens(): Optional = - Optional.ofNullable(maxTokens.getNullable("max_tokens")) - - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - - fun presencePenalty(): Optional = - Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - - fun responseFormat(): Optional = - Optional.ofNullable(responseFormat.getNullable("response_format")) - - fun toolChoice(): Optional = - Optional.ofNullable(toolChoice.getNullable("tool_choice")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun _frequencyPenalty() = frequencyPenalty - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun _presencePenalty() = presencePenalty - - @JsonProperty("response_format") - @ExcludeMissing - fun _responseFormat() = responseFormat - - @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice - - @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - - @JsonProperty("n") @ExcludeMissing fun _n() = n - - @JsonProperty("stop") @ExcludeMissing fun _stop() = stop - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): OpenAIModelParams = apply { - if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat() - toolChoice() - functionCall() - n() - stop() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var frequencyPenalty: JsonField = JsonMissing.of() - private var presencePenalty: JsonField = JsonMissing.of() - private var responseFormat: JsonField = JsonMissing.of() - private var toolChoice: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var n: JsonField = JsonMissing.of() - private var stop: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(openaiModelParams: OpenAIModelParams) = apply { - this.useCache = openaiModelParams.useCache - this.temperature = openaiModelParams.temperature - this.topP = openaiModelParams.topP - this.maxTokens = openaiModelParams.maxTokens - this.frequencyPenalty = openaiModelParams.frequencyPenalty - this.presencePenalty = openaiModelParams.presencePenalty - this.responseFormat = openaiModelParams.responseFormat - this.toolChoice = openaiModelParams.toolChoice - this.functionCall = openaiModelParams.functionCall - this.n = openaiModelParams.n - this.stop = openaiModelParams.stop - additionalProperties(openaiModelParams.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) - - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } - - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) - - @JsonProperty("presence_penalty") - @ExcludeMissing - fun presencePenalty(presencePenalty: JsonField) = apply { - this.presencePenalty = presencePenalty - } - - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) - - @JsonProperty("response_format") - @ExcludeMissing - fun responseFormat(responseFormat: JsonField) = apply { - this.responseFormat = responseFormat - } - - fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) - - @JsonProperty("tool_choice") - @ExcludeMissing - fun toolChoice(toolChoice: JsonField) = apply { - this.toolChoice = toolChoice - } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun n(n: Double) = n(JsonField.of(n)) - - @JsonProperty("n") - @ExcludeMissing - fun n(n: JsonField) = apply { this.n = n } - - fun stop(stop: List) = stop(JsonField.of(stop)) - - @JsonProperty("stop") - @ExcludeMissing - fun stop(stop: JsonField>) = apply { this.stop = stop } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): OpenAIModelParams = - OpenAIModelParams( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = FunctionCall.Deserializer::class) - @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( - private val auto: Auto? = null, - private val none: None? = null, - private val function: Function? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun auto(): Optional = Optional.ofNullable(auto) - - fun none(): Optional = Optional.ofNullable(none) - - fun function(): Optional = Optional.ofNullable(function) - - fun isAuto(): Boolean = auto != null - - fun isNone(): Boolean = none != null - - fun isFunction(): Boolean = function != null - - fun asAuto(): Auto = auto.getOrThrow("auto") - - fun asNone(): None = none.getOrThrow("none") - - fun asFunction(): Function = function.getOrThrow("function") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - auto != null -> visitor.visitAuto(auto) - none != null -> visitor.visitNone(none) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } - } - - fun validate(): FunctionCall = apply { - if (!validated) { - if (auto == null && none == null && function == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - function?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionCall && this.auto == other.auto && this.none == other.none && this.function == other.function /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(auto, none, function) /* spotless:on */ - } - - override fun toString(): String { - return when { - auto != null -> "FunctionCall{auto=$auto}" - none != null -> "FunctionCall{none=$none}" - function != null -> "FunctionCall{function=$function}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - - companion object { - - @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - - @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) - - @JvmStatic - fun ofFunction(function: Function) = FunctionCall(function = function) - } - - interface Visitor { - - fun visitAuto(auto: Auto): T - - fun visitNone(none: None): T - - fun visitFunction(function: Function): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") - } - } - - class Deserializer : BaseDeserializer(FunctionCall::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(auto = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(none = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(function = it, _json = json) - } - - return FunctionCall(_json = json) - } - } - - class Serializer : BaseSerializer(FunctionCall::class) { - - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.auto != null -> generator.writeObject(value.auto) - value.none != null -> generator.writeObject(value.none) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } - } - } - - class Auto - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Auto(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) - } - - enum class Known { - AUTO, - } - - enum class Value { - AUTO, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown Auto: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class None - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = None(JsonField.of("none")) - - @JvmStatic fun of(value: String) = None(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown None: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Function = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Function = - Function(name, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Function && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - } - } - - @JsonDeserialize(using = ResponseFormat.Deserializer::class) - @JsonSerialize(using = ResponseFormat.Serializer::class) - class ResponseFormat - private constructor( - private val jsonObject: JsonObject? = null, - private val jsonSchema: JsonSchema? = null, - private val text: Text? = null, - private val nullableVariant: NullableVariant? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun jsonObject(): Optional = Optional.ofNullable(jsonObject) - - fun jsonSchema(): Optional = Optional.ofNullable(jsonSchema) - - fun text(): Optional = Optional.ofNullable(text) - - fun nullableVariant(): Optional = - Optional.ofNullable(nullableVariant) - - fun isJsonObject(): Boolean = jsonObject != null - - fun isJsonSchema(): Boolean = jsonSchema != null - - fun isText(): Boolean = text != null - - fun isNullableVariant(): Boolean = nullableVariant != null - - fun asJsonObject(): JsonObject = jsonObject.getOrThrow("jsonObject") - - fun asJsonSchema(): JsonSchema = jsonSchema.getOrThrow("jsonSchema") - - fun asText(): Text = text.getOrThrow("text") - - fun asNullableVariant(): NullableVariant = - nullableVariant.getOrThrow("nullableVariant") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - jsonObject != null -> visitor.visitJsonObject(jsonObject) - jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) - text != null -> visitor.visitText(text) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } - } - - fun validate(): ResponseFormat = apply { - if (!validated) { - if ( - jsonObject == null && - jsonSchema == null && - text == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException( - "Unknown ResponseFormat: $_json" - ) - } - jsonObject?.validate() - jsonSchema?.validate() - text?.validate() - nullableVariant?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ResponseFormat && this.jsonObject == other.jsonObject && this.jsonSchema == other.jsonSchema && this.text == other.text && this.nullableVariant == other.nullableVariant /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ - } - - override fun toString(): String { - return when { - jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" - jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" - text != null -> "ResponseFormat{text=$text}" - nullableVariant != null -> - "ResponseFormat{nullableVariant=$nullableVariant}" - _json != null -> "ResponseFormat{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ResponseFormat") - } - } - - companion object { - - @JvmStatic - fun ofJsonObject(jsonObject: JsonObject) = - ResponseFormat(jsonObject = jsonObject) - - @JvmStatic - fun ofJsonSchema(jsonSchema: JsonSchema) = - ResponseFormat(jsonSchema = jsonSchema) - - @JvmStatic fun ofText(text: Text) = ResponseFormat(text = text) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - ResponseFormat(nullableVariant = nullableVariant) - } - - interface Visitor { - - fun visitJsonObject(jsonObject: JsonObject): T - - fun visitJsonSchema(jsonSchema: JsonSchema): T - - fun visitText(text: Text): T - - fun visitNullableVariant(nullableVariant: NullableVariant): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") - } - } - - class Deserializer : BaseDeserializer(ResponseFormat::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ResponseFormat { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(jsonObject = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(jsonSchema = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ResponseFormat(nullableVariant = it, _json = json) - } - - return ResponseFormat(_json = json) - } - } - - class Serializer : BaseSerializer(ResponseFormat::class) { - - override fun serialize( - value: ResponseFormat, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.jsonObject != null -> generator.writeObject(value.jsonObject) - value.jsonSchema != null -> generator.writeObject(value.jsonSchema) - value.text != null -> generator.writeObject(value.text) - value.nullableVariant != null -> - generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ResponseFormat") - } - } - } - - @JsonDeserialize(builder = JsonObject.Builder::class) - @NoAutoDetect - class JsonObject - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): JsonObject = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(jsonObject: JsonObject) = apply { - this.type = jsonObject.type - additionalProperties(jsonObject.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): JsonObject = - JsonObject(type, additionalProperties.toImmutable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - JSON_OBJECT, - } - - enum class Value { - JSON_OBJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is JsonObject && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "JsonObject{type=$type, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = JsonSchema.Builder::class) - @NoAutoDetect - class JsonSchema - private constructor( - private val type: JsonField, - private val jsonSchema: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") - - fun jsonSchema(): JsonSchema = jsonSchema.getRequired("json_schema") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("json_schema") @ExcludeMissing fun _jsonSchema() = jsonSchema - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): JsonSchema = apply { - if (!validated) { - type() - jsonSchema().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var jsonSchema: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(jsonSchema: JsonSchema) = apply { - this.type = jsonSchema.type - this.jsonSchema = jsonSchema.jsonSchema - additionalProperties(jsonSchema.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun jsonSchema(jsonSchema: JsonSchema) = - jsonSchema(JsonField.of(jsonSchema)) - - @JsonProperty("json_schema") - @ExcludeMissing - fun jsonSchema(jsonSchema: JsonField) = apply { - this.jsonSchema = jsonSchema - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): JsonSchema = - JsonSchema( - type, - jsonSchema, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = JsonSchema.Builder::class) - @NoAutoDetect - class JsonSchema - private constructor( - private val name: JsonField, - private val description: JsonField, - private val schema: JsonField, - private val strict: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun name(): String = name.getRequired("name") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun schema(): Optional = - Optional.ofNullable(schema.getNullable("schema")) - - fun strict(): Optional = - Optional.ofNullable(strict.getNullable("strict")) - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("description") - @ExcludeMissing - fun _description() = description - - @JsonProperty("schema") @ExcludeMissing fun _schema() = schema - - @JsonProperty("strict") @ExcludeMissing fun _strict() = strict - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): JsonSchema = apply { - if (!validated) { - name() - description() - schema().map { it.validate() } - strict() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var schema: JsonField = JsonMissing.of() - private var strict: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(jsonSchema: JsonSchema) = apply { - this.name = jsonSchema.name - this.description = jsonSchema.description - this.schema = jsonSchema.schema - this.strict = jsonSchema.strict - additionalProperties(jsonSchema.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun description(description: String) = - description(JsonField.of(description)) - - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - fun schema(schema: Schema) = schema(JsonField.of(schema)) - - @JsonProperty("schema") - @ExcludeMissing - fun schema(schema: JsonField) = apply { - this.schema = schema - } - - fun strict(strict: Boolean) = strict(JsonField.of(strict)) - - @JsonProperty("strict") - @ExcludeMissing - fun strict(strict: JsonField) = apply { - this.strict = strict - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): JsonSchema = - JsonSchema( - name, - description, - schema, - strict, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Schema.Builder::class) - @NoAutoDetect - class Schema - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Schema = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(schema: Schema) = apply { - additionalProperties(schema.additionalProperties) - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Schema = Schema(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Schema && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Schema{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is JsonSchema && this.name == other.name && this.description == other.description && this.schema == other.schema && this.strict == other.strict && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, description, schema, strict, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "JsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val JSON_SCHEMA = Type(JsonField.of("json_schema")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - JSON_SCHEMA, - } - - enum class Value { - JSON_SCHEMA, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - JSON_SCHEMA -> Value.JSON_SCHEMA - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - JSON_SCHEMA -> Known.JSON_SCHEMA - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is JsonSchema && this.type == other.type && this.jsonSchema == other.jsonSchema && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, jsonSchema, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "JsonSchema{type=$type, jsonSchema=$jsonSchema, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Text.Builder::class) - @NoAutoDetect - class Text - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Text = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(text: Text) = apply { - this.type = text.type - additionalProperties(text.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Text = Text(type, additionalProperties.toImmutable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TEXT = Type(JsonField.of("text")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - TEXT, - } - - enum class Value { - TEXT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Text && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Text{type=$type, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = NullableVariant.Builder::class) - @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): NullableVariant = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): NullableVariant = - NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "NullableVariant{additionalProperties=$additionalProperties}" - } - } - - @JsonDeserialize(using = ToolChoice.Deserializer::class) - @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( - private val auto: Auto? = null, - private val none: None? = null, - private val required: Required? = null, - private val function: Function? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun auto(): Optional = Optional.ofNullable(auto) - - fun none(): Optional = Optional.ofNullable(none) - - fun required(): Optional = Optional.ofNullable(required) - - fun function(): Optional = Optional.ofNullable(function) - - fun isAuto(): Boolean = auto != null - - fun isNone(): Boolean = none != null - - fun isRequired(): Boolean = required != null - - fun isFunction(): Boolean = function != null - - fun asAuto(): Auto = auto.getOrThrow("auto") - - fun asNone(): None = none.getOrThrow("none") - - fun asRequired(): Required = required.getOrThrow("required") - - fun asFunction(): Function = function.getOrThrow("function") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - auto != null -> visitor.visitAuto(auto) - none != null -> visitor.visitNone(none) - required != null -> visitor.visitRequired(required) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } - } - - fun validate(): ToolChoice = apply { - if (!validated) { - if ( - auto == null && none == null && required == null && function == null - ) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - function?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ToolChoice && this.auto == other.auto && this.none == other.none && this.required == other.required && this.function == other.function /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(auto, none, required, function) /* spotless:on */ - } - - override fun toString(): String { - return when { - auto != null -> "ToolChoice{auto=$auto}" - none != null -> "ToolChoice{none=$none}" - required != null -> "ToolChoice{required=$required}" - function != null -> "ToolChoice{function=$function}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - - companion object { - - @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - - @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) - - @JvmStatic - fun ofRequired(required: Required) = ToolChoice(required = required) - - @JvmStatic - fun ofFunction(function: Function) = ToolChoice(function = function) - } - - interface Visitor { - - fun visitAuto(auto: Auto): T - - fun visitNone(none: None): T - - fun visitRequired(required: Required): T - - fun visitFunction(function: Function): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") - } - } - - class Deserializer : BaseDeserializer(ToolChoice::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(auto = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(none = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(required = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolChoice(function = it, _json = json) - } - - return ToolChoice(_json = json) - } - } - - class Serializer : BaseSerializer(ToolChoice::class) { - - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.auto != null -> generator.writeObject(value.auto) - value.none != null -> generator.writeObject(value.none) - value.required != null -> generator.writeObject(value.required) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } - } - } - - class Auto - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val AUTO = Auto(JsonField.of("auto")) - - @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) - } - - enum class Known { - AUTO, - } - - enum class Value { - AUTO, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown Auto: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class None - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = None(JsonField.of("none")) - - @JvmStatic fun of(value: String) = None(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown None: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class Required - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Required && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val REQUIRED = Required(JsonField.of("required")) - - @JvmStatic fun of(value: String) = Required(JsonField.of(value)) - } - - enum class Known { - REQUIRED, - } - - enum class Value { - REQUIRED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - REQUIRED -> Value.REQUIRED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - REQUIRED -> Known.REQUIRED - else -> - throw BraintrustInvalidDataException("Unknown Required: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") - - fun function(): Function = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("function") @ExcludeMissing fun _function() = function - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Function = apply { - if (!validated) { - type() - function().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.type = function.type - this.function = function.function - additionalProperties(function.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: Function) = function(JsonField.of(function)) - - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { - this.function = function - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Function = - Function( - type, - function, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun name(): String = name.getRequired("name") - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Function = apply { - if (!validated) { - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Function = - Function(name, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Function && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Type(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Function && this.type == other.type && this.function == other.function && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, function, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OpenAIModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.topP == other.topP && this.maxTokens == other.maxTokens && this.frequencyPenalty == other.frequencyPenalty && this.presencePenalty == other.presencePenalty && this.responseFormat == other.responseFormat && this.toolChoice == other.toolChoice && this.functionCall == other.functionCall && this.n == other.n && this.stop == other.stop && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, temperature, topP, maxTokens, frequencyPenalty, presencePenalty, responseFormat, toolChoice, functionCall, n, stop, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = AnthropicModelParams.Builder::class) - @NoAutoDetect - class AnthropicModelParams - private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun maxTokens(): Double = maxTokens.getRequired("max_tokens") - - fun temperature(): Double = temperature.getRequired("temperature") - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = - Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP - - @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK - - @JsonProperty("stop_sequences") @ExcludeMissing fun _stopSequences() = stopSequences - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun _maxTokensToSample() = maxTokensToSample - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): AnthropicModelParams = apply { - if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var stopSequences: JsonField> = JsonMissing.of() - private var maxTokensToSample: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(anthropicModelParams: AnthropicModelParams) = apply { - this.useCache = anthropicModelParams.useCache - this.maxTokens = anthropicModelParams.maxTokens - this.temperature = anthropicModelParams.temperature - this.topP = anthropicModelParams.topP - this.topK = anthropicModelParams.topK - this.stopSequences = anthropicModelParams.stopSequences - this.maxTokensToSample = anthropicModelParams.maxTokensToSample - additionalProperties(anthropicModelParams.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - - @JsonProperty("max_tokens") - @ExcludeMissing - fun maxTokens(maxTokens: JsonField) = apply { - this.maxTokens = maxTokens - } - - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("top_k") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) - - @JsonProperty("stop_sequences") - @ExcludeMissing - fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences - } - - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): AnthropicModelParams = - AnthropicModelParams( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toImmutable() }, - maxTokensToSample, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AnthropicModelParams && this.useCache == other.useCache && this.maxTokens == other.maxTokens && this.temperature == other.temperature && this.topP == other.topP && this.topK == other.topK && this.stopSequences == other.stopSequences && this.maxTokensToSample == other.maxTokensToSample && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, maxTokens, temperature, topP, topK, stopSequences, maxTokensToSample, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = GoogleModelParams.Builder::class) - @NoAutoDetect - class GoogleModelParams - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - - fun maxOutputTokens(): Optional = - Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - - fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun _maxOutputTokens() = maxOutputTokens - - @JsonProperty("topP") @ExcludeMissing fun _topP() = topP - - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GoogleModelParams = apply { - if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var maxOutputTokens: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(googleModelParams: GoogleModelParams) = apply { - this.useCache = googleModelParams.useCache - this.temperature = googleModelParams.temperature - this.maxOutputTokens = googleModelParams.maxOutputTokens - this.topP = googleModelParams.topP - this.topK = googleModelParams.topK - additionalProperties(googleModelParams.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) - - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } - - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("topP") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("topK") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GoogleModelParams = - GoogleModelParams( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GoogleModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.maxOutputTokens == other.maxOutputTokens && this.topP == other.topP && this.topK == other.topK && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, temperature, maxOutputTokens, topP, topK, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = WindowAiModelParams.Builder::class) - @NoAutoDetect - class WindowAiModelParams - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature - - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): WindowAiModelParams = apply { - if (!validated) { - useCache() - temperature() - topK() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(windowAiModelParams: WindowAiModelParams) = apply { - this.useCache = windowAiModelParams.useCache - this.temperature = windowAiModelParams.temperature - this.topK = windowAiModelParams.topK - additionalProperties(windowAiModelParams.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } - - fun topK(topK: Double) = topK(JsonField.of(topK)) - - @JsonProperty("topK") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): WindowAiModelParams = - WindowAiModelParams( - useCache, - temperature, - topK, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is WindowAiModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.topK == other.topK && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, temperature, topK, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = JsCompletionParams.Builder::class) - @NoAutoDetect - class JsCompletionParams - private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): JsCompletionParams = apply { - if (!validated) { - useCache() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var useCache: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(jsCompletionParams: JsCompletionParams) = apply { - this.useCache = jsCompletionParams.useCache - additionalProperties(jsCompletionParams.additionalProperties) - } - - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): JsCompletionParams = - JsCompletionParams(useCache, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is JsCompletionParams && this.useCache == other.useCache && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Options && this.model == other.model && this.params == other.params && this.position == other.position && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(model, params, position, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" - } - @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect class Origin diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt new file mode 100644 index 00000000..834e7427 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -0,0 +1,3004 @@ +// File generated from our OpenAPI spec by Stainless. + +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 +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +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 +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = PromptOptions.Builder::class) +@NoAutoDetect +class PromptOptions +private constructor( + private val model: JsonField, + private val params: JsonField, + private val position: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + fun params(): Optional = Optional.ofNullable(params.getNullable("params")) + + fun position(): Optional = Optional.ofNullable(position.getNullable("position")) + + @JsonProperty("model") @ExcludeMissing fun _model() = model + + @JsonProperty("params") @ExcludeMissing fun _params() = params + + @JsonProperty("position") @ExcludeMissing fun _position() = position + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PromptOptions = apply { + if (!validated) { + model() + params() + position() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var model: JsonField = JsonMissing.of() + private var params: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(promptOptions: PromptOptions) = apply { + this.model = promptOptions.model + this.params = promptOptions.params + this.position = promptOptions.position + additionalProperties(promptOptions.additionalProperties) + } + + fun model(model: String) = model(JsonField.of(model)) + + @JsonProperty("model") + @ExcludeMissing + fun model(model: JsonField) = apply { this.model = model } + + fun params(params: Params) = params(JsonField.of(params)) + + @JsonProperty("params") + @ExcludeMissing + fun params(params: JsonField) = apply { this.params = params } + + fun position(position: String) = position(JsonField.of(position)) + + @JsonProperty("position") + @ExcludeMissing + fun position(position: JsonField) = apply { this.position = position } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PromptOptions = + PromptOptions( + model, + params, + position, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Params.Deserializer::class) + @JsonSerialize(using = Params.Serializer::class) + class Params + private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun openaiModelParams(): Optional = + Optional.ofNullable(openaiModelParams) + + fun anthropicModelParams(): Optional = + Optional.ofNullable(anthropicModelParams) + + fun googleModelParams(): Optional = + Optional.ofNullable(googleModelParams) + + fun windowAiModelParams(): Optional = + Optional.ofNullable(windowAiModelParams) + + fun jsCompletionParams(): Optional = + Optional.ofNullable(jsCompletionParams) + + fun isOpenAIModelParams(): Boolean = openaiModelParams != null + + fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + + fun isGoogleModelParams(): Boolean = googleModelParams != null + + fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + + fun isJsCompletionParams(): Boolean = jsCompletionParams != null + + fun asOpenAIModelParams(): OpenAIModelParams = + openaiModelParams.getOrThrow("openaiModelParams") + + fun asAnthropicModelParams(): AnthropicModelParams = + anthropicModelParams.getOrThrow("anthropicModelParams") + + fun asGoogleModelParams(): GoogleModelParams = + googleModelParams.getOrThrow("googleModelParams") + + fun asWindowAiModelParams(): WindowAiModelParams = + windowAiModelParams.getOrThrow("windowAiModelParams") + + fun asJsCompletionParams(): JsCompletionParams = + jsCompletionParams.getOrThrow("jsCompletionParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + openaiModelParams != null -> visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> + visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): Params = apply { + if (!validated) { + if ( + openaiModelParams == null && + anthropicModelParams == null && + googleModelParams == null && + windowAiModelParams == null && + jsCompletionParams == null + ) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Params && this.openaiModelParams == other.openaiModelParams && this.anthropicModelParams == other.anthropicModelParams && this.googleModelParams == other.googleModelParams && this.windowAiModelParams == other.windowAiModelParams && this.jsCompletionParams == other.jsCompletionParams /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(openaiModelParams, anthropicModelParams, googleModelParams, windowAiModelParams, jsCompletionParams) /* spotless:on */ + } + + override fun toString(): String { + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } + } + + companion object { + + @JvmStatic + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = + Params(openaiModelParams = openaiModelParams) + + @JvmStatic + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = + Params(anthropicModelParams = anthropicModelParams) + + @JvmStatic + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = + Params(googleModelParams = googleModelParams) + + @JvmStatic + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = + Params(windowAiModelParams = windowAiModelParams) + + @JvmStatic + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = + Params(jsCompletionParams = jsCompletionParams) + } + + interface Visitor { + + fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T + + fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T + + fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T + + fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T + + fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Params: $json") + } + } + + class Deserializer : BaseDeserializer(Params::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Params { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) + } + } + + class Serializer : BaseSerializer(Params::class) { + + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.openaiModelParams != null -> + generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> + generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> + generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> + generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> + generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } + } + } + + @JsonDeserialize(builder = OpenAIModelParams.Builder::class) + @NoAutoDetect + class OpenAIModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) + + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) + + fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) + + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) + + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) + + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) + + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) + + fun n(): Optional = Optional.ofNullable(n.getNullable("n")) + + fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP + + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens + + @JsonProperty("frequency_penalty") + @ExcludeMissing + fun _frequencyPenalty() = frequencyPenalty + + @JsonProperty("presence_penalty") + @ExcludeMissing + fun _presencePenalty() = presencePenalty + + @JsonProperty("response_format") @ExcludeMissing fun _responseFormat() = responseFormat + + @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice + + @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall + + @JsonProperty("n") @ExcludeMissing fun _n() = n + + @JsonProperty("stop") @ExcludeMissing fun _stop() = stop + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): OpenAIModelParams = apply { + if (!validated) { + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat() + toolChoice() + functionCall() + n() + stop() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var useCache: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var maxTokens: JsonField = JsonMissing.of() + private var frequencyPenalty: JsonField = JsonMissing.of() + private var presencePenalty: JsonField = JsonMissing.of() + private var responseFormat: JsonField = JsonMissing.of() + private var toolChoice: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var n: JsonField = JsonMissing.of() + private var stop: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + this.useCache = openaiModelParams.useCache + this.temperature = openaiModelParams.temperature + this.topP = openaiModelParams.topP + this.maxTokens = openaiModelParams.maxTokens + this.frequencyPenalty = openaiModelParams.frequencyPenalty + this.presencePenalty = openaiModelParams.presencePenalty + this.responseFormat = openaiModelParams.responseFormat + this.toolChoice = openaiModelParams.toolChoice + this.functionCall = openaiModelParams.functionCall + this.n = openaiModelParams.n + this.stop = openaiModelParams.stop + additionalProperties(openaiModelParams.additionalProperties) + } + + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + + @JsonProperty("use_cache") + @ExcludeMissing + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + + fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + + @JsonProperty("temperature") + @ExcludeMissing + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } + + fun topP(topP: Double) = topP(JsonField.of(topP)) + + @JsonProperty("top_p") + @ExcludeMissing + fun topP(topP: JsonField) = apply { this.topP = topP } + + fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) + + @JsonProperty("max_tokens") + @ExcludeMissing + fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) + + @JsonProperty("frequency_penalty") + @ExcludeMissing + fun frequencyPenalty(frequencyPenalty: JsonField) = apply { + this.frequencyPenalty = frequencyPenalty + } + + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) + + @JsonProperty("presence_penalty") + @ExcludeMissing + fun presencePenalty(presencePenalty: JsonField) = apply { + this.presencePenalty = presencePenalty + } + + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) + + @JsonProperty("response_format") + @ExcludeMissing + fun responseFormat(responseFormat: JsonField) = apply { + this.responseFormat = responseFormat + } + + fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + + @JsonProperty("tool_choice") + @ExcludeMissing + fun toolChoice(toolChoice: JsonField) = apply { + this.toolChoice = toolChoice + } + + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) + + @JsonProperty("function_call") + @ExcludeMissing + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + fun n(n: Double) = n(JsonField.of(n)) + + @JsonProperty("n") + @ExcludeMissing + fun n(n: JsonField) = apply { this.n = n } + + fun stop(stop: List) = stop(JsonField.of(stop)) + + @JsonProperty("stop") + @ExcludeMissing + fun stop(stop: JsonField>) = apply { this.stop = stop } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): OpenAIModelParams = + OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = FunctionCall.Deserializer::class) + @JsonSerialize(using = FunctionCall.Serializer::class) + class FunctionCall + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asFunction(): Function = function.getOrThrow("function") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } + } + + fun validate(): FunctionCall = apply { + if (!validated) { + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") + } + function?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionCall && this.auto == other.auto && this.none == other.none && this.function == other.function /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(auto, none, function) /* spotless:on */ + } + + override fun toString(): String { + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } + } + + companion object { + + @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) + + @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) + + @JvmStatic + fun ofFunction(function: Function) = FunctionCall(function = function) + } + + interface Visitor { + + fun visitAuto(auto: Auto): T + + fun visitNone(none: None): T + + fun visitFunction(function: Function): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + } + } + + class Deserializer : BaseDeserializer(FunctionCall::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } + + return FunctionCall(_json = json) + } + } + + class Serializer : BaseSerializer(FunctionCall::class) { + + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } + } + } + + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AUTO = Auto(JsonField.of("auto")) + + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) + } + + enum class Known { + AUTO, + } + + enum class Value { + AUTO, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> throw BraintrustInvalidDataException("Unknown Auto: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val NONE = None(JsonField.of("none")) + + @JvmStatic fun of(value: String) = None(JsonField.of(value)) + } + + enum class Known { + NONE, + } + + enum class Value { + NONE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> throw BraintrustInvalidDataException("Unknown None: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun name(): String = name.getRequired("name") + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Function = Function(name, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(using = ResponseFormat.Deserializer::class) + @JsonSerialize(using = ResponseFormat.Serializer::class) + class ResponseFormat + private constructor( + private val jsonObject: JsonObject? = null, + private val jsonSchema: JsonSchema? = null, + private val text: Text? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun jsonObject(): Optional = Optional.ofNullable(jsonObject) + + fun jsonSchema(): Optional = Optional.ofNullable(jsonSchema) + + fun text(): Optional = Optional.ofNullable(text) + + fun nullableVariant(): Optional = + Optional.ofNullable(nullableVariant) + + fun isJsonObject(): Boolean = jsonObject != null + + fun isJsonSchema(): Boolean = jsonSchema != null + + fun isText(): Boolean = text != null + + fun isNullableVariant(): Boolean = nullableVariant != null + + fun asJsonObject(): JsonObject = jsonObject.getOrThrow("jsonObject") + + fun asJsonSchema(): JsonSchema = jsonSchema.getOrThrow("jsonSchema") + + fun asText(): Text = text.getOrThrow("text") + + fun asNullableVariant(): NullableVariant = + nullableVariant.getOrThrow("nullableVariant") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + jsonObject != null -> visitor.visitJsonObject(jsonObject) + jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) + text != null -> visitor.visitText(text) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } + } + + fun validate(): ResponseFormat = apply { + if (!validated) { + if ( + jsonObject == null && + jsonSchema == null && + text == null && + nullableVariant == null + ) { + throw BraintrustInvalidDataException("Unknown ResponseFormat: $_json") + } + jsonObject?.validate() + jsonSchema?.validate() + text?.validate() + nullableVariant?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ResponseFormat && this.jsonObject == other.jsonObject && this.jsonSchema == other.jsonSchema && this.text == other.text && this.nullableVariant == other.nullableVariant /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ + } + + override fun toString(): String { + return when { + jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" + jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" + text != null -> "ResponseFormat{text=$text}" + nullableVariant != null -> + "ResponseFormat{nullableVariant=$nullableVariant}" + _json != null -> "ResponseFormat{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ResponseFormat") + } + } + + companion object { + + @JvmStatic + fun ofJsonObject(jsonObject: JsonObject) = + ResponseFormat(jsonObject = jsonObject) + + @JvmStatic + fun ofJsonSchema(jsonSchema: JsonSchema) = + ResponseFormat(jsonSchema = jsonSchema) + + @JvmStatic fun ofText(text: Text) = ResponseFormat(text = text) + + @JvmStatic + fun ofNullableVariant(nullableVariant: NullableVariant) = + ResponseFormat(nullableVariant = nullableVariant) + } + + interface Visitor { + + fun visitJsonObject(jsonObject: JsonObject): T + + fun visitJsonSchema(jsonSchema: JsonSchema): T + + fun visitText(text: Text): T + + fun visitNullableVariant(nullableVariant: NullableVariant): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") + } + } + + class Deserializer : BaseDeserializer(ResponseFormat::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ResponseFormat { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(jsonObject = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(jsonSchema = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(nullableVariant = it, _json = json) + } + + return ResponseFormat(_json = json) + } + } + + class Serializer : BaseSerializer(ResponseFormat::class) { + + override fun serialize( + value: ResponseFormat, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.jsonObject != null -> generator.writeObject(value.jsonObject) + value.jsonSchema != null -> generator.writeObject(value.jsonSchema) + value.text != null -> generator.writeObject(value.text) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ResponseFormat") + } + } + } + + @JsonDeserialize(builder = JsonObject.Builder::class) + @NoAutoDetect + class JsonObject + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): JsonObject = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(jsonObject: JsonObject) = apply { + this.type = jsonObject.type + additionalProperties(jsonObject.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): JsonObject = + JsonObject(type, additionalProperties.toImmutable()) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + JSON_OBJECT, + } + + enum class Value { + JSON_OBJECT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is JsonObject && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "JsonObject{type=$type, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = JsonSchema.Builder::class) + @NoAutoDetect + class JsonSchema + private constructor( + private val type: JsonField, + private val jsonSchema: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + fun jsonSchema(): JsonSchema = jsonSchema.getRequired("json_schema") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("json_schema") @ExcludeMissing fun _jsonSchema() = jsonSchema + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): JsonSchema = apply { + if (!validated) { + type() + jsonSchema().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var jsonSchema: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(jsonSchema: JsonSchema) = apply { + this.type = jsonSchema.type + this.jsonSchema = jsonSchema.jsonSchema + additionalProperties(jsonSchema.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun jsonSchema(jsonSchema: JsonSchema) = + jsonSchema(JsonField.of(jsonSchema)) + + @JsonProperty("json_schema") + @ExcludeMissing + fun jsonSchema(jsonSchema: JsonField) = apply { + this.jsonSchema = jsonSchema + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): JsonSchema = + JsonSchema( + type, + jsonSchema, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = JsonSchema.Builder::class) + @NoAutoDetect + class JsonSchema + private constructor( + private val name: JsonField, + private val description: JsonField, + private val schema: JsonField, + private val strict: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun name(): String = name.getRequired("name") + + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + fun schema(): Optional = + Optional.ofNullable(schema.getNullable("schema")) + + fun strict(): Optional = + Optional.ofNullable(strict.getNullable("strict")) + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("description") + @ExcludeMissing + fun _description() = description + + @JsonProperty("schema") @ExcludeMissing fun _schema() = schema + + @JsonProperty("strict") @ExcludeMissing fun _strict() = strict + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): JsonSchema = apply { + if (!validated) { + name() + description() + schema().map { it.validate() } + strict() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var schema: JsonField = JsonMissing.of() + private var strict: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(jsonSchema: JsonSchema) = apply { + this.name = jsonSchema.name + this.description = jsonSchema.description + this.schema = jsonSchema.schema + this.strict = jsonSchema.strict + additionalProperties(jsonSchema.additionalProperties) + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun description(description: String) = + description(JsonField.of(description)) + + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { + this.description = description + } + + fun schema(schema: Schema) = schema(JsonField.of(schema)) + + @JsonProperty("schema") + @ExcludeMissing + fun schema(schema: JsonField) = apply { this.schema = schema } + + fun strict(strict: Boolean) = strict(JsonField.of(strict)) + + @JsonProperty("strict") + @ExcludeMissing + fun strict(strict: JsonField) = apply { this.strict = strict } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): JsonSchema = + JsonSchema( + name, + description, + schema, + strict, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = Schema.Builder::class) + @NoAutoDetect + class Schema + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun validate(): Schema = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(schema: Schema) = apply { + additionalProperties(schema.additionalProperties) + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Schema = Schema(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schema && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Schema{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is JsonSchema && this.name == other.name && this.description == other.description && this.schema == other.schema && this.strict == other.strict && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, description, schema, strict, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "JsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val JSON_SCHEMA = Type(JsonField.of("json_schema")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + JSON_SCHEMA, + } + + enum class Value { + JSON_SCHEMA, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + JSON_SCHEMA -> Value.JSON_SCHEMA + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + JSON_SCHEMA -> Known.JSON_SCHEMA + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is JsonSchema && this.type == other.type && this.jsonSchema == other.jsonSchema && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, jsonSchema, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "JsonSchema{type=$type, jsonSchema=$jsonSchema, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Text.Builder::class) + @NoAutoDetect + class Text + private constructor( + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Text = apply { + if (!validated) { + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(text: Text) = apply { + this.type = text.type + additionalProperties(text.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Text = Text(type, additionalProperties.toImmutable()) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TEXT = Type(JsonField.of("text")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + TEXT, + } + + enum class Value { + TEXT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Text && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Text{type=$type, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = NullableVariant.Builder::class) + @NoAutoDetect + class NullableVariant + private constructor( + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): NullableVariant = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties(nullableVariant.additionalProperties) + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): NullableVariant = + NullableVariant(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" + } + } + + @JsonDeserialize(using = ToolChoice.Deserializer::class) + @JsonSerialize(using = ToolChoice.Serializer::class) + class ToolChoice + private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val required: Required? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun auto(): Optional = Optional.ofNullable(auto) + + fun none(): Optional = Optional.ofNullable(none) + + fun required(): Optional = Optional.ofNullable(required) + + fun function(): Optional = Optional.ofNullable(function) + + fun isAuto(): Boolean = auto != null + + fun isNone(): Boolean = none != null + + fun isRequired(): Boolean = required != null + + fun isFunction(): Boolean = function != null + + fun asAuto(): Auto = auto.getOrThrow("auto") + + fun asNone(): None = none.getOrThrow("none") + + fun asRequired(): Required = required.getOrThrow("required") + + fun asFunction(): Function = function.getOrThrow("function") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + required != null -> visitor.visitRequired(required) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } + } + + fun validate(): ToolChoice = apply { + if (!validated) { + if (auto == null && none == null && required == null && function == null) { + throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") + } + function?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ToolChoice && this.auto == other.auto && this.none == other.none && this.required == other.required && this.function == other.function /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(auto, none, required, function) /* spotless:on */ + } + + override fun toString(): String { + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + required != null -> "ToolChoice{required=$required}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } + } + + companion object { + + @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) + + @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) + + @JvmStatic fun ofRequired(required: Required) = ToolChoice(required = required) + + @JvmStatic fun ofFunction(function: Function) = ToolChoice(function = function) + } + + interface Visitor { + + fun visitAuto(auto: Auto): T + + fun visitNone(none: None): T + + fun visitRequired(required: Required): T + + fun visitFunction(function: Function): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + } + } + + class Deserializer : BaseDeserializer(ToolChoice::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(required = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } + + return ToolChoice(_json = json) + } + } + + class Serializer : BaseSerializer(ToolChoice::class) { + + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.required != null -> generator.writeObject(value.required) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } + } + } + + class Auto + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val AUTO = Auto(JsonField.of("auto")) + + @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) + } + + enum class Known { + AUTO, + } + + enum class Value { + AUTO, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + else -> throw BraintrustInvalidDataException("Unknown Auto: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class None + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val NONE = None(JsonField.of("none")) + + @JvmStatic fun of(value: String) = None(JsonField.of(value)) + } + + enum class Known { + NONE, + } + + enum class Value { + NONE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + NONE -> Known.NONE + else -> throw BraintrustInvalidDataException("Unknown None: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Required + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Required && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val REQUIRED = Required(JsonField.of("required")) + + @JvmStatic fun of(value: String) = Required(JsonField.of(value)) + } + + enum class Known { + REQUIRED, + } + + enum class Value { + REQUIRED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + REQUIRED -> Value.REQUIRED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + REQUIRED -> Known.REQUIRED + else -> throw BraintrustInvalidDataException("Unknown Required: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val type: JsonField, + private val function: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun type(): Type = type.getRequired("type") + + fun function(): Function = function.getRequired("function") + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("function") @ExcludeMissing fun _function() = function + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + type() + function().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var function: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.type = function.type + this.function = function.function + additionalProperties(function.additionalProperties) + } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun function(function: Function) = function(JsonField.of(function)) + + @JsonProperty("function") + @ExcludeMissing + fun function(function: JsonField) = apply { + this.function = function + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Function = + Function( + type, + function, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun name(): String = name.getRequired("name") + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.name = function.name + additionalProperties(function.additionalProperties) + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Function = + Function(name, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.type == other.type && this.function == other.function && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, function, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OpenAIModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.topP == other.topP && this.maxTokens == other.maxTokens && this.frequencyPenalty == other.frequencyPenalty && this.presencePenalty == other.presencePenalty && this.responseFormat == other.responseFormat && this.toolChoice == other.toolChoice && this.functionCall == other.functionCall && this.n == other.n && this.stop == other.stop && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, temperature, topP, maxTokens, frequencyPenalty, presencePenalty, responseFormat, toolChoice, functionCall, n, stop, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = AnthropicModelParams.Builder::class) + @NoAutoDetect + class AnthropicModelParams + private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) + + fun maxTokens(): Double = maxTokens.getRequired("max_tokens") + + fun temperature(): Double = temperature.getRequired("temperature") + + fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) + + fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) + + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + + /** This is a legacy parameter that should not be used. */ + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens + + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + + @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP + + @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK + + @JsonProperty("stop_sequences") @ExcludeMissing fun _stopSequences() = stopSequences + + /** This is a legacy parameter that should not be used. */ + @JsonProperty("max_tokens_to_sample") + @ExcludeMissing + fun _maxTokensToSample() = maxTokensToSample + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AnthropicModelParams = apply { + if (!validated) { + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var useCache: JsonField = JsonMissing.of() + private var maxTokens: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var topK: JsonField = JsonMissing.of() + private var stopSequences: JsonField> = JsonMissing.of() + private var maxTokensToSample: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + this.useCache = anthropicModelParams.useCache + this.maxTokens = anthropicModelParams.maxTokens + this.temperature = anthropicModelParams.temperature + this.topP = anthropicModelParams.topP + this.topK = anthropicModelParams.topK + this.stopSequences = anthropicModelParams.stopSequences + this.maxTokensToSample = anthropicModelParams.maxTokensToSample + additionalProperties(anthropicModelParams.additionalProperties) + } + + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + + @JsonProperty("use_cache") + @ExcludeMissing + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + + fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) + + @JsonProperty("max_tokens") + @ExcludeMissing + fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + + fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + + @JsonProperty("temperature") + @ExcludeMissing + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } + + fun topP(topP: Double) = topP(JsonField.of(topP)) + + @JsonProperty("top_p") + @ExcludeMissing + fun topP(topP: JsonField) = apply { this.topP = topP } + + fun topK(topK: Double) = topK(JsonField.of(topK)) + + @JsonProperty("top_k") + @ExcludeMissing + fun topK(topK: JsonField) = apply { this.topK = topK } + + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) + + @JsonProperty("stop_sequences") + @ExcludeMissing + fun stopSequences(stopSequences: JsonField>) = apply { + this.stopSequences = stopSequences + } + + /** This is a legacy parameter that should not be used. */ + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) + + /** This is a legacy parameter that should not be used. */ + @JsonProperty("max_tokens_to_sample") + @ExcludeMissing + fun maxTokensToSample(maxTokensToSample: JsonField) = apply { + this.maxTokensToSample = maxTokensToSample + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AnthropicModelParams = + AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toImmutable() }, + maxTokensToSample, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AnthropicModelParams && this.useCache == other.useCache && this.maxTokens == other.maxTokens && this.temperature == other.temperature && this.topP == other.topP && this.topK == other.topK && this.stopSequences == other.stopSequences && this.maxTokensToSample == other.maxTokensToSample && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, maxTokens, temperature, topP, topK, stopSequences, maxTokensToSample, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = GoogleModelParams.Builder::class) + @NoAutoDetect + class GoogleModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) + + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) + + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + + fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) + + fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) + + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + + @JsonProperty("maxOutputTokens") + @ExcludeMissing + fun _maxOutputTokens() = maxOutputTokens + + @JsonProperty("topP") @ExcludeMissing fun _topP() = topP + + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): GoogleModelParams = apply { + if (!validated) { + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var useCache: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var maxOutputTokens: JsonField = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var topK: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(googleModelParams: GoogleModelParams) = apply { + this.useCache = googleModelParams.useCache + this.temperature = googleModelParams.temperature + this.maxOutputTokens = googleModelParams.maxOutputTokens + this.topP = googleModelParams.topP + this.topK = googleModelParams.topK + additionalProperties(googleModelParams.additionalProperties) + } + + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + + @JsonProperty("use_cache") + @ExcludeMissing + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + + fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + + @JsonProperty("temperature") + @ExcludeMissing + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } + + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) + + @JsonProperty("maxOutputTokens") + @ExcludeMissing + fun maxOutputTokens(maxOutputTokens: JsonField) = apply { + this.maxOutputTokens = maxOutputTokens + } + + fun topP(topP: Double) = topP(JsonField.of(topP)) + + @JsonProperty("topP") + @ExcludeMissing + fun topP(topP: JsonField) = apply { this.topP = topP } + + fun topK(topK: Double) = topK(JsonField.of(topK)) + + @JsonProperty("topK") + @ExcludeMissing + fun topK(topK: JsonField) = apply { this.topK = topK } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): GoogleModelParams = + GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GoogleModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.maxOutputTokens == other.maxOutputTokens && this.topP == other.topP && this.topK == other.topK && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, temperature, maxOutputTokens, topP, topK, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = WindowAiModelParams.Builder::class) + @NoAutoDetect + class WindowAiModelParams + private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) + + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) + + fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) + + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + + @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + + @JsonProperty("topK") @ExcludeMissing fun _topK() = topK + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): WindowAiModelParams = apply { + if (!validated) { + useCache() + temperature() + topK() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var useCache: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() + private var topK: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + this.useCache = windowAiModelParams.useCache + this.temperature = windowAiModelParams.temperature + this.topK = windowAiModelParams.topK + additionalProperties(windowAiModelParams.additionalProperties) + } + + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + + @JsonProperty("use_cache") + @ExcludeMissing + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + + fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + + @JsonProperty("temperature") + @ExcludeMissing + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } + + fun topK(topK: Double) = topK(JsonField.of(topK)) + + @JsonProperty("topK") + @ExcludeMissing + fun topK(topK: JsonField) = apply { this.topK = topK } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): WindowAiModelParams = + WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is WindowAiModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.topK == other.topK && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, temperature, topK, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = JsCompletionParams.Builder::class) + @NoAutoDetect + class JsCompletionParams + private constructor( + private val useCache: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) + + @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): JsCompletionParams = apply { + if (!validated) { + useCache() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var useCache: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + this.useCache = jsCompletionParams.useCache + additionalProperties(jsCompletionParams.additionalProperties) + } + + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + + @JsonProperty("use_cache") + @ExcludeMissing + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): JsCompletionParams = + JsCompletionParams(useCache, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is JsCompletionParams && this.useCache == other.useCache && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(useCache, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptOptions && this.model == other.model && this.params == other.params && this.position == other.position && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(model, params, position, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PromptOptions{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" +} 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 new file mode 100644 index 00000000..db94838a --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanAttributes.kt @@ -0,0 +1,215 @@ +// File generated from our OpenAPI spec by Stainless. + +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 +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +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 +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects +import java.util.Optional + +/** Human-identifying attributes of the span, such as name, type, etc. */ +@JsonDeserialize(builder = SpanAttributes.Builder::class) +@NoAutoDetect +class SpanAttributes +private constructor( + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** Name of the span, for display purposes only */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Type of the span, for display purposes only */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** Type of the span, for display purposes only */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SpanAttributes = apply { + if (!validated) { + name() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanAttributes: SpanAttributes) = apply { + this.name = spanAttributes.name + this.type = spanAttributes.type + additionalProperties(spanAttributes.additionalProperties) + } + + /** Name of the span, for display purposes only */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span, for display purposes only */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** Type of the span, for display purposes only */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Type of the span, for display purposes only */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SpanAttributes = + SpanAttributes( + name, + type, + additionalProperties.toImmutable(), + ) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val LLM = Type(JsonField.of("llm")) + + @JvmField val SCORE = Type(JsonField.of("score")) + + @JvmField val FUNCTION = Type(JsonField.of("function")) + + @JvmField val EVAL = Type(JsonField.of("eval")) + + @JvmField val TASK = Type(JsonField.of("task")) + + @JvmField val TOOL = Type(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + } + + enum class Value { + LLM, + SCORE, + FUNCTION, + EVAL, + TASK, + TOOL, + _UNKNOWN, + } + + 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 + } + + 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") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index 69c688b4..a2054ae2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -16,19 +16,21 @@ class DatasetInsertParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertDatasetEvent.Metadata.builder().build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() ) ) .build() @@ -41,41 +43,45 @@ class DatasetInsertParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() + InsertDatasetEvent.builder() .id("id") ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) ._objectDelete(true) ._parentId("_parent_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonNull.of()) .input(JsonNull.of()) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .metadata(InsertDatasetEvent.Metadata.builder().build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .spanParents(listOf("string")) .tags(listOf("string")) .build() ) ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertDatasetEvent.Metadata.builder().build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + ) ) } @@ -84,24 +90,11 @@ class DatasetInsertParamsTest { val params = DatasetInsertParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder().build() - ) - ) - ) + .events(listOf(InsertDatasetEvent.builder().build())) .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder().build() - ) - ) - ) + assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) } @Test @@ -109,13 +102,7 @@ class DatasetInsertParamsTest { val params = DatasetInsertParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder().build() - ) - ) - ) + .events(listOf(InsertDatasetEvent.builder().build())) .build() assertThat(params).isNotNull // path param "datasetId" 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 75216ef1..eb549b4c 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 @@ -56,10 +56,7 @@ class ExperimentEventTest { .output(JsonNull.of()) .scores(ExperimentEvent.Scores.builder().build()) .spanAttributes( - ExperimentEvent.SpanAttributes.builder() - .name("name") - .type(ExperimentEvent.SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) .spanParents(listOf("string")) .tags(listOf("string")) @@ -112,12 +109,7 @@ class ExperimentEventTest { assertThat(experimentEvent._output()).isEqualTo(JsonNull.of()) assertThat(experimentEvent.scores()).contains(ExperimentEvent.Scores.builder().build()) assertThat(experimentEvent.spanAttributes()) - .contains( - ExperimentEvent.SpanAttributes.builder() - .name("name") - .type(ExperimentEvent.SpanAttributes.Type.LLM) - .build() - ) + .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.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 a5e47101..657899f2 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 @@ -16,48 +16,50 @@ class ExperimentInsertParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonNull.of()) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertExperimentEvent.Metadata.builder().build()) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonNull.of()) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder().build()) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() ) ) .build() @@ -70,64 +72,14 @@ class ExperimentInsertParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() + InsertExperimentEvent.builder() .id("id") ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) ._objectDelete(true) ._parentId("_parent_id") .context( - InsertExperimentEventReplace.Context.builder() + InsertExperimentEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) @@ -138,9 +90,9 @@ class ExperimentInsertParamsTest { .error(JsonNull.of()) .expected(JsonNull.of()) .input(JsonNull.of()) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metadata(InsertExperimentEvent.Metadata.builder().build()) .metrics( - InsertExperimentEventReplace.Metrics.builder() + InsertExperimentEvent.Metrics.builder() .callerFilename(JsonNull.of()) .callerFunctionname(JsonNull.of()) .callerLineno(JsonNull.of()) @@ -152,17 +104,71 @@ class ExperimentInsertParamsTest { .build() ) .output(JsonNull.of()) - .scores(InsertExperimentEventReplace.Scores.builder().build()) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder().build()) .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() + SpanAttributes.builder() .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .type(SpanAttributes.Type.LLM) .build() ) + .spanId("span_id") + .spanParents(listOf("string")) .tags(listOf("string")) .build() ) ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonNull.of()) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertExperimentEvent.Metadata.builder().build()) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonNull.of()) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder().build()) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + ) ) } @@ -171,24 +177,11 @@ class ExperimentInsertParamsTest { val params = ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder().build() - ) - ) - ) + .events(listOf(InsertExperimentEvent.builder().build())) .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder().build() - ) - ) - ) + assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) } @Test @@ -196,13 +189,7 @@ class ExperimentInsertParamsTest { val params = ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder().build() - ) - ) - ) + .events(listOf(InsertExperimentEvent.builder().build())) .build() assertThat(params).isNotNull // path param "experimentId" 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 da7f86c9..59428a69 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 @@ -59,9 +59,9 @@ class FetchExperimentEventsResponseTest { .output(JsonNull.of()) .scores(ExperimentEvent.Scores.builder().build()) .spanAttributes( - ExperimentEvent.SpanAttributes.builder() + SpanAttributes.builder() .name("name") - .type(ExperimentEvent.SpanAttributes.Type.LLM) + .type(SpanAttributes.Type.LLM) .build() ) .spanParents(listOf("string")) @@ -118,10 +118,7 @@ class FetchExperimentEventsResponseTest { .output(JsonNull.of()) .scores(ExperimentEvent.Scores.builder().build()) .spanAttributes( - ExperimentEvent.SpanAttributes.builder() - .name("name") - .type(ExperimentEvent.SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) .spanParents(listOf("string")) .tags(listOf("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 cbbef1a6..589fb2a1 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 @@ -59,9 +59,9 @@ class FetchProjectLogsEventsResponseTest { .output(JsonNull.of()) .scores(ProjectLogsEvent.Scores.builder().build()) .spanAttributes( - ProjectLogsEvent.SpanAttributes.builder() + SpanAttributes.builder() .name("name") - .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .type(SpanAttributes.Type.LLM) .build() ) .spanParents(listOf("string")) @@ -118,10 +118,7 @@ class FetchProjectLogsEventsResponseTest { .output(JsonNull.of()) .scores(ProjectLogsEvent.Scores.builder().build()) .spanAttributes( - ProjectLogsEvent.SpanAttributes.builder() - .name("name") - .type(ProjectLogsEvent.SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) .spanParents(listOf("string")) .tags(listOf("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 1e391994..37a9323e 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 @@ -40,16 +40,16 @@ class FunctionCreateParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -59,16 +59,14 @@ class FunctionCreateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -80,9 +78,9 @@ class FunctionCreateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -166,17 +164,16 @@ class FunctionCreateParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -186,15 +183,15 @@ class FunctionCreateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -207,10 +204,9 @@ class FunctionCreateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -294,16 +290,16 @@ class FunctionCreateParamsTest { .isEqualTo( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -313,16 +309,14 @@ class FunctionCreateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -334,9 +328,9 @@ class FunctionCreateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO 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 5836c0b4..8e387b3e 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 @@ -40,16 +40,16 @@ class FunctionReplaceParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -59,16 +59,14 @@ class FunctionReplaceParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -80,9 +78,9 @@ class FunctionReplaceParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -166,17 +164,16 @@ class FunctionReplaceParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -186,15 +183,15 @@ class FunctionReplaceParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -207,10 +204,9 @@ class FunctionReplaceParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -294,16 +290,16 @@ class FunctionReplaceParamsTest { .isEqualTo( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -313,16 +309,14 @@ class FunctionReplaceParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -334,9 +328,9 @@ class FunctionReplaceParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO 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 d1b8e471..6aa745a0 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 @@ -47,17 +47,16 @@ class FunctionTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -67,15 +66,15 @@ class FunctionTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -88,10 +87,9 @@ class FunctionTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -180,16 +178,16 @@ class FunctionTest { .contains( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -199,16 +197,14 @@ class FunctionTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -220,9 +216,9 @@ class FunctionTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index 6fc5f740..a7724f5e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -24,16 +24,16 @@ class FunctionUpdateParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -43,16 +43,14 @@ class FunctionUpdateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -64,9 +62,9 @@ class FunctionUpdateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -135,17 +133,16 @@ class FunctionUpdateParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -155,15 +152,15 @@ class FunctionUpdateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -176,10 +173,9 @@ class FunctionUpdateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -245,16 +241,16 @@ class FunctionUpdateParamsTest { .isEqualTo( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -264,16 +260,14 @@ class FunctionUpdateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -285,9 +279,9 @@ class FunctionUpdateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt deleted file mode 100755 index b90e611f..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonNull -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertDatasetEventMergeTest { - - @Test - fun createInsertDatasetEventMerge() { - val insertDatasetEventMerge = - InsertDatasetEventMerge.builder() - ._isMerge(true) - .id("id") - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEventMerge.Metadata.builder().build()) - .tags(listOf("string")) - .build() - assertThat(insertDatasetEventMerge).isNotNull - assertThat(insertDatasetEventMerge._isMerge()).isEqualTo(true) - assertThat(insertDatasetEventMerge.id()).contains("id") - assertThat(insertDatasetEventMerge._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertDatasetEventMerge._objectDelete()).contains(true) - assertThat(insertDatasetEventMerge.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertDatasetEventMerge._expected()).isEqualTo(JsonNull.of()) - assertThat(insertDatasetEventMerge._input()).isEqualTo(JsonNull.of()) - assertThat(insertDatasetEventMerge.metadata()) - .contains(InsertDatasetEventMerge.Metadata.builder().build()) - assertThat(insertDatasetEventMerge.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt deleted file mode 100755 index 55e6cf57..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonNull -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertDatasetEventReplaceTest { - - @Test - fun createInsertDatasetEventReplace() { - val insertDatasetEventReplace = - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - assertThat(insertDatasetEventReplace).isNotNull - assertThat(insertDatasetEventReplace.id()).contains("id") - assertThat(insertDatasetEventReplace._isMerge()).contains(true) - assertThat(insertDatasetEventReplace._objectDelete()).contains(true) - assertThat(insertDatasetEventReplace._parentId()).contains("_parent_id") - assertThat(insertDatasetEventReplace.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertDatasetEventReplace._expected()).isEqualTo(JsonNull.of()) - assertThat(insertDatasetEventReplace._input()).isEqualTo(JsonNull.of()) - assertThat(insertDatasetEventReplace.metadata()) - .contains(InsertDatasetEventReplace.Metadata.builder().build()) - assertThat(insertDatasetEventReplace.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt new file mode 100644 index 00000000..7191f0b7 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonNull +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertDatasetEventTest { + + @Test + fun createInsertDatasetEvent() { + val insertDatasetEvent = + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertDatasetEvent.Metadata.builder().build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + assertThat(insertDatasetEvent).isNotNull + assertThat(insertDatasetEvent.id()).contains("id") + assertThat(insertDatasetEvent._isMerge()).contains(true) + assertThat(insertDatasetEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertDatasetEvent._objectDelete()).contains(true) + assertThat(insertDatasetEvent._parentId()).contains("_parent_id") + assertThat(insertDatasetEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertDatasetEvent._expected()).isEqualTo(JsonNull.of()) + assertThat(insertDatasetEvent._input()).isEqualTo(JsonNull.of()) + assertThat(insertDatasetEvent.metadata()) + .contains(InsertDatasetEvent.Metadata.builder().build()) + assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") + assertThat(insertDatasetEvent.spanId()).contains("span_id") + assertThat(insertDatasetEvent.spanParents().get()).containsExactly("string") + assertThat(insertDatasetEvent.tags().get()).containsExactly("string") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt deleted file mode 100755 index 0aa4757e..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt +++ /dev/null @@ -1,101 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonNull -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertExperimentEventMergeTest { - - @Test - fun createInsertExperimentEventMerge() { - val insertExperimentEventMerge = - InsertExperimentEventMerge.builder() - ._isMerge(true) - .id("id") - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - .context( - InsertExperimentEventMerge.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEventMerge.Metadata.builder().build()) - .metrics( - InsertExperimentEventMerge.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertExperimentEventMerge.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventMerge.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventMerge.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(insertExperimentEventMerge).isNotNull - assertThat(insertExperimentEventMerge._isMerge()).isEqualTo(true) - assertThat(insertExperimentEventMerge.id()).contains("id") - assertThat(insertExperimentEventMerge._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertExperimentEventMerge._objectDelete()).contains(true) - assertThat(insertExperimentEventMerge.context()) - .contains( - InsertExperimentEventMerge.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(insertExperimentEventMerge.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEventMerge.datasetRecordId()).contains("dataset_record_id") - assertThat(insertExperimentEventMerge._error()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEventMerge._expected()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEventMerge._input()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEventMerge.metadata()) - .contains(InsertExperimentEventMerge.Metadata.builder().build()) - assertThat(insertExperimentEventMerge.metrics()) - .contains( - InsertExperimentEventMerge.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(insertExperimentEventMerge._output()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEventMerge.scores()) - .contains(InsertExperimentEventMerge.Scores.builder().build()) - assertThat(insertExperimentEventMerge.spanAttributes()) - .contains( - InsertExperimentEventMerge.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventMerge.SpanAttributes.Type.LLM) - .build() - ) - assertThat(insertExperimentEventMerge.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt deleted file mode 100755 index c6cce2d7..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt +++ /dev/null @@ -1,101 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonNull -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertExperimentEventReplaceTest { - - @Test - fun createInsertExperimentEventReplace() { - val insertExperimentEventReplace = - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(insertExperimentEventReplace).isNotNull - assertThat(insertExperimentEventReplace.id()).contains("id") - assertThat(insertExperimentEventReplace._isMerge()).contains(true) - assertThat(insertExperimentEventReplace._objectDelete()).contains(true) - assertThat(insertExperimentEventReplace._parentId()).contains("_parent_id") - assertThat(insertExperimentEventReplace.context()) - .contains( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(insertExperimentEventReplace.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEventReplace.datasetRecordId()).contains("dataset_record_id") - assertThat(insertExperimentEventReplace._error()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEventReplace._expected()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEventReplace._input()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEventReplace.metadata()) - .contains(InsertExperimentEventReplace.Metadata.builder().build()) - assertThat(insertExperimentEventReplace.metrics()) - .contains( - InsertExperimentEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(insertExperimentEventReplace._output()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEventReplace.scores()) - .contains(InsertExperimentEventReplace.Scores.builder().build()) - assertThat(insertExperimentEventReplace.spanAttributes()) - .contains( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - assertThat(insertExperimentEventReplace.tags().get()).containsExactly("string") - } -} 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 new file mode 100644 index 00000000..4f2d0418 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventTest.kt @@ -0,0 +1,101 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonNull +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertExperimentEventTest { + + @Test + fun createInsertExperimentEvent() { + val insertExperimentEvent = + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonNull.of()) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertExperimentEvent.Metadata.builder().build()) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonNull.of()) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder().build()) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + assertThat(insertExperimentEvent).isNotNull + assertThat(insertExperimentEvent.id()).contains("id") + assertThat(insertExperimentEvent._isMerge()).contains(true) + assertThat(insertExperimentEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertExperimentEvent._objectDelete()).contains(true) + assertThat(insertExperimentEvent._parentId()).contains("_parent_id") + assertThat(insertExperimentEvent.context()) + .contains( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + assertThat(insertExperimentEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") + assertThat(insertExperimentEvent._error()).isEqualTo(JsonNull.of()) + assertThat(insertExperimentEvent._expected()).isEqualTo(JsonNull.of()) + assertThat(insertExperimentEvent._input()).isEqualTo(JsonNull.of()) + assertThat(insertExperimentEvent.metadata()) + .contains(InsertExperimentEvent.Metadata.builder().build()) + assertThat(insertExperimentEvent.metrics()) + .contains( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + assertThat(insertExperimentEvent._output()).isEqualTo(JsonNull.of()) + assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") + assertThat(insertExperimentEvent.scores()) + .contains(InsertExperimentEvent.Scores.builder().build()) + assertThat(insertExperimentEvent.spanAttributes()) + .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.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/InsertProjectLogsEventMergeTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt deleted file mode 100755 index 39f7e545..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt +++ /dev/null @@ -1,100 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonNull -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertProjectLogsEventMergeTest { - - @Test - fun createInsertProjectLogsEventMerge() { - val insertProjectLogsEventMerge = - InsertProjectLogsEventMerge.builder() - ._isMerge(true) - .id("id") - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - .context( - InsertProjectLogsEventMerge.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEventMerge.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventMerge.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertProjectLogsEventMerge.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventMerge.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventMerge.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(insertProjectLogsEventMerge).isNotNull - assertThat(insertProjectLogsEventMerge._isMerge()).isEqualTo(true) - assertThat(insertProjectLogsEventMerge.id()).contains("id") - assertThat(insertProjectLogsEventMerge._mergePaths().get()) - .containsExactly(listOf("string")) - assertThat(insertProjectLogsEventMerge._objectDelete()).contains(true) - assertThat(insertProjectLogsEventMerge.context()) - .contains( - InsertProjectLogsEventMerge.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(insertProjectLogsEventMerge.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertProjectLogsEventMerge._error()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEventMerge._expected()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEventMerge._input()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEventMerge.metadata()) - .contains(InsertProjectLogsEventMerge.Metadata.builder().build()) - assertThat(insertProjectLogsEventMerge.metrics()) - .contains( - InsertProjectLogsEventMerge.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(insertProjectLogsEventMerge._output()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEventMerge.scores()) - .contains(InsertProjectLogsEventMerge.Scores.builder().build()) - assertThat(insertProjectLogsEventMerge.spanAttributes()) - .contains( - InsertProjectLogsEventMerge.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventMerge.SpanAttributes.Type.LLM) - .build() - ) - assertThat(insertProjectLogsEventMerge.tags().get()).containsExactly("string") - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt deleted file mode 100755 index 09b08af4..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt +++ /dev/null @@ -1,99 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonNull -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertProjectLogsEventReplaceTest { - - @Test - fun createInsertProjectLogsEventReplace() { - val insertProjectLogsEventReplace = - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(insertProjectLogsEventReplace).isNotNull - assertThat(insertProjectLogsEventReplace.id()).contains("id") - assertThat(insertProjectLogsEventReplace._isMerge()).contains(true) - assertThat(insertProjectLogsEventReplace._objectDelete()).contains(true) - assertThat(insertProjectLogsEventReplace._parentId()).contains("_parent_id") - assertThat(insertProjectLogsEventReplace.context()) - .contains( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(insertProjectLogsEventReplace.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertProjectLogsEventReplace._error()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEventReplace._expected()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEventReplace._input()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEventReplace.metadata()) - .contains(InsertProjectLogsEventReplace.Metadata.builder().build()) - assertThat(insertProjectLogsEventReplace.metrics()) - .contains( - InsertProjectLogsEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(insertProjectLogsEventReplace._output()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEventReplace.scores()) - .contains(InsertProjectLogsEventReplace.Scores.builder().build()) - assertThat(insertProjectLogsEventReplace.spanAttributes()) - .contains( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - assertThat(insertProjectLogsEventReplace.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 new file mode 100644 index 00000000..66f6ac96 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventTest.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonNull +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InsertProjectLogsEventTest { + + @Test + fun createInsertProjectLogsEvent() { + val insertProjectLogsEvent = + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonNull.of()) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertProjectLogsEvent.Metadata.builder().build()) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonNull.of()) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder().build()) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + assertThat(insertProjectLogsEvent).isNotNull + assertThat(insertProjectLogsEvent.id()).contains("id") + assertThat(insertProjectLogsEvent._isMerge()).contains(true) + assertThat(insertProjectLogsEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertProjectLogsEvent._objectDelete()).contains(true) + assertThat(insertProjectLogsEvent._parentId()).contains("_parent_id") + assertThat(insertProjectLogsEvent.context()) + .contains( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + assertThat(insertProjectLogsEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonNull.of()) + assertThat(insertProjectLogsEvent._expected()).isEqualTo(JsonNull.of()) + assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonNull.of()) + assertThat(insertProjectLogsEvent.metadata()) + .contains(InsertProjectLogsEvent.Metadata.builder().build()) + assertThat(insertProjectLogsEvent.metrics()) + .contains( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonNull.of()) + assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") + assertThat(insertProjectLogsEvent.scores()) + .contains(InsertProjectLogsEvent.Scores.builder().build()) + assertThat(insertProjectLogsEvent.spanAttributes()) + .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.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 8e3a2ce2..851546b4 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 @@ -16,47 +16,49 @@ class ProjectLogInsertParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonNull.of()) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertProjectLogsEvent.Metadata.builder().build()) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonNull.of()) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder().build()) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() ) ) .build() @@ -69,63 +71,14 @@ class ProjectLogInsertParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() + InsertProjectLogsEvent.builder() .id("id") ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) ._objectDelete(true) ._parentId("_parent_id") .context( - InsertProjectLogsEventReplace.Context.builder() + InsertProjectLogsEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") .callerLineno(123L) @@ -135,9 +88,9 @@ class ProjectLogInsertParamsTest { .error(JsonNull.of()) .expected(JsonNull.of()) .input(JsonNull.of()) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metadata(InsertProjectLogsEvent.Metadata.builder().build()) .metrics( - InsertProjectLogsEventReplace.Metrics.builder() + InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonNull.of()) .callerFunctionname(JsonNull.of()) .callerLineno(JsonNull.of()) @@ -149,17 +102,70 @@ class ProjectLogInsertParamsTest { .build() ) .output(JsonNull.of()) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder().build()) .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() + SpanAttributes.builder() .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .type(SpanAttributes.Type.LLM) .build() ) + .spanId("span_id") + .spanParents(listOf("string")) .tags(listOf("string")) .build() ) ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()) + .isEqualTo( + listOf( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonNull.of()) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertProjectLogsEvent.Metadata.builder().build()) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonNull.of()) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder().build()) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() + ) ) } @@ -168,24 +174,11 @@ class ProjectLogInsertParamsTest { val params = ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder().build() - ) - ) - ) + .events(listOf(InsertProjectLogsEvent.builder().build())) .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder().build() - ) - ) - ) + assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) } @Test @@ -193,13 +186,7 @@ class ProjectLogInsertParamsTest { val params = ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder().build() - ) - ) - ) + .events(listOf(InsertProjectLogsEvent.builder().build())) .build() assertThat(params).isNotNull // path param "projectId" 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 37ffb683..7b27c557 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 @@ -56,10 +56,7 @@ class ProjectLogsEventTest { .output(JsonNull.of()) .scores(ProjectLogsEvent.Scores.builder().build()) .spanAttributes( - ProjectLogsEvent.SpanAttributes.builder() - .name("name") - .type(ProjectLogsEvent.SpanAttributes.Type.LLM) - .build() + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) .spanParents(listOf("string")) .tags(listOf("string")) @@ -113,12 +110,7 @@ class ProjectLogsEventTest { assertThat(projectLogsEvent._output()).isEqualTo(JsonNull.of()) assertThat(projectLogsEvent.scores()).contains(ProjectLogsEvent.Scores.builder().build()) assertThat(projectLogsEvent.spanAttributes()) - .contains( - ProjectLogsEvent.SpanAttributes.builder() - .name("name") - .type(ProjectLogsEvent.SpanAttributes.Type.LLM) - .build() - ) + .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.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/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 1baf3939..e7962b7d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -19,16 +19,16 @@ class PromptCreateParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -38,16 +38,14 @@ class PromptCreateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -59,9 +57,9 @@ class PromptCreateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -125,17 +123,16 @@ class PromptCreateParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -145,15 +142,15 @@ class PromptCreateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -166,10 +163,9 @@ class PromptCreateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -230,16 +226,16 @@ class PromptCreateParamsTest { .isEqualTo( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -249,16 +245,14 @@ class PromptCreateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -270,9 +264,9 @@ class PromptCreateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index 872bde94..33c52da4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -12,33 +12,30 @@ class PromptDataTest { val promptData = PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) + PromptOptions.Params.OpenAIModelParams.FunctionCall.ofAuto( + PromptOptions.Params.OpenAIModelParams.FunctionCall.Auto + .AUTO + ) ) .maxTokens(42.23) .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams.ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -50,13 +47,10 @@ class PromptDataTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) + PromptOptions.Params.OpenAIModelParams.ToolChoice.ofAuto( + PromptOptions.Params.OpenAIModelParams.ToolChoice.Auto + .AUTO + ) ) .topP(42.23) .useCache(true) @@ -102,16 +96,15 @@ class PromptDataTest { assertThat(promptData).isNotNull assertThat(promptData.options()) .contains( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .Auto + PromptOptions.Params.OpenAIModelParams.FunctionCall.ofAuto( + PromptOptions.Params.OpenAIModelParams.FunctionCall.Auto .AUTO ) ) @@ -119,14 +112,13 @@ class PromptDataTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams.ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -138,9 +130,8 @@ class PromptDataTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto( - PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto - .AUTO + PromptOptions.Params.OpenAIModelParams.ToolChoice.ofAuto( + PromptOptions.Params.OpenAIModelParams.ToolChoice.Auto.AUTO ) ) .topP(42.23) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt new file mode 100644 index 00000000..15042e53 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PromptOptionsTest { + + @Test + fun createPromptOptions() { + val promptOptions = + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.ofAuto( + PromptOptions.Params.OpenAIModelParams.FunctionCall.Auto.AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.ofJsonObject( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.ofAuto( + PromptOptions.Params.OpenAIModelParams.ToolChoice.Auto.AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + .position("position") + .build() + assertThat(promptOptions).isNotNull + assertThat(promptOptions.model()).contains("model") + assertThat(promptOptions.params()) + .contains( + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.ofAuto( + PromptOptions.Params.OpenAIModelParams.FunctionCall.Auto.AUTO + ) + ) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.ofJsonObject( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + ) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.ofAuto( + PromptOptions.Params.OpenAIModelParams.ToolChoice.Auto.AUTO + ) + ) + .topP(42.23) + .useCache(true) + .build() + ) + ) + assertThat(promptOptions.position()).contains("position") + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 705c3dc6..9aa91544 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -19,16 +19,16 @@ class PromptReplaceParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -38,16 +38,14 @@ class PromptReplaceParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -59,9 +57,9 @@ class PromptReplaceParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -125,17 +123,16 @@ class PromptReplaceParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -145,15 +142,15 @@ class PromptReplaceParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -166,10 +163,9 @@ class PromptReplaceParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -230,16 +226,16 @@ class PromptReplaceParamsTest { .isEqualTo( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -249,16 +245,14 @@ class PromptReplaceParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -270,9 +264,9 @@ class PromptReplaceParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index c10b4197..d33be2b4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -26,17 +26,16 @@ class PromptTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -46,15 +45,15 @@ class PromptTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -67,10 +66,9 @@ class PromptTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -136,16 +134,16 @@ class PromptTest { .contains( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -155,16 +153,14 @@ class PromptTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -176,9 +172,9 @@ class PromptTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 574f9e45..a9dbfada 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -17,16 +17,16 @@ class PromptUpdateParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -36,16 +36,14 @@ class PromptUpdateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -57,9 +55,9 @@ class PromptUpdateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -122,17 +120,16 @@ class PromptUpdateParamsTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -142,15 +139,15 @@ class PromptUpdateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -163,10 +160,9 @@ class PromptUpdateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -225,16 +221,16 @@ class PromptUpdateParamsTest { .isEqualTo( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall + PromptOptions.Params.OpenAIModelParams.FunctionCall .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -244,16 +240,14 @@ class PromptUpdateParamsTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat + PromptOptions.Params.OpenAIModelParams.ResponseFormat .ofJsonObject( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .Type @@ -265,9 +259,9 @@ class PromptUpdateParamsTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice + PromptOptions.Params.OpenAIModelParams.ToolChoice .ofAuto( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO 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 new file mode 100644 index 00000000..562a0b8a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt @@ -0,0 +1,18 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SpanAttributesTest { + + @Test + fun createSpanAttributes() { + val spanAttributes = + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + assertThat(spanAttributes).isNotNull + assertThat(spanAttributes.name()).contains("name") + assertThat(spanAttributes.type()).contains(SpanAttributes.Type.LLM) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index 413a951b..0dd351c6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -201,19 +201,21 @@ class DatasetServiceTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertDatasetEvent.Metadata.builder().build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() ) ) .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 2b5aac61..0d9bc86d 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 @@ -238,52 +238,50 @@ class ExperimentServiceTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata( - InsertExperimentEventReplace.Metadata.builder().build() - ) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type( - InsertExperimentEventReplace.SpanAttributes.Type.LLM - ) - .build() - ) - .tags(listOf("string")) - .build() - ) + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonNull.of()) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertExperimentEvent.Metadata.builder().build()) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonNull.of()) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder().build()) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() ) ) .build() 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 d40772bf..e2606aa4 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 @@ -52,18 +52,17 @@ class FunctionServiceTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -73,16 +72,15 @@ class FunctionServiceTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -95,11 +93,10 @@ class FunctionServiceTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -196,18 +193,17 @@ class FunctionServiceTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -217,16 +213,15 @@ class FunctionServiceTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -239,11 +234,10 @@ class FunctionServiceTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -423,18 +417,17 @@ class FunctionServiceTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -444,16 +437,15 @@ class FunctionServiceTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -466,11 +458,10 @@ class FunctionServiceTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index c5370402..4d53e986 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -31,18 +31,17 @@ class PromptServiceTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -52,16 +51,15 @@ class PromptServiceTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -74,11 +72,10 @@ class PromptServiceTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -168,18 +165,17 @@ class PromptServiceTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -189,16 +185,15 @@ class PromptServiceTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -211,11 +206,10 @@ class PromptServiceTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO @@ -321,18 +315,17 @@ class PromptServiceTest { .promptData( PromptData.builder() .options( - PromptData.Options.builder() + PromptOptions.builder() .model("model") .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() + PromptOptions.Params.ofOpenAIModelParams( + PromptOptions.Params.OpenAIModelParams.builder() .frequencyPenalty(42.23) .functionCall( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .FunctionCall .Auto .AUTO @@ -342,16 +335,15 @@ class PromptServiceTest { .n(42.23) .presencePenalty(42.23) .responseFormat( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .ofJsonObject( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ResponseFormat .JsonObject .builder() .type( - PromptData.Options.Params + PromptOptions.Params .OpenAIModelParams .ResponseFormat .JsonObject @@ -364,11 +356,10 @@ class PromptServiceTest { .stop(listOf("string")) .temperature(42.23) .toolChoice( - PromptData.Options.Params.OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .ofAuto( - PromptData.Options.Params - .OpenAIModelParams + PromptOptions.Params.OpenAIModelParams .ToolChoice .Auto .AUTO 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 e1ea6e91..74b8a98b 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 @@ -111,52 +111,49 @@ class LogServiceTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .events( listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata( - InsertProjectLogsEventReplace.Metadata.builder().build() - ) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type( - InsertProjectLogsEventReplace.SpanAttributes.Type - .LLM - ) - .build() - ) - .tags(listOf("string")) - .build() - ) + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonNull.of()) + .expected(JsonNull.of()) + .input(JsonNull.of()) + .metadata(InsertProjectLogsEvent.Metadata.builder().build()) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonNull.of()) + .callerFunctionname(JsonNull.of()) + .callerLineno(JsonNull.of()) + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build() + ) + .output(JsonNull.of()) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder().build()) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .spanParents(listOf("string")) + .tags(listOf("string")) + .build() ) ) .build() From bb4b1b8f382f47929c8c63f3aa1ff77011679bd2 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Fri, 15 Nov 2024 22:57:56 +0000 Subject: [PATCH 25/87] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4ed71f89..3eace990 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-6970b65779234e307010f4471a87cb7afa22919dc2c3ee63cf63cb9979c3eafd.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-b503b10818f249e17a802c508900e3f53726e436dcf84cc39335c2de6e369d8c.yml From 1cd427d2b43bbfb35c1ef70ae0e20ff7c66bb876 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 07:42:33 +0000 Subject: [PATCH 26/87] chore: rebuild project due to codegen change (#94) --- braintrust-java-core/build.gradle.kts | 3 +++ .../api/core/PhantomReachable.kt | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/braintrust-java-core/build.gradle.kts b/braintrust-java-core/build.gradle.kts index 4301ae91..de260952 100755 --- a/braintrust-java-core/build.gradle.kts +++ b/braintrust-java-core/build.gradle.kts @@ -20,4 +20,7 @@ dependencies { testImplementation("org.assertj:assertj-core:3.25.3") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.mockito:mockito-core:5.14.2") + testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") + testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PhantomReachable.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PhantomReachable.kt index d3f62aab..91785b1a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PhantomReachable.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PhantomReachable.kt @@ -15,10 +15,20 @@ internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable) check(observed !== closeable) { "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" } - closeWhenPhantomReachable?.let { it(observed, closeable::close) } + closeWhenPhantomReachable(observed, closeable::close) } -private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy { +/** + * Calls [close] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, close: () -> Unit) { + closeWhenPhantomReachable?.let { it(observed, close) } +} + +private val closeWhenPhantomReachable: ((Any, () -> Unit) -> Unit)? by lazy { try { val cleanerClass = Class.forName("java.lang.ref.Cleaner") val cleanerCreate = cleanerClass.getMethod("create") @@ -26,9 +36,9 @@ private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy { cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) val cleanerObject = cleanerCreate.invoke(null); - { observed, closeable -> + { observed, close -> try { - cleanerRegister.invoke(cleanerObject, observed, Runnable { closeable.close() }) + cleanerRegister.invoke(cleanerObject, observed, Runnable { close() }) } catch (e: ReflectiveOperationException) { if (e is InvocationTargetException) { when (val cause = e.cause) { From 0e97915cf7aaa7f1610d56b7c281c28b84ead0ac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:21:52 +0000 Subject: [PATCH 27/87] feat(api): manual updates (#95) --- .../api/models/ChatCompletionContent.kt | 133 +++++++ .../api/models/ChatCompletionContentPart.kt | 166 +++++++++ .../api/models/FunctionInvokeParams.kt | 307 +--------------- .../braintrustdata/api/models/PromptData.kt | 336 +----------------- 4 files changed, 314 insertions(+), 628 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt new file mode 100644 index 00000000..6d477739 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = ChatCompletionContent.Deserializer::class) +@JsonSerialize(using = ChatCompletionContent.Serializer::class) +class ChatCompletionContent +private constructor( + private val text: String? = null, + private val array: List? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun text(): Optional = Optional.ofNullable(text) + + fun array(): Optional> = Optional.ofNullable(array) + + fun isText(): Boolean = text != null + + fun isArray(): Boolean = array != null + + fun asText(): String = text.getOrThrow("text") + + fun asArray(): List = array.getOrThrow("array") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContent = apply { + if (!validated) { + if (text == null && array == null) { + throw BraintrustInvalidDataException("Unknown ChatCompletionContent: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContent && this.text == other.text && this.array == other.array /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ + } + + override fun toString(): String { + return when { + text != null -> "ChatCompletionContent{text=$text}" + array != null -> "ChatCompletionContent{array=$array}" + _json != null -> "ChatCompletionContent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContent") + } + } + + companion object { + + @JvmStatic fun ofText(text: String) = ChatCompletionContent(text = text) + + @JvmStatic + fun ofArray(array: List) = ChatCompletionContent(array = array) + } + + interface Visitor { + + fun visitText(text: String): T + + fun visitArray(array: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ChatCompletionContent: $json") + } + } + + class Deserializer : BaseDeserializer(ChatCompletionContent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContent { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return ChatCompletionContent(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return ChatCompletionContent(array = it, _json = json) + } + + return ChatCompletionContent(_json = json) + } + } + + class Serializer : BaseSerializer(ChatCompletionContent::class) { + + override fun serialize( + value: ChatCompletionContent, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContent") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt new file mode 100644 index 00000000..35a3f312 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) +@JsonSerialize(using = ChatCompletionContentPart.Serializer::class) +class ChatCompletionContentPart +private constructor( + private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, + private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if (chatCompletionContentPartText == null && chatCompletionContentPartImage == null) { + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $_json") + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = ChatCompletionContentPart(chatCompletionContentPartText = chatCompletionContentPartText) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") + } + } + + class Deserializer : + BaseDeserializer(ChatCompletionContentPart::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : BaseSerializer(ChatCompletionContentPart::class) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject(value.chatCompletionContentPartText) + value.chatCompletionContentPartImage != null -> + generator.writeObject(value.chatCompletionContentPartImage) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 8d58dec8..963e7921 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -824,7 +824,7 @@ constructor( @NoAutoDetect class User private constructor( - private val content: JsonField, + private val content: JsonField, private val role: JsonField, private val name: JsonField, private val additionalProperties: Map, @@ -832,7 +832,8 @@ constructor( private var validated: Boolean = false - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -866,7 +867,7 @@ constructor( class Builder { - private var content: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -879,11 +880,13 @@ constructor( additionalProperties(user.additionalProperties) } - fun content(content: Content) = content(JsonField.of(content)) + fun content(content: ChatCompletionContent) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun role(role: Role) = role(JsonField.of(role)) @@ -972,300 +975,6 @@ constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val text: String? = null, - private val array: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun text(): Optional = Optional.ofNullable(text) - - fun array(): Optional> = Optional.ofNullable(array) - - fun isText(): Boolean = text != null - - fun isArray(): Boolean = array != null - - fun asText(): String = text.getOrThrow("text") - - fun asArray(): List = array.getOrThrow("array") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (text == null && array == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - } - - override fun toString(): String { - return when { - text != null -> "Content{text=$text}" - array != null -> "Content{array=$array}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofText(text: String) = Content(text = text) - - @JvmStatic - fun ofArray(array: List) = Content(array = array) - } - - interface Visitor { - - fun visitText(text: String): T - - fun visitArray(array: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>()) - ?.let { - return Content(array = it, _json = json) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) - @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = - null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = - chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = - chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText( - chatCompletionContentPartText - ) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage( - chatCompletionContentPartImage - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && - chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = chatCompletionContentPartText - ) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 539d5a13..2c59e71c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -1313,7 +1313,7 @@ private constructor( @NoAutoDetect class User private constructor( - private val content: JsonField, + private val content: JsonField, private val role: JsonField, private val name: JsonField, private val additionalProperties: Map, @@ -1321,7 +1321,7 @@ private constructor( private var validated: Boolean = false - fun content(): Optional = + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -1356,7 +1356,7 @@ private constructor( class Builder { - private var content: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -1370,11 +1370,13 @@ private constructor( additionalProperties(user.additionalProperties) } - fun content(content: Content) = content(JsonField.of(content)) + fun content(content: ChatCompletionContent) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun role(role: Role) = role(JsonField.of(role)) @@ -1464,330 +1466,6 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val text: String? = null, - private val array: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun text(): Optional = Optional.ofNullable(text) - - fun array(): Optional> = - Optional.ofNullable(array) - - fun isText(): Boolean = text != null - - fun isArray(): Boolean = array != null - - fun asText(): String = text.getOrThrow("text") - - fun asArray(): List = array.getOrThrow("array") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (text == null && array == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - } - - override fun toString(): String { - return when { - text != null -> "Content{text=$text}" - array != null -> "Content{array=$array}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofText(text: String) = Content(text = text) - - @JvmStatic - fun ofArray(array: List) = - Content(array = array) - } - - interface Visitor { - - fun visitText(text: String): T - - fun visitArray(array: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>() - ) - ?.let { - return Content(array = it, _json = json) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) - @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( - private val chatCompletionContentPartText: - ChatCompletionContentPartText? = - null, - private val chatCompletionContentPartImage: - ChatCompletionContentPartImage? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): - Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): - Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = - chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = - chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow( - "chatCompletionContentPartText" - ) - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow( - "chatCompletionContentPartImage" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText( - chatCompletionContentPartText - ) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage( - chatCompletionContentPartImage - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && - chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = - chatCompletionContentPartText - ) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = - chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize( - node, - jacksonTypeRef() - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize( - node, - jacksonTypeRef() - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject( - value.chatCompletionContentPartText - ) - value.chatCompletionContentPartImage != null -> - generator.writeObject( - value.chatCompletionContentPartImage - ) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) - } - } - } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true From 711a5bcf08739214cb62ef99a8de9e267c7afb34 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:24:06 +0000 Subject: [PATCH 28/87] feat(api): manual updates (#96) --- .../api/models/ChatCompletionMessage.kt | 1395 ++++++++++++++++ .../api/models/FunctionInvokeParams.kt | 1396 +--------------- .../braintrustdata/api/models/PromptData.kt | 1411 +---------------- .../api/models/FunctionInvokeParamsTest.kt | 18 +- .../services/blocking/FunctionServiceTest.kt | 6 +- 5 files changed, 1422 insertions(+), 2804 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessage.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessage.kt new file mode 100644 index 00000000..9ea2097b --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessage.kt @@ -0,0 +1,1395 @@ +// File generated from our OpenAPI spec by Stainless. + +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 +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.getOrThrow +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 +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = ChatCompletionMessage.Deserializer::class) +@JsonSerialize(using = ChatCompletionMessage.Serializer::class) +class ChatCompletionMessage +private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionMessage = apply { + if (!validated) { + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown ChatCompletionMessage: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionMessage && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ + } + + override fun toString(): String { + return when { + system != null -> "ChatCompletionMessage{system=$system}" + user != null -> "ChatCompletionMessage{user=$user}" + assistant != null -> "ChatCompletionMessage{assistant=$assistant}" + tool != null -> "ChatCompletionMessage{tool=$tool}" + function != null -> "ChatCompletionMessage{function=$function}" + fallback != null -> "ChatCompletionMessage{fallback=$fallback}" + _json != null -> "ChatCompletionMessage{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionMessage") + } + } + + companion object { + + @JvmStatic fun ofSystem(system: System) = ChatCompletionMessage(system = system) + + @JvmStatic fun ofUser(user: User) = ChatCompletionMessage(user = user) + + @JvmStatic + fun ofAssistant(assistant: Assistant) = ChatCompletionMessage(assistant = assistant) + + @JvmStatic fun ofTool(tool: Tool) = ChatCompletionMessage(tool = tool) + + @JvmStatic fun ofFunction(function: Function) = ChatCompletionMessage(function = function) + + @JvmStatic fun ofFallback(fallback: Fallback) = ChatCompletionMessage(fallback = fallback) + } + + interface Visitor { + + fun visitSystem(system: System): T + + fun visitUser(user: User): T + + fun visitAssistant(assistant: Assistant): T + + fun visitTool(tool: Tool): T + + fun visitFunction(function: Function): T + + fun visitFallback(fallback: Fallback): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ChatCompletionMessage: $json") + } + } + + class Deserializer : BaseDeserializer(ChatCompletionMessage::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionMessage { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionMessage(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionMessage(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionMessage(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionMessage(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionMessage(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ChatCompletionMessage(fallback = it, _json = json) + } + + return ChatCompletionMessage(_json = json) + } + } + + class Serializer : BaseSerializer(ChatCompletionMessage::class) { + + override fun serialize( + value: ChatCompletionMessage, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionMessage") + } + } + } + + @JsonDeserialize(builder = System.Builder::class) + @NoAutoDetect + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): System = apply { + if (!validated) { + content() + role() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): System = + System( + content, + role, + name, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SYSTEM = Role(JsonField.of("system")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + SYSTEM, + } + + enum class Value { + SYSTEM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = User.Builder::class) + @NoAutoDetect + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): User = apply { + if (!validated) { + content() + role() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) + } + + fun content(content: ChatCompletionContent) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { + this.content = content + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): User = + User( + content, + role, + name, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USER = Role(JsonField.of("user")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + USER, + } + + enum class Value { + USER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USER -> Known.USER + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Assistant.Builder::class) + @NoAutoDetect + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun role(): Role = role.getRequired("role") + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Assistant = apply { + if (!validated) { + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var role: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var toolCalls: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + + @JsonProperty("function_call") + @ExcludeMissing + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) + + @JsonProperty("tool_calls") + @ExcludeMissing + fun toolCalls(toolCalls: JsonField>) = apply { + this.toolCalls = toolCalls + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ASSISTANT = Role(JsonField.of("assistant")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + ASSISTANT, + } + + enum class Value { + ASSISTANT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = FunctionCall.Builder::class) + @NoAutoDetect + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun arguments(): String = arguments.getRequired("arguments") + + fun name(): String = name.getRequired("name") + + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FunctionCall = apply { + if (!validated) { + arguments() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionCall: FunctionCall) = apply { + this.arguments = functionCall.arguments + this.name = functionCall.name + additionalProperties(functionCall.additionalProperties) + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + @JsonProperty("arguments") + @ExcludeMissing + fun arguments(arguments: JsonField) = apply { this.arguments = arguments } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Tool.Builder::class) + @NoAutoDetect + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Tool = apply { + if (!validated) { + content() + role() + toolCallId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var toolCallId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + + @JsonProperty("tool_call_id") + @ExcludeMissing + fun toolCallId(toolCallId: JsonField) = apply { this.toolCallId = toolCallId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TOOL = Role(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + TOOL, + } + + enum class Value { + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + fun name(): String = name.getRequired("name") + + fun role(): Role = role.getRequired("role") + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + content() + name() + role() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Role(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Fallback.Builder::class) + @NoAutoDetect + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun role(): Role = role.getRequired("role") + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Fallback = apply { + if (!validated) { + role() + content() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var role: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MODEL = Role(JsonField.of("model")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + MODEL, + } + + enum class Value { + MODEL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 963e7921..3eca674b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -34,7 +34,7 @@ class FunctionInvokeParams constructor( private val functionId: String, private val input: JsonValue?, - private val messages: List?, + private val messages: List?, private val mode: Mode?, private val parent: Parent?, private val stream: Boolean?, @@ -48,7 +48,7 @@ constructor( fun input(): Optional = Optional.ofNullable(input) - fun messages(): Optional> = Optional.ofNullable(messages) + fun messages(): Optional> = Optional.ofNullable(messages) fun mode(): Optional = Optional.ofNullable(mode) @@ -88,7 +88,7 @@ constructor( class FunctionInvokeBody internal constructor( private val input: JsonValue?, - private val messages: List?, + private val messages: List?, private val mode: Mode?, private val parent: Parent?, private val stream: Boolean?, @@ -100,7 +100,7 @@ constructor( @JsonProperty("input") fun input(): JsonValue? = input /** If the function is an LLM, additional messages to pass along to it */ - @JsonProperty("messages") fun messages(): List? = messages + @JsonProperty("messages") fun messages(): List? = messages /** The mode format of the returned value (defaults to 'auto') */ @JsonProperty("mode") fun mode(): Mode? = mode @@ -131,7 +131,7 @@ constructor( class Builder { private var input: JsonValue? = null - private var messages: List? = null + private var messages: List? = null private var mode: Mode? = null private var parent: Parent? = null private var stream: Boolean? = null @@ -154,7 +154,7 @@ constructor( /** If the function is an LLM, additional messages to pass along to it */ @JsonProperty("messages") - fun messages(messages: List) = apply { this.messages = messages } + fun messages(messages: List) = apply { this.messages = messages } /** The mode format of the returned value (defaults to 'auto') */ @JsonProperty("mode") fun mode(mode: Mode) = apply { this.mode = mode } @@ -251,7 +251,7 @@ constructor( private var functionId: String? = null private var input: JsonValue? = null - private var messages: MutableList = mutableListOf() + private var messages: MutableList = mutableListOf() private var mode: Mode? = null private var parent: Parent? = null private var stream: Boolean? = null @@ -281,13 +281,13 @@ constructor( fun input(input: JsonValue) = apply { this.input = input } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: List) = apply { + fun messages(messages: List) = apply { this.messages.clear() this.messages.addAll(messages) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: Message) = apply { this.messages.add(message) } + fun addMessage(message: ChatCompletionMessage) = apply { this.messages.add(message) } /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Mode) = apply { this.mode = mode } @@ -447,1384 +447,6 @@ constructor( ) } - @JsonDeserialize(using = Message.Deserializer::class) - @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val system: System? = null, - private val user: User? = null, - private val assistant: Assistant? = null, - private val tool: Tool? = null, - private val function: Function? = null, - private val fallback: Fallback? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun system(): Optional = Optional.ofNullable(system) - - fun user(): Optional = Optional.ofNullable(user) - - fun assistant(): Optional = Optional.ofNullable(assistant) - - fun tool(): Optional = Optional.ofNullable(tool) - - fun function(): Optional = Optional.ofNullable(function) - - fun fallback(): Optional = Optional.ofNullable(fallback) - - fun isSystem(): Boolean = system != null - - fun isUser(): Boolean = user != null - - fun isAssistant(): Boolean = assistant != null - - fun isTool(): Boolean = tool != null - - fun isFunction(): Boolean = function != null - - fun isFallback(): Boolean = fallback != null - - fun asSystem(): System = system.getOrThrow("system") - - fun asUser(): User = user.getOrThrow("user") - - fun asAssistant(): Assistant = assistant.getOrThrow("assistant") - - fun asTool(): Tool = tool.getOrThrow("tool") - - fun asFunction(): Function = function.getOrThrow("function") - - fun asFallback(): Fallback = fallback.getOrThrow("fallback") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } - } - - fun validate(): Message = apply { - if (!validated) { - if ( - system == null && - user == null && - assistant == null && - tool == null && - function == null && - fallback == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - system?.validate() - user?.validate() - assistant?.validate() - tool?.validate() - function?.validate() - fallback?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Message && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ - } - - override fun toString(): String { - return when { - system != null -> "Message{system=$system}" - user != null -> "Message{user=$user}" - assistant != null -> "Message{assistant=$assistant}" - tool != null -> "Message{tool=$tool}" - function != null -> "Message{function=$function}" - fallback != null -> "Message{fallback=$fallback}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - } - - companion object { - - @JvmStatic fun ofSystem(system: System) = Message(system = system) - - @JvmStatic fun ofUser(user: User) = Message(user = user) - - @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - - @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - - @JvmStatic fun ofFunction(function: Function) = Message(function = function) - - @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) - } - - interface Visitor { - - fun visitSystem(system: System): T - - fun visitUser(user: User): T - - fun visitAssistant(assistant: Assistant): T - - fun visitTool(tool: Tool): T - - fun visitFunction(function: Function): T - - fun visitFallback(fallback: Fallback): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") - } - } - - class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) - } - } - - class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - @JsonDeserialize(builder = System.Builder::class) - @NoAutoDetect - class System - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): System = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(system: System) = apply { - this.content = system.content - this.role = system.role - this.name = system.name - additionalProperties(system.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): System = - System( - content, - role, - name, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SYSTEM = Role(JsonField.of("system")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - SYSTEM, - } - - enum class Value { - SYSTEM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = User.Builder::class) - @NoAutoDetect - class User - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): User = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(user: User) = apply { - this.content = user.content - this.role = user.role - this.name = user.name - additionalProperties(user.additionalProperties) - } - - fun content(content: ChatCompletionContent) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): User = - User( - content, - role, - name, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USER = Role(JsonField.of("user")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - USER, - } - - enum class Value { - USER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Assistant.Builder::class) - @NoAutoDetect - class Assistant - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Assistant = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(assistant: Assistant) = apply { - this.role = assistant.role - this.content = assistant.content - this.functionCall = assistant.functionCall - this.name = assistant.name - this.toolCalls = assistant.toolCalls - additionalProperties(assistant.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) - - @JsonProperty("tool_calls") - @ExcludeMissing - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Assistant = - Assistant( - role, - content, - functionCall, - name, - toolCalls.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - ASSISTANT, - } - - enum class Value { - ASSISTANT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = FunctionCall.Builder::class) - @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) - } - - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Tool.Builder::class) - @NoAutoDetect - class Tool - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun toolCallId(): Optional = - Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Tool = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tool: Tool) = apply { - this.content = tool.content - this.role = tool.role - this.toolCallId = tool.toolCallId - additionalProperties(tool.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - - @JsonProperty("tool_call_id") - @ExcludeMissing - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Tool = - Tool( - content, - role, - toolCallId, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TOOL = Role(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - TOOL, - } - - enum class Value { - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - fun name(): String = name.getRequired("name") - - fun role(): Role = role.getRequired("role") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Function = apply { - if (!validated) { - content() - name() - role() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.content = function.content - this.name = function.name - this.role = function.role - additionalProperties(function.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function( - content, - name, - role, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Role(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Fallback.Builder::class) - @NoAutoDetect - class Fallback - private constructor( - private val role: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Fallback = apply { - if (!validated) { - role() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fallback: Fallback) = apply { - this.role = fallback.role - this.content = fallback.content - additionalProperties(fallback.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Fallback = - Fallback( - role, - content, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val MODEL = Role(JsonField.of("model")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - MODEL, - } - - enum class Value { - MODEL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" - } - } - class Mode @JsonCreator private constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 2c59e71c..5a97f923 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -834,7 +834,7 @@ private constructor( class Chat private constructor( private val type: JsonField, - private val messages: JsonField>, + private val messages: JsonField>, private val tools: JsonField, private val additionalProperties: Map, ) { @@ -843,7 +843,7 @@ private constructor( fun type(): Type = type.getRequired("type") - fun messages(): List = messages.getRequired("messages") + fun messages(): List = messages.getRequired("messages") fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) @@ -876,7 +876,7 @@ private constructor( class Builder { private var type: JsonField = JsonMissing.of() - private var messages: JsonField> = JsonMissing.of() + private var messages: JsonField> = JsonMissing.of() private var tools: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -894,11 +894,12 @@ private constructor( @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } - fun messages(messages: List) = messages(JsonField.of(messages)) + fun messages(messages: List) = + messages(JsonField.of(messages)) @JsonProperty("messages") @ExcludeMissing - fun messages(messages: JsonField>) = apply { + fun messages(messages: JsonField>) = apply { this.messages = messages } @@ -932,1406 +933,6 @@ private constructor( ) } - @JsonDeserialize(using = Message.Deserializer::class) - @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val system: System? = null, - private val user: User? = null, - private val assistant: Assistant? = null, - private val tool: Tool? = null, - private val function: Function? = null, - private val fallback: Fallback? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun system(): Optional = Optional.ofNullable(system) - - fun user(): Optional = Optional.ofNullable(user) - - fun assistant(): Optional = Optional.ofNullable(assistant) - - fun tool(): Optional = Optional.ofNullable(tool) - - fun function(): Optional = Optional.ofNullable(function) - - fun fallback(): Optional = Optional.ofNullable(fallback) - - fun isSystem(): Boolean = system != null - - fun isUser(): Boolean = user != null - - fun isAssistant(): Boolean = assistant != null - - fun isTool(): Boolean = tool != null - - fun isFunction(): Boolean = function != null - - fun isFallback(): Boolean = fallback != null - - fun asSystem(): System = system.getOrThrow("system") - - fun asUser(): User = user.getOrThrow("user") - - fun asAssistant(): Assistant = assistant.getOrThrow("assistant") - - fun asTool(): Tool = tool.getOrThrow("tool") - - fun asFunction(): Function = function.getOrThrow("function") - - fun asFallback(): Fallback = fallback.getOrThrow("fallback") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } - } - - fun validate(): Message = apply { - if (!validated) { - if ( - system == null && - user == null && - assistant == null && - tool == null && - function == null && - fallback == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - system?.validate() - user?.validate() - assistant?.validate() - tool?.validate() - function?.validate() - fallback?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Message && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ - } - - override fun toString(): String { - return when { - system != null -> "Message{system=$system}" - user != null -> "Message{user=$user}" - assistant != null -> "Message{assistant=$assistant}" - tool != null -> "Message{tool=$tool}" - function != null -> "Message{function=$function}" - fallback != null -> "Message{fallback=$fallback}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - } - - companion object { - - @JvmStatic fun ofSystem(system: System) = Message(system = system) - - @JvmStatic fun ofUser(user: User) = Message(user = user) - - @JvmStatic - fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - - @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - - @JvmStatic fun ofFunction(function: Function) = Message(function = function) - - @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) - } - - interface Visitor { - - fun visitSystem(system: System): T - - fun visitUser(user: User): T - - fun visitAssistant(assistant: Assistant): T - - fun visitTool(tool: Tool): T - - fun visitFunction(function: Function): T - - fun visitFallback(fallback: Fallback): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") - } - } - - class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) - } - } - - class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - @JsonDeserialize(builder = System.Builder::class) - @NoAutoDetect - class System - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): System = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(system: System) = apply { - this.content = system.content - this.role = system.role - this.name = system.name - additionalProperties(system.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): System = - System( - content, - role, - name, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SYSTEM = Role(JsonField.of("system")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - SYSTEM, - } - - enum class Value { - SYSTEM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = User.Builder::class) - @NoAutoDetect - class User - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): User = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(user: User) = apply { - this.content = user.content - this.role = user.role - this.name = user.name - additionalProperties(user.additionalProperties) - } - - fun content(content: ChatCompletionContent) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): User = - User( - content, - role, - name, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USER = Role(JsonField.of("user")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - USER, - } - - enum class Value { - USER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Assistant.Builder::class) - @NoAutoDetect - class Assistant - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("function_call") - @ExcludeMissing - fun _functionCall() = functionCall - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Assistant = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = - JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(assistant: Assistant) = apply { - this.role = assistant.role - this.content = assistant.content - this.functionCall = assistant.functionCall - this.name = assistant.name - this.toolCalls = assistant.toolCalls - additionalProperties(assistant.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) - - @JsonProperty("tool_calls") - @ExcludeMissing - fun toolCalls(toolCalls: JsonField>) = - apply { - this.toolCalls = toolCalls - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Assistant = - Assistant( - role, - content, - functionCall, - name, - toolCalls.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - ASSISTANT, - } - - enum class Value { - ASSISTANT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = FunctionCall.Builder::class) - @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) - } - - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Tool.Builder::class) - @NoAutoDetect - class Tool - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun toolCallId(): Optional = - Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Tool = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tool: Tool) = apply { - this.content = tool.content - this.role = tool.role - this.toolCallId = tool.toolCallId - additionalProperties(tool.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - - @JsonProperty("tool_call_id") - @ExcludeMissing - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Tool = - Tool( - content, - role, - toolCallId, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TOOL = Role(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - TOOL, - } - - enum class Value { - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun name(): String = name.getRequired("name") - - fun role(): Role = role.getRequired("role") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Function = apply { - if (!validated) { - content() - name() - role() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.content = function.content - this.name = function.name - this.role = function.role - additionalProperties(function.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Function = - Function( - content, - name, - role, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Role(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Fallback.Builder::class) - @NoAutoDetect - class Fallback - private constructor( - private val role: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Fallback = apply { - if (!validated) { - role() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(fallback: Fallback) = apply { - this.role = fallback.role - this.content = fallback.content - additionalProperties(fallback.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Fallback = - Fallback( - role, - content, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val MODEL = Role(JsonField.of("model")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - MODEL, - } - - enum class Value { - MODEL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" - } - } - class Type @JsonCreator private constructor( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index 8b261382..9b325c6e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -16,9 +16,9 @@ class FunctionInvokeParamsTest { .input(JsonNull.of()) .messages( listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + ChatCompletionMessage.ofSystem( + ChatCompletionMessage.System.builder() + .role(ChatCompletionMessage.System.Role.SYSTEM) .content("content") .name("name") .build() @@ -60,9 +60,9 @@ class FunctionInvokeParamsTest { .input(JsonNull.of()) .messages( listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + ChatCompletionMessage.ofSystem( + ChatCompletionMessage.System.builder() + .role(ChatCompletionMessage.System.Role.SYSTEM) .content("content") .name("name") .build() @@ -101,9 +101,9 @@ class FunctionInvokeParamsTest { assertThat(body.messages()) .isEqualTo( listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + ChatCompletionMessage.ofSystem( + ChatCompletionMessage.System.builder() + .role(ChatCompletionMessage.System.Role.SYSTEM) .content("content") .name("name") .build() 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 e2606aa4..ab2695f4 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 @@ -338,9 +338,9 @@ class FunctionServiceTest { .input(JsonNull.of()) .messages( listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + ChatCompletionMessage.ofSystem( + ChatCompletionMessage.System.builder() + .role(ChatCompletionMessage.System.Role.SYSTEM) .content("content") .name("name") .build() From f229777ec23714e3e3adfdb6678cffccb13a89f9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:47:30 +0000 Subject: [PATCH 29/87] feat(api): manual updates (#97) --- .stats.yml | 2 +- .../api/models/ChatCompletionContent.kt | 160 ++ .../api/models/ChatCompletionContentPart.kt | 166 -- .../api/models/ChatCompletionMessage.kt | 1395 ---------------- .../api/models/FunctionInvokeParams.kt | 1396 +++++++++++++++- .../braintrustdata/api/models/PromptData.kt | 1411 ++++++++++++++++- .../api/models/FunctionInvokeParamsTest.kt | 18 +- .../services/blocking/FunctionServiceTest.kt | 6 +- 8 files changed, 2965 insertions(+), 1589 deletions(-) delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessage.kt diff --git a/.stats.yml b/.stats.yml index 3eace990..308af69e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-b503b10818f249e17a802c508900e3f53726e436dcf84cc39335c2de6e369d8c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-55d937fb23d3c593f54056e8ed9bcd9949b7f234649bc23e5c615e85b4309bb3.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt index 6d477739..97e38a9a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt @@ -130,4 +130,164 @@ private constructor( } } } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, + private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if ( + chatCompletionContentPartText == null && chatCompletionContentPartImage == null + ) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = + ChatCompletionContentPart( + chatCompletionContentPartText = chatCompletionContentPartText + ) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") + } + } + + class Deserializer : + BaseDeserializer(ChatCompletionContentPart::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer(ChatCompletionContentPart::class) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject(value.chatCompletionContentPartText) + value.chatCompletionContentPartImage != null -> + generator.writeObject(value.chatCompletionContentPartImage) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + } + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt deleted file mode 100644 index 35a3f312..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPart.kt +++ /dev/null @@ -1,166 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) -@JsonSerialize(using = ChatCompletionContentPart.Serializer::class) -class ChatCompletionContentPart -private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if (chatCompletionContentPartText == null && chatCompletionContentPartImage == null) { - throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $_json") - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = ChatCompletionContentPart(chatCompletionContentPartText = chatCompletionContentPartText) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") - } - } - - class Deserializer : - BaseDeserializer(ChatCompletionContentPart::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : BaseSerializer(ChatCompletionContentPart::class) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessage.kt deleted file mode 100644 index 9ea2097b..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessage.kt +++ /dev/null @@ -1,1395 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -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 -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(using = ChatCompletionMessage.Deserializer::class) -@JsonSerialize(using = ChatCompletionMessage.Serializer::class) -class ChatCompletionMessage -private constructor( - private val system: System? = null, - private val user: User? = null, - private val assistant: Assistant? = null, - private val tool: Tool? = null, - private val function: Function? = null, - private val fallback: Fallback? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun system(): Optional = Optional.ofNullable(system) - - fun user(): Optional = Optional.ofNullable(user) - - fun assistant(): Optional = Optional.ofNullable(assistant) - - fun tool(): Optional = Optional.ofNullable(tool) - - fun function(): Optional = Optional.ofNullable(function) - - fun fallback(): Optional = Optional.ofNullable(fallback) - - fun isSystem(): Boolean = system != null - - fun isUser(): Boolean = user != null - - fun isAssistant(): Boolean = assistant != null - - fun isTool(): Boolean = tool != null - - fun isFunction(): Boolean = function != null - - fun isFallback(): Boolean = fallback != null - - fun asSystem(): System = system.getOrThrow("system") - - fun asUser(): User = user.getOrThrow("user") - - fun asAssistant(): Assistant = assistant.getOrThrow("assistant") - - fun asTool(): Tool = tool.getOrThrow("tool") - - fun asFunction(): Function = function.getOrThrow("function") - - fun asFallback(): Fallback = fallback.getOrThrow("fallback") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionMessage = apply { - if (!validated) { - if ( - system == null && - user == null && - assistant == null && - tool == null && - function == null && - fallback == null - ) { - throw BraintrustInvalidDataException("Unknown ChatCompletionMessage: $_json") - } - system?.validate() - user?.validate() - assistant?.validate() - tool?.validate() - function?.validate() - fallback?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionMessage && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ - } - - override fun toString(): String { - return when { - system != null -> "ChatCompletionMessage{system=$system}" - user != null -> "ChatCompletionMessage{user=$user}" - assistant != null -> "ChatCompletionMessage{assistant=$assistant}" - tool != null -> "ChatCompletionMessage{tool=$tool}" - function != null -> "ChatCompletionMessage{function=$function}" - fallback != null -> "ChatCompletionMessage{fallback=$fallback}" - _json != null -> "ChatCompletionMessage{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionMessage") - } - } - - companion object { - - @JvmStatic fun ofSystem(system: System) = ChatCompletionMessage(system = system) - - @JvmStatic fun ofUser(user: User) = ChatCompletionMessage(user = user) - - @JvmStatic - fun ofAssistant(assistant: Assistant) = ChatCompletionMessage(assistant = assistant) - - @JvmStatic fun ofTool(tool: Tool) = ChatCompletionMessage(tool = tool) - - @JvmStatic fun ofFunction(function: Function) = ChatCompletionMessage(function = function) - - @JvmStatic fun ofFallback(fallback: Fallback) = ChatCompletionMessage(fallback = fallback) - } - - interface Visitor { - - fun visitSystem(system: System): T - - fun visitUser(user: User): T - - fun visitAssistant(assistant: Assistant): T - - fun visitTool(tool: Tool): T - - fun visitFunction(function: Function): T - - fun visitFallback(fallback: Fallback): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionMessage: $json") - } - } - - class Deserializer : BaseDeserializer(ChatCompletionMessage::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionMessage { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionMessage(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionMessage(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionMessage(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionMessage(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionMessage(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ChatCompletionMessage(fallback = it, _json = json) - } - - return ChatCompletionMessage(_json = json) - } - } - - class Serializer : BaseSerializer(ChatCompletionMessage::class) { - - override fun serialize( - value: ChatCompletionMessage, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionMessage") - } - } - } - - @JsonDeserialize(builder = System.Builder::class) - @NoAutoDetect - class System - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): System = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(system: System) = apply { - this.content = system.content - this.role = system.role - this.name = system.name - additionalProperties(system.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): System = - System( - content, - role, - name, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val SYSTEM = Role(JsonField.of("system")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - SYSTEM, - } - - enum class Value { - SYSTEM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = User.Builder::class) - @NoAutoDetect - class User - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): User = apply { - if (!validated) { - content() - role() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(user: User) = apply { - this.content = user.content - this.role = user.role - this.name = user.name - additionalProperties(user.additionalProperties) - } - - fun content(content: ChatCompletionContent) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): User = - User( - content, - role, - name, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val USER = Role(JsonField.of("user")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - USER, - } - - enum class Value { - USER, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Assistant.Builder::class) - @NoAutoDetect - class Assistant - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Assistant = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(assistant: Assistant) = apply { - this.role = assistant.role - this.content = assistant.content - this.functionCall = assistant.functionCall - this.name = assistant.name - this.toolCalls = assistant.toolCalls - additionalProperties(assistant.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) - - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) - - @JsonProperty("tool_calls") - @ExcludeMissing - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Assistant = - Assistant( - role, - content, - functionCall, - name, - toolCalls.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - ASSISTANT, - } - - enum class Value { - ASSISTANT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = FunctionCall.Builder::class) - @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun arguments(): String = arguments.getRequired("arguments") - - fun name(): String = name.getRequired("name") - - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) - } - - fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - - @JsonProperty("arguments") - @ExcludeMissing - fun arguments(arguments: JsonField) = apply { this.arguments = arguments } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Tool.Builder::class) - @NoAutoDetect - class Tool - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - fun role(): Role = role.getRequired("role") - - fun toolCallId(): Optional = - Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Tool = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tool: Tool) = apply { - this.content = tool.content - this.role = tool.role - this.toolCallId = tool.toolCallId - additionalProperties(tool.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - - @JsonProperty("tool_call_id") - @ExcludeMissing - fun toolCallId(toolCallId: JsonField) = apply { this.toolCallId = toolCallId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Tool = - Tool( - content, - role, - toolCallId, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val TOOL = Role(JsonField.of("tool")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - TOOL, - } - - enum class Value { - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Function.Builder::class) - @NoAutoDetect - class Function - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - fun name(): String = name.getRequired("name") - - fun role(): Role = role.getRequired("role") - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Function = apply { - if (!validated) { - content() - name() - role() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(function: Function) = apply { - this.content = function.content - this.name = function.name - this.role = function.role - additionalProperties(function.additionalProperties) - } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Function = - Function( - content, - name, - role, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val FUNCTION = Role(JsonField.of("function")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - FUNCTION, - } - - enum class Value { - FUNCTION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Fallback.Builder::class) - @NoAutoDetect - class Fallback - private constructor( - private val role: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun role(): Role = role.getRequired("role") - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - @JsonProperty("role") @ExcludeMissing fun _role() = role - - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Fallback = apply { - if (!validated) { - role() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fallback: Fallback) = apply { - this.role = fallback.role - this.content = fallback.content - additionalProperties(fallback.additionalProperties) - } - - fun role(role: Role) = role(JsonField.of(role)) - - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Fallback = - Fallback( - role, - content, - additionalProperties.toImmutable(), - ) - } - - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val MODEL = Role(JsonField.of("model")) - - @JvmStatic fun of(value: String) = Role(JsonField.of(value)) - } - - enum class Known { - MODEL, - } - - enum class Value { - MODEL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 3eca674b..963e7921 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -34,7 +34,7 @@ class FunctionInvokeParams constructor( private val functionId: String, private val input: JsonValue?, - private val messages: List?, + private val messages: List?, private val mode: Mode?, private val parent: Parent?, private val stream: Boolean?, @@ -48,7 +48,7 @@ constructor( fun input(): Optional = Optional.ofNullable(input) - fun messages(): Optional> = Optional.ofNullable(messages) + fun messages(): Optional> = Optional.ofNullable(messages) fun mode(): Optional = Optional.ofNullable(mode) @@ -88,7 +88,7 @@ constructor( class FunctionInvokeBody internal constructor( private val input: JsonValue?, - private val messages: List?, + private val messages: List?, private val mode: Mode?, private val parent: Parent?, private val stream: Boolean?, @@ -100,7 +100,7 @@ constructor( @JsonProperty("input") fun input(): JsonValue? = input /** If the function is an LLM, additional messages to pass along to it */ - @JsonProperty("messages") fun messages(): List? = messages + @JsonProperty("messages") fun messages(): List? = messages /** The mode format of the returned value (defaults to 'auto') */ @JsonProperty("mode") fun mode(): Mode? = mode @@ -131,7 +131,7 @@ constructor( class Builder { private var input: JsonValue? = null - private var messages: List? = null + private var messages: List? = null private var mode: Mode? = null private var parent: Parent? = null private var stream: Boolean? = null @@ -154,7 +154,7 @@ constructor( /** If the function is an LLM, additional messages to pass along to it */ @JsonProperty("messages") - fun messages(messages: List) = apply { this.messages = messages } + fun messages(messages: List) = apply { this.messages = messages } /** The mode format of the returned value (defaults to 'auto') */ @JsonProperty("mode") fun mode(mode: Mode) = apply { this.mode = mode } @@ -251,7 +251,7 @@ constructor( private var functionId: String? = null private var input: JsonValue? = null - private var messages: MutableList = mutableListOf() + private var messages: MutableList = mutableListOf() private var mode: Mode? = null private var parent: Parent? = null private var stream: Boolean? = null @@ -281,13 +281,13 @@ constructor( fun input(input: JsonValue) = apply { this.input = input } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: List) = apply { + fun messages(messages: List) = apply { this.messages.clear() this.messages.addAll(messages) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: ChatCompletionMessage) = apply { this.messages.add(message) } + fun addMessage(message: Message) = apply { this.messages.add(message) } /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Mode) = apply { this.mode = mode } @@ -447,6 +447,1384 @@ constructor( ) } + @JsonDeserialize(using = Message.Deserializer::class) + @JsonSerialize(using = Message.Serializer::class) + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } + } + + fun validate(): Message = apply { + if (!validated) { + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Message && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ + } + + override fun toString(): String { + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } + } + + companion object { + + @JvmStatic fun ofSystem(system: System) = Message(system = system) + + @JvmStatic fun ofUser(user: User) = Message(user = user) + + @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) + + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) + + @JvmStatic fun ofFunction(function: Function) = Message(function = function) + + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + } + + interface Visitor { + + fun visitSystem(system: System): T + + fun visitUser(user: User): T + + fun visitAssistant(assistant: Assistant): T + + fun visitTool(tool: Tool): T + + fun visitFunction(function: Function): T + + fun visitFallback(fallback: Fallback): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Message: $json") + } + } + + class Deserializer : BaseDeserializer(Message::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Message { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) + } + } + + class Serializer : BaseSerializer(Message::class) { + + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } + } + } + + @JsonDeserialize(builder = System.Builder::class) + @NoAutoDetect + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): System = apply { + if (!validated) { + content() + role() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): System = + System( + content, + role, + name, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SYSTEM = Role(JsonField.of("system")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + SYSTEM, + } + + enum class Value { + SYSTEM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = User.Builder::class) + @NoAutoDetect + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): User = apply { + if (!validated) { + content() + role() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) + } + + fun content(content: ChatCompletionContent) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { + this.content = content + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): User = + User( + content, + role, + name, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USER = Role(JsonField.of("user")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + USER, + } + + enum class Value { + USER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USER -> Known.USER + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Assistant.Builder::class) + @NoAutoDetect + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun role(): Role = role.getRequired("role") + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Assistant = apply { + if (!validated) { + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var role: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var toolCalls: JsonField> = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) + + @JsonProperty("function_call") + @ExcludeMissing + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) + + @JsonProperty("tool_calls") + @ExcludeMissing + fun toolCalls(toolCalls: JsonField>) = apply { + this.toolCalls = toolCalls + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ASSISTANT = Role(JsonField.of("assistant")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + ASSISTANT, + } + + enum class Value { + ASSISTANT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = FunctionCall.Builder::class) + @NoAutoDetect + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun arguments(): String = arguments.getRequired("arguments") + + fun name(): String = name.getRequired("name") + + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FunctionCall = apply { + if (!validated) { + arguments() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(functionCall: FunctionCall) = apply { + this.arguments = functionCall.arguments + this.name = functionCall.name + additionalProperties(functionCall.additionalProperties) + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + @JsonProperty("arguments") + @ExcludeMissing + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Tool.Builder::class) + @NoAutoDetect + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Tool = apply { + if (!validated) { + content() + role() + toolCallId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var toolCallId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + + @JsonProperty("tool_call_id") + @ExcludeMissing + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TOOL = Role(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + TOOL, + } + + enum class Value { + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + fun name(): String = name.getRequired("name") + + fun role(): Role = role.getRequired("role") + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + content() + name() + role() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Role(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Fallback.Builder::class) + @NoAutoDetect + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun role(): Role = role.getRequired("role") + + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Fallback = apply { + if (!validated) { + role() + content() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var role: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MODEL = Role(JsonField.of("model")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + MODEL, + } + + enum class Value { + MODEL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + } + } + class Mode @JsonCreator private constructor( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 5a97f923..2c59e71c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -834,7 +834,7 @@ private constructor( class Chat private constructor( private val type: JsonField, - private val messages: JsonField>, + private val messages: JsonField>, private val tools: JsonField, private val additionalProperties: Map, ) { @@ -843,7 +843,7 @@ private constructor( fun type(): Type = type.getRequired("type") - fun messages(): List = messages.getRequired("messages") + fun messages(): List = messages.getRequired("messages") fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) @@ -876,7 +876,7 @@ private constructor( class Builder { private var type: JsonField = JsonMissing.of() - private var messages: JsonField> = JsonMissing.of() + private var messages: JsonField> = JsonMissing.of() private var tools: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -894,12 +894,11 @@ private constructor( @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } - fun messages(messages: List) = - messages(JsonField.of(messages)) + fun messages(messages: List) = messages(JsonField.of(messages)) @JsonProperty("messages") @ExcludeMissing - fun messages(messages: JsonField>) = apply { + fun messages(messages: JsonField>) = apply { this.messages = messages } @@ -933,6 +932,1406 @@ private constructor( ) } + @JsonDeserialize(using = Message.Deserializer::class) + @JsonSerialize(using = Message.Serializer::class) + class Message + private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun system(): Optional = Optional.ofNullable(system) + + fun user(): Optional = Optional.ofNullable(user) + + fun assistant(): Optional = Optional.ofNullable(assistant) + + fun tool(): Optional = Optional.ofNullable(tool) + + fun function(): Optional = Optional.ofNullable(function) + + fun fallback(): Optional = Optional.ofNullable(fallback) + + fun isSystem(): Boolean = system != null + + fun isUser(): Boolean = user != null + + fun isAssistant(): Boolean = assistant != null + + fun isTool(): Boolean = tool != null + + fun isFunction(): Boolean = function != null + + fun isFallback(): Boolean = fallback != null + + fun asSystem(): System = system.getOrThrow("system") + + fun asUser(): User = user.getOrThrow("user") + + fun asAssistant(): Assistant = assistant.getOrThrow("assistant") + + fun asTool(): Tool = tool.getOrThrow("tool") + + fun asFunction(): Function = function.getOrThrow("function") + + fun asFallback(): Fallback = fallback.getOrThrow("fallback") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } + } + + fun validate(): Message = apply { + if (!validated) { + if ( + system == null && + user == null && + assistant == null && + tool == null && + function == null && + fallback == null + ) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Message && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ + } + + override fun toString(): String { + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } + } + + companion object { + + @JvmStatic fun ofSystem(system: System) = Message(system = system) + + @JvmStatic fun ofUser(user: User) = Message(user = user) + + @JvmStatic + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) + + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) + + @JvmStatic fun ofFunction(function: Function) = Message(function = function) + + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + } + + interface Visitor { + + fun visitSystem(system: System): T + + fun visitUser(user: User): T + + fun visitAssistant(assistant: Assistant): T + + fun visitTool(tool: Tool): T + + fun visitFunction(function: Function): T + + fun visitFallback(fallback: Fallback): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Message: $json") + } + } + + class Deserializer : BaseDeserializer(Message::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Message { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) + } + } + + class Serializer : BaseSerializer(Message::class) { + + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } + } + } + + @JsonDeserialize(builder = System.Builder::class) + @NoAutoDetect + class System + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): System = apply { + if (!validated) { + content() + role() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(system: System) = apply { + this.content = system.content + this.role = system.role + this.name = system.name + additionalProperties(system.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): System = + System( + content, + role, + name, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SYSTEM = Role(JsonField.of("system")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + SYSTEM, + } + + enum class Value { + SYSTEM, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SYSTEM -> Known.SYSTEM + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = User.Builder::class) + @NoAutoDetect + class User + private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): User = apply { + if (!validated) { + content() + role() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(user: User) = apply { + this.content = user.content + this.role = user.role + this.name = user.name + additionalProperties(user.additionalProperties) + } + + fun content(content: ChatCompletionContent) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { + this.content = content + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): User = + User( + content, + role, + name, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val USER = Role(JsonField.of("user")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + USER, + } + + enum class Value { + USER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + USER -> Known.USER + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Assistant.Builder::class) + @NoAutoDetect + class Assistant + private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun role(): Role = role.getRequired("role") + + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) + + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("function_call") + @ExcludeMissing + fun _functionCall() = functionCall + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Assistant = apply { + if (!validated) { + role() + content() + functionCall().map { it.validate() } + name() + toolCalls().map { it.forEach { it.validate() } } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var role: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var toolCalls: JsonField> = + JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(assistant: Assistant) = apply { + this.role = assistant.role + this.content = assistant.content + this.functionCall = assistant.functionCall + this.name = assistant.name + this.toolCalls = assistant.toolCalls + additionalProperties(assistant.additionalProperties) + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) + + @JsonProperty("function_call") + @ExcludeMissing + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun toolCalls(toolCalls: List) = + toolCalls(JsonField.of(toolCalls)) + + @JsonProperty("tool_calls") + @ExcludeMissing + fun toolCalls(toolCalls: JsonField>) = + apply { + this.toolCalls = toolCalls + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Assistant = + Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ASSISTANT = Role(JsonField.of("assistant")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + ASSISTANT, + } + + enum class Value { + ASSISTANT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ASSISTANT -> Known.ASSISTANT + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = FunctionCall.Builder::class) + @NoAutoDetect + class FunctionCall + private constructor( + private val arguments: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun arguments(): String = arguments.getRequired("arguments") + + fun name(): String = name.getRequired("name") + + @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FunctionCall = apply { + if (!validated) { + arguments() + name() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var arguments: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(functionCall: FunctionCall) = apply { + this.arguments = functionCall.arguments + this.name = functionCall.name + additionalProperties(functionCall.additionalProperties) + } + + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + + @JsonProperty("arguments") + @ExcludeMissing + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): FunctionCall = + FunctionCall( + arguments, + name, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Tool.Builder::class) + @NoAutoDetect + class Tool + private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) + + fun role(): Role = role.getRequired("role") + + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Tool = apply { + if (!validated) { + content() + role() + toolCallId() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var toolCallId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tool: Tool) = apply { + this.content = tool.content + this.role = tool.role + this.toolCallId = tool.toolCallId + additionalProperties(tool.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + + @JsonProperty("tool_call_id") + @ExcludeMissing + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Tool = + Tool( + content, + role, + toolCallId, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TOOL = Role(JsonField.of("tool")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + TOOL, + } + + enum class Value { + TOOL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Function.Builder::class) + @NoAutoDetect + class Function + private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) + + fun name(): String = name.getRequired("name") + + fun role(): Role = role.getRequired("role") + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonProperty("name") @ExcludeMissing fun _name() = name + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Function = apply { + if (!validated) { + content() + name() + role() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var content: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(function: Function) = apply { + this.content = function.content + this.name = function.name + this.role = function.role + additionalProperties(function.additionalProperties) + } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun name(name: String) = name(JsonField.of(name)) + + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Function = + Function( + content, + name, + role, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val FUNCTION = Role(JsonField.of("function")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + FUNCTION, + } + + enum class Value { + FUNCTION, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = Fallback.Builder::class) + @NoAutoDetect + class Fallback + private constructor( + private val role: JsonField, + private val content: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun role(): Role = role.getRequired("role") + + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) + + @JsonProperty("role") @ExcludeMissing fun _role() = role + + @JsonProperty("content") @ExcludeMissing fun _content() = content + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Fallback = apply { + if (!validated) { + role() + content() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var role: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(fallback: Fallback) = apply { + this.role = fallback.role + this.content = fallback.content + additionalProperties(fallback.additionalProperties) + } + + fun role(role: Role) = role(JsonField.of(role)) + + @JsonProperty("role") + @ExcludeMissing + fun role(role: JsonField) = apply { this.role = role } + + fun content(content: String) = content(JsonField.of(content)) + + @JsonProperty("content") + @ExcludeMissing + fun content(content: JsonField) = apply { this.content = content } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Fallback = + Fallback( + role, + content, + additionalProperties.toImmutable(), + ) + } + + class Role + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MODEL = Role(JsonField.of("model")) + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + enum class Known { + MODEL, + } + + enum class Value { + MODEL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MODEL -> Known.MODEL + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + } + } + class Type @JsonCreator private constructor( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index 9b325c6e..8b261382 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -16,9 +16,9 @@ class FunctionInvokeParamsTest { .input(JsonNull.of()) .messages( listOf( - ChatCompletionMessage.ofSystem( - ChatCompletionMessage.System.builder() - .role(ChatCompletionMessage.System.Role.SYSTEM) + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) .content("content") .name("name") .build() @@ -60,9 +60,9 @@ class FunctionInvokeParamsTest { .input(JsonNull.of()) .messages( listOf( - ChatCompletionMessage.ofSystem( - ChatCompletionMessage.System.builder() - .role(ChatCompletionMessage.System.Role.SYSTEM) + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) .content("content") .name("name") .build() @@ -101,9 +101,9 @@ class FunctionInvokeParamsTest { assertThat(body.messages()) .isEqualTo( listOf( - ChatCompletionMessage.ofSystem( - ChatCompletionMessage.System.builder() - .role(ChatCompletionMessage.System.Role.SYSTEM) + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) .content("content") .name("name") .build() 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 ab2695f4..e2606aa4 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 @@ -338,9 +338,9 @@ class FunctionServiceTest { .input(JsonNull.of()) .messages( listOf( - ChatCompletionMessage.ofSystem( - ChatCompletionMessage.System.builder() - .role(ChatCompletionMessage.System.Role.SYSTEM) + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) .content("content") .name("name") .build() From d27a7828e50e8e0c91c6b9a527796d0352a8a554 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 04:51:17 +0000 Subject: [PATCH 30/87] feat(api): manual updates (#98) --- .stats.yml | 2 +- .../api/models/ChatCompletionContent.kt | 293 --------------- .../api/models/DatasetFetchPostParams.kt | 67 +--- .../api/models/ExperimentFetchPostParams.kt | 67 +--- .../api/models/ExperimentInsertResponse.kt | 160 --------- .../api/models/FeedbackDatasetItem.kt | 40 ++- .../api/models/FeedbackExperimentItem.kt | 40 ++- .../api/models/FeedbackProjectLogsItem.kt | 40 ++- .../api/models/FunctionInvokeParams.kt | 307 +++++++++++++++- .../models/PatchOrganizationMembersOutput.kt | 25 +- .../api/models/PathLookupFilter.kt | 235 ------------ .../api/models/ProjectLogFetchPostParams.kt | 67 +--- .../api/models/ProjectLogInsertResponse.kt | 160 --------- .../braintrustdata/api/models/PromptData.kt | 336 +++++++++++++++++- .../api/services/async/DatasetServiceAsync.kt | 6 +- .../services/async/DatasetServiceAsyncImpl.kt | 6 +- .../services/async/ExperimentServiceAsync.kt | 10 +- .../async/ExperimentServiceAsyncImpl.kt | 15 +- .../async/projects/LogServiceAsync.kt | 10 +- .../async/projects/LogServiceAsyncImpl.kt | 15 +- .../api/services/blocking/DatasetService.kt | 6 +- .../services/blocking/DatasetServiceImpl.kt | 6 +- .../services/blocking/ExperimentService.kt | 10 +- .../blocking/ExperimentServiceImpl.kt | 15 +- .../services/blocking/projects/LogService.kt | 10 +- .../blocking/projects/LogServiceImpl.kt | 15 +- .../api/models/DatasetFeedbackParamsTest.kt | 3 + .../api/models/DatasetFetchPostParamsTest.kt | 29 -- .../models/ExperimentFeedbackParamsTest.kt | 3 + .../models/ExperimentFetchPostParamsTest.kt | 29 -- .../api/models/FeedbackDatasetItemTest.kt | 2 + .../api/models/FeedbackExperimentItemTest.kt | 2 + .../api/models/FeedbackProjectLogsItemTest.kt | 2 + .../PatchOrganizationMembersOutputTest.kt | 2 + .../api/models/PathLookupFilterTest.kt | 24 -- .../models/ProjectLogFeedbackParamsTest.kt | 3 + .../models/ProjectLogFetchPostParamsTest.kt | 29 -- .../services/blocking/DatasetServiceTest.kt | 10 +- .../blocking/ExperimentServiceTest.kt | 15 +- .../blocking/projects/LogServiceTest.kt | 15 +- 40 files changed, 863 insertions(+), 1268 deletions(-) delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt delete mode 100755 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt delete mode 100755 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt diff --git a/.stats.yml b/.stats.yml index 308af69e..ec4da9f8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-55d937fb23d3c593f54056e8ed9bcd9949b7f234649bc23e5c615e85b4309bb3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-47514bb48808f22e7d712c118371a74397a68dc3033bedacf1778398de875e02.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt deleted file mode 100644 index 97e38a9a..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt +++ /dev/null @@ -1,293 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(using = ChatCompletionContent.Deserializer::class) -@JsonSerialize(using = ChatCompletionContent.Serializer::class) -class ChatCompletionContent -private constructor( - private val text: String? = null, - private val array: List? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun text(): Optional = Optional.ofNullable(text) - - fun array(): Optional> = Optional.ofNullable(array) - - fun isText(): Boolean = text != null - - fun isArray(): Boolean = array != null - - fun asText(): String = text.getOrThrow("text") - - fun asArray(): List = array.getOrThrow("array") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContent = apply { - if (!validated) { - if (text == null && array == null) { - throw BraintrustInvalidDataException("Unknown ChatCompletionContent: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContent && this.text == other.text && this.array == other.array /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - } - - override fun toString(): String { - return when { - text != null -> "ChatCompletionContent{text=$text}" - array != null -> "ChatCompletionContent{array=$array}" - _json != null -> "ChatCompletionContent{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContent") - } - } - - companion object { - - @JvmStatic fun ofText(text: String) = ChatCompletionContent(text = text) - - @JvmStatic - fun ofArray(array: List) = ChatCompletionContent(array = array) - } - - interface Visitor { - - fun visitText(text: String): T - - fun visitArray(array: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionContent: $json") - } - } - - class Deserializer : BaseDeserializer(ChatCompletionContent::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContent { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return ChatCompletionContent(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return ChatCompletionContent(array = it, _json = json) - } - - return ChatCompletionContent(_json = json) - } - } - - class Serializer : BaseSerializer(ChatCompletionContent::class) { - - override fun serialize( - value: ChatCompletionContent, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionContent") - } - } - } - - @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) - @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = chatCompletionContentPartText - ) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") - } - } - - class Deserializer : - BaseDeserializer(ChatCompletionContentPart::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : - BaseSerializer(ChatCompletionContentPart::class) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 6683ecc8..47e442c7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -20,7 +20,6 @@ class DatasetFetchPostParams constructor( private val datasetId: String, private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -34,8 +33,6 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) - fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -48,7 +45,6 @@ constructor( internal fun getBody(): DatasetFetchPostBody { return DatasetFetchPostBody( cursor, - filters, limit, maxRootSpanId, maxXactId, @@ -73,7 +69,6 @@ constructor( class DatasetFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -90,16 +85,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - @JsonProperty("filters") fun filters(): List? = filters - /** * limit the number of traces fetched * @@ -167,7 +152,6 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -177,7 +161,6 @@ constructor( @JvmSynthetic internal fun from(datasetFetchPostBody: DatasetFetchPostBody) = apply { this.cursor = datasetFetchPostBody.cursor - this.filters = datasetFetchPostBody.filters this.limit = datasetFetchPostBody.limit this.maxRootSpanId = datasetFetchPostBody.maxRootSpanId this.maxXactId = datasetFetchPostBody.maxXactId @@ -194,17 +177,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. - */ - @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } - /** * limit the number of traces fetched * @@ -278,7 +250,6 @@ constructor( fun build(): DatasetFetchPostBody = DatasetFetchPostBody( cursor, - filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -292,20 +263,20 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "DatasetFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -319,15 +290,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -341,7 +312,6 @@ constructor( private var datasetId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -354,7 +324,6 @@ constructor( internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = apply { this.datasetId = datasetFetchPostParams.datasetId this.cursor = datasetFetchPostParams.cursor - this.filters(datasetFetchPostParams.filters ?: listOf()) this.limit = datasetFetchPostParams.limit this.maxRootSpanId = datasetFetchPostParams.maxRootSpanId this.maxXactId = datasetFetchPostParams.maxXactId @@ -376,29 +345,6 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun filters(filters: List) = apply { - this.filters.clear() - this.filters.addAll(filters) - } - - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } - /** * limit the number of traces fetched * @@ -576,7 +522,6 @@ constructor( DatasetFetchPostParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 91fac9f8..53439ee7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -20,7 +20,6 @@ class ExperimentFetchPostParams constructor( private val experimentId: String, private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -34,8 +33,6 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) - fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -48,7 +45,6 @@ constructor( internal fun getBody(): ExperimentFetchPostBody { return ExperimentFetchPostBody( cursor, - filters, limit, maxRootSpanId, maxXactId, @@ -73,7 +69,6 @@ constructor( class ExperimentFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -90,16 +85,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - @JsonProperty("filters") fun filters(): List? = filters - /** * limit the number of traces fetched * @@ -167,7 +152,6 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -177,7 +161,6 @@ constructor( @JvmSynthetic internal fun from(experimentFetchPostBody: ExperimentFetchPostBody) = apply { this.cursor = experimentFetchPostBody.cursor - this.filters = experimentFetchPostBody.filters this.limit = experimentFetchPostBody.limit this.maxRootSpanId = experimentFetchPostBody.maxRootSpanId this.maxXactId = experimentFetchPostBody.maxXactId @@ -194,17 +177,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. - */ - @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } - /** * limit the number of traces fetched * @@ -278,7 +250,6 @@ constructor( fun build(): ExperimentFetchPostBody = ExperimentFetchPostBody( cursor, - filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -292,20 +263,20 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "ExperimentFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -319,15 +290,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -341,7 +312,6 @@ constructor( private var experimentId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -354,7 +324,6 @@ constructor( internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = apply { this.experimentId = experimentFetchPostParams.experimentId this.cursor = experimentFetchPostParams.cursor - this.filters(experimentFetchPostParams.filters ?: listOf()) this.limit = experimentFetchPostParams.limit this.maxRootSpanId = experimentFetchPostParams.maxRootSpanId this.maxXactId = experimentFetchPostParams.maxXactId @@ -376,29 +345,6 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun filters(filters: List) = apply { - this.filters.clear() - this.filters.addAll(filters) - } - - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } - /** * limit the number of traces fetched * @@ -576,7 +522,6 @@ constructor( ExperimentFetchPostParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt deleted file mode 100644 index b4bf81b7..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = ExperimentInsertResponse.Builder::class) -@NoAutoDetect -class ExperimentInsertResponse -private constructor( - private val rowIds: JsonField>, - private val serializedSpanSlugs: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - fun rowIds(): List = rowIds.getRequired("row_ids") - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - fun serializedSpanSlugs(): List = - serializedSpanSlugs.getRequired("serialized_span_slugs") - - fun toInsertEventsResponse(): InsertEventsResponse = - InsertEventsResponse.builder().rowIds(rowIds).build() - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - @JsonProperty("serialized_span_slugs") - @ExcludeMissing - fun _serializedSpanSlugs() = serializedSpanSlugs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ExperimentInsertResponse = apply { - if (!validated) { - rowIds() - serializedSpanSlugs() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var rowIds: JsonField> = JsonMissing.of() - private var serializedSpanSlugs: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(experimentInsertResponse: ExperimentInsertResponse) = apply { - this.rowIds = experimentInsertResponse.rowIds - this.serializedSpanSlugs = experimentInsertResponse.serializedSpanSlugs - additionalProperties(experimentInsertResponse.additionalProperties) - } - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - fun serializedSpanSlugs(serializedSpanSlugs: List) = - serializedSpanSlugs(JsonField.of(serializedSpanSlugs)) - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - @JsonProperty("serialized_span_slugs") - @ExcludeMissing - fun serializedSpanSlugs(serializedSpanSlugs: JsonField>) = apply { - this.serializedSpanSlugs = serializedSpanSlugs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ExperimentInsertResponse = - ExperimentInsertResponse( - rowIds.map { it.toImmutable() }, - serializedSpanSlugs.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentInsertResponse && this.rowIds == other.rowIds && this.serializedSpanSlugs == other.serializedSpanSlugs && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(rowIds, serializedSpanSlugs, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ExperimentInsertResponse{rowIds=$rowIds, serializedSpanSlugs=$serializedSpanSlugs, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 180d5da5..7c23b746 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -26,6 +26,7 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, + private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -42,13 +43,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** * The id of the dataset event to log feedback for. This is the row `id` returned by `POST * /v1/dataset/{dataset_id}/insert` @@ -60,13 +65,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -77,6 +86,7 @@ private constructor( comment() metadata().map { it.validate() } source() + tags() validated = true } } @@ -94,6 +104,7 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -102,6 +113,7 @@ private constructor( this.comment = feedbackDatasetItem.comment this.metadata = feedbackDatasetItem.metadata this.source = feedbackDatasetItem.source + this.tags = feedbackDatasetItem.tags additionalProperties(feedbackDatasetItem.additionalProperties) } @@ -127,13 +139,15 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing @@ -147,6 +161,14 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -167,13 +189,15 @@ private constructor( comment, metadata, source, + tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -315,18 +339,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackDatasetItem && this.id == other.id && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackDatasetItem && this.id == other.id && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, comment, metadata, source, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, comment, metadata, source, tags, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index 9a7f2303..ea2f3124 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -28,6 +28,7 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, + private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -56,13 +57,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** * The id of the experiment event to log feedback for. This is the row `id` returned by `POST * /v1/experiment/{experiment_id}/insert` @@ -86,13 +91,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -105,6 +114,7 @@ private constructor( comment() metadata().map { it.validate() } source() + tags() validated = true } } @@ -124,6 +134,7 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -134,6 +145,7 @@ private constructor( this.comment = feedbackExperimentItem.comment this.metadata = feedbackExperimentItem.metadata this.source = feedbackExperimentItem.source + this.tags = feedbackExperimentItem.tags additionalProperties(feedbackExperimentItem.additionalProperties) } @@ -181,13 +193,15 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing @@ -201,6 +215,14 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -223,13 +245,15 @@ private constructor( comment, metadata, source, + tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -447,18 +471,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackExperimentItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackExperimentItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 46b6f743..e717c6d1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -28,6 +28,7 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, + private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -56,13 +57,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** * The id of the project logs event to log feedback for. This is the row `id` returned by `POST * /v1/project_logs/{project_id}/insert` @@ -86,13 +91,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -105,6 +114,7 @@ private constructor( comment() metadata().map { it.validate() } source() + tags() validated = true } } @@ -124,6 +134,7 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -134,6 +145,7 @@ private constructor( this.comment = feedbackProjectLogsItem.comment this.metadata = feedbackProjectLogsItem.metadata this.source = feedbackProjectLogsItem.source + this.tags = feedbackProjectLogsItem.tags additionalProperties(feedbackProjectLogsItem.additionalProperties) } @@ -181,13 +193,15 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing @@ -201,6 +215,14 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -223,13 +245,15 @@ private constructor( comment, metadata, source, + tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -447,18 +471,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackProjectLogsItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackProjectLogsItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 963e7921..8d58dec8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -824,7 +824,7 @@ constructor( @NoAutoDetect class User private constructor( - private val content: JsonField, + private val content: JsonField, private val role: JsonField, private val name: JsonField, private val additionalProperties: Map, @@ -832,8 +832,7 @@ constructor( private var validated: Boolean = false - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -867,7 +866,7 @@ constructor( class Builder { - private var content: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -880,13 +879,11 @@ constructor( additionalProperties(user.additionalProperties) } - fun content(content: ChatCompletionContent) = content(JsonField.of(content)) + fun content(content: Content) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun role(role: Role) = role(JsonField.of(role)) @@ -975,6 +972,300 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val text: String? = null, + private val array: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun text(): Optional = Optional.ofNullable(text) + + fun array(): Optional> = Optional.ofNullable(array) + + fun isText(): Boolean = text != null + + fun isArray(): Boolean = array != null + + fun asText(): String = text.getOrThrow("text") + + fun asArray(): List = array.getOrThrow("array") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } + } + + fun validate(): Content = apply { + if (!validated) { + if (text == null && array == null) { + throw BraintrustInvalidDataException("Unknown Content: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ + } + + override fun toString(): String { + return when { + text != null -> "Content{text=$text}" + array != null -> "Content{array=$array}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + } + + companion object { + + @JvmStatic fun ofText(text: String) = Content(text = text) + + @JvmStatic + fun ofArray(array: List) = Content(array = array) + } + + interface Visitor { + + fun visitText(text: String): T + + fun visitArray(array: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Content: $json") + } + } + + class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>()) + ?.let { + return Content(array = it, _json = json) + } + + return Content(_json = json) + } + } + + class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val chatCompletionContentPartText: ChatCompletionContentPartText? = + null, + private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = + null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = + chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = + chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText( + chatCompletionContentPartText + ) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage( + chatCompletionContentPartImage + ) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if ( + chatCompletionContentPartText == null && + chatCompletionContentPartImage == null + ) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = + ChatCompletionContentPart( + chatCompletionContentPartText = chatCompletionContentPartText + ) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) + } + } + + class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject(value.chatCompletionContentPartText) + value.chatCompletionContentPartImage != null -> + generator.writeObject(value.chatCompletionContentPartImage) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 7b98d59d..6f8bf79c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -23,6 +23,7 @@ import java.util.Optional class PatchOrganizationMembersOutput private constructor( private val status: JsonField, + private val orgId: JsonField, private val sendEmailError: JsonField, private val additionalProperties: Map, ) { @@ -31,6 +32,9 @@ private constructor( fun status(): Status = status.getRequired("status") + /** The id of the org that was modified. */ + fun orgId(): String = orgId.getRequired("org_id") + /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here @@ -40,6 +44,9 @@ private constructor( @JsonProperty("status") @ExcludeMissing fun _status() = status + /** The id of the org that was modified. */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here @@ -53,6 +60,7 @@ private constructor( fun validate(): PatchOrganizationMembersOutput = apply { if (!validated) { status() + orgId() sendEmailError() validated = true } @@ -68,12 +76,14 @@ private constructor( class Builder { private var status: JsonField = JsonMissing.of() + private var orgId: JsonField = JsonMissing.of() private var sendEmailError: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = apply { this.status = patchOrganizationMembersOutput.status + this.orgId = patchOrganizationMembersOutput.orgId this.sendEmailError = patchOrganizationMembersOutput.sendEmailError additionalProperties(patchOrganizationMembersOutput.additionalProperties) } @@ -84,6 +94,14 @@ private constructor( @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } + /** The id of the org that was modified. */ + fun orgId(orgId: String) = orgId(JsonField.of(orgId)) + + /** The id of the org that was modified. */ + @JsonProperty("org_id") + @ExcludeMissing + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + /** * If invite emails failed to send for some reason, the patch operation will still complete, * but we will return an error message here @@ -117,6 +135,7 @@ private constructor( fun build(): PatchOrganizationMembersOutput = PatchOrganizationMembersOutput( status, + orgId, sendEmailError, additionalProperties.toImmutable(), ) @@ -178,18 +197,18 @@ private constructor( return true } - return /* spotless:off */ other is PatchOrganizationMembersOutput && this.status == other.status && this.sendEmailError == other.sendEmailError && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PatchOrganizationMembersOutput && this.status == other.status && this.orgId == other.orgId && this.sendEmailError == other.sendEmailError && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(status, sendEmailError, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(status, orgId, sendEmailError, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "PatchOrganizationMembersOutput{status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + "PatchOrganizationMembersOutput{status=$status, orgId=$orgId, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt deleted file mode 100755 index 84540bbc..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt +++ /dev/null @@ -1,235 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -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 -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -/** - * A path-lookup filter describes an equality comparison against a specific sub-field in the event - * row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": - * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` - */ -@JsonDeserialize(builder = PathLookupFilter.Builder::class) -@NoAutoDetect -class PathLookupFilter -private constructor( - private val type: JsonField, - private val path: JsonField>, - private val value: JsonValue, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** Denotes the type of filter as a path-lookup filter */ - fun type(): Type = type.getRequired("type") - - /** - * List of fields describing the path to the value to be checked against. For instance, if you - * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - fun path(): List = path.getRequired("path") - - /** - * The value to compare equality-wise against the event value at the specified `path`. The value - * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. - * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": - * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - fun value(): JsonValue = value - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - /** - * List of fields describing the path to the value to be checked against. For instance, if you - * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") @ExcludeMissing fun _path() = path - - /** - * The value to compare equality-wise against the event value at the specified `path`. The value - * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. - * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": - * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") @ExcludeMissing fun _value() = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PathLookupFilter = apply { - if (!validated) { - type() - path() - value() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var path: JsonField> = JsonMissing.of() - private var value: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(pathLookupFilter: PathLookupFilter) = apply { - this.type = pathLookupFilter.type - this.path = pathLookupFilter.path - this.value = pathLookupFilter.value - additionalProperties(pathLookupFilter.additionalProperties) - } - - /** Denotes the type of filter as a path-lookup filter */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - fun path(path: List) = path(JsonField.of(path)) - - /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") - @ExcludeMissing - fun path(path: JsonField>) = apply { this.path = path } - - /** - * The value to compare equality-wise against the event value at the specified `path`. The - * value must be a "primitive", that is, any JSON-serializable object except for objects and - * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") - @ExcludeMissing - fun value(value: JsonValue) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PathLookupFilter = - PathLookupFilter( - type, - path.map { it.toImmutable() }, - value, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val PATH_LOOKUP = Type(JsonField.of("path_lookup")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - PATH_LOOKUP, - } - - enum class Value { - PATH_LOOKUP, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PathLookupFilter && this.type == other.type && this.path == other.path && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, path, value, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "PathLookupFilter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index a2fa80bd..721df4c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -20,7 +20,6 @@ class ProjectLogFetchPostParams constructor( private val projectId: String, private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -34,8 +33,6 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) - fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -48,7 +45,6 @@ constructor( internal fun getBody(): ProjectLogFetchPostBody { return ProjectLogFetchPostBody( cursor, - filters, limit, maxRootSpanId, maxXactId, @@ -73,7 +69,6 @@ constructor( class ProjectLogFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -90,16 +85,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - @JsonProperty("filters") fun filters(): List? = filters - /** * limit the number of traces fetched * @@ -167,7 +152,6 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -177,7 +161,6 @@ constructor( @JvmSynthetic internal fun from(projectLogFetchPostBody: ProjectLogFetchPostBody) = apply { this.cursor = projectLogFetchPostBody.cursor - this.filters = projectLogFetchPostBody.filters this.limit = projectLogFetchPostBody.limit this.maxRootSpanId = projectLogFetchPostBody.maxRootSpanId this.maxXactId = projectLogFetchPostBody.maxXactId @@ -194,17 +177,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. - */ - @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } - /** * limit the number of traces fetched * @@ -278,7 +250,6 @@ constructor( fun build(): ProjectLogFetchPostBody = ProjectLogFetchPostBody( cursor, - filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -292,20 +263,20 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "ProjectLogFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -319,15 +290,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -341,7 +312,6 @@ constructor( private var projectId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -354,7 +324,6 @@ constructor( internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = apply { this.projectId = projectLogFetchPostParams.projectId this.cursor = projectLogFetchPostParams.cursor - this.filters(projectLogFetchPostParams.filters ?: listOf()) this.limit = projectLogFetchPostParams.limit this.maxRootSpanId = projectLogFetchPostParams.maxRootSpanId this.maxXactId = projectLogFetchPostParams.maxXactId @@ -376,29 +345,6 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun filters(filters: List) = apply { - this.filters.clear() - this.filters.addAll(filters) - } - - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } - /** * limit the number of traces fetched * @@ -576,7 +522,6 @@ constructor( ProjectLogFetchPostParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt deleted file mode 100644 index e529d36e..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = ProjectLogInsertResponse.Builder::class) -@NoAutoDetect -class ProjectLogInsertResponse -private constructor( - private val rowIds: JsonField>, - private val serializedSpanSlugs: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - fun rowIds(): List = rowIds.getRequired("row_ids") - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - fun serializedSpanSlugs(): List = - serializedSpanSlugs.getRequired("serialized_span_slugs") - - fun toInsertEventsResponse(): InsertEventsResponse = - InsertEventsResponse.builder().rowIds(rowIds).build() - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - @JsonProperty("serialized_span_slugs") - @ExcludeMissing - fun _serializedSpanSlugs() = serializedSpanSlugs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectLogInsertResponse = apply { - if (!validated) { - rowIds() - serializedSpanSlugs() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var rowIds: JsonField> = JsonMissing.of() - private var serializedSpanSlugs: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectLogInsertResponse: ProjectLogInsertResponse) = apply { - this.rowIds = projectLogInsertResponse.rowIds - this.serializedSpanSlugs = projectLogInsertResponse.serializedSpanSlugs - additionalProperties(projectLogInsertResponse.additionalProperties) - } - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - fun serializedSpanSlugs(serializedSpanSlugs: List) = - serializedSpanSlugs(JsonField.of(serializedSpanSlugs)) - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - @JsonProperty("serialized_span_slugs") - @ExcludeMissing - fun serializedSpanSlugs(serializedSpanSlugs: JsonField>) = apply { - this.serializedSpanSlugs = serializedSpanSlugs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectLogInsertResponse = - ProjectLogInsertResponse( - rowIds.map { it.toImmutable() }, - serializedSpanSlugs.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectLogInsertResponse && this.rowIds == other.rowIds && this.serializedSpanSlugs == other.serializedSpanSlugs && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(rowIds, serializedSpanSlugs, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ProjectLogInsertResponse{rowIds=$rowIds, serializedSpanSlugs=$serializedSpanSlugs, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 2c59e71c..539d5a13 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -1313,7 +1313,7 @@ private constructor( @NoAutoDetect class User private constructor( - private val content: JsonField, + private val content: JsonField, private val role: JsonField, private val name: JsonField, private val additionalProperties: Map, @@ -1321,7 +1321,7 @@ private constructor( private var validated: Boolean = false - fun content(): Optional = + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -1356,7 +1356,7 @@ private constructor( class Builder { - private var content: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -1370,13 +1370,11 @@ private constructor( additionalProperties(user.additionalProperties) } - fun content(content: ChatCompletionContent) = content(JsonField.of(content)) + fun content(content: Content) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun role(role: Role) = role(JsonField.of(role)) @@ -1466,6 +1464,330 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val text: String? = null, + private val array: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun text(): Optional = Optional.ofNullable(text) + + fun array(): Optional> = + Optional.ofNullable(array) + + fun isText(): Boolean = text != null + + fun isArray(): Boolean = array != null + + fun asText(): String = text.getOrThrow("text") + + fun asArray(): List = array.getOrThrow("array") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } + } + + fun validate(): Content = apply { + if (!validated) { + if (text == null && array == null) { + throw BraintrustInvalidDataException("Unknown Content: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ + } + + override fun toString(): String { + return when { + text != null -> "Content{text=$text}" + array != null -> "Content{array=$array}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + } + + companion object { + + @JvmStatic fun ofText(text: String) = Content(text = text) + + @JvmStatic + fun ofArray(array: List) = + Content(array = array) + } + + interface Visitor { + + fun visitText(text: String): T + + fun visitArray(array: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Content: $json") + } + } + + class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content(array = it, _json = json) + } + + return Content(_json = json) + } + } + + class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val chatCompletionContentPartText: + ChatCompletionContentPartText? = + null, + private val chatCompletionContentPartImage: + ChatCompletionContentPartImage? = + null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): + Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): + Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = + chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = + chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow( + "chatCompletionContentPartText" + ) + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow( + "chatCompletionContentPartImage" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText( + chatCompletionContentPartText + ) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage( + chatCompletionContentPartImage + ) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if ( + chatCompletionContentPartText == null && + chatCompletionContentPartImage == null + ) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid ChatCompletionContentPart" + ) + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = + ChatCompletionContentPart( + chatCompletionContentPartText = + chatCompletionContentPartText + ) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = + chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) + } + } + + class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject( + value.chatCompletionContentPartText + ) + value.chatCompletionContentPartImage != null -> + generator.writeObject( + value.chatCompletionContentPartImage + ) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid ChatCompletionContentPart" + ) + } + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index 730918fa..ca44dff1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -79,7 +79,8 @@ interface DatasetServiceAsync { /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -89,7 +90,8 @@ interface DatasetServiceAsync { /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index 6e3ff5f3..b767b4bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -233,7 +233,8 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetch( params: DatasetFetchParams, @@ -266,7 +267,8 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: DatasetFetchPostParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index b96278ab..1b601325 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -12,7 +12,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -20,6 +19,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture @@ -79,7 +79,8 @@ interface ExperimentServiceAsync { /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -89,7 +90,8 @@ interface ExperimentServiceAsync { /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( @@ -102,7 +104,7 @@ interface ExperimentServiceAsync { fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Summarize experiment */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 4468bf15..7753231b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -19,7 +19,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -27,6 +26,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture @@ -233,7 +233,8 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetch( params: ExperimentFetchParams, @@ -266,7 +267,8 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: ExperimentFetchPostParams, @@ -294,15 +296,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index 321b599c..782f3331 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture interface LogServiceAsync { @@ -25,7 +25,8 @@ interface LogServiceAsync { /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -35,7 +36,8 @@ interface LogServiceAsync { /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( @@ -48,5 +50,5 @@ interface LogServiceAsync { fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index eda101b7..a1432eaa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -14,11 +14,11 @@ import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture class LogServiceAsyncImpl @@ -64,7 +64,8 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ override fun fetch( params: ProjectLogFetchParams, @@ -97,7 +98,8 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: ProjectLogFetchPostParams, @@ -125,15 +127,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 418bb13a..9a8e7b8e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -78,7 +78,8 @@ interface DatasetService { /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -88,7 +89,8 @@ interface DatasetService { /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 24f60d84..66b4afd6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -211,7 +211,8 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetch( params: DatasetFetchParams, @@ -243,7 +244,8 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: DatasetFetchPostParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 24ead7fd..b8dcc7bf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -12,7 +12,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -20,6 +19,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse interface ExperimentService { @@ -78,7 +78,8 @@ interface ExperimentService { /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -88,7 +89,8 @@ interface ExperimentService { /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( @@ -101,7 +103,7 @@ interface ExperimentService { fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): ExperimentInsertResponse + ): InsertEventsResponse /** Summarize experiment */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index c5e92523..fdecad4d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -19,7 +19,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -27,6 +26,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse class ExperimentServiceImpl @@ -226,7 +226,8 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetch( params: ExperimentFetchParams, @@ -258,7 +259,8 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: ExperimentFetchPostParams, @@ -285,15 +287,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): ExperimentInsertResponse { + ): InsertEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index cd4f4c96..c36b6e81 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse interface LogService { @@ -24,7 +24,8 @@ interface LogService { /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -34,7 +35,8 @@ interface LogService { /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( @@ -47,5 +49,5 @@ interface LogService { fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectLogInsertResponse + ): InsertEventsResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index a7b5ed35..72e74f7a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -14,11 +14,11 @@ import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse class LogServiceImpl constructor( @@ -62,7 +62,8 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ override fun fetch( params: ProjectLogFetchParams, @@ -94,7 +95,8 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: ProjectLogFetchPostParams, @@ -121,15 +123,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): ProjectLogInsertResponse { + ): InsertEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index e5ec92fd..116f69f8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -19,6 +19,7 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -37,6 +38,7 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -51,6 +53,7 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index cc6494aa..f92d1111 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,15 +13,6 @@ class DatasetFetchPostParamsTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -36,15 +26,6 @@ class DatasetFetchPostParamsTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -53,16 +34,6 @@ class DatasetFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index b05c51e5..a0dafd44 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -22,6 +22,7 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -42,6 +43,7 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -58,6 +60,7 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index d48306d8..fde0406f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,15 +13,6 @@ class ExperimentFetchPostParamsTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -36,15 +26,6 @@ class ExperimentFetchPostParamsTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -53,16 +34,6 @@ class ExperimentFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index 76dd0db6..b3719906 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -15,6 +15,7 @@ class FeedbackDatasetItemTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() assertThat(feedbackDatasetItem).isNotNull assertThat(feedbackDatasetItem.id()).isEqualTo("id") @@ -22,5 +23,6 @@ class FeedbackDatasetItemTest { assertThat(feedbackDatasetItem.metadata()) .contains(FeedbackDatasetItem.Metadata.builder().build()) assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) + assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index 35ee660b..7e050574 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -18,6 +18,7 @@ class FeedbackExperimentItemTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() assertThat(feedbackExperimentItem).isNotNull assertThat(feedbackExperimentItem.id()).isEqualTo("id") @@ -28,5 +29,6 @@ class FeedbackExperimentItemTest { assertThat(feedbackExperimentItem.scores()) .contains(FeedbackExperimentItem.Scores.builder().build()) assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) + assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index 3f219e5d..b622ead2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -18,6 +18,7 @@ class FeedbackProjectLogsItemTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() assertThat(feedbackProjectLogsItem).isNotNull assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") @@ -28,5 +29,6 @@ class FeedbackProjectLogsItemTest { assertThat(feedbackProjectLogsItem.scores()) .contains(FeedbackProjectLogsItem.Scores.builder().build()) assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) + assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt index 50747d77..dabc2d8c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt @@ -11,10 +11,12 @@ class PatchOrganizationMembersOutputTest { fun createPatchOrganizationMembersOutput() { val patchOrganizationMembersOutput = PatchOrganizationMembersOutput.builder() + .orgId("org_id") .status(PatchOrganizationMembersOutput.Status.SUCCESS) .sendEmailError("send_email_error") .build() assertThat(patchOrganizationMembersOutput).isNotNull + assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") assertThat(patchOrganizationMembersOutput.status()) .isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt deleted file mode 100755 index 4d32afc1..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PathLookupFilterTest { - - @Test - fun createPathLookupFilter() { - val pathLookupFilter = - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - assertThat(pathLookupFilter).isNotNull - assertThat(pathLookupFilter.path()).containsExactly("string") - assertThat(pathLookupFilter.type()).isEqualTo(PathLookupFilter.Type.PATH_LOOKUP) - assertThat(pathLookupFilter._value()).isEqualTo(JsonNull.of()) - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index c2b19357..4b9a5bb8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -22,6 +22,7 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -42,6 +43,7 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -58,6 +60,7 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index acb4cc3d..421ef272 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,15 +13,6 @@ class ProjectLogFetchPostParamsTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -36,15 +26,6 @@ class ProjectLogFetchPostParamsTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -53,16 +34,6 @@ class ProjectLogFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index 0dd351c6..774cd505 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -124,6 +124,7 @@ class DatasetServiceTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -168,15 +169,6 @@ class DatasetServiceTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") 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 0d9bc86d..a80a6a14 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 @@ -161,6 +161,7 @@ class ExperimentServiceTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -205,15 +206,6 @@ class ExperimentServiceTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -232,7 +224,7 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val experimentInsertResponse = + val insertEventsResponse = experimentService.insert( ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -286,7 +278,8 @@ class ExperimentServiceTest { ) .build() ) - println(experimentInsertResponse) + println(insertEventsResponse) + insertEventsResponse.validate() } @Test 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 74b8a98b..1ae8216b 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 @@ -34,6 +34,7 @@ class LogServiceTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -78,15 +79,6 @@ class LogServiceTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -105,7 +97,7 @@ class LogServiceTest { .apiKey("My API Key") .build() val logService = client.projects().logs() - val projectLogInsertResponse = + val insertEventsResponse = logService.insert( ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -158,6 +150,7 @@ class LogServiceTest { ) .build() ) - println(projectLogInsertResponse) + println(insertEventsResponse) + insertEventsResponse.validate() } } From eb3e6891d822772b04258b63d3ecb1db96537186 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 05:02:22 +0000 Subject: [PATCH 31/87] feat(api): manual updates (#99) --- .stats.yml | 2 +- .../api/models/ChatCompletionContent.kt | 293 +++++++++++++++ .../api/models/DatasetFetchPostParams.kt | 67 +++- .../api/models/ExperimentFetchPostParams.kt | 67 +++- .../api/models/ExperimentInsertResponse.kt | 160 +++++++++ .../api/models/FeedbackDatasetItem.kt | 40 +-- .../api/models/FeedbackExperimentItem.kt | 40 +-- .../api/models/FeedbackProjectLogsItem.kt | 40 +-- .../api/models/FunctionInvokeParams.kt | 307 +--------------- .../models/PatchOrganizationMembersOutput.kt | 25 +- .../api/models/PathLookupFilter.kt | 235 ++++++++++++ .../api/models/ProjectLogFetchPostParams.kt | 67 +++- .../api/models/ProjectLogInsertResponse.kt | 160 +++++++++ .../braintrustdata/api/models/PromptData.kt | 336 +----------------- .../api/services/async/DatasetServiceAsync.kt | 6 +- .../services/async/DatasetServiceAsyncImpl.kt | 6 +- .../services/async/ExperimentServiceAsync.kt | 10 +- .../async/ExperimentServiceAsyncImpl.kt | 15 +- .../async/projects/LogServiceAsync.kt | 10 +- .../async/projects/LogServiceAsyncImpl.kt | 15 +- .../api/services/blocking/DatasetService.kt | 6 +- .../services/blocking/DatasetServiceImpl.kt | 6 +- .../services/blocking/ExperimentService.kt | 10 +- .../blocking/ExperimentServiceImpl.kt | 15 +- .../services/blocking/projects/LogService.kt | 10 +- .../blocking/projects/LogServiceImpl.kt | 15 +- .../api/models/DatasetFeedbackParamsTest.kt | 3 - .../api/models/DatasetFetchPostParamsTest.kt | 29 ++ .../models/ExperimentFeedbackParamsTest.kt | 3 - .../models/ExperimentFetchPostParamsTest.kt | 29 ++ .../api/models/FeedbackDatasetItemTest.kt | 2 - .../api/models/FeedbackExperimentItemTest.kt | 2 - .../api/models/FeedbackProjectLogsItemTest.kt | 2 - .../PatchOrganizationMembersOutputTest.kt | 2 - .../api/models/PathLookupFilterTest.kt | 24 ++ .../models/ProjectLogFeedbackParamsTest.kt | 3 - .../models/ProjectLogFetchPostParamsTest.kt | 29 ++ .../services/blocking/DatasetServiceTest.kt | 10 +- .../blocking/ExperimentServiceTest.kt | 15 +- .../blocking/projects/LogServiceTest.kt | 15 +- 40 files changed, 1268 insertions(+), 863 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt diff --git a/.stats.yml b/.stats.yml index ec4da9f8..308af69e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-47514bb48808f22e7d712c118371a74397a68dc3033bedacf1778398de875e02.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-55d937fb23d3c593f54056e8ed9bcd9949b7f234649bc23e5c615e85b4309bb3.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt new file mode 100644 index 00000000..97e38a9a --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt @@ -0,0 +1,293 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = ChatCompletionContent.Deserializer::class) +@JsonSerialize(using = ChatCompletionContent.Serializer::class) +class ChatCompletionContent +private constructor( + private val text: String? = null, + private val array: List? = null, + private val _json: JsonValue? = null, +) { + + private var validated: Boolean = false + + fun text(): Optional = Optional.ofNullable(text) + + fun array(): Optional> = Optional.ofNullable(array) + + fun isText(): Boolean = text != null + + fun isArray(): Boolean = array != null + + fun asText(): String = text.getOrThrow("text") + + fun asArray(): List = array.getOrThrow("array") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContent = apply { + if (!validated) { + if (text == null && array == null) { + throw BraintrustInvalidDataException("Unknown ChatCompletionContent: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContent && this.text == other.text && this.array == other.array /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ + } + + override fun toString(): String { + return when { + text != null -> "ChatCompletionContent{text=$text}" + array != null -> "ChatCompletionContent{array=$array}" + _json != null -> "ChatCompletionContent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContent") + } + } + + companion object { + + @JvmStatic fun ofText(text: String) = ChatCompletionContent(text = text) + + @JvmStatic + fun ofArray(array: List) = ChatCompletionContent(array = array) + } + + interface Visitor { + + fun visitText(text: String): T + + fun visitArray(array: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ChatCompletionContent: $json") + } + } + + class Deserializer : BaseDeserializer(ChatCompletionContent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContent { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return ChatCompletionContent(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return ChatCompletionContent(array = it, _json = json) + } + + return ChatCompletionContent(_json = json) + } + } + + class Serializer : BaseSerializer(ChatCompletionContent::class) { + + override fun serialize( + value: ChatCompletionContent, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContent") + } + } + } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, + private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if ( + chatCompletionContentPartText == null && chatCompletionContentPartImage == null + ) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = + ChatCompletionContentPart( + chatCompletionContentPartText = chatCompletionContentPartText + ) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") + } + } + + class Deserializer : + BaseDeserializer(ChatCompletionContentPart::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer(ChatCompletionContentPart::class) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject(value.chatCompletionContentPartText) + value.chatCompletionContentPartImage != null -> + generator.writeObject(value.chatCompletionContentPartImage) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 47e442c7..6683ecc8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -20,6 +20,7 @@ class DatasetFetchPostParams constructor( private val datasetId: String, private val cursor: String?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -33,6 +34,8 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) + fun filters(): Optional> = Optional.ofNullable(filters) + fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -45,6 +48,7 @@ constructor( internal fun getBody(): DatasetFetchPostBody { return DatasetFetchPostBody( cursor, + filters, limit, maxRootSpanId, maxXactId, @@ -69,6 +73,7 @@ constructor( class DatasetFetchPostBody internal constructor( private val cursor: String?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -85,6 +90,16 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + @JsonProperty("filters") fun filters(): List? = filters + /** * limit the number of traces fetched * @@ -152,6 +167,7 @@ constructor( class Builder { private var cursor: String? = null + private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -161,6 +177,7 @@ constructor( @JvmSynthetic internal fun from(datasetFetchPostBody: DatasetFetchPostBody) = apply { this.cursor = datasetFetchPostBody.cursor + this.filters = datasetFetchPostBody.filters this.limit = datasetFetchPostBody.limit this.maxRootSpanId = datasetFetchPostBody.maxRootSpanId this.maxXactId = datasetFetchPostBody.maxXactId @@ -177,6 +194,17 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters + * are supported. + */ + @JsonProperty("filters") + fun filters(filters: List) = apply { this.filters = filters } + /** * limit the number of traces fetched * @@ -250,6 +278,7 @@ constructor( fun build(): DatasetFetchPostBody = DatasetFetchPostBody( cursor, + filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -263,20 +292,20 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "DatasetFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -290,15 +319,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -312,6 +341,7 @@ constructor( private var datasetId: String? = null private var cursor: String? = null + private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -324,6 +354,7 @@ constructor( internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = apply { this.datasetId = datasetFetchPostParams.datasetId this.cursor = datasetFetchPostParams.cursor + this.filters(datasetFetchPostParams.filters ?: listOf()) this.limit = datasetFetchPostParams.limit this.maxRootSpanId = datasetFetchPostParams.maxRootSpanId this.maxXactId = datasetFetchPostParams.maxXactId @@ -345,6 +376,29 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + fun filters(filters: List) = apply { + this.filters.clear() + this.filters.addAll(filters) + } + + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } + /** * limit the number of traces fetched * @@ -522,6 +576,7 @@ constructor( DatasetFetchPostParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, cursor, + if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 53439ee7..91fac9f8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -20,6 +20,7 @@ class ExperimentFetchPostParams constructor( private val experimentId: String, private val cursor: String?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -33,6 +34,8 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) + fun filters(): Optional> = Optional.ofNullable(filters) + fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -45,6 +48,7 @@ constructor( internal fun getBody(): ExperimentFetchPostBody { return ExperimentFetchPostBody( cursor, + filters, limit, maxRootSpanId, maxXactId, @@ -69,6 +73,7 @@ constructor( class ExperimentFetchPostBody internal constructor( private val cursor: String?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -85,6 +90,16 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + @JsonProperty("filters") fun filters(): List? = filters + /** * limit the number of traces fetched * @@ -152,6 +167,7 @@ constructor( class Builder { private var cursor: String? = null + private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -161,6 +177,7 @@ constructor( @JvmSynthetic internal fun from(experimentFetchPostBody: ExperimentFetchPostBody) = apply { this.cursor = experimentFetchPostBody.cursor + this.filters = experimentFetchPostBody.filters this.limit = experimentFetchPostBody.limit this.maxRootSpanId = experimentFetchPostBody.maxRootSpanId this.maxXactId = experimentFetchPostBody.maxXactId @@ -177,6 +194,17 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters + * are supported. + */ + @JsonProperty("filters") + fun filters(filters: List) = apply { this.filters = filters } + /** * limit the number of traces fetched * @@ -250,6 +278,7 @@ constructor( fun build(): ExperimentFetchPostBody = ExperimentFetchPostBody( cursor, + filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -263,20 +292,20 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ExperimentFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -290,15 +319,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -312,6 +341,7 @@ constructor( private var experimentId: String? = null private var cursor: String? = null + private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -324,6 +354,7 @@ constructor( internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = apply { this.experimentId = experimentFetchPostParams.experimentId this.cursor = experimentFetchPostParams.cursor + this.filters(experimentFetchPostParams.filters ?: listOf()) this.limit = experimentFetchPostParams.limit this.maxRootSpanId = experimentFetchPostParams.maxRootSpanId this.maxXactId = experimentFetchPostParams.maxXactId @@ -345,6 +376,29 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + fun filters(filters: List) = apply { + this.filters.clear() + this.filters.addAll(filters) + } + + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } + /** * limit the number of traces fetched * @@ -522,6 +576,7 @@ constructor( ExperimentFetchPostParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, cursor, + if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt new file mode 100644 index 00000000..b4bf81b7 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toImmutable +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects + +@JsonDeserialize(builder = ExperimentInsertResponse.Builder::class) +@NoAutoDetect +class ExperimentInsertResponse +private constructor( + private val rowIds: JsonField>, + private val serializedSpanSlugs: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + fun rowIds(): List = rowIds.getRequired("row_ids") + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + fun serializedSpanSlugs(): List = + serializedSpanSlugs.getRequired("serialized_span_slugs") + + fun toInsertEventsResponse(): InsertEventsResponse = + InsertEventsResponse.builder().rowIds(rowIds).build() + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + @JsonProperty("serialized_span_slugs") + @ExcludeMissing + fun _serializedSpanSlugs() = serializedSpanSlugs + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ExperimentInsertResponse = apply { + if (!validated) { + rowIds() + serializedSpanSlugs() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var rowIds: JsonField> = JsonMissing.of() + private var serializedSpanSlugs: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(experimentInsertResponse: ExperimentInsertResponse) = apply { + this.rowIds = experimentInsertResponse.rowIds + this.serializedSpanSlugs = experimentInsertResponse.serializedSpanSlugs + additionalProperties(experimentInsertResponse.additionalProperties) + } + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + @JsonProperty("row_ids") + @ExcludeMissing + fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + fun serializedSpanSlugs(serializedSpanSlugs: List) = + serializedSpanSlugs(JsonField.of(serializedSpanSlugs)) + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + @JsonProperty("serialized_span_slugs") + @ExcludeMissing + fun serializedSpanSlugs(serializedSpanSlugs: JsonField>) = apply { + this.serializedSpanSlugs = serializedSpanSlugs + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExperimentInsertResponse = + ExperimentInsertResponse( + rowIds.map { it.toImmutable() }, + serializedSpanSlugs.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentInsertResponse && this.rowIds == other.rowIds && this.serializedSpanSlugs == other.serializedSpanSlugs && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(rowIds, serializedSpanSlugs, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ExperimentInsertResponse{rowIds=$rowIds, serializedSpanSlugs=$serializedSpanSlugs, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 7c23b746..180d5da5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -26,7 +26,6 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, - private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -43,17 +42,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** * The id of the dataset event to log feedback for. This is the row `id` returned by `POST * /v1/dataset/{dataset_id}/insert` @@ -65,17 +60,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -86,7 +77,6 @@ private constructor( comment() metadata().map { it.validate() } source() - tags() validated = true } } @@ -104,7 +94,6 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -113,7 +102,6 @@ private constructor( this.comment = feedbackDatasetItem.comment this.metadata = feedbackDatasetItem.metadata this.source = feedbackDatasetItem.source - this.tags = feedbackDatasetItem.tags additionalProperties(feedbackDatasetItem.additionalProperties) } @@ -139,15 +127,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * log it here and access it in the Braintrust UI. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * log it here and access it in the Braintrust UI. */ @JsonProperty("metadata") @ExcludeMissing @@ -161,14 +147,6 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -189,15 +167,13 @@ private constructor( comment, metadata, source, - tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -339,18 +315,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackDatasetItem && this.id == other.id && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackDatasetItem && this.id == other.id && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, comment, metadata, source, tags, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, comment, metadata, source, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index ea2f3124..9a7f2303 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -28,7 +28,6 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, - private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -57,17 +56,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** * The id of the experiment event to log feedback for. This is the row `id` returned by `POST * /v1/experiment/{experiment_id}/insert` @@ -91,17 +86,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -114,7 +105,6 @@ private constructor( comment() metadata().map { it.validate() } source() - tags() validated = true } } @@ -134,7 +124,6 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -145,7 +134,6 @@ private constructor( this.comment = feedbackExperimentItem.comment this.metadata = feedbackExperimentItem.metadata this.source = feedbackExperimentItem.source - this.tags = feedbackExperimentItem.tags additionalProperties(feedbackExperimentItem.additionalProperties) } @@ -193,15 +181,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * log it here and access it in the Braintrust UI. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * log it here and access it in the Braintrust UI. */ @JsonProperty("metadata") @ExcludeMissing @@ -215,14 +201,6 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -245,15 +223,13 @@ private constructor( comment, metadata, source, - tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -471,18 +447,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackExperimentItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackExperimentItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index e717c6d1..46b6f743 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -28,7 +28,6 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, - private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -57,17 +56,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** * The id of the project logs event to log feedback for. This is the row `id` returned by `POST * /v1/project_logs/{project_id}/insert` @@ -91,17 +86,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -114,7 +105,6 @@ private constructor( comment() metadata().map { it.validate() } source() - tags() validated = true } } @@ -134,7 +124,6 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -145,7 +134,6 @@ private constructor( this.comment = feedbackProjectLogsItem.comment this.metadata = feedbackProjectLogsItem.metadata this.source = feedbackProjectLogsItem.source - this.tags = feedbackProjectLogsItem.tags additionalProperties(feedbackProjectLogsItem.additionalProperties) } @@ -193,15 +181,13 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * log it here and access it in the Braintrust UI. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * log it here and access it in the Braintrust UI. */ @JsonProperty("metadata") @ExcludeMissing @@ -215,14 +201,6 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -245,15 +223,13 @@ private constructor( comment, metadata, source, - tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * here and access it in the Braintrust UI. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -471,18 +447,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackProjectLogsItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackProjectLogsItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 8d58dec8..963e7921 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -824,7 +824,7 @@ constructor( @NoAutoDetect class User private constructor( - private val content: JsonField, + private val content: JsonField, private val role: JsonField, private val name: JsonField, private val additionalProperties: Map, @@ -832,7 +832,8 @@ constructor( private var validated: Boolean = false - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -866,7 +867,7 @@ constructor( class Builder { - private var content: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -879,11 +880,13 @@ constructor( additionalProperties(user.additionalProperties) } - fun content(content: Content) = content(JsonField.of(content)) + fun content(content: ChatCompletionContent) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun role(role: Role) = role(JsonField.of(role)) @@ -972,300 +975,6 @@ constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val text: String? = null, - private val array: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun text(): Optional = Optional.ofNullable(text) - - fun array(): Optional> = Optional.ofNullable(array) - - fun isText(): Boolean = text != null - - fun isArray(): Boolean = array != null - - fun asText(): String = text.getOrThrow("text") - - fun asArray(): List = array.getOrThrow("array") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (text == null && array == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - } - - override fun toString(): String { - return when { - text != null -> "Content{text=$text}" - array != null -> "Content{array=$array}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofText(text: String) = Content(text = text) - - @JvmStatic - fun ofArray(array: List) = Content(array = array) - } - - interface Visitor { - - fun visitText(text: String): T - - fun visitArray(array: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>()) - ?.let { - return Content(array = it, _json = json) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) - @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = - null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = - chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = - chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText( - chatCompletionContentPartText - ) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage( - chatCompletionContentPartImage - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && - chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = chatCompletionContentPartText - ) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 6f8bf79c..7b98d59d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -23,7 +23,6 @@ import java.util.Optional class PatchOrganizationMembersOutput private constructor( private val status: JsonField, - private val orgId: JsonField, private val sendEmailError: JsonField, private val additionalProperties: Map, ) { @@ -32,9 +31,6 @@ private constructor( fun status(): Status = status.getRequired("status") - /** The id of the org that was modified. */ - fun orgId(): String = orgId.getRequired("org_id") - /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here @@ -44,9 +40,6 @@ private constructor( @JsonProperty("status") @ExcludeMissing fun _status() = status - /** The id of the org that was modified. */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here @@ -60,7 +53,6 @@ private constructor( fun validate(): PatchOrganizationMembersOutput = apply { if (!validated) { status() - orgId() sendEmailError() validated = true } @@ -76,14 +68,12 @@ private constructor( class Builder { private var status: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() private var sendEmailError: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = apply { this.status = patchOrganizationMembersOutput.status - this.orgId = patchOrganizationMembersOutput.orgId this.sendEmailError = patchOrganizationMembersOutput.sendEmailError additionalProperties(patchOrganizationMembersOutput.additionalProperties) } @@ -94,14 +84,6 @@ private constructor( @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } - /** The id of the org that was modified. */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** The id of the org that was modified. */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - /** * If invite emails failed to send for some reason, the patch operation will still complete, * but we will return an error message here @@ -135,7 +117,6 @@ private constructor( fun build(): PatchOrganizationMembersOutput = PatchOrganizationMembersOutput( status, - orgId, sendEmailError, additionalProperties.toImmutable(), ) @@ -197,18 +178,18 @@ private constructor( return true } - return /* spotless:off */ other is PatchOrganizationMembersOutput && this.status == other.status && this.orgId == other.orgId && this.sendEmailError == other.sendEmailError && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PatchOrganizationMembersOutput && this.status == other.status && this.sendEmailError == other.sendEmailError && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(status, orgId, sendEmailError, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(status, sendEmailError, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "PatchOrganizationMembersOutput{status=$status, orgId=$orgId, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + "PatchOrganizationMembersOutput{status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt new file mode 100644 index 00000000..84540bbc --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +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 +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +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 +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects + +/** + * A path-lookup filter describes an equality comparison against a specific sub-field in the event + * row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": + * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` + */ +@JsonDeserialize(builder = PathLookupFilter.Builder::class) +@NoAutoDetect +class PathLookupFilter +private constructor( + private val type: JsonField, + private val path: JsonField>, + private val value: JsonValue, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** Denotes the type of filter as a path-lookup filter */ + fun type(): Type = type.getRequired("type") + + /** + * List of fields describing the path to the value to be checked against. For instance, if you + * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` + */ + fun path(): List = path.getRequired("path") + + /** + * The value to compare equality-wise against the event value at the specified `path`. The value + * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. + * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": + * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + */ + fun value(): JsonValue = value + + /** Denotes the type of filter as a path-lookup filter */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + /** + * List of fields describing the path to the value to be checked against. For instance, if you + * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` + */ + @JsonProperty("path") @ExcludeMissing fun _path() = path + + /** + * The value to compare equality-wise against the event value at the specified `path`. The value + * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. + * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": + * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + */ + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PathLookupFilter = apply { + if (!validated) { + type() + path() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var type: JsonField = JsonMissing.of() + private var path: JsonField> = JsonMissing.of() + private var value: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pathLookupFilter: PathLookupFilter) = apply { + this.type = pathLookupFilter.type + this.path = pathLookupFilter.path + this.value = pathLookupFilter.value + additionalProperties(pathLookupFilter.additionalProperties) + } + + /** Denotes the type of filter as a path-lookup filter */ + fun type(type: Type) = type(JsonField.of(type)) + + /** Denotes the type of filter as a path-lookup filter */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + /** + * List of fields describing the path to the value to be checked against. For instance, if + * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` + */ + fun path(path: List) = path(JsonField.of(path)) + + /** + * List of fields describing the path to the value to be checked against. For instance, if + * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` + */ + @JsonProperty("path") + @ExcludeMissing + fun path(path: JsonField>) = apply { this.path = path } + + /** + * The value to compare equality-wise against the event value at the specified `path`. The + * value must be a "primitive", that is, any JSON-serializable object except for objects and + * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + */ + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonValue) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): PathLookupFilter = + PathLookupFilter( + type, + path.map { it.toImmutable() }, + value, + additionalProperties.toImmutable(), + ) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PATH_LOOKUP = Type(JsonField.of("path_lookup")) + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + PATH_LOOKUP, + } + + enum class Value { + PATH_LOOKUP, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PATH_LOOKUP -> Value.PATH_LOOKUP + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PATH_LOOKUP -> Known.PATH_LOOKUP + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PathLookupFilter && this.type == other.type && this.path == other.path && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(type, path, value, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "PathLookupFilter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 721df4c3..a2fa80bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -20,6 +20,7 @@ class ProjectLogFetchPostParams constructor( private val projectId: String, private val cursor: String?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -33,6 +34,8 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) + fun filters(): Optional> = Optional.ofNullable(filters) + fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -45,6 +48,7 @@ constructor( internal fun getBody(): ProjectLogFetchPostBody { return ProjectLogFetchPostBody( cursor, + filters, limit, maxRootSpanId, maxXactId, @@ -69,6 +73,7 @@ constructor( class ProjectLogFetchPostBody internal constructor( private val cursor: String?, + private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -85,6 +90,16 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + @JsonProperty("filters") fun filters(): List? = filters + /** * limit the number of traces fetched * @@ -152,6 +167,7 @@ constructor( class Builder { private var cursor: String? = null + private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -161,6 +177,7 @@ constructor( @JvmSynthetic internal fun from(projectLogFetchPostBody: ProjectLogFetchPostBody) = apply { this.cursor = projectLogFetchPostBody.cursor + this.filters = projectLogFetchPostBody.filters this.limit = projectLogFetchPostBody.limit this.maxRootSpanId = projectLogFetchPostBody.maxRootSpanId this.maxXactId = projectLogFetchPostBody.maxXactId @@ -177,6 +194,17 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters + * are supported. + */ + @JsonProperty("filters") + fun filters(filters: List) = apply { this.filters = filters } + /** * limit the number of traces fetched * @@ -250,6 +278,7 @@ constructor( fun build(): ProjectLogFetchPostBody = ProjectLogFetchPostBody( cursor, + filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -263,20 +292,20 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ProjectLogFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -290,15 +319,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -312,6 +341,7 @@ constructor( private var projectId: String? = null private var cursor: String? = null + private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -324,6 +354,7 @@ constructor( internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = apply { this.projectId = projectLogFetchPostParams.projectId this.cursor = projectLogFetchPostParams.cursor + this.filters(projectLogFetchPostParams.filters ?: listOf()) this.limit = projectLogFetchPostParams.limit this.maxRootSpanId = projectLogFetchPostParams.maxRootSpanId this.maxXactId = projectLogFetchPostParams.maxXactId @@ -345,6 +376,29 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + fun filters(filters: List) = apply { + this.filters.clear() + this.filters.addAll(filters) + } + + /** + * NOTE: This parameter is deprecated and will be removed in a future revision. Consider + * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more + * advanced filtering. + * + * A list of filters on the events to fetch. Currently, only path-lookup type filters are + * supported. + */ + fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } + /** * limit the number of traces fetched * @@ -522,6 +576,7 @@ constructor( ProjectLogFetchPostParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, cursor, + if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt new file mode 100644 index 00000000..e529d36e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toImmutable +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects + +@JsonDeserialize(builder = ProjectLogInsertResponse.Builder::class) +@NoAutoDetect +class ProjectLogInsertResponse +private constructor( + private val rowIds: JsonField>, + private val serializedSpanSlugs: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + fun rowIds(): List = rowIds.getRequired("row_ids") + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + fun serializedSpanSlugs(): List = + serializedSpanSlugs.getRequired("serialized_span_slugs") + + fun toInsertEventsResponse(): InsertEventsResponse = + InsertEventsResponse.builder().rowIds(rowIds).build() + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + */ + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + @JsonProperty("serialized_span_slugs") + @ExcludeMissing + fun _serializedSpanSlugs() = serializedSpanSlugs + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectLogInsertResponse = apply { + if (!validated) { + rowIds() + serializedSpanSlugs() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var rowIds: JsonField> = JsonMissing.of() + private var serializedSpanSlugs: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectLogInsertResponse: ProjectLogInsertResponse) = apply { + this.rowIds = projectLogInsertResponse.rowIds + this.serializedSpanSlugs = projectLogInsertResponse.serializedSpanSlugs + additionalProperties(projectLogInsertResponse.additionalProperties) + } + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + @JsonProperty("row_ids") + @ExcludeMissing + fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + fun serializedSpanSlugs(serializedSpanSlugs: List) = + serializedSpanSlugs(JsonField.of(serializedSpanSlugs)) + + /** + * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' + * specifier to attach spans underneath the row + */ + @JsonProperty("serialized_span_slugs") + @ExcludeMissing + fun serializedSpanSlugs(serializedSpanSlugs: JsonField>) = apply { + this.serializedSpanSlugs = serializedSpanSlugs + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ProjectLogInsertResponse = + ProjectLogInsertResponse( + rowIds.map { it.toImmutable() }, + serializedSpanSlugs.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogInsertResponse && this.rowIds == other.rowIds && this.serializedSpanSlugs == other.serializedSpanSlugs && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(rowIds, serializedSpanSlugs, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectLogInsertResponse{rowIds=$rowIds, serializedSpanSlugs=$serializedSpanSlugs, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 539d5a13..2c59e71c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -1313,7 +1313,7 @@ private constructor( @NoAutoDetect class User private constructor( - private val content: JsonField, + private val content: JsonField, private val role: JsonField, private val name: JsonField, private val additionalProperties: Map, @@ -1321,7 +1321,7 @@ private constructor( private var validated: Boolean = false - fun content(): Optional = + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -1356,7 +1356,7 @@ private constructor( class Builder { - private var content: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -1370,11 +1370,13 @@ private constructor( additionalProperties(user.additionalProperties) } - fun content(content: Content) = content(JsonField.of(content)) + fun content(content: ChatCompletionContent) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun role(role: Role) = role(JsonField.of(role)) @@ -1464,330 +1466,6 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val text: String? = null, - private val array: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun text(): Optional = Optional.ofNullable(text) - - fun array(): Optional> = - Optional.ofNullable(array) - - fun isText(): Boolean = text != null - - fun isArray(): Boolean = array != null - - fun asText(): String = text.getOrThrow("text") - - fun asArray(): List = array.getOrThrow("array") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } - } - - fun validate(): Content = apply { - if (!validated) { - if (text == null && array == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - } - - override fun toString(): String { - return when { - text != null -> "Content{text=$text}" - array != null -> "Content{array=$array}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - } - - companion object { - - @JvmStatic fun ofText(text: String) = Content(text = text) - - @JvmStatic - fun ofArray(array: List) = - Content(array = array) - } - - interface Visitor { - - fun visitText(text: String): T - - fun visitArray(array: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") - } - } - - class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>() - ) - ?.let { - return Content(array = it, _json = json) - } - - return Content(_json = json) - } - } - - class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) - @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( - private val chatCompletionContentPartText: - ChatCompletionContentPartText? = - null, - private val chatCompletionContentPartImage: - ChatCompletionContentPartImage? = - null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): - Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): - Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = - chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = - chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow( - "chatCompletionContentPartText" - ) - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow( - "chatCompletionContentPartImage" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText( - chatCompletionContentPartText - ) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage( - chatCompletionContentPartImage - ) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && - chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = - chatCompletionContentPartText - ) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = - chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) - } - } - - class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize( - node, - jacksonTypeRef() - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize( - node, - jacksonTypeRef() - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject( - value.chatCompletionContentPartText - ) - value.chatCompletionContentPartImage != null -> - generator.writeObject( - value.chatCompletionContentPartImage - ) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) - } - } - } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index ca44dff1..730918fa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -79,8 +79,7 @@ interface DatasetServiceAsync { /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the URL query rather than in the request body */ @JvmOverloads fun fetch( @@ -90,8 +89,7 @@ interface DatasetServiceAsync { /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ @JvmOverloads fun fetchPost( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index b767b4bd..6e3ff5f3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -233,8 +233,7 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the URL query rather than in the request body */ override fun fetch( params: DatasetFetchParams, @@ -267,8 +266,7 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ override fun fetchPost( params: DatasetFetchPostParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index 1b601325..b96278ab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -12,6 +12,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -19,7 +20,6 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture @@ -79,8 +79,7 @@ interface ExperimentServiceAsync { /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the URL query rather than in the request body */ @JvmOverloads fun fetch( @@ -90,8 +89,7 @@ interface ExperimentServiceAsync { /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ @JvmOverloads fun fetchPost( @@ -104,7 +102,7 @@ interface ExperimentServiceAsync { fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Summarize experiment */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 7753231b..4468bf15 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -26,7 +27,6 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture @@ -233,8 +233,7 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the URL query rather than in the request body */ override fun fetch( params: ExperimentFetchParams, @@ -267,8 +266,7 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ override fun fetchPost( params: ExperimentFetchPostParams, @@ -296,14 +294,15 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index 782f3331..321b599c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture interface LogServiceAsync { @@ -25,8 +25,7 @@ interface LogServiceAsync { /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. + * the parameters in the URL query rather than in the request body */ @JvmOverloads fun fetch( @@ -36,8 +35,7 @@ interface LogServiceAsync { /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ @JvmOverloads fun fetchPost( @@ -50,5 +48,5 @@ interface LogServiceAsync { fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index a1432eaa..eda101b7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -14,11 +14,11 @@ import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture class LogServiceAsyncImpl @@ -64,8 +64,7 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. + * the parameters in the URL query rather than in the request body */ override fun fetch( params: ProjectLogFetchParams, @@ -98,8 +97,7 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ override fun fetchPost( params: ProjectLogFetchPostParams, @@ -127,14 +125,15 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 9a8e7b8e..418bb13a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -78,8 +78,7 @@ interface DatasetService { /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the URL query rather than in the request body */ @JvmOverloads fun fetch( @@ -89,8 +88,7 @@ interface DatasetService { /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ @JvmOverloads fun fetchPost( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 66b4afd6..24f60d84 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -211,8 +211,7 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the URL query rather than in the request body */ override fun fetch( params: DatasetFetchParams, @@ -244,8 +243,7 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ override fun fetchPost( params: DatasetFetchPostParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index b8dcc7bf..24ead7fd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -12,6 +12,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -19,7 +20,6 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse interface ExperimentService { @@ -78,8 +78,7 @@ interface ExperimentService { /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the URL query rather than in the request body */ @JvmOverloads fun fetch( @@ -89,8 +88,7 @@ interface ExperimentService { /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ @JvmOverloads fun fetchPost( @@ -103,7 +101,7 @@ interface ExperimentService { fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + ): ExperimentInsertResponse /** Summarize experiment */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index fdecad4d..c5e92523 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -19,6 +19,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -26,7 +27,6 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse class ExperimentServiceImpl @@ -226,8 +226,7 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the URL query rather than in the request body */ override fun fetch( params: ExperimentFetchParams, @@ -259,8 +258,7 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ override fun fetchPost( params: ExperimentFetchPostParams, @@ -287,14 +285,15 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): InsertEventsResponse { + ): ExperimentInsertResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index c36b6e81..cd4f4c96 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertResponse interface LogService { @@ -24,8 +24,7 @@ interface LogService { /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. + * the parameters in the URL query rather than in the request body */ @JvmOverloads fun fetch( @@ -35,8 +34,7 @@ interface LogService { /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ @JvmOverloads fun fetchPost( @@ -49,5 +47,5 @@ interface LogService { fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + ): ProjectLogInsertResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 72e74f7a..a7b5ed35 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -14,11 +14,11 @@ import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertResponse class LogServiceImpl constructor( @@ -62,8 +62,7 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. + * the parameters in the URL query rather than in the request body */ override fun fetch( params: ProjectLogFetchParams, @@ -95,8 +94,7 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * parameters in the request body rather than in the URL query */ override fun fetchPost( params: ProjectLogFetchPostParams, @@ -123,14 +121,15 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): InsertEventsResponse { + ): ProjectLogInsertResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index 116f69f8..e5ec92fd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -19,7 +19,6 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -38,7 +37,6 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -53,7 +51,6 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index f92d1111..cc6494aa 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,6 +14,15 @@ class DatasetFetchPostParamsTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -26,6 +36,15 @@ class DatasetFetchPostParamsTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -34,6 +53,16 @@ class DatasetFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()) + .isEqualTo( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index a0dafd44..b05c51e5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -22,7 +22,6 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -43,7 +42,6 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -60,7 +58,6 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index fde0406f..d48306d8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,6 +14,15 @@ class ExperimentFetchPostParamsTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -26,6 +36,15 @@ class ExperimentFetchPostParamsTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -34,6 +53,16 @@ class ExperimentFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()) + .isEqualTo( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index b3719906..76dd0db6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -15,7 +15,6 @@ class FeedbackDatasetItemTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) .build() assertThat(feedbackDatasetItem).isNotNull assertThat(feedbackDatasetItem.id()).isEqualTo("id") @@ -23,6 +22,5 @@ class FeedbackDatasetItemTest { assertThat(feedbackDatasetItem.metadata()) .contains(FeedbackDatasetItem.Metadata.builder().build()) assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) - assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index 7e050574..35ee660b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -18,7 +18,6 @@ class FeedbackExperimentItemTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) .build() assertThat(feedbackExperimentItem).isNotNull assertThat(feedbackExperimentItem.id()).isEqualTo("id") @@ -29,6 +28,5 @@ class FeedbackExperimentItemTest { assertThat(feedbackExperimentItem.scores()) .contains(FeedbackExperimentItem.Scores.builder().build()) assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) - assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index b622ead2..3f219e5d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -18,7 +18,6 @@ class FeedbackProjectLogsItemTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) .build() assertThat(feedbackProjectLogsItem).isNotNull assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") @@ -29,6 +28,5 @@ class FeedbackProjectLogsItemTest { assertThat(feedbackProjectLogsItem.scores()) .contains(FeedbackProjectLogsItem.Scores.builder().build()) assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) - assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt index dabc2d8c..50747d77 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt @@ -11,12 +11,10 @@ class PatchOrganizationMembersOutputTest { fun createPatchOrganizationMembersOutput() { val patchOrganizationMembersOutput = PatchOrganizationMembersOutput.builder() - .orgId("org_id") .status(PatchOrganizationMembersOutput.Status.SUCCESS) .sendEmailError("send_email_error") .build() assertThat(patchOrganizationMembersOutput).isNotNull - assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") assertThat(patchOrganizationMembersOutput.status()) .isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt new file mode 100644 index 00000000..4d32afc1 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import com.braintrustdata.api.core.JsonNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PathLookupFilterTest { + + @Test + fun createPathLookupFilter() { + val pathLookupFilter = + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + assertThat(pathLookupFilter).isNotNull + assertThat(pathLookupFilter.path()).containsExactly("string") + assertThat(pathLookupFilter.type()).isEqualTo(PathLookupFilter.Type.PATH_LOOKUP) + assertThat(pathLookupFilter._value()).isEqualTo(JsonNull.of()) + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index 4b9a5bb8..c2b19357 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -22,7 +22,6 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -43,7 +42,6 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -60,7 +58,6 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 421ef272..acb4cc3d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,6 +14,15 @@ class ProjectLogFetchPostParamsTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -26,6 +36,15 @@ class ProjectLogFetchPostParamsTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -34,6 +53,16 @@ class ProjectLogFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()) + .isEqualTo( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index 774cd505..0dd351c6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -124,7 +124,6 @@ class DatasetServiceTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -169,6 +168,15 @@ class DatasetServiceTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") 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 a80a6a14..0d9bc86d 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 @@ -161,7 +161,6 @@ class ExperimentServiceTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -206,6 +205,15 @@ class ExperimentServiceTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -224,7 +232,7 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val insertEventsResponse = + val experimentInsertResponse = experimentService.insert( ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -278,8 +286,7 @@ class ExperimentServiceTest { ) .build() ) - println(insertEventsResponse) - insertEventsResponse.validate() + println(experimentInsertResponse) } @Test 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 1ae8216b..74b8a98b 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 @@ -34,7 +34,6 @@ class LogServiceTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) .build() ) ) @@ -79,6 +78,15 @@ class LogServiceTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") + .filters( + listOf( + PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonNull.of()) + .build() + ) + ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -97,7 +105,7 @@ class LogServiceTest { .apiKey("My API Key") .build() val logService = client.projects().logs() - val insertEventsResponse = + val projectLogInsertResponse = logService.insert( ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -150,7 +158,6 @@ class LogServiceTest { ) .build() ) - println(insertEventsResponse) - insertEventsResponse.validate() + println(projectLogInsertResponse) } } From 8aea924ce9c2992c1f620f63c077de8e508852f6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 05:07:59 +0000 Subject: [PATCH 32/87] feat(api): manual updates (#100) --- .stats.yml | 2 +- .../api/models/ChatCompletionContent.kt | 293 --------------- .../api/models/DatasetFetchPostParams.kt | 67 +--- .../api/models/ExperimentFetchPostParams.kt | 67 +--- .../api/models/ExperimentInsertResponse.kt | 160 --------- .../api/models/FeedbackDatasetItem.kt | 40 ++- .../api/models/FeedbackExperimentItem.kt | 40 ++- .../api/models/FeedbackProjectLogsItem.kt | 40 ++- .../api/models/FunctionInvokeParams.kt | 307 +++++++++++++++- .../models/PatchOrganizationMembersOutput.kt | 25 +- .../api/models/PathLookupFilter.kt | 235 ------------ .../api/models/ProjectLogFetchPostParams.kt | 67 +--- .../api/models/ProjectLogInsertResponse.kt | 160 --------- .../braintrustdata/api/models/PromptData.kt | 336 +++++++++++++++++- .../api/services/async/DatasetServiceAsync.kt | 6 +- .../services/async/DatasetServiceAsyncImpl.kt | 6 +- .../services/async/ExperimentServiceAsync.kt | 10 +- .../async/ExperimentServiceAsyncImpl.kt | 15 +- .../async/projects/LogServiceAsync.kt | 10 +- .../async/projects/LogServiceAsyncImpl.kt | 15 +- .../api/services/blocking/DatasetService.kt | 6 +- .../services/blocking/DatasetServiceImpl.kt | 6 +- .../services/blocking/ExperimentService.kt | 10 +- .../blocking/ExperimentServiceImpl.kt | 15 +- .../services/blocking/projects/LogService.kt | 10 +- .../blocking/projects/LogServiceImpl.kt | 15 +- .../api/models/DatasetFeedbackParamsTest.kt | 3 + .../api/models/DatasetFetchPostParamsTest.kt | 29 -- .../models/ExperimentFeedbackParamsTest.kt | 3 + .../models/ExperimentFetchPostParamsTest.kt | 29 -- .../api/models/FeedbackDatasetItemTest.kt | 2 + .../api/models/FeedbackExperimentItemTest.kt | 2 + .../api/models/FeedbackProjectLogsItemTest.kt | 2 + .../PatchOrganizationMembersOutputTest.kt | 2 + .../api/models/PathLookupFilterTest.kt | 24 -- .../models/ProjectLogFeedbackParamsTest.kt | 3 + .../models/ProjectLogFetchPostParamsTest.kt | 29 -- .../services/blocking/DatasetServiceTest.kt | 10 +- .../blocking/ExperimentServiceTest.kt | 15 +- .../blocking/projects/LogServiceTest.kt | 15 +- 40 files changed, 863 insertions(+), 1268 deletions(-) delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt diff --git a/.stats.yml b/.stats.yml index 308af69e..bb136169 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-55d937fb23d3c593f54056e8ed9bcd9949b7f234649bc23e5c615e85b4309bb3.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-ce135a587d4ea037e39949984ed8f98578043e8c3a90fa203d24f28d234d8675.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt deleted file mode 100644 index 97e38a9a..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContent.kt +++ /dev/null @@ -1,293 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(using = ChatCompletionContent.Deserializer::class) -@JsonSerialize(using = ChatCompletionContent.Serializer::class) -class ChatCompletionContent -private constructor( - private val text: String? = null, - private val array: List? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun text(): Optional = Optional.ofNullable(text) - - fun array(): Optional> = Optional.ofNullable(array) - - fun isText(): Boolean = text != null - - fun isArray(): Boolean = array != null - - fun asText(): String = text.getOrThrow("text") - - fun asArray(): List = array.getOrThrow("array") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContent = apply { - if (!validated) { - if (text == null && array == null) { - throw BraintrustInvalidDataException("Unknown ChatCompletionContent: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContent && this.text == other.text && this.array == other.array /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - } - - override fun toString(): String { - return when { - text != null -> "ChatCompletionContent{text=$text}" - array != null -> "ChatCompletionContent{array=$array}" - _json != null -> "ChatCompletionContent{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContent") - } - } - - companion object { - - @JvmStatic fun ofText(text: String) = ChatCompletionContent(text = text) - - @JvmStatic - fun ofArray(array: List) = ChatCompletionContent(array = array) - } - - interface Visitor { - - fun visitText(text: String): T - - fun visitArray(array: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionContent: $json") - } - } - - class Deserializer : BaseDeserializer(ChatCompletionContent::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContent { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return ChatCompletionContent(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return ChatCompletionContent(array = it, _json = json) - } - - return ChatCompletionContent(_json = json) - } - } - - class Serializer : BaseSerializer(ChatCompletionContent::class) { - - override fun serialize( - value: ChatCompletionContent, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionContent") - } - } - } - - @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) - @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) - - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) - - fun isChatCompletionContentPartText(): Boolean = chatCompletionContentPartText != null - - fun isChatCompletionContentPartImage(): Boolean = chatCompletionContentPartImage != null - - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") - - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText(chatCompletionContentPartText) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage(chatCompletionContentPartImage) - else -> visitor.unknown(_json) - } - } - - fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ - } - - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } - - override fun toString(): String { - return when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" - _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - - companion object { - - @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = chatCompletionContentPartText - ) - - @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) - } - - interface Visitor { - - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") - } - } - - class Deserializer : - BaseDeserializer(ChatCompletionContentPart::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) - } - - return ChatCompletionContentPart(_json = json) - } - } - - class Serializer : - BaseSerializer(ChatCompletionContentPart::class) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } - } - } - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 6683ecc8..47e442c7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -20,7 +20,6 @@ class DatasetFetchPostParams constructor( private val datasetId: String, private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -34,8 +33,6 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) - fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -48,7 +45,6 @@ constructor( internal fun getBody(): DatasetFetchPostBody { return DatasetFetchPostBody( cursor, - filters, limit, maxRootSpanId, maxXactId, @@ -73,7 +69,6 @@ constructor( class DatasetFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -90,16 +85,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - @JsonProperty("filters") fun filters(): List? = filters - /** * limit the number of traces fetched * @@ -167,7 +152,6 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -177,7 +161,6 @@ constructor( @JvmSynthetic internal fun from(datasetFetchPostBody: DatasetFetchPostBody) = apply { this.cursor = datasetFetchPostBody.cursor - this.filters = datasetFetchPostBody.filters this.limit = datasetFetchPostBody.limit this.maxRootSpanId = datasetFetchPostBody.maxRootSpanId this.maxXactId = datasetFetchPostBody.maxXactId @@ -194,17 +177,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. - */ - @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } - /** * limit the number of traces fetched * @@ -278,7 +250,6 @@ constructor( fun build(): DatasetFetchPostBody = DatasetFetchPostBody( cursor, - filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -292,20 +263,20 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "DatasetFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -319,15 +290,15 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(datasetId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -341,7 +312,6 @@ constructor( private var datasetId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -354,7 +324,6 @@ constructor( internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = apply { this.datasetId = datasetFetchPostParams.datasetId this.cursor = datasetFetchPostParams.cursor - this.filters(datasetFetchPostParams.filters ?: listOf()) this.limit = datasetFetchPostParams.limit this.maxRootSpanId = datasetFetchPostParams.maxRootSpanId this.maxXactId = datasetFetchPostParams.maxXactId @@ -376,29 +345,6 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun filters(filters: List) = apply { - this.filters.clear() - this.filters.addAll(filters) - } - - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } - /** * limit the number of traces fetched * @@ -576,7 +522,6 @@ constructor( DatasetFetchPostParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 91fac9f8..53439ee7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -20,7 +20,6 @@ class ExperimentFetchPostParams constructor( private val experimentId: String, private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -34,8 +33,6 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) - fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -48,7 +45,6 @@ constructor( internal fun getBody(): ExperimentFetchPostBody { return ExperimentFetchPostBody( cursor, - filters, limit, maxRootSpanId, maxXactId, @@ -73,7 +69,6 @@ constructor( class ExperimentFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -90,16 +85,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - @JsonProperty("filters") fun filters(): List? = filters - /** * limit the number of traces fetched * @@ -167,7 +152,6 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -177,7 +161,6 @@ constructor( @JvmSynthetic internal fun from(experimentFetchPostBody: ExperimentFetchPostBody) = apply { this.cursor = experimentFetchPostBody.cursor - this.filters = experimentFetchPostBody.filters this.limit = experimentFetchPostBody.limit this.maxRootSpanId = experimentFetchPostBody.maxRootSpanId this.maxXactId = experimentFetchPostBody.maxXactId @@ -194,17 +177,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. - */ - @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } - /** * limit the number of traces fetched * @@ -278,7 +250,6 @@ constructor( fun build(): ExperimentFetchPostBody = ExperimentFetchPostBody( cursor, - filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -292,20 +263,20 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "ExperimentFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -319,15 +290,15 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(experimentId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -341,7 +312,6 @@ constructor( private var experimentId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -354,7 +324,6 @@ constructor( internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = apply { this.experimentId = experimentFetchPostParams.experimentId this.cursor = experimentFetchPostParams.cursor - this.filters(experimentFetchPostParams.filters ?: listOf()) this.limit = experimentFetchPostParams.limit this.maxRootSpanId = experimentFetchPostParams.maxRootSpanId this.maxXactId = experimentFetchPostParams.maxXactId @@ -376,29 +345,6 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun filters(filters: List) = apply { - this.filters.clear() - this.filters.addAll(filters) - } - - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } - /** * limit the number of traces fetched * @@ -576,7 +522,6 @@ constructor( ExperimentFetchPostParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt deleted file mode 100644 index b4bf81b7..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = ExperimentInsertResponse.Builder::class) -@NoAutoDetect -class ExperimentInsertResponse -private constructor( - private val rowIds: JsonField>, - private val serializedSpanSlugs: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - fun rowIds(): List = rowIds.getRequired("row_ids") - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - fun serializedSpanSlugs(): List = - serializedSpanSlugs.getRequired("serialized_span_slugs") - - fun toInsertEventsResponse(): InsertEventsResponse = - InsertEventsResponse.builder().rowIds(rowIds).build() - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - @JsonProperty("serialized_span_slugs") - @ExcludeMissing - fun _serializedSpanSlugs() = serializedSpanSlugs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ExperimentInsertResponse = apply { - if (!validated) { - rowIds() - serializedSpanSlugs() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var rowIds: JsonField> = JsonMissing.of() - private var serializedSpanSlugs: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(experimentInsertResponse: ExperimentInsertResponse) = apply { - this.rowIds = experimentInsertResponse.rowIds - this.serializedSpanSlugs = experimentInsertResponse.serializedSpanSlugs - additionalProperties(experimentInsertResponse.additionalProperties) - } - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - fun serializedSpanSlugs(serializedSpanSlugs: List) = - serializedSpanSlugs(JsonField.of(serializedSpanSlugs)) - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - @JsonProperty("serialized_span_slugs") - @ExcludeMissing - fun serializedSpanSlugs(serializedSpanSlugs: JsonField>) = apply { - this.serializedSpanSlugs = serializedSpanSlugs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ExperimentInsertResponse = - ExperimentInsertResponse( - rowIds.map { it.toImmutable() }, - serializedSpanSlugs.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentInsertResponse && this.rowIds == other.rowIds && this.serializedSpanSlugs == other.serializedSpanSlugs && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(rowIds, serializedSpanSlugs, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ExperimentInsertResponse{rowIds=$rowIds, serializedSpanSlugs=$serializedSpanSlugs, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 180d5da5..7c23b746 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -26,6 +26,7 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, + private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -42,13 +43,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** * The id of the dataset event to log feedback for. This is the row `id` returned by `POST * /v1/dataset/{dataset_id}/insert` @@ -60,13 +65,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -77,6 +86,7 @@ private constructor( comment() metadata().map { it.validate() } source() + tags() validated = true } } @@ -94,6 +104,7 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -102,6 +113,7 @@ private constructor( this.comment = feedbackDatasetItem.comment this.metadata = feedbackDatasetItem.metadata this.source = feedbackDatasetItem.source + this.tags = feedbackDatasetItem.tags additionalProperties(feedbackDatasetItem.additionalProperties) } @@ -127,13 +139,15 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing @@ -147,6 +161,14 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -167,13 +189,15 @@ private constructor( comment, metadata, source, + tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -315,18 +339,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackDatasetItem && this.id == other.id && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackDatasetItem && this.id == other.id && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, comment, metadata, source, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, comment, metadata, source, tags, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index 9a7f2303..ea2f3124 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -28,6 +28,7 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, + private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -56,13 +57,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** * The id of the experiment event to log feedback for. This is the row `id` returned by `POST * /v1/experiment/{experiment_id}/insert` @@ -86,13 +91,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -105,6 +114,7 @@ private constructor( comment() metadata().map { it.validate() } source() + tags() validated = true } } @@ -124,6 +134,7 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -134,6 +145,7 @@ private constructor( this.comment = feedbackExperimentItem.comment this.metadata = feedbackExperimentItem.metadata this.source = feedbackExperimentItem.source + this.tags = feedbackExperimentItem.tags additionalProperties(feedbackExperimentItem.additionalProperties) } @@ -181,13 +193,15 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing @@ -201,6 +215,14 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -223,13 +245,15 @@ private constructor( comment, metadata, source, + tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -447,18 +471,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackExperimentItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackExperimentItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 46b6f743..e717c6d1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -28,6 +28,7 @@ private constructor( private val comment: JsonField, private val metadata: JsonField, private val source: JsonField, + private val tags: JsonField>, private val additionalProperties: Map, ) { @@ -56,13 +57,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** * The id of the project logs event to log feedback for. This is the row `id` returned by `POST * /v1/project_logs/{project_id}/insert` @@ -86,13 +91,17 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing fun _source() = source + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -105,6 +114,7 @@ private constructor( comment() metadata().map { it.validate() } source() + tags() validated = true } } @@ -124,6 +134,7 @@ private constructor( private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() + private var tags: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -134,6 +145,7 @@ private constructor( this.comment = feedbackProjectLogsItem.comment this.metadata = feedbackProjectLogsItem.metadata this.source = feedbackProjectLogsItem.source + this.tags = feedbackProjectLogsItem.tags additionalProperties(feedbackProjectLogsItem.additionalProperties) } @@ -181,13 +193,15 @@ private constructor( /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ @JsonProperty("metadata") @ExcludeMissing @@ -201,6 +215,14 @@ private constructor( @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } + /** A list of tags to log */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** A list of tags to log */ + @JsonProperty("tags") + @ExcludeMissing + fun tags(tags: JsonField>) = apply { this.tags = tags } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -223,13 +245,15 @@ private constructor( comment, metadata, source, + tags.map { it.toImmutable() }, additionalProperties.toImmutable(), ) } /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect @@ -447,18 +471,18 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackProjectLogsItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackProjectLogsItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 963e7921..8d58dec8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -824,7 +824,7 @@ constructor( @NoAutoDetect class User private constructor( - private val content: JsonField, + private val content: JsonField, private val role: JsonField, private val name: JsonField, private val additionalProperties: Map, @@ -832,8 +832,7 @@ constructor( private var validated: Boolean = false - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -867,7 +866,7 @@ constructor( class Builder { - private var content: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -880,13 +879,11 @@ constructor( additionalProperties(user.additionalProperties) } - fun content(content: ChatCompletionContent) = content(JsonField.of(content)) + fun content(content: Content) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun role(role: Role) = role(JsonField.of(role)) @@ -975,6 +972,300 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val text: String? = null, + private val array: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun text(): Optional = Optional.ofNullable(text) + + fun array(): Optional> = Optional.ofNullable(array) + + fun isText(): Boolean = text != null + + fun isArray(): Boolean = array != null + + fun asText(): String = text.getOrThrow("text") + + fun asArray(): List = array.getOrThrow("array") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } + } + + fun validate(): Content = apply { + if (!validated) { + if (text == null && array == null) { + throw BraintrustInvalidDataException("Unknown Content: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ + } + + override fun toString(): String { + return when { + text != null -> "Content{text=$text}" + array != null -> "Content{array=$array}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + } + + companion object { + + @JvmStatic fun ofText(text: String) = Content(text = text) + + @JvmStatic + fun ofArray(array: List) = Content(array = array) + } + + interface Visitor { + + fun visitText(text: String): T + + fun visitArray(array: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Content: $json") + } + } + + class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>()) + ?.let { + return Content(array = it, _json = json) + } + + return Content(_json = json) + } + } + + class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val chatCompletionContentPartText: ChatCompletionContentPartText? = + null, + private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = + null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = + chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = + chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText( + chatCompletionContentPartText + ) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage( + chatCompletionContentPartImage + ) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if ( + chatCompletionContentPartText == null && + chatCompletionContentPartImage == null + ) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = + ChatCompletionContentPart( + chatCompletionContentPartText = chatCompletionContentPartText + ) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) + } + } + + class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject(value.chatCompletionContentPartText) + value.chatCompletionContentPartImage != null -> + generator.writeObject(value.chatCompletionContentPartImage) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid ChatCompletionContentPart") + } + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 7b98d59d..6f8bf79c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -23,6 +23,7 @@ import java.util.Optional class PatchOrganizationMembersOutput private constructor( private val status: JsonField, + private val orgId: JsonField, private val sendEmailError: JsonField, private val additionalProperties: Map, ) { @@ -31,6 +32,9 @@ private constructor( fun status(): Status = status.getRequired("status") + /** The id of the org that was modified. */ + fun orgId(): String = orgId.getRequired("org_id") + /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here @@ -40,6 +44,9 @@ private constructor( @JsonProperty("status") @ExcludeMissing fun _status() = status + /** The id of the org that was modified. */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here @@ -53,6 +60,7 @@ private constructor( fun validate(): PatchOrganizationMembersOutput = apply { if (!validated) { status() + orgId() sendEmailError() validated = true } @@ -68,12 +76,14 @@ private constructor( class Builder { private var status: JsonField = JsonMissing.of() + private var orgId: JsonField = JsonMissing.of() private var sendEmailError: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = apply { this.status = patchOrganizationMembersOutput.status + this.orgId = patchOrganizationMembersOutput.orgId this.sendEmailError = patchOrganizationMembersOutput.sendEmailError additionalProperties(patchOrganizationMembersOutput.additionalProperties) } @@ -84,6 +94,14 @@ private constructor( @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } + /** The id of the org that was modified. */ + fun orgId(orgId: String) = orgId(JsonField.of(orgId)) + + /** The id of the org that was modified. */ + @JsonProperty("org_id") + @ExcludeMissing + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + /** * If invite emails failed to send for some reason, the patch operation will still complete, * but we will return an error message here @@ -117,6 +135,7 @@ private constructor( fun build(): PatchOrganizationMembersOutput = PatchOrganizationMembersOutput( status, + orgId, sendEmailError, additionalProperties.toImmutable(), ) @@ -178,18 +197,18 @@ private constructor( return true } - return /* spotless:off */ other is PatchOrganizationMembersOutput && this.status == other.status && this.sendEmailError == other.sendEmailError && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PatchOrganizationMembersOutput && this.status == other.status && this.orgId == other.orgId && this.sendEmailError == other.sendEmailError && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(status, sendEmailError, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(status, orgId, sendEmailError, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "PatchOrganizationMembersOutput{status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + "PatchOrganizationMembersOutput{status=$status, orgId=$orgId, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt deleted file mode 100644 index 84540bbc..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt +++ /dev/null @@ -1,235 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -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 -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -/** - * A path-lookup filter describes an equality comparison against a specific sub-field in the event - * row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": - * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` - */ -@JsonDeserialize(builder = PathLookupFilter.Builder::class) -@NoAutoDetect -class PathLookupFilter -private constructor( - private val type: JsonField, - private val path: JsonField>, - private val value: JsonValue, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** Denotes the type of filter as a path-lookup filter */ - fun type(): Type = type.getRequired("type") - - /** - * List of fields describing the path to the value to be checked against. For instance, if you - * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - fun path(): List = path.getRequired("path") - - /** - * The value to compare equality-wise against the event value at the specified `path`. The value - * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. - * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": - * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - fun value(): JsonValue = value - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - /** - * List of fields describing the path to the value to be checked against. For instance, if you - * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") @ExcludeMissing fun _path() = path - - /** - * The value to compare equality-wise against the event value at the specified `path`. The value - * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. - * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": - * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") @ExcludeMissing fun _value() = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PathLookupFilter = apply { - if (!validated) { - type() - path() - value() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var path: JsonField> = JsonMissing.of() - private var value: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(pathLookupFilter: PathLookupFilter) = apply { - this.type = pathLookupFilter.type - this.path = pathLookupFilter.path - this.value = pathLookupFilter.value - additionalProperties(pathLookupFilter.additionalProperties) - } - - /** Denotes the type of filter as a path-lookup filter */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - fun path(path: List) = path(JsonField.of(path)) - - /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` - */ - @JsonProperty("path") - @ExcludeMissing - fun path(path: JsonField>) = apply { this.path = path } - - /** - * The value to compare equality-wise against the event value at the specified `path`. The - * value must be a "primitive", that is, any JSON-serializable object except for objects and - * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` - */ - @JsonProperty("value") - @ExcludeMissing - fun value(value: JsonValue) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PathLookupFilter = - PathLookupFilter( - type, - path.map { it.toImmutable() }, - value, - additionalProperties.toImmutable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val PATH_LOOKUP = Type(JsonField.of("path_lookup")) - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - PATH_LOOKUP, - } - - enum class Value { - PATH_LOOKUP, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PathLookupFilter && this.type == other.type && this.path == other.path && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, path, value, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "PathLookupFilter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index a2fa80bd..721df4c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -20,7 +20,6 @@ class ProjectLogFetchPostParams constructor( private val projectId: String, private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -34,8 +33,6 @@ constructor( fun cursor(): Optional = Optional.ofNullable(cursor) - fun filters(): Optional> = Optional.ofNullable(filters) - fun limit(): Optional = Optional.ofNullable(limit) fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) @@ -48,7 +45,6 @@ constructor( internal fun getBody(): ProjectLogFetchPostBody { return ProjectLogFetchPostBody( cursor, - filters, limit, maxRootSpanId, maxXactId, @@ -73,7 +69,6 @@ constructor( class ProjectLogFetchPostBody internal constructor( private val cursor: String?, - private val filters: List?, private val limit: Long?, private val maxRootSpanId: String?, private val maxXactId: String?, @@ -90,16 +85,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(): String? = cursor - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - @JsonProperty("filters") fun filters(): List? = filters - /** * limit the number of traces fetched * @@ -167,7 +152,6 @@ constructor( class Builder { private var cursor: String? = null - private var filters: List? = null private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -177,7 +161,6 @@ constructor( @JvmSynthetic internal fun from(projectLogFetchPostBody: ProjectLogFetchPostBody) = apply { this.cursor = projectLogFetchPostBody.cursor - this.filters = projectLogFetchPostBody.filters this.limit = projectLogFetchPostBody.limit this.maxRootSpanId = projectLogFetchPostBody.maxRootSpanId this.maxXactId = projectLogFetchPostBody.maxXactId @@ -194,17 +177,6 @@ constructor( */ @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. - */ - @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } - /** * limit the number of traces fetched * @@ -278,7 +250,6 @@ constructor( fun build(): ProjectLogFetchPostBody = ProjectLogFetchPostBody( cursor, - filters?.toImmutable(), limit, maxRootSpanId, maxXactId, @@ -292,20 +263,20 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostBody && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ } private var hashCode: Int = 0 override fun hashCode(): Int { if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ + hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ } return hashCode } override fun toString() = - "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "ProjectLogFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun _additionalHeaders(): Headers = additionalHeaders @@ -319,15 +290,15 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.filters == other.filters && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, cursor, filters, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(projectId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -341,7 +312,6 @@ constructor( private var projectId: String? = null private var cursor: String? = null - private var filters: MutableList = mutableListOf() private var limit: Long? = null private var maxRootSpanId: String? = null private var maxXactId: String? = null @@ -354,7 +324,6 @@ constructor( internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = apply { this.projectId = projectLogFetchPostParams.projectId this.cursor = projectLogFetchPostParams.cursor - this.filters(projectLogFetchPostParams.filters ?: listOf()) this.limit = projectLogFetchPostParams.limit this.maxRootSpanId = projectLogFetchPostParams.maxRootSpanId this.maxXactId = projectLogFetchPostParams.maxXactId @@ -376,29 +345,6 @@ constructor( */ fun cursor(cursor: String) = apply { this.cursor = cursor } - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun filters(filters: List) = apply { - this.filters.clear() - this.filters.addAll(filters) - } - - /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. - * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. - */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } - /** * limit the number of traces fetched * @@ -576,7 +522,6 @@ constructor( ProjectLogFetchPostParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, cursor, - if (filters.size == 0) null else filters.toImmutable(), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt deleted file mode 100644 index e529d36e..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toImmutable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = ProjectLogInsertResponse.Builder::class) -@NoAutoDetect -class ProjectLogInsertResponse -private constructor( - private val rowIds: JsonField>, - private val serializedSpanSlugs: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - fun rowIds(): List = rowIds.getRequired("row_ids") - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - fun serializedSpanSlugs(): List = - serializedSpanSlugs.getRequired("serialized_span_slugs") - - fun toInsertEventsResponse(): InsertEventsResponse = - InsertEventsResponse.builder().rowIds(rowIds).build() - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - @JsonProperty("serialized_span_slugs") - @ExcludeMissing - fun _serializedSpanSlugs() = serializedSpanSlugs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectLogInsertResponse = apply { - if (!validated) { - rowIds() - serializedSpanSlugs() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var rowIds: JsonField> = JsonMissing.of() - private var serializedSpanSlugs: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectLogInsertResponse: ProjectLogInsertResponse) = apply { - this.rowIds = projectLogInsertResponse.rowIds - this.serializedSpanSlugs = projectLogInsertResponse.serializedSpanSlugs - additionalProperties(projectLogInsertResponse.additionalProperties) - } - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - fun serializedSpanSlugs(serializedSpanSlugs: List) = - serializedSpanSlugs(JsonField.of(serializedSpanSlugs)) - - /** - * String slugs which line up 1-1 with the row_ids. These slugs can be used as the 'parent' - * specifier to attach spans underneath the row - */ - @JsonProperty("serialized_span_slugs") - @ExcludeMissing - fun serializedSpanSlugs(serializedSpanSlugs: JsonField>) = apply { - this.serializedSpanSlugs = serializedSpanSlugs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectLogInsertResponse = - ProjectLogInsertResponse( - rowIds.map { it.toImmutable() }, - serializedSpanSlugs.map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectLogInsertResponse && this.rowIds == other.rowIds && this.serializedSpanSlugs == other.serializedSpanSlugs && this.additionalProperties == other.additionalProperties /* spotless:on */ - } - - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(rowIds, serializedSpanSlugs, additionalProperties) /* spotless:on */ - } - return hashCode - } - - override fun toString() = - "ProjectLogInsertResponse{rowIds=$rowIds, serializedSpanSlugs=$serializedSpanSlugs, additionalProperties=$additionalProperties}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 2c59e71c..539d5a13 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -1313,7 +1313,7 @@ private constructor( @NoAutoDetect class User private constructor( - private val content: JsonField, + private val content: JsonField, private val role: JsonField, private val name: JsonField, private val additionalProperties: Map, @@ -1321,7 +1321,7 @@ private constructor( private var validated: Boolean = false - fun content(): Optional = + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun role(): Role = role.getRequired("role") @@ -1356,7 +1356,7 @@ private constructor( class Builder { - private var content: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -1370,13 +1370,11 @@ private constructor( additionalProperties(user.additionalProperties) } - fun content(content: ChatCompletionContent) = content(JsonField.of(content)) + fun content(content: Content) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun role(role: Role) = role(JsonField.of(role)) @@ -1466,6 +1464,330 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val text: String? = null, + private val array: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun text(): Optional = Optional.ofNullable(text) + + fun array(): Optional> = + Optional.ofNullable(array) + + fun isText(): Boolean = text != null + + fun isArray(): Boolean = array != null + + fun asText(): String = text.getOrThrow("text") + + fun asArray(): List = array.getOrThrow("array") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } + } + + fun validate(): Content = apply { + if (!validated) { + if (text == null && array == null) { + throw BraintrustInvalidDataException("Unknown Content: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ + } + + override fun toString(): String { + return when { + text != null -> "Content{text=$text}" + array != null -> "Content{array=$array}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + } + + companion object { + + @JvmStatic fun ofText(text: String) = Content(text = text) + + @JvmStatic + fun ofArray(array: List) = + Content(array = array) + } + + interface Visitor { + + fun visitText(text: String): T + + fun visitArray(array: List): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Content: $json") + } + } + + class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>() + ) + ?.let { + return Content(array = it, _json = json) + } + + return Content(_json = json) + } + } + + class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) + @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) + class ChatCompletionContentPart + private constructor( + private val chatCompletionContentPartText: + ChatCompletionContentPartText? = + null, + private val chatCompletionContentPartImage: + ChatCompletionContentPartImage? = + null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun chatCompletionContentPartText(): + Optional = + Optional.ofNullable(chatCompletionContentPartText) + + fun chatCompletionContentPartImage(): + Optional = + Optional.ofNullable(chatCompletionContentPartImage) + + fun isChatCompletionContentPartText(): Boolean = + chatCompletionContentPartText != null + + fun isChatCompletionContentPartImage(): Boolean = + chatCompletionContentPartImage != null + + fun asChatCompletionContentPartText(): ChatCompletionContentPartText = + chatCompletionContentPartText.getOrThrow( + "chatCompletionContentPartText" + ) + + fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = + chatCompletionContentPartImage.getOrThrow( + "chatCompletionContentPartImage" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + chatCompletionContentPartText != null -> + visitor.visitChatCompletionContentPartText( + chatCompletionContentPartText + ) + chatCompletionContentPartImage != null -> + visitor.visitChatCompletionContentPartImage( + chatCompletionContentPartImage + ) + else -> visitor.unknown(_json) + } + } + + fun validate(): ChatCompletionContentPart = apply { + if (!validated) { + if ( + chatCompletionContentPartText == null && + chatCompletionContentPartImage == null + ) { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $_json" + ) + } + chatCompletionContentPartText?.validate() + chatCompletionContentPartImage?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + } + + override fun toString(): String { + return when { + chatCompletionContentPartText != null -> + "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" + chatCompletionContentPartImage != null -> + "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + _json != null -> "ChatCompletionContentPart{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid ChatCompletionContentPart" + ) + } + } + + companion object { + + @JvmStatic + fun ofChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ) = + ChatCompletionContentPart( + chatCompletionContentPartText = + chatCompletionContentPartText + ) + + @JvmStatic + fun ofChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ) = + ChatCompletionContentPart( + chatCompletionContentPartImage = + chatCompletionContentPartImage + ) + } + + interface Visitor { + + fun visitChatCompletionContentPartText( + chatCompletionContentPartText: ChatCompletionContentPartText + ): T + + fun visitChatCompletionContentPartImage( + chatCompletionContentPartImage: ChatCompletionContentPartImage + ): T + + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) + } + } + + class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartText = it, + _json = json + ) + } + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + chatCompletionContentPartImage = it, + _json = json + ) + } + + return ChatCompletionContentPart(_json = json) + } + } + + class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.chatCompletionContentPartText != null -> + generator.writeObject( + value.chatCompletionContentPartText + ) + value.chatCompletionContentPartImage != null -> + generator.writeObject( + value.chatCompletionContentPartImage + ) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid ChatCompletionContentPart" + ) + } + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index 730918fa..ca44dff1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -79,7 +79,8 @@ interface DatasetServiceAsync { /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -89,7 +90,8 @@ interface DatasetServiceAsync { /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index 6e3ff5f3..b767b4bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -233,7 +233,8 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetch( params: DatasetFetchParams, @@ -266,7 +267,8 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: DatasetFetchPostParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index b96278ab..1b601325 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -12,7 +12,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -20,6 +19,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture @@ -79,7 +79,8 @@ interface ExperimentServiceAsync { /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -89,7 +90,8 @@ interface ExperimentServiceAsync { /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( @@ -102,7 +104,7 @@ interface ExperimentServiceAsync { fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture /** Summarize experiment */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 4468bf15..7753231b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -19,7 +19,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -27,6 +26,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture @@ -233,7 +233,8 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetch( params: ExperimentFetchParams, @@ -266,7 +267,8 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: ExperimentFetchPostParams, @@ -294,15 +296,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index 321b599c..782f3331 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture interface LogServiceAsync { @@ -25,7 +25,8 @@ interface LogServiceAsync { /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -35,7 +36,8 @@ interface LogServiceAsync { /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( @@ -48,5 +50,5 @@ interface LogServiceAsync { fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index eda101b7..a1432eaa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -14,11 +14,11 @@ import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse import java.util.concurrent.CompletableFuture class LogServiceAsyncImpl @@ -64,7 +64,8 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ override fun fetch( params: ProjectLogFetchParams, @@ -97,7 +98,8 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: ProjectLogFetchPostParams, @@ -125,15 +127,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): CompletableFuture { + ): CompletableFuture { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 418bb13a..9a8e7b8e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -78,7 +78,8 @@ interface DatasetService { /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -88,7 +89,8 @@ interface DatasetService { /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 24f60d84..66b4afd6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -211,7 +211,8 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetch( params: DatasetFetchParams, @@ -243,7 +244,8 @@ constructor( /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: DatasetFetchPostParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 24ead7fd..b8dcc7bf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -12,7 +12,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -20,6 +19,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse interface ExperimentService { @@ -78,7 +78,8 @@ interface ExperimentService { /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -88,7 +89,8 @@ interface ExperimentService { /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( @@ -101,7 +103,7 @@ interface ExperimentService { fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): ExperimentInsertResponse + ): InsertEventsResponse /** Summarize experiment */ @JvmOverloads diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index c5e92523..fdecad4d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -19,7 +19,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentInsertResponse import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -27,6 +26,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse class ExperimentServiceImpl @@ -226,7 +226,8 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetch( params: ExperimentFetchParams, @@ -258,7 +259,8 @@ constructor( /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: ExperimentFetchPostParams, @@ -285,15 +287,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions - ): ExperimentInsertResponse { + ): InsertEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index cd4f4c96..c36b6e81 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -7,11 +7,11 @@ package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse interface LogService { @@ -24,7 +24,8 @@ interface LogService { /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ @JvmOverloads fun fetch( @@ -34,7 +35,8 @@ interface LogService { /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ @JvmOverloads fun fetchPost( @@ -47,5 +49,5 @@ interface LogService { fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none() - ): ProjectLogInsertResponse + ): InsertEventsResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index a7b5ed35..72e74f7a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -14,11 +14,11 @@ import com.braintrustdata.api.core.json import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse +import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.models.ProjectLogInsertResponse class LogServiceImpl constructor( @@ -62,7 +62,8 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ override fun fetch( params: ProjectLogFetchParams, @@ -94,7 +95,8 @@ constructor( /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ override fun fetchPost( params: ProjectLogFetchPostParams, @@ -121,15 +123,14 @@ constructor( } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions - ): ProjectLogInsertResponse { + ): InsertEventsResponse { val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index e5ec92fd..116f69f8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -19,6 +19,7 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -37,6 +38,7 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -51,6 +53,7 @@ class DatasetFeedbackParamsTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index cc6494aa..f92d1111 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,15 +13,6 @@ class DatasetFetchPostParamsTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -36,15 +26,6 @@ class DatasetFetchPostParamsTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -53,16 +34,6 @@ class DatasetFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index b05c51e5..a0dafd44 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -22,6 +22,7 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -42,6 +43,7 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -58,6 +60,7 @@ class ExperimentFeedbackParamsTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index d48306d8..fde0406f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,15 +13,6 @@ class ExperimentFetchPostParamsTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -36,15 +26,6 @@ class ExperimentFetchPostParamsTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -53,16 +34,6 @@ class ExperimentFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index 76dd0db6..b3719906 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -15,6 +15,7 @@ class FeedbackDatasetItemTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() assertThat(feedbackDatasetItem).isNotNull assertThat(feedbackDatasetItem.id()).isEqualTo("id") @@ -22,5 +23,6 @@ class FeedbackDatasetItemTest { assertThat(feedbackDatasetItem.metadata()) .contains(FeedbackDatasetItem.Metadata.builder().build()) assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) + assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index 35ee660b..7e050574 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -18,6 +18,7 @@ class FeedbackExperimentItemTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() assertThat(feedbackExperimentItem).isNotNull assertThat(feedbackExperimentItem.id()).isEqualTo("id") @@ -28,5 +29,6 @@ class FeedbackExperimentItemTest { assertThat(feedbackExperimentItem.scores()) .contains(FeedbackExperimentItem.Scores.builder().build()) assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) + assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index 3f219e5d..b622ead2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -18,6 +18,7 @@ class FeedbackProjectLogsItemTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() assertThat(feedbackProjectLogsItem).isNotNull assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") @@ -28,5 +29,6 @@ class FeedbackProjectLogsItemTest { assertThat(feedbackProjectLogsItem.scores()) .contains(FeedbackProjectLogsItem.Scores.builder().build()) assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) + assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt index 50747d77..dabc2d8c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt @@ -11,10 +11,12 @@ class PatchOrganizationMembersOutputTest { fun createPatchOrganizationMembersOutput() { val patchOrganizationMembersOutput = PatchOrganizationMembersOutput.builder() + .orgId("org_id") .status(PatchOrganizationMembersOutput.Status.SUCCESS) .sendEmailError("send_email_error") .build() assertThat(patchOrganizationMembersOutput).isNotNull + assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") assertThat(patchOrganizationMembersOutput.status()) .isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt deleted file mode 100644 index 4d32afc1..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PathLookupFilterTest { - - @Test - fun createPathLookupFilter() { - val pathLookupFilter = - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - assertThat(pathLookupFilter).isNotNull - assertThat(pathLookupFilter.path()).containsExactly("string") - assertThat(pathLookupFilter.type()).isEqualTo(PathLookupFilter.Type.PATH_LOOKUP) - assertThat(pathLookupFilter._value()).isEqualTo(JsonNull.of()) - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index c2b19357..4b9a5bb8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -22,6 +22,7 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -42,6 +43,7 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -58,6 +60,7 @@ class ProjectLogFeedbackParamsTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() ) ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index acb4cc3d..421ef272 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -2,7 +2,6 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,15 +13,6 @@ class ProjectLogFetchPostParamsTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -36,15 +26,6 @@ class ProjectLogFetchPostParamsTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -53,16 +34,6 @@ class ProjectLogFetchPostParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) assertThat(body.limit()).isEqualTo(123L) assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") assertThat(body.maxXactId()).isEqualTo("max_xact_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index 0dd351c6..774cd505 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -124,6 +124,7 @@ class DatasetServiceTest { .comment("comment") .metadata(FeedbackDatasetItem.Metadata.builder().build()) .source(FeedbackDatasetItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -168,15 +169,6 @@ class DatasetServiceTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") 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 0d9bc86d..a80a6a14 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 @@ -161,6 +161,7 @@ class ExperimentServiceTest { .metadata(FeedbackExperimentItem.Metadata.builder().build()) .scores(FeedbackExperimentItem.Scores.builder().build()) .source(FeedbackExperimentItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -205,15 +206,6 @@ class ExperimentServiceTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -232,7 +224,7 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val experimentInsertResponse = + val insertEventsResponse = experimentService.insert( ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -286,7 +278,8 @@ class ExperimentServiceTest { ) .build() ) - println(experimentInsertResponse) + println(insertEventsResponse) + insertEventsResponse.validate() } @Test 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 74b8a98b..1ae8216b 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 @@ -34,6 +34,7 @@ class LogServiceTest { .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) .scores(FeedbackProjectLogsItem.Scores.builder().build()) .source(FeedbackProjectLogsItem.Source.APP) + .tags(listOf("string")) .build() ) ) @@ -78,15 +79,6 @@ class LogServiceTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonNull.of()) - .build() - ) - ) .limit(123L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") @@ -105,7 +97,7 @@ class LogServiceTest { .apiKey("My API Key") .build() val logService = client.projects().logs() - val projectLogInsertResponse = + val insertEventsResponse = logService.insert( ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -158,6 +150,7 @@ class LogServiceTest { ) .build() ) - println(projectLogInsertResponse) + println(insertEventsResponse) + insertEventsResponse.validate() } } From 1d5c887b11473e110a197d004a278f9abf8ed4c4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:30:33 +0000 Subject: [PATCH 33/87] chore(deps): bump jackson to 2.18.1 (#101) --- braintrust-java-core/build.gradle.kts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/braintrust-java-core/build.gradle.kts b/braintrust-java-core/build.gradle.kts index de260952..840fffe3 100755 --- a/braintrust-java-core/build.gradle.kts +++ b/braintrust-java-core/build.gradle.kts @@ -4,13 +4,13 @@ plugins { } dependencies { - api("com.fasterxml.jackson.core:jackson-core:2.14.3") - api("com.fasterxml.jackson.core:jackson-databind:2.14.3") + api("com.fasterxml.jackson.core:jackson-core:2.18.1") + api("com.fasterxml.jackson.core:jackson-databind:2.18.1") - implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.3") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.3") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3") + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1") implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") From f09c5a01a41e464796e781e9923a96f501786242 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:37:17 +0000 Subject: [PATCH 34/87] style(internal): reduce verbosity of identity methods (#103) --- .../api/errors/BraintrustError.kt | 6 +- .../com/braintrustdata/api/models/Acl.kt | 19 +- .../api/models/AclBatchUpdateParams.kt | 57 ++-- .../api/models/AclBatchUpdateResponse.kt | 13 +- .../api/models/AclCreateParams.kt | 25 +- .../api/models/AclDeleteParams.kt | 6 +- .../api/models/AclFindAndDeleteParams.kt | 25 +- .../braintrustdata/api/models/AclListPage.kt | 14 +- .../api/models/AclListPageAsync.kt | 14 +- .../api/models/AclListParams.kt | 19 +- .../api/models/AclRetrieveParams.kt | 6 +- .../com/braintrustdata/api/models/AiSecret.kt | 26 +- .../api/models/AiSecretCreateParams.kt | 32 +- .../api/models/AiSecretDeleteParams.kt | 6 +- .../api/models/AiSecretFindAndDeleteParams.kt | 19 +- .../api/models/AiSecretListPage.kt | 14 +- .../api/models/AiSecretListPageAsync.kt | 14 +- .../api/models/AiSecretListParams.kt | 28 +- .../api/models/AiSecretReplaceParams.kt | 32 +- .../api/models/AiSecretRetrieveParams.kt | 6 +- .../api/models/AiSecretUpdateParams.kt | 32 +- .../com/braintrustdata/api/models/ApiKey.kt | 13 +- .../api/models/ApiKeyCreateParams.kt | 19 +- .../api/models/ApiKeyDeleteParams.kt | 6 +- .../api/models/ApiKeyListPage.kt | 14 +- .../api/models/ApiKeyListPageAsync.kt | 14 +- .../api/models/ApiKeyListParams.kt | 17 +- .../api/models/ApiKeyRetrieveParams.kt | 6 +- .../models/ChatCompletionContentPartImage.kt | 30 +- .../models/ChatCompletionContentPartText.kt | 15 +- .../models/ChatCompletionMessageToolCall.kt | 28 +- .../braintrustdata/api/models/CodeBundle.kt | 110 +++---- .../api/models/CreateApiKeyOutput.kt | 13 +- .../api/models/CrossObjectInsertResponse.kt | 52 ++-- .../braintrustdata/api/models/DataSummary.kt | 13 +- .../com/braintrustdata/api/models/Dataset.kt | 26 +- .../api/models/DatasetCreateParams.kt | 32 +- .../api/models/DatasetDeleteParams.kt | 6 +- .../braintrustdata/api/models/DatasetEvent.kt | 41 +-- .../api/models/DatasetFeedbackParams.kt | 19 +- .../api/models/DatasetFetchParams.kt | 6 +- .../api/models/DatasetFetchPostParams.kt | 19 +- .../api/models/DatasetInsertParams.kt | 19 +- .../api/models/DatasetListPage.kt | 14 +- .../api/models/DatasetListPageAsync.kt | 14 +- .../api/models/DatasetListParams.kt | 17 +- .../api/models/DatasetRetrieveParams.kt | 6 +- .../api/models/DatasetSummarizeParams.kt | 6 +- .../api/models/DatasetUpdateParams.kt | 32 +- .../com/braintrustdata/api/models/EnvVar.kt | 15 +- .../api/models/EnvVarCreateParams.kt | 21 +- .../api/models/EnvVarDeleteParams.kt | 6 +- .../api/models/EnvVarListParams.kt | 19 +- .../api/models/EnvVarListResponse.kt | 13 +- .../api/models/EnvVarReplaceParams.kt | 21 +- .../api/models/EnvVarRetrieveParams.kt | 6 +- .../api/models/EnvVarUpdateParams.kt | 19 +- .../api/models/EvalCreateParams.kt | 294 +++++++----------- .../braintrustdata/api/models/Experiment.kt | 26 +- .../api/models/ExperimentCreateParams.kt | 32 +- .../api/models/ExperimentDeleteParams.kt | 6 +- .../api/models/ExperimentEvent.kt | 80 ++--- .../api/models/ExperimentFeedbackParams.kt | 19 +- .../api/models/ExperimentFetchParams.kt | 6 +- .../api/models/ExperimentFetchPostParams.kt | 19 +- .../api/models/ExperimentInsertParams.kt | 19 +- .../api/models/ExperimentListPage.kt | 14 +- .../api/models/ExperimentListPageAsync.kt | 14 +- .../api/models/ExperimentListParams.kt | 17 +- .../api/models/ExperimentRetrieveParams.kt | 6 +- .../api/models/ExperimentSummarizeParams.kt | 6 +- .../api/models/ExperimentUpdateParams.kt | 32 +- .../api/models/FeedbackDatasetItem.kt | 28 +- .../api/models/FeedbackExperimentItem.kt | 41 +-- .../api/models/FeedbackProjectLogsItem.kt | 41 +-- .../api/models/FeedbackResponseSchema.kt | 15 +- .../api/models/FetchDatasetEventsResponse.kt | 13 +- .../models/FetchExperimentEventsResponse.kt | 13 +- .../models/FetchProjectLogsEventsResponse.kt | 13 +- .../com/braintrustdata/api/models/Function.kt | 170 ++++------ .../api/models/FunctionCreateParams.kt | 161 ++++------ .../api/models/FunctionDeleteParams.kt | 6 +- .../api/models/FunctionInvokeParams.kt | 209 +++++-------- .../api/models/FunctionInvokeResponse.kt | 13 +- .../api/models/FunctionListPage.kt | 14 +- .../api/models/FunctionListPageAsync.kt | 14 +- .../api/models/FunctionListParams.kt | 17 +- .../api/models/FunctionReplaceParams.kt | 161 ++++------ .../api/models/FunctionRetrieveParams.kt | 6 +- .../api/models/FunctionUpdateParams.kt | 144 ++++----- .../com/braintrustdata/api/models/Group.kt | 13 +- .../api/models/GroupCreateParams.kt | 19 +- .../api/models/GroupDeleteParams.kt | 6 +- .../api/models/GroupListPage.kt | 14 +- .../api/models/GroupListPageAsync.kt | 14 +- .../api/models/GroupListParams.kt | 17 +- .../api/models/GroupReplaceParams.kt | 19 +- .../api/models/GroupRetrieveParams.kt | 6 +- .../api/models/GroupUpdateParams.kt | 19 +- .../api/models/InsertDatasetEvent.kt | 26 +- .../api/models/InsertEventsResponse.kt | 13 +- .../api/models/InsertExperimentEvent.kt | 65 ++-- .../api/models/InsertProjectLogsEvent.kt | 65 ++-- .../api/models/MetricSummary.kt | 13 +- .../api/models/OnlineScoreConfig.kt | 54 ++-- .../braintrustdata/api/models/Organization.kt | 13 +- .../api/models/OrganizationDeleteParams.kt | 6 +- .../api/models/OrganizationListPage.kt | 14 +- .../api/models/OrganizationListPageAsync.kt | 14 +- .../api/models/OrganizationListParams.kt | 17 +- .../models/OrganizationMemberUpdateParams.kt | 45 +-- .../api/models/OrganizationRetrieveParams.kt | 6 +- .../api/models/OrganizationUpdateParams.kt | 19 +- .../models/PatchOrganizationMembersOutput.kt | 15 +- .../com/braintrustdata/api/models/Project.kt | 13 +- .../api/models/ProjectCreateParams.kt | 19 +- .../api/models/ProjectDeleteParams.kt | 6 +- .../api/models/ProjectListPage.kt | 14 +- .../api/models/ProjectListPageAsync.kt | 14 +- .../api/models/ProjectListParams.kt | 17 +- .../api/models/ProjectLogFeedbackParams.kt | 19 +- .../api/models/ProjectLogFetchParams.kt | 6 +- .../api/models/ProjectLogFetchPostParams.kt | 19 +- .../api/models/ProjectLogInsertParams.kt | 19 +- .../api/models/ProjectLogsEvent.kt | 82 ++--- .../api/models/ProjectRetrieveParams.kt | 6 +- .../braintrustdata/api/models/ProjectScore.kt | 52 ++-- .../api/models/ProjectScoreCategory.kt | 13 +- .../api/models/ProjectScoreConfig.kt | 15 +- .../api/models/ProjectScoreCreateParams.kt | 58 ++-- .../api/models/ProjectScoreDeleteParams.kt | 6 +- .../api/models/ProjectScoreListPage.kt | 14 +- .../api/models/ProjectScoreListPageAsync.kt | 14 +- .../api/models/ProjectScoreListParams.kt | 32 +- .../api/models/ProjectScoreReplaceParams.kt | 58 ++-- .../api/models/ProjectScoreRetrieveParams.kt | 6 +- .../api/models/ProjectScoreUpdateParams.kt | 58 ++-- .../api/models/ProjectSettings.kt | 13 +- .../braintrustdata/api/models/ProjectTag.kt | 13 +- .../api/models/ProjectTagCreateParams.kt | 19 +- .../api/models/ProjectTagDeleteParams.kt | 6 +- .../api/models/ProjectTagListPage.kt | 14 +- .../api/models/ProjectTagListPageAsync.kt | 14 +- .../api/models/ProjectTagListParams.kt | 17 +- .../api/models/ProjectTagReplaceParams.kt | 19 +- .../api/models/ProjectTagRetrieveParams.kt | 6 +- .../api/models/ProjectTagUpdateParams.kt | 19 +- .../api/models/ProjectUpdateParams.kt | 19 +- .../com/braintrustdata/api/models/Prompt.kt | 30 +- .../api/models/PromptCreateParams.kt | 21 +- .../braintrustdata/api/models/PromptData.kt | 285 +++++++---------- .../api/models/PromptDeleteParams.kt | 6 +- .../api/models/PromptListPage.kt | 14 +- .../api/models/PromptListPageAsync.kt | 14 +- .../api/models/PromptListParams.kt | 17 +- .../api/models/PromptOptions.kt | 257 ++++++--------- .../api/models/PromptReplaceParams.kt | 21 +- .../api/models/PromptRetrieveParams.kt | 6 +- .../api/models/PromptUpdateParams.kt | 19 +- .../com/braintrustdata/api/models/RepoInfo.kt | 13 +- .../com/braintrustdata/api/models/Role.kt | 30 +- .../api/models/RoleCreateParams.kt | 36 +-- .../api/models/RoleDeleteParams.kt | 6 +- .../braintrustdata/api/models/RoleListPage.kt | 14 +- .../api/models/RoleListPageAsync.kt | 14 +- .../api/models/RoleListParams.kt | 17 +- .../api/models/RoleReplaceParams.kt | 36 +-- .../api/models/RoleRetrieveParams.kt | 6 +- .../api/models/RoleUpdateParams.kt | 53 ++-- .../braintrustdata/api/models/ScoreSummary.kt | 13 +- .../api/models/SpanAttributes.kt | 15 +- .../braintrustdata/api/models/SpanIFrame.kt | 13 +- .../api/models/SpanIframeCreateParams.kt | 19 +- .../api/models/SpanIframeDeleteParams.kt | 6 +- .../api/models/SpanIframeListPage.kt | 14 +- .../api/models/SpanIframeListPageAsync.kt | 14 +- .../api/models/SpanIframeListParams.kt | 17 +- .../api/models/SpanIframeReplaceParams.kt | 19 +- .../api/models/SpanIframeRetrieveParams.kt | 6 +- .../api/models/SpanIframeUpdateParams.kt | 19 +- .../api/models/SummarizeDatasetResponse.kt | 13 +- .../api/models/SummarizeExperimentResponse.kt | 39 +-- .../api/models/TopLevelHelloWorldParams.kt | 6 +- .../com/braintrustdata/api/models/User.kt | 13 +- .../braintrustdata/api/models/UserListPage.kt | 14 +- .../api/models/UserListPageAsync.kt | 14 +- .../api/models/UserListParams.kt | 50 ++- .../api/models/UserRetrieveParams.kt | 6 +- .../com/braintrustdata/api/models/View.kt | 17 +- .../api/models/ViewCreateParams.kt | 23 +- .../com/braintrustdata/api/models/ViewData.kt | 13 +- .../api/models/ViewDataSearch.kt | 13 +- .../api/models/ViewDeleteParams.kt | 21 +- .../braintrustdata/api/models/ViewListPage.kt | 14 +- .../api/models/ViewListPageAsync.kt | 14 +- .../api/models/ViewListParams.kt | 21 +- .../braintrustdata/api/models/ViewOptions.kt | 39 +-- .../api/models/ViewReplaceParams.kt | 23 +- .../api/models/ViewRetrieveParams.kt | 8 +- .../api/models/ViewUpdateParams.kt | 23 +- 200 files changed, 2086 insertions(+), 3408 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index 87dcc685..3f29cfb6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -24,12 +24,10 @@ private constructor( return true } - return /* spotless:off */ other is BraintrustError && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ override fun toString() = "BraintrustError{additionalProperties=$additionalProperties}" 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 3b094948..47f0796c 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 @@ -330,7 +330,7 @@ private constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -441,7 +441,7 @@ private constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -534,7 +534,7 @@ private constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -637,17 +637,14 @@ private constructor( return true } - return /* spotless:off */ other is Acl && this.id == other.id && this.objectType == other.objectType && this.objectId == other.objectId && this.userId == other.userId && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this._objectOrgId == other._objectOrgId && this.created == other.created && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Acl && id == other.id && objectType == other.objectType && objectId == other.objectId && userId == other.userId && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && _objectOrgId == other._objectOrgId && created == other.created && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, _objectOrgId, created, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, _objectOrgId, created, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Acl{id=$id, objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, _objectOrgId=$_objectOrgId, created=$created, additionalProperties=$additionalProperties}" 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 583e8229..52bf1c5d 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 @@ -158,17 +158,14 @@ constructor( return true } - return /* spotless:off */ other is AclBatchUpdateBody && this.addAcls == other.addAcls && this.removeAcls == other.removeAcls && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateBody && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(addAcls, removeAcls, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AclBatchUpdateBody{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" @@ -185,12 +182,10 @@ constructor( return true } - return /* spotless:off */ other is AclBatchUpdateParams && this.addAcls == other.addAcls && this.removeAcls == other.removeAcls && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateParams && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AclBatchUpdateParams{addAcls=$addAcls, removeAcls=$removeAcls, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -577,7 +572,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -688,7 +683,7 @@ constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -781,7 +776,7 @@ constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -885,17 +880,14 @@ constructor( return true } - return /* spotless:off */ other is AddAcl && this.objectType == other.objectType && this.objectId == other.objectId && this.userId == other.userId && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddAcl && objectType == other.objectType && objectId == other.objectId && userId == other.userId && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AddAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" @@ -1074,7 +1066,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1185,7 +1177,7 @@ constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1278,7 +1270,7 @@ constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1382,17 +1374,14 @@ constructor( return true } - return /* spotless:off */ other is RemoveAcl && this.objectType == other.objectType && this.objectId == other.objectId && this.userId == other.userId && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveAcl && objectType == other.objectType && objectId == other.objectId && userId == other.userId && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RemoveAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index a9055b0d..becae827 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -186,17 +186,14 @@ private constructor( return true } - return /* spotless:off */ other is AclBatchUpdateResponse && this.addedAcls == other.addedAcls && this.removedAcls == other.removedAcls && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateResponse && addedAcls == other.addedAcls && removedAcls == other.removedAcls && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(addedAcls, removedAcls, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(addedAcls, removedAcls, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" 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 71cf1b88..e11ac71b 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 @@ -231,17 +231,14 @@ constructor( return true } - return /* spotless:off */ other is AclCreateBody && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AclCreateBody && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" @@ -258,12 +255,10 @@ constructor( return true } - return /* spotless:off */ other is AclCreateParams && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclCreateParams && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -485,7 +480,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -596,7 +591,7 @@ constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -689,7 +684,7 @@ constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 4c951af3..b541d640 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is AclDeleteParams && this.aclId == other.aclId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" 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 31777cde..479c0be0 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 @@ -231,17 +231,14 @@ constructor( return true } - return /* spotless:off */ other is AclFindAndDeleteBody && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AclFindAndDeleteBody && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AclFindAndDeleteBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" @@ -258,12 +255,10 @@ constructor( return true } - return /* spotless:off */ other is AclFindAndDeleteParams && this.objectId == other.objectId && this.objectType == other.objectType && this.groupId == other.groupId && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.roleId == other.roleId && this.userId == other.userId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclFindAndDeleteParams && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AclFindAndDeleteParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -485,7 +480,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -596,7 +591,7 @@ constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -689,7 +684,7 @@ constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index 2e952c62..2fe666f6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is AclListPage && this.aclsService == other.aclsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is AclListPage && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ override fun toString() = "AclListPage{aclsService=$aclsService, params=$params, response=$response}" @@ -114,15 +112,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "AclListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index 681e3c3a..816bc8b5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is AclListPageAsync && this.aclsService == other.aclsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is AclListPageAsync && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ override fun toString() = "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" @@ -117,15 +115,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "AclListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { 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 990fdc7d..95d5f345 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 @@ -72,12 +72,10 @@ constructor( return true } - return /* spotless:off */ other is AclListParams && this.objectId == other.objectId && this.objectType == other.objectType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -282,7 +280,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -427,21 +425,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 66f18f2d..4ed1a558 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is AclRetrieveParams && this.aclId == other.aclId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt index fcd4b525..db8234cd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt @@ -250,17 +250,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -270,17 +267,14 @@ private constructor( return true } - return /* spotless:off */ other is AISecret && this.id == other.id && this.created == other.created && this.orgId == other.orgId && this.name == other.name && this.type == other.type && this.metadata == other.metadata && this.previewSecret == other.previewSecret && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AISecret && id == other.id && created == other.created && orgId == other.orgId && name == other.name && type == other.type && metadata == other.metadata && previewSecret == other.previewSecret && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, created, orgId, name, type, metadata, previewSecret, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, created, orgId, name, type, metadata, previewSecret, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AISecret{id=$id, created=$created, orgId=$orgId, name=$name, type=$type, metadata=$metadata, previewSecret=$previewSecret, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 29ceb91c..1120354a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -168,17 +168,14 @@ constructor( return true } - return /* spotless:off */ other is AiSecretCreateBody && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretCreateBody && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, metadata, orgName, secret, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AiSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" @@ -195,12 +192,10 @@ constructor( return true } - return /* spotless:off */ other is AiSecretCreateParams && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretCreateParams && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AiSecretCreateParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -438,17 +433,14 @@ constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index c10eddd4..54d772a9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is AiSecretDeleteParams && this.aiSecretId == other.aiSecretId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index a8d4c8df..5eaecc0f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -123,17 +123,14 @@ constructor( return true } - return /* spotless:off */ other is AiSecretFindAndDeleteBody && this.name == other.name && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretFindAndDeleteBody && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, orgName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, orgName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AiSecretFindAndDeleteBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" @@ -150,12 +147,10 @@ constructor( return true } - return /* spotless:off */ other is AiSecretFindAndDeleteParams && this.name == other.name && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretFindAndDeleteParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AiSecretFindAndDeleteParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index 23448015..159cdb0c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is AiSecretListPage && this.aiSecretsService == other.aiSecretsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is AiSecretListPage && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ override fun toString() = "AiSecretListPage{aiSecretsService=$aiSecretsService, params=$params, response=$response}" @@ -120,15 +118,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "AiSecretListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 1a91a044..35287dea 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is AiSecretListPageAsync && this.aiSecretsService == other.aiSecretsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is AiSecretListPageAsync && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ override fun toString() = "AiSecretListPageAsync{aiSecretsService=$aiSecretsService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "AiSecretListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 53a51901..1ce8f821 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -73,12 +73,10 @@ constructor( return true } - return /* spotless:off */ other is AiSecretListParams && this.aiSecretName == other.aiSecretName && this.aiSecretType == other.aiSecretType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -330,21 +328,18 @@ constructor( return true } - return /* spotless:off */ other is AiSecretType && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is AiSecretType && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "AiSecretType{string=$string}" strings != null -> "AiSecretType{strings=$strings}" _json != null -> "AiSecretType{_unknown=$_json}" else -> throw IllegalStateException("Invalid AiSecretType") } - } companion object { @@ -444,21 +439,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index ca225346..d80328d8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -168,17 +168,14 @@ constructor( return true } - return /* spotless:off */ other is AiSecretReplaceBody && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretReplaceBody && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, metadata, orgName, secret, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AiSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" @@ -195,12 +192,10 @@ constructor( return true } - return /* spotless:off */ other is AiSecretReplaceParams && this.name == other.name && this.metadata == other.metadata && this.orgName == other.orgName && this.secret == other.secret && this.type == other.type && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretReplaceParams && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AiSecretReplaceParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -438,17 +433,14 @@ constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index 0d784169..924b14cc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is AiSecretRetrieveParams && this.aiSecretId == other.aiSecretId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 0dd8675d..e932ad65 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -147,17 +147,14 @@ constructor( return true } - return /* spotless:off */ other is AiSecretUpdateBody && this.metadata == other.metadata && this.name == other.name && this.secret == other.secret && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretUpdateBody && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, name, secret, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(metadata, name, secret, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AiSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" @@ -174,12 +171,10 @@ constructor( return true } - return /* spotless:off */ other is AiSecretUpdateParams && this.aiSecretId == other.aiSecretId && this.metadata == other.metadata && this.name == other.name && this.secret == other.secret && this.type == other.type && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(aiSecretId, metadata, name, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, metadata, name, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "AiSecretUpdateParams{aiSecretId=$aiSecretId, metadata=$metadata, name=$name, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -409,17 +404,14 @@ constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 3442296e..4a87b0da 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -184,17 +184,14 @@ private constructor( return true } - return /* spotless:off */ other is ApiKey && this.id == other.id && this.created == other.created && this.name == other.name && this.previewName == other.previewName && this.userId == other.userId && this.orgId == other.orgId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ApiKey && id == other.id && created == other.created && name == other.name && previewName == other.previewName && userId == other.userId && orgId == other.orgId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, created, name, previewName, userId, orgId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, created, name, previewName, userId, orgId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ApiKey{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 9be22c2d..136630d2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -123,17 +123,14 @@ constructor( return true } - return /* spotless:off */ other is ApiKeyCreateBody && this.name == other.name && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyCreateBody && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, orgName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, orgName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" @@ -150,12 +147,10 @@ constructor( return true } - return /* spotless:off */ other is ApiKeyCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyCreateParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index 66660bb0..74acfa22 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is ApiKeyDeleteParams && this.apiKeyId == other.apiKeyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 46913160..933b6db5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is ApiKeyListPage && this.apiKeysService == other.apiKeysService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ApiKeyListPage && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ override fun toString() = "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" @@ -114,15 +112,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ApiKeyListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index dc2c5d58..29cdabae 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is ApiKeyListPageAsync && this.apiKeysService == other.apiKeysService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ApiKeyListPageAsync && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ override fun toString() = "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" @@ -117,15 +115,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ApiKeyListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index c332e427..a24b1853 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -69,12 +69,10 @@ constructor( return true } - return /* spotless:off */ other is ApiKeyListParams && this.apiKeyName == other.apiKeyName && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -313,21 +311,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 4928c895..9ac78ac2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is ApiKeyRetrieveParams && this.apiKeyId == other.apiKeyId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index 2e7b9f90..ed412255 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -201,7 +201,7 @@ private constructor( return true } - return /* spotless:off */ other is Detail && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -256,17 +256,14 @@ private constructor( return true } - return /* spotless:off */ other is ImageUrl && this.url == other.url && this.detail == other.detail && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ImageUrl && url == other.url && detail == other.detail && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(url, detail, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(url, detail, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" @@ -285,7 +282,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -328,17 +325,14 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionContentPartImage && this.imageUrl == other.imageUrl && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartImage && imageUrl == other.imageUrl && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(imageUrl, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(imageUrl, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index f8787516..70f25c06 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -116,7 +116,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -159,17 +159,14 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionContentPartText && this.text == other.text && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartText && text == other.text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(text, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(text, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ChatCompletionContentPartText{text=$text, type=$type, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 5327e7f0..6b7482ba 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -205,17 +205,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arguments, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" @@ -234,7 +231,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -277,17 +274,14 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionMessageToolCall && this.id == other.id && this.function == other.function && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionMessageToolCall && id == other.id && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, function, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, function, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index 4c5d6997..c88ce5df 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -198,21 +198,18 @@ private constructor( return true } - return /* spotless:off */ other is Location && this.experiment == other.experiment && this.function == other.function /* spotless:on */ + return /* spotless:off */ other is Location && experiment == other.experiment && function == other.function /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experiment, function) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experiment, function) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { experiment != null -> "Location{experiment=$experiment}" function != null -> "Location{function=$function}" _json != null -> "Location{_unknown=$_json}" else -> throw IllegalStateException("Invalid Location") } - } companion object { @@ -416,21 +413,18 @@ private constructor( return true } - return /* spotless:off */ other is Position && this.type == other.type && this.scorer == other.scorer /* spotless:on */ + return /* spotless:off */ other is Position && type == other.type && scorer == other.scorer /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(type, scorer) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(type, scorer) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { type != null -> "Position{type=$type}" scorer != null -> "Position{scorer=$scorer}" _json != null -> "Position{_unknown=$_json}" else -> throw IllegalStateException("Invalid Position") } - } companion object { @@ -566,7 +560,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -609,17 +603,14 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Type && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" @@ -726,7 +717,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -769,17 +760,14 @@ private constructor( return true } - return /* spotless:off */ other is Scorer && this.type == other.type && this.index == other.index && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scorer && type == other.type && index == other.index && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, index, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, index, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" @@ -799,7 +787,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -842,17 +830,14 @@ private constructor( return true } - return /* spotless:off */ other is Experiment && this.type == other.type && this.evalName == other.evalName && this.position == other.position && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && type == other.type && evalName == other.evalName && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, evalName, position, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, evalName, position, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Experiment{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" @@ -957,7 +942,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1000,17 +985,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.type == other.type && this.index == other.index && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && type == other.type && index == other.index && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, index, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, index, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{type=$type, index=$index, additionalProperties=$additionalProperties}" @@ -1115,7 +1097,7 @@ private constructor( return true } - return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1164,17 +1146,14 @@ private constructor( return true } - return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtime, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" @@ -1185,17 +1164,14 @@ private constructor( return true } - return /* spotless:off */ other is CodeBundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CodeBundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "CodeBundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index 733e9d8d..72fcbff1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -203,17 +203,14 @@ private constructor( return true } - return /* spotless:off */ other is CreateApiKeyOutput && this.id == other.id && this.created == other.created && this.name == other.name && this.previewName == other.previewName && this.userId == other.userId && this.orgId == other.orgId && this.key == other.key && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && created == other.created && name == other.name && previewName == other.previewName && userId == other.userId && orgId == other.orgId && key == other.key && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, created, name, previewName, userId, orgId, key, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, created, name, previewName, userId, orgId, key, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "CreateApiKeyOutput{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index 88cf8bd4..0cec2c85 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -189,17 +189,14 @@ private constructor( return true } - return /* spotless:off */ other is Dataset && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Dataset{additionalProperties=$additionalProperties}" } @@ -262,17 +259,14 @@ private constructor( return true } - return /* spotless:off */ other is Experiment && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Experiment{additionalProperties=$additionalProperties}" } @@ -335,17 +329,14 @@ private constructor( return true } - return /* spotless:off */ other is ProjectLogs && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectLogs{additionalProperties=$additionalProperties}" } @@ -355,17 +346,14 @@ private constructor( return true } - return /* spotless:off */ other is CrossObjectInsertResponse && this.experiment == other.experiment && this.dataset == other.dataset && this.projectLogs == other.projectLogs && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CrossObjectInsertResponse && experiment == other.experiment && dataset == other.dataset && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(experiment, dataset, projectLogs, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(experiment, dataset, projectLogs, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "CrossObjectInsertResponse{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index b07ee919..e0b37873 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -90,17 +90,14 @@ private constructor( return true } - return /* spotless:off */ other is DataSummary && this.totalRecords == other.totalRecords && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DataSummary && totalRecords == other.totalRecords && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(totalRecords, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(totalRecords, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index df03f7a7..aa856b64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -281,17 +281,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -301,17 +298,14 @@ private constructor( return true } - return /* spotless:off */ other is Dataset && this.id == other.id && this.projectId == other.projectId && this.name == other.name && this.description == other.description && this.created == other.created && this.deletedAt == other.deletedAt && this.userId == other.userId && this.metadata == other.metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && id == other.id && projectId == other.projectId && name == other.name && description == other.description && created == other.created && deletedAt == other.deletedAt && userId == other.userId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, projectId, name, description, created, deletedAt, userId, metadata, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, projectId, name, description, created, deletedAt, userId, metadata, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Dataset{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, deletedAt=$deletedAt, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index ef0cf74b..37f32b64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -145,17 +145,14 @@ constructor( return true } - return /* spotless:off */ other is DatasetCreateBody && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.metadata == other.metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetCreateBody && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, description, metadata, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, description, metadata, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" @@ -172,12 +169,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetCreateParams && this.name == other.name && this.projectId == other.projectId && this.description == other.description && this.metadata == other.metadata && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetCreateParams && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, description, metadata, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, description, metadata, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "DatasetCreateParams{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -405,17 +400,14 @@ constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 06816587..454dfec6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetDeleteParams && this.datasetId == other.datasetId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 6dfe64a0..3b579c4e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -456,17 +456,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -618,7 +615,7 @@ private constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -691,17 +688,14 @@ private constructor( return true } - return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.id == other.id && this._xactId == other._xactId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && id == other.id && _xactId == other._xactId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, id, _xactId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, id, _xactId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" @@ -712,17 +706,14 @@ private constructor( return true } - return /* spotless:off */ other is DatasetEvent && this.id == other.id && this._xactId == other._xactId && this.created == other.created && this.projectId == other.projectId && this.datasetId == other.datasetId && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.isRoot == other.isRoot && this.origin == other.origin && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && projectId == other.projectId && datasetId == other.datasetId && input == other.input && expected == other.expected && metadata == other.metadata && tags == other.tags && spanId == other.spanId && rootSpanId == other.rootSpanId && isRoot == other.isRoot && origin == other.origin && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, projectId, datasetId, input, expected, metadata, tags, spanId, rootSpanId, isRoot, origin, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, _xactId, created, projectId, datasetId, input, expected, metadata, tags, spanId, rootSpanId, isRoot, origin, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, isRoot=$isRoot, origin=$origin, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index b52c83cf..71f65f40 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -108,17 +108,14 @@ constructor( return true } - return /* spotless:off */ other is DatasetFeedbackBody && this.feedback == other.feedback && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFeedbackBody && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(feedback, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(feedback, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" @@ -135,12 +132,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetFeedbackParams && this.datasetId == other.datasetId && this.feedback == other.feedback && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index bf83ae7e..096f6f87 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -59,12 +59,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchParams && this.datasetId == other.datasetId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 47e442c7..5ebfbe09 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -263,17 +263,14 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostBody && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DatasetFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" @@ -290,12 +287,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostParams && this.datasetId == other.datasetId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 7c0b4337..c89ae0f4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -107,17 +107,14 @@ constructor( return true } - return /* spotless:off */ other is DatasetInsertBody && this.events == other.events && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetInsertBody && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(events, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(events, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" @@ -134,12 +131,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetInsertParams && this.datasetId == other.datasetId && this.events == other.events && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index 6e878af8..117b1e39 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is DatasetListPage && this.datasetsService == other.datasetsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is DatasetListPage && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ override fun toString() = "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" @@ -120,15 +118,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "DatasetListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index 75bfa66f..2a6e6ee3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is DatasetListPageAsync && this.datasetsService == other.datasetsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is DatasetListPageAsync && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ override fun toString() = "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "DatasetListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 1c2181a2..ae17b6b9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -77,12 +77,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetListParams && this.datasetName == other.datasetName && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -333,21 +331,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index 0d016465..97b54216 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetRetrieveParams && this.datasetId == other.datasetId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 9de8c6a4..562d281a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -47,12 +47,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetSummarizeParams && this.datasetId == other.datasetId && this.summarizeData == other.summarizeData && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 62f06677..3bdefd72 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -140,17 +140,14 @@ constructor( return true } - return /* spotless:off */ other is DatasetUpdateBody && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetUpdateBody && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(description, metadata, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(description, metadata, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" @@ -167,12 +164,10 @@ constructor( return true } - return /* spotless:off */ other is DatasetUpdateParams && this.datasetId == other.datasetId && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && description == other.description && metadata == other.metadata && name == other.name && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, description, metadata, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, description, metadata, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -400,17 +395,14 @@ constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 483a52a5..f9b4c49d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -199,7 +199,7 @@ private constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -254,17 +254,14 @@ private constructor( return true } - return /* spotless:off */ other is EnvVar && this.id == other.id && this.objectType == other.objectType && this.objectId == other.objectId && this.name == other.name && this.created == other.created && this.used == other.used && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVar && id == other.id && objectType == other.objectType && objectId == other.objectId && name == other.name && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, objectType, objectId, name, created, used, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, objectType, objectId, name, created, used, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "EnvVar{id=$id, objectType=$objectType, objectId=$objectId, name=$name, created=$created, used=$used, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 7b8a695f..792c18a5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -148,17 +148,14 @@ constructor( return true } - return /* spotless:off */ other is EnvVarCreateBody && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarCreateBody && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, objectId, objectType, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "EnvVarCreateBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" @@ -175,12 +172,10 @@ constructor( return true } - return /* spotless:off */ other is EnvVarCreateParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarCreateParams && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "EnvVarCreateParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -371,7 +366,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index f2419595..39e7d0d2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is EnvVarDeleteParams && this.envVarId == other.envVarId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" 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 3c30e2fa..4d4ad6df 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 @@ -68,12 +68,10 @@ constructor( return true } - return /* spotless:off */ other is EnvVarListParams && this.envVarName == other.envVarName && this.ids == other.ids && this.limit == other.limit && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -294,21 +292,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { @@ -374,7 +369,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 983be40d..9c258975 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -90,17 +90,14 @@ private constructor( return true } - return /* spotless:off */ other is EnvVarListResponse && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarListResponse && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objects, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index 7ee9c316..2ee8454c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -148,17 +148,14 @@ constructor( return true } - return /* spotless:off */ other is EnvVarReplaceBody && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarReplaceBody && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, objectId, objectType, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "EnvVarReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" @@ -175,12 +172,10 @@ constructor( return true } - return /* spotless:off */ other is EnvVarReplaceParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.value == other.value && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarReplaceParams && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "EnvVarReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -371,7 +366,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index d9e34fd0..6c302efd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is EnvVarRetrieveParams && this.envVarId == other.envVarId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index fb35e464..8c55f79f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -124,17 +124,14 @@ constructor( return true } - return /* spotless:off */ other is EnvVarUpdateBody && this.name == other.name && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarUpdateBody && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "EnvVarUpdateBody{name=$name, value=$value, additionalProperties=$additionalProperties}" @@ -151,12 +148,10 @@ constructor( return true } - return /* spotless:off */ other is EnvVarUpdateParams && this.envVarId == other.envVarId && this.name == other.name && this.value == other.value && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && name == other.name && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(envVarId, name, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, name, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "EnvVarUpdateParams{envVarId=$envVarId, name=$name, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 300e3d10..3d91e18d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -390,17 +390,14 @@ constructor( return true } - return /* spotless:off */ other is EvalCreateBody && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.baseExperimentId == other.baseExperimentId && this.baseExperimentName == other.baseExperimentName && this.experimentName == other.experimentName && this.gitMetadataSettings == other.gitMetadataSettings && this.isPublic == other.isPublic && this.maxConcurrency == other.maxConcurrency && this.metadata == other.metadata && this.repoInfo == other.repoInfo && this.stream == other.stream && this.timeout == other.timeout && this.trialCount == other.trialCount && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EvalCreateBody && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" @@ -417,12 +414,10 @@ constructor( return true } - return /* spotless:off */ other is EvalCreateParams && this.data == other.data && this.projectId == other.projectId && this.scores == other.scores && this.task == other.task && this.baseExperimentId == other.baseExperimentId && this.baseExperimentName == other.baseExperimentName && this.experimentName == other.experimentName && this.gitMetadataSettings == other.gitMetadataSettings && this.isPublic == other.isPublic && this.maxConcurrency == other.maxConcurrency && this.metadata == other.metadata && this.repoInfo == other.repoInfo && this.stream == other.stream && this.timeout == other.timeout && this.trialCount == other.trialCount && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EvalCreateParams && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "EvalCreateParams{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -793,21 +788,18 @@ constructor( return true } - return /* spotless:off */ other is Data && this.datasetId == other.datasetId && this.projectDatasetName == other.projectDatasetName /* spotless:on */ + return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(datasetId, projectDatasetName) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, projectDatasetName) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { datasetId != null -> "Data{datasetId=$datasetId}" projectDatasetName != null -> "Data{projectDatasetName=$projectDatasetName}" _json != null -> "Data{_unknown=$_json}" else -> throw IllegalStateException("Invalid Data") } - } companion object { @@ -937,17 +929,14 @@ constructor( return true } - return /* spotless:off */ other is DatasetId && this.datasetId == other.datasetId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(datasetId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(datasetId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" @@ -1049,17 +1038,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectDatasetName && this.projectName == other.projectName && this.datasetName == other.datasetName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDatasetName && projectName == other.projectName && datasetName == other.datasetName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(projectName, datasetName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(projectName, datasetName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectDatasetName{projectName=$projectName, datasetName=$datasetName, additionalProperties=$additionalProperties}" @@ -1159,15 +1145,13 @@ constructor( return true } - return /* spotless:off */ other is Score && this.functionId == other.functionId && this.projectSlug == other.projectSlug && this.globalFunction == other.globalFunction && this.promptSessionId == other.promptSessionId && this.inlineCode == other.inlineCode && this.inlinePrompt == other.inlinePrompt /* spotless:on */ + return /* spotless:off */ other is Score && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { functionId != null -> "Score{functionId=$functionId}" projectSlug != null -> "Score{projectSlug=$projectSlug}" globalFunction != null -> "Score{globalFunction=$globalFunction}" @@ -1177,7 +1161,6 @@ constructor( _json != null -> "Score{_unknown=$_json}" else -> throw IllegalStateException("Invalid Score") } - } companion object { @@ -1375,17 +1358,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionId && this.functionId == other.functionId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(functionId, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(functionId, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" @@ -1512,17 +1492,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectSlug && this.projectName == other.projectName && this.slug == other.slug && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(projectName, slug, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(projectName, slug, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" @@ -1621,17 +1598,14 @@ constructor( return true } - return /* spotless:off */ other is GlobalFunction && this.globalFunction == other.globalFunction && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(globalFunction, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(globalFunction, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" @@ -1767,17 +1741,14 @@ constructor( return true } - return /* spotless:off */ other is PromptSessionId && this.promptSessionId == other.promptSessionId && this.promptSessionFunctionId == other.promptSessionFunctionId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionId == other.promptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(promptSessionId, promptSessionFunctionId, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(promptSessionId, promptSessionFunctionId, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PromptSessionId{promptSessionId=$promptSessionId, promptSessionFunctionId=$promptSessionFunctionId, version=$version, additionalProperties=$additionalProperties}" @@ -1996,7 +1967,7 @@ constructor( return true } - return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2045,17 +2016,14 @@ constructor( return true } - return /* spotless:off */ other is InlineContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtime, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" @@ -2066,17 +2034,14 @@ constructor( return true } - return /* spotless:off */ other is InlineCode && this.inlineContext == other.inlineContext && this.code == other.code && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && inlineContext == other.inlineContext && code == other.code && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(inlineContext, code, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(inlineContext, code, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InlineCode{inlineContext=$inlineContext, code=$code, name=$name, additionalProperties=$additionalProperties}" @@ -2186,17 +2151,14 @@ constructor( return true } - return /* spotless:off */ other is InlinePrompt && this.inlinePrompt == other.inlinePrompt && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(inlinePrompt, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(inlinePrompt, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" @@ -2296,15 +2258,13 @@ constructor( return true } - return /* spotless:off */ other is Task && this.functionId == other.functionId && this.projectSlug == other.projectSlug && this.globalFunction == other.globalFunction && this.promptSessionId == other.promptSessionId && this.inlineCode == other.inlineCode && this.inlinePrompt == other.inlinePrompt /* spotless:on */ + return /* spotless:off */ other is Task && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { functionId != null -> "Task{functionId=$functionId}" projectSlug != null -> "Task{projectSlug=$projectSlug}" globalFunction != null -> "Task{globalFunction=$globalFunction}" @@ -2314,7 +2274,6 @@ constructor( _json != null -> "Task{_unknown=$_json}" else -> throw IllegalStateException("Invalid Task") } - } companion object { @@ -2511,17 +2470,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionId && this.functionId == other.functionId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(functionId, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(functionId, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" @@ -2648,17 +2604,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectSlug && this.projectName == other.projectName && this.slug == other.slug && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(projectName, slug, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(projectName, slug, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" @@ -2757,17 +2710,14 @@ constructor( return true } - return /* spotless:off */ other is GlobalFunction && this.globalFunction == other.globalFunction && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(globalFunction, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(globalFunction, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" @@ -2903,17 +2853,14 @@ constructor( return true } - return /* spotless:off */ other is PromptSessionId && this.promptSessionId == other.promptSessionId && this.promptSessionFunctionId == other.promptSessionFunctionId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionId == other.promptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(promptSessionId, promptSessionFunctionId, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(promptSessionId, promptSessionFunctionId, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PromptSessionId{promptSessionId=$promptSessionId, promptSessionFunctionId=$promptSessionFunctionId, version=$version, additionalProperties=$additionalProperties}" @@ -3132,7 +3079,7 @@ constructor( return true } - return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3181,17 +3128,14 @@ constructor( return true } - return /* spotless:off */ other is InlineContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtime, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" @@ -3202,17 +3146,14 @@ constructor( return true } - return /* spotless:off */ other is InlineCode && this.inlineContext == other.inlineContext && this.code == other.code && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && inlineContext == other.inlineContext && code == other.code && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(inlineContext, code, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(inlineContext, code, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InlineCode{inlineContext=$inlineContext, code=$code, name=$name, additionalProperties=$additionalProperties}" @@ -3322,17 +3263,14 @@ constructor( return true } - return /* spotless:off */ other is InlinePrompt && this.inlinePrompt == other.inlinePrompt && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(inlinePrompt, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(inlinePrompt, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" @@ -3420,7 +3358,7 @@ constructor( return true } - return /* spotless:off */ other is Collect && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3483,7 +3421,7 @@ constructor( return true } - return /* spotless:off */ other is Field && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Field && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3574,17 +3512,14 @@ constructor( return true } - return /* spotless:off */ other is GitMetadataSettings && this.collect == other.collect && this.fields == other.fields && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GitMetadataSettings && collect == other.collect && fields == other.fields && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(collect, fields, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(collect, fields, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "GitMetadataSettings{collect=$collect, fields=$fields, additionalProperties=$additionalProperties}" @@ -3643,17 +3578,14 @@ constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 76a90944..5d342b8f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -426,17 +426,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -446,17 +443,14 @@ private constructor( return true } - return /* spotless:off */ other is Experiment && this.id == other.id && this.projectId == other.projectId && this.name == other.name && this.description == other.description && this.created == other.created && this.repoInfo == other.repoInfo && this.commit == other.commit && this.baseExpId == other.baseExpId && this.deletedAt == other.deletedAt && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.public_ == other.public_ && this.userId == other.userId && this.metadata == other.metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && id == other.id && projectId == other.projectId && name == other.name && description == other.description && created == other.created && repoInfo == other.repoInfo && commit == other.commit && baseExpId == other.baseExpId && deletedAt == other.deletedAt && datasetId == other.datasetId && datasetVersion == other.datasetVersion && public_ == other.public_ && userId == other.userId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, projectId, name, description, created, repoInfo, commit, baseExpId, deletedAt, datasetId, datasetVersion, public_, userId, metadata, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, projectId, name, description, created, repoInfo, commit, baseExpId, deletedAt, datasetId, datasetVersion, public_, userId, metadata, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Experiment{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, repoInfo=$repoInfo, commit=$commit, baseExpId=$baseExpId, deletedAt=$deletedAt, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index b7e02f37..2d86c5a5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -261,17 +261,14 @@ constructor( return true } - return /* spotless:off */ other is ExperimentCreateBody && this.projectId == other.projectId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.ensureNew == other.ensureNew && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentCreateBody && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" @@ -288,12 +285,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentCreateParams && this.projectId == other.projectId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.ensureNew == other.ensureNew && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentCreateParams && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -569,17 +564,14 @@ constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 9e961da8..8ab8dbcf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentDeleteParams && this.experimentId == other.experimentId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index 9ba8b444..bbd2b249 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -817,17 +817,14 @@ private constructor( return true } - return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" @@ -897,17 +894,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -1183,17 +1177,14 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && start == other.start && end == other.end && promptTokens == other.promptTokens && completionTokens == other.completionTokens && tokens == other.tokens && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" @@ -1346,7 +1337,7 @@ private constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1419,17 +1410,14 @@ private constructor( return true } - return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.id == other.id && this._xactId == other._xactId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && id == other.id && _xactId == other._xactId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, id, _xactId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, id, _xactId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" @@ -1501,17 +1489,14 @@ private constructor( return true } - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Scores{additionalProperties=$additionalProperties}" } @@ -1521,17 +1506,14 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentEvent && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this._xactId == other._xactId && this.created == other.created && this.projectId == other.projectId && this.experimentId == other.experimentId && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanId == other.spanId && this.spanParents == other.spanParents && this.rootSpanId == other.rootSpanId && this.spanAttributes == other.spanAttributes && this.isRoot == other.isRoot && this.origin == other.origin && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentEvent && id == other.id && datasetRecordId == other.datasetRecordId && _xactId == other._xactId && created == other.created && projectId == other.projectId && experimentId == other.experimentId && input == other.input && output == other.output && expected == other.expected && error == other.error && scores == other.scores && metadata == other.metadata && tags == other.tags && metrics == other.metrics && context == other.context && spanId == other.spanId && spanParents == other.spanParents && rootSpanId == other.rootSpanId && spanAttributes == other.spanAttributes && isRoot == other.isRoot && origin == other.origin && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, datasetRecordId, _xactId, created, projectId, experimentId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, spanAttributes, isRoot, origin, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, datasetRecordId, _xactId, created, projectId, experimentId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, spanAttributes, isRoot, origin, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, isRoot=$isRoot, origin=$origin, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 363f5507..2aad69b4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -110,17 +110,14 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFeedbackBody && this.feedback == other.feedback && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFeedbackBody && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(feedback, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(feedback, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" @@ -137,12 +134,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFeedbackParams && this.experimentId == other.experimentId && this.feedback == other.feedback && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 4e305c4b..2f660184 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -59,12 +59,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchParams && this.experimentId == other.experimentId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 53439ee7..187957ca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -263,17 +263,14 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostBody && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ExperimentFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" @@ -290,12 +287,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostParams && this.experimentId == other.experimentId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index df3e98ec..e7980b7b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -107,17 +107,14 @@ constructor( return true } - return /* spotless:off */ other is ExperimentInsertBody && this.events == other.events && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentInsertBody && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(events, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(events, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" @@ -134,12 +131,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentInsertParams && this.experimentId == other.experimentId && this.events == other.events && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 84f15d25..38837f0d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentListPage && this.experimentsService == other.experimentsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ExperimentListPage && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ override fun toString() = "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" @@ -124,15 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ExperimentListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index 9b7089c9..a1459960 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentListPageAsync && this.experimentsService == other.experimentsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ExperimentListPageAsync && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ override fun toString() = "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ExperimentListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 9533744d..777c21e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -77,12 +77,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentListParams && this.endingBefore == other.endingBefore && this.experimentName == other.experimentName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -333,21 +331,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index e3497fed..908c3b36 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentRetrieveParams && this.experimentId == other.experimentId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 98615e1e..4f41a127 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -53,12 +53,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentSummarizeParams && this.experimentId == other.experimentId && this.comparisonExperimentId == other.comparisonExperimentId && this.summarizeScores == other.summarizeScores && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 132704ec..034d41bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -233,17 +233,14 @@ constructor( return true } - return /* spotless:off */ other is ExperimentUpdateBody && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentUpdateBody && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" @@ -260,12 +257,10 @@ constructor( return true } - return /* spotless:off */ other is ExperimentUpdateParams && this.experimentId == other.experimentId && this.baseExpId == other.baseExpId && this.datasetId == other.datasetId && this.datasetVersion == other.datasetVersion && this.description == other.description && this.metadata == other.metadata && this.name == other.name && this.public_ == other.public_ && this.repoInfo == other.repoInfo && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(experimentId, baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -531,17 +526,14 @@ constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 7c23b746..e5a4bef7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -256,17 +256,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -284,7 +281,7 @@ private constructor( return true } - return /* spotless:off */ other is Source && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -339,17 +336,14 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackDatasetItem && this.id == other.id && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackDatasetItem && id == other.id && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, comment, metadata, source, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, comment, metadata, source, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index ea2f3124..e4613f52 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -312,17 +312,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -388,17 +385,14 @@ private constructor( return true } - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Scores{additionalProperties=$additionalProperties}" } @@ -416,7 +410,7 @@ private constructor( return true } - return /* spotless:off */ other is Source && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -471,17 +465,14 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackExperimentItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && scores == other.scores && expected == other.expected && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index e717c6d1..a77a10aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -312,17 +312,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -388,17 +385,14 @@ private constructor( return true } - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Scores{additionalProperties=$additionalProperties}" } @@ -416,7 +410,7 @@ private constructor( return true } - return /* spotless:off */ other is Source && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -471,17 +465,14 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackProjectLogsItem && this.id == other.id && this.scores == other.scores && this.expected == other.expected && this.comment == other.comment && this.metadata == other.metadata && this.source == other.source && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && scores == other.scores && expected == other.expected && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index f97ba0b6..9079670a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -97,7 +97,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -140,17 +140,14 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackResponseSchema && this.status == other.status && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackResponseSchema && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(status, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 671c2340..d921c8ca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -133,17 +133,14 @@ private constructor( return true } - return /* spotless:off */ other is FetchDatasetEventsResponse && this.events == other.events && this.cursor == other.cursor && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchDatasetEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(events, cursor, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(events, cursor, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index e8874422..98314805 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -133,17 +133,14 @@ private constructor( return true } - return /* spotless:off */ other is FetchExperimentEventsResponse && this.events == other.events && this.cursor == other.cursor && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchExperimentEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(events, cursor, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(events, cursor, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 84c37b04..e3812840 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -133,17 +133,14 @@ private constructor( return true } - return /* spotless:off */ other is FetchProjectLogsEventsResponse && this.events == other.events && this.cursor == other.cursor && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchProjectLogsEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(events, cursor, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(events, cursor, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" 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 b6981e01..66256d5d 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 @@ -458,22 +458,19 @@ private constructor( return true } - return /* spotless:off */ other is FunctionData && this.prompt == other.prompt && this.code == other.code && this.global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { prompt != null -> "FunctionData{prompt=$prompt}" code != null -> "FunctionData{code=$code}" global != null -> "FunctionData{global=$global}" _json != null -> "FunctionData{_unknown=$_json}" else -> throw IllegalStateException("Invalid FunctionData") } - } companion object { @@ -616,7 +613,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -659,17 +656,14 @@ private constructor( return true } - return /* spotless:off */ other is Prompt && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" @@ -809,21 +803,18 @@ private constructor( return true } - return /* spotless:off */ other is Data && this.bundle == other.bundle && this.inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { bundle != null -> "Data{bundle=$bundle}" inline != null -> "Data{inline=$inline}" _json != null -> "Data{_unknown=$_json}" else -> throw IllegalStateException("Invalid Data") } - } companion object { @@ -1048,7 +1039,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1091,17 +1082,14 @@ private constructor( return true } - return /* spotless:off */ other is Bundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" @@ -1320,7 +1308,7 @@ private constructor( return true } - return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1372,17 +1360,14 @@ private constructor( return true } - return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtime, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" @@ -1402,7 +1387,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1445,17 +1430,14 @@ private constructor( return true } - return /* spotless:off */ other is Inline && this.type == other.type && this.runtimeContext == other.runtimeContext && this.code == other.code && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && type == other.type && runtimeContext == other.runtimeContext && code == other.code && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, runtimeContext, code, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, runtimeContext, code, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" @@ -1475,7 +1457,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1518,17 +1500,14 @@ private constructor( return true } - return /* spotless:off */ other is Code && this.type == other.type && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && type == other.type && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" @@ -1633,7 +1612,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1676,17 +1655,14 @@ private constructor( return true } - return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" @@ -1706,7 +1682,7 @@ private constructor( return true } - return /* spotless:off */ other is LogId && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1831,17 +1807,14 @@ private constructor( return true } - return /* spotless:off */ other is FunctionSchema && this.parameters == other.parameters && this.returns == other.returns && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(parameters, returns, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(parameters, returns, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" @@ -1860,7 +1833,7 @@ private constructor( return true } - return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1974,17 +1947,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -2128,7 +2098,7 @@ private constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2231,17 +2201,14 @@ private constructor( return true } - return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.internal_ == other.internal_ && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, internal_, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, internal_, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" @@ -2252,17 +2219,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.id == other.id && this._xactId == other._xactId && this.projectId == other.projectId && this.logId == other.logId && this.orgId == other.orgId && this.name == other.name && this.slug == other.slug && this.description == other.description && this.created == other.created && this.promptData == other.promptData && this.tags == other.tags && this.metadata == other.metadata && this.functionType == other.functionType && this.functionData == other.functionData && this.origin == other.origin && this.functionSchema == other.functionSchema && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && projectId == other.projectId && logId == other.logId && orgId == other.orgId && name == other.name && slug == other.slug && description == other.description && created == other.created && promptData == other.promptData && tags == other.tags && metadata == other.metadata && functionType == other.functionType && functionData == other.functionData && origin == other.origin && functionSchema == other.functionSchema && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, _xactId, projectId, logId, orgId, name, slug, description, created, promptData, tags, metadata, functionType, functionData, origin, functionSchema, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, _xactId, projectId, logId, orgId, name, slug, description, created, promptData, tags, metadata, functionType, functionData, origin, functionSchema, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, functionData=$functionData, origin=$origin, functionSchema=$functionSchema, additionalProperties=$additionalProperties}" 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 13801a1a..c5b0f660 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 @@ -246,17 +246,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionCreateBody && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCreateBody && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" @@ -273,12 +270,10 @@ constructor( return true } - return /* spotless:off */ other is FunctionCreateParams && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCreateParams && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -567,22 +562,19 @@ constructor( return true } - return /* spotless:off */ other is FunctionData && this.prompt == other.prompt && this.code == other.code && this.global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { prompt != null -> "FunctionData{prompt=$prompt}" code != null -> "FunctionData{code=$code}" global != null -> "FunctionData{global=$global}" _json != null -> "FunctionData{_unknown=$_json}" else -> throw IllegalStateException("Invalid FunctionData") } - } companion object { @@ -725,7 +717,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -768,17 +760,14 @@ constructor( return true } - return /* spotless:off */ other is Prompt && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" @@ -918,21 +907,18 @@ constructor( return true } - return /* spotless:off */ other is Data && this.bundle == other.bundle && this.inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { bundle != null -> "Data{bundle=$bundle}" inline != null -> "Data{inline=$inline}" _json != null -> "Data{_unknown=$_json}" else -> throw IllegalStateException("Invalid Data") } - } companion object { @@ -1154,7 +1140,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1197,17 +1183,14 @@ constructor( return true } - return /* spotless:off */ other is Bundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" @@ -1426,7 +1409,7 @@ constructor( return true } - return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1478,17 +1461,14 @@ constructor( return true } - return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtime, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" @@ -1508,7 +1488,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1551,17 +1531,14 @@ constructor( return true } - return /* spotless:off */ other is Inline && this.type == other.type && this.runtimeContext == other.runtimeContext && this.code == other.code && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && type == other.type && runtimeContext == other.runtimeContext && code == other.code && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, runtimeContext, code, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, runtimeContext, code, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" @@ -1581,7 +1558,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1624,17 +1601,14 @@ constructor( return true } - return /* spotless:off */ other is Code && this.type == other.type && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && type == other.type && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" @@ -1739,7 +1713,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1782,17 +1756,14 @@ constructor( return true } - return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" @@ -1870,17 +1841,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionSchema && this.parameters == other.parameters && this.returns == other.returns && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(parameters, returns, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(parameters, returns, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" @@ -1899,7 +1867,7 @@ constructor( return true } - return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2054,7 +2022,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2157,17 +2125,14 @@ constructor( return true } - return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.internal_ == other.internal_ && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, internal_, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, internal_, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index 6893c593..9a11e345 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is FunctionDeleteParams && this.functionId == other.functionId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 8d58dec8..7542e094 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -202,17 +202,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionInvokeBody && this.input == other.input && this.messages == other.messages && this.mode == other.mode && this.parent == other.parent && this.stream == other.stream && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeBody && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(input, messages, mode, parent, stream, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, messages, mode, parent, stream, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionInvokeBody{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" @@ -229,12 +226,10 @@ constructor( return true } - return /* spotless:off */ other is FunctionInvokeParams && this.functionId == other.functionId && this.input == other.input && this.messages == other.messages && this.mode == other.mode && this.parent == other.parent && this.stream == other.stream && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, input, messages, mode, parent, stream, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, input, messages, mode, parent, stream, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "FunctionInvokeParams{functionId=$functionId, input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -539,15 +534,13 @@ constructor( return true } - return /* spotless:off */ other is Message && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ + return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { system != null -> "Message{system=$system}" user != null -> "Message{user=$user}" assistant != null -> "Message{assistant=$assistant}" @@ -557,7 +550,6 @@ constructor( _json != null -> "Message{_unknown=$_json}" else -> throw IllegalStateException("Invalid Message") } - } companion object { @@ -761,7 +753,7 @@ constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -804,17 +796,14 @@ constructor( return true } - return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && content == other.content && role == other.role && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, role, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" @@ -934,7 +923,7 @@ constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1019,21 +1008,18 @@ constructor( return true } - return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { text != null -> "Content{text=$text}" array != null -> "Content{array=$array}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } - } companion object { @@ -1155,15 +1141,13 @@ constructor( return true } - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && chatCompletionContentPartText == other.chatCompletionContentPartText && chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { chatCompletionContentPartText != null -> "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" chatCompletionContentPartImage != null -> @@ -1171,7 +1155,6 @@ constructor( _json != null -> "ChatCompletionContentPart{_unknown=$_json}" else -> throw IllegalStateException("Invalid ChatCompletionContentPart") } - } companion object { @@ -1271,17 +1254,14 @@ constructor( return true } - return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && content == other.content && role == other.role && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, role, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" @@ -1440,7 +1420,7 @@ constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1571,17 +1551,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arguments, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" @@ -1592,17 +1569,14 @@ constructor( return true } - return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" @@ -1725,7 +1699,7 @@ constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1768,17 +1742,14 @@ constructor( return true } - return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && content == other.content && role == other.role && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, role, toolCallId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" @@ -1898,7 +1869,7 @@ constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1941,17 +1912,14 @@ constructor( return true } - return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && content == other.content && name == other.name && role == other.role && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, name, role, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" @@ -2056,7 +2024,7 @@ constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2099,17 +2067,14 @@ constructor( return true } - return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(role, content, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" @@ -2129,7 +2094,7 @@ constructor( return true } - return /* spotless:off */ other is Mode && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2222,21 +2187,18 @@ constructor( return true } - return /* spotless:off */ other is Parent && this.spanParentStruct == other.spanParentStruct && this.string == other.string /* spotless:on */ + return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(spanParentStruct, string) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanParentStruct, string) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { spanParentStruct != null -> "Parent{spanParentStruct=$spanParentStruct}" string != null -> "Parent{string=$string}" _json != null -> "Parent{_unknown=$_json}" else -> throw IllegalStateException("Invalid Parent") } - } companion object { @@ -2441,7 +2403,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2545,17 +2507,14 @@ constructor( return true } - return /* spotless:off */ other is PropagatedEvent && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PropagatedEvent{additionalProperties=$additionalProperties}" @@ -2682,17 +2641,14 @@ constructor( return true } - return /* spotless:off */ other is RowIds && this.id == other.id && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RowIds && id == other.id && spanId == other.spanId && rootSpanId == other.rootSpanId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, spanId, rootSpanId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, spanId, rootSpanId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RowIds{id=$id, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" @@ -2703,17 +2659,14 @@ constructor( return true } - return /* spotless:off */ other is SpanParentStruct && this.objectType == other.objectType && this.objectId == other.objectId && this.rowIds == other.rowIds && this.propagatedEvent == other.propagatedEvent && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanParentStruct && objectType == other.objectType && objectId == other.objectId && rowIds == other.rowIds && propagatedEvent == other.propagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, rowIds, propagatedEvent, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, rowIds, propagatedEvent, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SpanParentStruct{objectType=$objectType, objectId=$objectId, rowIds=$rowIds, propagatedEvent=$propagatedEvent, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 854fbf3f..505e191b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -69,17 +69,14 @@ private constructor( return true } - return /* spotless:off */ other is FunctionInvokeResponse && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeResponse && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionInvokeResponse{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 033c109b..828cf5ea 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is FunctionListPage && this.functionsService == other.functionsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is FunctionListPage && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ override fun toString() = "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" @@ -120,15 +118,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "FunctionListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 7a907505..9ebdcf18 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is FunctionListPageAsync && this.functionsService == other.functionsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is FunctionListPageAsync && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ override fun toString() = "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "FunctionListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 43e271b9..b89cb925 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -85,12 +85,10 @@ constructor( return true } - return /* spotless:off */ other is FunctionListParams && this.endingBefore == other.endingBefore && this.functionName == other.functionName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.slug == other.slug && this.startingAfter == other.startingAfter && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -358,21 +356,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { 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 9803f28f..ac538eb8 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 @@ -246,17 +246,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionReplaceBody && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionReplaceBody && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" @@ -273,12 +270,10 @@ constructor( return true } - return /* spotless:off */ other is FunctionReplaceParams && this.functionData == other.functionData && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionSchema == other.functionSchema && this.functionType == other.functionType && this.origin == other.origin && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionReplaceParams && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -567,22 +562,19 @@ constructor( return true } - return /* spotless:off */ other is FunctionData && this.prompt == other.prompt && this.code == other.code && this.global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { prompt != null -> "FunctionData{prompt=$prompt}" code != null -> "FunctionData{code=$code}" global != null -> "FunctionData{global=$global}" _json != null -> "FunctionData{_unknown=$_json}" else -> throw IllegalStateException("Invalid FunctionData") } - } companion object { @@ -725,7 +717,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -768,17 +760,14 @@ constructor( return true } - return /* spotless:off */ other is Prompt && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" @@ -918,21 +907,18 @@ constructor( return true } - return /* spotless:off */ other is Data && this.bundle == other.bundle && this.inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { bundle != null -> "Data{bundle=$bundle}" inline != null -> "Data{inline=$inline}" _json != null -> "Data{_unknown=$_json}" else -> throw IllegalStateException("Invalid Data") } - } companion object { @@ -1154,7 +1140,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1197,17 +1183,14 @@ constructor( return true } - return /* spotless:off */ other is Bundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" @@ -1426,7 +1409,7 @@ constructor( return true } - return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1478,17 +1461,14 @@ constructor( return true } - return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtime, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" @@ -1508,7 +1488,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1551,17 +1531,14 @@ constructor( return true } - return /* spotless:off */ other is Inline && this.type == other.type && this.runtimeContext == other.runtimeContext && this.code == other.code && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && type == other.type && runtimeContext == other.runtimeContext && code == other.code && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, runtimeContext, code, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, runtimeContext, code, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" @@ -1581,7 +1558,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1624,17 +1601,14 @@ constructor( return true } - return /* spotless:off */ other is Code && this.type == other.type && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && type == other.type && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" @@ -1739,7 +1713,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1782,17 +1756,14 @@ constructor( return true } - return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" @@ -1870,17 +1841,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionSchema && this.parameters == other.parameters && this.returns == other.returns && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(parameters, returns, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(parameters, returns, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" @@ -1899,7 +1867,7 @@ constructor( return true } - return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2054,7 +2022,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2157,17 +2125,14 @@ constructor( return true } - return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.internal_ == other.internal_ && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, internal_, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, internal_, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index 53a8d298..054c835a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is FunctionRetrieveParams && this.functionId == other.functionId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index a8ad9451..88e39149 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -183,17 +183,14 @@ constructor( return true } - return /* spotless:off */ other is FunctionUpdateBody && this.description == other.description && this.functionData == other.functionData && this.name == other.name && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionUpdateBody && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(description, functionData, name, promptData, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(description, functionData, name, promptData, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" @@ -210,12 +207,10 @@ constructor( return true } - return /* spotless:off */ other is FunctionUpdateParams && this.functionId == other.functionId && this.description == other.description && this.functionData == other.functionData && this.name == other.name && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(functionId, description, functionData, name, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, description, functionData, name, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -493,15 +488,13 @@ constructor( return true } - return /* spotless:off */ other is FunctionData && this.prompt == other.prompt && this.code == other.code && this.global == other.global && this.nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(prompt, code, global, nullableVariant) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global, nullableVariant) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { prompt != null -> "FunctionData{prompt=$prompt}" code != null -> "FunctionData{code=$code}" global != null -> "FunctionData{global=$global}" @@ -509,7 +502,6 @@ constructor( _json != null -> "FunctionData{_unknown=$_json}" else -> throw IllegalStateException("Invalid FunctionData") } - } companion object { @@ -663,7 +655,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -706,17 +698,14 @@ constructor( return true } - return /* spotless:off */ other is Prompt && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" @@ -856,21 +845,18 @@ constructor( return true } - return /* spotless:off */ other is Data && this.bundle == other.bundle && this.inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { bundle != null -> "Data{bundle=$bundle}" inline != null -> "Data{inline=$inline}" _json != null -> "Data{_unknown=$_json}" else -> throw IllegalStateException("Invalid Data") } - } companion object { @@ -1092,7 +1078,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1135,17 +1121,14 @@ constructor( return true } - return /* spotless:off */ other is Bundle && this.runtimeContext == other.runtimeContext && this.location == other.location && this.bundleId == other.bundleId && this.preview == other.preview && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" @@ -1364,7 +1347,7 @@ constructor( return true } - return /* spotless:off */ other is Runtime && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1416,17 +1399,14 @@ constructor( return true } - return /* spotless:off */ other is RuntimeContext && this.runtime == other.runtime && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(runtime, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(runtime, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" @@ -1446,7 +1426,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1489,17 +1469,14 @@ constructor( return true } - return /* spotless:off */ other is Inline && this.type == other.type && this.runtimeContext == other.runtimeContext && this.code == other.code && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && type == other.type && runtimeContext == other.runtimeContext && code == other.code && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, runtimeContext, code, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, runtimeContext, code, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" @@ -1519,7 +1496,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1562,17 +1539,14 @@ constructor( return true } - return /* spotless:off */ other is Code && this.type == other.type && this.data == other.data && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && type == other.type && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, data, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, data, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" @@ -1677,7 +1651,7 @@ constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1720,17 +1694,14 @@ constructor( return true } - return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" @@ -1794,17 +1765,14 @@ constructor( return true } - return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index ad3cac21..91330774 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -294,17 +294,14 @@ private constructor( return true } - return /* spotless:off */ other is Group && this.id == other.id && this.orgId == other.orgId && this.userId == other.userId && this.created == other.created && this.name == other.name && this.description == other.description && this.deletedAt == other.deletedAt && this.memberUsers == other.memberUsers && this.memberGroups == other.memberGroups && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Group && id == other.id && orgId == other.orgId && userId == other.userId && created == other.created && name == other.name && description == other.description && deletedAt == other.deletedAt && memberUsers == other.memberUsers && memberGroups == other.memberGroups && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, orgId, userId, created, name, description, deletedAt, memberUsers, memberGroups, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, orgId, userId, created, name, description, deletedAt, memberUsers, memberGroups, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Group{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberUsers=$memberUsers, memberGroups=$memberGroups, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index b92715d8..321eb648 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -180,17 +180,14 @@ constructor( return true } - return /* spotless:off */ other is GroupCreateBody && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupCreateBody && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" @@ -207,12 +204,10 @@ constructor( return true } - return /* spotless:off */ other is GroupCreateParams && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupCreateParams && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index ca61cba4..32401090 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is GroupDeleteParams && this.groupId == other.groupId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index fd65dbbe..05da2456 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is GroupListPage && this.groupsService == other.groupsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is GroupListPage && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ override fun toString() = "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" @@ -114,15 +112,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "GroupListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index b4ba90ad..f9e04f24 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is GroupListPageAsync && this.groupsService == other.groupsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is GroupListPageAsync && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ override fun toString() = "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" @@ -117,15 +115,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "GroupListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 26e4a7b2..a211dfa6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -69,12 +69,10 @@ constructor( return true } - return /* spotless:off */ other is GroupListParams && this.endingBefore == other.endingBefore && this.groupName == other.groupName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -313,21 +311,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 4aa47aa2..6a51ca0c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -180,17 +180,14 @@ constructor( return true } - return /* spotless:off */ other is GroupReplaceBody && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupReplaceBody && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" @@ -207,12 +204,10 @@ constructor( return true } - return /* spotless:off */ other is GroupReplaceParams && this.name == other.name && this.description == other.description && this.memberGroups == other.memberGroups && this.memberUsers == other.memberUsers && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupReplaceParams && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index 6c2c4ca9..e4a47fc9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is GroupRetrieveParams && this.groupId == other.groupId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index cec4e959..609fdeef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -195,17 +195,14 @@ constructor( return true } - return /* spotless:off */ other is GroupUpdateBody && this.addMemberGroups == other.addMemberGroups && this.addMemberUsers == other.addMemberUsers && this.description == other.description && this.name == other.name && this.removeMemberGroups == other.removeMemberGroups && this.removeMemberUsers == other.removeMemberUsers && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupUpdateBody && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" @@ -222,12 +219,10 @@ constructor( return true } - return /* spotless:off */ other is GroupUpdateParams && this.groupId == other.groupId && this.addMemberGroups == other.addMemberGroups && this.addMemberUsers == other.addMemberUsers && this.description == other.description && this.name == other.name && this.removeMemberGroups == other.removeMemberGroups && this.removeMemberUsers == other.removeMemberUsers && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(groupId, addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index d597b616..556406f9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -773,17 +773,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -793,17 +790,14 @@ private constructor( return true } - return /* spotless:off */ other is InsertDatasetEvent && this.input == other.input && this.expected == other.expected && this.metadata == other.metadata && this.tags == other.tags && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this._parentId == other._parentId && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.spanParents == other.spanParents && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertDatasetEvent && input == other.input && expected == other.expected && metadata == other.metadata && tags == other.tags && id == other.id && created == other.created && _objectDelete == other._objectDelete && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _parentId == other._parentId && spanId == other.spanId && rootSpanId == other.rootSpanId && spanParents == other.spanParents && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(input, expected, metadata, tags, id, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, expected, metadata, tags, id, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InsertDatasetEvent{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 49e6a262..80aa1350 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -103,17 +103,14 @@ private constructor( return true } - return /* spotless:off */ other is InsertEventsResponse && this.rowIds == other.rowIds && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertEventsResponse && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(rowIds, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(rowIds, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 89520f8d..5b406d62 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -1098,17 +1098,14 @@ private constructor( return true } - return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" @@ -1178,17 +1175,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -1464,17 +1458,14 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && start == other.start && end == other.end && promptTokens == other.promptTokens && completionTokens == other.completionTokens && tokens == other.tokens && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" @@ -1546,17 +1537,14 @@ private constructor( return true } - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Scores{additionalProperties=$additionalProperties}" } @@ -1566,17 +1554,14 @@ private constructor( return true } - return /* spotless:off */ other is InsertExperimentEvent && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.datasetRecordId == other.datasetRecordId && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this._parentId == other._parentId && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.spanParents == other.spanParents && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertExperimentEvent && input == other.input && output == other.output && expected == other.expected && error == other.error && scores == other.scores && metadata == other.metadata && tags == other.tags && metrics == other.metrics && context == other.context && spanAttributes == other.spanAttributes && id == other.id && datasetRecordId == other.datasetRecordId && created == other.created && _objectDelete == other._objectDelete && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _parentId == other._parentId && spanId == other.spanId && rootSpanId == other.rootSpanId && spanParents == other.spanParents && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, datasetRecordId, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, datasetRecordId, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InsertExperimentEvent{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index 2a01fd2b..3a179072 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -1050,17 +1050,14 @@ private constructor( return true } - return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" @@ -1130,17 +1127,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -1416,17 +1410,14 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && start == other.start && end == other.end && promptTokens == other.promptTokens && completionTokens == other.completionTokens && tokens == other.tokens && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" @@ -1498,17 +1489,14 @@ private constructor( return true } - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Scores{additionalProperties=$additionalProperties}" } @@ -1518,17 +1506,14 @@ private constructor( return true } - return /* spotless:off */ other is InsertProjectLogsEvent && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanAttributes == other.spanAttributes && this.id == other.id && this.created == other.created && this._objectDelete == other._objectDelete && this._isMerge == other._isMerge && this._mergePaths == other._mergePaths && this._parentId == other._parentId && this.spanId == other.spanId && this.rootSpanId == other.rootSpanId && this.spanParents == other.spanParents && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertProjectLogsEvent && input == other.input && output == other.output && expected == other.expected && error == other.error && scores == other.scores && metadata == other.metadata && tags == other.tags && metrics == other.metrics && context == other.context && spanAttributes == other.spanAttributes && id == other.id && created == other.created && _objectDelete == other._objectDelete && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _parentId == other._parentId && spanId == other.spanId && rootSpanId == other.rootSpanId && spanParents == other.spanParents && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InsertProjectLogsEvent{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index 029e9b9c..cbccf51b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -190,17 +190,14 @@ private constructor( return true } - return /* spotless:off */ other is MetricSummary && this.name == other.name && this.metric == other.metric && this.unit == other.unit && this.diff == other.diff && this.improvements == other.improvements && this.regressions == other.regressions && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MetricSummary && name == other.name && metric == other.metric && unit == other.unit && diff == other.diff && improvements == other.improvements && regressions == other.regressions && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, metric, unit, diff, improvements, regressions, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, metric, unit, diff, improvements, regressions, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "MetricSummary{name=$name, metric=$metric, unit=$unit, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 79c3826c..8d6da526 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -217,21 +217,18 @@ private constructor( return true } - return /* spotless:off */ other is Scorer && this.function == other.function && this.global == other.global /* spotless:on */ + return /* spotless:off */ other is Scorer && function == other.function && global == other.global /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(function, global) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(function, global) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { function != null -> "Scorer{function=$function}" global != null -> "Scorer{global=$global}" _json != null -> "Scorer{_unknown=$_json}" else -> throw IllegalStateException("Invalid Scorer") } - } companion object { @@ -384,7 +381,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -427,17 +424,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.type == other.type && this.id == other.id && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && type == other.type && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, id, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, id, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" @@ -542,7 +536,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -585,17 +579,14 @@ private constructor( return true } - return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" @@ -607,17 +598,14 @@ private constructor( return true } - return /* spotless:off */ other is OnlineScoreConfig && this.samplingRate == other.samplingRate && this.scorers == other.scorers && this.applyToRootSpan == other.applyToRootSpan && this.applyToSpanNames == other.applyToSpanNames && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OnlineScoreConfig && samplingRate == other.samplingRate && scorers == other.scorers && applyToRootSpan == other.applyToRootSpan && applyToSpanNames == other.applyToSpanNames && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(samplingRate, scorers, applyToRootSpan, applyToSpanNames, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(samplingRate, scorers, applyToRootSpan, applyToSpanNames, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 1baae702..7f3fc444 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -195,17 +195,14 @@ private constructor( return true } - return /* spotless:off */ other is Organization && this.id == other.id && this.name == other.name && this.apiUrl == other.apiUrl && this.isUniversalApi == other.isUniversalApi && this.proxyUrl == other.proxyUrl && this.realtimeUrl == other.realtimeUrl && this.created == other.created && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && created == other.created && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, apiUrl, isUniversalApi, proxyUrl, realtimeUrl, created, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, name, apiUrl, isUniversalApi, proxyUrl, realtimeUrl, created, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Organization{id=$id, name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, created=$created, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index a50158c1..b17e2a3a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is OrganizationDeleteParams && this.organizationId == other.organizationId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index d9617280..c6411018 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is OrganizationListPage && this.organizationsService == other.organizationsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is OrganizationListPage && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ override fun toString() = "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" @@ -124,15 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "OrganizationListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index e3e67824..309b4c7b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is OrganizationListPageAsync && this.organizationsService == other.organizationsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is OrganizationListPageAsync && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ override fun toString() = "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "OrganizationListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index ab003151..11403c90 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -65,12 +65,10 @@ constructor( return true } - return /* spotless:off */ other is OrganizationListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -303,21 +301,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 0c945564..7b0defe5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -163,17 +163,14 @@ constructor( return true } - return /* spotless:off */ other is OrganizationMemberUpdateBody && this.inviteUsers == other.inviteUsers && this.orgId == other.orgId && this.orgName == other.orgName && this.removeUsers == other.removeUsers && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationMemberUpdateBody && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" @@ -190,12 +187,10 @@ constructor( return true } - return /* spotless:off */ other is OrganizationMemberUpdateParams && this.inviteUsers == other.inviteUsers && this.orgId == other.orgId && this.orgName == other.orgName && this.removeUsers == other.removeUsers && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationMemberUpdateParams && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -512,17 +507,14 @@ constructor( return true } - return /* spotless:off */ other is InviteUsers && this.ids == other.ids && this.emails == other.emails && this.sendInviteEmails == other.sendInviteEmails && this.groupIds == other.groupIds && this.groupNames == other.groupNames && this.groupId == other.groupId && this.groupName == other.groupName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InviteUsers && ids == other.ids && emails == other.emails && sendInviteEmails == other.sendInviteEmails && groupIds == other.groupIds && groupNames == other.groupNames && groupId == other.groupId && groupName == other.groupName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(ids, emails, sendInviteEmails, groupIds, groupNames, groupId, groupName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(ids, emails, sendInviteEmails, groupIds, groupNames, groupId, groupName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupIds=$groupIds, groupNames=$groupNames, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" @@ -602,17 +594,14 @@ constructor( return true } - return /* spotless:off */ other is RemoveUsers && this.ids == other.ids && this.emails == other.emails && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveUsers && ids == other.ids && emails == other.emails && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(ids, emails, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(ids, emails, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 3ef4e2e3..c60e623c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is OrganizationRetrieveParams && this.organizationId == other.organizationId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 84441ed9..fd7a12f0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -163,17 +163,14 @@ constructor( return true } - return /* spotless:off */ other is OrganizationUpdateBody && this.apiUrl == other.apiUrl && this.isUniversalApi == other.isUniversalApi && this.name == other.name && this.proxyUrl == other.proxyUrl && this.realtimeUrl == other.realtimeUrl && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationUpdateBody && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" @@ -190,12 +187,10 @@ constructor( return true } - return /* spotless:off */ other is OrganizationUpdateParams && this.organizationId == other.organizationId && this.apiUrl == other.apiUrl && this.isUniversalApi == other.isUniversalApi && this.name == other.name && this.proxyUrl == other.proxyUrl && this.realtimeUrl == other.realtimeUrl && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(organizationId, apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 6f8bf79c..c20f53c9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -154,7 +154,7 @@ private constructor( return true } - return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -197,17 +197,14 @@ private constructor( return true } - return /* spotless:off */ other is PatchOrganizationMembersOutput && this.status == other.status && this.orgId == other.orgId && this.sendEmailError == other.sendEmailError && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PatchOrganizationMembersOutput && status == other.status && orgId == other.orgId && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(status, orgId, sendEmailError, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(status, orgId, sendEmailError, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PatchOrganizationMembersOutput{status=$status, orgId=$orgId, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index d5339198..cc9e6d6d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -205,17 +205,14 @@ private constructor( return true } - return /* spotless:off */ other is Project && this.id == other.id && this.orgId == other.orgId && this.name == other.name && this.created == other.created && this.deletedAt == other.deletedAt && this.userId == other.userId && this.settings == other.settings && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Project && id == other.id && orgId == other.orgId && name == other.name && created == other.created && deletedAt == other.deletedAt && userId == other.userId && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, orgId, name, created, deletedAt, userId, settings, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, orgId, name, created, deletedAt, userId, settings, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index fc4b9fa6..84e27a83 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -123,17 +123,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectCreateBody && this.name == other.name && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectCreateBody && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, orgName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, orgName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" @@ -150,12 +147,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectCreateParams && this.name == other.name && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectCreateParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index cd8ed199..bc0cf9bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectDeleteParams && this.projectId == other.projectId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index 5635ae73..a19ead47 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is ProjectListPage && this.projectsService == other.projectsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectListPage && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ override fun toString() = "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" @@ -120,15 +118,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ProjectListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index a019b26b..1a0f4e9c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is ProjectListPageAsync && this.projectsService == other.projectsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectListPageAsync && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ override fun toString() = "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ProjectListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index a8bb107a..6362f645 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -69,12 +69,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectName == other.projectName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -313,21 +311,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 67750730..a03021a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -110,17 +110,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFeedbackBody && this.feedback == other.feedback && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFeedbackBody && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(feedback, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(feedback, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" @@ -137,12 +134,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFeedbackParams && this.projectId == other.projectId && this.feedback == other.feedback && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 7d62f4eb..933e7d84 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -59,12 +59,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchParams && this.projectId == other.projectId && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 721df4c3..73371efe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -263,17 +263,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostBody && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostBody && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(cursor, limit, maxRootSpanId, maxXactId, version, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectLogFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" @@ -290,12 +287,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostParams && this.projectId == other.projectId && this.cursor == other.cursor && this.limit == other.limit && this.maxRootSpanId == other.maxRootSpanId && this.maxXactId == other.maxXactId && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 9938c488..bc1215ea 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -107,17 +107,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogInsertBody && this.events == other.events && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogInsertBody && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(events, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(events, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" @@ -134,12 +131,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogInsertParams && this.projectId == other.projectId && this.events == other.events && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 66972205..290eb5ed 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -666,7 +666,7 @@ private constructor( return true } - return /* spotless:off */ other is LogId && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -839,17 +839,14 @@ private constructor( return true } - return /* spotless:off */ other is Context && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" @@ -919,17 +916,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -1205,17 +1199,14 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.start == other.start && this.end == other.end && this.promptTokens == other.promptTokens && this.completionTokens == other.completionTokens && this.tokens == other.tokens && this.callerFunctionname == other.callerFunctionname && this.callerFilename == other.callerFilename && this.callerLineno == other.callerLineno && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && start == other.start && end == other.end && promptTokens == other.promptTokens && completionTokens == other.completionTokens && tokens == other.tokens && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" @@ -1368,7 +1359,7 @@ private constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1441,17 +1432,14 @@ private constructor( return true } - return /* spotless:off */ other is Origin && this.objectType == other.objectType && this.objectId == other.objectId && this.id == other.id && this._xactId == other._xactId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && id == other.id && _xactId == other._xactId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectType, objectId, id, _xactId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectType, objectId, id, _xactId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" @@ -1523,17 +1511,14 @@ private constructor( return true } - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Scores{additionalProperties=$additionalProperties}" } @@ -1543,17 +1528,14 @@ private constructor( return true } - return /* spotless:off */ other is ProjectLogsEvent && this.id == other.id && this._xactId == other._xactId && this.created == other.created && this.orgId == other.orgId && this.projectId == other.projectId && this.logId == other.logId && this.input == other.input && this.output == other.output && this.expected == other.expected && this.error == other.error && this.scores == other.scores && this.metadata == other.metadata && this.tags == other.tags && this.metrics == other.metrics && this.context == other.context && this.spanId == other.spanId && this.spanParents == other.spanParents && this.rootSpanId == other.rootSpanId && this.isRoot == other.isRoot && this.spanAttributes == other.spanAttributes && this.origin == other.origin && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && orgId == other.orgId && projectId == other.projectId && logId == other.logId && input == other.input && output == other.output && expected == other.expected && error == other.error && scores == other.scores && metadata == other.metadata && tags == other.tags && metrics == other.metrics && context == other.context && spanId == other.spanId && spanParents == other.spanParents && rootSpanId == other.rootSpanId && isRoot == other.isRoot && spanAttributes == other.spanAttributes && origin == other.origin && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, orgId, projectId, logId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, isRoot, spanAttributes, origin, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, _xactId, created, orgId, projectId, logId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, isRoot, spanAttributes, origin, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, isRoot=$isRoot, spanAttributes=$spanAttributes, origin=$origin, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index a5f686d8..ad41bd68 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectRetrieveParams && this.projectId == other.projectId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" 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 757c5b2d..28bb4d36 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 @@ -279,7 +279,7 @@ private constructor( return true } - return /* spotless:off */ other is ScoreType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -419,15 +419,13 @@ private constructor( return true } - return /* spotless:off */ other is Categories && this.categorical == other.categorical && this.weighted == other.weighted && this.minimum == other.minimum && this.nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" @@ -435,7 +433,6 @@ private constructor( _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } - } companion object { @@ -571,17 +568,14 @@ private constructor( return true } - return /* spotless:off */ other is Weighted && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } @@ -644,17 +638,14 @@ private constructor( return true } - return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } @@ -665,17 +656,14 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScore && this.id == other.id && this.projectId == other.projectId && this.userId == other.userId && this.created == other.created && this.name == other.name && this.description == other.description && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.position == other.position && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScore && id == other.id && projectId == other.projectId && userId == other.userId && created == other.created && name == other.name && description == other.description && scoreType == other.scoreType && categories == other.categories && config == other.config && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, projectId, userId, created, name, description, scoreType, categories, config, position, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, projectId, userId, created, name, description, scoreType, categories, config, position, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectScore{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, scoreType=$scoreType, categories=$categories, config=$config, position=$position, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index 79db9fbd..99a37566 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -113,17 +113,14 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScoreCategory && this.name == other.name && this.value == other.value && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCategory && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, value, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, value, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 1bf51379..e1641f66 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -135,7 +135,7 @@ private constructor( return true } - return /* spotless:off */ other is Destination && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -178,17 +178,14 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScoreConfig && this.multiSelect == other.multiSelect && this.destination == other.destination && this.online == other.online && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreConfig && multiSelect == other.multiSelect && destination == other.destination && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(multiSelect, destination, online, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(multiSelect, destination, online, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectScoreConfig{multiSelect=$multiSelect, destination=$destination, online=$online, additionalProperties=$additionalProperties}" 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 60058737..bb659f61 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 @@ -186,17 +186,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreCreateBody && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCreateBody && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, scoreType, categories, config, description, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" @@ -213,12 +210,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreCreateParams && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCreateParams && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -440,7 +435,7 @@ constructor( return true } - return /* spotless:off */ other is ScoreType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -580,15 +575,13 @@ constructor( return true } - return /* spotless:off */ other is Categories && this.categorical == other.categorical && this.weighted == other.weighted && this.minimum == other.minimum && this.nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" @@ -596,7 +589,6 @@ constructor( _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } - } companion object { @@ -732,17 +724,14 @@ constructor( return true } - return /* spotless:off */ other is Weighted && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } @@ -805,17 +794,14 @@ constructor( return true } - return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 1b8a417f..d084bb49 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreDeleteParams && this.projectScoreId == other.projectScoreId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index ce5bf53e..2f728a79 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScoreListPage && this.projectScoresService == other.projectScoresService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListPage && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ override fun toString() = "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" @@ -124,15 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ProjectScoreListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index 1f09685c..5c68f620 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScoreListPageAsync && this.projectScoresService == other.projectScoresService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListPageAsync && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ override fun toString() = "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ProjectScoreListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { 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 7fcf0fe2..d9db0408 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 @@ -84,12 +84,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.projectScoreName == other.projectScoreName && this.scoreType == other.scoreType && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -358,21 +356,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { @@ -475,21 +470,18 @@ constructor( return true } - return /* spotless:off */ other is ScoreType && this.projectScoreType == other.projectScoreType && this.projectScoreTypes == other.projectScoreTypes /* spotless:on */ + return /* spotless:off */ other is ScoreType && projectScoreType == other.projectScoreType && projectScoreTypes == other.projectScoreTypes /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoreType, projectScoreTypes) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreType, projectScoreTypes) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { projectScoreType != null -> "ScoreType{projectScoreType=$projectScoreType}" projectScoreTypes != null -> "ScoreType{projectScoreTypes=$projectScoreTypes}" _json != null -> "ScoreType{_unknown=$_json}" else -> throw IllegalStateException("Invalid ScoreType") } - } companion object { @@ -559,7 +551,7 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -640,7 +632,7 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() 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 99729d33..f4b4f5e0 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 @@ -186,17 +186,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreReplaceBody && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreReplaceBody && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, scoreType, categories, config, description, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" @@ -213,12 +210,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreReplaceParams && this.name == other.name && this.projectId == other.projectId && this.scoreType == other.scoreType && this.categories == other.categories && this.config == other.config && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreReplaceParams && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -440,7 +435,7 @@ constructor( return true } - return /* spotless:off */ other is ScoreType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -580,15 +575,13 @@ constructor( return true } - return /* spotless:off */ other is Categories && this.categorical == other.categorical && this.weighted == other.weighted && this.minimum == other.minimum && this.nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" @@ -596,7 +589,6 @@ constructor( _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } - } companion object { @@ -732,17 +724,14 @@ constructor( return true } - return /* spotless:off */ other is Weighted && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } @@ -805,17 +794,14 @@ constructor( return true } - return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 963b0cee..c1af62f2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreRetrieveParams && this.projectScoreId == other.projectScoreId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" 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 5f942fad..65b15ac1 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 @@ -181,17 +181,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreUpdateBody && this.categories == other.categories && this.config == other.config && this.description == other.description && this.name == other.name && this.scoreType == other.scoreType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreUpdateBody && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(categories, config, description, name, scoreType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(categories, config, description, name, scoreType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectScoreUpdateBody{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" @@ -208,12 +205,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreUpdateParams && this.projectScoreId == other.projectScoreId && this.categories == other.categories && this.config == other.config && this.description == other.description && this.name == other.name && this.scoreType == other.scoreType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectScoreId, categories, config, description, name, scoreType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, categories, config, description, name, scoreType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -494,15 +489,13 @@ constructor( return true } - return /* spotless:off */ other is Categories && this.categorical == other.categorical && this.weighted == other.weighted && this.minimum == other.minimum && this.nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" @@ -510,7 +503,6 @@ constructor( _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } - } companion object { @@ -646,17 +638,14 @@ constructor( return true } - return /* spotless:off */ other is Weighted && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } @@ -719,17 +708,14 @@ constructor( return true } - return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } @@ -748,7 +734,7 @@ constructor( return true } - return /* spotless:off */ other is ScoreType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index dddda0c9..63d9c02a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -94,17 +94,14 @@ private constructor( return true } - return /* spotless:off */ other is ProjectSettings && this.comparisonKey == other.comparisonKey && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(comparisonKey, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(comparisonKey, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 55a488a0..257b71ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -208,17 +208,14 @@ private constructor( return true } - return /* spotless:off */ other is ProjectTag && this.id == other.id && this.projectId == other.projectId && this.userId == other.userId && this.created == other.created && this.name == other.name && this.description == other.description && this.color == other.color && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTag && id == other.id && projectId == other.projectId && userId == other.userId && created == other.created && name == other.name && description == other.description && color == other.color && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, projectId, userId, created, name, description, color, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, projectId, userId, created, name, description, color, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectTag{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 9321520d..49605061 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -144,17 +144,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagCreateBody && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagCreateBody && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, color, description, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" @@ -171,12 +168,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagCreateParams && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagCreateParams && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 34a96215..6d7a6038 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagDeleteParams && this.projectTagId == other.projectTagId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index ac4fbfea..e32a9436 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is ProjectTagListPage && this.projectTagsService == other.projectTagsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectTagListPage && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ override fun toString() = "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" @@ -124,15 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ProjectTagListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 2ba47420..822a3261 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is ProjectTagListPageAsync && this.projectTagsService == other.projectTagsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectTagListPageAsync && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ override fun toString() = "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ProjectTagListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index b7d71d99..ab396d03 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -77,12 +77,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.projectTagName == other.projectTagName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -333,21 +331,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index a8b692f9..6a3dd241 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -144,17 +144,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagReplaceBody && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagReplaceBody && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, color, description, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" @@ -171,12 +168,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagReplaceParams && this.name == other.name && this.projectId == other.projectId && this.color == other.color && this.description == other.description && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagReplaceParams && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 44302f60..658f450f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagRetrieveParams && this.projectTagId == other.projectTagId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 7cfcd4bd..54ad308a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -139,17 +139,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagUpdateBody && this.color == other.color && this.description == other.description && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagUpdateBody && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(color, description, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(color, description, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" @@ -166,12 +163,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagUpdateParams && this.projectTagId == other.projectTagId && this.color == other.color && this.description == other.description && this.name == other.name && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && color == other.color && description == other.description && name == other.name && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectTagId, color, description, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, color, description, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index 2d75d5c2..d67a82ca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -131,17 +131,14 @@ constructor( return true } - return /* spotless:off */ other is ProjectUpdateBody && this.name == other.name && this.settings == other.settings && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectUpdateBody && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, settings, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, settings, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" @@ -158,12 +155,10 @@ constructor( return true } - return /* spotless:off */ other is ProjectUpdateParams && this.projectId == other.projectId && this.name == other.name && this.settings == other.settings && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && name == other.name && settings == other.settings && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(projectId, name, settings, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, name, settings, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 438b3ad8..6f591005 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -349,7 +349,7 @@ private constructor( return true } - return /* spotless:off */ other is LogId && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -400,7 +400,7 @@ private constructor( return true } - return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -514,17 +514,14 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } @@ -534,17 +531,14 @@ private constructor( return true } - return /* spotless:off */ other is Prompt && this.id == other.id && this._xactId == other._xactId && this.projectId == other.projectId && this.logId == other.logId && this.orgId == other.orgId && this.name == other.name && this.slug == other.slug && this.description == other.description && this.created == other.created && this.promptData == other.promptData && this.tags == other.tags && this.metadata == other.metadata && this.functionType == other.functionType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && projectId == other.projectId && logId == other.logId && orgId == other.orgId && name == other.name && slug == other.slug && description == other.description && created == other.created && promptData == other.promptData && tags == other.tags && metadata == other.metadata && functionType == other.functionType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, _xactId, projectId, logId, orgId, name, slug, description, created, promptData, tags, metadata, functionType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, _xactId, projectId, logId, orgId, name, slug, description, created, promptData, tags, metadata, functionType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 2d136623..14ae625a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -192,17 +192,14 @@ constructor( return true } - return /* spotless:off */ other is PromptCreateBody && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptCreateBody && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" @@ -219,12 +216,10 @@ constructor( return true } - return /* spotless:off */ other is PromptCreateParams && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptCreateParams && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -438,7 +433,7 @@ constructor( return true } - return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 539d5a13..942ab249 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -270,17 +270,14 @@ private constructor( return true } - return /* spotless:off */ other is Origin && this.promptId == other.promptId && this.projectId == other.projectId && this.promptVersion == other.promptVersion && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && promptId == other.promptId && projectId == other.projectId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(promptId, projectId, promptVersion, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(promptId, projectId, promptVersion, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" @@ -446,17 +443,14 @@ private constructor( return true } - return /* spotless:off */ other is ChoiceScores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChoiceScores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ChoiceScores{additionalProperties=$additionalProperties}" } @@ -474,7 +468,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -517,17 +511,14 @@ private constructor( return true } - return /* spotless:off */ other is Parser && this.type == other.type && this.useCot == other.useCot && this.choiceScores == other.choiceScores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Parser && type == other.type && useCot == other.useCot && choiceScores == other.choiceScores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, useCot, choiceScores, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, useCot, choiceScores, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Parser{type=$type, useCot=$useCot, choiceScores=$choiceScores, additionalProperties=$additionalProperties}" @@ -591,22 +582,19 @@ private constructor( return true } - return /* spotless:off */ other is Prompt && this.completion == other.completion && this.chat == other.chat && this.nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(completion, chat, nullableVariant) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(completion, chat, nullableVariant) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { completion != null -> "Prompt{completion=$completion}" chat != null -> "Prompt{chat=$chat}" nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" _json != null -> "Prompt{_unknown=$_json}" else -> throw IllegalStateException("Invalid Prompt") } - } companion object { @@ -770,7 +758,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -813,17 +801,14 @@ private constructor( return true } - return /* spotless:off */ other is Completion && this.type == other.type && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Completion && type == other.type && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, content, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, content, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" @@ -1024,15 +1009,13 @@ private constructor( return true } - return /* spotless:off */ other is Message && this.system == other.system && this.user == other.user && this.assistant == other.assistant && this.tool == other.tool && this.function == other.function && this.fallback == other.fallback /* spotless:on */ + return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { system != null -> "Message{system=$system}" user != null -> "Message{user=$user}" assistant != null -> "Message{assistant=$assistant}" @@ -1042,7 +1025,6 @@ private constructor( _json != null -> "Message{_unknown=$_json}" else -> throw IllegalStateException("Invalid Message") } - } companion object { @@ -1250,7 +1232,7 @@ private constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1293,17 +1275,14 @@ private constructor( return true } - return /* spotless:off */ other is System && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && content == other.content && role == other.role && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, role, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" @@ -1426,7 +1405,7 @@ private constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1512,21 +1491,18 @@ private constructor( return true } - return /* spotless:off */ other is Content && this.text == other.text && this.array == other.array /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, array) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { text != null -> "Content{text=$text}" array != null -> "Content{array=$array}" _json != null -> "Content{_unknown=$_json}" else -> throw IllegalStateException("Invalid Content") } - } companion object { @@ -1660,15 +1636,13 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionContentPart && this.chatCompletionContentPartText == other.chatCompletionContentPartText && this.chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && chatCompletionContentPartText == other.chatCompletionContentPartText && chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { chatCompletionContentPartText != null -> "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" chatCompletionContentPartImage != null -> @@ -1679,7 +1653,6 @@ private constructor( "Invalid ChatCompletionContentPart" ) } - } companion object { @@ -1793,17 +1766,14 @@ private constructor( return true } - return /* spotless:off */ other is User && this.content == other.content && this.role == other.role && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && content == other.content && role == other.role && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, role, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" @@ -1968,7 +1938,7 @@ private constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2100,17 +2070,14 @@ private constructor( return true } - return /* spotless:off */ other is FunctionCall && this.arguments == other.arguments && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(arguments, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(arguments, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" @@ -2121,17 +2088,14 @@ private constructor( return true } - return /* spotless:off */ other is Assistant && this.role == other.role && this.content == other.content && this.functionCall == other.functionCall && this.name == other.name && this.toolCalls == other.toolCalls && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, functionCall, name, toolCalls, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" @@ -2257,7 +2221,7 @@ private constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2300,17 +2264,14 @@ private constructor( return true } - return /* spotless:off */ other is Tool && this.content == other.content && this.role == other.role && this.toolCallId == other.toolCallId && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && content == other.content && role == other.role && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, role, toolCallId, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, role, toolCallId, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" @@ -2433,7 +2394,7 @@ private constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2476,17 +2437,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.content == other.content && this.name == other.name && this.role == other.role && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && content == other.content && name == other.name && role == other.role && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, name, role, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(content, name, role, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" @@ -2594,7 +2552,7 @@ private constructor( return true } - return /* spotless:off */ other is Role && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2637,17 +2595,14 @@ private constructor( return true } - return /* spotless:off */ other is Fallback && this.role == other.role && this.content == other.content && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(role, content, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(role, content, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" @@ -2667,7 +2622,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2710,17 +2665,14 @@ private constructor( return true } - return /* spotless:off */ other is Chat && this.type == other.type && this.messages == other.messages && this.tools == other.tools && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Chat && type == other.type && messages == other.messages && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, messages, tools, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, messages, tools, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" @@ -2784,17 +2736,14 @@ private constructor( return true } - return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } @@ -2849,21 +2798,18 @@ private constructor( return true } - return /* spotless:off */ other is ToolFunction && this.function == other.function && this.global == other.global /* spotless:on */ + return /* spotless:off */ other is ToolFunction && function == other.function && global == other.global /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(function, global) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(function, global) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { function != null -> "ToolFunction{function=$function}" global != null -> "ToolFunction{global=$global}" _json != null -> "ToolFunction{_unknown=$_json}" else -> throw IllegalStateException("Invalid ToolFunction") } - } companion object { @@ -3016,7 +2962,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3059,17 +3005,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.type == other.type && this.id == other.id && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && type == other.type && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, id, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, id, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" @@ -3174,7 +3117,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3217,17 +3160,14 @@ private constructor( return true } - return /* spotless:off */ other is Global && this.type == other.type && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" @@ -3239,17 +3179,14 @@ private constructor( return true } - return /* spotless:off */ other is PromptData && this.prompt == other.prompt && this.options == other.options && this.parser == other.parser && this.toolFunctions == other.toolFunctions && this.origin == other.origin && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptData && prompt == other.prompt && options == other.options && parser == other.parser && toolFunctions == other.toolFunctions && origin == other.origin && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(prompt, options, parser, toolFunctions, origin, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(prompt, options, parser, toolFunctions, origin, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PromptData{prompt=$prompt, options=$options, parser=$parser, toolFunctions=$toolFunctions, origin=$origin, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 7762e85a..6904cf2f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is PromptDeleteParams && this.promptId == other.promptId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index 0e8d72a0..c692f4f7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is PromptListPage && this.promptsService == other.promptsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is PromptListPage && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ override fun toString() = "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" @@ -114,15 +112,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "PromptListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index c7aa8ec6..9d1786e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is PromptListPageAsync && this.promptsService == other.promptsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is PromptListPageAsync && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ override fun toString() = "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" @@ -117,15 +115,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "PromptListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 12a3ed32..19dd0825 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -85,12 +85,10 @@ constructor( return true } - return /* spotless:off */ other is PromptListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.projectId == other.projectId && this.projectName == other.projectName && this.promptName == other.promptName && this.slug == other.slug && this.startingAfter == other.startingAfter && this.version == other.version && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -358,21 +356,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 834e7427..2db2169f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -220,15 +220,13 @@ private constructor( return true } - return /* spotless:off */ other is Params && this.openaiModelParams == other.openaiModelParams && this.anthropicModelParams == other.anthropicModelParams && this.googleModelParams == other.googleModelParams && this.windowAiModelParams == other.windowAiModelParams && this.jsCompletionParams == other.jsCompletionParams /* spotless:on */ + return /* spotless:off */ other is Params && openaiModelParams == other.openaiModelParams && anthropicModelParams == other.anthropicModelParams && googleModelParams == other.googleModelParams && windowAiModelParams == other.windowAiModelParams && jsCompletionParams == other.jsCompletionParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(openaiModelParams, anthropicModelParams, googleModelParams, windowAiModelParams, jsCompletionParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(openaiModelParams, anthropicModelParams, googleModelParams, windowAiModelParams, jsCompletionParams) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" anthropicModelParams != null -> "Params{anthropicModelParams=$anthropicModelParams}" googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" @@ -237,7 +235,6 @@ private constructor( _json != null -> "Params{_unknown=$_json}" else -> throw IllegalStateException("Invalid Params") } - } companion object { @@ -638,22 +635,19 @@ private constructor( return true } - return /* spotless:off */ other is FunctionCall && this.auto == other.auto && this.none == other.none && this.function == other.function /* spotless:on */ + return /* spotless:off */ other is FunctionCall && auto == other.auto && none == other.none && function == other.function /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(auto, none, function) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, none, function) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { auto != null -> "FunctionCall{auto=$auto}" none != null -> "FunctionCall{none=$none}" function != null -> "FunctionCall{function=$function}" _json != null -> "FunctionCall{_unknown=$_json}" else -> throw IllegalStateException("Invalid FunctionCall") } - } companion object { @@ -729,7 +723,7 @@ private constructor( return true } - return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Auto && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -781,7 +775,7 @@ private constructor( return true } - return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is None && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -892,17 +886,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" @@ -983,15 +974,13 @@ private constructor( return true } - return /* spotless:off */ other is ResponseFormat && this.jsonObject == other.jsonObject && this.jsonSchema == other.jsonSchema && this.text == other.text && this.nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" text != null -> "ResponseFormat{text=$text}" @@ -1000,7 +989,6 @@ private constructor( _json != null -> "ResponseFormat{_unknown=$_json}" else -> throw IllegalStateException("Invalid ResponseFormat") } - } companion object { @@ -1162,7 +1150,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1205,17 +1193,14 @@ private constructor( return true } - return /* spotless:off */ other is JsonObject && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonObject && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "JsonObject{type=$type, additionalProperties=$additionalProperties}" @@ -1497,17 +1482,14 @@ private constructor( return true } - return /* spotless:off */ other is Schema && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Schema{additionalProperties=$additionalProperties}" @@ -1518,17 +1500,14 @@ private constructor( return true } - return /* spotless:off */ other is JsonSchema && this.name == other.name && this.description == other.description && this.schema == other.schema && this.strict == other.strict && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, description, schema, strict, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, description, schema, strict, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "JsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" @@ -1548,7 +1527,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1591,17 +1570,14 @@ private constructor( return true } - return /* spotless:off */ other is JsonSchema && this.type == other.type && this.jsonSchema == other.jsonSchema && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonSchema && type == other.type && jsonSchema == other.jsonSchema && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, jsonSchema, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, jsonSchema, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "JsonSchema{type=$type, jsonSchema=$jsonSchema, additionalProperties=$additionalProperties}" @@ -1689,7 +1665,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1732,17 +1708,14 @@ private constructor( return true } - return /* spotless:off */ other is Text && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Text{type=$type, additionalProperties=$additionalProperties}" @@ -1808,17 +1781,14 @@ private constructor( return true } - return /* spotless:off */ other is NullableVariant && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" @@ -1889,15 +1859,13 @@ private constructor( return true } - return /* spotless:off */ other is ToolChoice && this.auto == other.auto && this.none == other.none && this.required == other.required && this.function == other.function /* spotless:on */ + return /* spotless:off */ other is ToolChoice && auto == other.auto && none == other.none && required == other.required && function == other.function /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(auto, none, required, function) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, none, required, function) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { auto != null -> "ToolChoice{auto=$auto}" none != null -> "ToolChoice{none=$none}" required != null -> "ToolChoice{required=$required}" @@ -1905,7 +1873,6 @@ private constructor( _json != null -> "ToolChoice{_unknown=$_json}" else -> throw IllegalStateException("Invalid ToolChoice") } - } companion object { @@ -1988,7 +1955,7 @@ private constructor( return true } - return /* spotless:off */ other is Auto && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Auto && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2040,7 +2007,7 @@ private constructor( return true } - return /* spotless:off */ other is None && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is None && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2092,7 +2059,7 @@ private constructor( return true } - return /* spotless:off */ other is Required && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Required && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2293,17 +2260,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.name == other.name && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" @@ -2323,7 +2287,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2366,17 +2330,14 @@ private constructor( return true } - return /* spotless:off */ other is Function && this.type == other.type && this.function == other.function && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && type == other.type && function == other.function && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, function, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(type, function, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" @@ -2388,17 +2349,14 @@ private constructor( return true } - return /* spotless:off */ other is OpenAIModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.topP == other.topP && this.maxTokens == other.maxTokens && this.frequencyPenalty == other.frequencyPenalty && this.presencePenalty == other.presencePenalty && this.responseFormat == other.responseFormat && this.toolChoice == other.toolChoice && this.functionCall == other.functionCall && this.n == other.n && this.stop == other.stop && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OpenAIModelParams && useCache == other.useCache && temperature == other.temperature && topP == other.topP && maxTokens == other.maxTokens && frequencyPenalty == other.frequencyPenalty && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && toolChoice == other.toolChoice && functionCall == other.functionCall && n == other.n && stop == other.stop && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(useCache, temperature, topP, maxTokens, frequencyPenalty, presencePenalty, responseFormat, toolChoice, functionCall, n, stop, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, temperature, topP, maxTokens, frequencyPenalty, presencePenalty, responseFormat, toolChoice, functionCall, n, stop, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" @@ -2587,17 +2545,14 @@ private constructor( return true } - return /* spotless:off */ other is AnthropicModelParams && this.useCache == other.useCache && this.maxTokens == other.maxTokens && this.temperature == other.temperature && this.topP == other.topP && this.topK == other.topK && this.stopSequences == other.stopSequences && this.maxTokensToSample == other.maxTokensToSample && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AnthropicModelParams && useCache == other.useCache && maxTokens == other.maxTokens && temperature == other.temperature && topP == other.topP && topK == other.topK && stopSequences == other.stopSequences && maxTokensToSample == other.maxTokensToSample && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(useCache, maxTokens, temperature, topP, topK, stopSequences, maxTokensToSample, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, maxTokens, temperature, topP, topK, stopSequences, maxTokensToSample, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" @@ -2749,17 +2704,14 @@ private constructor( return true } - return /* spotless:off */ other is GoogleModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.maxOutputTokens == other.maxOutputTokens && this.topP == other.topP && this.topK == other.topK && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GoogleModelParams && useCache == other.useCache && temperature == other.temperature && maxOutputTokens == other.maxOutputTokens && topP == other.topP && topK == other.topK && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(useCache, temperature, maxOutputTokens, topP, topK, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, temperature, maxOutputTokens, topP, topK, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" @@ -2875,17 +2827,14 @@ private constructor( return true } - return /* spotless:off */ other is WindowAiModelParams && this.useCache == other.useCache && this.temperature == other.temperature && this.topK == other.topK && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is WindowAiModelParams && useCache == other.useCache && temperature == other.temperature && topK == other.topK && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(useCache, temperature, topK, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, temperature, topK, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" @@ -2965,17 +2914,14 @@ private constructor( return true } - return /* spotless:off */ other is JsCompletionParams && this.useCache == other.useCache && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsCompletionParams && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(useCache, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(useCache, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" @@ -2987,17 +2933,14 @@ private constructor( return true } - return /* spotless:off */ other is PromptOptions && this.model == other.model && this.params == other.params && this.position == other.position && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptOptions && model == other.model && params == other.params && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(model, params, position, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(model, params, position, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PromptOptions{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index d56b8967..a958d0a1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -192,17 +192,14 @@ constructor( return true } - return /* spotless:off */ other is PromptReplaceBody && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptReplaceBody && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" @@ -219,12 +216,10 @@ constructor( return true } - return /* spotless:off */ other is PromptReplaceParams && this.name == other.name && this.projectId == other.projectId && this.slug == other.slug && this.description == other.description && this.functionType == other.functionType && this.promptData == other.promptData && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptReplaceParams && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -438,7 +433,7 @@ constructor( return true } - return /* spotless:off */ other is FunctionType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index e664bced..cfad460f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is PromptRetrieveParams && this.promptId == other.promptId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index 70a69e55..a95a0ba1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -168,17 +168,14 @@ constructor( return true } - return /* spotless:off */ other is PromptUpdateBody && this.description == other.description && this.name == other.name && this.promptData == other.promptData && this.slug == other.slug && this.tags == other.tags && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptUpdateBody && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(description, name, promptData, slug, tags, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(description, name, promptData, slug, tags, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" @@ -195,12 +192,10 @@ constructor( return true } - return /* spotless:off */ other is PromptUpdateParams && this.promptId == other.promptId && this.description == other.description && this.name == other.name && this.promptData == other.promptData && this.slug == other.slug && this.tags == other.tags && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(promptId, description, name, promptData, slug, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, description, name, promptData, slug, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index 135364d3..c17cecde 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -263,17 +263,14 @@ private constructor( return true } - return /* spotless:off */ other is RepoInfo && this.commit == other.commit && this.branch == other.branch && this.tag == other.tag && this.dirty == other.dirty && this.authorName == other.authorName && this.authorEmail == other.authorEmail && this.commitMessage == other.commitMessage && this.commitTime == other.commitTime && this.gitDiff == other.gitDiff && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RepoInfo && commit == other.commit && branch == other.branch && tag == other.tag && dirty == other.dirty && authorName == other.authorName && authorEmail == other.authorEmail && commitMessage == other.commitMessage && commitTime == other.commitTime && gitDiff == other.gitDiff && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(commit, branch, tag, dirty, authorName, authorEmail, commitMessage, commitTime, gitDiff, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(commit, branch, tag, dirty, authorName, authorEmail, commitMessage, commitTime, gitDiff, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" 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 9f311854..8fb5572a 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 @@ -437,7 +437,7 @@ private constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -530,7 +530,7 @@ private constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -634,17 +634,14 @@ private constructor( return true } - return /* spotless:off */ other is MemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(permission, restrictObjectType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" @@ -655,17 +652,14 @@ private constructor( return true } - return /* spotless:off */ other is Role && this.id == other.id && this.orgId == other.orgId && this.userId == other.userId && this.created == other.created && this.name == other.name && this.description == other.description && this.deletedAt == other.deletedAt && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Role && id == other.id && orgId == other.orgId && userId == other.userId && created == other.created && name == other.name && description == other.description && deletedAt == other.deletedAt && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, orgId, userId, created, name, description, deletedAt, memberPermissions, memberRoles, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, orgId, userId, created, name, description, deletedAt, memberPermissions, memberRoles, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Role{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberPermissions=$memberPermissions, memberRoles=$memberRoles, additionalProperties=$additionalProperties}" 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 ad873cf6..796c4928 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 @@ -186,17 +186,14 @@ constructor( return true } - return /* spotless:off */ other is RoleCreateBody && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RoleCreateBody && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" @@ -213,12 +210,10 @@ constructor( return true } - return /* spotless:off */ other is RoleCreateParams && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleCreateParams && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -524,7 +519,7 @@ constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -617,7 +612,7 @@ constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -721,17 +716,14 @@ constructor( return true } - return /* spotless:off */ other is MemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(permission, restrictObjectType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 811df939..76b4a7b1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is RoleDeleteParams && this.roleId == other.roleId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index b78f7bec..1debe4a4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is RoleListPage && this.rolesService == other.rolesService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is RoleListPage && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ override fun toString() = "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" @@ -114,15 +112,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "RoleListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index 452fb9b6..1874ecb6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is RoleListPageAsync && this.rolesService == other.rolesService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is RoleListPageAsync && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ override fun toString() = "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" @@ -117,15 +115,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "RoleListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 96d37f2c..698bbe3d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -69,12 +69,10 @@ constructor( return true } - return /* spotless:off */ other is RoleListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.roleName == other.roleName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -313,21 +311,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { 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 22623159..803994e4 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 @@ -186,17 +186,14 @@ constructor( return true } - return /* spotless:off */ other is RoleReplaceBody && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RoleReplaceBody && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" @@ -213,12 +210,10 @@ constructor( return true } - return /* spotless:off */ other is RoleReplaceParams && this.name == other.name && this.description == other.description && this.memberPermissions == other.memberPermissions && this.memberRoles == other.memberRoles && this.orgName == other.orgName && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleReplaceParams && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -524,7 +519,7 @@ constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -617,7 +612,7 @@ constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -721,17 +716,14 @@ constructor( return true } - return /* spotless:off */ other is MemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(permission, restrictObjectType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index f5a74fb3..36e8c206 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is RoleRetrieveParams && this.roleId == other.roleId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" 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 2c50afe7..9f83c745 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 @@ -203,17 +203,14 @@ constructor( return true } - return /* spotless:off */ other is RoleUpdateBody && this.addMemberPermissions == other.addMemberPermissions && this.addMemberRoles == other.addMemberRoles && this.description == other.description && this.name == other.name && this.removeMemberPermissions == other.removeMemberPermissions && this.removeMemberRoles == other.removeMemberRoles && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RoleUpdateBody && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" @@ -230,12 +227,10 @@ constructor( return true } - return /* spotless:off */ other is RoleUpdateParams && this.roleId == other.roleId && this.addMemberPermissions == other.addMemberPermissions && this.addMemberRoles == other.addMemberRoles && this.description == other.description && this.name == other.name && this.removeMemberPermissions == other.removeMemberPermissions && this.removeMemberRoles == other.removeMemberRoles && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(roleId, addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -558,7 +553,7 @@ constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -651,7 +646,7 @@ constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -755,17 +750,14 @@ constructor( return true } - return /* spotless:off */ other is AddMemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(permission, restrictObjectType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" @@ -865,7 +857,7 @@ constructor( return true } - return /* spotless:off */ other is Permission && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -958,7 +950,7 @@ constructor( return true } - return /* spotless:off */ other is RestrictObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1062,17 +1054,14 @@ constructor( return true } - return /* spotless:off */ other is RemoveMemberPermission && this.permission == other.permission && this.restrictObjectType == other.restrictObjectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(permission, restrictObjectType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(permission, restrictObjectType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index 7d0c76cf..e7f5ddee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -171,17 +171,14 @@ private constructor( return true } - return /* spotless:off */ other is ScoreSummary && this.name == other.name && this.score == other.score && this.diff == other.diff && this.improvements == other.improvements && this.regressions == other.regressions && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScoreSummary && name == other.name && score == other.score && diff == other.diff && improvements == other.improvements && regressions == other.regressions && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, score, diff, improvements, regressions, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, score, diff, improvements, regressions, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ScoreSummary{name=$name, score=$score, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" 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 db94838a..4f500d7d 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 @@ -125,7 +125,7 @@ private constructor( return true } - return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -198,17 +198,14 @@ private constructor( return true } - return /* spotless:off */ other is SpanAttributes && this.name == other.name && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanAttributes && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, type, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, type, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index 53141d9b..c99c13e3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -260,17 +260,14 @@ private constructor( return true } - return /* spotless:off */ other is SpanIFrame && this.id == other.id && this.projectId == other.projectId && this.userId == other.userId && this.created == other.created && this.deletedAt == other.deletedAt && this.name == other.name && this.description == other.description && this.url == other.url && this.postMessage == other.postMessage && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanIFrame && id == other.id && projectId == other.projectId && userId == other.userId && created == other.created && deletedAt == other.deletedAt && name == other.name && description == other.description && url == other.url && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, projectId, userId, created, deletedAt, name, description, url, postMessage, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, projectId, userId, created, deletedAt, name, description, url, postMessage, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SpanIFrame{id=$id, projectId=$projectId, userId=$userId, created=$created, deletedAt=$deletedAt, name=$name, description=$description, url=$url, postMessage=$postMessage, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 617ccfe1..68168fa1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -165,17 +165,14 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeCreateBody && this.name == other.name && this.projectId == other.projectId && this.url == other.url && this.description == other.description && this.postMessage == other.postMessage && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeCreateBody && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, url, description, postMessage, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SpanIframeCreateBody{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" @@ -192,12 +189,10 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeCreateParams && this.name == other.name && this.projectId == other.projectId && this.url == other.url && this.description == other.description && this.postMessage == other.postMessage && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeCreateParams && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "SpanIframeCreateParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt index de9931dc..c52bf2b7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -48,12 +48,10 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeDeleteParams && this.spanIframeId == other.spanIframeId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index 2de2b0f6..7d5d0009 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is SpanIframeListPage && this.spanIframesService == other.spanIframesService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is SpanIframeListPage && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ override fun toString() = "SpanIframeListPage{spanIframesService=$spanIframesService, params=$params, response=$response}" @@ -124,15 +122,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "SpanIframeListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt index c79d5014..d4edf97f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is SpanIframeListPageAsync && this.spanIframesService == other.spanIframesService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is SpanIframeListPageAsync && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ override fun toString() = "SpanIframeListPageAsync{spanIframesService=$spanIframesService, params=$params, response=$response}" @@ -127,15 +125,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "SpanIframeListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 824669af..7b8bed0d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -69,12 +69,10 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeListParams && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.spanIframeName == other.spanIframeName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, spanIframeName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, spanIframeName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -313,21 +311,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index 2a43dde3..3940b04c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -165,17 +165,14 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeReplaceBody && this.name == other.name && this.projectId == other.projectId && this.url == other.url && this.description == other.description && this.postMessage == other.postMessage && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeReplaceBody && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, projectId, url, description, postMessage, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SpanIframeReplaceBody{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" @@ -192,12 +189,10 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeReplaceParams && this.name == other.name && this.projectId == other.projectId && this.url == other.url && this.description == other.description && this.postMessage == other.postMessage && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeReplaceParams && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "SpanIframeReplaceParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt index 35e8ee94..8dc33539 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeRetrieveParams && this.spanIframeId == other.spanIframeId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 0e3af93e..03cef145 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -145,17 +145,14 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeUpdateBody && this.name == other.name && this.postMessage == other.postMessage && this.url == other.url && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeUpdateBody && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, postMessage, url, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, postMessage, url, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SpanIframeUpdateBody{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" @@ -172,12 +169,10 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeUpdateParams && this.spanIframeId == other.spanIframeId && this.name == other.name && this.postMessage == other.postMessage && this.url == other.url && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && name == other.name && postMessage == other.postMessage && url == other.url && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(spanIframeId, name, postMessage, url, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, name, postMessage, url, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "SpanIframeUpdateParams{spanIframeId=$spanIframeId, name=$name, postMessage=$postMessage, url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 178d3cc7..51b2eef2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -174,17 +174,14 @@ private constructor( return true } - return /* spotless:off */ other is SummarizeDatasetResponse && this.projectName == other.projectName && this.datasetName == other.datasetName && this.projectUrl == other.projectUrl && this.datasetUrl == other.datasetUrl && this.dataSummary == other.dataSummary && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeDatasetResponse && projectName == other.projectName && datasetName == other.datasetName && projectUrl == other.projectUrl && datasetUrl == other.datasetUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(projectName, datasetName, projectUrl, datasetUrl, dataSummary, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(projectName, datasetName, projectUrl, datasetUrl, dataSummary, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SummarizeDatasetResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 1a2564f4..721160c7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -272,17 +272,14 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Metrics{additionalProperties=$additionalProperties}" } @@ -345,17 +342,14 @@ private constructor( return true } - return /* spotless:off */ other is Scores && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "Scores{additionalProperties=$additionalProperties}" } @@ -365,17 +359,14 @@ private constructor( return true } - return /* spotless:off */ other is SummarizeExperimentResponse && this.projectName == other.projectName && this.experimentName == other.experimentName && this.projectUrl == other.projectUrl && this.experimentUrl == other.experimentUrl && this.comparisonExperimentName == other.comparisonExperimentName && this.scores == other.scores && this.metrics == other.metrics && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeExperimentResponse && projectName == other.projectName && experimentName == other.experimentName && projectUrl == other.projectUrl && experimentUrl == other.experimentUrl && comparisonExperimentName == other.comparisonExperimentName && scores == other.scores && metrics == other.metrics && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(projectName, experimentName, projectUrl, experimentUrl, comparisonExperimentName, scores, metrics, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(projectName, experimentName, projectUrl, experimentUrl, comparisonExperimentName, scores, metrics, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "SummarizeExperimentResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index ceb54600..823beb22 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -27,12 +27,10 @@ constructor( return true } - return /* spotless:off */ other is TopLevelHelloWorldParams && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index b3563520..b17e4ade 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -188,17 +188,14 @@ private constructor( return true } - return /* spotless:off */ other is User && this.id == other.id && this.givenName == other.givenName && this.familyName == other.familyName && this.email == other.email && this.avatarUrl == other.avatarUrl && this.created == other.created && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && id == other.id && givenName == other.givenName && familyName == other.familyName && email == other.email && avatarUrl == other.avatarUrl && created == other.created && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, givenName, familyName, email, avatarUrl, created, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, givenName, familyName, email, avatarUrl, created, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "User{id=$id, givenName=$givenName, familyName=$familyName, email=$email, avatarUrl=$avatarUrl, created=$created, additionalProperties=$additionalProperties}" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 8a7c8b9a..bb5feed1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is UserListPage && this.usersService == other.usersService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is UserListPage && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ override fun toString() = "UserListPage{usersService=$usersService, params=$params, response=$response}" @@ -114,15 +112,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "UserListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 3698364c..7d2c1d8d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is UserListPageAsync && this.usersService == other.usersService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is UserListPageAsync && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ override fun toString() = "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" @@ -117,15 +115,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "UserListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index f6db409d..df621a18 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -77,12 +77,10 @@ constructor( return true } - return /* spotless:off */ other is UserListParams && this.email == other.email && this.endingBefore == other.endingBefore && this.familyName == other.familyName && this.givenName == other.givenName && this.ids == other.ids && this.limit == other.limit && this.orgName == other.orgName && this.startingAfter == other.startingAfter && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -382,21 +380,18 @@ constructor( return true } - return /* spotless:off */ other is Email && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Email && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Email{string=$string}" strings != null -> "Email{strings=$strings}" _json != null -> "Email{_unknown=$_json}" else -> throw IllegalStateException("Invalid Email") } - } companion object { @@ -496,21 +491,18 @@ constructor( return true } - return /* spotless:off */ other is FamilyName && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is FamilyName && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "FamilyName{string=$string}" strings != null -> "FamilyName{strings=$strings}" _json != null -> "FamilyName{_unknown=$_json}" else -> throw IllegalStateException("Invalid FamilyName") } - } companion object { @@ -610,21 +602,18 @@ constructor( return true } - return /* spotless:off */ other is GivenName && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is GivenName && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "GivenName{string=$string}" strings != null -> "GivenName{strings=$strings}" _json != null -> "GivenName{_unknown=$_json}" else -> throw IllegalStateException("Invalid GivenName") } - } companion object { @@ -724,21 +713,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 4b7e3af7..25d447af 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -37,12 +37,10 @@ constructor( return true } - return /* spotless:off */ other is UserRetrieveParams && this.userId == other.userId && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" 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 7a28ec96..1800405d 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 @@ -276,7 +276,7 @@ private constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -387,7 +387,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -472,17 +472,14 @@ private constructor( return true } - return /* spotless:off */ other is View && this.id == other.id && this.objectType == other.objectType && this.objectId == other.objectId && this.viewType == other.viewType && this.name == other.name && this.created == other.created && this.viewData == other.viewData && this.options == other.options && this.userId == other.userId && this.deletedAt == other.deletedAt && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is View && id == other.id && objectType == other.objectType && objectId == other.objectId && viewType == other.viewType && name == other.name && created == other.created && viewData == other.viewData && options == other.options && userId == other.userId && deletedAt == other.deletedAt && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, objectType, objectId, viewType, name, created, viewData, options, userId, deletedAt, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(id, objectType, objectId, viewType, name, created, viewData, options, userId, deletedAt, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "View{id=$id, objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, created=$created, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" 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 1db69dfc..fdec4491 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 @@ -209,17 +209,14 @@ constructor( return true } - return /* spotless:off */ other is ViewCreateBody && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewCreateBody && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" @@ -236,12 +233,10 @@ constructor( return true } - return /* spotless:off */ other is ViewCreateParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewCreateParams && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -456,7 +451,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -567,7 +562,7 @@ constructor( return true } - return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 80c4da3f..54e1a726 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -87,17 +87,14 @@ private constructor( return true } - return /* spotless:off */ other is ViewData && this.search == other.search && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewData && search == other.search && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(search, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(search, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ViewData{search=$search, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 881c8201..1ec4696a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -135,17 +135,14 @@ private constructor( return true } - return /* spotless:off */ other is ViewDataSearch && this.filter == other.filter && this.tag == other.tag && this.match == other.match && this.sort == other.sort && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewDataSearch && filter == other.filter && tag == other.tag && match == other.match && sort == other.sort && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(filter, tag, match, sort, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(filter, tag, match, sort, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ViewDataSearch{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" 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 2e29f940..f2218f5f 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 @@ -129,17 +129,14 @@ constructor( return true } - return /* spotless:off */ other is ViewDeleteBody && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewDeleteBody && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectId, objectType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" @@ -156,12 +153,10 @@ constructor( return true } - return /* spotless:off */ other is ViewDeleteParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -346,7 +341,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index 33f66db2..0c004876 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -34,12 +34,10 @@ private constructor( return true } - return /* spotless:off */ other is ViewListPage && this.viewsService == other.viewsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ViewListPage && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ override fun toString() = "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" @@ -114,15 +112,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ViewListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index eb9f0a24..d524096c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -35,12 +35,10 @@ private constructor( return true } - return /* spotless:off */ other is ViewListPageAsync && this.viewsService == other.viewsService && this.params == other.params && this.response == other.response /* spotless:on */ + return /* spotless:off */ other is ViewListPageAsync && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ override fun toString() = "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" @@ -117,15 +115,13 @@ private constructor( return true } - return /* spotless:off */ other is Response && this.objects == other.objects && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ override fun toString() = - "ViewListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { 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 fbfbab78..888e4947 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 @@ -80,12 +80,10 @@ constructor( return true } - return /* spotless:off */ other is ViewListParams && this.objectId == other.objectId && this.objectType == other.objectType && this.endingBefore == other.endingBefore && this.ids == other.ids && this.limit == other.limit && this.startingAfter == other.startingAfter && this.viewName == other.viewName && this.viewType == other.viewType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -302,7 +300,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -447,21 +445,18 @@ constructor( return true } - return /* spotless:off */ other is Ids && this.string == other.string && this.strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ - override fun toString(): String { - return when { + override fun toString(): String = + when { string != null -> "Ids{string=$string}" strings != null -> "Ids{strings=$strings}" _json != null -> "Ids{_unknown=$_json}" else -> throw IllegalStateException("Invalid Ids") } - } companion object { @@ -527,7 +522,7 @@ constructor( return true } - return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index eeb08af4..29a55165 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -183,17 +183,14 @@ private constructor( return true } - return /* spotless:off */ other is ColumnSizing && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ColumnSizing && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" } @@ -255,17 +252,14 @@ private constructor( return true } - return /* spotless:off */ other is ColumnVisibility && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ColumnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ColumnVisibility{additionalProperties=$additionalProperties}" } @@ -275,17 +269,14 @@ private constructor( return true } - return /* spotless:off */ other is ViewOptions && this.columnVisibility == other.columnVisibility && this.columnOrder == other.columnOrder && this.columnSizing == other.columnSizing && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewOptions && columnVisibility == other.columnVisibility && columnOrder == other.columnOrder && columnSizing == other.columnSizing && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(columnVisibility, columnOrder, columnSizing, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(columnVisibility, columnOrder, columnSizing, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ViewOptions{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" 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 3ec104a8..24c3fc69 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 @@ -209,17 +209,14 @@ constructor( return true } - return /* spotless:off */ other is ViewReplaceBody && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewReplaceBody && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" @@ -236,12 +233,10 @@ constructor( return true } - return /* spotless:off */ other is ViewReplaceParams && this.name == other.name && this.objectId == other.objectId && this.objectType == other.objectType && this.viewType == other.viewType && this.deletedAt == other.deletedAt && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewReplaceParams && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -456,7 +451,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -567,7 +562,7 @@ constructor( return true } - return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() 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 e88ec622..879f7e58 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 @@ -55,12 +55,10 @@ constructor( return true } - return /* spotless:off */ other is ViewRetrieveParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" @@ -220,7 +218,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() 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 b95d336e..5338ce8d 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 @@ -203,17 +203,14 @@ constructor( return true } - return /* spotless:off */ other is ViewUpdateBody && this.objectId == other.objectId && this.objectType == other.objectType && this.name == other.name && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.viewType == other.viewType && this.additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewUpdateBody && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ } - private var hashCode: Int = 0 + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, name, options, userId, viewData, viewType, additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = /* spotless:off */ Objects.hash(objectId, objectType, name, options, userId, viewData, viewType, additionalProperties) /* spotless:on */ - } - return hashCode - } + override fun hashCode(): Int = hashCode override fun toString() = "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" @@ -230,12 +227,10 @@ constructor( return true } - return /* spotless:off */ other is ViewUpdateParams && this.viewId == other.viewId && this.objectId == other.objectId && this.objectType == other.objectType && this.name == other.name && this.options == other.options && this.userId == other.userId && this.viewData == other.viewData && this.viewType == other.viewType && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } - override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(viewId, objectId, objectType, name, options, userId, viewData, viewType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - } + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, name, options, userId, viewData, viewType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" @@ -450,7 +445,7 @@ constructor( return true } - return /* spotless:off */ other is ObjectType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -561,7 +556,7 @@ constructor( return true } - return /* spotless:off */ other is ViewType && this.value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() From fd04071cbeb2abb04310bd4389279dbaadb9a302 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:55:06 +0000 Subject: [PATCH 35/87] style(internal): move identity methods to bottom of error class (#104) --- .../api/errors/BraintrustError.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index 3f29cfb6..28c52d93 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -19,18 +19,6 @@ private constructor( val additionalProperties: Map, ) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - - override fun toString() = "BraintrustError{additionalProperties=$additionalProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -69,4 +57,16 @@ private constructor( fun build(): BraintrustError = BraintrustError(additionalProperties.toImmutable()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ + + override fun toString() = "BraintrustError{additionalProperties=$additionalProperties}" } From ad0fed3824772a29ce635f672c2feb6f7c2beb17 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 09:45:12 +0000 Subject: [PATCH 36/87] chore(internal): codegen related update (#105) --- .../api/models/AclBatchUpdateParams.kt | 52 ++++++------- .../api/models/AclCreateParams.kt | 58 +++++++------- .../api/models/AclDeleteParams.kt | 46 +++++------ .../api/models/AclFindAndDeleteParams.kt | 59 +++++++------- .../api/models/AclListParams.kt | 50 ++++++------ .../api/models/AclRetrieveParams.kt | 40 +++++----- .../api/models/AiSecretCreateParams.kt | 54 ++++++------- .../api/models/AiSecretDeleteParams.kt | 46 +++++------ .../api/models/AiSecretFindAndDeleteParams.kt | 49 ++++++------ .../api/models/AiSecretListParams.kt | 52 ++++++------- .../api/models/AiSecretReplaceParams.kt | 54 ++++++------- .../api/models/AiSecretRetrieveParams.kt | 40 +++++----- .../api/models/AiSecretUpdateParams.kt | 54 ++++++------- .../api/models/ApiKeyCreateParams.kt | 48 ++++++------ .../api/models/ApiKeyDeleteParams.kt | 46 +++++------ .../api/models/ApiKeyListParams.kt | 50 ++++++------ .../api/models/ApiKeyRetrieveParams.kt | 40 +++++----- .../api/models/DatasetCreateParams.kt | 52 ++++++------- .../api/models/DatasetDeleteParams.kt | 46 +++++------ .../api/models/DatasetFeedbackParams.kt | 50 ++++++------ .../api/models/DatasetFetchParams.kt | 48 ++++++------ .../api/models/DatasetFetchPostParams.kt | 57 +++++++------- .../api/models/DatasetInsertParams.kt | 50 ++++++------ .../api/models/DatasetListParams.kt | 54 ++++++------- .../api/models/DatasetRetrieveParams.kt | 40 +++++----- .../api/models/DatasetSummarizeParams.kt | 42 +++++----- .../api/models/DatasetUpdateParams.kt | 52 ++++++------- .../api/models/EnvVarCreateParams.kt | 52 ++++++------- .../api/models/EnvVarDeleteParams.kt | 46 +++++------ .../api/models/EnvVarListParams.kt | 48 ++++++------ .../api/models/EnvVarReplaceParams.kt | 52 ++++++------- .../api/models/EnvVarRetrieveParams.kt | 40 +++++----- .../api/models/EnvVarUpdateParams.kt | 50 ++++++------ .../api/models/EvalCreateParams.kt | 76 +++++++++---------- .../api/models/ExperimentCreateParams.kt | 65 ++++++++-------- .../api/models/ExperimentDeleteParams.kt | 47 ++++++------ .../api/models/ExperimentFeedbackParams.kt | 51 +++++++------ .../api/models/ExperimentFetchParams.kt | 48 ++++++------ .../api/models/ExperimentFetchPostParams.kt | 57 +++++++------- .../api/models/ExperimentInsertParams.kt | 51 +++++++------ .../api/models/ExperimentListParams.kt | 54 ++++++------- .../api/models/ExperimentRetrieveParams.kt | 40 +++++----- .../api/models/ExperimentSummarizeParams.kt | 44 +++++------ .../api/models/ExperimentUpdateParams.kt | 63 +++++++-------- .../api/models/FunctionCreateParams.kt | 66 ++++++++-------- .../api/models/FunctionDeleteParams.kt | 46 +++++------ .../api/models/FunctionInvokeParams.kt | 60 +++++++-------- .../api/models/FunctionListParams.kt | 58 +++++++------- .../api/models/FunctionReplaceParams.kt | 66 ++++++++-------- .../api/models/FunctionRetrieveParams.kt | 40 +++++----- .../api/models/FunctionUpdateParams.kt | 58 +++++++------- .../api/models/GroupCreateParams.kt | 58 +++++++------- .../api/models/GroupDeleteParams.kt | 46 +++++------ .../api/models/GroupListParams.kt | 50 ++++++------ .../api/models/GroupReplaceParams.kt | 58 +++++++------- .../api/models/GroupRetrieveParams.kt | 40 +++++----- .../api/models/GroupUpdateParams.kt | 68 +++++++++-------- .../api/models/OrganizationDeleteParams.kt | 47 ++++++------ .../api/models/OrganizationListParams.kt | 48 ++++++------ .../models/OrganizationMemberUpdateParams.kt | 53 ++++++------- .../api/models/OrganizationRetrieveParams.kt | 40 +++++----- .../api/models/OrganizationUpdateParams.kt | 57 +++++++------- .../api/models/ProjectCreateParams.kt | 48 ++++++------ .../api/models/ProjectDeleteParams.kt | 46 +++++------ .../api/models/ProjectListParams.kt | 50 ++++++------ .../api/models/ProjectLogFeedbackParams.kt | 51 +++++++------ .../api/models/ProjectLogFetchParams.kt | 48 ++++++------ .../api/models/ProjectLogFetchPostParams.kt | 57 +++++++------- .../api/models/ProjectLogInsertParams.kt | 51 +++++++------ .../api/models/ProjectRetrieveParams.kt | 40 +++++----- .../api/models/ProjectScoreCreateParams.kt | 57 +++++++------- .../api/models/ProjectScoreDeleteParams.kt | 47 ++++++------ .../api/models/ProjectScoreListParams.kt | 56 +++++++------- .../api/models/ProjectScoreReplaceParams.kt | 57 +++++++------- .../api/models/ProjectScoreRetrieveParams.kt | 40 +++++----- .../api/models/ProjectScoreUpdateParams.kt | 57 +++++++------- .../api/models/ProjectTagCreateParams.kt | 53 ++++++------- .../api/models/ProjectTagDeleteParams.kt | 47 ++++++------ .../api/models/ProjectTagListParams.kt | 54 ++++++------- .../api/models/ProjectTagReplaceParams.kt | 53 ++++++------- .../api/models/ProjectTagRetrieveParams.kt | 40 +++++----- .../api/models/ProjectTagUpdateParams.kt | 53 ++++++------- .../api/models/ProjectUpdateParams.kt | 50 ++++++------ .../api/models/PromptCreateParams.kt | 60 +++++++-------- .../api/models/PromptDeleteParams.kt | 46 +++++------ .../api/models/PromptListParams.kt | 58 +++++++------- .../api/models/PromptReplaceParams.kt | 60 +++++++-------- .../api/models/PromptRetrieveParams.kt | 40 +++++----- .../api/models/PromptUpdateParams.kt | 58 +++++++------- .../api/models/RoleCreateParams.kt | 59 +++++++------- .../api/models/RoleDeleteParams.kt | 46 +++++------ .../api/models/RoleListParams.kt | 50 ++++++------ .../api/models/RoleReplaceParams.kt | 59 +++++++------- .../api/models/RoleRetrieveParams.kt | 40 +++++----- .../api/models/RoleUpdateParams.kt | 70 ++++++++--------- .../api/models/SpanIframeCreateParams.kt | 55 +++++++------- .../api/models/SpanIframeDeleteParams.kt | 47 ++++++------ .../api/models/SpanIframeListParams.kt | 50 ++++++------ .../api/models/SpanIframeReplaceParams.kt | 55 +++++++------- .../api/models/SpanIframeRetrieveParams.kt | 40 +++++----- .../api/models/SpanIframeUpdateParams.kt | 53 ++++++------- .../api/models/TopLevelHelloWorldParams.kt | 34 ++++----- .../api/models/UserListParams.kt | 54 ++++++------- .../api/models/UserRetrieveParams.kt | 40 +++++----- .../api/models/ViewCreateParams.kt | 60 +++++++-------- .../api/models/ViewDeleteParams.kt | 50 ++++++------ .../api/models/ViewListParams.kt | 54 ++++++------- .../api/models/ViewReplaceParams.kt | 60 +++++++-------- .../api/models/ViewRetrieveParams.kt | 44 +++++------ .../api/models/ViewUpdateParams.kt | 60 +++++++-------- 110 files changed, 2831 insertions(+), 2798 deletions(-) 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 52bf1c5d..6ce91dbc 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 @@ -33,6 +33,12 @@ constructor( fun removeAcls(): Optional> = Optional.ofNullable(removeAcls) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): AclBatchUpdateBody { return AclBatchUpdateBody( @@ -171,25 +177,6 @@ constructor( "AclBatchUpdateBody{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AclBatchUpdateParams && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AclBatchUpdateParams{addAcls=$addAcls, removeAcls=$removeAcls, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -208,11 +195,11 @@ constructor( @JvmSynthetic internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { - this.addAcls(aclBatchUpdateParams.addAcls ?: listOf()) - this.removeAcls(aclBatchUpdateParams.removeAcls ?: listOf()) - additionalHeaders(aclBatchUpdateParams.additionalHeaders) - additionalQueryParams(aclBatchUpdateParams.additionalQueryParams) - additionalBodyProperties(aclBatchUpdateParams.additionalBodyProperties) + addAcls = aclBatchUpdateParams.addAcls?.toMutableList() ?: mutableListOf() + removeAcls = aclBatchUpdateParams.removeAcls?.toMutableList() ?: mutableListOf() + additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aclBatchUpdateParams.additionalBodyProperties.toMutableMap() } /** @@ -391,8 +378,8 @@ constructor( fun build(): AclBatchUpdateParams = AclBatchUpdateParams( - if (addAcls.size == 0) null else addAcls.toImmutable(), - if (removeAcls.size == 0) null else removeAcls.toImmutable(), + addAcls.toImmutable().ifEmpty { null }, + removeAcls.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -1386,4 +1373,17 @@ constructor( override fun toString() = "RemoveAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclBatchUpdateParams && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AclBatchUpdateParams{addAcls=$addAcls, removeAcls=$removeAcls, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 e11ac71b..35089027 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 @@ -48,6 +48,12 @@ constructor( fun userId(): Optional = Optional.ofNullable(userId) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): AclCreateBody { return AclCreateBody( @@ -244,25 +250,6 @@ constructor( "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AclCreateParams && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -286,16 +273,16 @@ constructor( @JvmSynthetic internal fun from(aclCreateParams: AclCreateParams) = apply { - this.objectId = aclCreateParams.objectId - this.objectType = aclCreateParams.objectType - this.groupId = aclCreateParams.groupId - this.permission = aclCreateParams.permission - this.restrictObjectType = aclCreateParams.restrictObjectType - this.roleId = aclCreateParams.roleId - this.userId = aclCreateParams.userId - additionalHeaders(aclCreateParams.additionalHeaders) - additionalQueryParams(aclCreateParams.additionalQueryParams) - additionalBodyProperties(aclCreateParams.additionalBodyProperties) + objectId = aclCreateParams.objectId + objectType = aclCreateParams.objectType + groupId = aclCreateParams.groupId + permission = aclCreateParams.permission + restrictObjectType = aclCreateParams.restrictObjectType + roleId = aclCreateParams.roleId + userId = aclCreateParams.userId + additionalHeaders = aclCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aclCreateParams.additionalBodyProperties.toMutableMap() } /** The id of the object the ACL applies to */ @@ -781,4 +768,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclCreateParams && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index b541d640..a0b5b26d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun aclId(): String = aclId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(aclDeleteParams: AclDeleteParams) = apply { - this.aclId = aclDeleteParams.aclId - additionalHeaders(aclDeleteParams.additionalHeaders) - additionalQueryParams(aclDeleteParams.additionalQueryParams) - additionalBodyProperties(aclDeleteParams.additionalBodyProperties) + aclId = aclDeleteParams.aclId + additionalHeaders = aclDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aclDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aclDeleteParams.additionalBodyProperties.toMutableMap() } /** Acl id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 479c0be0..c9b0c0b0 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 @@ -48,6 +48,12 @@ constructor( fun userId(): Optional = Optional.ofNullable(userId) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): AclFindAndDeleteBody { return AclFindAndDeleteBody( @@ -244,25 +250,6 @@ constructor( "AclFindAndDeleteBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AclFindAndDeleteParams && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AclFindAndDeleteParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -286,16 +273,17 @@ constructor( @JvmSynthetic internal fun from(aclFindAndDeleteParams: AclFindAndDeleteParams) = apply { - this.objectId = aclFindAndDeleteParams.objectId - this.objectType = aclFindAndDeleteParams.objectType - this.groupId = aclFindAndDeleteParams.groupId - this.permission = aclFindAndDeleteParams.permission - this.restrictObjectType = aclFindAndDeleteParams.restrictObjectType - this.roleId = aclFindAndDeleteParams.roleId - this.userId = aclFindAndDeleteParams.userId - additionalHeaders(aclFindAndDeleteParams.additionalHeaders) - additionalQueryParams(aclFindAndDeleteParams.additionalQueryParams) - additionalBodyProperties(aclFindAndDeleteParams.additionalBodyProperties) + objectId = aclFindAndDeleteParams.objectId + objectType = aclFindAndDeleteParams.objectType + groupId = aclFindAndDeleteParams.groupId + permission = aclFindAndDeleteParams.permission + restrictObjectType = aclFindAndDeleteParams.restrictObjectType + roleId = aclFindAndDeleteParams.roleId + userId = aclFindAndDeleteParams.userId + additionalHeaders = aclFindAndDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aclFindAndDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + aclFindAndDeleteParams.additionalBodyProperties.toMutableMap() } /** The id of the object the ACL applies to */ @@ -781,4 +769,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclFindAndDeleteParams && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AclFindAndDeleteParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 95d5f345..1411d13c 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 @@ -48,6 +48,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -63,23 +67,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -101,14 +88,14 @@ constructor( @JvmSynthetic internal fun from(aclListParams: AclListParams) = apply { - this.objectId = aclListParams.objectId - this.objectType = aclListParams.objectType - this.endingBefore = aclListParams.endingBefore - this.ids = aclListParams.ids - this.limit = aclListParams.limit - this.startingAfter = aclListParams.startingAfter - additionalHeaders(aclListParams.additionalHeaders) - additionalQueryParams(aclListParams.additionalQueryParams) + objectId = aclListParams.objectId + objectType = aclListParams.objectType + endingBefore = aclListParams.endingBefore + ids = aclListParams.ids + limit = aclListParams.limit + startingAfter = aclListParams.startingAfter + additionalHeaders = aclListParams.additionalHeaders.toBuilder() + additionalQueryParams = aclListParams.additionalQueryParams.toBuilder() } /** The id of the object the ACL applies to */ @@ -488,4 +475,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 4ed1a558..5e32b3d8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun aclId(): String = aclId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(aclRetrieveParams: AclRetrieveParams) = apply { - this.aclId = aclRetrieveParams.aclId - additionalHeaders(aclRetrieveParams.additionalHeaders) - additionalQueryParams(aclRetrieveParams.additionalQueryParams) + aclId = aclRetrieveParams.aclId + additionalHeaders = aclRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = aclRetrieveParams.additionalQueryParams.toBuilder() } /** Acl id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 1120354a..a7c4fc1e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -38,6 +38,12 @@ constructor( fun type(): Optional = Optional.ofNullable(type) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): AiSecretCreateBody { return AiSecretCreateBody( @@ -181,25 +187,6 @@ constructor( "AiSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AiSecretCreateParams && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AiSecretCreateParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -221,14 +208,14 @@ constructor( @JvmSynthetic internal fun from(aiSecretCreateParams: AiSecretCreateParams) = apply { - this.name = aiSecretCreateParams.name - this.metadata = aiSecretCreateParams.metadata - this.orgName = aiSecretCreateParams.orgName - this.secret = aiSecretCreateParams.secret - this.type = aiSecretCreateParams.type - additionalHeaders(aiSecretCreateParams.additionalHeaders) - additionalQueryParams(aiSecretCreateParams.additionalQueryParams) - additionalBodyProperties(aiSecretCreateParams.additionalBodyProperties) + name = aiSecretCreateParams.name + metadata = aiSecretCreateParams.metadata + orgName = aiSecretCreateParams.orgName + secret = aiSecretCreateParams.secret + type = aiSecretCreateParams.type + additionalHeaders = aiSecretCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aiSecretCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the AI secret */ @@ -444,4 +431,17 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretCreateParams && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AiSecretCreateParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index 54d772a9..cad70dc8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun aiSecretId(): String = aiSecretId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(aiSecretDeleteParams: AiSecretDeleteParams) = apply { - this.aiSecretId = aiSecretDeleteParams.aiSecretId - additionalHeaders(aiSecretDeleteParams.additionalHeaders) - additionalQueryParams(aiSecretDeleteParams.additionalQueryParams) - additionalBodyProperties(aiSecretDeleteParams.additionalBodyProperties) + aiSecretId = aiSecretDeleteParams.aiSecretId + additionalHeaders = aiSecretDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aiSecretDeleteParams.additionalBodyProperties.toMutableMap() } /** AiSecret id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 5eaecc0f..9750ec57 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -29,6 +29,12 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): AiSecretFindAndDeleteBody { return AiSecretFindAndDeleteBody( @@ -136,25 +142,6 @@ constructor( "AiSecretFindAndDeleteBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AiSecretFindAndDeleteParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AiSecretFindAndDeleteParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -173,11 +160,12 @@ constructor( @JvmSynthetic internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = apply { - this.name = aiSecretFindAndDeleteParams.name - this.orgName = aiSecretFindAndDeleteParams.orgName - additionalHeaders(aiSecretFindAndDeleteParams.additionalHeaders) - additionalQueryParams(aiSecretFindAndDeleteParams.additionalQueryParams) - additionalBodyProperties(aiSecretFindAndDeleteParams.additionalBodyProperties) + name = aiSecretFindAndDeleteParams.name + orgName = aiSecretFindAndDeleteParams.orgName + additionalHeaders = aiSecretFindAndDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretFindAndDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + aiSecretFindAndDeleteParams.additionalBodyProperties.toMutableMap() } /** Name of the AI secret */ @@ -319,4 +307,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretFindAndDeleteParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AiSecretFindAndDeleteParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 1ce8f821..24c3dd98 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -48,6 +48,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -64,23 +68,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -103,15 +90,15 @@ constructor( @JvmSynthetic internal fun from(aiSecretListParams: AiSecretListParams) = apply { - this.aiSecretName = aiSecretListParams.aiSecretName - this.aiSecretType = aiSecretListParams.aiSecretType - this.endingBefore = aiSecretListParams.endingBefore - this.ids = aiSecretListParams.ids - this.limit = aiSecretListParams.limit - this.orgName = aiSecretListParams.orgName - this.startingAfter = aiSecretListParams.startingAfter - additionalHeaders(aiSecretListParams.additionalHeaders) - additionalQueryParams(aiSecretListParams.additionalQueryParams) + aiSecretName = aiSecretListParams.aiSecretName + aiSecretType = aiSecretListParams.aiSecretType + endingBefore = aiSecretListParams.endingBefore + ids = aiSecretListParams.ids + limit = aiSecretListParams.limit + orgName = aiSecretListParams.orgName + startingAfter = aiSecretListParams.startingAfter + additionalHeaders = aiSecretListParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretListParams.additionalQueryParams.toBuilder() } /** Name of the ai_secret to search for */ @@ -502,4 +489,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index d80328d8..592dc10d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -38,6 +38,12 @@ constructor( fun type(): Optional = Optional.ofNullable(type) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): AiSecretReplaceBody { return AiSecretReplaceBody( @@ -181,25 +187,6 @@ constructor( "AiSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AiSecretReplaceParams && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AiSecretReplaceParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -221,14 +208,14 @@ constructor( @JvmSynthetic internal fun from(aiSecretReplaceParams: AiSecretReplaceParams) = apply { - this.name = aiSecretReplaceParams.name - this.metadata = aiSecretReplaceParams.metadata - this.orgName = aiSecretReplaceParams.orgName - this.secret = aiSecretReplaceParams.secret - this.type = aiSecretReplaceParams.type - additionalHeaders(aiSecretReplaceParams.additionalHeaders) - additionalQueryParams(aiSecretReplaceParams.additionalQueryParams) - additionalBodyProperties(aiSecretReplaceParams.additionalBodyProperties) + name = aiSecretReplaceParams.name + metadata = aiSecretReplaceParams.metadata + orgName = aiSecretReplaceParams.orgName + secret = aiSecretReplaceParams.secret + type = aiSecretReplaceParams.type + additionalHeaders = aiSecretReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aiSecretReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the AI secret */ @@ -444,4 +431,17 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretReplaceParams && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AiSecretReplaceParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index 924b14cc..b9fee653 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun aiSecretId(): String = aiSecretId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = apply { - this.aiSecretId = aiSecretRetrieveParams.aiSecretId - additionalHeaders(aiSecretRetrieveParams.additionalHeaders) - additionalQueryParams(aiSecretRetrieveParams.additionalQueryParams) + aiSecretId = aiSecretRetrieveParams.aiSecretId + additionalHeaders = aiSecretRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretRetrieveParams.additionalQueryParams.toBuilder() } /** AiSecret id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index e932ad65..41fc51e5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -38,6 +38,12 @@ constructor( fun type(): Optional = Optional.ofNullable(type) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): AiSecretUpdateBody { return AiSecretUpdateBody( @@ -160,25 +166,6 @@ constructor( "AiSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, metadata, name, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "AiSecretUpdateParams{aiSecretId=$aiSecretId, metadata=$metadata, name=$name, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -200,14 +187,14 @@ constructor( @JvmSynthetic internal fun from(aiSecretUpdateParams: AiSecretUpdateParams) = apply { - this.aiSecretId = aiSecretUpdateParams.aiSecretId - this.metadata = aiSecretUpdateParams.metadata - this.name = aiSecretUpdateParams.name - this.secret = aiSecretUpdateParams.secret - this.type = aiSecretUpdateParams.type - additionalHeaders(aiSecretUpdateParams.additionalHeaders) - additionalQueryParams(aiSecretUpdateParams.additionalQueryParams) - additionalBodyProperties(aiSecretUpdateParams.additionalBodyProperties) + aiSecretId = aiSecretUpdateParams.aiSecretId + metadata = aiSecretUpdateParams.metadata + name = aiSecretUpdateParams.name + secret = aiSecretUpdateParams.secret + type = aiSecretUpdateParams.type + additionalHeaders = aiSecretUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aiSecretUpdateParams.additionalBodyProperties.toMutableMap() } /** AiSecret id */ @@ -415,4 +402,17 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, metadata, name, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AiSecretUpdateParams{aiSecretId=$aiSecretId, metadata=$metadata, name=$name, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 136630d2..e1a95de1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -29,6 +29,12 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ApiKeyCreateBody { return ApiKeyCreateBody( @@ -136,25 +142,6 @@ constructor( "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ApiKeyCreateParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -173,11 +160,11 @@ constructor( @JvmSynthetic internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { - this.name = apiKeyCreateParams.name - this.orgName = apiKeyCreateParams.orgName - additionalHeaders(apiKeyCreateParams.additionalHeaders) - additionalQueryParams(apiKeyCreateParams.additionalQueryParams) - additionalBodyProperties(apiKeyCreateParams.additionalBodyProperties) + name = apiKeyCreateParams.name + orgName = apiKeyCreateParams.orgName + additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = apiKeyCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the api key. Does not have to be unique */ @@ -319,4 +306,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ApiKeyCreateParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index 74acfa22..a614a6ad 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun apiKeyId(): String = apiKeyId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = apply { - this.apiKeyId = apiKeyDeleteParams.apiKeyId - additionalHeaders(apiKeyDeleteParams.additionalHeaders) - additionalQueryParams(apiKeyDeleteParams.additionalQueryParams) - additionalBodyProperties(apiKeyDeleteParams.additionalBodyProperties) + apiKeyId = apiKeyDeleteParams.apiKeyId + additionalHeaders = apiKeyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = apiKeyDeleteParams.additionalBodyProperties.toMutableMap() } /** ApiKey id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index a24b1853..a2571a54 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -45,6 +45,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -60,23 +64,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -98,14 +85,14 @@ constructor( @JvmSynthetic internal fun from(apiKeyListParams: ApiKeyListParams) = apply { - this.apiKeyName = apiKeyListParams.apiKeyName - this.endingBefore = apiKeyListParams.endingBefore - this.ids = apiKeyListParams.ids - this.limit = apiKeyListParams.limit - this.orgName = apiKeyListParams.orgName - this.startingAfter = apiKeyListParams.startingAfter - additionalHeaders(apiKeyListParams.additionalHeaders) - additionalQueryParams(apiKeyListParams.additionalQueryParams) + apiKeyName = apiKeyListParams.apiKeyName + endingBefore = apiKeyListParams.endingBefore + ids = apiKeyListParams.ids + limit = apiKeyListParams.limit + orgName = apiKeyListParams.orgName + startingAfter = apiKeyListParams.startingAfter + additionalHeaders = apiKeyListParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyListParams.additionalQueryParams.toBuilder() } /** Name of the api_key to search for */ @@ -374,4 +361,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 9ac78ac2..e6a5848a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun apiKeyId(): String = apiKeyId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = apply { - this.apiKeyId = apiKeyRetrieveParams.apiKeyId - additionalHeaders(apiKeyRetrieveParams.additionalHeaders) - additionalQueryParams(apiKeyRetrieveParams.additionalQueryParams) + apiKeyId = apiKeyRetrieveParams.apiKeyId + additionalHeaders = apiKeyRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyRetrieveParams.additionalQueryParams.toBuilder() } /** ApiKey id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 37f32b64..1e5f3b48 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -35,6 +35,12 @@ constructor( fun metadata(): Optional = Optional.ofNullable(metadata) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): DatasetCreateBody { return DatasetCreateBody( @@ -158,25 +164,6 @@ constructor( "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetCreateParams && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, description, metadata, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "DatasetCreateParams{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -197,13 +184,13 @@ constructor( @JvmSynthetic internal fun from(datasetCreateParams: DatasetCreateParams) = apply { - this.name = datasetCreateParams.name - this.projectId = datasetCreateParams.projectId - this.description = datasetCreateParams.description - this.metadata = datasetCreateParams.metadata - additionalHeaders(datasetCreateParams.additionalHeaders) - additionalQueryParams(datasetCreateParams.additionalQueryParams) - additionalBodyProperties(datasetCreateParams.additionalBodyProperties) + name = datasetCreateParams.name + projectId = datasetCreateParams.projectId + description = datasetCreateParams.description + metadata = datasetCreateParams.metadata + additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the dataset. Within a project, dataset names are unique */ @@ -411,4 +398,17 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetCreateParams && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, description, metadata, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "DatasetCreateParams{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 454dfec6..a73911ab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun datasetId(): String = datasetId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(datasetDeleteParams: DatasetDeleteParams) = apply { - this.datasetId = datasetDeleteParams.datasetId - additionalHeaders(datasetDeleteParams.additionalHeaders) - additionalQueryParams(datasetDeleteParams.additionalQueryParams) - additionalBodyProperties(datasetDeleteParams.additionalBodyProperties) + datasetId = datasetDeleteParams.datasetId + additionalHeaders = datasetDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetDeleteParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 71f65f40..40a78dcd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -28,6 +28,12 @@ constructor( fun feedback(): List = feedback + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): DatasetFeedbackBody { return DatasetFeedbackBody(feedback, additionalBodyProperties) @@ -121,25 +127,6 @@ constructor( "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -158,11 +145,11 @@ constructor( @JvmSynthetic internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = apply { - this.datasetId = datasetFeedbackParams.datasetId - this.feedback(datasetFeedbackParams.feedback) - additionalHeaders(datasetFeedbackParams.additionalHeaders) - additionalQueryParams(datasetFeedbackParams.additionalQueryParams) - additionalBodyProperties(datasetFeedbackParams.additionalBodyProperties) + datasetId = datasetFeedbackParams.datasetId + feedback = datasetFeedbackParams.feedback.toMutableList() + additionalHeaders = datasetFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFeedbackParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetFeedbackParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ @@ -300,10 +287,23 @@ constructor( fun build(): DatasetFeedbackParams = DatasetFeedbackParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), + feedback.toImmutable(), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 096f6f87..46d06bb3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -30,6 +30,10 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -50,23 +54,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -87,13 +74,13 @@ constructor( @JvmSynthetic internal fun from(datasetFetchParams: DatasetFetchParams) = apply { - this.datasetId = datasetFetchParams.datasetId - this.limit = datasetFetchParams.limit - this.maxRootSpanId = datasetFetchParams.maxRootSpanId - this.maxXactId = datasetFetchParams.maxXactId - this.version = datasetFetchParams.version - additionalHeaders(datasetFetchParams.additionalHeaders) - additionalQueryParams(datasetFetchParams.additionalQueryParams) + datasetId = datasetFetchParams.datasetId + limit = datasetFetchParams.limit + maxRootSpanId = datasetFetchParams.maxRootSpanId + maxXactId = datasetFetchParams.maxXactId + version = datasetFetchParams.version + additionalHeaders = datasetFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFetchParams.additionalQueryParams.toBuilder() } /** Dataset id */ @@ -261,4 +248,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 5ebfbe09..a8dd1fdb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -41,6 +41,12 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): DatasetFetchPostBody { return DatasetFetchPostBody( @@ -276,25 +282,6 @@ constructor( "DatasetFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -317,15 +304,16 @@ constructor( @JvmSynthetic internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = apply { - this.datasetId = datasetFetchPostParams.datasetId - this.cursor = datasetFetchPostParams.cursor - this.limit = datasetFetchPostParams.limit - this.maxRootSpanId = datasetFetchPostParams.maxRootSpanId - this.maxXactId = datasetFetchPostParams.maxXactId - this.version = datasetFetchPostParams.version - additionalHeaders(datasetFetchPostParams.additionalHeaders) - additionalQueryParams(datasetFetchPostParams.additionalQueryParams) - additionalBodyProperties(datasetFetchPostParams.additionalBodyProperties) + datasetId = datasetFetchPostParams.datasetId + cursor = datasetFetchPostParams.cursor + limit = datasetFetchPostParams.limit + maxRootSpanId = datasetFetchPostParams.maxRootSpanId + maxXactId = datasetFetchPostParams.maxXactId + version = datasetFetchPostParams.version + additionalHeaders = datasetFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFetchPostParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + datasetFetchPostParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ @@ -526,4 +514,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index c89ae0f4..2e6c8004 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -28,6 +28,12 @@ constructor( fun events(): List = events + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): DatasetInsertBody { return DatasetInsertBody(events, additionalBodyProperties) @@ -120,25 +126,6 @@ constructor( "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -157,11 +144,11 @@ constructor( @JvmSynthetic internal fun from(datasetInsertParams: DatasetInsertParams) = apply { - this.datasetId = datasetInsertParams.datasetId - this.events(datasetInsertParams.events) - additionalHeaders(datasetInsertParams.additionalHeaders) - additionalQueryParams(datasetInsertParams.additionalQueryParams) - additionalBodyProperties(datasetInsertParams.additionalBodyProperties) + datasetId = datasetInsertParams.datasetId + events = datasetInsertParams.events.toMutableList() + additionalHeaders = datasetInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetInsertParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetInsertParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ @@ -299,10 +286,23 @@ constructor( fun build(): DatasetInsertParams = DatasetInsertParams( checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + events.toImmutable(), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index ae17b6b9..71464ae0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -51,6 +51,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -68,23 +72,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -108,16 +95,16 @@ constructor( @JvmSynthetic internal fun from(datasetListParams: DatasetListParams) = apply { - this.datasetName = datasetListParams.datasetName - this.endingBefore = datasetListParams.endingBefore - this.ids = datasetListParams.ids - this.limit = datasetListParams.limit - this.orgName = datasetListParams.orgName - this.projectId = datasetListParams.projectId - this.projectName = datasetListParams.projectName - this.startingAfter = datasetListParams.startingAfter - additionalHeaders(datasetListParams.additionalHeaders) - additionalQueryParams(datasetListParams.additionalQueryParams) + datasetName = datasetListParams.datasetName + endingBefore = datasetListParams.endingBefore + ids = datasetListParams.ids + limit = datasetListParams.limit + orgName = datasetListParams.orgName + projectId = datasetListParams.projectId + projectName = datasetListParams.projectName + startingAfter = datasetListParams.startingAfter + additionalHeaders = datasetListParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() } /** Name of the dataset to search for */ @@ -394,4 +381,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index 97b54216..c24a97c2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun datasetId(): String = datasetId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = apply { - this.datasetId = datasetRetrieveParams.datasetId - additionalHeaders(datasetRetrieveParams.additionalHeaders) - additionalQueryParams(datasetRetrieveParams.additionalQueryParams) + datasetId = datasetRetrieveParams.datasetId + additionalHeaders = datasetRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveParams.additionalQueryParams.toBuilder() } /** Dataset id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 562d281a..143a45ee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -21,6 +21,10 @@ constructor( fun summarizeData(): Optional = Optional.ofNullable(summarizeData) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -38,23 +42,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -72,10 +59,10 @@ constructor( @JvmSynthetic internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = apply { - this.datasetId = datasetSummarizeParams.datasetId - this.summarizeData = datasetSummarizeParams.summarizeData - additionalHeaders(datasetSummarizeParams.additionalHeaders) - additionalQueryParams(datasetSummarizeParams.additionalQueryParams) + datasetId = datasetSummarizeParams.datasetId + summarizeData = datasetSummarizeParams.summarizeData + additionalHeaders = datasetSummarizeParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetSummarizeParams.additionalQueryParams.toBuilder() } /** Dataset id */ @@ -192,4 +179,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 3bdefd72..102ed380 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -35,6 +35,12 @@ constructor( fun name(): Optional = Optional.ofNullable(name) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): DatasetUpdateBody { return DatasetUpdateBody( @@ -153,25 +159,6 @@ constructor( "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && description == other.description && metadata == other.metadata && name == other.name && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, description, metadata, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -192,13 +179,13 @@ constructor( @JvmSynthetic internal fun from(datasetUpdateParams: DatasetUpdateParams) = apply { - this.datasetId = datasetUpdateParams.datasetId - this.description = datasetUpdateParams.description - this.metadata = datasetUpdateParams.metadata - this.name = datasetUpdateParams.name - additionalHeaders(datasetUpdateParams.additionalHeaders) - additionalQueryParams(datasetUpdateParams.additionalQueryParams) - additionalBodyProperties(datasetUpdateParams.additionalBodyProperties) + datasetId = datasetUpdateParams.datasetId + description = datasetUpdateParams.description + metadata = datasetUpdateParams.metadata + name = datasetUpdateParams.name + additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetUpdateParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ @@ -406,4 +393,17 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && description == other.description && metadata == other.metadata && name == other.name && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, description, metadata, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 792c18a5..c302f4fe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -39,6 +39,12 @@ constructor( fun value(): Optional = Optional.ofNullable(value) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): EnvVarCreateBody { return EnvVarCreateBody( @@ -161,25 +167,6 @@ constructor( "EnvVarCreateBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EnvVarCreateParams && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "EnvVarCreateParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -200,13 +187,13 @@ constructor( @JvmSynthetic internal fun from(envVarCreateParams: EnvVarCreateParams) = apply { - this.name = envVarCreateParams.name - this.objectId = envVarCreateParams.objectId - this.objectType = envVarCreateParams.objectType - this.value = envVarCreateParams.value - additionalHeaders(envVarCreateParams.additionalHeaders) - additionalQueryParams(envVarCreateParams.additionalQueryParams) - additionalBodyProperties(envVarCreateParams.additionalBodyProperties) + name = envVarCreateParams.name + objectId = envVarCreateParams.objectId + objectType = envVarCreateParams.objectType + value = envVarCreateParams.value + additionalHeaders = envVarCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = envVarCreateParams.additionalBodyProperties.toMutableMap() } /** The name of the environment variable */ @@ -415,4 +402,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarCreateParams && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "EnvVarCreateParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index 39e7d0d2..93b1b39f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun envVarId(): String = envVarId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(envVarDeleteParams: EnvVarDeleteParams) = apply { - this.envVarId = envVarDeleteParams.envVarId - additionalHeaders(envVarDeleteParams.additionalHeaders) - additionalQueryParams(envVarDeleteParams.additionalQueryParams) - additionalBodyProperties(envVarDeleteParams.additionalBodyProperties) + envVarId = envVarDeleteParams.envVarId + additionalHeaders = envVarDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = envVarDeleteParams.additionalBodyProperties.toMutableMap() } /** EnvVar id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 4d4ad6df..fb3972cd 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 @@ -45,6 +45,10 @@ constructor( fun objectType(): Optional = Optional.ofNullable(objectType) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -59,23 +63,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -96,13 +83,13 @@ constructor( @JvmSynthetic internal fun from(envVarListParams: EnvVarListParams) = apply { - this.envVarName = envVarListParams.envVarName - this.ids = envVarListParams.ids - this.limit = envVarListParams.limit - this.objectId = envVarListParams.objectId - this.objectType = envVarListParams.objectType - additionalHeaders(envVarListParams.additionalHeaders) - additionalQueryParams(envVarListParams.additionalQueryParams) + envVarName = envVarListParams.envVarName + ids = envVarListParams.ids + limit = envVarListParams.limit + objectId = envVarListParams.objectId + objectType = envVarListParams.objectType + additionalHeaders = envVarListParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarListParams.additionalQueryParams.toBuilder() } /** Name of the env_var to search for */ @@ -418,4 +405,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index 2ee8454c..c08b94ac 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -39,6 +39,12 @@ constructor( fun value(): Optional = Optional.ofNullable(value) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): EnvVarReplaceBody { return EnvVarReplaceBody( @@ -161,25 +167,6 @@ constructor( "EnvVarReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EnvVarReplaceParams && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "EnvVarReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -200,13 +187,13 @@ constructor( @JvmSynthetic internal fun from(envVarReplaceParams: EnvVarReplaceParams) = apply { - this.name = envVarReplaceParams.name - this.objectId = envVarReplaceParams.objectId - this.objectType = envVarReplaceParams.objectType - this.value = envVarReplaceParams.value - additionalHeaders(envVarReplaceParams.additionalHeaders) - additionalQueryParams(envVarReplaceParams.additionalQueryParams) - additionalBodyProperties(envVarReplaceParams.additionalBodyProperties) + name = envVarReplaceParams.name + objectId = envVarReplaceParams.objectId + objectType = envVarReplaceParams.objectType + value = envVarReplaceParams.value + additionalHeaders = envVarReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = envVarReplaceParams.additionalBodyProperties.toMutableMap() } /** The name of the environment variable */ @@ -415,4 +402,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarReplaceParams && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "EnvVarReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 6c302efd..8524af2e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun envVarId(): String = envVarId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = apply { - this.envVarId = envVarRetrieveParams.envVarId - additionalHeaders(envVarRetrieveParams.additionalHeaders) - additionalQueryParams(envVarRetrieveParams.additionalQueryParams) + envVarId = envVarRetrieveParams.envVarId + additionalHeaders = envVarRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarRetrieveParams.additionalQueryParams.toBuilder() } /** EnvVar id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 8c55f79f..9b59ba36 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -32,6 +32,12 @@ constructor( fun value(): Optional = Optional.ofNullable(value) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): EnvVarUpdateBody { return EnvVarUpdateBody( @@ -137,25 +143,6 @@ constructor( "EnvVarUpdateBody{name=$name, value=$value, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && name == other.name && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, name, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "EnvVarUpdateParams{envVarId=$envVarId, name=$name, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -175,12 +162,12 @@ constructor( @JvmSynthetic internal fun from(envVarUpdateParams: EnvVarUpdateParams) = apply { - this.envVarId = envVarUpdateParams.envVarId - this.name = envVarUpdateParams.name - this.value = envVarUpdateParams.value - additionalHeaders(envVarUpdateParams.additionalHeaders) - additionalQueryParams(envVarUpdateParams.additionalQueryParams) - additionalBodyProperties(envVarUpdateParams.additionalBodyProperties) + envVarId = envVarUpdateParams.envVarId + name = envVarUpdateParams.name + value = envVarUpdateParams.value + additionalHeaders = envVarUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = envVarUpdateParams.additionalBodyProperties.toMutableMap() } /** EnvVar id */ @@ -322,4 +309,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && name == other.name && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, name, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "EnvVarUpdateParams{envVarId=$envVarId, name=$name, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 3d91e18d..31008b33 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -83,6 +83,12 @@ constructor( fun trialCount(): Optional = Optional.ofNullable(trialCount) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): EvalCreateBody { return EvalCreateBody( @@ -403,25 +409,6 @@ constructor( "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EvalCreateParams && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "EvalCreateParams{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -453,24 +440,24 @@ constructor( @JvmSynthetic internal fun from(evalCreateParams: EvalCreateParams) = apply { - this.data = evalCreateParams.data - this.projectId = evalCreateParams.projectId - this.scores(evalCreateParams.scores) - this.task = evalCreateParams.task - this.baseExperimentId = evalCreateParams.baseExperimentId - this.baseExperimentName = evalCreateParams.baseExperimentName - this.experimentName = evalCreateParams.experimentName - this.gitMetadataSettings = evalCreateParams.gitMetadataSettings - this.isPublic = evalCreateParams.isPublic - this.maxConcurrency = evalCreateParams.maxConcurrency - this.metadata = evalCreateParams.metadata - this.repoInfo = evalCreateParams.repoInfo - this.stream = evalCreateParams.stream - this.timeout = evalCreateParams.timeout - this.trialCount = evalCreateParams.trialCount - additionalHeaders(evalCreateParams.additionalHeaders) - additionalQueryParams(evalCreateParams.additionalQueryParams) - additionalBodyProperties(evalCreateParams.additionalBodyProperties) + data = evalCreateParams.data + projectId = evalCreateParams.projectId + scores = evalCreateParams.scores.toMutableList() + task = evalCreateParams.task + baseExperimentId = evalCreateParams.baseExperimentId + baseExperimentName = evalCreateParams.baseExperimentName + experimentName = evalCreateParams.experimentName + gitMetadataSettings = evalCreateParams.gitMetadataSettings + isPublic = evalCreateParams.isPublic + maxConcurrency = evalCreateParams.maxConcurrency + metadata = evalCreateParams.metadata + repoInfo = evalCreateParams.repoInfo + stream = evalCreateParams.stream + timeout = evalCreateParams.timeout + trialCount = evalCreateParams.trialCount + additionalHeaders = evalCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = evalCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = evalCreateParams.additionalBodyProperties.toMutableMap() } /** The dataset to use */ @@ -717,7 +704,7 @@ constructor( EvalCreateParams( checkNotNull(data) { "`data` is required but was not set" }, checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(scores) { "`scores` is required but was not set" }.toImmutable(), + scores.toImmutable(), checkNotNull(task) { "`task` is required but was not set" }, baseExperimentId, baseExperimentName, @@ -3589,4 +3576,17 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EvalCreateParams && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "EvalCreateParams{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 2d86c5a5..b8273443 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -53,6 +53,12 @@ constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ExperimentCreateBody { return ExperimentCreateBody( @@ -274,25 +280,6 @@ constructor( "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentCreateParams && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -319,19 +306,20 @@ constructor( @JvmSynthetic internal fun from(experimentCreateParams: ExperimentCreateParams) = apply { - this.projectId = experimentCreateParams.projectId - this.baseExpId = experimentCreateParams.baseExpId - this.datasetId = experimentCreateParams.datasetId - this.datasetVersion = experimentCreateParams.datasetVersion - this.description = experimentCreateParams.description - this.ensureNew = experimentCreateParams.ensureNew - this.metadata = experimentCreateParams.metadata - this.name = experimentCreateParams.name - this.public_ = experimentCreateParams.public_ - this.repoInfo = experimentCreateParams.repoInfo - additionalHeaders(experimentCreateParams.additionalHeaders) - additionalQueryParams(experimentCreateParams.additionalQueryParams) - additionalBodyProperties(experimentCreateParams.additionalBodyProperties) + projectId = experimentCreateParams.projectId + baseExpId = experimentCreateParams.baseExpId + datasetId = experimentCreateParams.datasetId + datasetVersion = experimentCreateParams.datasetVersion + description = experimentCreateParams.description + ensureNew = experimentCreateParams.ensureNew + metadata = experimentCreateParams.metadata + name = experimentCreateParams.name + public_ = experimentCreateParams.public_ + repoInfo = experimentCreateParams.repoInfo + additionalHeaders = experimentCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + experimentCreateParams.additionalBodyProperties.toMutableMap() } /** Unique identifier for the project that the experiment belongs under */ @@ -575,4 +563,17 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentCreateParams && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 8ab8dbcf..d6273fe6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun experimentId(): String = experimentId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,11 @@ constructor( @JvmSynthetic internal fun from(experimentDeleteParams: ExperimentDeleteParams) = apply { - this.experimentId = experimentDeleteParams.experimentId - additionalHeaders(experimentDeleteParams.additionalHeaders) - additionalQueryParams(experimentDeleteParams.additionalQueryParams) - additionalBodyProperties(experimentDeleteParams.additionalBodyProperties) + experimentId = experimentDeleteParams.experimentId + additionalHeaders = experimentDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + experimentDeleteParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ @@ -210,4 +198,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 2aad69b4..11386697 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -28,6 +28,12 @@ constructor( fun feedback(): List = feedback + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ExperimentFeedbackBody { return ExperimentFeedbackBody(feedback, additionalBodyProperties) @@ -123,25 +129,6 @@ constructor( "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -160,11 +147,12 @@ constructor( @JvmSynthetic internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = apply { - this.experimentId = experimentFeedbackParams.experimentId - this.feedback(experimentFeedbackParams.feedback) - additionalHeaders(experimentFeedbackParams.additionalHeaders) - additionalQueryParams(experimentFeedbackParams.additionalQueryParams) - additionalBodyProperties(experimentFeedbackParams.additionalBodyProperties) + experimentId = experimentFeedbackParams.experimentId + feedback = experimentFeedbackParams.feedback.toMutableList() + additionalHeaders = experimentFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFeedbackParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + experimentFeedbackParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ @@ -302,10 +290,23 @@ constructor( fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), + feedback.toImmutable(), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 2f660184..5d243ca8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -30,6 +30,10 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -50,23 +54,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -87,13 +74,13 @@ constructor( @JvmSynthetic internal fun from(experimentFetchParams: ExperimentFetchParams) = apply { - this.experimentId = experimentFetchParams.experimentId - this.limit = experimentFetchParams.limit - this.maxRootSpanId = experimentFetchParams.maxRootSpanId - this.maxXactId = experimentFetchParams.maxXactId - this.version = experimentFetchParams.version - additionalHeaders(experimentFetchParams.additionalHeaders) - additionalQueryParams(experimentFetchParams.additionalQueryParams) + experimentId = experimentFetchParams.experimentId + limit = experimentFetchParams.limit + maxRootSpanId = experimentFetchParams.maxRootSpanId + maxXactId = experimentFetchParams.maxXactId + version = experimentFetchParams.version + additionalHeaders = experimentFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFetchParams.additionalQueryParams.toBuilder() } /** Experiment id */ @@ -261,4 +248,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 187957ca..14451928 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -41,6 +41,12 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ExperimentFetchPostBody { return ExperimentFetchPostBody( @@ -276,25 +282,6 @@ constructor( "ExperimentFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -317,15 +304,16 @@ constructor( @JvmSynthetic internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = apply { - this.experimentId = experimentFetchPostParams.experimentId - this.cursor = experimentFetchPostParams.cursor - this.limit = experimentFetchPostParams.limit - this.maxRootSpanId = experimentFetchPostParams.maxRootSpanId - this.maxXactId = experimentFetchPostParams.maxXactId - this.version = experimentFetchPostParams.version - additionalHeaders(experimentFetchPostParams.additionalHeaders) - additionalQueryParams(experimentFetchPostParams.additionalQueryParams) - additionalBodyProperties(experimentFetchPostParams.additionalBodyProperties) + experimentId = experimentFetchPostParams.experimentId + cursor = experimentFetchPostParams.cursor + limit = experimentFetchPostParams.limit + maxRootSpanId = experimentFetchPostParams.maxRootSpanId + maxXactId = experimentFetchPostParams.maxXactId + version = experimentFetchPostParams.version + additionalHeaders = experimentFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFetchPostParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + experimentFetchPostParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ @@ -526,4 +514,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index e7980b7b..f0f02b2b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -28,6 +28,12 @@ constructor( fun events(): List = events + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ExperimentInsertBody { return ExperimentInsertBody(events, additionalBodyProperties) @@ -120,25 +126,6 @@ constructor( "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -157,11 +144,12 @@ constructor( @JvmSynthetic internal fun from(experimentInsertParams: ExperimentInsertParams) = apply { - this.experimentId = experimentInsertParams.experimentId - this.events(experimentInsertParams.events) - additionalHeaders(experimentInsertParams.additionalHeaders) - additionalQueryParams(experimentInsertParams.additionalQueryParams) - additionalBodyProperties(experimentInsertParams.additionalBodyProperties) + experimentId = experimentInsertParams.experimentId + events = experimentInsertParams.events.toMutableList() + additionalHeaders = experimentInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentInsertParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + experimentInsertParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ @@ -299,10 +287,23 @@ constructor( fun build(): ExperimentInsertParams = ExperimentInsertParams( checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + events.toImmutable(), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 777c21e3..72788281 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -51,6 +51,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -68,23 +72,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -108,16 +95,16 @@ constructor( @JvmSynthetic internal fun from(experimentListParams: ExperimentListParams) = apply { - this.endingBefore = experimentListParams.endingBefore - this.experimentName = experimentListParams.experimentName - this.ids = experimentListParams.ids - this.limit = experimentListParams.limit - this.orgName = experimentListParams.orgName - this.projectId = experimentListParams.projectId - this.projectName = experimentListParams.projectName - this.startingAfter = experimentListParams.startingAfter - additionalHeaders(experimentListParams.additionalHeaders) - additionalQueryParams(experimentListParams.additionalQueryParams) + endingBefore = experimentListParams.endingBefore + experimentName = experimentListParams.experimentName + ids = experimentListParams.ids + limit = experimentListParams.limit + orgName = experimentListParams.orgName + projectId = experimentListParams.projectId + projectName = experimentListParams.projectName + startingAfter = experimentListParams.startingAfter + additionalHeaders = experimentListParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentListParams.additionalQueryParams.toBuilder() } /** @@ -394,4 +381,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 908c3b36..78835532 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun experimentId(): String = experimentId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = apply { - this.experimentId = experimentRetrieveParams.experimentId - additionalHeaders(experimentRetrieveParams.additionalHeaders) - additionalQueryParams(experimentRetrieveParams.additionalQueryParams) + experimentId = experimentRetrieveParams.experimentId + additionalHeaders = experimentRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentRetrieveParams.additionalQueryParams.toBuilder() } /** Experiment id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 4f41a127..4d1a2b52 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -24,6 +24,10 @@ constructor( fun summarizeScores(): Optional = Optional.ofNullable(summarizeScores) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -44,23 +48,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -79,11 +66,11 @@ constructor( @JvmSynthetic internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = apply { - this.experimentId = experimentSummarizeParams.experimentId - this.comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId - this.summarizeScores = experimentSummarizeParams.summarizeScores - additionalHeaders(experimentSummarizeParams.additionalHeaders) - additionalQueryParams(experimentSummarizeParams.additionalQueryParams) + experimentId = experimentSummarizeParams.experimentId + comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId + summarizeScores = experimentSummarizeParams.summarizeScores + additionalHeaders = experimentSummarizeParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentSummarizeParams.additionalQueryParams.toBuilder() } /** Experiment id */ @@ -214,4 +201,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 034d41bc..ce106713 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -50,6 +50,12 @@ constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ExperimentUpdateBody { return ExperimentUpdateBody( @@ -246,25 +252,6 @@ constructor( "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -290,18 +277,19 @@ constructor( @JvmSynthetic internal fun from(experimentUpdateParams: ExperimentUpdateParams) = apply { - this.experimentId = experimentUpdateParams.experimentId - this.baseExpId = experimentUpdateParams.baseExpId - this.datasetId = experimentUpdateParams.datasetId - this.datasetVersion = experimentUpdateParams.datasetVersion - this.description = experimentUpdateParams.description - this.metadata = experimentUpdateParams.metadata - this.name = experimentUpdateParams.name - this.public_ = experimentUpdateParams.public_ - this.repoInfo = experimentUpdateParams.repoInfo - additionalHeaders(experimentUpdateParams.additionalHeaders) - additionalQueryParams(experimentUpdateParams.additionalQueryParams) - additionalBodyProperties(experimentUpdateParams.additionalBodyProperties) + experimentId = experimentUpdateParams.experimentId + baseExpId = experimentUpdateParams.baseExpId + datasetId = experimentUpdateParams.datasetId + datasetVersion = experimentUpdateParams.datasetVersion + description = experimentUpdateParams.description + metadata = experimentUpdateParams.metadata + name = experimentUpdateParams.name + public_ = experimentUpdateParams.public_ + repoInfo = experimentUpdateParams.repoInfo + additionalHeaders = experimentUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + experimentUpdateParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ @@ -537,4 +525,17 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 c5b0f660..94748ae5 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 @@ -67,6 +67,12 @@ constructor( fun tags(): Optional> = Optional.ofNullable(tags) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): FunctionCreateBody { return FunctionCreateBody( @@ -259,25 +265,6 @@ constructor( "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionCreateParams && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -304,19 +291,19 @@ constructor( @JvmSynthetic internal fun from(functionCreateParams: FunctionCreateParams) = apply { - this.functionData = functionCreateParams.functionData - this.name = functionCreateParams.name - this.projectId = functionCreateParams.projectId - this.slug = functionCreateParams.slug - this.description = functionCreateParams.description - this.functionSchema = functionCreateParams.functionSchema - this.functionType = functionCreateParams.functionType - this.origin = functionCreateParams.origin - this.promptData = functionCreateParams.promptData - this.tags(functionCreateParams.tags ?: listOf()) - additionalHeaders(functionCreateParams.additionalHeaders) - additionalQueryParams(functionCreateParams.additionalQueryParams) - additionalBodyProperties(functionCreateParams.additionalBodyProperties) + functionData = functionCreateParams.functionData + name = functionCreateParams.name + projectId = functionCreateParams.projectId + slug = functionCreateParams.slug + description = functionCreateParams.description + functionSchema = functionCreateParams.functionSchema + functionType = functionCreateParams.functionType + origin = functionCreateParams.origin + promptData = functionCreateParams.promptData + tags = functionCreateParams.tags?.toMutableList() ?: mutableListOf() + additionalHeaders = functionCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = functionCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = functionCreateParams.additionalBodyProperties.toMutableMap() } fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } @@ -497,7 +484,7 @@ constructor( functionType, origin, promptData, - if (tags.size == 0) null else tags.toImmutable(), + tags.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -2137,4 +2124,17 @@ constructor( override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionCreateParams && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index 9a11e345..fb4cf4c1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun functionId(): String = functionId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(functionDeleteParams: FunctionDeleteParams) = apply { - this.functionId = functionDeleteParams.functionId - additionalHeaders(functionDeleteParams.additionalHeaders) - additionalQueryParams(functionDeleteParams.additionalQueryParams) - additionalBodyProperties(functionDeleteParams.additionalBodyProperties) + functionId = functionDeleteParams.functionId + additionalHeaders = functionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = functionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = functionDeleteParams.additionalBodyProperties.toMutableMap() } /** Function id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 7542e094..42017edc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -58,6 +58,12 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): FunctionInvokeBody { return FunctionInvokeBody( @@ -215,25 +221,6 @@ constructor( "FunctionInvokeBody{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, input, messages, mode, parent, stream, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "FunctionInvokeParams{functionId=$functionId, input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -257,16 +244,16 @@ constructor( @JvmSynthetic internal fun from(functionInvokeParams: FunctionInvokeParams) = apply { - this.functionId = functionInvokeParams.functionId - this.input = functionInvokeParams.input - this.messages(functionInvokeParams.messages ?: listOf()) - this.mode = functionInvokeParams.mode - this.parent = functionInvokeParams.parent - this.stream = functionInvokeParams.stream - this.version = functionInvokeParams.version - additionalHeaders(functionInvokeParams.additionalHeaders) - additionalQueryParams(functionInvokeParams.additionalQueryParams) - additionalBodyProperties(functionInvokeParams.additionalBodyProperties) + functionId = functionInvokeParams.functionId + input = functionInvokeParams.input + messages = functionInvokeParams.messages?.toMutableList() ?: mutableListOf() + mode = functionInvokeParams.mode + parent = functionInvokeParams.parent + stream = functionInvokeParams.stream + version = functionInvokeParams.version + additionalHeaders = functionInvokeParams.additionalHeaders.toBuilder() + additionalQueryParams = functionInvokeParams.additionalQueryParams.toBuilder() + additionalBodyProperties = functionInvokeParams.additionalBodyProperties.toMutableMap() } /** Function id */ @@ -431,7 +418,7 @@ constructor( FunctionInvokeParams( checkNotNull(functionId) { "`functionId` is required but was not set" }, input, - if (messages.size == 0) null else messages.toImmutable(), + messages.toImmutable().ifEmpty { null }, mode, parent, stream, @@ -2672,4 +2659,17 @@ constructor( "SpanParentStruct{objectType=$objectType, objectId=$objectId, rowIds=$rowIds, propagatedEvent=$propagatedEvent, additionalProperties=$additionalProperties}" } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, input, messages, mode, parent, stream, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "FunctionInvokeParams{functionId=$functionId, input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index b89cb925..5ef0037b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -57,6 +57,10 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -76,23 +80,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -118,18 +105,18 @@ constructor( @JvmSynthetic internal fun from(functionListParams: FunctionListParams) = apply { - this.endingBefore = functionListParams.endingBefore - this.functionName = functionListParams.functionName - this.ids = functionListParams.ids - this.limit = functionListParams.limit - this.orgName = functionListParams.orgName - this.projectId = functionListParams.projectId - this.projectName = functionListParams.projectName - this.slug = functionListParams.slug - this.startingAfter = functionListParams.startingAfter - this.version = functionListParams.version - additionalHeaders(functionListParams.additionalHeaders) - additionalQueryParams(functionListParams.additionalQueryParams) + endingBefore = functionListParams.endingBefore + functionName = functionListParams.functionName + ids = functionListParams.ids + limit = functionListParams.limit + orgName = functionListParams.orgName + projectId = functionListParams.projectId + projectName = functionListParams.projectName + slug = functionListParams.slug + startingAfter = functionListParams.startingAfter + version = functionListParams.version + additionalHeaders = functionListParams.additionalHeaders.toBuilder() + additionalQueryParams = functionListParams.additionalQueryParams.toBuilder() } /** @@ -419,4 +406,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 ac538eb8..d5f5ef69 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 @@ -67,6 +67,12 @@ constructor( fun tags(): Optional> = Optional.ofNullable(tags) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): FunctionReplaceBody { return FunctionReplaceBody( @@ -259,25 +265,6 @@ constructor( "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionReplaceParams && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -304,19 +291,19 @@ constructor( @JvmSynthetic internal fun from(functionReplaceParams: FunctionReplaceParams) = apply { - this.functionData = functionReplaceParams.functionData - this.name = functionReplaceParams.name - this.projectId = functionReplaceParams.projectId - this.slug = functionReplaceParams.slug - this.description = functionReplaceParams.description - this.functionSchema = functionReplaceParams.functionSchema - this.functionType = functionReplaceParams.functionType - this.origin = functionReplaceParams.origin - this.promptData = functionReplaceParams.promptData - this.tags(functionReplaceParams.tags ?: listOf()) - additionalHeaders(functionReplaceParams.additionalHeaders) - additionalQueryParams(functionReplaceParams.additionalQueryParams) - additionalBodyProperties(functionReplaceParams.additionalBodyProperties) + functionData = functionReplaceParams.functionData + name = functionReplaceParams.name + projectId = functionReplaceParams.projectId + slug = functionReplaceParams.slug + description = functionReplaceParams.description + functionSchema = functionReplaceParams.functionSchema + functionType = functionReplaceParams.functionType + origin = functionReplaceParams.origin + promptData = functionReplaceParams.promptData + tags = functionReplaceParams.tags?.toMutableList() ?: mutableListOf() + additionalHeaders = functionReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = functionReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = functionReplaceParams.additionalBodyProperties.toMutableMap() } fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } @@ -497,7 +484,7 @@ constructor( functionType, origin, promptData, - if (tags.size == 0) null else tags.toImmutable(), + tags.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -2137,4 +2124,17 @@ constructor( override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionReplaceParams && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index 054c835a..e7aed157 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun functionId(): String = functionId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(functionRetrieveParams: FunctionRetrieveParams) = apply { - this.functionId = functionRetrieveParams.functionId - additionalHeaders(functionRetrieveParams.additionalHeaders) - additionalQueryParams(functionRetrieveParams.additionalQueryParams) + functionId = functionRetrieveParams.functionId + additionalHeaders = functionRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = functionRetrieveParams.additionalQueryParams.toBuilder() } /** Function id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 88e39149..48fbfd55 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -55,6 +55,12 @@ constructor( fun tags(): Optional> = Optional.ofNullable(tags) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): FunctionUpdateBody { return FunctionUpdateBody( @@ -196,25 +202,6 @@ constructor( "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, description, functionData, name, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -237,15 +224,15 @@ constructor( @JvmSynthetic internal fun from(functionUpdateParams: FunctionUpdateParams) = apply { - this.functionId = functionUpdateParams.functionId - this.description = functionUpdateParams.description - this.functionData = functionUpdateParams.functionData - this.name = functionUpdateParams.name - this.promptData = functionUpdateParams.promptData - this.tags(functionUpdateParams.tags ?: listOf()) - additionalHeaders(functionUpdateParams.additionalHeaders) - additionalQueryParams(functionUpdateParams.additionalQueryParams) - additionalBodyProperties(functionUpdateParams.additionalBodyProperties) + functionId = functionUpdateParams.functionId + description = functionUpdateParams.description + functionData = functionUpdateParams.functionData + name = functionUpdateParams.name + promptData = functionUpdateParams.promptData + tags = functionUpdateParams.tags?.toMutableList() ?: mutableListOf() + additionalHeaders = functionUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = functionUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = functionUpdateParams.additionalBodyProperties.toMutableMap() } /** Function id */ @@ -414,7 +401,7 @@ constructor( functionData, name, promptData, - if (tags.size == 0) null else tags.toImmutable(), + tags.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -1777,4 +1764,17 @@ constructor( override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, description, functionData, name, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 321eb648..ca5de374 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -38,6 +38,12 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): GroupCreateBody { return GroupCreateBody( @@ -193,25 +199,6 @@ constructor( "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupCreateParams && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -233,14 +220,14 @@ constructor( @JvmSynthetic internal fun from(groupCreateParams: GroupCreateParams) = apply { - this.name = groupCreateParams.name - this.description = groupCreateParams.description - this.memberGroups(groupCreateParams.memberGroups ?: listOf()) - this.memberUsers(groupCreateParams.memberUsers ?: listOf()) - this.orgName = groupCreateParams.orgName - additionalHeaders(groupCreateParams.additionalHeaders) - additionalQueryParams(groupCreateParams.additionalQueryParams) - additionalBodyProperties(groupCreateParams.additionalBodyProperties) + name = groupCreateParams.name + description = groupCreateParams.description + memberGroups = groupCreateParams.memberGroups?.toMutableList() ?: mutableListOf() + memberUsers = groupCreateParams.memberUsers?.toMutableList() ?: mutableListOf() + orgName = groupCreateParams.orgName + additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = groupCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the group */ @@ -408,12 +395,25 @@ constructor( GroupCreateParams( checkNotNull(name) { "`name` is required but was not set" }, description, - if (memberGroups.size == 0) null else memberGroups.toImmutable(), - if (memberUsers.size == 0) null else memberUsers.toImmutable(), + memberGroups.toImmutable().ifEmpty { null }, + memberUsers.toImmutable().ifEmpty { null }, orgName, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupCreateParams && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 32401090..a60e1027 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun groupId(): String = groupId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(groupDeleteParams: GroupDeleteParams) = apply { - this.groupId = groupDeleteParams.groupId - additionalHeaders(groupDeleteParams.additionalHeaders) - additionalQueryParams(groupDeleteParams.additionalQueryParams) - additionalBodyProperties(groupDeleteParams.additionalBodyProperties) + groupId = groupDeleteParams.groupId + additionalHeaders = groupDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = groupDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = groupDeleteParams.additionalBodyProperties.toMutableMap() } /** Group id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index a211dfa6..388cd7fc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -45,6 +45,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -60,23 +64,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -98,14 +85,14 @@ constructor( @JvmSynthetic internal fun from(groupListParams: GroupListParams) = apply { - this.endingBefore = groupListParams.endingBefore - this.groupName = groupListParams.groupName - this.ids = groupListParams.ids - this.limit = groupListParams.limit - this.orgName = groupListParams.orgName - this.startingAfter = groupListParams.startingAfter - additionalHeaders(groupListParams.additionalHeaders) - additionalQueryParams(groupListParams.additionalQueryParams) + endingBefore = groupListParams.endingBefore + groupName = groupListParams.groupName + ids = groupListParams.ids + limit = groupListParams.limit + orgName = groupListParams.orgName + startingAfter = groupListParams.startingAfter + additionalHeaders = groupListParams.additionalHeaders.toBuilder() + additionalQueryParams = groupListParams.additionalQueryParams.toBuilder() } /** @@ -374,4 +361,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 6a51ca0c..0f9b8053 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -38,6 +38,12 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): GroupReplaceBody { return GroupReplaceBody( @@ -193,25 +199,6 @@ constructor( "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupReplaceParams && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -233,14 +220,14 @@ constructor( @JvmSynthetic internal fun from(groupReplaceParams: GroupReplaceParams) = apply { - this.name = groupReplaceParams.name - this.description = groupReplaceParams.description - this.memberGroups(groupReplaceParams.memberGroups ?: listOf()) - this.memberUsers(groupReplaceParams.memberUsers ?: listOf()) - this.orgName = groupReplaceParams.orgName - additionalHeaders(groupReplaceParams.additionalHeaders) - additionalQueryParams(groupReplaceParams.additionalQueryParams) - additionalBodyProperties(groupReplaceParams.additionalBodyProperties) + name = groupReplaceParams.name + description = groupReplaceParams.description + memberGroups = groupReplaceParams.memberGroups?.toMutableList() ?: mutableListOf() + memberUsers = groupReplaceParams.memberUsers?.toMutableList() ?: mutableListOf() + orgName = groupReplaceParams.orgName + additionalHeaders = groupReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = groupReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = groupReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the group */ @@ -408,12 +395,25 @@ constructor( GroupReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, description, - if (memberGroups.size == 0) null else memberGroups.toImmutable(), - if (memberUsers.size == 0) null else memberUsers.toImmutable(), + memberGroups.toImmutable().ifEmpty { null }, + memberUsers.toImmutable().ifEmpty { null }, orgName, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupReplaceParams && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index e4a47fc9..3a52c1ae 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun groupId(): String = groupId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(groupRetrieveParams: GroupRetrieveParams) = apply { - this.groupId = groupRetrieveParams.groupId - additionalHeaders(groupRetrieveParams.additionalHeaders) - additionalQueryParams(groupRetrieveParams.additionalQueryParams) + groupId = groupRetrieveParams.groupId + additionalHeaders = groupRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = groupRetrieveParams.additionalQueryParams.toBuilder() } /** Group id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 609fdeef..50ae0659 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -44,6 +44,12 @@ constructor( fun removeMemberUsers(): Optional> = Optional.ofNullable(removeMemberUsers) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): GroupUpdateBody { return GroupUpdateBody( @@ -208,25 +214,6 @@ constructor( "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -250,16 +237,18 @@ constructor( @JvmSynthetic internal fun from(groupUpdateParams: GroupUpdateParams) = apply { - this.groupId = groupUpdateParams.groupId - this.addMemberGroups(groupUpdateParams.addMemberGroups ?: listOf()) - this.addMemberUsers(groupUpdateParams.addMemberUsers ?: listOf()) - this.description = groupUpdateParams.description - this.name = groupUpdateParams.name - this.removeMemberGroups(groupUpdateParams.removeMemberGroups ?: listOf()) - this.removeMemberUsers(groupUpdateParams.removeMemberUsers ?: listOf()) - additionalHeaders(groupUpdateParams.additionalHeaders) - additionalQueryParams(groupUpdateParams.additionalQueryParams) - additionalBodyProperties(groupUpdateParams.additionalBodyProperties) + groupId = groupUpdateParams.groupId + addMemberGroups = groupUpdateParams.addMemberGroups?.toMutableList() ?: mutableListOf() + addMemberUsers = groupUpdateParams.addMemberUsers?.toMutableList() ?: mutableListOf() + description = groupUpdateParams.description + name = groupUpdateParams.name + removeMemberGroups = + groupUpdateParams.removeMemberGroups?.toMutableList() ?: mutableListOf() + removeMemberUsers = + groupUpdateParams.removeMemberUsers?.toMutableList() ?: mutableListOf() + additionalHeaders = groupUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = groupUpdateParams.additionalBodyProperties.toMutableMap() } /** Group id */ @@ -438,15 +427,28 @@ constructor( fun build(): GroupUpdateParams = GroupUpdateParams( checkNotNull(groupId) { "`groupId` is required but was not set" }, - if (addMemberGroups.size == 0) null else addMemberGroups.toImmutable(), - if (addMemberUsers.size == 0) null else addMemberUsers.toImmutable(), + addMemberGroups.toImmutable().ifEmpty { null }, + addMemberUsers.toImmutable().ifEmpty { null }, description, name, - if (removeMemberGroups.size == 0) null else removeMemberGroups.toImmutable(), - if (removeMemberUsers.size == 0) null else removeMemberUsers.toImmutable(), + removeMemberGroups.toImmutable().ifEmpty { null }, + removeMemberUsers.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index b17e2a3a..ce556db7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun organizationId(): String = organizationId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,11 @@ constructor( @JvmSynthetic internal fun from(organizationDeleteParams: OrganizationDeleteParams) = apply { - this.organizationId = organizationDeleteParams.organizationId - additionalHeaders(organizationDeleteParams.additionalHeaders) - additionalQueryParams(organizationDeleteParams.additionalQueryParams) - additionalBodyProperties(organizationDeleteParams.additionalBodyProperties) + organizationId = organizationDeleteParams.organizationId + additionalHeaders = organizationDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + organizationDeleteParams.additionalBodyProperties.toMutableMap() } /** Organization id */ @@ -210,4 +198,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 11403c90..eb3a4fcc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -42,6 +42,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -56,23 +60,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -93,13 +80,13 @@ constructor( @JvmSynthetic internal fun from(organizationListParams: OrganizationListParams) = apply { - this.endingBefore = organizationListParams.endingBefore - this.ids = organizationListParams.ids - this.limit = organizationListParams.limit - this.orgName = organizationListParams.orgName - this.startingAfter = organizationListParams.startingAfter - additionalHeaders(organizationListParams.additionalHeaders) - additionalQueryParams(organizationListParams.additionalQueryParams) + endingBefore = organizationListParams.endingBefore + ids = organizationListParams.ids + limit = organizationListParams.limit + orgName = organizationListParams.orgName + startingAfter = organizationListParams.startingAfter + additionalHeaders = organizationListParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationListParams.additionalQueryParams.toBuilder() } /** @@ -364,4 +351,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 7b0defe5..2a7fd616 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -35,6 +35,12 @@ constructor( fun removeUsers(): Optional = Optional.ofNullable(removeUsers) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): OrganizationMemberUpdateBody { return OrganizationMemberUpdateBody( @@ -176,25 +182,6 @@ constructor( "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OrganizationMemberUpdateParams && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -215,13 +202,14 @@ constructor( @JvmSynthetic internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = apply { - this.inviteUsers = organizationMemberUpdateParams.inviteUsers - this.orgId = organizationMemberUpdateParams.orgId - this.orgName = organizationMemberUpdateParams.orgName - this.removeUsers = organizationMemberUpdateParams.removeUsers - additionalHeaders(organizationMemberUpdateParams.additionalHeaders) - additionalQueryParams(organizationMemberUpdateParams.additionalQueryParams) - additionalBodyProperties(organizationMemberUpdateParams.additionalBodyProperties) + inviteUsers = organizationMemberUpdateParams.inviteUsers + orgId = organizationMemberUpdateParams.orgId + orgName = organizationMemberUpdateParams.orgName + removeUsers = organizationMemberUpdateParams.removeUsers + additionalHeaders = organizationMemberUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationMemberUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + organizationMemberUpdateParams.additionalBodyProperties.toMutableMap() } /** Users to invite to the organization */ @@ -606,4 +594,17 @@ constructor( override fun toString() = "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OrganizationMemberUpdateParams && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index c60e623c..81c6fe94 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun organizationId(): String = organizationId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = apply { - this.organizationId = organizationRetrieveParams.organizationId - additionalHeaders(organizationRetrieveParams.additionalHeaders) - additionalQueryParams(organizationRetrieveParams.additionalQueryParams) + organizationId = organizationRetrieveParams.organizationId + additionalHeaders = organizationRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationRetrieveParams.additionalQueryParams.toBuilder() } /** Organization id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index fd7a12f0..78deac2d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -41,6 +41,12 @@ constructor( fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): OrganizationUpdateBody { return OrganizationUpdateBody( @@ -176,25 +182,6 @@ constructor( "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -217,15 +204,16 @@ constructor( @JvmSynthetic internal fun from(organizationUpdateParams: OrganizationUpdateParams) = apply { - this.organizationId = organizationUpdateParams.organizationId - this.apiUrl = organizationUpdateParams.apiUrl - this.isUniversalApi = organizationUpdateParams.isUniversalApi - this.name = organizationUpdateParams.name - this.proxyUrl = organizationUpdateParams.proxyUrl - this.realtimeUrl = organizationUpdateParams.realtimeUrl - additionalHeaders(organizationUpdateParams.additionalHeaders) - additionalQueryParams(organizationUpdateParams.additionalQueryParams) - additionalBodyProperties(organizationUpdateParams.additionalBodyProperties) + organizationId = organizationUpdateParams.organizationId + apiUrl = organizationUpdateParams.apiUrl + isUniversalApi = organizationUpdateParams.isUniversalApi + name = organizationUpdateParams.name + proxyUrl = organizationUpdateParams.proxyUrl + realtimeUrl = organizationUpdateParams.realtimeUrl + additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + organizationUpdateParams.additionalBodyProperties.toMutableMap() } /** Organization id */ @@ -375,4 +363,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 84e27a83..062dc275 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -29,6 +29,12 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectCreateBody { return ProjectCreateBody( @@ -136,25 +142,6 @@ constructor( "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectCreateParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -173,11 +160,11 @@ constructor( @JvmSynthetic internal fun from(projectCreateParams: ProjectCreateParams) = apply { - this.name = projectCreateParams.name - this.orgName = projectCreateParams.orgName - additionalHeaders(projectCreateParams.additionalHeaders) - additionalQueryParams(projectCreateParams.additionalQueryParams) - additionalBodyProperties(projectCreateParams.additionalBodyProperties) + name = projectCreateParams.name + orgName = projectCreateParams.orgName + additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the project */ @@ -319,4 +306,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectCreateParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index bc0cf9bd..9c24a6f7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun projectId(): String = projectId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(projectDeleteParams: ProjectDeleteParams) = apply { - this.projectId = projectDeleteParams.projectId - additionalHeaders(projectDeleteParams.additionalHeaders) - additionalQueryParams(projectDeleteParams.additionalQueryParams) - additionalBodyProperties(projectDeleteParams.additionalBodyProperties) + projectId = projectDeleteParams.projectId + additionalHeaders = projectDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectDeleteParams.additionalBodyProperties.toMutableMap() } /** Project id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 6362f645..ff8c5a39 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -45,6 +45,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -60,23 +64,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -98,14 +85,14 @@ constructor( @JvmSynthetic internal fun from(projectListParams: ProjectListParams) = apply { - this.endingBefore = projectListParams.endingBefore - this.ids = projectListParams.ids - this.limit = projectListParams.limit - this.orgName = projectListParams.orgName - this.projectName = projectListParams.projectName - this.startingAfter = projectListParams.startingAfter - additionalHeaders(projectListParams.additionalHeaders) - additionalQueryParams(projectListParams.additionalQueryParams) + endingBefore = projectListParams.endingBefore + ids = projectListParams.ids + limit = projectListParams.limit + orgName = projectListParams.orgName + projectName = projectListParams.projectName + startingAfter = projectListParams.startingAfter + additionalHeaders = projectListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectListParams.additionalQueryParams.toBuilder() } /** @@ -374,4 +361,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index a03021a0..2bfd74a5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -28,6 +28,12 @@ constructor( fun feedback(): List = feedback + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectLogFeedbackBody { return ProjectLogFeedbackBody(feedback, additionalBodyProperties) @@ -123,25 +129,6 @@ constructor( "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -160,11 +147,12 @@ constructor( @JvmSynthetic internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = apply { - this.projectId = projectLogFeedbackParams.projectId - this.feedback(projectLogFeedbackParams.feedback) - additionalHeaders(projectLogFeedbackParams.additionalHeaders) - additionalQueryParams(projectLogFeedbackParams.additionalQueryParams) - additionalBodyProperties(projectLogFeedbackParams.additionalBodyProperties) + projectId = projectLogFeedbackParams.projectId + feedback = projectLogFeedbackParams.feedback.toMutableList() + additionalHeaders = projectLogFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFeedbackParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectLogFeedbackParams.additionalBodyProperties.toMutableMap() } /** Project id */ @@ -302,10 +290,23 @@ constructor( fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" }.toImmutable(), + feedback.toImmutable(), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 933e7d84..4623fef6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -30,6 +30,10 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -50,23 +54,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -87,13 +74,13 @@ constructor( @JvmSynthetic internal fun from(projectLogFetchParams: ProjectLogFetchParams) = apply { - this.projectId = projectLogFetchParams.projectId - this.limit = projectLogFetchParams.limit - this.maxRootSpanId = projectLogFetchParams.maxRootSpanId - this.maxXactId = projectLogFetchParams.maxXactId - this.version = projectLogFetchParams.version - additionalHeaders(projectLogFetchParams.additionalHeaders) - additionalQueryParams(projectLogFetchParams.additionalQueryParams) + projectId = projectLogFetchParams.projectId + limit = projectLogFetchParams.limit + maxRootSpanId = projectLogFetchParams.maxRootSpanId + maxXactId = projectLogFetchParams.maxXactId + version = projectLogFetchParams.version + additionalHeaders = projectLogFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFetchParams.additionalQueryParams.toBuilder() } /** Project id */ @@ -261,4 +248,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 73371efe..8a3ef33d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -41,6 +41,12 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectLogFetchPostBody { return ProjectLogFetchPostBody( @@ -276,25 +282,6 @@ constructor( "ProjectLogFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -317,15 +304,16 @@ constructor( @JvmSynthetic internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = apply { - this.projectId = projectLogFetchPostParams.projectId - this.cursor = projectLogFetchPostParams.cursor - this.limit = projectLogFetchPostParams.limit - this.maxRootSpanId = projectLogFetchPostParams.maxRootSpanId - this.maxXactId = projectLogFetchPostParams.maxXactId - this.version = projectLogFetchPostParams.version - additionalHeaders(projectLogFetchPostParams.additionalHeaders) - additionalQueryParams(projectLogFetchPostParams.additionalQueryParams) - additionalBodyProperties(projectLogFetchPostParams.additionalBodyProperties) + projectId = projectLogFetchPostParams.projectId + cursor = projectLogFetchPostParams.cursor + limit = projectLogFetchPostParams.limit + maxRootSpanId = projectLogFetchPostParams.maxRootSpanId + maxXactId = projectLogFetchPostParams.maxXactId + version = projectLogFetchPostParams.version + additionalHeaders = projectLogFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFetchPostParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectLogFetchPostParams.additionalBodyProperties.toMutableMap() } /** Project id */ @@ -526,4 +514,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index bc1215ea..815ee46e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -28,6 +28,12 @@ constructor( fun events(): List = events + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectLogInsertBody { return ProjectLogInsertBody(events, additionalBodyProperties) @@ -120,25 +126,6 @@ constructor( "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -157,11 +144,12 @@ constructor( @JvmSynthetic internal fun from(projectLogInsertParams: ProjectLogInsertParams) = apply { - this.projectId = projectLogInsertParams.projectId - this.events(projectLogInsertParams.events) - additionalHeaders(projectLogInsertParams.additionalHeaders) - additionalQueryParams(projectLogInsertParams.additionalQueryParams) - additionalBodyProperties(projectLogInsertParams.additionalBodyProperties) + projectId = projectLogInsertParams.projectId + events = projectLogInsertParams.events.toMutableList() + additionalHeaders = projectLogInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogInsertParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectLogInsertParams.additionalBodyProperties.toMutableMap() } /** Project id */ @@ -299,10 +287,23 @@ constructor( fun build(): ProjectLogInsertParams = ProjectLogInsertParams( checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + events.toImmutable(), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index ad41bd68..824ea72c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun projectId(): String = projectId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(projectRetrieveParams: ProjectRetrieveParams) = apply { - this.projectId = projectRetrieveParams.projectId - additionalHeaders(projectRetrieveParams.additionalHeaders) - additionalQueryParams(projectRetrieveParams.additionalQueryParams) + projectId = projectRetrieveParams.projectId + additionalHeaders = projectRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectRetrieveParams.additionalQueryParams.toBuilder() } /** Project id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 bb659f61..85482c3f 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 @@ -53,6 +53,12 @@ constructor( fun description(): Optional = Optional.ofNullable(description) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectScoreCreateBody { return ProjectScoreCreateBody( @@ -199,25 +205,6 @@ constructor( "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreCreateParams && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -240,15 +227,16 @@ constructor( @JvmSynthetic internal fun from(projectScoreCreateParams: ProjectScoreCreateParams) = apply { - this.name = projectScoreCreateParams.name - this.projectId = projectScoreCreateParams.projectId - this.scoreType = projectScoreCreateParams.scoreType - this.categories = projectScoreCreateParams.categories - this.config = projectScoreCreateParams.config - this.description = projectScoreCreateParams.description - additionalHeaders(projectScoreCreateParams.additionalHeaders) - additionalQueryParams(projectScoreCreateParams.additionalQueryParams) - additionalBodyProperties(projectScoreCreateParams.additionalBodyProperties) + name = projectScoreCreateParams.name + projectId = projectScoreCreateParams.projectId + scoreType = projectScoreCreateParams.scoreType + categories = projectScoreCreateParams.categories + config = projectScoreCreateParams.config + description = projectScoreCreateParams.description + additionalHeaders = projectScoreCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectScoreCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the project score */ @@ -806,4 +794,17 @@ constructor( override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreCreateParams && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index d084bb49..0d76b5fc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun projectScoreId(): String = projectScoreId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,11 @@ constructor( @JvmSynthetic internal fun from(projectScoreDeleteParams: ProjectScoreDeleteParams) = apply { - this.projectScoreId = projectScoreDeleteParams.projectScoreId - additionalHeaders(projectScoreDeleteParams.additionalHeaders) - additionalQueryParams(projectScoreDeleteParams.additionalQueryParams) - additionalBodyProperties(projectScoreDeleteParams.additionalBodyProperties) + projectScoreId = projectScoreDeleteParams.projectScoreId + additionalHeaders = projectScoreDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectScoreDeleteParams.additionalBodyProperties.toMutableMap() } /** ProjectScore id */ @@ -210,4 +198,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 d9db0408..5b669e67 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 @@ -57,6 +57,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -75,23 +79,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -116,17 +103,17 @@ constructor( @JvmSynthetic internal fun from(projectScoreListParams: ProjectScoreListParams) = apply { - this.endingBefore = projectScoreListParams.endingBefore - this.ids = projectScoreListParams.ids - this.limit = projectScoreListParams.limit - this.orgName = projectScoreListParams.orgName - this.projectId = projectScoreListParams.projectId - this.projectName = projectScoreListParams.projectName - this.projectScoreName = projectScoreListParams.projectScoreName - this.scoreType = projectScoreListParams.scoreType - this.startingAfter = projectScoreListParams.startingAfter - additionalHeaders(projectScoreListParams.additionalHeaders) - additionalQueryParams(projectScoreListParams.additionalQueryParams) + endingBefore = projectScoreListParams.endingBefore + ids = projectScoreListParams.ids + limit = projectScoreListParams.limit + orgName = projectScoreListParams.orgName + projectId = projectScoreListParams.projectId + projectName = projectScoreListParams.projectName + projectScoreName = projectScoreListParams.projectScoreName + scoreType = projectScoreListParams.scoreType + startingAfter = projectScoreListParams.startingAfter + additionalHeaders = projectScoreListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreListParams.additionalQueryParams.toBuilder() } /** @@ -700,4 +687,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 f4b4f5e0..05cbad15 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 @@ -53,6 +53,12 @@ constructor( fun description(): Optional = Optional.ofNullable(description) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectScoreReplaceBody { return ProjectScoreReplaceBody( @@ -199,25 +205,6 @@ constructor( "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreReplaceParams && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -240,15 +227,16 @@ constructor( @JvmSynthetic internal fun from(projectScoreReplaceParams: ProjectScoreReplaceParams) = apply { - this.name = projectScoreReplaceParams.name - this.projectId = projectScoreReplaceParams.projectId - this.scoreType = projectScoreReplaceParams.scoreType - this.categories = projectScoreReplaceParams.categories - this.config = projectScoreReplaceParams.config - this.description = projectScoreReplaceParams.description - additionalHeaders(projectScoreReplaceParams.additionalHeaders) - additionalQueryParams(projectScoreReplaceParams.additionalQueryParams) - additionalBodyProperties(projectScoreReplaceParams.additionalBodyProperties) + name = projectScoreReplaceParams.name + projectId = projectScoreReplaceParams.projectId + scoreType = projectScoreReplaceParams.scoreType + categories = projectScoreReplaceParams.categories + config = projectScoreReplaceParams.config + description = projectScoreReplaceParams.description + additionalHeaders = projectScoreReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectScoreReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the project score */ @@ -806,4 +794,17 @@ constructor( override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreReplaceParams && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index c1af62f2..0cf1948a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun projectScoreId(): String = projectScoreId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = apply { - this.projectScoreId = projectScoreRetrieveParams.projectScoreId - additionalHeaders(projectScoreRetrieveParams.additionalHeaders) - additionalQueryParams(projectScoreRetrieveParams.additionalQueryParams) + projectScoreId = projectScoreRetrieveParams.projectScoreId + additionalHeaders = projectScoreRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreRetrieveParams.additionalQueryParams.toBuilder() } /** ProjectScore id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 65b15ac1..5c6e0a37 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 @@ -53,6 +53,12 @@ constructor( fun scoreType(): Optional = Optional.ofNullable(scoreType) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectScoreUpdateBody { return ProjectScoreUpdateBody( @@ -194,25 +200,6 @@ constructor( "ProjectScoreUpdateBody{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, categories, config, description, name, scoreType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -235,15 +222,16 @@ constructor( @JvmSynthetic internal fun from(projectScoreUpdateParams: ProjectScoreUpdateParams) = apply { - this.projectScoreId = projectScoreUpdateParams.projectScoreId - this.categories = projectScoreUpdateParams.categories - this.config = projectScoreUpdateParams.config - this.description = projectScoreUpdateParams.description - this.name = projectScoreUpdateParams.name - this.scoreType = projectScoreUpdateParams.scoreType - additionalHeaders(projectScoreUpdateParams.additionalHeaders) - additionalQueryParams(projectScoreUpdateParams.additionalQueryParams) - additionalBodyProperties(projectScoreUpdateParams.additionalBodyProperties) + projectScoreId = projectScoreUpdateParams.projectScoreId + categories = projectScoreUpdateParams.categories + config = projectScoreUpdateParams.config + description = projectScoreUpdateParams.description + name = projectScoreUpdateParams.name + scoreType = projectScoreUpdateParams.scoreType + additionalHeaders = projectScoreUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectScoreUpdateParams.additionalBodyProperties.toMutableMap() } /** ProjectScore id */ @@ -801,4 +789,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, categories, config, description, name, scoreType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 49605061..a73ba12f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -35,6 +35,12 @@ constructor( fun description(): Optional = Optional.ofNullable(description) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectTagCreateBody { return ProjectTagCreateBody( @@ -157,25 +163,6 @@ constructor( "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectTagCreateParams && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -196,13 +183,14 @@ constructor( @JvmSynthetic internal fun from(projectTagCreateParams: ProjectTagCreateParams) = apply { - this.name = projectTagCreateParams.name - this.projectId = projectTagCreateParams.projectId - this.color = projectTagCreateParams.color - this.description = projectTagCreateParams.description - additionalHeaders(projectTagCreateParams.additionalHeaders) - additionalQueryParams(projectTagCreateParams.additionalQueryParams) - additionalBodyProperties(projectTagCreateParams.additionalBodyProperties) + name = projectTagCreateParams.name + projectId = projectTagCreateParams.projectId + color = projectTagCreateParams.color + description = projectTagCreateParams.description + additionalHeaders = projectTagCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectTagCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the project tag */ @@ -348,4 +336,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagCreateParams && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 6d7a6038..8cc4cbd5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun projectTagId(): String = projectTagId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,11 @@ constructor( @JvmSynthetic internal fun from(projectTagDeleteParams: ProjectTagDeleteParams) = apply { - this.projectTagId = projectTagDeleteParams.projectTagId - additionalHeaders(projectTagDeleteParams.additionalHeaders) - additionalQueryParams(projectTagDeleteParams.additionalQueryParams) - additionalBodyProperties(projectTagDeleteParams.additionalBodyProperties) + projectTagId = projectTagDeleteParams.projectTagId + additionalHeaders = projectTagDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectTagDeleteParams.additionalBodyProperties.toMutableMap() } /** ProjectTag id */ @@ -210,4 +198,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index ab396d03..b5f6307e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -51,6 +51,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -68,23 +72,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -108,16 +95,16 @@ constructor( @JvmSynthetic internal fun from(projectTagListParams: ProjectTagListParams) = apply { - this.endingBefore = projectTagListParams.endingBefore - this.ids = projectTagListParams.ids - this.limit = projectTagListParams.limit - this.orgName = projectTagListParams.orgName - this.projectId = projectTagListParams.projectId - this.projectName = projectTagListParams.projectName - this.projectTagName = projectTagListParams.projectTagName - this.startingAfter = projectTagListParams.startingAfter - additionalHeaders(projectTagListParams.additionalHeaders) - additionalQueryParams(projectTagListParams.additionalQueryParams) + endingBefore = projectTagListParams.endingBefore + ids = projectTagListParams.ids + limit = projectTagListParams.limit + orgName = projectTagListParams.orgName + projectId = projectTagListParams.projectId + projectName = projectTagListParams.projectName + projectTagName = projectTagListParams.projectTagName + startingAfter = projectTagListParams.startingAfter + additionalHeaders = projectTagListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagListParams.additionalQueryParams.toBuilder() } /** @@ -394,4 +381,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index 6a3dd241..e8744dfe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -35,6 +35,12 @@ constructor( fun description(): Optional = Optional.ofNullable(description) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectTagReplaceBody { return ProjectTagReplaceBody( @@ -157,25 +163,6 @@ constructor( "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectTagReplaceParams && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -196,13 +183,14 @@ constructor( @JvmSynthetic internal fun from(projectTagReplaceParams: ProjectTagReplaceParams) = apply { - this.name = projectTagReplaceParams.name - this.projectId = projectTagReplaceParams.projectId - this.color = projectTagReplaceParams.color - this.description = projectTagReplaceParams.description - additionalHeaders(projectTagReplaceParams.additionalHeaders) - additionalQueryParams(projectTagReplaceParams.additionalQueryParams) - additionalBodyProperties(projectTagReplaceParams.additionalBodyProperties) + name = projectTagReplaceParams.name + projectId = projectTagReplaceParams.projectId + color = projectTagReplaceParams.color + description = projectTagReplaceParams.description + additionalHeaders = projectTagReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectTagReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the project tag */ @@ -348,4 +336,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagReplaceParams && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 658f450f..4bdda4c7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun projectTagId(): String = projectTagId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = apply { - this.projectTagId = projectTagRetrieveParams.projectTagId - additionalHeaders(projectTagRetrieveParams.additionalHeaders) - additionalQueryParams(projectTagRetrieveParams.additionalQueryParams) + projectTagId = projectTagRetrieveParams.projectTagId + additionalHeaders = projectTagRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagRetrieveParams.additionalQueryParams.toBuilder() } /** ProjectTag id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 54ad308a..821a2c38 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -35,6 +35,12 @@ constructor( fun name(): Optional = Optional.ofNullable(name) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectTagUpdateBody { return ProjectTagUpdateBody( @@ -152,25 +158,6 @@ constructor( "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && color == other.color && description == other.description && name == other.name && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, color, description, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -191,13 +178,14 @@ constructor( @JvmSynthetic internal fun from(projectTagUpdateParams: ProjectTagUpdateParams) = apply { - this.projectTagId = projectTagUpdateParams.projectTagId - this.color = projectTagUpdateParams.color - this.description = projectTagUpdateParams.description - this.name = projectTagUpdateParams.name - additionalHeaders(projectTagUpdateParams.additionalHeaders) - additionalQueryParams(projectTagUpdateParams.additionalQueryParams) - additionalBodyProperties(projectTagUpdateParams.additionalBodyProperties) + projectTagId = projectTagUpdateParams.projectTagId + color = projectTagUpdateParams.color + description = projectTagUpdateParams.description + name = projectTagUpdateParams.name + additionalHeaders = projectTagUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectTagUpdateParams.additionalBodyProperties.toMutableMap() } /** ProjectTag id */ @@ -343,4 +331,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && color == other.color && description == other.description && name == other.name && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, color, description, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index d67a82ca..b4d4b463 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -32,6 +32,12 @@ constructor( fun settings(): Optional = Optional.ofNullable(settings) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ProjectUpdateBody { return ProjectUpdateBody( @@ -144,25 +150,6 @@ constructor( "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && name == other.name && settings == other.settings && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, name, settings, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -182,12 +169,12 @@ constructor( @JvmSynthetic internal fun from(projectUpdateParams: ProjectUpdateParams) = apply { - this.projectId = projectUpdateParams.projectId - this.name = projectUpdateParams.name - this.settings = projectUpdateParams.settings - additionalHeaders(projectUpdateParams.additionalHeaders) - additionalQueryParams(projectUpdateParams.additionalQueryParams) - additionalBodyProperties(projectUpdateParams.additionalBodyProperties) + projectId = projectUpdateParams.projectId + name = projectUpdateParams.name + settings = projectUpdateParams.settings + additionalHeaders = projectUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectUpdateParams.additionalBodyProperties.toMutableMap() } /** Project id */ @@ -332,4 +319,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && name == other.name && settings == other.settings && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, name, settings, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 14ae625a..8a2884de 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -48,6 +48,12 @@ constructor( fun tags(): Optional> = Optional.ofNullable(tags) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): PromptCreateBody { return PromptCreateBody( @@ -205,25 +211,6 @@ constructor( "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PromptCreateParams && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -247,16 +234,16 @@ constructor( @JvmSynthetic internal fun from(promptCreateParams: PromptCreateParams) = apply { - this.name = promptCreateParams.name - this.projectId = promptCreateParams.projectId - this.slug = promptCreateParams.slug - this.description = promptCreateParams.description - this.functionType = promptCreateParams.functionType - this.promptData = promptCreateParams.promptData - this.tags(promptCreateParams.tags ?: listOf()) - additionalHeaders(promptCreateParams.additionalHeaders) - additionalQueryParams(promptCreateParams.additionalQueryParams) - additionalBodyProperties(promptCreateParams.additionalBodyProperties) + name = promptCreateParams.name + projectId = promptCreateParams.projectId + slug = promptCreateParams.slug + description = promptCreateParams.description + functionType = promptCreateParams.functionType + promptData = promptCreateParams.promptData + tags = promptCreateParams.tags?.toMutableList() ?: mutableListOf() + additionalHeaders = promptCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = promptCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the prompt */ @@ -413,7 +400,7 @@ constructor( description, functionType, promptData, - if (tags.size == 0) null else tags.toImmutable(), + tags.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -488,4 +475,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptCreateParams && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 6904cf2f..c4e173e1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun promptId(): String = promptId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(promptDeleteParams: PromptDeleteParams) = apply { - this.promptId = promptDeleteParams.promptId - additionalHeaders(promptDeleteParams.additionalHeaders) - additionalQueryParams(promptDeleteParams.additionalQueryParams) - additionalBodyProperties(promptDeleteParams.additionalBodyProperties) + promptId = promptDeleteParams.promptId + additionalHeaders = promptDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = promptDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = promptDeleteParams.additionalBodyProperties.toMutableMap() } /** Prompt id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 19dd0825..ec56d5cf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -57,6 +57,10 @@ constructor( fun version(): Optional = Optional.ofNullable(version) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -76,23 +80,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -118,18 +105,18 @@ constructor( @JvmSynthetic internal fun from(promptListParams: PromptListParams) = apply { - this.endingBefore = promptListParams.endingBefore - this.ids = promptListParams.ids - this.limit = promptListParams.limit - this.orgName = promptListParams.orgName - this.projectId = promptListParams.projectId - this.projectName = promptListParams.projectName - this.promptName = promptListParams.promptName - this.slug = promptListParams.slug - this.startingAfter = promptListParams.startingAfter - this.version = promptListParams.version - additionalHeaders(promptListParams.additionalHeaders) - additionalQueryParams(promptListParams.additionalQueryParams) + endingBefore = promptListParams.endingBefore + ids = promptListParams.ids + limit = promptListParams.limit + orgName = promptListParams.orgName + projectId = promptListParams.projectId + projectName = promptListParams.projectName + promptName = promptListParams.promptName + slug = promptListParams.slug + startingAfter = promptListParams.startingAfter + version = promptListParams.version + additionalHeaders = promptListParams.additionalHeaders.toBuilder() + additionalQueryParams = promptListParams.additionalQueryParams.toBuilder() } /** @@ -419,4 +406,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index a958d0a1..262ddfc9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -48,6 +48,12 @@ constructor( fun tags(): Optional> = Optional.ofNullable(tags) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): PromptReplaceBody { return PromptReplaceBody( @@ -205,25 +211,6 @@ constructor( "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PromptReplaceParams && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -247,16 +234,16 @@ constructor( @JvmSynthetic internal fun from(promptReplaceParams: PromptReplaceParams) = apply { - this.name = promptReplaceParams.name - this.projectId = promptReplaceParams.projectId - this.slug = promptReplaceParams.slug - this.description = promptReplaceParams.description - this.functionType = promptReplaceParams.functionType - this.promptData = promptReplaceParams.promptData - this.tags(promptReplaceParams.tags ?: listOf()) - additionalHeaders(promptReplaceParams.additionalHeaders) - additionalQueryParams(promptReplaceParams.additionalQueryParams) - additionalBodyProperties(promptReplaceParams.additionalBodyProperties) + name = promptReplaceParams.name + projectId = promptReplaceParams.projectId + slug = promptReplaceParams.slug + description = promptReplaceParams.description + functionType = promptReplaceParams.functionType + promptData = promptReplaceParams.promptData + tags = promptReplaceParams.tags?.toMutableList() ?: mutableListOf() + additionalHeaders = promptReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = promptReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = promptReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the prompt */ @@ -413,7 +400,7 @@ constructor( description, functionType, promptData, - if (tags.size == 0) null else tags.toImmutable(), + tags.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -488,4 +475,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptReplaceParams && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index cfad460f..0feb8a9e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun promptId(): String = promptId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(promptRetrieveParams: PromptRetrieveParams) = apply { - this.promptId = promptRetrieveParams.promptId - additionalHeaders(promptRetrieveParams.additionalHeaders) - additionalQueryParams(promptRetrieveParams.additionalQueryParams) + promptId = promptRetrieveParams.promptId + additionalHeaders = promptRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = promptRetrieveParams.additionalQueryParams.toBuilder() } /** Prompt id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index a95a0ba1..e75d265a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -41,6 +41,12 @@ constructor( fun tags(): Optional> = Optional.ofNullable(tags) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): PromptUpdateBody { return PromptUpdateBody( @@ -181,25 +187,6 @@ constructor( "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, description, name, promptData, slug, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -222,15 +209,15 @@ constructor( @JvmSynthetic internal fun from(promptUpdateParams: PromptUpdateParams) = apply { - this.promptId = promptUpdateParams.promptId - this.description = promptUpdateParams.description - this.name = promptUpdateParams.name - this.promptData = promptUpdateParams.promptData - this.slug = promptUpdateParams.slug - this.tags(promptUpdateParams.tags ?: listOf()) - additionalHeaders(promptUpdateParams.additionalHeaders) - additionalQueryParams(promptUpdateParams.additionalQueryParams) - additionalBodyProperties(promptUpdateParams.additionalBodyProperties) + promptId = promptUpdateParams.promptId + description = promptUpdateParams.description + name = promptUpdateParams.name + promptData = promptUpdateParams.promptData + slug = promptUpdateParams.slug + tags = promptUpdateParams.tags?.toMutableList() ?: mutableListOf() + additionalHeaders = promptUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = promptUpdateParams.additionalBodyProperties.toMutableMap() } /** Prompt id */ @@ -384,10 +371,23 @@ constructor( name, promptData, slug, - if (tags.size == 0) null else tags.toImmutable(), + tags.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, description, name, promptData, slug, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 796c4928..04e373f2 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 @@ -43,6 +43,12 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): RoleCreateBody { return RoleCreateBody( @@ -199,25 +205,6 @@ constructor( "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoleCreateParams && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -239,14 +226,15 @@ constructor( @JvmSynthetic internal fun from(roleCreateParams: RoleCreateParams) = apply { - this.name = roleCreateParams.name - this.description = roleCreateParams.description - this.memberPermissions(roleCreateParams.memberPermissions ?: listOf()) - this.memberRoles(roleCreateParams.memberRoles ?: listOf()) - this.orgName = roleCreateParams.orgName - additionalHeaders(roleCreateParams.additionalHeaders) - additionalQueryParams(roleCreateParams.additionalQueryParams) - additionalBodyProperties(roleCreateParams.additionalBodyProperties) + name = roleCreateParams.name + description = roleCreateParams.description + memberPermissions = + roleCreateParams.memberPermissions?.toMutableList() ?: mutableListOf() + memberRoles = roleCreateParams.memberRoles?.toMutableList() ?: mutableListOf() + orgName = roleCreateParams.orgName + additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = roleCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the role */ @@ -416,8 +404,8 @@ constructor( RoleCreateParams( checkNotNull(name) { "`name` is required but was not set" }, description, - if (memberPermissions.size == 0) null else memberPermissions.toImmutable(), - if (memberRoles.size == 0) null else memberRoles.toImmutable(), + memberPermissions.toImmutable().ifEmpty { null }, + memberRoles.toImmutable().ifEmpty { null }, orgName, additionalHeaders.build(), additionalQueryParams.build(), @@ -728,4 +716,17 @@ constructor( override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleCreateParams && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 76b4a7b1..2722412a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun roleId(): String = roleId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,10 @@ constructor( @JvmSynthetic internal fun from(roleDeleteParams: RoleDeleteParams) = apply { - this.roleId = roleDeleteParams.roleId - additionalHeaders(roleDeleteParams.additionalHeaders) - additionalQueryParams(roleDeleteParams.additionalQueryParams) - additionalBodyProperties(roleDeleteParams.additionalBodyProperties) + roleId = roleDeleteParams.roleId + additionalHeaders = roleDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = roleDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = roleDeleteParams.additionalBodyProperties.toMutableMap() } /** Role id */ @@ -210,4 +197,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 698bbe3d..1ab7b664 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -45,6 +45,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -60,23 +64,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -98,14 +85,14 @@ constructor( @JvmSynthetic internal fun from(roleListParams: RoleListParams) = apply { - this.endingBefore = roleListParams.endingBefore - this.ids = roleListParams.ids - this.limit = roleListParams.limit - this.orgName = roleListParams.orgName - this.roleName = roleListParams.roleName - this.startingAfter = roleListParams.startingAfter - additionalHeaders(roleListParams.additionalHeaders) - additionalQueryParams(roleListParams.additionalQueryParams) + endingBefore = roleListParams.endingBefore + ids = roleListParams.ids + limit = roleListParams.limit + orgName = roleListParams.orgName + roleName = roleListParams.roleName + startingAfter = roleListParams.startingAfter + additionalHeaders = roleListParams.additionalHeaders.toBuilder() + additionalQueryParams = roleListParams.additionalQueryParams.toBuilder() } /** @@ -374,4 +361,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 803994e4..0c08fdc9 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 @@ -43,6 +43,12 @@ constructor( fun orgName(): Optional = Optional.ofNullable(orgName) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): RoleReplaceBody { return RoleReplaceBody( @@ -199,25 +205,6 @@ constructor( "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoleReplaceParams && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -239,14 +226,15 @@ constructor( @JvmSynthetic internal fun from(roleReplaceParams: RoleReplaceParams) = apply { - this.name = roleReplaceParams.name - this.description = roleReplaceParams.description - this.memberPermissions(roleReplaceParams.memberPermissions ?: listOf()) - this.memberRoles(roleReplaceParams.memberRoles ?: listOf()) - this.orgName = roleReplaceParams.orgName - additionalHeaders(roleReplaceParams.additionalHeaders) - additionalQueryParams(roleReplaceParams.additionalQueryParams) - additionalBodyProperties(roleReplaceParams.additionalBodyProperties) + name = roleReplaceParams.name + description = roleReplaceParams.description + memberPermissions = + roleReplaceParams.memberPermissions?.toMutableList() ?: mutableListOf() + memberRoles = roleReplaceParams.memberRoles?.toMutableList() ?: mutableListOf() + orgName = roleReplaceParams.orgName + additionalHeaders = roleReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = roleReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = roleReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the role */ @@ -416,8 +404,8 @@ constructor( RoleReplaceParams( checkNotNull(name) { "`name` is required but was not set" }, description, - if (memberPermissions.size == 0) null else memberPermissions.toImmutable(), - if (memberRoles.size == 0) null else memberRoles.toImmutable(), + memberPermissions.toImmutable().ifEmpty { null }, + memberRoles.toImmutable().ifEmpty { null }, orgName, additionalHeaders.build(), additionalQueryParams.build(), @@ -728,4 +716,17 @@ constructor( override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleReplaceParams && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 36e8c206..6731b49d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun roleId(): String = roleId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(roleRetrieveParams: RoleRetrieveParams) = apply { - this.roleId = roleRetrieveParams.roleId - additionalHeaders(roleRetrieveParams.additionalHeaders) - additionalQueryParams(roleRetrieveParams.additionalQueryParams) + roleId = roleRetrieveParams.roleId + additionalHeaders = roleRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = roleRetrieveParams.additionalQueryParams.toBuilder() } /** Role id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 9f83c745..114321ff 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 @@ -50,6 +50,12 @@ constructor( fun removeMemberRoles(): Optional> = Optional.ofNullable(removeMemberRoles) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): RoleUpdateBody { return RoleUpdateBody( @@ -216,25 +222,6 @@ constructor( "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -258,16 +245,19 @@ constructor( @JvmSynthetic internal fun from(roleUpdateParams: RoleUpdateParams) = apply { - this.roleId = roleUpdateParams.roleId - this.addMemberPermissions(roleUpdateParams.addMemberPermissions ?: listOf()) - this.addMemberRoles(roleUpdateParams.addMemberRoles ?: listOf()) - this.description = roleUpdateParams.description - this.name = roleUpdateParams.name - this.removeMemberPermissions(roleUpdateParams.removeMemberPermissions ?: listOf()) - this.removeMemberRoles(roleUpdateParams.removeMemberRoles ?: listOf()) - additionalHeaders(roleUpdateParams.additionalHeaders) - additionalQueryParams(roleUpdateParams.additionalQueryParams) - additionalBodyProperties(roleUpdateParams.additionalBodyProperties) + roleId = roleUpdateParams.roleId + addMemberPermissions = + roleUpdateParams.addMemberPermissions?.toMutableList() ?: mutableListOf() + addMemberRoles = roleUpdateParams.addMemberRoles?.toMutableList() ?: mutableListOf() + description = roleUpdateParams.description + name = roleUpdateParams.name + removeMemberPermissions = + roleUpdateParams.removeMemberPermissions?.toMutableList() ?: mutableListOf() + removeMemberRoles = + roleUpdateParams.removeMemberRoles?.toMutableList() ?: mutableListOf() + additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = roleUpdateParams.additionalBodyProperties.toMutableMap() } /** Role id */ @@ -446,13 +436,12 @@ constructor( fun build(): RoleUpdateParams = RoleUpdateParams( checkNotNull(roleId) { "`roleId` is required but was not set" }, - if (addMemberPermissions.size == 0) null else addMemberPermissions.toImmutable(), - if (addMemberRoles.size == 0) null else addMemberRoles.toImmutable(), + addMemberPermissions.toImmutable().ifEmpty { null }, + addMemberRoles.toImmutable().ifEmpty { null }, description, name, - if (removeMemberPermissions.size == 0) null - else removeMemberPermissions.toImmutable(), - if (removeMemberRoles.size == 0) null else removeMemberRoles.toImmutable(), + removeMemberPermissions.toImmutable().ifEmpty { null }, + removeMemberRoles.toImmutable().ifEmpty { null }, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -1066,4 +1055,17 @@ constructor( override fun toString() = "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 68168fa1..abc43e69 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -38,6 +38,12 @@ constructor( fun postMessage(): Optional = Optional.ofNullable(postMessage) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): SpanIframeCreateBody { return SpanIframeCreateBody( @@ -178,25 +184,6 @@ constructor( "SpanIframeCreateBody{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanIframeCreateParams && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "SpanIframeCreateParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -218,14 +205,15 @@ constructor( @JvmSynthetic internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = apply { - this.name = spanIframeCreateParams.name - this.projectId = spanIframeCreateParams.projectId - this.url = spanIframeCreateParams.url - this.description = spanIframeCreateParams.description - this.postMessage = spanIframeCreateParams.postMessage - additionalHeaders(spanIframeCreateParams.additionalHeaders) - additionalQueryParams(spanIframeCreateParams.additionalQueryParams) - additionalBodyProperties(spanIframeCreateParams.additionalBodyProperties) + name = spanIframeCreateParams.name + projectId = spanIframeCreateParams.projectId + url = spanIframeCreateParams.url + description = spanIframeCreateParams.description + postMessage = spanIframeCreateParams.postMessage + additionalHeaders = spanIframeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + spanIframeCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the span iframe */ @@ -378,4 +366,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeCreateParams && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "SpanIframeCreateParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt index c52bf2b7..8b118418 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -21,6 +21,12 @@ constructor( fun spanIframeId(): String = spanIframeId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): Optional> { return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) @@ -37,25 +43,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -73,10 +60,11 @@ constructor( @JvmSynthetic internal fun from(spanIframeDeleteParams: SpanIframeDeleteParams) = apply { - this.spanIframeId = spanIframeDeleteParams.spanIframeId - additionalHeaders(spanIframeDeleteParams.additionalHeaders) - additionalQueryParams(spanIframeDeleteParams.additionalQueryParams) - additionalBodyProperties(spanIframeDeleteParams.additionalBodyProperties) + spanIframeId = spanIframeDeleteParams.spanIframeId + additionalHeaders = spanIframeDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + spanIframeDeleteParams.additionalBodyProperties.toMutableMap() } /** SpanIframe id */ @@ -210,4 +198,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 7b8bed0d..b17e23af 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -45,6 +45,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -60,23 +64,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, spanIframeName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -98,14 +85,14 @@ constructor( @JvmSynthetic internal fun from(spanIframeListParams: SpanIframeListParams) = apply { - this.endingBefore = spanIframeListParams.endingBefore - this.ids = spanIframeListParams.ids - this.limit = spanIframeListParams.limit - this.orgName = spanIframeListParams.orgName - this.spanIframeName = spanIframeListParams.spanIframeName - this.startingAfter = spanIframeListParams.startingAfter - additionalHeaders(spanIframeListParams.additionalHeaders) - additionalQueryParams(spanIframeListParams.additionalQueryParams) + endingBefore = spanIframeListParams.endingBefore + ids = spanIframeListParams.ids + limit = spanIframeListParams.limit + orgName = spanIframeListParams.orgName + spanIframeName = spanIframeListParams.spanIframeName + startingAfter = spanIframeListParams.startingAfter + additionalHeaders = spanIframeListParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeListParams.additionalQueryParams.toBuilder() } /** @@ -374,4 +361,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, spanIframeName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index 3940b04c..2c6f3ebf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -38,6 +38,12 @@ constructor( fun postMessage(): Optional = Optional.ofNullable(postMessage) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): SpanIframeReplaceBody { return SpanIframeReplaceBody( @@ -178,25 +184,6 @@ constructor( "SpanIframeReplaceBody{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanIframeReplaceParams && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "SpanIframeReplaceParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -218,14 +205,15 @@ constructor( @JvmSynthetic internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = apply { - this.name = spanIframeReplaceParams.name - this.projectId = spanIframeReplaceParams.projectId - this.url = spanIframeReplaceParams.url - this.description = spanIframeReplaceParams.description - this.postMessage = spanIframeReplaceParams.postMessage - additionalHeaders(spanIframeReplaceParams.additionalHeaders) - additionalQueryParams(spanIframeReplaceParams.additionalQueryParams) - additionalBodyProperties(spanIframeReplaceParams.additionalBodyProperties) + name = spanIframeReplaceParams.name + projectId = spanIframeReplaceParams.projectId + url = spanIframeReplaceParams.url + description = spanIframeReplaceParams.description + postMessage = spanIframeReplaceParams.postMessage + additionalHeaders = spanIframeReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + spanIframeReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the span iframe */ @@ -378,4 +366,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeReplaceParams && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "SpanIframeReplaceParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt index 8dc33539..9878d60a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun spanIframeId(): String = spanIframeId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(spanIframeRetrieveParams: SpanIframeRetrieveParams) = apply { - this.spanIframeId = spanIframeRetrieveParams.spanIframeId - additionalHeaders(spanIframeRetrieveParams.additionalHeaders) - additionalQueryParams(spanIframeRetrieveParams.additionalQueryParams) + spanIframeId = spanIframeRetrieveParams.spanIframeId + additionalHeaders = spanIframeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeRetrieveParams.additionalQueryParams.toBuilder() } /** SpanIframe id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 03cef145..57143fee 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -35,6 +35,12 @@ constructor( fun url(): Optional = Optional.ofNullable(url) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): SpanIframeUpdateBody { return SpanIframeUpdateBody( @@ -158,25 +164,6 @@ constructor( "SpanIframeUpdateBody{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && name == other.name && postMessage == other.postMessage && url == other.url && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, name, postMessage, url, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "SpanIframeUpdateParams{spanIframeId=$spanIframeId, name=$name, postMessage=$postMessage, url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -197,13 +184,14 @@ constructor( @JvmSynthetic internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = apply { - this.spanIframeId = spanIframeUpdateParams.spanIframeId - this.name = spanIframeUpdateParams.name - this.postMessage = spanIframeUpdateParams.postMessage - this.url = spanIframeUpdateParams.url - additionalHeaders(spanIframeUpdateParams.additionalHeaders) - additionalQueryParams(spanIframeUpdateParams.additionalQueryParams) - additionalBodyProperties(spanIframeUpdateParams.additionalBodyProperties) + spanIframeId = spanIframeUpdateParams.spanIframeId + name = spanIframeUpdateParams.name + postMessage = spanIframeUpdateParams.postMessage + url = spanIframeUpdateParams.url + additionalHeaders = spanIframeUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + spanIframeUpdateParams.additionalBodyProperties.toMutableMap() } /** SpanIframe id */ @@ -352,4 +340,17 @@ constructor( additionalBodyProperties.toImmutable(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && name == other.name && postMessage == other.postMessage && url == other.url && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, name, postMessage, url, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "SpanIframeUpdateParams{spanIframeId=$spanIframeId, name=$name, postMessage=$postMessage, url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 823beb22..a2e5425f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -14,26 +14,13 @@ constructor( private val additionalQueryParams: QueryParams, ) { - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams - fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - override fun toString() = - "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -50,8 +37,8 @@ constructor( @JvmSynthetic internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = apply { - additionalHeaders(topLevelHelloWorldParams.additionalHeaders) - additionalQueryParams(topLevelHelloWorldParams.additionalQueryParams) + additionalHeaders = topLevelHelloWorldParams.additionalHeaders.toBuilder() + additionalQueryParams = topLevelHelloWorldParams.additionalQueryParams.toBuilder() } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -155,4 +142,17 @@ constructor( fun build(): TopLevelHelloWorldParams = TopLevelHelloWorldParams(additionalHeaders.build(), additionalQueryParams.build()) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index df621a18..dd9bc6a5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -51,6 +51,10 @@ constructor( fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -68,23 +72,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -108,16 +95,16 @@ constructor( @JvmSynthetic internal fun from(userListParams: UserListParams) = apply { - this.email = userListParams.email - this.endingBefore = userListParams.endingBefore - this.familyName = userListParams.familyName - this.givenName = userListParams.givenName - this.ids = userListParams.ids - this.limit = userListParams.limit - this.orgName = userListParams.orgName - this.startingAfter = userListParams.startingAfter - additionalHeaders(userListParams.additionalHeaders) - additionalQueryParams(userListParams.additionalQueryParams) + email = userListParams.email + endingBefore = userListParams.endingBefore + familyName = userListParams.familyName + givenName = userListParams.givenName + ids = userListParams.ids + limit = userListParams.limit + orgName = userListParams.orgName + startingAfter = userListParams.startingAfter + additionalHeaders = userListParams.additionalHeaders.toBuilder() + additionalQueryParams = userListParams.additionalQueryParams.toBuilder() } /** @@ -776,4 +763,17 @@ constructor( } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 25d447af..6ec27bd7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -17,6 +17,10 @@ constructor( fun userId(): String = userId + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -28,23 +32,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -61,9 +48,9 @@ constructor( @JvmSynthetic internal fun from(userRetrieveParams: UserRetrieveParams) = apply { - this.userId = userRetrieveParams.userId - additionalHeaders(userRetrieveParams.additionalHeaders) - additionalQueryParams(userRetrieveParams.additionalQueryParams) + userId = userRetrieveParams.userId + additionalHeaders = userRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = userRetrieveParams.additionalQueryParams.toBuilder() } /** User id */ @@ -174,4 +161,17 @@ constructor( additionalQueryParams.build(), ) } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 fdec4491..09431370 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 @@ -52,6 +52,12 @@ constructor( fun viewData(): Optional = Optional.ofNullable(viewData) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ViewCreateBody { return ViewCreateBody( @@ -222,25 +228,6 @@ constructor( "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ViewCreateParams && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -265,17 +252,17 @@ constructor( @JvmSynthetic internal fun from(viewCreateParams: ViewCreateParams) = apply { - this.name = viewCreateParams.name - this.objectId = viewCreateParams.objectId - this.objectType = viewCreateParams.objectType - this.viewType = viewCreateParams.viewType - this.deletedAt = viewCreateParams.deletedAt - this.options = viewCreateParams.options - this.userId = viewCreateParams.userId - this.viewData = viewCreateParams.viewData - additionalHeaders(viewCreateParams.additionalHeaders) - additionalQueryParams(viewCreateParams.additionalQueryParams) - additionalBodyProperties(viewCreateParams.additionalBodyProperties) + name = viewCreateParams.name + objectId = viewCreateParams.objectId + objectType = viewCreateParams.objectType + viewType = viewCreateParams.viewType + deletedAt = viewCreateParams.deletedAt + options = viewCreateParams.options + userId = viewCreateParams.userId + viewData = viewCreateParams.viewData + additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = viewCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the view */ @@ -641,4 +628,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewCreateParams && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 f2218f5f..000f4ab3 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 @@ -35,6 +35,12 @@ constructor( fun objectType(): ObjectType = objectType + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ViewDeleteBody { return ViewDeleteBody( @@ -142,25 +148,6 @@ constructor( "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -180,12 +167,12 @@ constructor( @JvmSynthetic internal fun from(viewDeleteParams: ViewDeleteParams) = apply { - this.viewId = viewDeleteParams.viewId - this.objectId = viewDeleteParams.objectId - this.objectType = viewDeleteParams.objectType - additionalHeaders(viewDeleteParams.additionalHeaders) - additionalQueryParams(viewDeleteParams.additionalQueryParams) - additionalBodyProperties(viewDeleteParams.additionalBodyProperties) + viewId = viewDeleteParams.viewId + objectId = viewDeleteParams.objectId + objectType = viewDeleteParams.objectType + additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = viewDeleteParams.additionalBodyProperties.toMutableMap() } /** View id */ @@ -438,4 +425,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 888e4947..9f97f328 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 @@ -54,6 +54,10 @@ constructor( fun viewType(): Optional = Optional.ofNullable(viewType) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -71,23 +75,6 @@ constructor( return queryParams.build() } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -111,16 +98,16 @@ constructor( @JvmSynthetic internal fun from(viewListParams: ViewListParams) = apply { - this.objectId = viewListParams.objectId - this.objectType = viewListParams.objectType - this.endingBefore = viewListParams.endingBefore - this.ids = viewListParams.ids - this.limit = viewListParams.limit - this.startingAfter = viewListParams.startingAfter - this.viewName = viewListParams.viewName - this.viewType = viewListParams.viewType - additionalHeaders(viewListParams.additionalHeaders) - additionalQueryParams(viewListParams.additionalQueryParams) + objectId = viewListParams.objectId + objectType = viewListParams.objectType + endingBefore = viewListParams.endingBefore + ids = viewListParams.ids + limit = viewListParams.limit + startingAfter = viewListParams.startingAfter + viewName = viewListParams.viewName + viewType = viewListParams.viewType + additionalHeaders = viewListParams.additionalHeaders.toBuilder() + additionalQueryParams = viewListParams.additionalQueryParams.toBuilder() } /** The id of the object the ACL applies to */ @@ -601,4 +588,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 24c3fc69..73d0660c 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 @@ -52,6 +52,12 @@ constructor( fun viewData(): Optional = Optional.ofNullable(viewData) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ViewReplaceBody { return ViewReplaceBody( @@ -222,25 +228,6 @@ constructor( "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ViewReplaceParams && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -265,17 +252,17 @@ constructor( @JvmSynthetic internal fun from(viewReplaceParams: ViewReplaceParams) = apply { - this.name = viewReplaceParams.name - this.objectId = viewReplaceParams.objectId - this.objectType = viewReplaceParams.objectType - this.viewType = viewReplaceParams.viewType - this.deletedAt = viewReplaceParams.deletedAt - this.options = viewReplaceParams.options - this.userId = viewReplaceParams.userId - this.viewData = viewReplaceParams.viewData - additionalHeaders(viewReplaceParams.additionalHeaders) - additionalQueryParams(viewReplaceParams.additionalQueryParams) - additionalBodyProperties(viewReplaceParams.additionalBodyProperties) + name = viewReplaceParams.name + objectId = viewReplaceParams.objectId + objectType = viewReplaceParams.objectType + viewType = viewReplaceParams.viewType + deletedAt = viewReplaceParams.deletedAt + options = viewReplaceParams.options + userId = viewReplaceParams.userId + viewData = viewReplaceParams.viewData + additionalHeaders = viewReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = viewReplaceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = viewReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the view */ @@ -641,4 +628,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewReplaceParams && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 879f7e58..13133781 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 @@ -28,6 +28,10 @@ constructor( fun objectType(): ObjectType = objectType + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic @@ -46,23 +50,6 @@ constructor( } } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" - fun toBuilder() = Builder().from(this) companion object { @@ -81,11 +68,11 @@ constructor( @JvmSynthetic internal fun from(viewRetrieveParams: ViewRetrieveParams) = apply { - this.viewId = viewRetrieveParams.viewId - this.objectId = viewRetrieveParams.objectId - this.objectType = viewRetrieveParams.objectType - additionalHeaders(viewRetrieveParams.additionalHeaders) - additionalQueryParams(viewRetrieveParams.additionalQueryParams) + viewId = viewRetrieveParams.viewId + objectId = viewRetrieveParams.objectId + objectType = viewRetrieveParams.objectType + additionalHeaders = viewRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = viewRetrieveParams.additionalQueryParams.toBuilder() } /** View id */ @@ -315,4 +302,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 5338ce8d..5a7e0a69 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 @@ -51,6 +51,12 @@ constructor( fun viewType(): Optional = Optional.ofNullable(viewType) + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun getBody(): ViewUpdateBody { return ViewUpdateBody( @@ -216,25 +222,6 @@ constructor( "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" } - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, name, options, userId, viewData, viewType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" - fun toBuilder() = Builder().from(this) companion object { @@ -259,17 +246,17 @@ constructor( @JvmSynthetic internal fun from(viewUpdateParams: ViewUpdateParams) = apply { - this.viewId = viewUpdateParams.viewId - this.objectId = viewUpdateParams.objectId - this.objectType = viewUpdateParams.objectType - this.name = viewUpdateParams.name - this.options = viewUpdateParams.options - this.userId = viewUpdateParams.userId - this.viewData = viewUpdateParams.viewData - this.viewType = viewUpdateParams.viewType - additionalHeaders(viewUpdateParams.additionalHeaders) - additionalQueryParams(viewUpdateParams.additionalQueryParams) - additionalBodyProperties(viewUpdateParams.additionalBodyProperties) + viewId = viewUpdateParams.viewId + objectId = viewUpdateParams.objectId + objectType = viewUpdateParams.objectType + name = viewUpdateParams.name + options = viewUpdateParams.options + userId = viewUpdateParams.userId + viewData = viewUpdateParams.viewData + viewType = viewUpdateParams.viewType + additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = viewUpdateParams.additionalBodyProperties.toMutableMap() } /** View id */ @@ -635,4 +622,17 @@ constructor( fun asString(): String = _value().asStringOrThrow() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, name, options, userId, viewData, viewType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } From 0bad87e1644242cfdbe21d92bf19d138536900f0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:53:33 +0000 Subject: [PATCH 37/87] feat(client): add logging when debug env is set (#106) --- README.md | 16 +++++++++ .../build.gradle.kts | 1 + .../api/client/okhttp/OkHttpClient.kt | 33 ++++++++++++++----- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 31a23686..dd95efbb 100644 --- a/README.md +++ b/README.md @@ -301,6 +301,22 @@ get a map of untyped fields of type `Map`. You can then acces `._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. +## Logging + +We use the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). + +You can enable logging by setting the environment variable `BRAINTRUST_LOG` to `info`. + +```sh +$ export BRAINTRUST_LOG=info +``` + +Or to `debug` for more verbose logging. + +```sh +$ export BRAINTRUST_LOG=debug +``` + ## Semantic versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: diff --git a/braintrust-java-client-okhttp/build.gradle.kts b/braintrust-java-client-okhttp/build.gradle.kts index f708b5aa..8408ea37 100755 --- a/braintrust-java-client-okhttp/build.gradle.kts +++ b/braintrust-java-client-okhttp/build.gradle.kts @@ -7,6 +7,7 @@ dependencies { api(project(":braintrust-java-core")) implementation("com.squareup.okhttp3:okhttp:4.12.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.25.3") diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index f052fc61..9d9f81c9 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -23,6 +23,7 @@ import okhttp3.Request import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response +import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink class OkHttpClient @@ -30,14 +31,30 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val HttpClient { private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { - val timeout = requestOptions.timeout ?: return okHttpClient - return okHttpClient - .newBuilder() - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) - .build() + val clientBuilder = okHttpClient.newBuilder() + + val logLevel = + when (System.getenv("BRAINTRUST_LOG")?.lowercase()) { + "info" -> HttpLoggingInterceptor.Level.BASIC + "debug" -> HttpLoggingInterceptor.Level.BODY + else -> null + } + if (logLevel != null) { + clientBuilder.addNetworkInterceptor( + HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + ) + } + + val timeout = requestOptions.timeout + if (timeout != null) { + clientBuilder + .connectTimeout(timeout) + .readTimeout(timeout) + .writeTimeout(timeout) + .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + } + + return clientBuilder.build() } override fun execute( From 893c7c9d9397aa0b5abd0b13f8d3d889aa2c6636 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2025 17:00:10 +0000 Subject: [PATCH 38/87] feat(api): manual updates (#107) --- .github/workflows/publish-sonatype.yml | 6 +- .github/workflows/release-doctor.yml | 1 - LICENSE | 2 +- README.md | 182 +- .../client/okhttp/BraintrustOkHttpClient.kt | 6 +- .../okhttp/BraintrustOkHttpClientAsync.kt | 6 +- .../api/client/okhttp/OkHttpClient.kt | 111 +- .../api/client/BraintrustClient.kt | 56 +- .../api/client/BraintrustClientAsync.kt | 56 +- .../api/client/BraintrustClientAsyncImpl.kt | 47 +- .../api/client/BraintrustClientImpl.kt | 47 +- .../com/braintrustdata/api/core/Check.kt | 29 + .../braintrustdata/api/core/ClientOptions.kt | 28 +- .../com/braintrustdata/api/core/Params.kt | 16 + .../braintrustdata/api/core/PrepareRequest.kt | 24 + .../braintrustdata/api/core/RequestOptions.kt | 3 +- .../com/braintrustdata/api/core/Utils.kt | 4 +- .../com/braintrustdata/api/core/Values.kt | 2 + .../braintrustdata/api/core/http/Headers.kt | 2 +- .../api/core/http/HttpRequest.kt | 5 +- .../api/core/http/QueryParams.kt | 2 +- .../api/core/http/RetryingHttpClient.kt | 41 +- .../api/errors/BraintrustError.kt | 14 +- .../api/models/{AiSecret.kt => AISecret.kt} | 216 +- .../com/braintrustdata/api/models/Acl.kt | 549 +-- .../api/models/AclBatchUpdateParams.kt | 1403 ++++++-- .../api/models/AclBatchUpdateResponse.kt | 120 +- .../api/models/AclCreateParams.kt | 739 ++-- .../api/models/AclDeleteParams.kt | 23 +- .../api/models/AclFindAndDeleteParams.kt | 737 ++-- .../braintrustdata/api/models/AclListPage.kt | 31 +- .../api/models/AclListPageAsync.kt | 31 +- .../api/models/AclListParams.kt | 201 +- .../api/models/AclRetrieveParams.kt | 18 +- .../api/models/AiSecretCreateParams.kt | 389 ++- .../api/models/AiSecretDeleteParams.kt | 23 +- .../api/models/AiSecretFindAndDeleteParams.kt | 225 +- .../api/models/AiSecretListPage.kt | 31 +- .../api/models/AiSecretListPageAsync.kt | 31 +- .../api/models/AiSecretListParams.kt | 165 +- .../api/models/AiSecretReplaceParams.kt | 389 ++- .../api/models/AiSecretRetrieveParams.kt | 18 +- .../api/models/AiSecretUpdateParams.kt | 299 +- .../com/braintrustdata/api/models/ApiKey.kt | 171 +- .../api/models/ApiKeyCreateParams.kt | 227 +- .../api/models/ApiKeyDeleteParams.kt | 23 +- .../api/models/ApiKeyListPage.kt | 31 +- .../api/models/ApiKeyListPageAsync.kt | 31 +- .../api/models/ApiKeyListParams.kt | 122 +- .../api/models/ApiKeyRetrieveParams.kt | 18 +- .../models/ChatCompletionContentPartImage.kt | 249 +- .../models/ChatCompletionContentPartText.kt | 134 +- .../models/ChatCompletionMessageToolCall.kt | 201 +- .../braintrustdata/api/models/CodeBundle.kt | 929 +++-- .../api/models/CreateApiKeyOutput.kt | 191 +- .../api/models/CrossObjectInsertResponse.kt | 207 +- .../braintrustdata/api/models/DataSummary.kt | 56 +- .../com/braintrustdata/api/models/Dataset.kt | 258 +- .../api/models/DatasetCreateParams.kt | 315 +- .../api/models/DatasetDeleteParams.kt | 23 +- .../braintrustdata/api/models/DatasetEvent.kt | 655 ++-- .../api/models/DatasetFeedbackParams.kt | 179 +- .../api/models/DatasetFetchParams.kt | 147 +- .../api/models/DatasetFetchPostParams.kt | 714 +++- .../api/models/DatasetInsertParams.kt | 178 +- .../api/models/DatasetListPage.kt | 31 +- .../api/models/DatasetListPageAsync.kt | 31 +- .../api/models/DatasetListParams.kt | 134 +- .../api/models/DatasetRetrieveParams.kt | 18 +- .../api/models/DatasetSummarizeParams.kt | 34 +- .../api/models/DatasetUpdateParams.kt | 285 +- .../com/braintrustdata/api/models/EnvVar.kt | 231 +- .../api/models/EnvVarCreateParams.kt | 344 +- .../api/models/EnvVarDeleteParams.kt | 23 +- .../api/models/EnvVarListParams.kt | 159 +- .../api/models/EnvVarListResponse.kt | 71 +- .../api/models/EnvVarReplaceParams.kt | 344 +- .../api/models/EnvVarRetrieveParams.kt | 18 +- .../api/models/EnvVarUpdateParams.kt | 202 +- .../api/models/EvalCreateParams.kt | 3007 ++++++++++++----- .../braintrustdata/api/models/Experiment.kt | 476 +-- .../api/models/ExperimentCreateParams.kt | 696 ++-- .../api/models/ExperimentDeleteParams.kt | 23 +- .../api/models/ExperimentEvent.kt | 1566 +++++---- .../api/models/ExperimentFeedbackParams.kt | 180 +- .../api/models/ExperimentFetchParams.kt | 147 +- .../api/models/ExperimentFetchPostParams.kt | 714 +++- .../api/models/ExperimentInsertParams.kt | 179 +- .../api/models/ExperimentListPage.kt | 32 +- .../api/models/ExperimentListPageAsync.kt | 32 +- .../api/models/ExperimentListParams.kt | 137 +- .../api/models/ExperimentRetrieveParams.kt | 18 +- .../api/models/ExperimentSummarizeParams.kt | 55 +- .../api/models/ExperimentUpdateParams.kt | 572 +++- .../api/models/FeedbackDatasetItem.kt | 238 +- .../api/models/FeedbackExperimentItem.kt | 370 +- .../api/models/FeedbackProjectLogsItem.kt | 370 +- .../api/models/FeedbackResponseSchema.kt | 113 +- .../api/models/FetchDatasetEventsResponse.kt | 90 +- .../models/FetchExperimentEventsResponse.kt | 90 +- .../models/FetchProjectLogsEventsResponse.kt | 93 +- .../com/braintrustdata/api/models/Function.kt | 1931 +++++++---- .../api/models/FunctionCreateParams.kt | 1959 +++++++---- .../api/models/FunctionDeleteParams.kt | 23 +- .../api/models/FunctionInvokeParams.kt | 2167 ++++++++---- .../api/models/FunctionInvokeResponse.kt | 33 +- .../api/models/FunctionListPage.kt | 31 +- .../api/models/FunctionListPageAsync.kt | 31 +- .../api/models/FunctionListParams.kt | 158 +- .../api/models/FunctionReplaceParams.kt | 1959 +++++++---- .../api/models/FunctionRetrieveParams.kt | 18 +- .../api/models/FunctionUpdateParams.kt | 1469 +++++--- .../com/braintrustdata/api/models/Group.kt | 326 +- .../api/models/GroupCreateParams.kt | 465 ++- .../api/models/GroupDeleteParams.kt | 23 +- .../api/models/GroupListPage.kt | 31 +- .../api/models/GroupListPageAsync.kt | 31 +- .../api/models/GroupListParams.kt | 124 +- .../api/models/GroupReplaceParams.kt | 465 ++- .../api/models/GroupRetrieveParams.kt | 18 +- .../api/models/GroupUpdateParams.kt | 504 ++- .../api/models/InsertDatasetEvent.kt | 702 ++-- .../api/models/InsertEventsResponse.kt | 71 +- .../api/models/InsertExperimentEvent.kt | 1848 ++++++---- .../api/models/InsertProjectLogsEvent.kt | 1652 +++++---- .../api/models/MetricSummary.kt | 178 +- .../api/models/OnlineScoreConfig.kt | 487 ++- .../braintrustdata/api/models/Organization.kt | 180 +- .../api/models/OrganizationDeleteParams.kt | 23 +- .../api/models/OrganizationListPage.kt | 32 +- .../api/models/OrganizationListPageAsync.kt | 32 +- .../api/models/OrganizationListParams.kt | 118 +- .../models/OrganizationMemberUpdateParams.kt | 787 +++-- .../api/models/OrganizationRetrieveParams.kt | 18 +- .../api/models/OrganizationUpdateParams.kt | 324 +- .../models/PatchOrganizationMembersOutput.kt | 169 +- .../com/braintrustdata/api/models/Project.kt | 189 +- .../api/models/ProjectCreateParams.kt | 227 +- .../api/models/ProjectDeleteParams.kt | 23 +- .../api/models/ProjectListPage.kt | 31 +- .../api/models/ProjectListPageAsync.kt | 31 +- .../api/models/ProjectListParams.kt | 124 +- .../api/models/ProjectLogFeedbackParams.kt | 180 +- .../api/models/ProjectLogFetchParams.kt | 147 +- .../api/models/ProjectLogFetchPostParams.kt | 714 +++- .../api/models/ProjectLogInsertParams.kt | 179 +- .../api/models/ProjectLogsEvent.kt | 1562 +++++---- .../api/models/ProjectRetrieveParams.kt | 18 +- .../braintrustdata/api/models/ProjectScore.kt | 494 ++- .../api/models/ProjectScoreCategory.kt | 62 +- .../api/models/ProjectScoreConfig.kt | 169 +- .../api/models/ProjectScoreCreateParams.kt | 599 ++-- .../api/models/ProjectScoreDeleteParams.kt | 23 +- .../api/models/ProjectScoreListPage.kt | 32 +- .../api/models/ProjectScoreListPageAsync.kt | 32 +- .../api/models/ProjectScoreListParams.kt | 360 +- .../api/models/ProjectScoreReplaceParams.kt | 600 ++-- .../api/models/ProjectScoreRetrieveParams.kt | 18 +- .../api/models/ProjectScoreUpdateParams.kt | 572 +++- .../api/models/ProjectSettings.kt | 54 +- .../braintrustdata/api/models/ProjectTag.kt | 193 +- .../api/models/ProjectTagCreateParams.kt | 284 +- .../api/models/ProjectTagDeleteParams.kt | 23 +- .../api/models/ProjectTagListPage.kt | 32 +- .../api/models/ProjectTagListPageAsync.kt | 32 +- .../api/models/ProjectTagListParams.kt | 137 +- .../api/models/ProjectTagReplaceParams.kt | 285 +- .../api/models/ProjectTagRetrieveParams.kt | 18 +- .../api/models/ProjectTagUpdateParams.kt | 254 +- .../api/models/ProjectUpdateParams.kt | 231 +- .../com/braintrustdata/api/models/Prompt.kt | 520 +-- .../api/models/PromptCreateParams.kt | 502 ++- .../braintrustdata/api/models/PromptData.kt | 2517 +++++++++----- .../api/models/PromptDeleteParams.kt | 23 +- .../api/models/PromptListPage.kt | 31 +- .../api/models/PromptListPageAsync.kt | 31 +- .../api/models/PromptListParams.kt | 158 +- .../api/models/PromptOptions.kt | 2466 ++++++++------ .../api/models/PromptReplaceParams.kt | 502 ++- .../api/models/PromptRetrieveParams.kt | 18 +- .../api/models/PromptUpdateParams.kt | 364 +- .../com/braintrustdata/api/models/RepoInfo.kt | 295 +- .../com/braintrustdata/api/models/Role.kt | 599 ++-- .../api/models/RoleCreateParams.kt | 725 ++-- .../api/models/RoleDeleteParams.kt | 23 +- .../braintrustdata/api/models/RoleListPage.kt | 31 +- .../api/models/RoleListPageAsync.kt | 31 +- .../api/models/RoleListParams.kt | 124 +- .../api/models/RoleReplaceParams.kt | 725 ++-- .../api/models/RoleRetrieveParams.kt | 18 +- .../api/models/RoleUpdateParams.kt | 1039 ++++-- .../braintrustdata/api/models/ScoreSummary.kt | 150 +- .../api/models/SpanAttributes.kt | 134 +- .../braintrustdata/api/models/SpanIFrame.kt | 252 +- .../api/models/SpanIframeCreateParams.kt | 362 +- .../api/models/SpanIframeDeleteParams.kt | 23 +- .../api/models/SpanIframeListPage.kt | 32 +- .../api/models/SpanIframeListPageAsync.kt | 32 +- .../api/models/SpanIframeListParams.kt | 125 +- .../api/models/SpanIframeReplaceParams.kt | 362 +- .../api/models/SpanIframeRetrieveParams.kt | 18 +- .../api/models/SpanIframeUpdateParams.kt | 289 +- .../api/models/SummarizeDatasetResponse.kt | 167 +- .../api/models/SummarizeExperimentResponse.kt | 288 +- .../api/models/TopLevelHelloWorldParams.kt | 14 +- .../com/braintrustdata/api/models/User.kt | 197 +- .../braintrustdata/api/models/UserListPage.kt | 31 +- .../api/models/UserListPageAsync.kt | 31 +- .../api/models/UserListParams.kt | 262 +- .../api/models/UserRetrieveParams.kt | 18 +- .../com/braintrustdata/api/models/View.kt | 433 ++- .../api/models/ViewCreateParams.kt | 609 ++-- .../com/braintrustdata/api/models/ViewData.kt | 49 +- .../api/models/ViewDataSearch.kt | 191 +- .../api/models/ViewDeleteParams.kt | 282 +- .../braintrustdata/api/models/ViewListPage.kt | 31 +- .../api/models/ViewListPageAsync.kt | 31 +- .../api/models/ViewListParams.kt | 289 +- .../braintrustdata/api/models/ViewOptions.kt | 197 +- .../api/models/ViewReplaceParams.kt | 609 ++-- .../api/models/ViewRetrieveParams.kt | 110 +- .../api/models/ViewUpdateParams.kt | 566 +++- .../api/services/async/AclServiceAsyncImpl.kt | 157 +- .../async/AiSecretServiceAsyncImpl.kt | 183 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 105 +- .../services/async/DatasetServiceAsyncImpl.kt | 257 +- .../services/async/EnvVarServiceAsyncImpl.kt | 155 +- .../services/async/EvalServiceAsyncImpl.kt | 29 +- .../async/ExperimentServiceAsyncImpl.kt | 257 +- .../async/FunctionServiceAsyncImpl.kt | 184 +- .../services/async/GroupServiceAsyncImpl.kt | 157 +- .../async/OrganizationServiceAsyncImpl.kt | 105 +- .../async/ProjectScoreServiceAsyncImpl.kt | 157 +- .../services/async/ProjectServiceAsyncImpl.kt | 131 +- .../async/ProjectTagServiceAsyncImpl.kt | 157 +- .../services/async/PromptServiceAsyncImpl.kt | 157 +- .../services/async/RoleServiceAsyncImpl.kt | 157 +- .../async/SpanIframeServiceAsyncImpl.kt | 157 +- .../async/TopLevelServiceAsyncImpl.kt | 15 +- .../services/async/UserServiceAsyncImpl.kt | 53 +- .../services/async/ViewServiceAsyncImpl.kt | 157 +- .../organizations/MemberServiceAsyncImpl.kt | 29 +- .../async/projects/LogServiceAsyncImpl.kt | 105 +- .../api/services/blocking/AclServiceImpl.kt | 133 +- .../services/blocking/AiSecretServiceImpl.kt | 155 +- .../services/blocking/ApiKeyServiceImpl.kt | 89 +- .../services/blocking/DatasetServiceImpl.kt | 217 +- .../services/blocking/EnvVarServiceImpl.kt | 131 +- .../api/services/blocking/EvalServiceImpl.kt | 25 +- .../blocking/ExperimentServiceImpl.kt | 217 +- .../services/blocking/FunctionServiceImpl.kt | 156 +- .../api/services/blocking/GroupServiceImpl.kt | 133 +- .../blocking/OrganizationServiceImpl.kt | 89 +- .../blocking/ProjectScoreServiceImpl.kt | 133 +- .../services/blocking/ProjectServiceImpl.kt | 111 +- .../blocking/ProjectTagServiceImpl.kt | 133 +- .../services/blocking/PromptServiceImpl.kt | 133 +- .../api/services/blocking/RoleServiceImpl.kt | 133 +- .../blocking/SpanIframeServiceImpl.kt | 133 +- .../services/blocking/TopLevelServiceImpl.kt | 13 +- .../api/services/blocking/UserServiceImpl.kt | 45 +- .../api/services/blocking/ViewServiceImpl.kt | 133 +- .../organizations/MemberServiceImpl.kt | 25 +- .../blocking/projects/LogServiceImpl.kt | 89 +- .../api/core/http/RetryingHttpClientTest.kt | 139 +- .../api/core/http/SerializerTest.kt | 3 +- .../braintrustdata/api/models/AISecretTest.kt | 14 +- .../api/models/AclBatchUpdateParamsTest.kt | 89 +- .../api/models/AclBatchUpdateResponseTest.kt | 56 +- .../api/models/AclCreateParamsTest.kt | 21 +- .../api/models/AclDeleteParamsTest.kt | 3 +- .../api/models/AclFindAndDeleteParamsTest.kt | 21 +- .../api/models/AclListParamsTest.kt | 21 +- .../api/models/AclRetrieveParamsTest.kt | 3 +- .../api/models/AiSecretCreateParamsTest.kt | 37 +- .../api/models/AiSecretDeleteParamsTest.kt | 3 +- .../models/AiSecretFindAndDeleteParamsTest.kt | 13 +- .../api/models/AiSecretListParamsTest.kt | 25 +- .../api/models/AiSecretReplaceParamsTest.kt | 37 +- .../api/models/AiSecretRetrieveParamsTest.kt | 3 +- .../api/models/AiSecretUpdateParamsTest.kt | 37 +- .../api/models/ApiKeyCreateParamsTest.kt | 13 +- .../api/models/ApiKeyDeleteParamsTest.kt | 3 +- .../api/models/ApiKeyListParamsTest.kt | 21 +- .../api/models/ApiKeyRetrieveParamsTest.kt | 3 +- .../api/models/CodeBundleTest.kt | 32 +- .../models/CrossObjectInsertResponseTest.kt | 55 +- .../api/models/DataSummaryTest.kt | 4 +- .../api/models/DatasetCreateParamsTest.kt | 33 +- .../api/models/DatasetDeleteParamsTest.kt | 3 +- .../api/models/DatasetEventTest.kt | 25 +- .../api/models/DatasetFeedbackParamsTest.kt | 68 +- .../api/models/DatasetFetchParamsTest.kt | 17 +- .../api/models/DatasetFetchPostParamsTest.kt | 25 +- .../api/models/DatasetInsertParamsTest.kt | 107 +- .../api/models/DatasetListParamsTest.kt | 21 +- .../api/models/DatasetRetrieveParamsTest.kt | 3 +- .../api/models/DatasetSummarizeParamsTest.kt | 11 +- .../braintrustdata/api/models/DatasetTest.kt | 14 +- .../api/models/DatasetUpdateParamsTest.kt | 35 +- .../api/models/EnvVarCreateParamsTest.kt | 13 +- .../api/models/EnvVarDeleteParamsTest.kt | 3 +- .../api/models/EnvVarListParamsTest.kt | 21 +- .../api/models/EnvVarListResponseTest.kt | 20 +- .../api/models/EnvVarReplaceParamsTest.kt | 13 +- .../api/models/EnvVarRetrieveParamsTest.kt | 3 +- .../api/models/EnvVarUpdateParamsTest.kt | 13 +- .../api/models/EvalCreateParamsTest.kt | 151 +- .../api/models/ExperimentCreateParamsTest.kt | 47 +- .../api/models/ExperimentDeleteParamsTest.kt | 3 +- .../api/models/ExperimentEventTest.kt | 84 +- .../models/ExperimentFeedbackParamsTest.kt | 93 +- .../api/models/ExperimentFetchParamsTest.kt | 17 +- .../models/ExperimentFetchPostParamsTest.kt | 25 +- .../api/models/ExperimentInsertParamsTest.kt | 222 +- .../api/models/ExperimentListParamsTest.kt | 21 +- .../models/ExperimentRetrieveParamsTest.kt | 3 +- .../models/ExperimentSummarizeParamsTest.kt | 11 +- .../api/models/ExperimentTest.kt | 14 +- .../api/models/ExperimentUpdateParamsTest.kt | 45 +- .../api/models/FeedbackDatasetItemTest.kt | 15 +- .../api/models/FeedbackExperimentItemTest.kt | 33 +- .../api/models/FeedbackProjectLogsItemTest.kt | 33 +- .../models/FetchDatasetEventsResponseTest.kt | 66 +- .../FetchExperimentEventsResponseTest.kt | 160 +- .../FetchProjectLogsEventsResponseTest.kt | 160 +- .../api/models/FunctionCreateParamsTest.kt | 316 +- .../api/models/FunctionDeleteParamsTest.kt | 3 +- .../api/models/FunctionInvokeParamsTest.kt | 129 +- .../api/models/FunctionListParamsTest.kt | 21 +- .../api/models/FunctionReplaceParamsTest.kt | 316 +- .../api/models/FunctionRetrieveParamsTest.kt | 3 +- .../braintrustdata/api/models/FunctionTest.kt | 201 +- .../api/models/FunctionUpdateParamsTest.kt | 293 +- .../api/models/GroupCreateParamsTest.kt | 27 +- .../api/models/GroupDeleteParamsTest.kt | 3 +- .../api/models/GroupListParamsTest.kt | 21 +- .../api/models/GroupReplaceParamsTest.kt | 27 +- .../api/models/GroupRetrieveParamsTest.kt | 3 +- .../braintrustdata/api/models/GroupTest.kt | 4 +- .../api/models/GroupUpdateParamsTest.kt | 39 +- .../api/models/InsertDatasetEventTest.kt | 28 +- .../api/models/InsertEventsResponseTest.kt | 2 +- .../api/models/InsertExperimentEventTest.kt | 85 +- .../api/models/InsertProjectLogsEventTest.kt | 85 +- .../api/models/MetricSummaryTest.kt | 16 +- .../api/models/OnlineScoreConfigTest.kt | 20 +- .../models/OrganizationDeleteParamsTest.kt | 3 +- .../api/models/OrganizationListParamsTest.kt | 21 +- .../OrganizationMemberUpdateParamsTest.kt | 55 +- .../models/OrganizationRetrieveParamsTest.kt | 3 +- .../models/OrganizationUpdateParamsTest.kt | 21 +- .../api/models/ProjectCreateParamsTest.kt | 13 +- .../api/models/ProjectDeleteParamsTest.kt | 3 +- .../api/models/ProjectListParamsTest.kt | 21 +- .../models/ProjectLogFeedbackParamsTest.kt | 93 +- .../api/models/ProjectLogFetchParamsTest.kt | 17 +- .../models/ProjectLogFetchPostParamsTest.kt | 25 +- .../api/models/ProjectLogInsertParamsTest.kt | 220 +- .../api/models/ProjectLogsEventTest.kt | 83 +- .../api/models/ProjectRetrieveParamsTest.kt | 3 +- .../api/models/ProjectScoreCategoryTest.kt | 4 +- .../api/models/ProjectScoreConfigTest.kt | 36 +- .../models/ProjectScoreCreateParamsTest.kt | 87 +- .../models/ProjectScoreDeleteParamsTest.kt | 3 +- .../api/models/ProjectScoreListParamsTest.kt | 37 +- .../models/ProjectScoreReplaceParamsTest.kt | 87 +- .../models/ProjectScoreRetrieveParamsTest.kt | 3 +- .../api/models/ProjectScoreTest.kt | 46 +- .../models/ProjectScoreUpdateParamsTest.kt | 91 +- .../api/models/ProjectTagCreateParamsTest.kt | 15 +- .../api/models/ProjectTagDeleteParamsTest.kt | 3 +- .../api/models/ProjectTagListParamsTest.kt | 21 +- .../api/models/ProjectTagReplaceParamsTest.kt | 15 +- .../models/ProjectTagRetrieveParamsTest.kt | 3 +- .../api/models/ProjectTagUpdateParamsTest.kt | 17 +- .../api/models/ProjectUpdateParamsTest.kt | 15 +- .../api/models/PromptCreateParamsTest.kt | 275 +- .../api/models/PromptDataTest.kt | 129 +- .../api/models/PromptDeleteParamsTest.kt | 3 +- .../api/models/PromptListParamsTest.kt | 21 +- .../api/models/PromptOptionsTest.kt | 78 +- .../api/models/PromptReplaceParamsTest.kt | 275 +- .../api/models/PromptRetrieveParamsTest.kt | 3 +- .../braintrustdata/api/models/PromptTest.kt | 184 +- .../api/models/PromptUpdateParamsTest.kt | 277 +- .../api/models/RoleCreateParamsTest.kt | 55 +- .../api/models/RoleDeleteParamsTest.kt | 3 +- .../api/models/RoleListParamsTest.kt | 21 +- .../api/models/RoleReplaceParamsTest.kt | 55 +- .../api/models/RoleRetrieveParamsTest.kt | 3 +- .../com/braintrustdata/api/models/RoleTest.kt | 16 +- .../api/models/RoleUpdateParamsTest.kt | 96 +- .../api/models/ScoreSummaryTest.kt | 16 +- .../api/models/SpanIframeCreateParamsTest.kt | 15 +- .../api/models/SpanIframeDeleteParamsTest.kt | 3 +- .../api/models/SpanIframeListParamsTest.kt | 21 +- .../api/models/SpanIframeReplaceParamsTest.kt | 15 +- .../models/SpanIframeRetrieveParamsTest.kt | 3 +- .../api/models/SpanIframeUpdateParamsTest.kt | 17 +- .../models/SummarizeDatasetResponseTest.kt | 4 +- .../models/SummarizeExperimentResponseTest.kt | 71 +- .../models/TopLevelHelloWorldParamsTest.kt | 3 +- .../api/models/UserListParamsTest.kt | 33 +- .../api/models/UserRetrieveParamsTest.kt | 3 +- .../api/models/ViewCreateParamsTest.kt | 91 +- .../api/models/ViewDataSearchTest.kt | 21 +- .../braintrustdata/api/models/ViewDataTest.kt | 18 +- .../api/models/ViewDeleteParamsTest.kt | 11 +- .../api/models/ViewListParamsTest.kt | 21 +- .../api/models/ViewOptionsTest.kt | 28 +- .../api/models/ViewReplaceParamsTest.kt | 91 +- .../api/models/ViewRetrieveParamsTest.kt | 11 +- .../com/braintrustdata/api/models/ViewTest.kt | 46 +- .../api/models/ViewUpdateParamsTest.kt | 89 +- .../api/services/ErrorHandlingTest.kt | 10 +- .../api/services/ServiceParamsTest.kt | 9 +- .../api/services/blocking/AclServiceTest.kt | 58 +- .../services/blocking/AiSecretServiceTest.kt | 26 +- .../services/blocking/ApiKeyServiceTest.kt | 4 +- .../services/blocking/DatasetServiceTest.kt | 90 +- .../services/blocking/EnvVarServiceTest.kt | 10 +- .../api/services/blocking/EvalServiceTest.kt | 50 +- .../blocking/ExperimentServiceTest.kt | 162 +- .../services/blocking/FunctionServiceTest.kt | 368 +- .../api/services/blocking/GroupServiceTest.kt | 22 +- .../blocking/OrganizationServiceTest.kt | 4 +- .../blocking/ProjectScoreServiceTest.kt | 90 +- .../services/blocking/ProjectServiceTest.kt | 6 +- .../blocking/ProjectTagServiceTest.kt | 6 +- .../services/blocking/PromptServiceTest.kt | 276 +- .../api/services/blocking/RoleServiceTest.kt | 85 +- .../blocking/SpanIframeServiceTest.kt | 6 +- .../services/blocking/TopLevelServiceTest.kt | 2 +- .../api/services/blocking/UserServiceTest.kt | 2 +- .../api/services/blocking/ViewServiceTest.kt | 77 +- .../organizations/MemberServiceTest.kt | 14 +- .../blocking/projects/LogServiceTest.kt | 142 +- braintrust-java-example/build.gradle.kts | 18 + build.gradle.kts | 6 - buildSrc/build.gradle.kts | 2 +- .../main/kotlin/braintrust.java.gradle.kts | 4 - .../main/kotlin/braintrust.kotlin.gradle.kts | 9 +- .../main/kotlin/braintrust.publish.gradle.kts | 9 +- gradle/wrapper/gradle-wrapper.jar | Bin 43453 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 6 +- gradlew.bat | 2 + 448 files changed, 50053 insertions(+), 29704 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Check.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt rename braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/{AiSecret.kt => AISecret.kt} (56%) create mode 100644 braintrust-java-example/build.gradle.kts diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index d0246884..a1f76188 100755 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -29,11 +29,13 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Publish to Sonatype - run: | + run: |- + export -- GPG_SIGNING_KEY_ID + printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" + GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" env: SONATYPE_USERNAME: ${{ secrets.BRAINTRUST_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.BRAINTRUST_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY_ID: ${{ secrets.BRAINTRUST_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} GPG_SIGNING_KEY: ${{ secrets.BRAINTRUST_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.BRAINTRUST_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 88dee7a9..d9128fbc 100755 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -20,6 +20,5 @@ jobs: env: SONATYPE_USERNAME: ${{ secrets.BRAINTRUST_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.BRAINTRUST_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY_ID: ${{ secrets.BRAINTRUST_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} GPG_SIGNING_KEY: ${{ secrets.BRAINTRUST_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} GPG_SIGNING_PASSWORD: ${{ secrets.BRAINTRUST_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/LICENSE b/LICENSE index 5e03e95a..f3b9e7e5 100755 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2024 Braintrust + Copyright 2025 Braintrust Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index dd95efbb..460c5029 100644 --- a/README.md +++ b/README.md @@ -6,31 +6,25 @@ -The Braintrust Java SDK provides convenient access to the Braintrust REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property. +The Braintrust Java SDK provides convenient access to the Braintrust REST API from applications written in Java. The Braintrust Java SDK is similar to the Braintrust Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. It is generated with [Stainless](https://www.stainlessapi.com/). -## Documentation +The REST API documentation can be found on [www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec). -The REST API documentation can be found on [www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec). - ---- - -## Getting started - -### Install dependencies - -#### Gradle +## Installation +### Gradle + ```kotlin implementation("com.braintrustdata.api:braintrust-java:0.7.0") ``` -#### Maven +### Maven ```xml @@ -42,6 +36,12 @@ implementation("com.braintrustdata.api:braintrust-java:0.7.0") +## Requirements + +This library requires Java 8 or later. + +## Usage + ### Configure the client Use `BraintrustOkHttpClient.builder()` to configure the client. @@ -49,6 +49,9 @@ Use `BraintrustOkHttpClient.builder()` to configure the client. Alternately, set the environment with `BRAINTRUST_API_KEY`, and use `BraintrustOkHttpClient.fromEnv()` to read from the environment. ```java +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; + BraintrustClient client = BraintrustOkHttpClient.fromEnv(); // Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties @@ -68,8 +71,7 @@ Read the documentation for more configuration options. ### Example: creating a resource -To create a new project, first use the `ProjectCreateParams` builder to specify attributes, -then pass that to the `create` method of the `projects` service. +To create a new project, first use the `ProjectCreateParams` builder to specify attributes, then pass that to the `create` method of the `projects` service. ```java import com.braintrustdata.api.models.Project; @@ -83,12 +85,11 @@ Project project = client.projects().create(params); ### Example: listing resources -The Braintrust API provides a `list` method to get a paginated list of projects. -You can retrieve the first page by: +The Braintrust API provides a `list` method to get a paginated list of projects. You can retrieve the first page by: ```java -import com.braintrustdata.api.models.Page; import com.braintrustdata.api.models.Project; +import com.braintrustdata.api.models.ProjectListPage; ProjectListPage page = client.projects().list(); for (Project project : page.objects()) { @@ -96,6 +97,31 @@ for (Project project : page.objects()) { } ``` +Use the `ProjectListParams` builder to set parameters: + +```java +import com.braintrustdata.api.models.ProjectListPage; +import com.braintrustdata.api.models.ProjectListParams; + +ProjectListParams params = ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build(); +ProjectListPage page1 = client.projects().list(params); + +// Using the `from` method of the builder you can reuse previous params values: +ProjectListPage page2 = client.projects().list(ProjectListParams.builder() + .from(params) + .build()); + +// Or easily get params for the next page by using the helper `getNextPageParams`: +ProjectListPage page3 = client.projects().list(params.getNextPageParams(page2)); +``` + See [Pagination](#pagination) below for more information on transparently working with lists of objects without worrying about fetching each page. --- @@ -106,19 +132,7 @@ See [Pagination](#pagination) below for more information on transparently workin To make a request to the Braintrust API, you generally build an instance of the appropriate `Params` class. -In [Example: creating a resource](#example-creating-a-resource) above, we used the `ProjectCreateParams.builder()` to pass to -the `create` method of the `projects` service. - -Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, -you can attach them using the `putAdditionalProperty` method. - -```java -import com.braintrustdata.api.models.core.JsonValue; -ProjectCreateParams params = ProjectCreateParams.builder() - // ... normal properties - .putAdditionalProperty("secret_param", JsonValue.from("4242")) - .build(); -``` +See [Undocumented request params](#undocumented-request-params) for how to send arbitrary parameters. ## Responses @@ -127,15 +141,19 @@ ProjectCreateParams params = ProjectCreateParams.builder() When receiving a response, the Braintrust Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `BraintrustInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model. ```java +import com.braintrustdata.api.models.Project; + Project project = client.projects().create().validate(); ``` ### Response properties as JSON -In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by -this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value. +In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value. ```java +import com.braintrustdata.api.core.JsonField; +import java.util.Optional; + JsonField field = responseObj._field(); if (field.isMissing()) { @@ -157,6 +175,8 @@ if (field.isMissing()) { Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method: ```java +import com.braintrustdata.api.core.JsonValue; + JsonValue secret = aISecret._additionalProperties().get("secret_field"); ``` @@ -164,17 +184,18 @@ JsonValue secret = aISecret._additionalProperties().get("secret_field"); ## Pagination -For methods that return a paginated list of results, this library provides convenient ways access -the results either one page at a time, or item-by-item across all pages. +For methods that return a paginated list of results, this library provides convenient ways access the results either one page at a time, or item-by-item across all pages. ### Auto-pagination -To iterate through all results across all pages, you can use `autoPager`, -which automatically handles fetching more pages for you: +To iterate through all results across all pages, you can use `autoPager`, which automatically handles fetching more pages for you: ### Synchronous ```java +import com.braintrustdata.api.models.Project; +import com.braintrustdata.api.models.ProjectListPage; + // As an Iterable: ProjectListPage page = client.projects().list(params); for (Project project : page.autoPager()) { @@ -197,12 +218,12 @@ asyncClient.projects().list(params).autoPager() ### Manual pagination -If none of the above helpers meet your needs, you can also manually request pages one-by-one. -A page of results has a `data()` method to fetch the list of objects, as well as top-level -`response` and other methods to fetch top-level data about the page. It also has methods -`hasNextPage`, `getNextPage`, and `getNextPageParams` methods to help with pagination. +If none of the above helpers meet your needs, you can also manually request pages one-by-one. A page of results has a `data()` method to fetch the list of objects, as well as top-level `response` and other methods to fetch top-level data about the page. It also has methods `hasNextPage`, `getNextPage`, and `getNextPageParams` methods to help with pagination. ```java +import com.braintrustdata.api.models.Project; +import com.braintrustdata.api.models.ProjectListPage; + ProjectListPage page = client.projects().list(params); while (page != null) { for (Project project : page.objects()) { @@ -221,31 +242,33 @@ This library throws exceptions in a single hierarchy for easy handling: - **`BraintrustException`** - Base exception for all exceptions - - **`BraintrustServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server. +- **`BraintrustServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server. - | 400 | BadRequestException | - | ------ | ----------------------------- | - | 401 | AuthenticationException | - | 403 | PermissionDeniedException | - | 404 | NotFoundException | - | 422 | UnprocessableEntityException | - | 429 | RateLimitException | - | 5xx | InternalServerException | - | others | UnexpectedStatusCodeException | + | 400 | BadRequestException | + | ------ | ----------------------------- | + | 401 | AuthenticationException | + | 403 | PermissionDeniedException | + | 404 | NotFoundException | + | 422 | UnprocessableEntityException | + | 429 | RateLimitException | + | 5xx | InternalServerException | + | others | UnexpectedStatusCodeException | - - **`BraintrustIoException`** - I/O networking errors - - **`BraintrustInvalidDataException`** - any other exceptions on the client side, e.g.: - - We failed to serialize the request body - - We failed to parse the response body (has access to response code and body) +- **`BraintrustIoException`** - I/O networking errors +- **`BraintrustInvalidDataException`** - any other exceptions on the client side, e.g.: + - We failed to serialize the request body + - We failed to parse the response body (has access to response code and body) ## Network options ### Retries -Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. -You can provide a `maxRetries` on the client builder to configure this: +Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. You can provide a `maxRetries` on the client builder to configure this: ```java +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; + BraintrustClient client = BraintrustOkHttpClient.builder() .fromEnv() .maxRetries(4) @@ -257,6 +280,10 @@ BraintrustClient client = BraintrustOkHttpClient.builder() Requests time out after 1 minute by default. You can configure this on the client builder: ```java +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; +import java.time.Duration; + BraintrustClient client = BraintrustOkHttpClient.builder() .fromEnv() .timeout(Duration.ofSeconds(30)) @@ -268,38 +295,43 @@ BraintrustClient client = BraintrustOkHttpClient.builder() Requests can be routed through a proxy. You can configure this on the client builder: ```java +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; +import java.net.InetSocketAddress; +import java.net.Proxy; + BraintrustClient client = BraintrustOkHttpClient.builder() .fromEnv() - .proxy(new Proxy( - Type.HTTP, - new InetSocketAddress("proxy.com", 8080) - )) + .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("example.com", 8080))) .build(); ``` ## Making custom/undocumented requests -This library is typed for convenient access to the documented API. If you need to access undocumented -params or response properties, the library can still be used. +This library is typed for convenient access to the documented API. If you need to access undocumented params or response properties, the library can still be used. ### Undocumented request params -To make requests using undocumented parameters, you can provide or override parameters on the params object -while building it. +In [Example: creating a resource](#example-creating-a-resource) above, we used the `ProjectCreateParams.builder()` to pass to the `create` method of the `projects` service. -```kotlin -FooCreateParams address = FooCreateParams.builder() - .id("my_id") - .putAdditionalProperty("secret_prop", JsonValue.from("hello")) +Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using raw setters: + +```java +import com.braintrustdata.api.core.JsonValue; +import com.braintrustdata.api.models.ProjectCreateParams; + +ProjectCreateParams params = ProjectCreateParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build(); ``` +You can also use the `putAdditionalProperty` method on nested headers, query params, or body objects. + ### Undocumented response properties -To access undocumented response properties, you can use `res._additionalProperties()` on a response object to -get a map of untyped fields of type `Map`. You can then access fields like -`._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class -to extract it to a desired type. +To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `res._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. ## Logging @@ -321,13 +353,9 @@ $ export BRAINTRUST_LOG=debug This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: -1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_. +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ 2. Changes that we do not expect to impact the vast majority of users in practice. We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. We are keen for your feedback; please open an [issue](https://www.github.com/braintrustdata/braintrust-java/issues) with questions, bugs, or suggestions. - -## Requirements - -This library requires Java 8 or later. diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index f180e456..f7b49e5c 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration +import java.util.Optional class BraintrustOkHttpClient private constructor() { @@ -21,7 +22,8 @@ class BraintrustOkHttpClient private constructor() { @JvmStatic fun fromEnv(): BraintrustClient = builder().fromEnv().build() } - class Builder { + /** A builder for [BraintrustOkHttpClient]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL @@ -130,6 +132,8 @@ class BraintrustOkHttpClient private constructor() { fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: Optional) = apiKey(apiKey.orElse(null)) + fun fromEnv() = apply { clientOptions.fromEnv() } fun build(): BraintrustClient = diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index f1c04318..d812a431 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration +import java.util.Optional class BraintrustOkHttpClientAsync private constructor() { @@ -21,7 +22,8 @@ class BraintrustOkHttpClientAsync private constructor() { @JvmStatic fun fromEnv(): BraintrustClientAsync = builder().fromEnv().build() } - class Builder { + /** A builder for [BraintrustOkHttpClientAsync]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL @@ -130,6 +132,8 @@ class BraintrustOkHttpClientAsync private constructor() { fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: Optional) = apiKey(apiKey.orElse(null)) + fun fromEnv() = apply { clientOptions.fromEnv() } fun build(): BraintrustClientAsync = diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index 9d9f81c9..60b45b95 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -1,6 +1,7 @@ package com.braintrustdata.api.client.okhttp import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpClient import com.braintrustdata.api.core.http.HttpMethod @@ -30,38 +31,11 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { - val clientBuilder = okHttpClient.newBuilder() - - val logLevel = - when (System.getenv("BRAINTRUST_LOG")?.lowercase()) { - "info" -> HttpLoggingInterceptor.Level.BASIC - "debug" -> HttpLoggingInterceptor.Level.BODY - else -> null - } - if (logLevel != null) { - clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } - ) - } - - val timeout = requestOptions.timeout - if (timeout != null) { - clientBuilder - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) - } - - return clientBuilder.build() - } - override fun execute( request: HttpRequest, requestOptions: RequestOptions, ): HttpResponse { - val call = getClient(requestOptions).newCall(request.toRequest()) + val call = newCall(request, requestOptions) return try { call.execute().toResponse() @@ -80,18 +54,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } - val call = getClient(requestOptions).newCall(request.toRequest()) - call.enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(BraintrustIoException("Request failed", e)) + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(BraintrustIoException("Request failed", e)) + } } - } - ) + ) return future } @@ -102,10 +76,37 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val okHttpClient.cache?.close() } - private fun HttpRequest.toRequest(): Request { + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + val clientBuilder = okHttpClient.newBuilder() + + val logLevel = + when (System.getenv("BRAINTRUST_LOG")?.lowercase()) { + "info" -> HttpLoggingInterceptor.Level.BASIC + "debug" -> HttpLoggingInterceptor.Level.BODY + else -> null + } + if (logLevel != null) { + clientBuilder.addNetworkInterceptor( + HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + ) + } + + val timeout = requestOptions.timeout + if (timeout != null) { + clientBuilder + .connectTimeout(timeout) + .readTimeout(timeout) + .writeTimeout(timeout) + .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + } + + val client = clientBuilder.build() + return client.newCall(request.toRequest(client)) + } + + private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { var body: RequestBody? = body?.toRequestBody() - // OkHttpClient always requires a request body for PUT and POST methods. - if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) { + if (body == null && requiresBody(method)) { body = "".toRequestBody() } @@ -114,9 +115,33 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val headers.values(name).forEach { builder.header(name, it) } } + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.header( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString() + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.header( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString() + ) + } + return builder.build() } + /** `OkHttpClient` always requires a request body for some methods. */ + private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + private fun HttpRequest.toUrl(): String { url?.let { return it @@ -170,7 +195,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var baseUrl: HttpUrl? = null // The default timeout is 1 minute. @@ -192,7 +217,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) .proxy(proxy) .build(), - checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }, + checkRequired("baseUrl", baseUrl), ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index 9f688451..e303c335 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -2,11 +2,48 @@ package com.braintrustdata.api.client -import com.braintrustdata.api.models.* -import com.braintrustdata.api.services.blocking.* - +import com.braintrustdata.api.services.blocking.AclService +import com.braintrustdata.api.services.blocking.AiSecretService +import com.braintrustdata.api.services.blocking.ApiKeyService +import com.braintrustdata.api.services.blocking.DatasetService +import com.braintrustdata.api.services.blocking.EnvVarService +import com.braintrustdata.api.services.blocking.EvalService +import com.braintrustdata.api.services.blocking.ExperimentService +import com.braintrustdata.api.services.blocking.FunctionService +import com.braintrustdata.api.services.blocking.GroupService +import com.braintrustdata.api.services.blocking.OrganizationService +import com.braintrustdata.api.services.blocking.ProjectScoreService +import com.braintrustdata.api.services.blocking.ProjectService +import com.braintrustdata.api.services.blocking.ProjectTagService +import com.braintrustdata.api.services.blocking.PromptService +import com.braintrustdata.api.services.blocking.RoleService +import com.braintrustdata.api.services.blocking.SpanIframeService +import com.braintrustdata.api.services.blocking.TopLevelService +import com.braintrustdata.api.services.blocking.UserService +import com.braintrustdata.api.services.blocking.ViewService + +/** + * A client for interacting with the Braintrust REST API synchronously. You can also switch to + * asynchronous execution via the [async] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ interface BraintrustClient { + /** + * Returns a version of this client that uses asynchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ fun async(): BraintrustClientAsync fun topLevel(): TopLevelService @@ -46,4 +83,17 @@ interface BraintrustClient { fun envVars(): EnvVarService fun evals(): EvalService + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index eea2d753..c0b9db25 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -2,11 +2,48 @@ package com.braintrustdata.api.client -import com.braintrustdata.api.models.* -import com.braintrustdata.api.services.async.* - +import com.braintrustdata.api.services.async.AclServiceAsync +import com.braintrustdata.api.services.async.AiSecretServiceAsync +import com.braintrustdata.api.services.async.ApiKeyServiceAsync +import com.braintrustdata.api.services.async.DatasetServiceAsync +import com.braintrustdata.api.services.async.EnvVarServiceAsync +import com.braintrustdata.api.services.async.EvalServiceAsync +import com.braintrustdata.api.services.async.ExperimentServiceAsync +import com.braintrustdata.api.services.async.FunctionServiceAsync +import com.braintrustdata.api.services.async.GroupServiceAsync +import com.braintrustdata.api.services.async.OrganizationServiceAsync +import com.braintrustdata.api.services.async.ProjectScoreServiceAsync +import com.braintrustdata.api.services.async.ProjectServiceAsync +import com.braintrustdata.api.services.async.ProjectTagServiceAsync +import com.braintrustdata.api.services.async.PromptServiceAsync +import com.braintrustdata.api.services.async.RoleServiceAsync +import com.braintrustdata.api.services.async.SpanIframeServiceAsync +import com.braintrustdata.api.services.async.TopLevelServiceAsync +import com.braintrustdata.api.services.async.UserServiceAsync +import com.braintrustdata.api.services.async.ViewServiceAsync + +/** + * A client for interacting with the Braintrust REST API asynchronously. You can also switch to + * synchronous execution via the [sync] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ interface BraintrustClientAsync { + /** + * Returns a version of this client that uses synchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ fun sync(): BraintrustClient fun topLevel(): TopLevelServiceAsync @@ -46,4 +83,17 @@ interface BraintrustClientAsync { fun envVars(): EnvVarServiceAsync fun evals(): EvalServiceAsync + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index e334c9bc..544e4880 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -4,11 +4,46 @@ package com.braintrustdata.api.client import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.getPackageVersion -import com.braintrustdata.api.models.* -import com.braintrustdata.api.services.async.* - -class BraintrustClientAsyncImpl -constructor( +import com.braintrustdata.api.services.async.AclServiceAsync +import com.braintrustdata.api.services.async.AclServiceAsyncImpl +import com.braintrustdata.api.services.async.AiSecretServiceAsync +import com.braintrustdata.api.services.async.AiSecretServiceAsyncImpl +import com.braintrustdata.api.services.async.ApiKeyServiceAsync +import com.braintrustdata.api.services.async.ApiKeyServiceAsyncImpl +import com.braintrustdata.api.services.async.DatasetServiceAsync +import com.braintrustdata.api.services.async.DatasetServiceAsyncImpl +import com.braintrustdata.api.services.async.EnvVarServiceAsync +import com.braintrustdata.api.services.async.EnvVarServiceAsyncImpl +import com.braintrustdata.api.services.async.EvalServiceAsync +import com.braintrustdata.api.services.async.EvalServiceAsyncImpl +import com.braintrustdata.api.services.async.ExperimentServiceAsync +import com.braintrustdata.api.services.async.ExperimentServiceAsyncImpl +import com.braintrustdata.api.services.async.FunctionServiceAsync +import com.braintrustdata.api.services.async.FunctionServiceAsyncImpl +import com.braintrustdata.api.services.async.GroupServiceAsync +import com.braintrustdata.api.services.async.GroupServiceAsyncImpl +import com.braintrustdata.api.services.async.OrganizationServiceAsync +import com.braintrustdata.api.services.async.OrganizationServiceAsyncImpl +import com.braintrustdata.api.services.async.ProjectScoreServiceAsync +import com.braintrustdata.api.services.async.ProjectScoreServiceAsyncImpl +import com.braintrustdata.api.services.async.ProjectServiceAsync +import com.braintrustdata.api.services.async.ProjectServiceAsyncImpl +import com.braintrustdata.api.services.async.ProjectTagServiceAsync +import com.braintrustdata.api.services.async.ProjectTagServiceAsyncImpl +import com.braintrustdata.api.services.async.PromptServiceAsync +import com.braintrustdata.api.services.async.PromptServiceAsyncImpl +import com.braintrustdata.api.services.async.RoleServiceAsync +import com.braintrustdata.api.services.async.RoleServiceAsyncImpl +import com.braintrustdata.api.services.async.SpanIframeServiceAsync +import com.braintrustdata.api.services.async.SpanIframeServiceAsyncImpl +import com.braintrustdata.api.services.async.TopLevelServiceAsync +import com.braintrustdata.api.services.async.TopLevelServiceAsyncImpl +import com.braintrustdata.api.services.async.UserServiceAsync +import com.braintrustdata.api.services.async.UserServiceAsyncImpl +import com.braintrustdata.api.services.async.ViewServiceAsync +import com.braintrustdata.api.services.async.ViewServiceAsyncImpl + +class BraintrustClientAsyncImpl( private val clientOptions: ClientOptions, ) : BraintrustClientAsync { @@ -128,4 +163,6 @@ constructor( override fun envVars(): EnvVarServiceAsync = envVars override fun evals(): EvalServiceAsync = evals + + override fun close() = clientOptions.httpClient.close() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index 8e1b73e7..2c8268d1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -4,11 +4,46 @@ package com.braintrustdata.api.client import com.braintrustdata.api.core.ClientOptions import com.braintrustdata.api.core.getPackageVersion -import com.braintrustdata.api.models.* -import com.braintrustdata.api.services.blocking.* - -class BraintrustClientImpl -constructor( +import com.braintrustdata.api.services.blocking.AclService +import com.braintrustdata.api.services.blocking.AclServiceImpl +import com.braintrustdata.api.services.blocking.AiSecretService +import com.braintrustdata.api.services.blocking.AiSecretServiceImpl +import com.braintrustdata.api.services.blocking.ApiKeyService +import com.braintrustdata.api.services.blocking.ApiKeyServiceImpl +import com.braintrustdata.api.services.blocking.DatasetService +import com.braintrustdata.api.services.blocking.DatasetServiceImpl +import com.braintrustdata.api.services.blocking.EnvVarService +import com.braintrustdata.api.services.blocking.EnvVarServiceImpl +import com.braintrustdata.api.services.blocking.EvalService +import com.braintrustdata.api.services.blocking.EvalServiceImpl +import com.braintrustdata.api.services.blocking.ExperimentService +import com.braintrustdata.api.services.blocking.ExperimentServiceImpl +import com.braintrustdata.api.services.blocking.FunctionService +import com.braintrustdata.api.services.blocking.FunctionServiceImpl +import com.braintrustdata.api.services.blocking.GroupService +import com.braintrustdata.api.services.blocking.GroupServiceImpl +import com.braintrustdata.api.services.blocking.OrganizationService +import com.braintrustdata.api.services.blocking.OrganizationServiceImpl +import com.braintrustdata.api.services.blocking.ProjectScoreService +import com.braintrustdata.api.services.blocking.ProjectScoreServiceImpl +import com.braintrustdata.api.services.blocking.ProjectService +import com.braintrustdata.api.services.blocking.ProjectServiceImpl +import com.braintrustdata.api.services.blocking.ProjectTagService +import com.braintrustdata.api.services.blocking.ProjectTagServiceImpl +import com.braintrustdata.api.services.blocking.PromptService +import com.braintrustdata.api.services.blocking.PromptServiceImpl +import com.braintrustdata.api.services.blocking.RoleService +import com.braintrustdata.api.services.blocking.RoleServiceImpl +import com.braintrustdata.api.services.blocking.SpanIframeService +import com.braintrustdata.api.services.blocking.SpanIframeServiceImpl +import com.braintrustdata.api.services.blocking.TopLevelService +import com.braintrustdata.api.services.blocking.TopLevelServiceImpl +import com.braintrustdata.api.services.blocking.UserService +import com.braintrustdata.api.services.blocking.UserServiceImpl +import com.braintrustdata.api.services.blocking.ViewService +import com.braintrustdata.api.services.blocking.ViewServiceImpl + +class BraintrustClientImpl( private val clientOptions: ClientOptions, ) : BraintrustClient { @@ -116,4 +151,6 @@ constructor( override fun envVars(): EnvVarService = envVars override fun evals(): EvalService = evals + + override fun close() = clientOptions.httpClient.close() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Check.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Check.kt new file mode 100644 index 00000000..da8f235b --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Check.kt @@ -0,0 +1,29 @@ +@file:JvmName("Check") + +package com.braintrustdata.api.core + +fun checkRequired(name: String, value: T?): T = + checkNotNull(value) { "`$name` is required, but was not set" } + +@JvmSynthetic +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } + +@JvmSynthetic +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } + } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index f7568abf..ea3dd912 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper import java.time.Clock +import java.util.Optional class ClientOptions private constructor( @@ -35,7 +36,8 @@ private constructor( @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } - class Builder { + /** A builder for [ClientOptions]. */ + class Builder internal constructor() { private var httpClient: HttpClient? = null private var jsonMapper: JsonMapper = jsonMapper() @@ -68,6 +70,16 @@ private constructor( fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } + + fun apiKey(apiKey: Optional) = apiKey(apiKey.orElse(null)) + fun headers(headers: Headers) = apply { this.headers.clear() putAllHeaders(headers) @@ -148,18 +160,10 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation - } - - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - - fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } - fun fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } } fun build(): ClientOptions { - checkNotNull(httpClient) { "`httpClient` is required but was not set" } + val httpClient = checkRequired("httpClient", httpClient) val headers = Headers.builder() val queryParams = QueryParams.builder() @@ -179,10 +183,10 @@ private constructor( queryParams.replaceAll(this.queryParams.build()) return ClientOptions( - httpClient!!, + httpClient, PhantomReachableClosingHttpClient( RetryingHttpClient.builder() - .httpClient(httpClient!!) + .httpClient(httpClient) .clock(clock) .maxRetries(maxRetries) .build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt new file mode 100644 index 00000000..f98bf142 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt @@ -0,0 +1,16 @@ +package com.braintrustdata.api.core + +import com.braintrustdata.api.core.http.Headers +import com.braintrustdata.api.core.http.QueryParams + +/** An interface representing parameters passed to a service method. */ +interface Params { + /** The full set of headers in the parameters, including both fixed and additional headers. */ + fun _headers(): Headers + + /** + * The full set of query params in the parameters, including both fixed and additional query + * params. + */ + fun _queryParams(): QueryParams +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt new file mode 100644 index 00000000..5df92543 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt @@ -0,0 +1,24 @@ +@file:JvmName("PrepareRequest") + +package com.braintrustdata.api.core + +import com.braintrustdata.api.core.http.HttpRequest +import java.util.concurrent.CompletableFuture + +@JvmSynthetic +internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = + toBuilder() + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params._queryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params._headers()) + .build() + +@JvmSynthetic +internal fun HttpRequest.prepareAsync( + clientOptions: ClientOptions, + params: Params +): CompletableFuture = + // This async version exists to make it easier to add async specific preparation logic in the + // future. + CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt index 7a8c8b26..ff946373 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt @@ -23,7 +23,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { + private var responseValidation: Boolean? = null private var timeout: Duration? = null diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 2706f7d4..2e3d2548 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -16,7 +16,9 @@ internal fun List.toImmutable(): List = @JvmSynthetic internal fun Map.toImmutable(): Map = - if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap()) + if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) + +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() @JvmSynthetic internal fun , V> SortedMap.toImmutable(): SortedMap = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 48703257..89e4dc64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -117,6 +117,8 @@ sealed class JsonField { is JsonValue -> this } + @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + fun accept(visitor: Visitor): R = when (this) { is KnownValue -> visitor.visitKnown(value) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt index 2f344105..d5795453 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt @@ -22,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = TreeMap(String.CASE_INSENSITIVE_ORDER) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index b6878c7f..1105f7d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -1,5 +1,6 @@ package com.braintrustdata.api.core.http +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.toImmutable class HttpRequest @@ -21,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var method: HttpMethod? = null private var url: String? = null @@ -134,7 +135,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( - checkNotNull(method) { "`method` is required but was not set" }, + checkRequired("method", method), url, pathSegments.toImmutable(), headers.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt index 97a2b094..1604872d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt @@ -21,7 +21,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = mutableMapOf() private var size: Int = 0 diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 0d1679b5..2fbb8396 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -1,6 +1,7 @@ package com.braintrustdata.api.core.http import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.errors.BraintrustIoException import java.io.IOException import java.time.Clock @@ -56,15 +57,17 @@ private constructor( } response - } catch (t: Throwable) { - if (++retries > maxRetries || !shouldRetry(t)) { - throw t + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable } null } val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() Thread.sleep(backoffMillis.toMillis()) } } @@ -112,6 +115,8 @@ private constructor( } val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() return sleepAsync(backoffMillis.toMillis()).thenCompose { executeWithRetries(requestWithRetryCount, requestOptions) } @@ -222,27 +227,27 @@ private constructor( return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) } - private fun sleepAsync(millis: Long): CompletableFuture { - val future = CompletableFuture() - TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis - ) - return future - } - companion object { private val TIMER = Timer("RetryingHttpClient", true) + private fun sleepAsync(millis: Long): CompletableFuture { + val future = CompletableFuture() + TIMER.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + millis + ) + return future + } + @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var httpClient: HttpClient? = null private var clock: Clock = Clock.systemUTC() @@ -259,7 +264,7 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( - checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + checkRequired("httpClient", httpClient), clock, maxRetries, idempotencyHeader, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index 28c52d93..4712bd76 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -2,21 +2,25 @@ package com.braintrustdata.api.errors +import com.braintrustdata.api.core.ExcludeMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects -@JsonDeserialize(builder = BraintrustError.Builder::class) @NoAutoDetect class BraintrustError +@JsonCreator private constructor( @JsonAnyGetter + @ExcludeMissing + @JsonAnySetter @get:JvmName("additionalProperties") - val additionalProperties: Map, + val additionalProperties: Map = immutableEmptyMap(), ) { fun toBuilder() = Builder().from(this) @@ -26,7 +30,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [BraintrustError]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @@ -40,7 +45,6 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { additionalProperties.put(key, value) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt similarity index 56% rename from braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt rename to braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index db8234cd..a1b84877 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -7,83 +7,95 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = AISecret.Builder::class) @NoAutoDetect class AISecret +@JsonCreator private constructor( - private val id: JsonField, - private val created: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val type: JsonField, - private val metadata: JsonField, - private val previewSecret: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("preview_secret") + @ExcludeMissing + private val previewSecret: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the AI secret */ fun id(): String = id.getRequired("id") - /** Date of AI secret creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** Name of the AI secret */ + fun name(): String = name.getRequired("name") /** Unique identifier for the organization */ fun orgId(): String = orgId.getRequired("org_id") - /** Name of the AI secret */ - fun name(): String = name.getRequired("name") - - fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + /** Date of AI secret creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) fun previewSecret(): Optional = Optional.ofNullable(previewSecret.getNullable("preview_secret")) + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + /** Unique identifier for the AI secret */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Date of AI secret creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + /** Name of the AI secret */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + /** Date of AI secret creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("preview_secret") + @ExcludeMissing + fun _previewSecret(): JsonField = previewSecret - @JsonProperty("preview_secret") @ExcludeMissing fun _previewSecret() = previewSecret + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): AISecret = apply { - if (!validated) { - id() - created() - orgId() - name() - type() - metadata().map { it.validate() } - previewSecret() - validated = true + if (validated) { + return@apply } + + id() + name() + orgId() + created() + metadata().ifPresent { it.validate() } + previewSecret() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -93,123 +105,131 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AISecret]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var orgId: JsonField? = null private var created: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var previewSecret: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecret: AISecret) = apply { - this.id = aiSecret.id - this.created = aiSecret.created - this.orgId = aiSecret.orgId - this.name = aiSecret.name - this.type = aiSecret.type - this.metadata = aiSecret.metadata - this.previewSecret = aiSecret.previewSecret - additionalProperties(aiSecret.additionalProperties) + id = aiSecret.id + name = aiSecret.name + orgId = aiSecret.orgId + created = aiSecret.created + metadata = aiSecret.metadata + previewSecret = aiSecret.previewSecret + type = aiSecret.type + additionalProperties = aiSecret.additionalProperties.toMutableMap() } /** Unique identifier for the AI secret */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the AI secret */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** Date of AI secret creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + /** Name of the AI secret */ + fun name(name: String) = name(JsonField.of(name)) - /** Date of AI secret creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + /** Name of the AI secret */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - /** Name of the AI secret */ - fun name(name: String) = name(JsonField.of(name)) + /** Date of AI secret creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Name of the AI secret */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Date of AI secret creation */ + fun created(created: Optional) = created(created.orElse(null)) - fun type(type: String) = type(JsonField.of(type)) + /** Date of AI secret creation */ + fun created(created: JsonField) = apply { this.created = created } - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun previewSecret(previewSecret: String) = previewSecret(JsonField.of(previewSecret)) + fun previewSecret(previewSecret: String?) = + previewSecret(JsonField.ofNullable(previewSecret)) + + fun previewSecret(previewSecret: Optional) = + previewSecret(previewSecret.orElse(null)) - @JsonProperty("preview_secret") - @ExcludeMissing fun previewSecret(previewSecret: JsonField) = apply { this.previewSecret = previewSecret } + fun type(type: String?) = type(JsonField.ofNullable(type)) + + fun type(type: Optional) = type(type.orElse(null)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AISecret = AISecret( - id, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("orgId", orgId), created, - orgId, - name, - type, metadata, previewSecret, + type, additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -219,29 +239,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -267,15 +293,15 @@ private constructor( return true } - return /* spotless:off */ other is AISecret && id == other.id && created == other.created && orgId == other.orgId && name == other.name && type == other.type && metadata == other.metadata && previewSecret == other.previewSecret && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, created, orgId, name, type, metadata, previewSecret, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, orgId, created, metadata, previewSecret, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "AISecret{id=$id, created=$created, orgId=$orgId, name=$name, type=$type, metadata=$metadata, previewSecret=$previewSecret, additionalProperties=$additionalProperties}" + "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" } 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 47f0796c..c9b17129 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 @@ -8,13 +8,14 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -29,38 +30,55 @@ import java.util.Optional * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. */ -@JsonDeserialize(builder = Acl.Builder::class) @NoAutoDetect class Acl +@JsonCreator private constructor( - private val id: JsonField, - private val objectType: JsonField, - private val objectId: JsonField, - private val userId: JsonField, - private val groupId: JsonField, - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val roleId: JsonField, - private val _objectOrgId: JsonField, - private val created: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_object_org_id") + @ExcludeMissing + private val _objectOrgId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the acl */ fun id(): String = id.getRequired("id") - /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + /** The organization the ACL's referred object belongs to */ + fun _objectOrgId(): String = _objectOrgId.getRequired("_object_org_id") /** The id of the object the ACL applies to */ fun objectId(): String = objectId.getRequired("object_id") - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided - */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** Date of acl creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided @@ -81,33 +99,39 @@ private constructor( /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) - /** The organization the ACL's referred object belongs to */ - fun _objectOrgId(): String = _objectOrgId.getRequired("_object_org_id") - - /** Date of acl creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the acl */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + /** The organization the ACL's referred object belongs to */ + @JsonProperty("_object_org_id") + @ExcludeMissing + fun __objectOrgId(): JsonField = _objectOrgId /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + /** Date of acl creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId() = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") @ExcludeMissing fun _permission() = permission + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** * When setting a permission directly, optionally restricts the permission grant to just the @@ -115,35 +139,38 @@ private constructor( */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType() = 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() = roleId + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId - /** The organization the ACL's referred object belongs to */ - @JsonProperty("_object_org_id") @ExcludeMissing fun __objectOrgId() = _objectOrgId - - /** Date of acl creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Acl = apply { - if (!validated) { - id() - objectType() - objectId() - userId() - groupId() - permission() - restrictObjectType() - roleId() - _objectOrgId() - created() - validated = true + if (validated) { + return@apply } + + id() + _objectOrgId() + objectId() + objectType() + created() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -153,106 +180,116 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Acl]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var _objectOrgId: JsonField? = null + private var objectId: 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 roleId: JsonField = JsonMissing.of() - private var _objectOrgId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(acl: Acl) = apply { - this.id = acl.id - this.objectType = acl.objectType - this.objectId = acl.objectId - this.userId = acl.userId - this.groupId = acl.groupId - this.permission = acl.permission - this.restrictObjectType = acl.restrictObjectType - this.roleId = acl.roleId - this._objectOrgId = acl._objectOrgId - this.created = acl.created - additionalProperties(acl.additionalProperties) + id = acl.id + _objectOrgId = acl._objectOrgId + objectId = acl.objectId + objectType = acl.objectType + created = acl.created + groupId = acl.groupId + permission = acl.permission + restrictObjectType = acl.restrictObjectType + roleId = acl.roleId + userId = acl.userId + additionalProperties = acl.additionalProperties.toMutableMap() } /** Unique identifier for the acl */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the acl */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + /** The organization the ACL's referred object belongs to */ + fun _objectOrgId(_objectOrgId: String) = _objectOrgId(JsonField.of(_objectOrgId)) - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + /** The organization the ACL's referred object belongs to */ + fun _objectOrgId(_objectOrgId: JsonField) = apply { + this._objectOrgId = _objectOrgId + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - @ExcludeMissing fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: String) = userId(JsonField.of(userId)) + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + /** Date of acl creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** Date of acl creation */ + fun created(created: Optional) = created(created.orElse(null)) + + /** Date of acl creation */ + fun created(created: JsonField) = apply { this.created = created } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: String) = groupId(JsonField.of(groupId)) + fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") - @ExcludeMissing fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission) = permission(JsonField.of(permission)) + fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: Optional) = permission(permission.orElse(null)) /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - @ExcludeMissing fun permission(permission: JsonField) = apply { this.permission = permission } /** * 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) = - restrictObjectType(JsonField.of(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + 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) = + restrictObjectType(restrictObjectType.orElse(null)) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ - @JsonProperty("restrict_object_type") - @ExcludeMissing fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -260,110 +297,116 @@ private constructor( /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: String) = roleId(JsonField.of(roleId)) + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") - @ExcludeMissing - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) - /** The organization the ACL's referred object belongs to */ - fun _objectOrgId(_objectOrgId: String) = _objectOrgId(JsonField.of(_objectOrgId)) + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } - /** The organization the ACL's referred object belongs to */ - @JsonProperty("_object_org_id") - @ExcludeMissing - fun _objectOrgId(_objectOrgId: JsonField) = apply { - this._objectOrgId = _objectOrgId - } + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Date of acl creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.orElse(null)) - /** Date of acl creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Acl = Acl( - id, - objectType, - objectId, - userId, + checkRequired("id", id), + checkRequired("_objectOrgId", _objectOrgId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + created, groupId, permission, restrictObjectType, roleId, - _objectOrgId, - created, + userId, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -378,6 +421,15 @@ private constructor( 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, @@ -390,9 +442,19 @@ private constructor( 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 @@ -409,6 +471,15 @@ private constructor( 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 @@ -426,49 +497,59 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + 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 = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -480,6 +561,15 @@ private constructor( 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, @@ -489,9 +579,19 @@ private constructor( 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 @@ -505,6 +605,15 @@ private constructor( 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 @@ -519,55 +628,68 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -582,6 +704,15 @@ private constructor( 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, @@ -594,9 +725,20 @@ private constructor( 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 @@ -613,6 +755,15 @@ private constructor( 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 @@ -630,6 +781,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -637,15 +800,15 @@ private constructor( return true } - return /* spotless:off */ other is Acl && id == other.id && objectType == other.objectType && objectId == other.objectId && userId == other.userId && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && _objectOrgId == other._objectOrgId && created == other.created && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Acl && id == other.id && _objectOrgId == other._objectOrgId && objectId == other.objectId && objectType == other.objectType && created == other.created && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, _objectOrgId, created, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _objectOrgId, objectId, objectType, created, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Acl{id=$id, objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, _objectOrgId=$_objectOrgId, created=$created, additionalProperties=$additionalProperties}" + "Acl{id=$id, _objectOrgId=$_objectOrgId, objectId=$objectId, objectType=$objectType, created=$created, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } 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 6ce91dbc..4bfabd52 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 @@ -5,60 +5,106 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Batch update acls. This operation is idempotent, so adding acls which already exist will have no + * effect, and removing acls which do not exist will have no effect. + */ class AclBatchUpdateParams -constructor( - private val addAcls: List?, - private val removeAcls: List?, +private constructor( + private val body: AclBatchUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun addAcls(): Optional> = Optional.ofNullable(addAcls) + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + fun addAcls(): Optional> = body.addAcls() - fun removeAcls(): Optional> = Optional.ofNullable(removeAcls) + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(): Optional> = body.removeAcls() + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + fun _addAcls(): JsonField> = body._addAcls() + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + fun _removeAcls(): JsonField> = body._removeAcls() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): AclBatchUpdateBody { - return AclBatchUpdateBody( - addAcls, - removeAcls, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): AclBatchUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = AclBatchUpdateBody.Builder::class) @NoAutoDetect class AclBatchUpdateBody + @JsonCreator internal constructor( - private val addAcls: List?, - private val removeAcls: List?, - private val additionalProperties: Map, + @JsonProperty("add_acls") + @ExcludeMissing + private val addAcls: JsonField> = JsonMissing.of(), + @JsonProperty("remove_acls") + @ExcludeMissing + private val removeAcls: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -71,7 +117,32 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - @JsonProperty("add_acls") fun addAcls(): List? = addAcls + fun addAcls(): Optional> = Optional.ofNullable(addAcls.getNullable("add_acls")) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(): Optional> = + Optional.ofNullable(removeAcls.getNullable("remove_acls")) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + @JsonProperty("add_acls") @ExcludeMissing fun _addAcls(): JsonField> = addAcls /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -83,12 +154,26 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - @JsonProperty("remove_acls") fun removeAcls(): List? = removeAcls + @JsonProperty("remove_acls") + @ExcludeMissing + fun _removeAcls(): JsonField> = removeAcls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AclBatchUpdateBody = apply { + if (validated) { + return@apply + } + + addAcls().ifPresent { it.forEach { it.validate() } } + removeAcls().ifPresent { it.forEach { it.validate() } } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -96,17 +181,18 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AclBatchUpdateBody]. */ + class Builder internal constructor() { - private var addAcls: List? = null - private var removeAcls: List? = null + private var addAcls: JsonField>? = null + private var removeAcls: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclBatchUpdateBody: AclBatchUpdateBody) = apply { - this.addAcls = aclBatchUpdateBody.addAcls - this.removeAcls = aclBatchUpdateBody.removeAcls - additionalProperties(aclBatchUpdateBody.additionalProperties) + addAcls = aclBatchUpdateBody.addAcls.map { it.toMutableList() } + removeAcls = aclBatchUpdateBody.removeAcls.map { it.toMutableList() } + additionalProperties = aclBatchUpdateBody.additionalProperties.toMutableMap() } /** @@ -120,8 +206,7 @@ constructor( * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of * a role. */ - @JsonProperty("add_acls") - fun addAcls(addAcls: List) = apply { this.addAcls = addAcls } + fun addAcls(addAcls: List?) = addAcls(JsonField.ofNullable(addAcls)) /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -134,27 +219,137 @@ constructor( * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of * a role. */ - @JsonProperty("remove_acls") - fun removeAcls(removeAcls: List) = apply { this.removeAcls = removeAcls } + fun addAcls(addAcls: Optional>) = addAcls(addAcls.orElse(null)) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun addAcls(addAcls: JsonField>) = apply { + this.addAcls = addAcls.map { it.toMutableList() } + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun addAddAcl(addAcl: AddAcl) = apply { + addAcls = + (addAcls ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addAcl) + } + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun removeAcls(removeAcls: List?) = + removeAcls(JsonField.ofNullable(removeAcls)) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun removeAcls(removeAcls: Optional>) = + removeAcls(removeAcls.orElse(null)) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun removeAcls(removeAcls: JsonField>) = apply { + this.removeAcls = removeAcls.map { it.toMutableList() } + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun addRemoveAcl(removeAcl: RemoveAcl) = apply { + removeAcls = + (removeAcls ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removeAcl) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AclBatchUpdateBody = AclBatchUpdateBody( - addAcls?.toImmutable(), - removeAcls?.toImmutable(), + (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, + (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -184,22 +379,19 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AclBatchUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var addAcls: MutableList = mutableListOf() - private var removeAcls: MutableList = mutableListOf() + private var body: AclBatchUpdateBody.Builder = AclBatchUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { - addAcls = aclBatchUpdateParams.addAcls?.toMutableList() ?: mutableListOf() - removeAcls = aclBatchUpdateParams.removeAcls?.toMutableList() ?: mutableListOf() + body = aclBatchUpdateParams.body.toBuilder() additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aclBatchUpdateParams.additionalBodyProperties.toMutableMap() } /** @@ -212,10 +404,31 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - fun addAcls(addAcls: List) = apply { - this.addAcls.clear() - this.addAcls.addAll(addAcls) - } + fun addAcls(addAcls: List?) = apply { body.addAcls(addAcls) } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addAcls(addAcls: Optional>) = addAcls(addAcls.orElse(null)) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addAcls(addAcls: JsonField>) = apply { body.addAcls(addAcls) } /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -227,7 +440,7 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - fun addAddAcl(addAcl: AddAcl) = apply { this.addAcls.add(addAcl) } + fun addAddAcl(addAcl: AddAcl) = apply { body.addAddAcl(addAcl) } /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -239,9 +452,32 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - fun removeAcls(removeAcls: List) = apply { - this.removeAcls.clear() - this.removeAcls.addAll(removeAcls) + fun removeAcls(removeAcls: List?) = apply { body.removeAcls(removeAcls) } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.orElse(null)) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(removeAcls: JsonField>) = apply { + body.removeAcls(removeAcls) } /** @@ -254,7 +490,26 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { this.removeAcls.add(removeAcl) } + fun addRemoveAcl(removeAcl: RemoveAcl) = apply { body.addRemoveAcl(removeAcl) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -354,35 +609,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): AclBatchUpdateParams = AclBatchUpdateParams( - addAcls.toImmutable().ifEmpty { null }, - removeAcls.toImmutable().ifEmpty { null }, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -396,57 +627,128 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. */ - @JsonDeserialize(builder = AddAcl.Builder::class) @NoAutoDetect class AddAcl + @JsonCreator private constructor( - private val objectType: ObjectType?, - private val objectId: String?, - private val userId: String?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The id of the object the ACL applies to */ + fun objectId(): String = objectId.getRequired("object_id") + /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + fun objectType(): ObjectType = objectType.getRequired("object_type") - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** + * 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 = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") fun userId(): String? = userId + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The id of the object the ACL applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") fun groupId(): String? = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") fun permission(): Permission? = permission + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType + @ExcludeMissing + fun _restrictObjectType(): JsonField = restrictObjectType /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") fun roleId(): String? = roleId + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddAcl = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -454,62 +756,98 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AddAcl]. */ + class Builder internal constructor() { - private var objectType: ObjectType? = null - private var objectId: String? = null - private var userId: String? = null - private var groupId: String? = null - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null - private var roleId: String? = null + private var objectId: 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 roleId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(addAcl: AddAcl) = apply { - this.objectType = addAcl.objectType - this.objectId = addAcl.objectId - this.userId = addAcl.userId - this.groupId = addAcl.groupId - this.permission = addAcl.permission - this.restrictObjectType = addAcl.restrictObjectType - this.roleId = addAcl.roleId - additionalProperties(addAcl.additionalProperties) + objectId = addAcl.objectId + objectType = addAcl.objectType + groupId = addAcl.groupId + permission = addAcl.permission + restrictObjectType = addAcl.restrictObjectType + roleId = addAcl.roleId + userId = addAcl.userId + additionalProperties = addAcl.additionalProperties.toMutableMap() } - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + /** The id of the object the ACL applies to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Optional) = permission(permission.orElse(null)) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } + + /** + * 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?) = + 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) = + restrictObjectType(restrictObjectType.orElse(null)) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -517,82 +855,115 @@ constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - @JsonProperty("role_id") fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AddAcl = AddAcl( - checkNotNull(objectType) { "`objectType` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - userId, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), groupId, permission, restrictObjectType, roleId, + userId, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -607,6 +978,15 @@ constructor( 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, @@ -619,9 +999,20 @@ constructor( 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 @@ -638,6 +1029,15 @@ constructor( 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 @@ -655,49 +1055,59 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + 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 = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -709,6 +1119,15 @@ constructor( 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, @@ -718,9 +1137,20 @@ constructor( 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 @@ -734,6 +1164,15 @@ constructor( 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 @@ -748,55 +1187,68 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -811,6 +1263,17 @@ constructor( 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, @@ -823,9 +1286,20 @@ constructor( 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 @@ -842,6 +1316,15 @@ constructor( 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 @@ -860,6 +1343,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -867,17 +1362,17 @@ constructor( return true } - return /* spotless:off */ other is AddAcl && objectType == other.objectType && objectId == other.objectId && userId == other.userId && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "AddAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" + "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } /** @@ -890,57 +1385,128 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. */ - @JsonDeserialize(builder = RemoveAcl.Builder::class) @NoAutoDetect class RemoveAcl + @JsonCreator private constructor( - private val objectType: ObjectType?, - private val objectId: String?, - private val userId: String?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The id of the object the ACL applies to */ + fun objectId(): String = objectId.getRequired("object_id") + /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + fun objectType(): ObjectType = objectType.getRequired("object_type") - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** + * 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 = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") fun userId(): String? = userId + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The id of the object the ACL applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") fun groupId(): String? = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") fun permission(): Permission? = permission + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType + @ExcludeMissing + fun _restrictObjectType(): JsonField = restrictObjectType /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") fun roleId(): String? = roleId + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RemoveAcl = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -948,62 +1514,98 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RemoveAcl]. */ + class Builder internal constructor() { - private var objectType: ObjectType? = null - private var objectId: String? = null - private var userId: String? = null - private var groupId: String? = null - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null - private var roleId: String? = null + private var objectId: 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 roleId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(removeAcl: RemoveAcl) = apply { - this.objectType = removeAcl.objectType - this.objectId = removeAcl.objectId - this.userId = removeAcl.userId - this.groupId = removeAcl.groupId - this.permission = removeAcl.permission - this.restrictObjectType = removeAcl.restrictObjectType - this.roleId = removeAcl.roleId - additionalProperties(removeAcl.additionalProperties) + objectId = removeAcl.objectId + objectType = removeAcl.objectType + groupId = removeAcl.groupId + permission = removeAcl.permission + restrictObjectType = removeAcl.restrictObjectType + roleId = removeAcl.roleId + userId = removeAcl.userId + additionalProperties = removeAcl.additionalProperties.toMutableMap() } - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + /** The id of the object the ACL applies to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Optional) = permission(permission.orElse(null)) /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: JsonField) = apply { + this.permission = permission + } + + /** + * 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?) = + 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) = + restrictObjectType(restrictObjectType.orElse(null)) /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -1011,82 +1613,115 @@ constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - @JsonProperty("role_id") fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RemoveAcl = RemoveAcl( - checkNotNull(objectType) { "`objectType` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - userId, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), groupId, permission, restrictObjectType, roleId, + userId, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -1101,6 +1736,15 @@ constructor( 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, @@ -1113,9 +1757,20 @@ constructor( 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 @@ -1132,6 +1787,15 @@ constructor( 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 @@ -1149,49 +1813,59 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + 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 = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -1203,6 +1877,15 @@ constructor( 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, @@ -1212,9 +1895,20 @@ constructor( 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 @@ -1228,6 +1922,15 @@ constructor( 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 @@ -1242,55 +1945,68 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -1305,6 +2021,17 @@ constructor( 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, @@ -1317,9 +2044,20 @@ constructor( 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 @@ -1336,6 +2074,15 @@ constructor( 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 @@ -1354,6 +2101,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1361,17 +2120,17 @@ constructor( return true } - return /* spotless:off */ other is RemoveAcl && objectType == other.objectType && objectId == other.objectId && userId == other.userId && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, userId, groupId, permission, restrictObjectType, roleId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "RemoveAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" + "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1379,11 +2138,11 @@ constructor( return true } - return /* spotless:off */ other is AclBatchUpdateParams && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(addAcls, removeAcls, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AclBatchUpdateParams{addAcls=$addAcls, removeAcls=$removeAcls, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index becae827..f31e08fe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -7,24 +7,28 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects -@JsonDeserialize(builder = AclBatchUpdateResponse.Builder::class) @NoAutoDetect class AclBatchUpdateResponse +@JsonCreator private constructor( - private val addedAcls: JsonField>, - private val removedAcls: JsonField>, - private val additionalProperties: Map, + @JsonProperty("added_acls") + @ExcludeMissing + private val addedAcls: JsonField> = JsonMissing.of(), + @JsonProperty("removed_acls") + @ExcludeMissing + private val removedAcls: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * An ACL grants a certain permission or role to a certain user or group on an object. * @@ -59,7 +63,7 @@ private constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. */ - @JsonProperty("added_acls") @ExcludeMissing fun _addedAcls() = addedAcls + @JsonProperty("added_acls") @ExcludeMissing fun _addedAcls(): JsonField> = addedAcls /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -71,18 +75,24 @@ private constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. */ - @JsonProperty("removed_acls") @ExcludeMissing fun _removedAcls() = removedAcls + @JsonProperty("removed_acls") + @ExcludeMissing + fun _removedAcls(): JsonField> = removedAcls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): AclBatchUpdateResponse = apply { - if (!validated) { - addedAcls().forEach { it.validate() } - removedAcls().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + addedAcls().forEach { it.validate() } + removedAcls().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -92,17 +102,18 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AclBatchUpdateResponse]. */ + class Builder internal constructor() { - private var addedAcls: JsonField> = JsonMissing.of() - private var removedAcls: JsonField> = JsonMissing.of() + private var addedAcls: JsonField>? = null + private var removedAcls: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclBatchUpdateResponse: AclBatchUpdateResponse) = apply { - this.addedAcls = aclBatchUpdateResponse.addedAcls - this.removedAcls = aclBatchUpdateResponse.removedAcls - additionalProperties(aclBatchUpdateResponse.additionalProperties) + addedAcls = aclBatchUpdateResponse.addedAcls.map { it.toMutableList() } + removedAcls = aclBatchUpdateResponse.removedAcls.map { it.toMutableList() } + additionalProperties = aclBatchUpdateResponse.additionalProperties.toMutableMap() } /** @@ -127,9 +138,32 @@ private constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - @JsonProperty("added_acls") - @ExcludeMissing - fun addedAcls(addedAcls: JsonField>) = apply { this.addedAcls = addedAcls } + fun addedAcls(addedAcls: JsonField>) = apply { + this.addedAcls = addedAcls.map { it.toMutableList() } + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addAddedAcl(addedAcl: Acl) = apply { + addedAcls = + (addedAcls ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addedAcl) + } + } /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -153,30 +187,56 @@ private constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - @JsonProperty("removed_acls") - @ExcludeMissing fun removedAcls(removedAcls: JsonField>) = apply { - this.removedAcls = removedAcls + this.removedAcls = removedAcls.map { it.toMutableList() } + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addRemovedAcl(removedAcl: Acl) = apply { + removedAcls = + (removedAcls ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removedAcl) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AclBatchUpdateResponse = AclBatchUpdateResponse( - addedAcls.map { it.toImmutable() }, - removedAcls.map { it.toImmutable() }, + checkRequired("addedAcls", addedAcls).map { it.toImmutable() }, + checkRequired("removedAcls", removedAcls).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } 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 35089027..7a01698a 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 @@ -5,72 +5,101 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new acl. If there is an existing acl with the same contents as the one specified in the + * request, will return the existing acl unmodified + */ class AclCreateParams -constructor( - private val objectId: String, - private val objectType: ObjectType, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, +private constructor( + private val body: AclCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun objectId(): String = objectId + /** The id of the object the ACL applies to */ + fun objectId(): String = body.objectId() - fun objectType(): ObjectType = objectType + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = body.objectType() - fun groupId(): Optional = Optional.ofNullable(groupId) + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun groupId(): Optional = body.groupId() + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = body.permission() + + /** + * 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 permission(): Optional = Optional.ofNullable(permission) + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun roleId(): Optional = body.roleId() - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType) + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun userId(): Optional = body.userId() - fun roleId(): Optional = Optional.ofNullable(roleId) + /** The id of the object the ACL applies to */ + fun _objectId(): JsonField = body._objectId() - fun userId(): Optional = Optional.ofNullable(userId) + /** The object type that the ACL applies to */ + fun _objectType(): JsonField = body._objectType() + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun _groupId(): JsonField = body._groupId() + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun _permission(): JsonField = body._permission() + + /** + * 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() + + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun _roleId(): JsonField = body._roleId() + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun _userId(): JsonField = body._userId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): AclCreateBody { - return AclCreateBody( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): AclCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -82,57 +111,128 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. */ - @JsonDeserialize(builder = AclCreateBody.Builder::class) @NoAutoDetect class AclCreateBody + @JsonCreator internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the ACL applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + fun objectId(): String = objectId.getRequired("object_id") + + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** + * 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 = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The id of the object the ACL applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") fun groupId(): String? = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") fun permission(): Permission? = permission + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType + @ExcludeMissing + fun _restrictObjectType(): JsonField = restrictObjectType /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") fun roleId(): String? = roleId + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") fun userId(): String? = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AclCreateBody = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -140,56 +240,98 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AclCreateBody]. */ + class Builder internal constructor() { - private var objectId: String? = null - private var objectType: ObjectType? = null - private var groupId: String? = null - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null - private var roleId: String? = null - private var userId: String? = null + private var objectId: 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 roleId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclCreateBody: AclCreateBody) = apply { - this.objectId = aclCreateBody.objectId - this.objectType = aclCreateBody.objectType - this.groupId = aclCreateBody.groupId - this.permission = aclCreateBody.permission - this.restrictObjectType = aclCreateBody.restrictObjectType - this.roleId = aclCreateBody.roleId - this.userId = aclCreateBody.userId - additionalProperties(aclCreateBody.additionalProperties) + objectId = aclCreateBody.objectId + objectType = aclCreateBody.objectType + groupId = aclCreateBody.groupId + permission = aclCreateBody.permission + restrictObjectType = aclCreateBody.restrictObjectType + roleId = aclCreateBody.roleId + userId = aclCreateBody.userId + additionalProperties = aclCreateBody.additionalProperties.toMutableMap() } /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the ACL applies to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Optional) = permission(permission.orElse(null)) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + 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) = + restrictObjectType(restrictObjectType.orElse(null)) + + /** + * 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 { this.restrictObjectType = restrictObjectType } @@ -197,32 +339,61 @@ constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - @JsonProperty("role_id") fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AclCreateBody = AclCreateBody( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), groupId, permission, restrictObjectType, @@ -257,67 +428,134 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AclCreateParams]. */ @NoAutoDetect - class Builder { - - private var objectId: String? = null - private var objectType: ObjectType? = null - private var groupId: String? = null - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null - private var roleId: String? = null - private var userId: String? = null + class Builder internal constructor() { + + private var body: AclCreateBody.Builder = AclCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclCreateParams: AclCreateParams) = apply { - objectId = aclCreateParams.objectId - objectType = aclCreateParams.objectType - groupId = aclCreateParams.groupId - permission = aclCreateParams.permission - restrictObjectType = aclCreateParams.restrictObjectType - roleId = aclCreateParams.roleId - userId = aclCreateParams.userId + body = aclCreateParams.body.toBuilder() additionalHeaders = aclCreateParams.additionalHeaders.toBuilder() additionalQueryParams = aclCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aclCreateParams.additionalBodyProperties.toMutableMap() } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { body.objectId(objectId) } + + /** The id of the object the ACL applies to */ + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + + /** The object type that the ACL applies to */ + 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 + * provided + */ + fun groupId(groupId: String?) = apply { body.groupId(groupId) } /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: Permission?) = apply { body.permission(permission) } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Optional) = permission(permission.orElse(null)) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: JsonField) = apply { body.permission(permission) } + + /** + * 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 { + body.restrictObjectType(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) = + restrictObjectType(restrictObjectType.orElse(null)) /** * 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 { - this.restrictObjectType = restrictObjectType + fun restrictObjectType(restrictObjectType: JsonField) = apply { + body.restrictObjectType(restrictObjectType) } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String?) = apply { body.roleId(roleId) } + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String?) = apply { body.userId(userId) } + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { body.userId(userId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -417,90 +655,59 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): AclCreateParams = AclCreateParams( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - groupId, - permission, - restrictObjectType, - roleId, - userId, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -515,6 +722,15 @@ constructor( 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, @@ -527,9 +743,19 @@ constructor( 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 @@ -546,6 +772,15 @@ constructor( 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 @@ -563,49 +798,59 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + 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 = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -617,6 +862,15 @@ constructor( 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, @@ -626,9 +880,19 @@ constructor( 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 @@ -642,6 +906,15 @@ constructor( 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 @@ -656,55 +929,68 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -719,6 +1005,15 @@ constructor( 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, @@ -731,9 +1026,20 @@ constructor( 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 @@ -750,6 +1056,15 @@ constructor( 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 @@ -767,6 +1082,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -774,11 +1101,11 @@ constructor( return true } - return /* spotless:off */ other is AclCreateParams && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "AclCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index a0b5b26d..da75bf13 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete an acl object by its id */ class AclDeleteParams -constructor( +private constructor( private val aclId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Acl id */ fun aclId(): String = aclId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AclDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var aclId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): AclDeleteParams = AclDeleteParams( - checkNotNull(aclId) { "`aclId` is required but was not set" }, + checkRequired("aclId", aclId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), 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 c9b0c0b0..252fd873 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 @@ -5,72 +5,98 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** Delete a single acl */ class AclFindAndDeleteParams -constructor( - private val objectId: String, - private val objectType: ObjectType, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, +private constructor( + private val body: AclFindAndDeleteBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun objectId(): String = objectId + /** The id of the object the ACL applies to */ + fun objectId(): String = body.objectId() - fun objectType(): ObjectType = objectType + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = body.objectType() - fun groupId(): Optional = Optional.ofNullable(groupId) + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun groupId(): Optional = body.groupId() + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = body.permission() + + /** + * 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 permission(): Optional = Optional.ofNullable(permission) + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun roleId(): Optional = body.roleId() - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType) + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun userId(): Optional = body.userId() - fun roleId(): Optional = Optional.ofNullable(roleId) + /** The id of the object the ACL applies to */ + fun _objectId(): JsonField = body._objectId() - fun userId(): Optional = Optional.ofNullable(userId) + /** The object type that the ACL applies to */ + fun _objectType(): JsonField = body._objectType() + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun _groupId(): JsonField = body._groupId() + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun _permission(): JsonField = body._permission() + + /** + * 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() + + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun _roleId(): JsonField = body._roleId() + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + fun _userId(): JsonField = body._userId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): AclFindAndDeleteBody { - return AclFindAndDeleteBody( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): AclFindAndDeleteBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -82,57 +108,128 @@ constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. */ - @JsonDeserialize(builder = AclFindAndDeleteBody.Builder::class) @NoAutoDetect class AclFindAndDeleteBody + @JsonCreator internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the ACL applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + fun objectId(): String = objectId.getRequired("object_id") + + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** + * 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 = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The id of the object the ACL applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") fun groupId(): String? = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") fun permission(): Permission? = permission + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType + @ExcludeMissing + fun _restrictObjectType(): JsonField = restrictObjectType /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") fun roleId(): String? = roleId + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") fun userId(): String? = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AclFindAndDeleteBody = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -140,56 +237,98 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AclFindAndDeleteBody]. */ + class Builder internal constructor() { - private var objectId: String? = null - private var objectType: ObjectType? = null - private var groupId: String? = null - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null - private var roleId: String? = null - private var userId: String? = null + private var objectId: 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 roleId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclFindAndDeleteBody: AclFindAndDeleteBody) = apply { - this.objectId = aclFindAndDeleteBody.objectId - this.objectType = aclFindAndDeleteBody.objectType - this.groupId = aclFindAndDeleteBody.groupId - this.permission = aclFindAndDeleteBody.permission - this.restrictObjectType = aclFindAndDeleteBody.restrictObjectType - this.roleId = aclFindAndDeleteBody.roleId - this.userId = aclFindAndDeleteBody.userId - additionalProperties(aclFindAndDeleteBody.additionalProperties) + objectId = aclFindAndDeleteBody.objectId + objectType = aclFindAndDeleteBody.objectType + groupId = aclFindAndDeleteBody.groupId + permission = aclFindAndDeleteBody.permission + restrictObjectType = aclFindAndDeleteBody.restrictObjectType + roleId = aclFindAndDeleteBody.roleId + userId = aclFindAndDeleteBody.userId + additionalProperties = aclFindAndDeleteBody.additionalProperties.toMutableMap() } /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the ACL applies to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("group_id") - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Optional) = permission(permission.orElse(null)) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** * When setting a permission directly, optionally restricts the permission grant to just * the specified object type. Cannot be set alongside a `role_id`. */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + 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) = + restrictObjectType(restrictObjectType.orElse(null)) + + /** + * 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 { this.restrictObjectType = restrictObjectType } @@ -197,32 +336,61 @@ constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - @JsonProperty("role_id") fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AclFindAndDeleteBody = AclFindAndDeleteBody( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), groupId, permission, restrictObjectType, @@ -257,68 +425,134 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AclFindAndDeleteParams]. */ @NoAutoDetect - class Builder { - - private var objectId: String? = null - private var objectType: ObjectType? = null - private var groupId: String? = null - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null - private var roleId: String? = null - private var userId: String? = null + class Builder internal constructor() { + + private var body: AclFindAndDeleteBody.Builder = AclFindAndDeleteBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aclFindAndDeleteParams: AclFindAndDeleteParams) = apply { - objectId = aclFindAndDeleteParams.objectId - objectType = aclFindAndDeleteParams.objectType - groupId = aclFindAndDeleteParams.groupId - permission = aclFindAndDeleteParams.permission - restrictObjectType = aclFindAndDeleteParams.restrictObjectType - roleId = aclFindAndDeleteParams.roleId - userId = aclFindAndDeleteParams.userId + body = aclFindAndDeleteParams.body.toBuilder() additionalHeaders = aclFindAndDeleteParams.additionalHeaders.toBuilder() additionalQueryParams = aclFindAndDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - aclFindAndDeleteParams.additionalBodyProperties.toMutableMap() } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { body.objectId(objectId) } + + /** The id of the object the ACL applies to */ + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + + /** The object type that the ACL applies to */ + 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 + * provided + */ + fun groupId(groupId: String?) = apply { body.groupId(groupId) } /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: Permission?) = apply { body.permission(permission) } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Optional) = permission(permission.orElse(null)) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: JsonField) = apply { body.permission(permission) } + + /** + * 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 { + body.restrictObjectType(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) = + restrictObjectType(restrictObjectType.orElse(null)) /** * 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 { - this.restrictObjectType = restrictObjectType + fun restrictObjectType(restrictObjectType: JsonField) = apply { + body.restrictObjectType(restrictObjectType) } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String?) = apply { body.roleId(roleId) } + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String?) = apply { body.userId(userId) } + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { body.userId(userId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -418,90 +652,59 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): AclFindAndDeleteParams = AclFindAndDeleteParams( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - groupId, - permission, - restrictObjectType, - roleId, - userId, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -516,6 +719,15 @@ constructor( 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, @@ -528,9 +740,19 @@ constructor( 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 @@ -547,6 +769,15 @@ constructor( 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 @@ -564,49 +795,59 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + 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 = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -618,6 +859,15 @@ constructor( 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, @@ -627,9 +877,19 @@ constructor( 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 @@ -643,6 +903,15 @@ constructor( 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 @@ -657,55 +926,68 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -720,6 +1002,15 @@ constructor( 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, @@ -732,9 +1023,20 @@ constructor( 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 @@ -751,6 +1053,15 @@ constructor( 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 @@ -768,6 +1079,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -775,11 +1098,11 @@ constructor( return true } - return /* spotless:off */ other is AclFindAndDeleteParams && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AclFindAndDeleteParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "AclFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index 2fe666f6..4f437d03 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.AclService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first + */ class AclListPage private constructor( private val aclsService: AclService, @@ -79,16 +84,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -98,11 +102,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,10 +146,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -150,8 +156,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: AclListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index 816bc8b5..8c7986b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.AclServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first + */ class AclListPageAsync private constructor( private val aclsService: AclServiceAsync, @@ -82,16 +87,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -101,11 +105,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -141,10 +149,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -153,8 +159,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: AclListPageAsync, ) { 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 1411d13c..faf2beeb 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 @@ -8,11 +8,12 @@ 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 +import com.braintrustdata.api.core.checkRequired 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.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -24,8 +25,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first + */ class AclListParams -constructor( +private constructor( private val objectId: String, private val objectType: ObjectType, private val endingBefore: String?, @@ -34,28 +39,48 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** The id of the object the ACL applies to */ fun objectId(): String = objectId + /** The object type that the ACL applies to */ fun objectType(): ObjectType = objectType + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } @@ -74,8 +99,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AclListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var objectId: String? = null private var objectType: ObjectType? = null @@ -111,28 +137,50 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** * Pagination cursor id. @@ -141,7 +189,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -243,8 +301,8 @@ constructor( fun build(): AclListParams = AclListParams( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), endingBefore, ids, limit, @@ -254,53 +312,51 @@ 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -315,6 +371,15 @@ constructor( 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, @@ -327,9 +392,19 @@ constructor( 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 @@ -346,6 +421,15 @@ constructor( 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 @@ -363,8 +447,24 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -374,8 +474,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -398,15 +496,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -432,18 +521,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -459,7 +558,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 5e32b3d8..83dde98e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get an acl object by its id */ class AclRetrieveParams -constructor( +private constructor( private val aclId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Acl id */ fun aclId(): String = aclId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AclRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var aclId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): AclRetrieveParams = AclRetrieveParams( - checkNotNull(aclId) { "`aclId` is required but was not set" }, + checkRequired("aclId", aclId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index a7c4fc1e..dff8800a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -3,99 +3,168 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new ai_secret. If there is an existing ai_secret with the same name as the one specified + * in the request, will return the existing ai_secret unmodified + */ class AiSecretCreateParams -constructor( - private val name: String, - private val metadata: Metadata?, - private val orgName: String?, - private val secret: String?, - private val type: String?, +private constructor( + private val body: AiSecretCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the AI secret */ + fun name(): String = body.name() - fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = body.metadata() - fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. + */ + fun orgName(): Optional = body.orgName() - fun secret(): Optional = Optional.ofNullable(secret) + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not + * replaced with null. + */ + fun secret(): Optional = body.secret() - fun type(): Optional = Optional.ofNullable(type) + fun type(): Optional = body.type() + + /** Name of the AI secret */ + fun _name(): JsonField = body._name() + + fun _metadata(): JsonField = body._metadata() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not + * replaced with null. + */ + fun _secret(): JsonField = body._secret() + + fun _type(): JsonField = body._type() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): AiSecretCreateBody { - return AiSecretCreateBody( - name, - metadata, - orgName, - secret, - type, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): AiSecretCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = AiSecretCreateBody.Builder::class) @NoAutoDetect class AiSecretCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val metadata: Metadata?, - private val orgName: String?, - private val secret: String?, - private val type: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("secret") + @ExcludeMissing + private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the AI secret */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, * not replaced with null. */ - @JsonProperty("secret") fun secret(): String? = secret + fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) + + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("type") fun type(): String? = type + /** Name of the AI secret */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. + */ + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AiSecretCreateBody = apply { + if (validated) { + return@apply + } + + name() + metadata().ifPresent { it.validate() } + orgName() + secret() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -103,64 +172,105 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AiSecretCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var metadata: Metadata? = null - private var orgName: String? = null - private var secret: String? = null - private var type: String? = null + private var name: JsonField? = null + private var metadata: JsonField = JsonMissing.of() + private var orgName: JsonField = JsonMissing.of() + private var secret: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretCreateBody: AiSecretCreateBody) = apply { - this.name = aiSecretCreateBody.name - this.metadata = aiSecretCreateBody.metadata - this.orgName = aiSecretCreateBody.orgName - this.secret = aiSecretCreateBody.secret - this.type = aiSecretCreateBody.type - additionalProperties(aiSecretCreateBody.additionalProperties) + name = aiSecretCreateBody.name + metadata = aiSecretCreateBody.metadata + orgName = aiSecretCreateBody.orgName + secret = aiSecretCreateBody.secret + type = aiSecretCreateBody.type + additionalProperties = aiSecretCreateBody.additionalProperties.toMutableMap() } /** Name of the AI secret */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + /** Name of the AI secret */ + fun name(name: JsonField) = apply { this.name = name } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. + */ + fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. + */ + fun secret(secret: Optional) = secret(secret.orElse(null)) /** * Secret value. If omitted in a PUT request, the existing secret value will be left * intact, not replaced with null. */ - @JsonProperty("secret") fun secret(secret: String) = apply { this.secret = secret } + fun secret(secret: JsonField) = apply { this.secret = secret } + + fun type(type: String?) = type(JsonField.ofNullable(type)) - @JsonProperty("type") fun type(type: String) = apply { this.type = type } + fun type(type: Optional) = type(type.orElse(null)) + + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AiSecretCreateBody = AiSecretCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), metadata, orgName, secret, @@ -194,49 +304,96 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AiSecretCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var metadata: Metadata? = null - private var orgName: String? = null - private var secret: String? = null - private var type: String? = null + private var body: AiSecretCreateBody.Builder = AiSecretCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretCreateParams: AiSecretCreateParams) = apply { - name = aiSecretCreateParams.name - metadata = aiSecretCreateParams.metadata - orgName = aiSecretCreateParams.orgName - secret = aiSecretCreateParams.secret - type = aiSecretCreateParams.type + body = aiSecretCreateParams.body.toBuilder() additionalHeaders = aiSecretCreateParams.additionalHeaders.toBuilder() additionalQueryParams = aiSecretCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aiSecretCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the AI secret */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the AI secret */ + fun name(name: JsonField) = apply { body.name(name) } + + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, * not replaced with null. */ - fun secret(secret: String) = apply { this.secret = secret } + fun secret(secret: String?) = apply { body.secret(secret) } - fun type(type: String) = apply { this.type = type } + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. + */ + fun secret(secret: Optional) = secret(secret.orElse(null)) + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. + */ + fun secret(secret: JsonField) = apply { body.secret(secret) } + + fun type(type: String?) = apply { body.type(type) } + + fun type(type: Optional) = type(type.orElse(null)) + + fun type(type: JsonField) = apply { body.type(type) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -336,52 +493,36 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): AiSecretCreateParams = AiSecretCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - metadata, - orgName, - secret, - type, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -389,29 +530,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -437,11 +584,11 @@ constructor( return true } - return /* spotless:off */ other is AiSecretCreateParams && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AiSecretCreateParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index cad70dc8..99869a1a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete an ai_secret object by its id */ class AiSecretDeleteParams -constructor( +private constructor( private val aiSecretId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** AiSecret id */ fun aiSecretId(): String = aiSecretId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AiSecretDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var aiSecretId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): AiSecretDeleteParams = AiSecretDeleteParams( - checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, + checkRequired("aiSecretId", aiSecretId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 9750ec57..7496e3a5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -3,74 +3,113 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** Delete a single ai_secret */ class AiSecretFindAndDeleteParams -constructor( - private val name: String, - private val orgName: String?, +private constructor( + private val body: AiSecretFindAndDeleteBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the AI secret */ + fun name(): String = body.name() - fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. + */ + fun orgName(): Optional = body.orgName() + + /** Name of the AI secret */ + fun _name(): JsonField = body._name() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun _body(): AiSecretFindAndDeleteBody = body - @JvmSynthetic - internal fun getBody(): AiSecretFindAndDeleteBody { - return AiSecretFindAndDeleteBody( - name, - orgName, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = AiSecretFindAndDeleteBody.Builder::class) @NoAutoDetect class AiSecretFindAndDeleteBody + @JsonCreator internal constructor( - private val name: String?, - private val orgName: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the AI secret */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the AI secret */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AiSecretFindAndDeleteBody = apply { + if (validated) { + return@apply + } + + name() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -78,47 +117,69 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AiSecretFindAndDeleteBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var orgName: String? = null + private var name: JsonField? = null + private var orgName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretFindAndDeleteBody: AiSecretFindAndDeleteBody) = apply { - this.name = aiSecretFindAndDeleteBody.name - this.orgName = aiSecretFindAndDeleteBody.orgName - additionalProperties(aiSecretFindAndDeleteBody.additionalProperties) + name = aiSecretFindAndDeleteBody.name + orgName = aiSecretFindAndDeleteBody.orgName + additionalProperties = aiSecretFindAndDeleteBody.additionalProperties.toMutableMap() } /** Name of the AI secret */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the AI secret */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AiSecretFindAndDeleteBody = AiSecretFindAndDeleteBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), orgName, additionalProperties.toImmutable(), ) @@ -149,34 +210,66 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AiSecretFindAndDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var orgName: String? = null + private var body: AiSecretFindAndDeleteBody.Builder = AiSecretFindAndDeleteBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = apply { - name = aiSecretFindAndDeleteParams.name - orgName = aiSecretFindAndDeleteParams.orgName + body = aiSecretFindAndDeleteParams.body.toBuilder() additionalHeaders = aiSecretFindAndDeleteParams.additionalHeaders.toBuilder() additionalQueryParams = aiSecretFindAndDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - aiSecretFindAndDeleteParams.additionalBodyProperties.toMutableMap() } /** Name of the AI secret */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the AI secret */ + fun name(name: JsonField) = apply { body.name(name) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -276,35 +369,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): AiSecretFindAndDeleteParams = AiSecretFindAndDeleteParams( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -313,11 +382,11 @@ constructor( return true } - return /* spotless:off */ other is AiSecretFindAndDeleteParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AiSecretFindAndDeleteParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index 159cdb0c..771e6960 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.AiSecretService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first + */ class AiSecretListPage private constructor( private val aiSecretsService: AiSecretService, @@ -85,16 +90,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -104,11 +108,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -144,10 +152,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -156,8 +162,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: AiSecretListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 35287dea..76bd74f3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.AiSecretServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first + */ class AiSecretListPageAsync private constructor( private val aiSecretsService: AiSecretServiceAsync, @@ -92,16 +97,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +115,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +159,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +169,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: AiSecretListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 24c3dd98..402fb4cf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first + */ class AiSecretListParams -constructor( +private constructor( private val aiSecretName: String?, private val aiSecretType: AiSecretType?, private val endingBefore: String?, @@ -32,30 +36,50 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Name of the ai_secret to search for */ fun aiSecretName(): Optional = Optional.ofNullable(aiSecretName) fun aiSecretType(): Optional = Optional.ofNullable(aiSecretType) + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.aiSecretName?.let { queryParams.put("ai_secret_name", listOf(it.toString())) } this.aiSecretType?.let { queryParams.put("ai_secret_type", listOf(it.toString())) } @@ -75,8 +99,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AiSecretListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var aiSecretName: String? = null private var aiSecretType: AiSecretType? = null @@ -102,17 +127,29 @@ constructor( } /** Name of the ai_secret to search for */ - fun aiSecretName(aiSecretName: String) = apply { this.aiSecretName = aiSecretName } + fun aiSecretName(aiSecretName: String?) = apply { this.aiSecretName = aiSecretName } - fun aiSecretType(aiSecretType: AiSecretType) = apply { this.aiSecretType = aiSecretType } + /** Name of the ai_secret to search for */ + fun aiSecretName(aiSecretName: Optional) = aiSecretName(aiSecretName.orElse(null)) - fun aiSecretType(string: String) = apply { - this.aiSecretType = AiSecretType.ofString(string) - } + fun aiSecretType(aiSecretType: AiSecretType?) = apply { this.aiSecretType = aiSecretType } - fun aiSecretTypeOfStrings(strings: List) = apply { - this.aiSecretType = AiSecretType.ofStrings(strings) - } + fun aiSecretType(aiSecretType: Optional) = + aiSecretType(aiSecretType.orElse(null)) + + fun aiSecretType(string: String) = aiSecretType(AiSecretType.ofString(string)) + + fun aiSecretTypeOfStrings(strings: List) = + aiSecretType(AiSecretType.ofStrings(strings)) + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. @@ -121,31 +158,47 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * Pagination cursor id. @@ -154,7 +207,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -277,8 +340,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -301,15 +362,6 @@ constructor( } } - fun validate(): AiSecretType = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown AiSecretType: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -335,18 +387,32 @@ constructor( @JvmStatic fun ofStrings(strings: List) = AiSecretType(strings = strings) } + /** + * An interface that defines how to map each variant of [AiSecretType] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [AiSecretType] to a value of type [T]. + * + * An instance of [AiSecretType] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown AiSecretType: $json") } } - class Deserializer : BaseDeserializer(AiSecretType::class) { + internal class Deserializer : BaseDeserializer(AiSecretType::class) { override fun ObjectCodec.deserialize(node: JsonNode): AiSecretType { val json = JsonValue.fromJsonNode(node) @@ -362,7 +428,7 @@ constructor( } } - class Serializer : BaseSerializer(AiSecretType::class) { + internal class Serializer : BaseSerializer(AiSecretType::class) { override fun serialize( value: AiSecretType, @@ -379,6 +445,10 @@ constructor( } } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -388,8 +458,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -412,15 +480,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -446,18 +505,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -473,7 +542,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 592dc10d..a1a01520 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -3,99 +3,168 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one + * specified in the request, will replace the existing ai_secret with the provided fields + */ class AiSecretReplaceParams -constructor( - private val name: String, - private val metadata: Metadata?, - private val orgName: String?, - private val secret: String?, - private val type: String?, +private constructor( + private val body: AiSecretReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the AI secret */ + fun name(): String = body.name() - fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = body.metadata() - fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. + */ + fun orgName(): Optional = body.orgName() - fun secret(): Optional = Optional.ofNullable(secret) + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not + * replaced with null. + */ + fun secret(): Optional = body.secret() - fun type(): Optional = Optional.ofNullable(type) + fun type(): Optional = body.type() + + /** Name of the AI secret */ + fun _name(): JsonField = body._name() + + fun _metadata(): JsonField = body._metadata() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not + * replaced with null. + */ + fun _secret(): JsonField = body._secret() + + fun _type(): JsonField = body._type() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): AiSecretReplaceBody { - return AiSecretReplaceBody( - name, - metadata, - orgName, - secret, - type, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): AiSecretReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = AiSecretReplaceBody.Builder::class) @NoAutoDetect class AiSecretReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val metadata: Metadata?, - private val orgName: String?, - private val secret: String?, - private val type: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("secret") + @ExcludeMissing + private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the AI secret */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, * not replaced with null. */ - @JsonProperty("secret") fun secret(): String? = secret + fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) + + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("type") fun type(): String? = type + /** Name of the AI secret */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. + */ + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AiSecretReplaceBody = apply { + if (validated) { + return@apply + } + + name() + metadata().ifPresent { it.validate() } + orgName() + secret() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -103,64 +172,105 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AiSecretReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var metadata: Metadata? = null - private var orgName: String? = null - private var secret: String? = null - private var type: String? = null + private var name: JsonField? = null + private var metadata: JsonField = JsonMissing.of() + private var orgName: JsonField = JsonMissing.of() + private var secret: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretReplaceBody: AiSecretReplaceBody) = apply { - this.name = aiSecretReplaceBody.name - this.metadata = aiSecretReplaceBody.metadata - this.orgName = aiSecretReplaceBody.orgName - this.secret = aiSecretReplaceBody.secret - this.type = aiSecretReplaceBody.type - additionalProperties(aiSecretReplaceBody.additionalProperties) + name = aiSecretReplaceBody.name + metadata = aiSecretReplaceBody.metadata + orgName = aiSecretReplaceBody.orgName + secret = aiSecretReplaceBody.secret + type = aiSecretReplaceBody.type + additionalProperties = aiSecretReplaceBody.additionalProperties.toMutableMap() } /** Name of the AI secret */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + /** Name of the AI secret */ + fun name(name: JsonField) = apply { this.name = name } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. + */ + fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. + */ + fun secret(secret: Optional) = secret(secret.orElse(null)) /** * Secret value. If omitted in a PUT request, the existing secret value will be left * intact, not replaced with null. */ - @JsonProperty("secret") fun secret(secret: String) = apply { this.secret = secret } + fun secret(secret: JsonField) = apply { this.secret = secret } + + fun type(type: String?) = type(JsonField.ofNullable(type)) - @JsonProperty("type") fun type(type: String) = apply { this.type = type } + fun type(type: Optional) = type(type.orElse(null)) + + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AiSecretReplaceBody = AiSecretReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), metadata, orgName, secret, @@ -194,49 +304,96 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AiSecretReplaceParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var metadata: Metadata? = null - private var orgName: String? = null - private var secret: String? = null - private var type: String? = null + private var body: AiSecretReplaceBody.Builder = AiSecretReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretReplaceParams: AiSecretReplaceParams) = apply { - name = aiSecretReplaceParams.name - metadata = aiSecretReplaceParams.metadata - orgName = aiSecretReplaceParams.orgName - secret = aiSecretReplaceParams.secret - type = aiSecretReplaceParams.type + body = aiSecretReplaceParams.body.toBuilder() additionalHeaders = aiSecretReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = aiSecretReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aiSecretReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the AI secret */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the AI secret */ + fun name(name: JsonField) = apply { body.name(name) } + + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. + */ + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, * not replaced with null. */ - fun secret(secret: String) = apply { this.secret = secret } + fun secret(secret: String?) = apply { body.secret(secret) } - fun type(type: String) = apply { this.type = type } + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. + */ + fun secret(secret: Optional) = secret(secret.orElse(null)) + + /** + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. + */ + fun secret(secret: JsonField) = apply { body.secret(secret) } + + fun type(type: String?) = apply { body.type(type) } + + fun type(type: Optional) = type(type.orElse(null)) + + fun type(type: JsonField) = apply { body.type(type) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -336,52 +493,36 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): AiSecretReplaceParams = AiSecretReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - metadata, - orgName, - secret, - type, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -389,29 +530,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -437,11 +584,11 @@ constructor( return true } - return /* spotless:off */ other is AiSecretReplaceParams && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, metadata, orgName, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AiSecretReplaceParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index b9fee653..a312db88 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get an ai_secret object by its id */ class AiSecretRetrieveParams -constructor( +private constructor( private val aiSecretId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** AiSecret id */ fun aiSecretId(): String = aiSecretId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AiSecretRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var aiSecretId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( - checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, + checkRequired("aiSecretId", aiSecretId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 41fc51e5..c5c38aa5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -3,61 +3,68 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update an ai_secret object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ class AiSecretUpdateParams -constructor( +private constructor( private val aiSecretId: String, - private val metadata: Metadata?, - private val name: String?, - private val secret: String?, - private val type: String?, + private val body: AiSecretUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** AiSecret id */ fun aiSecretId(): String = aiSecretId - fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = body.metadata() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the AI secret */ + fun name(): Optional = body.name() - fun secret(): Optional = Optional.ofNullable(secret) + fun secret(): Optional = body.secret() - fun type(): Optional = Optional.ofNullable(type) + fun type(): Optional = body.type() + + fun _metadata(): JsonField = body._metadata() + + /** Name of the AI secret */ + fun _name(): JsonField = body._name() + + fun _secret(): JsonField = body._secret() + + fun _type(): JsonField = body._type() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): AiSecretUpdateBody { - return AiSecretUpdateBody( - metadata, - name, - secret, - type, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): AiSecretUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -66,30 +73,62 @@ constructor( } } - @JsonDeserialize(builder = AiSecretUpdateBody.Builder::class) @NoAutoDetect class AiSecretUpdateBody + @JsonCreator internal constructor( - private val metadata: Metadata?, - private val name: String?, - private val secret: String?, - private val type: String?, - private val additionalProperties: Map, + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("secret") + @ExcludeMissing + private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Name of the AI secret */ - @JsonProperty("name") fun name(): String? = name + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) - @JsonProperty("secret") fun secret(): String? = secret + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("type") fun type(): String? = type + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** Name of the AI secret */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AiSecretUpdateBody = apply { + if (validated) { + return@apply + } + + metadata().ifPresent { it.validate() } + name() + secret() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,47 +136,70 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AiSecretUpdateBody]. */ + class Builder internal constructor() { - private var metadata: Metadata? = null - private var name: String? = null - private var secret: String? = null - private var type: String? = null + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var secret: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretUpdateBody: AiSecretUpdateBody) = apply { - this.metadata = aiSecretUpdateBody.metadata - this.name = aiSecretUpdateBody.name - this.secret = aiSecretUpdateBody.secret - this.type = aiSecretUpdateBody.type - additionalProperties(aiSecretUpdateBody.additionalProperties) + metadata = aiSecretUpdateBody.metadata + name = aiSecretUpdateBody.name + secret = aiSecretUpdateBody.secret + type = aiSecretUpdateBody.type + additionalProperties = aiSecretUpdateBody.additionalProperties.toMutableMap() } - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Name of the AI secret */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the AI secret */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the AI secret */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } - @JsonProperty("secret") fun secret(secret: String) = apply { this.secret = secret } + fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) - @JsonProperty("type") fun type(type: String) = apply { this.type = type } + fun secret(secret: Optional) = secret(secret.orElse(null)) + + fun secret(secret: JsonField) = apply { this.secret = secret } + + fun type(type: String?) = type(JsonField.ofNullable(type)) + + fun type(type: Optional) = type(type.orElse(null)) + + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AiSecretUpdateBody = AiSecretUpdateBody( metadata, @@ -173,41 +235,71 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AiSecretUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var aiSecretId: String? = null - private var metadata: Metadata? = null - private var name: String? = null - private var secret: String? = null - private var type: String? = null + private var body: AiSecretUpdateBody.Builder = AiSecretUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(aiSecretUpdateParams: AiSecretUpdateParams) = apply { aiSecretId = aiSecretUpdateParams.aiSecretId - metadata = aiSecretUpdateParams.metadata - name = aiSecretUpdateParams.name - secret = aiSecretUpdateParams.secret - type = aiSecretUpdateParams.type + body = aiSecretUpdateParams.body.toBuilder() additionalHeaders = aiSecretUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = aiSecretUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aiSecretUpdateParams.additionalBodyProperties.toMutableMap() } /** AiSecret id */ fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the AI secret */ - fun name(name: String) = apply { this.name = name } + fun name(name: String?) = apply { body.name(name) } + + /** Name of the AI secret */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the AI secret */ + fun name(name: JsonField) = apply { body.name(name) } + + fun secret(secret: String?) = apply { body.secret(secret) } - fun secret(secret: String) = apply { this.secret = secret } + fun secret(secret: Optional) = secret(secret.orElse(null)) - fun type(type: String) = apply { this.type = type } + fun secret(secret: JsonField) = apply { body.secret(secret) } + + fun type(type: String?) = apply { body.type(type) } + + fun type(type: Optional) = type(type.orElse(null)) + + fun type(type: JsonField) = apply { body.type(type) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -307,52 +399,37 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): AiSecretUpdateParams = AiSecretUpdateParams( - checkNotNull(aiSecretId) { "`aiSecretId` is required but was not set" }, - metadata, - name, - secret, - type, + checkRequired("aiSecretId", aiSecretId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -360,29 +437,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -408,11 +491,11 @@ constructor( return true } - return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, metadata, name, secret, type, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AiSecretUpdateParams{aiSecretId=$aiSecretId, metadata=$metadata, name=$name, secret=$secret, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "AiSecretUpdateParams{aiSecretId=$aiSecretId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 4a87b0da..f70d6af1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -7,78 +7,90 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ApiKey.Builder::class) @NoAutoDetect class ApiKey +@JsonCreator private constructor( - private val id: JsonField, - private val created: JsonField, - private val name: JsonField, - private val previewName: JsonField, - private val userId: JsonField, - private val orgId: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("preview_name") + @ExcludeMissing + private val previewName: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the api key */ fun id(): String = id.getRequired("id") - /** Date of api key creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Name of the api key */ fun name(): String = name.getRequired("name") fun previewName(): String = previewName.getRequired("preview_name") - /** Unique identifier for the user */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** Date of api key creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Unique identifier for the organization */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) - /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + /** Unique identifier for the user */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + /** Unique identifier for the api key */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("preview_name") @ExcludeMissing fun _previewName() = previewName + @JsonProperty("preview_name") + @ExcludeMissing + fun _previewName(): JsonField = previewName - /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + /** Date of api key creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + + /** Unique identifier for the user */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ApiKey = apply { - if (!validated) { - id() - created() - name() - previewName() - userId() - orgId() - validated = true + if (validated) { + return@apply } + + id() + name() + previewName() + created() + orgId() + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -88,93 +100,98 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ApiKey]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var previewName: JsonField? = null private var created: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var previewName: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() private var orgId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(apiKey: ApiKey) = apply { - this.id = apiKey.id - this.created = apiKey.created - this.name = apiKey.name - this.previewName = apiKey.previewName - this.userId = apiKey.userId - this.orgId = apiKey.orgId - additionalProperties(apiKey.additionalProperties) + id = apiKey.id + name = apiKey.name + previewName = apiKey.previewName + created = apiKey.created + orgId = apiKey.orgId + userId = apiKey.userId + additionalProperties = apiKey.additionalProperties.toMutableMap() } /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** Date of api key creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** Date of api key creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun id(id: JsonField) = apply { this.id = id } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - @JsonProperty("preview_name") - @ExcludeMissing fun previewName(previewName: JsonField) = apply { this.previewName = previewName } - /** Unique identifier for the user */ - fun userId(userId: String) = userId(JsonField.of(userId)) + /** Date of api key creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Unique identifier for the user */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + /** Date of api key creation */ + fun created(created: Optional) = created(created.orElse(null)) + + /** Date of api key creation */ + fun created(created: JsonField) = apply { this.created = created } + + /** Unique identifier for the organization */ + fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) + fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + /** Unique identifier for the user */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Unique identifier for the user */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Unique identifier for the user */ + fun userId(userId: JsonField) = apply { this.userId = userId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ApiKey = ApiKey( - id, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("previewName", previewName), created, - name, - previewName, - userId, orgId, + userId, additionalProperties.toImmutable(), ) } @@ -184,15 +201,15 @@ private constructor( return true } - return /* spotless:off */ other is ApiKey && id == other.id && created == other.created && name == other.name && previewName == other.previewName && userId == other.userId && orgId == other.orgId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ApiKey && id == other.id && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, created, name, previewName, userId, orgId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, previewName, created, orgId, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ApiKey{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, additionalProperties=$additionalProperties}" + "ApiKey{id=$id, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index e1a95de1..057a7a4f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -3,74 +3,116 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new api_key. It is possible to have multiple API keys with the same name. There is no + * de-duplication + */ class ApiKeyCreateParams -constructor( - private val name: String, - private val orgName: String?, +private constructor( + private val body: ApiKeyCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the api key. Does not have to be unique */ + fun name(): String = body.name() - fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * API key belongs in. + */ + fun orgName(): Optional = body.orgName() + + /** Name of the api key. Does not have to be unique */ + fun _name(): JsonField = body._name() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * API key belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun _body(): ApiKeyCreateBody = body - @JvmSynthetic - internal fun getBody(): ApiKeyCreateBody { - return ApiKeyCreateBody( - name, - orgName, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = ApiKeyCreateBody.Builder::class) @NoAutoDetect class ApiKeyCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val orgName: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the API key belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the api key. Does not have to be unique */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ApiKeyCreateBody = apply { + if (validated) { + return@apply + } + + name() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -78,47 +120,69 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ApiKeyCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var orgName: String? = null + private var name: JsonField? = null + private var orgName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(apiKeyCreateBody: ApiKeyCreateBody) = apply { - this.name = apiKeyCreateBody.name - this.orgName = apiKeyCreateBody.orgName - additionalProperties(apiKeyCreateBody.additionalProperties) + name = apiKeyCreateBody.name + orgName = apiKeyCreateBody.orgName + additionalProperties = apiKeyCreateBody.additionalProperties.toMutableMap() } /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the api key. Does not have to be unique */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the API key belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ApiKeyCreateBody = ApiKeyCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), orgName, additionalProperties.toImmutable(), ) @@ -149,33 +213,66 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ApiKeyCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var orgName: String? = null + private var body: ApiKeyCreateBody.Builder = ApiKeyCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { - name = apiKeyCreateParams.name - orgName = apiKeyCreateParams.orgName + body = apiKeyCreateParams.body.toBuilder() additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = apiKeyCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the api key. Does not have to be unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the api key. Does not have to be unique */ + fun name(name: JsonField) = apply { body.name(name) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the API key belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. + */ + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -275,35 +372,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ApiKeyCreateParams = ApiKeyCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -312,11 +385,11 @@ constructor( return true } - return /* spotless:off */ other is ApiKeyCreateParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ApiKeyCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index a614a6ad..b52bc42e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete an api_key object by its id */ class ApiKeyDeleteParams -constructor( +private constructor( private val apiKeyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** ApiKey id */ fun apiKeyId(): String = apiKeyId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ApiKeyDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var apiKeyId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( - checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, + checkRequired("apiKeyId", apiKeyId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 933b6db5..846d2563 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.ApiKeyService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created + * api_keys coming first + */ class ApiKeyListPage private constructor( private val apiKeysService: ApiKeyService, @@ -79,16 +84,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -98,11 +102,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,10 +146,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -150,8 +156,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ApiKeyListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index 29cdabae..1e9dfbd6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.ApiKeyServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created + * api_keys coming first + */ class ApiKeyListPageAsync private constructor( private val apiKeysService: ApiKeyServiceAsync, @@ -82,16 +87,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -101,11 +105,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -141,10 +149,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -153,8 +159,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ApiKeyListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index a2571a54..c641baca 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created + * api_keys coming first + */ class ApiKeyListParams -constructor( +private constructor( private val apiKeyName: String?, private val endingBefore: String?, private val ids: Ids?, @@ -31,28 +35,48 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Name of the api_key to search for */ fun apiKeyName(): Optional = Optional.ofNullable(apiKeyName) + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.apiKeyName?.let { queryParams.put("api_key_name", listOf(it.toString())) } this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } @@ -71,8 +95,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ApiKeyListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var apiKeyName: String? = null private var endingBefore: String? = null @@ -96,7 +121,10 @@ constructor( } /** Name of the api_key to search for */ - fun apiKeyName(apiKeyName: String) = apply { this.apiKeyName = apiKeyName } + fun apiKeyName(apiKeyName: String?) = apply { this.apiKeyName = apiKeyName } + + /** Name of the api_key to search for */ + fun apiKeyName(apiKeyName: Optional) = apiKeyName(apiKeyName.orElse(null)) /** * Pagination cursor id. @@ -105,31 +133,56 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = ids(Ids.ofString(string)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long) = limit(limit as Long?) + + /** Limit the number of objects to return */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * Pagination cursor id. @@ -138,7 +191,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -251,6 +314,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -260,8 +327,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -284,15 +349,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -318,18 +374,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -345,7 +411,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index e6a5848a..3680e5bb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get an api_key object by its id */ class ApiKeyRetrieveParams -constructor( +private constructor( private val apiKeyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** ApiKey id */ fun apiKeyId(): String = apiKeyId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ApiKeyRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var apiKeyId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( - checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, + checkRequired("apiKeyId", apiKeyId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index ed412255..df858b7b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -8,45 +8,50 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ChatCompletionContentPartImage.Builder::class) @NoAutoDetect class ChatCompletionContentPartImage +@JsonCreator private constructor( - private val imageUrl: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("image_url") + @ExcludeMissing + private val imageUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") fun type(): Type = type.getRequired("type") - @JsonProperty("image_url") @ExcludeMissing fun _imageUrl() = imageUrl + @JsonProperty("image_url") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ChatCompletionContentPartImage = apply { - if (!validated) { - imageUrl().validate() - type() - validated = true + if (validated) { + return@apply } + + imageUrl().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -56,82 +61,90 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ChatCompletionContentPartImage]. */ + class Builder internal constructor() { - private var imageUrl: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var imageUrl: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(chatCompletionContentPartImage: ChatCompletionContentPartImage) = apply { - this.imageUrl = chatCompletionContentPartImage.imageUrl - this.type = chatCompletionContentPartImage.type - additionalProperties(chatCompletionContentPartImage.additionalProperties) + imageUrl = chatCompletionContentPartImage.imageUrl + type = chatCompletionContentPartImage.type + additionalProperties = + chatCompletionContentPartImage.additionalProperties.toMutableMap() } fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) - @JsonProperty("image_url") - @ExcludeMissing fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ChatCompletionContentPartImage = ChatCompletionContentPartImage( - imageUrl, - type, + checkRequired("imageUrl", imageUrl), + checkRequired("type", type), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect class ImageUrl + @JsonCreator private constructor( - private val url: JsonField, - private val detail: JsonField, - private val additionalProperties: Map, + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonProperty("detail") + @ExcludeMissing + private val detail: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun url(): String = url.getRequired("url") fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - @JsonProperty("detail") @ExcludeMissing fun _detail() = detail + @JsonProperty("detail") @ExcludeMissing fun _detail(): JsonField = detail @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ImageUrl = apply { - if (!validated) { - url() - detail() - validated = true + if (validated) { + return@apply } + + url() + detail() + validated = true } fun toBuilder() = Builder().from(this) @@ -141,48 +154,50 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ImageUrl]. */ + class Builder internal constructor() { - private var url: JsonField = JsonMissing.of() + private var url: JsonField? = null private var detail: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(imageUrl: ImageUrl) = apply { - this.url = imageUrl.url - this.detail = imageUrl.detail - additionalProperties(imageUrl.additionalProperties) + url = imageUrl.url + detail = imageUrl.detail + additionalProperties = imageUrl.additionalProperties.toMutableMap() } fun url(url: String) = url(JsonField.of(url)) - @JsonProperty("url") - @ExcludeMissing fun url(url: JsonField) = apply { this.url = url } fun detail(detail: Detail) = detail(JsonField.of(detail)) - @JsonProperty("detail") - @ExcludeMissing fun detail(detail: JsonField) = apply { this.detail = detail } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ImageUrl = ImageUrl( - url, + checkRequired("url", url), detail, additionalProperties.toImmutable(), ) @@ -194,44 +209,60 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val AUTO = Detail(JsonField.of("auto")) + @JvmField val AUTO = of("auto") - @JvmField val LOW = Detail(JsonField.of("low")) + @JvmField val LOW = of("low") - @JvmField val HIGH = Detail(JsonField.of("high")) + @JvmField val HIGH = of("high") @JvmStatic fun of(value: String) = Detail(JsonField.of(value)) } + /** An enum containing [Detail]'s known values. */ enum class Known { AUTO, LOW, HIGH, } + /** + * An enum containing [Detail]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Detail] 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 { AUTO, LOW, HIGH, + /** + * An enum member indicating that [Detail] 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) { AUTO -> Value.AUTO @@ -240,6 +271,15 @@ private constructor( 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) { AUTO -> Known.AUTO @@ -249,6 +289,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -275,42 +327,65 @@ 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 - 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() - companion object { - @JvmField val IMAGE_URL = Type(JsonField.of("image_url")) + @JvmField val IMAGE_URL = of("image_url") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { IMAGE_URL, } + /** + * 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 { IMAGE_URL, + /** 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) { IMAGE_URL -> Value.IMAGE_URL 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) { IMAGE_URL -> Known.IMAGE_URL @@ -318,6 +393,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index 70f25c06..fd421416 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -8,45 +8,48 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ChatCompletionContentPartText.Builder::class) @NoAutoDetect class ChatCompletionContentPartText +@JsonCreator private constructor( - private val text: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun type(): Type = type.getRequired("type") fun text(): Optional = Optional.ofNullable(text.getNullable("text")) - fun type(): Type = type.getRequired("type") - - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ChatCompletionContentPartText = apply { - if (!validated) { - text() - type() - validated = true + if (validated) { + return@apply } + + type() + text() + validated = true } fun toBuilder() = Builder().from(this) @@ -56,49 +59,51 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ChatCompletionContentPartText]. */ + class Builder internal constructor() { + private var type: JsonField? = null private var text: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(chatCompletionContentPartText: ChatCompletionContentPartText) = apply { - this.text = chatCompletionContentPartText.text - this.type = chatCompletionContentPartText.type - additionalProperties(chatCompletionContentPartText.additionalProperties) + type = chatCompletionContentPartText.type + text = chatCompletionContentPartText.text + additionalProperties = chatCompletionContentPartText.additionalProperties.toMutableMap() } - fun text(text: String) = text(JsonField.of(text)) - - @JsonProperty("text") - @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } - fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } + fun text(text: String) = text(JsonField.of(text)) + + fun text(text: JsonField) = apply { this.text = text } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ChatCompletionContentPartText = ChatCompletionContentPartText( + checkRequired("type", type), text, - type, additionalProperties.toImmutable(), ) } @@ -109,42 +114,65 @@ 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 - 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() - companion object { - @JvmField val TEXT = Type(JsonField.of("text")) + @JvmField val TEXT = of("text") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { TEXT, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { TEXT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { TEXT -> Value.TEXT else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { TEXT -> Known.TEXT @@ -152,6 +180,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -159,15 +199,15 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionContentPartText && text == other.text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartText && type == other.type && text == other.text && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(text, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(type, text, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ChatCompletionContentPartText{text=$text, type=$type, additionalProperties=$additionalProperties}" + "ChatCompletionContentPartText{type=$type, text=$text, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 6b7482ba..26594d72 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -8,50 +8,55 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects -@JsonDeserialize(builder = ChatCompletionMessageToolCall.Builder::class) @NoAutoDetect class ChatCompletionMessageToolCall +@JsonCreator private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("function") + @ExcludeMissing + private val function: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun id(): String = id.getRequired("id") fun function(): Function = function.getRequired("function") fun type(): Type = type.getRequired("type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("function") @ExcludeMissing fun _function() = function + @JsonProperty("function") @ExcludeMissing fun _function(): JsonField = function - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ChatCompletionMessageToolCall = apply { - if (!validated) { - id() - function().validate() - type() - validated = true + if (validated) { + return@apply } + + id() + function().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -61,89 +66,98 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ChatCompletionMessageToolCall]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var function: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(chatCompletionMessageToolCall: ChatCompletionMessageToolCall) = apply { - this.id = chatCompletionMessageToolCall.id - this.function = chatCompletionMessageToolCall.function - this.type = chatCompletionMessageToolCall.type - additionalProperties(chatCompletionMessageToolCall.additionalProperties) + id = chatCompletionMessageToolCall.id + function = chatCompletionMessageToolCall.function + type = chatCompletionMessageToolCall.type + additionalProperties = chatCompletionMessageToolCall.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) - @JsonProperty("function") - @ExcludeMissing fun function(function: JsonField) = apply { this.function = function } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ChatCompletionMessageToolCall = ChatCompletionMessageToolCall( - id, - function, - type, + checkRequired("id", id), + checkRequired("function", function), + checkRequired("type", type), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function + @JsonCreator private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("arguments") + @ExcludeMissing + private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - arguments() - name() - validated = true + if (validated) { + return@apply } + + arguments() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -153,49 +167,51 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Function]. */ + class Builder internal constructor() { - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var arguments: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.arguments = function.arguments - this.name = function.name - additionalProperties(function.additionalProperties) + arguments = function.arguments + name = function.name + additionalProperties = function.additionalProperties.toMutableMap() } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - @JsonProperty("arguments") - @ExcludeMissing fun arguments(arguments: JsonField) = apply { this.arguments = arguments } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Function = Function( - arguments, - name, + checkRequired("arguments", arguments), + checkRequired("name", name), additionalProperties.toImmutable(), ) } @@ -224,42 +240,65 @@ 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 - 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() - companion object { - @JvmField val FUNCTION = Type(JsonField.of("function")) + @JvmField val FUNCTION = of("function") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { FUNCTION, } + /** + * 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 { FUNCTION, + /** 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) { 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) { FUNCTION -> Known.FUNCTION @@ -267,6 +306,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index c88ce5df..b7f16dd4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -10,7 +10,9 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -27,49 +29,61 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = CodeBundle.Builder::class) @NoAutoDetect class CodeBundle +@JsonCreator private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val additionalProperties: Map, + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): Location = location.getRequired("location") - fun bundleId(): String = bundleId.getRequired("bundle_id") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) - @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext + @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("runtime_context") + @ExcludeMissing + fun _runtimeContext(): JsonField = runtimeContext /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): CodeBundle = apply { - if (!validated) { - runtimeContext().validate() - location() - bundleId() - preview() - validated = true + if (validated) { + return@apply } + + bundleId() + location().validate() + runtimeContext().validate() + preview() + validated = true } fun toBuilder() = Builder().from(this) @@ -79,71 +93,76 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CodeBundle]. */ + class Builder internal constructor() { - private var runtimeContext: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var bundleId: JsonField = JsonMissing.of() + private var bundleId: JsonField? = null + private var location: JsonField? = null + private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(codeBundle: CodeBundle) = apply { - this.runtimeContext = codeBundle.runtimeContext - this.location = codeBundle.location - this.bundleId = codeBundle.bundleId - this.preview = codeBundle.preview - additionalProperties(codeBundle.additionalProperties) + bundleId = codeBundle.bundleId + location = codeBundle.location + runtimeContext = codeBundle.runtimeContext + preview = codeBundle.preview + additionalProperties = codeBundle.additionalProperties.toMutableMap() } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - @JsonProperty("runtime_context") - @ExcludeMissing - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } fun location(location: Location) = location(JsonField.of(location)) - @JsonProperty("location") - @ExcludeMissing fun location(location: JsonField) = apply { this.location = location } - fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + fun location(experiment: Location.Experiment) = location(Location.ofExperiment(experiment)) - @JsonProperty("bundle_id") - @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } + fun location(function: Location.Function) = location(Location.ofFunction(function)) + + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) + + fun runtimeContext(runtimeContext: JsonField) = apply { + this.runtimeContext = runtimeContext + } /** A preview of the code */ - fun preview(preview: String) = preview(JsonField.of(preview)) + fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) + + /** A preview of the code */ + fun preview(preview: Optional) = preview(preview.orElse(null)) /** A preview of the code */ - @JsonProperty("preview") - @ExcludeMissing fun preview(preview: JsonField) = apply { this.preview = preview } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): CodeBundle = CodeBundle( - runtimeContext, - location, - bundleId, + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), preview, additionalProperties.toImmutable(), ) @@ -158,8 +177,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun experiment(): Optional = Optional.ofNullable(experiment) fun function(): Optional = Optional.ofNullable(function) @@ -182,15 +199,25 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): Location = apply { - if (!validated) { - if (experiment == null && function == null) { - throw BraintrustInvalidDataException("Unknown Location: $_json") - } - experiment?.validate() - function?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitExperiment(experiment: Experiment) { + experiment.validate() + } + + override fun visitFunction(function: Function) { + function.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -218,18 +245,31 @@ private constructor( @JvmStatic fun ofFunction(function: Function) = Location(function = function) } + /** + * An interface that defines how to map each variant of [Location] to a value of type [T]. + */ interface Visitor { fun visitExperiment(experiment: Experiment): T fun visitFunction(function: Function): T + /** + * Maps an unknown variant of [Location] to a value of type [T]. + * + * An instance of [Location] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Location: $json") } } - class Deserializer : BaseDeserializer(Location::class) { + internal class Deserializer : BaseDeserializer(Location::class) { override fun ObjectCodec.deserialize(node: JsonNode): Location { val json = JsonValue.fromJsonNode(node) @@ -247,7 +287,7 @@ private constructor( } } - class Serializer : BaseSerializer(Location::class) { + internal class Serializer : BaseSerializer(Location::class) { override fun serialize( value: Location, @@ -263,41 +303,52 @@ private constructor( } } - @JsonDeserialize(builder = Experiment.Builder::class) @NoAutoDetect class Experiment + @JsonCreator private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + @JsonProperty("eval_name") + @ExcludeMissing + private val evalName: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") - fun evalName(): String = evalName.getRequired("eval_name") fun position(): Position = position.getRequired("position") - @JsonProperty("type") @ExcludeMissing fun _type() = type + fun type(): Type = type.getRequired("type") + + @JsonProperty("eval_name") @ExcludeMissing fun _evalName(): JsonField = evalName - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Experiment = apply { - if (!validated) { - type() - evalName() - position() - validated = true + if (validated) { + return@apply } + + evalName() + position().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -307,47 +358,45 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Experiment]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var evalName: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() + private var evalName: JsonField? = null + private var position: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experiment: Experiment) = apply { - this.type = experiment.type - this.evalName = experiment.evalName - this.position = experiment.position - additionalProperties(experiment.additionalProperties) + evalName = experiment.evalName + position = experiment.position + type = experiment.type + additionalProperties = experiment.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun evalName(evalName: String) = evalName(JsonField.of(evalName)) - @JsonProperty("eval_name") - @ExcludeMissing fun evalName(evalName: JsonField) = apply { this.evalName = evalName } fun position(position: Position) = position(JsonField.of(position)) - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } + fun position(type: Position.Type) = position(Position.ofType(type)) + + fun position(scorer: Position.Scorer) = position(Position.ofScorer(scorer)) + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -355,11 +404,19 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Experiment = Experiment( - type, - evalName, - position, + checkRequired("evalName", evalName), + checkRequired("position", position), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -373,8 +430,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun type(): Optional = Optional.ofNullable(type) fun scorer(): Optional = Optional.ofNullable(scorer) @@ -397,15 +452,25 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): Position = apply { - if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException("Unknown Position: $_json") - } - type?.validate() - scorer?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitType(type: Type) { + type.validate() + } + + override fun visitScorer(scorer: Scorer) { + scorer.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -433,18 +498,32 @@ private constructor( @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) } + /** + * An interface that defines how to map each variant of [Position] to a value of + * type [T]. + */ interface Visitor { fun visitType(type: Type): T fun visitScorer(scorer: Scorer): T + /** + * Maps an unknown variant of [Position] to a value of type [T]. + * + * An instance of [Position] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Position: $json") } } - class Deserializer : BaseDeserializer(Position::class) { + internal class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { val json = JsonValue.fromJsonNode(node) @@ -462,7 +541,7 @@ private constructor( } } - class Serializer : BaseSerializer(Position::class) { + internal class Serializer : BaseSerializer(Position::class) { override fun serialize( value: Position, @@ -478,29 +557,34 @@ private constructor( } } - @JsonDeserialize(builder = Type.Builder::class) @NoAutoDetect class Type + @JsonCreator private constructor( - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun type(): InnerType = type.getRequired("type") - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Type = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -510,92 +594,142 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Type]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(type: Type) = apply { this.type = type.type - additionalProperties(type.additionalProperties) + additionalProperties = type.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: InnerType) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Type = Type(type, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Type = + Type(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type + class InnerType @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 - 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() - companion object { - @JvmField val TASK = Type(JsonField.of("task")) + @JvmField val TASK = of("task") - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun of(value: String) = InnerType(JsonField.of(value)) } + /** An enum containing [InnerType]'s known values. */ enum class Known { TASK, } + /** + * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InnerType] 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 { TASK, + /** + * An enum member indicating that [InnerType] 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) { TASK -> Value.TASK 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) { TASK -> Known.TASK - else -> throw BraintrustInvalidDataException("Unknown Type: $value") + else -> + throw BraintrustInvalidDataException( + "Unknown InnerType: $value" + ) } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -616,35 +750,42 @@ private constructor( "Type{type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Scorer.Builder::class) @NoAutoDetect class Scorer + @JsonCreator private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, + @JsonProperty("index") + @ExcludeMissing + private val index: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun index(): Long = index.getRequired("index") fun type(): Type = type.getRequired("type") - fun index(): Long = index.getRequired("index") + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("index") @ExcludeMissing fun _index() = index + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Scorer = apply { - if (!validated) { - type() - index() - validated = true + if (validated) { + return@apply } + + index() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -654,51 +795,55 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Scorer]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var index: JsonField = JsonMissing.of() + private var index: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scorer: Scorer) = apply { - this.type = scorer.type - this.index = scorer.index - additionalProperties(scorer.additionalProperties) + index = scorer.index + type = scorer.type + additionalProperties = scorer.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun index(index: Long) = index(JsonField.of(index)) - @JsonProperty("index") - @ExcludeMissing fun index(index: JsonField) = apply { this.index = index } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Scorer = Scorer( - type, - index, + checkRequired("index", index), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -709,43 +854,70 @@ 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 - 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() - companion object { - @JvmField val SCORER = Type(JsonField.of("scorer")) + @JvmField val SCORER = of("scorer") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { SCORER, } + /** + * 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 { SCORER, + /** + * 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) { SCORER -> Value.SCORER 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) { SCORER -> Known.SCORER @@ -753,6 +925,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -760,17 +944,17 @@ private constructor( return true } - return /* spotless:off */ other is Scorer && type == other.type && index == other.index && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scorer && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, index, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(index, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + "Scorer{index=$index, type=$type, additionalProperties=$additionalProperties}" } } @@ -780,42 +964,67 @@ 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 - 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() - companion object { - @JvmField val EXPERIMENT = Type(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { EXPERIMENT, } + /** + * 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 { EXPERIMENT, + /** + * 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) { EXPERIMENT -> Value.EXPERIMENT 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) { EXPERIMENT -> Known.EXPERIMENT @@ -823,6 +1032,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -830,48 +1051,55 @@ private constructor( return true } - return /* spotless:off */ other is Experiment && type == other.type && evalName == other.evalName && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && evalName == other.evalName && position == other.position && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, evalName, position, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(evalName, position, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Experiment{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + "Experiment{evalName=$evalName, position=$position, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function + @JsonCreator private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, + @JsonProperty("index") + @ExcludeMissing + private val index: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun index(): Long = index.getRequired("index") fun type(): Type = type.getRequired("type") - fun index(): Long = index.getRequired("index") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index - @JsonProperty("index") @ExcludeMissing fun _index() = index + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - type() - index() - validated = true + if (validated) { + return@apply } + + index() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -881,39 +1109,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Function]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var index: JsonField = JsonMissing.of() + private var index: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.type = function.type - this.index = function.index - additionalProperties(function.additionalProperties) + index = function.index + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun index(index: Long) = index(JsonField.of(index)) - @JsonProperty("index") - @ExcludeMissing fun index(index: JsonField) = apply { this.index = index } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -921,10 +1145,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Function = Function( - type, - index, + checkRequired("index", index), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -935,42 +1167,67 @@ 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 - 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() - companion object { - @JvmField val FUNCTION = Type(JsonField.of("function")) + @JvmField val FUNCTION = of("function") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { FUNCTION, } + /** + * 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 { FUNCTION, + /** + * 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) { 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) { FUNCTION -> Known.FUNCTION @@ -978,6 +1235,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -985,49 +1254,56 @@ private constructor( return true } - return /* spotless:off */ other is Function && type == other.type && index == other.index && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, index, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(index, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Function{type=$type, index=$index, additionalProperties=$additionalProperties}" + "Function{index=$index, type=$type, additionalProperties=$additionalProperties}" } } - @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect class RuntimeContext + @JsonCreator private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): RuntimeContext = apply { - if (!validated) { - runtime() - version() - validated = true + if (validated) { + return@apply } + + runtime() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1037,49 +1313,51 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RuntimeContext]. */ + class Builder internal constructor() { - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var runtime: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { - this.runtime = runtimeContext.runtime - this.version = runtimeContext.version - additionalProperties(runtimeContext.additionalProperties) + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - @JsonProperty("runtime") - @ExcludeMissing fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RuntimeContext = RuntimeContext( - runtime, - version, + checkRequired("runtime", runtime), + checkRequired("version", version), additionalProperties.toImmutable(), ) } @@ -1090,40 +1368,56 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val NODE = Runtime(JsonField.of("node")) + @JvmField val NODE = of("node") - @JvmField val PYTHON = Runtime(JsonField.of("python")) + @JvmField val PYTHON = of("python") @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) } + /** An enum containing [Runtime]'s known values. */ enum class Known { NODE, PYTHON, } + /** + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] 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 { NODE, PYTHON, + /** + * An enum member indicating that [Runtime] 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) { NODE -> Value.NODE @@ -1131,6 +1425,15 @@ private constructor( 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) { NODE -> Known.NODE @@ -1139,6 +1442,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1164,15 +1479,15 @@ private constructor( return true } - return /* spotless:off */ other is CodeBundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CodeBundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(bundleId, location, runtimeContext, preview, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "CodeBundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" + "CodeBundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index 72fcbff1..b0407b94 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -7,86 +7,98 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = CreateApiKeyOutput.Builder::class) @NoAutoDetect class CreateApiKeyOutput +@JsonCreator private constructor( - private val id: JsonField, - private val created: JsonField, - private val name: JsonField, - private val previewName: JsonField, - private val userId: JsonField, - private val orgId: JsonField, - private val key: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("key") @ExcludeMissing private val key: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("preview_name") + @ExcludeMissing + private val previewName: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the api key */ fun id(): String = id.getRequired("id") - /** Date of api key creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** The raw API key. It will only be exposed this one time */ + fun key(): String = key.getRequired("key") /** Name of the api key */ fun name(): String = name.getRequired("name") fun previewName(): String = previewName.getRequired("preview_name") - /** Unique identifier for the user */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** Date of api key creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Unique identifier for the organization */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) - /** The raw API key. It will only be exposed this one time */ - fun key(): String = key.getRequired("key") + /** Unique identifier for the user */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + /** The raw API key. It will only be exposed this one time */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("preview_name") @ExcludeMissing fun _previewName() = previewName + @JsonProperty("preview_name") + @ExcludeMissing + fun _previewName(): JsonField = previewName - /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + /** Date of api key creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** The raw API key. It will only be exposed this one time */ - @JsonProperty("key") @ExcludeMissing fun _key() = key + /** Unique identifier for the user */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): CreateApiKeyOutput = apply { - if (!validated) { - id() - created() - name() - previewName() - userId() - orgId() - key() - validated = true + if (validated) { + return@apply } + + id() + key() + name() + previewName() + created() + orgId() + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -96,104 +108,107 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CreateApiKeyOutput]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var key: JsonField? = null + private var name: JsonField? = null + private var previewName: JsonField? = null private var created: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var previewName: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() private var orgId: JsonField = JsonMissing.of() - private var key: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(createApiKeyOutput: CreateApiKeyOutput) = apply { - this.id = createApiKeyOutput.id - this.created = createApiKeyOutput.created - this.name = createApiKeyOutput.name - this.previewName = createApiKeyOutput.previewName - this.userId = createApiKeyOutput.userId - this.orgId = createApiKeyOutput.orgId - this.key = createApiKeyOutput.key - additionalProperties(createApiKeyOutput.additionalProperties) + id = createApiKeyOutput.id + key = createApiKeyOutput.key + name = createApiKeyOutput.name + previewName = createApiKeyOutput.previewName + created = createApiKeyOutput.created + orgId = createApiKeyOutput.orgId + userId = createApiKeyOutput.userId + additionalProperties = createApiKeyOutput.additionalProperties.toMutableMap() } /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** Date of api key creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + /** The raw API key. It will only be exposed this one time */ + fun key(key: String) = key(JsonField.of(key)) - /** Date of api key creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + /** The raw API key. It will only be exposed this one time */ + fun key(key: JsonField) = apply { this.key = key } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - @JsonProperty("preview_name") - @ExcludeMissing fun previewName(previewName: JsonField) = apply { this.previewName = previewName } - /** Unique identifier for the user */ - fun userId(userId: String) = userId(JsonField.of(userId)) + /** Date of api key creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Unique identifier for the user */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + /** Date of api key creation */ + fun created(created: Optional) = created(created.orElse(null)) + + /** Date of api key creation */ + fun created(created: JsonField) = apply { this.created = created } + + /** Unique identifier for the organization */ + fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) + fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - /** The raw API key. It will only be exposed this one time */ - fun key(key: String) = key(JsonField.of(key)) + /** Unique identifier for the user */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** The raw API key. It will only be exposed this one time */ - @JsonProperty("key") - @ExcludeMissing - fun key(key: JsonField) = apply { this.key = key } + /** Unique identifier for the user */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Unique identifier for the user */ + fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): CreateApiKeyOutput = CreateApiKeyOutput( - id, + checkRequired("id", id), + checkRequired("key", key), + checkRequired("name", name), + checkRequired("previewName", previewName), created, - name, - previewName, - userId, orgId, - key, + userId, additionalProperties.toImmutable(), ) } @@ -203,15 +218,15 @@ private constructor( return true } - return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && created == other.created && name == other.name && previewName == other.previewName && userId == other.userId && orgId == other.orgId && key == other.key && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && key == other.key && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, created, name, previewName, userId, orgId, key, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, key, name, previewName, created, orgId, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "CreateApiKeyOutput{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" + "CreateApiKeyOutput{id=$id, key=$key, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index 0cec2c85..055f0e83 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -7,57 +7,70 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = CrossObjectInsertResponse.Builder::class) @NoAutoDetect class CrossObjectInsertResponse +@JsonCreator private constructor( - private val experiment: JsonField, - private val dataset: JsonField, - private val projectLogs: JsonField, - private val additionalProperties: Map, + @JsonProperty("dataset") + @ExcludeMissing + private val dataset: JsonField = JsonMissing.of(), + @JsonProperty("experiment") + @ExcludeMissing + private val experiment: JsonField = JsonMissing.of(), + @JsonProperty("project_logs") + @ExcludeMissing + private val projectLogs: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** A mapping from dataset id to row ids for inserted `events` */ + fun dataset(): Optional = Optional.ofNullable(dataset.getNullable("dataset")) /** A mapping from experiment id to row ids for inserted `events` */ fun experiment(): Optional = Optional.ofNullable(experiment.getNullable("experiment")) - /** A mapping from dataset id to row ids for inserted `events` */ - fun dataset(): Optional = Optional.ofNullable(dataset.getNullable("dataset")) - /** A mapping from project id to row ids for inserted `events` */ fun projectLogs(): Optional = Optional.ofNullable(projectLogs.getNullable("project_logs")) - /** A mapping from experiment id to row ids for inserted `events` */ - @JsonProperty("experiment") @ExcludeMissing fun _experiment() = experiment - /** A mapping from dataset id to row ids for inserted `events` */ - @JsonProperty("dataset") @ExcludeMissing fun _dataset() = dataset + @JsonProperty("dataset") @ExcludeMissing fun _dataset(): JsonField = dataset + + /** A mapping from experiment id to row ids for inserted `events` */ + @JsonProperty("experiment") + @ExcludeMissing + fun _experiment(): JsonField = experiment /** A mapping from project id to row ids for inserted `events` */ - @JsonProperty("project_logs") @ExcludeMissing fun _projectLogs() = projectLogs + @JsonProperty("project_logs") + @ExcludeMissing + fun _projectLogs(): JsonField = projectLogs @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): CrossObjectInsertResponse = apply { - if (!validated) { - experiment().map { it.validate() } - dataset().map { it.validate() } - projectLogs().map { it.validate() } - validated = true + if (validated) { + return@apply } + + dataset().ifPresent { it.validate() } + experiment().ifPresent { it.validate() } + projectLogs().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -67,88 +80,100 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CrossObjectInsertResponse]. */ + class Builder internal constructor() { - private var experiment: JsonField = JsonMissing.of() private var dataset: JsonField = JsonMissing.of() + private var experiment: JsonField = JsonMissing.of() private var projectLogs: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(crossObjectInsertResponse: CrossObjectInsertResponse) = apply { - this.experiment = crossObjectInsertResponse.experiment - this.dataset = crossObjectInsertResponse.dataset - this.projectLogs = crossObjectInsertResponse.projectLogs - additionalProperties(crossObjectInsertResponse.additionalProperties) + dataset = crossObjectInsertResponse.dataset + experiment = crossObjectInsertResponse.experiment + projectLogs = crossObjectInsertResponse.projectLogs + additionalProperties = crossObjectInsertResponse.additionalProperties.toMutableMap() } - /** A mapping from experiment id to row ids for inserted `events` */ - fun experiment(experiment: Experiment) = experiment(JsonField.of(experiment)) - - /** A mapping from experiment id to row ids for inserted `events` */ - @JsonProperty("experiment") - @ExcludeMissing - fun experiment(experiment: JsonField) = apply { this.experiment = experiment } + /** A mapping from dataset id to row ids for inserted `events` */ + fun dataset(dataset: Dataset?) = dataset(JsonField.ofNullable(dataset)) /** A mapping from dataset id to row ids for inserted `events` */ - fun dataset(dataset: Dataset) = dataset(JsonField.of(dataset)) + fun dataset(dataset: Optional) = dataset(dataset.orElse(null)) /** A mapping from dataset id to row ids for inserted `events` */ - @JsonProperty("dataset") - @ExcludeMissing fun dataset(dataset: JsonField) = apply { this.dataset = dataset } + /** A mapping from experiment id to row ids for inserted `events` */ + fun experiment(experiment: Experiment?) = experiment(JsonField.ofNullable(experiment)) + + /** A mapping from experiment id to row ids for inserted `events` */ + fun experiment(experiment: Optional) = experiment(experiment.orElse(null)) + + /** A mapping from experiment id to row ids for inserted `events` */ + fun experiment(experiment: JsonField) = apply { this.experiment = experiment } + /** A mapping from project id to row ids for inserted `events` */ - fun projectLogs(projectLogs: ProjectLogs) = projectLogs(JsonField.of(projectLogs)) + fun projectLogs(projectLogs: ProjectLogs?) = projectLogs(JsonField.ofNullable(projectLogs)) + + /** A mapping from project id to row ids for inserted `events` */ + fun projectLogs(projectLogs: Optional) = projectLogs(projectLogs.orElse(null)) /** A mapping from project id to row ids for inserted `events` */ - @JsonProperty("project_logs") - @ExcludeMissing fun projectLogs(projectLogs: JsonField) = apply { this.projectLogs = projectLogs } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): CrossObjectInsertResponse = CrossObjectInsertResponse( - experiment, dataset, + experiment, projectLogs, additionalProperties.toImmutable(), ) } /** A mapping from dataset id to row ids for inserted `events` */ - @JsonDeserialize(builder = Dataset.Builder::class) @NoAutoDetect class Dataset + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Dataset = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -158,29 +183,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Dataset]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(dataset: Dataset) = apply { - additionalProperties(dataset.additionalProperties) + additionalProperties = dataset.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Dataset = Dataset(additionalProperties.toImmutable()) } @@ -202,23 +233,26 @@ private constructor( } /** A mapping from experiment id to row ids for inserted `events` */ - @JsonDeserialize(builder = Experiment.Builder::class) @NoAutoDetect class Experiment + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Experiment = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -228,29 +262,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Experiment]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experiment: Experiment) = apply { - additionalProperties(experiment.additionalProperties) + additionalProperties = experiment.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Experiment = Experiment(additionalProperties.toImmutable()) } @@ -272,23 +312,26 @@ private constructor( } /** A mapping from project id to row ids for inserted `events` */ - @JsonDeserialize(builder = ProjectLogs.Builder::class) @NoAutoDetect class ProjectLogs + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectLogs = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -298,29 +341,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectLogs]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogs: ProjectLogs) = apply { - additionalProperties(projectLogs.additionalProperties) + additionalProperties = projectLogs.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectLogs = ProjectLogs(additionalProperties.toImmutable()) } @@ -346,15 +395,15 @@ private constructor( return true } - return /* spotless:off */ other is CrossObjectInsertResponse && experiment == other.experiment && dataset == other.dataset && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CrossObjectInsertResponse && dataset == other.dataset && experiment == other.experiment && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(experiment, dataset, projectLogs, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(dataset, experiment, projectLogs, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "CrossObjectInsertResponse{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" + "CrossObjectInsertResponse{dataset=$dataset, experiment=$experiment, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index e0b37873..de709547 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -7,39 +7,47 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects /** Summary of a dataset's data */ -@JsonDeserialize(builder = DataSummary.Builder::class) @NoAutoDetect class DataSummary +@JsonCreator private constructor( - private val totalRecords: JsonField, - private val additionalProperties: Map, + @JsonProperty("total_records") + @ExcludeMissing + private val totalRecords: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Total number of records in the dataset */ fun totalRecords(): Long = totalRecords.getRequired("total_records") /** Total number of records in the dataset */ - @JsonProperty("total_records") @ExcludeMissing fun _totalRecords() = totalRecords + @JsonProperty("total_records") + @ExcludeMissing + fun _totalRecords(): JsonField = totalRecords @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): DataSummary = apply { - if (!validated) { - totalRecords() - validated = true + if (validated) { + return@apply } + + totalRecords() + validated = true } fun toBuilder() = Builder().from(this) @@ -49,40 +57,48 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DataSummary]. */ + class Builder internal constructor() { - private var totalRecords: JsonField = JsonMissing.of() + private var totalRecords: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(dataSummary: DataSummary) = apply { - this.totalRecords = dataSummary.totalRecords - additionalProperties(dataSummary.additionalProperties) + totalRecords = dataSummary.totalRecords + additionalProperties = dataSummary.additionalProperties.toMutableMap() } /** Total number of records in the dataset */ fun totalRecords(totalRecords: Long) = totalRecords(JsonField.of(totalRecords)) /** Total number of records in the dataset */ - @JsonProperty("total_records") - @ExcludeMissing fun totalRecords(totalRecords: JsonField) = apply { this.totalRecords = totalRecords } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): DataSummary = DataSummary(totalRecords, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): DataSummary = + DataSummary( + checkRequired("totalRecords", totalRecords), + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index aa856b64..2db02449 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -7,44 +7,52 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = Dataset.Builder::class) @NoAutoDetect class Dataset +@JsonCreator private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val created: JsonField, - private val deletedAt: JsonField, - private val userId: JsonField, - private val metadata: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the dataset */ fun id(): String = id.getRequired("id") - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - /** Name of the dataset. Within a project, dataset names are unique */ fun name(): String = name.getRequired("name") - /** Textual description of the dataset */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(): String = projectId.getRequired("project_id") /** Date of dataset creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) @@ -53,52 +61,62 @@ private constructor( fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Identifies the user who created the dataset */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** Textual description of the dataset */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Unique identifier for the dataset */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + /** Identifies the user who created the dataset */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + /** Unique identifier for the dataset */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Textual description of the dataset */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + /** Unique identifier for the project that the dataset belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Date of dataset creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of dataset deletion, or null if the dataset is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt - /** Identifies the user who created the dataset */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + /** Textual description of the dataset */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** Identifies the user who created the dataset */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Dataset = apply { - if (!validated) { - id() - projectId() - name() - description() - created() - deletedAt() - userId() - metadata().map { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + name() + projectId() + created() + deletedAt() + description() + metadata().ifPresent { it.validate() } + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -108,139 +126,149 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Dataset]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null private var created: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(dataset: Dataset) = apply { - this.id = dataset.id - this.projectId = dataset.projectId - this.name = dataset.name - this.description = dataset.description - this.created = dataset.created - this.deletedAt = dataset.deletedAt - this.userId = dataset.userId - this.metadata = dataset.metadata - additionalProperties(dataset.additionalProperties) + id = dataset.id + name = dataset.name + projectId = dataset.projectId + created = dataset.created + deletedAt = dataset.deletedAt + description = dataset.description + metadata = dataset.metadata + userId = dataset.userId + additionalProperties = dataset.additionalProperties.toMutableMap() } /** Unique identifier for the dataset */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the dataset */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun id(id: JsonField) = apply { this.id = id } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } - /** Textual description of the dataset */ - fun description(description: String) = description(JsonField.of(description)) + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Textual description of the dataset */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Date of dataset creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** Date of dataset creation */ + fun created(created: Optional) = created(created.orElse(null)) /** Date of dataset creation */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) + + /** Date of dataset deletion, or null if the dataset is still active */ + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) /** Date of dataset deletion, or null if the dataset is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } - /** Identifies the user who created the dataset */ - fun userId(userId: String) = userId(JsonField.of(userId)) + /** Textual description of the dataset */ + fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Identifies the user who created the dataset */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + /** Textual description of the dataset */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the dataset */ + fun description(description: JsonField) = apply { this.description = description } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Identifies the user who created the dataset */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Identifies the user who created the dataset */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Identifies the user who created the dataset */ + fun userId(userId: JsonField) = apply { this.userId = userId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Dataset = Dataset( - id, - projectId, - name, - description, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), created, deletedAt, - userId, + description, metadata, + userId, additionalProperties.toImmutable(), ) } /** User-controlled metadata about the dataset */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -250,29 +278,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -298,15 +332,15 @@ private constructor( return true } - return /* spotless:off */ other is Dataset && id == other.id && projectId == other.projectId && name == other.name && description == other.description && created == other.created && deletedAt == other.deletedAt && userId == other.userId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && id == other.id && name == other.name && projectId == other.projectId && created == other.created && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, name, description, created, deletedAt, userId, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, projectId, created, deletedAt, description, metadata, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Dataset{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, deletedAt=$deletedAt, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" + "Dataset{id=$id, name=$name, projectId=$projectId, created=$created, deletedAt=$deletedAt, description=$description, metadata=$metadata, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 1e5f3b48..92780096 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -3,86 +3,135 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new dataset. If there is an existing dataset in the project with the same name as the + * one specified in the request, will return the existing dataset unmodified + */ class DatasetCreateParams -constructor( - private val name: String, - private val projectId: String, - private val description: String?, - private val metadata: Metadata?, +private constructor( + private val body: DatasetCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(): String = body.projectId() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the dataset */ + fun description(): Optional = body.description() - fun metadata(): Optional = Optional.ofNullable(metadata) + /** User-controlled metadata about the dataset */ + fun metadata(): Optional = body.metadata() + + /** Name of the dataset. Within a project, dataset names are unique */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the dataset belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** Textual description of the dataset */ + fun _description(): JsonField = body._description() + + /** User-controlled metadata about the dataset */ + fun _metadata(): JsonField = body._metadata() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): DatasetCreateBody { - return DatasetCreateBody( - name, - projectId, - description, - metadata, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): DatasetCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = DatasetCreateBody.Builder::class) @NoAutoDetect class DatasetCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val description: String?, - private val metadata: Metadata?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + fun projectId(): String = projectId.getRequired("project_id") /** Textual description of the dataset */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** Name of the dataset. Within a project, dataset names are unique */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Unique identifier for the project that the dataset belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** Textual description of the dataset */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** User-controlled metadata about the dataset */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DatasetCreateBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + description() + metadata().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -90,56 +139,79 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DatasetCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var description: String? = null - private var metadata: Metadata? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetCreateBody: DatasetCreateBody) = apply { - this.name = datasetCreateBody.name - this.projectId = datasetCreateBody.projectId - this.description = datasetCreateBody.description - this.metadata = datasetCreateBody.metadata - additionalProperties(datasetCreateBody.additionalProperties) + name = datasetCreateBody.name + projectId = datasetCreateBody.projectId + description = datasetCreateBody.description + metadata = datasetCreateBody.metadata + additionalProperties = datasetCreateBody.additionalProperties.toMutableMap() } /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(name: JsonField) = apply { this.name = name } + + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Textual description of the dataset */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the dataset */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the dataset */ + fun description(description: JsonField) = apply { + this.description = description + } /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): DatasetCreateBody = DatasetCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), description, metadata, additionalProperties.toImmutable(), @@ -171,39 +243,69 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var description: String? = null - private var metadata: Metadata? = null + private var body: DatasetCreateBody.Builder = DatasetCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetCreateParams: DatasetCreateParams) = apply { - name = datasetCreateParams.name - projectId = datasetCreateParams.projectId - description = datasetCreateParams.description - metadata = datasetCreateParams.metadata + body = datasetCreateParams.body.toBuilder() additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = datasetCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the dataset belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Textual description of the dataset */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the dataset */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the dataset */ + fun description(description: JsonField) = apply { body.description(description) } + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -303,52 +405,37 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): DatasetCreateParams = DatasetCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - description, - metadata, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } /** User-controlled metadata about the dataset */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -356,29 +443,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -404,11 +497,11 @@ constructor( return true } - return /* spotless:off */ other is DatasetCreateParams && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, description, metadata, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "DatasetCreateParams{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index a73911ab..7e02f065 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a dataset object by its id */ class DatasetDeleteParams -constructor( +private constructor( private val datasetId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Dataset id */ fun datasetId(): String = datasetId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): DatasetDeleteParams = DatasetDeleteParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + checkRequired("datasetId", datasetId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 3b579c4e..dd7edd64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -8,39 +8,58 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = DatasetEvent.Builder::class) @NoAutoDetect class DatasetEvent +@JsonCreator private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val datasetId: JsonField, - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val isRoot: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), + @JsonProperty("is_root") + @ExcludeMissing + private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate * one for you @@ -57,20 +76,33 @@ private constructor( /** The timestamp the dataset event was created */ fun created(): OffsetDateTime = created.getRequired("created") + /** Unique identifier for the dataset */ + fun datasetId(): String = datasetId.getRequired("dataset_id") + /** Unique identifier for the project that the dataset belongs under */ fun projectId(): String = projectId.getRequired("project_id") - /** Unique identifier for the dataset */ - fun datasetId(): String = datasetId.getRequired("dataset_id") + /** A unique identifier for the trace this dataset event belongs to */ + fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - fun input(): JsonValue = input + /** + * A unique identifier used to link different dataset events together as part of a full trace. + * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on + * tracing + */ + fun spanId(): String = spanId.getRequired("span_id") /** * The output of your application, including post-processing (an arbitrary, JSON serializable * object) */ - fun expected(): JsonValue = expected + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + + /** Whether this span is a root span */ + fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -81,55 +113,46 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing - */ - fun spanId(): String = spanId.getRequired("span_id") - - /** A unique identifier for the trace this dataset event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** Whether this span is a root span */ - fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) - /** Indicates the event was copied from another object. */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate * one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the dataset (see the `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input() = input + /** Unique identifier for the project that the dataset belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** A unique identifier for the trace this dataset event belongs to */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) + * A unique identifier used to link different dataset events together as part of a full trace. + * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on + * tracing */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + + /** Whether this span is a root span */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** * A dictionary with additional data about the test example, model outputs, or just about @@ -138,48 +161,37 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing - */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId - - /** A unique identifier for the trace this dataset event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot() = isRoot + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): DatasetEvent = apply { - if (!validated) { - id() - _xactId() - created() - projectId() - datasetId() - input() - expected() - metadata().map { it.validate() } - tags() - spanId() - rootSpanId() - isRoot() - origin().map { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + _xactId() + created() + datasetId() + projectId() + rootSpanId() + spanId() + isRoot() + metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -189,39 +201,40 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DatasetEvent]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var datasetId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var created: JsonField? = null + private var datasetId: JsonField? = null + private var projectId: JsonField? = null + private var rootSpanId: JsonField? = null + private var spanId: JsonField? = null private var expected: JsonValue = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() private var isRoot: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var origin: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetEvent: DatasetEvent) = apply { - this.id = datasetEvent.id - this._xactId = datasetEvent._xactId - this.created = datasetEvent.created - this.projectId = datasetEvent.projectId - this.datasetId = datasetEvent.datasetId - this.input = datasetEvent.input - this.expected = datasetEvent.expected - this.metadata = datasetEvent.metadata - this.tags = datasetEvent.tags - this.spanId = datasetEvent.spanId - this.rootSpanId = datasetEvent.rootSpanId - this.isRoot = datasetEvent.isRoot - this.origin = datasetEvent.origin - additionalProperties(datasetEvent.additionalProperties) + id = datasetEvent.id + _xactId = datasetEvent._xactId + created = datasetEvent.created + datasetId = datasetEvent.datasetId + projectId = datasetEvent.projectId + rootSpanId = datasetEvent.rootSpanId + spanId = datasetEvent.spanId + expected = datasetEvent.expected + input = datasetEvent.input + isRoot = datasetEvent.isRoot + metadata = datasetEvent.metadata + origin = datasetEvent.origin + tags = datasetEvent.tags.map { it.toMutableList() } + additionalProperties = datasetEvent.additionalProperties.toMutableMap() } /** @@ -234,7 +247,7 @@ private constructor( * A unique identifier for the dataset event. If you don't provide one, BrainTrust will * generate one for you */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } /** * The transaction id of an event is unique to the network operation that processed the @@ -248,49 +261,70 @@ private constructor( * event insertion. Transaction ids are monotonically increasing over time and can be used * to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } + /** Unique identifier for the dataset */ + fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + + /** Unique identifier for the dataset */ + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - /** Unique identifier for the dataset */ - fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + /** A unique identifier for the trace this dataset event belongs to */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + /** A unique identifier for the trace this dataset event belongs to */ + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - @JsonProperty("expected") - @ExcludeMissing fun expected(expected: JsonValue) = apply { this.expected = expected } + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + */ + fun input(input: JsonValue) = apply { this.input = input } + + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) + + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) + + /** Whether this span is a root span */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isRoot(isRoot: Optional) = isRoot(isRoot.orElse(null) as Boolean?) + + /** Whether this span is a root span */ + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + /** * A dictionary with additional data about the test example, model outputs, or just about * anything else that's relevant, that you can use to help find and analyze examples later. @@ -298,7 +332,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -307,87 +341,85 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing - */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + /** Indicates the event was copied from another object. */ + fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) - /** A unique identifier for the trace this dataset event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.orElse(null)) - /** A unique identifier for the trace this dataset event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } - /** Whether this span is a root span */ - fun isRoot(isRoot: Boolean) = isRoot(JsonField.of(isRoot)) + /** A list of tags to log */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** Whether this span is a root span */ - @JsonProperty("is_root") - @ExcludeMissing - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + /** A list of tags to log */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) - /** Indicates the event was copied from another object. */ - fun origin(origin: Origin) = origin(JsonField.of(origin)) + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } - /** Indicates the event was copied from another object. */ - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): DatasetEvent = DatasetEvent( - id, - _xactId, - created, - projectId, - datasetId, - input, + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("created", created), + checkRequired("datasetId", datasetId), + checkRequired("projectId", projectId), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), expected, - metadata, - tags.map { it.toImmutable() }, - spanId, - rootSpanId, + input, isRoot, + metadata, origin, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -399,23 +431,26 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -425,29 +460,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -469,55 +510,66 @@ private constructor( } /** Indicates the event was copied from another object. */ - @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect class Origin + @JsonCreator private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val id: JsonField, - private val _xactId: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - /** ID of the original event. */ fun id(): String = id.getRequired("id") /** Transaction ID of the original event. */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + fun objectId(): String = objectId.getRequired("object_id") + + /** Type of the object the event is originating from. */ + fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Origin = apply { - if (!validated) { - objectType() - objectId() - id() - _xactId() - validated = true + if (validated) { + return@apply } + + id() + _xactId() + objectId() + objectType() + validated = true } fun toBuilder() = Builder().from(this) @@ -527,118 +579,114 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Origin]. */ + class Builder internal constructor() { - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(origin: Origin) = apply { - this.objectType = origin.objectType - this.objectId = origin.objectId - this.id = origin.id - this._xactId = origin._xactId - additionalProperties(origin.additionalProperties) - } - - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() } - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") - @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") - @ExcludeMissing fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + /** ID of the object the event is originating from. */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** ID of the object the event is originating from. */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** Type of the object the event is originating from. */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** Type of the object the event is originating from. */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Origin = Origin( - objectType, - objectId, - id, - _xactId, + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), additionalProperties.toImmutable(), ) } + /** Type of the object the event is originating from. */ 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 - 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() - companion object { - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + @JvmField val FUNCTION = of("function") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val PROJECT_LOGS = ObjectType(JsonField.of("project_logs")) + @JvmField val PROJECT_LOGS = of("project_logs") @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) } + /** An enum containing [ObjectType]'s known values. */ enum class Known { EXPERIMENT, DATASET, @@ -648,6 +696,15 @@ private constructor( PROJECT_LOGS, } + /** + * 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 { EXPERIMENT, DATASET, @@ -655,9 +712,20 @@ private constructor( FUNCTION, PROMPT_SESSION, PROJECT_LOGS, + /** + * 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) { EXPERIMENT -> Value.EXPERIMENT @@ -669,6 +737,15 @@ private constructor( 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) { EXPERIMENT -> Known.EXPERIMENT @@ -681,6 +758,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -688,17 +777,17 @@ private constructor( return true } - return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && id == other.id && _xactId == other._xactId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, id, _xactId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" + "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -706,15 +795,15 @@ private constructor( return true } - return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && projectId == other.projectId && datasetId == other.datasetId && input == other.input && expected == other.expected && metadata == other.metadata && tags == other.tags && spanId == other.spanId && rootSpanId == other.rootSpanId && isRoot == other.isRoot && origin == other.origin && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && datasetId == other.datasetId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && origin == other.origin && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, projectId, datasetId, input, expected, metadata, tags, spanId, rootSpanId, isRoot, origin, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, datasetId, projectId, rootSpanId, spanId, expected, input, isRoot, metadata, origin, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, isRoot=$isRoot, origin=$origin, additionalProperties=$additionalProperties}" + "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, datasetId=$datasetId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, origin=$origin, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 40a78dcd..4cf3b15a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -3,45 +3,51 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects +/** Log feedback for a set of dataset events */ class DatasetFeedbackParams -constructor( +private constructor( private val datasetId: String, - private val feedback: List, + private val body: DatasetFeedbackBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Dataset id */ fun datasetId(): String = datasetId - fun feedback(): List = feedback + /** A list of dataset feedback items */ + fun feedback(): List = body.feedback() + + /** A list of dataset feedback items */ + fun _feedback(): JsonField> = body._feedback() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): DatasetFeedbackBody { - return DatasetFeedbackBody(feedback, additionalBodyProperties) - } + @JvmSynthetic internal fun _body(): DatasetFeedbackBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,21 +56,40 @@ constructor( } } - @JsonDeserialize(builder = DatasetFeedbackBody.Builder::class) @NoAutoDetect class DatasetFeedbackBody + @JsonCreator internal constructor( - private val feedback: List?, - private val additionalProperties: Map, + @JsonProperty("feedback") + @ExcludeMissing + private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of dataset feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + fun feedback(): List = feedback.getRequired("feedback") + + /** A list of dataset feedback items */ + @JsonProperty("feedback") + @ExcludeMissing + fun _feedback(): JsonField> = feedback @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DatasetFeedbackBody = apply { + if (validated) { + return@apply + } + + feedback().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,39 +97,62 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DatasetFeedbackBody]. */ + class Builder internal constructor() { - private var feedback: List? = null + private var feedback: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetFeedbackBody: DatasetFeedbackBody) = apply { - this.feedback = datasetFeedbackBody.feedback - additionalProperties(datasetFeedbackBody.additionalProperties) + feedback = datasetFeedbackBody.feedback.map { it.toMutableList() } + additionalProperties = datasetFeedbackBody.additionalProperties.toMutableMap() } /** A list of dataset feedback items */ - @JsonProperty("feedback") - fun feedback(feedback: List) = apply { this.feedback = feedback } + fun feedback(feedback: List) = feedback(JsonField.of(feedback)) + + /** A list of dataset feedback items */ + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback.map { it.toMutableList() } + } + + /** A list of dataset feedback items */ + fun addFeedback(feedback: FeedbackDatasetItem) = apply { + this.feedback = + (this.feedback ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(feedback) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): DatasetFeedbackBody = DatasetFeedbackBody( - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toImmutable(), + checkRequired("feedback", feedback).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -134,35 +182,55 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetFeedbackParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetId: String? = null - private var feedback: MutableList = mutableListOf() + private var body: DatasetFeedbackBody.Builder = DatasetFeedbackBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = apply { datasetId = datasetFeedbackParams.datasetId - feedback = datasetFeedbackParams.feedback.toMutableList() + body = datasetFeedbackParams.body.toBuilder() additionalHeaders = datasetFeedbackParams.additionalHeaders.toBuilder() additionalQueryParams = datasetFeedbackParams.additionalQueryParams.toBuilder() - additionalBodyProperties = datasetFeedbackParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset feedback items */ - fun feedback(feedback: List) = apply { - this.feedback.clear() - this.feedback.addAll(feedback) + fun feedback(feedback: List) = apply { body.feedback(feedback) } + + /** A list of dataset feedback items */ + fun feedback(feedback: JsonField>) = apply { + body.feedback(feedback) } /** A list of dataset feedback items */ - fun addFeedback(feedback: FeedbackDatasetItem) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackDatasetItem) = apply { body.addFeedback(feedback) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -262,35 +330,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): DatasetFeedbackParams = DatasetFeedbackParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - feedback.toImmutable(), + checkRequired("datasetId", datasetId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -299,11 +344,11 @@ constructor( return true } - return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetFeedbackParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 46d06bb3..a059766e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -3,14 +3,20 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects import java.util.Optional +/** + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use the + * `POST /btql` endpoint. + */ class DatasetFetchParams -constructor( +private constructor( private val datasetId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -18,26 +24,70 @@ constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Dataset id */ fun datasetId(): String = datasetId + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ fun limit(): Optional = Optional.ofNullable(limit) + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ fun version(): Optional = Optional.ofNullable(version) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.limit?.let { queryParams.put("limit", listOf(it.toString())) } this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } @@ -61,8 +111,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetFetchParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetId: String? = null private var limit: Long? = null @@ -101,7 +152,42 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -115,7 +201,7 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -129,7 +215,44 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: String?) = apply { this.version = version } /** * Retrieve a snapshot of events from a past time @@ -137,7 +260,7 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { this.version = version } + fun version(version: Optional) = version(version.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -239,7 +362,7 @@ constructor( fun build(): DatasetFetchParams = DatasetFetchParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + checkRequired("datasetId", datasetId), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index a8dd1fdb..98ba9956 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -3,65 +3,170 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use the + * `POST /btql` endpoint. + */ class DatasetFetchPostParams -constructor( +private constructor( private val datasetId: String, - private val cursor: String?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, + private val body: DatasetFetchPostBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Dataset id */ fun datasetId(): String = datasetId - fun cursor(): Optional = Optional.ofNullable(cursor) - - fun limit(): Optional = Optional.ofNullable(limit) - - fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) - - fun maxXactId(): Optional = Optional.ofNullable(maxXactId) - - fun version(): Optional = Optional.ofNullable(version) + /** + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch query + */ + fun cursor(): Optional = body.cursor() + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ + fun limit(): Optional = body.limit() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun maxRootSpanId(): Optional = body.maxRootSpanId() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun maxXactId(): Optional = body.maxXactId() + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(): Optional = body.version() + + /** + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch query + */ + fun _cursor(): JsonField = body._cursor() + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ + fun _limit(): JsonField = body._limit() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun _maxRootSpanId(): JsonField = body._maxRootSpanId() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun _maxXactId(): JsonField = body._maxXactId() + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun _version(): JsonField = body._version() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): DatasetFetchPostBody { - return DatasetFetchPostBody( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): DatasetFetchPostBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -70,16 +175,27 @@ constructor( } } - @JsonDeserialize(builder = DatasetFetchPostBody.Builder::class) @NoAutoDetect class DatasetFetchPostBody + @JsonCreator internal constructor( - private val cursor: String?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") + @ExcludeMissing + private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") + @ExcludeMissing + private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") + @ExcludeMissing + private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -89,7 +205,7 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - @JsonProperty("cursor") fun cursor(): String? = cursor + fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched @@ -106,7 +222,7 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @JsonProperty("limit") fun limit(): Long? = limit + fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -120,7 +236,8 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - @JsonProperty("max_root_span_id") fun maxRootSpanId(): String? = maxRootSpanId + fun maxRootSpanId(): Optional = + Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -134,7 +251,8 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - @JsonProperty("max_xact_id") fun maxXactId(): String? = maxXactId + fun maxXactId(): Optional = + Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time @@ -142,12 +260,91 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") fun version(): String? = version + fun version(): Optional = Optional.ofNullable(version.getNullable("version")) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + @JsonProperty("max_root_span_id") + @ExcludeMissing + fun _maxRootSpanId(): JsonField = maxRootSpanId + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DatasetFetchPostBody = apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -155,23 +352,24 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DatasetFetchPostBody]. */ + class Builder internal constructor() { - private var cursor: String? = null - private var limit: Long? = null - private var maxRootSpanId: String? = null - private var maxXactId: String? = null - private var version: String? = null + private var cursor: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var maxRootSpanId: JsonField = JsonMissing.of() + private var maxXactId: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetFetchPostBody: DatasetFetchPostBody) = apply { - this.cursor = datasetFetchPostBody.cursor - this.limit = datasetFetchPostBody.limit - this.maxRootSpanId = datasetFetchPostBody.maxRootSpanId - this.maxXactId = datasetFetchPostBody.maxXactId - this.version = datasetFetchPostBody.version - additionalProperties(datasetFetchPostBody.additionalProperties) + cursor = datasetFetchPostBody.cursor + limit = datasetFetchPostBody.limit + maxRootSpanId = datasetFetchPostBody.maxRootSpanId + maxXactId = datasetFetchPostBody.maxXactId + version = datasetFetchPostBody.version + additionalProperties = datasetFetchPostBody.additionalProperties.toMutableMap() } /** @@ -181,7 +379,25 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } /** * limit the number of traces fetched @@ -198,7 +414,119 @@ constructor( * with more individual rows than the specified limit if you are fetching events * containing traces. */ - @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: String?) = + maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + this.maxRootSpanId = maxRootSpanId + } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -212,8 +540,7 @@ constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - @JsonProperty("max_root_span_id") - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -227,8 +554,25 @@ constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. + */ + fun version(version: String?) = version(JsonField.ofNullable(version)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. + */ + fun version(version: Optional) = version(version.orElse(null)) /** * Retrieve a snapshot of events from a past time @@ -237,22 +581,27 @@ constructor( * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact * fetch. */ - @JsonProperty("version") fun version(version: String) = apply { this.version = version } + fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): DatasetFetchPostBody = DatasetFetchPostBody( cursor, @@ -289,31 +638,21 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetFetchPostParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetId: String? = null - private var cursor: String? = null - private var limit: Long? = null - private var maxRootSpanId: String? = null - private var maxXactId: String? = null - private var version: String? = null + private var body: DatasetFetchPostBody.Builder = DatasetFetchPostBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = apply { datasetId = datasetFetchPostParams.datasetId - cursor = datasetFetchPostParams.cursor - limit = datasetFetchPostParams.limit - maxRootSpanId = datasetFetchPostParams.maxRootSpanId - maxXactId = datasetFetchPostParams.maxXactId - version = datasetFetchPostParams.version + body = datasetFetchPostParams.body.toBuilder() additionalHeaders = datasetFetchPostParams.additionalHeaders.toBuilder() additionalQueryParams = datasetFetchPostParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - datasetFetchPostParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ @@ -326,7 +665,25 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: String) = apply { this.cursor = cursor } + fun cursor(cursor: String?) = apply { body.cursor(cursor) } + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } /** * limit the number of traces fetched @@ -343,7 +700,59 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = apply { body.limit(limit) } + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: JsonField) = apply { body.limit(limit) } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -357,7 +766,7 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -371,7 +780,74 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + body.maxRootSpanId(maxRootSpanId) + } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: String?) = apply { body.version(version) } /** * Retrieve a snapshot of events from a past time @@ -379,7 +855,34 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { this.version = version } + fun version(version: Optional) = version(version.orElse(null)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: JsonField) = apply { body.version(version) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -479,39 +982,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): DatasetFetchPostParams = DatasetFetchPostParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - cursor, - limit, - maxRootSpanId, - maxXactId, - version, + checkRequired("datasetId", datasetId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -520,11 +996,11 @@ constructor( return true } - return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetFetchPostParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 2e6c8004..234bd79f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -3,45 +3,51 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects +/** Insert a set of events into the dataset */ class DatasetInsertParams -constructor( +private constructor( private val datasetId: String, - private val events: List, + private val body: DatasetInsertBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Dataset id */ fun datasetId(): String = datasetId - fun events(): List = events + /** A list of dataset events to insert */ + fun events(): List = body.events() + + /** A list of dataset events to insert */ + fun _events(): JsonField> = body._events() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): DatasetInsertBody { - return DatasetInsertBody(events, additionalBodyProperties) - } + @JvmSynthetic internal fun _body(): DatasetInsertBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,21 +56,40 @@ constructor( } } - @JsonDeserialize(builder = DatasetInsertBody.Builder::class) @NoAutoDetect class DatasetInsertBody + @JsonCreator internal constructor( - private val events: List?, - private val additionalProperties: Map, + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of dataset events to insert */ - @JsonProperty("events") fun events(): List? = events + fun events(): List = events.getRequired("events") + + /** A list of dataset events to insert */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DatasetInsertBody = apply { + if (validated) { + return@apply + } + + events().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,38 +97,62 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DatasetInsertBody]. */ + class Builder internal constructor() { - private var events: List? = null + private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetInsertBody: DatasetInsertBody) = apply { - this.events = datasetInsertBody.events - additionalProperties(datasetInsertBody.additionalProperties) + events = datasetInsertBody.events.map { it.toMutableList() } + additionalProperties = datasetInsertBody.additionalProperties.toMutableMap() + } + + /** A list of dataset events to insert */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of dataset events to insert */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } } /** A list of dataset events to insert */ - @JsonProperty("events") - fun events(events: List) = apply { this.events = events } + fun addEvent(event: InsertDatasetEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(event) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): DatasetInsertBody = DatasetInsertBody( - checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + checkRequired("events", events).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -133,35 +182,53 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetInsertParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetId: String? = null - private var events: MutableList = mutableListOf() + private var body: DatasetInsertBody.Builder = DatasetInsertBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetInsertParams: DatasetInsertParams) = apply { datasetId = datasetInsertParams.datasetId - events = datasetInsertParams.events.toMutableList() + body = datasetInsertParams.body.toBuilder() additionalHeaders = datasetInsertParams.additionalHeaders.toBuilder() additionalQueryParams = datasetInsertParams.additionalQueryParams.toBuilder() - additionalBodyProperties = datasetInsertParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset events to insert */ - fun events(events: List) = apply { - this.events.clear() - this.events.addAll(events) - } + fun events(events: List) = apply { body.events(events) } /** A list of dataset events to insert */ - fun addEvent(event: InsertDatasetEvent) = apply { this.events.add(event) } + fun events(events: JsonField>) = apply { body.events(events) } + + /** A list of dataset events to insert */ + fun addEvent(event: InsertDatasetEvent) = apply { body.addEvent(event) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -261,35 +328,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): DatasetInsertParams = DatasetInsertParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - events.toImmutable(), + checkRequired("datasetId", datasetId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -298,11 +342,11 @@ constructor( return true } - return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetInsertParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index 117b1e39..532b9e08 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.DatasetService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all datasets. The datasets are sorted by creation date, with the most recently-created + * datasets coming first + */ class DatasetListPage private constructor( private val datasetsService: DatasetService, @@ -85,16 +90,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -104,11 +108,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -144,10 +152,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -156,8 +162,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: DatasetListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index 2a6e6ee3..e8d3d34a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.DatasetServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all datasets. The datasets are sorted by creation date, with the most recently-created + * datasets coming first + */ class DatasetListPageAsync private constructor( private val datasetsService: DatasetServiceAsync, @@ -92,16 +97,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +115,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +159,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +169,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: DatasetListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 71464ae0..fd0395c1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all datasets. The datasets are sorted by creation date, with the most recently-created + * datasets coming first + */ class DatasetListParams -constructor( +private constructor( private val datasetName: String?, private val endingBefore: String?, private val ids: Ids?, @@ -33,32 +37,54 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Name of the dataset to search for */ fun datasetName(): Optional = Optional.ofNullable(datasetName) + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Project id */ fun projectId(): Optional = Optional.ofNullable(projectId) + /** Name of the project to search for */ fun projectName(): Optional = Optional.ofNullable(projectName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.datasetName?.let { queryParams.put("dataset_name", listOf(it.toString())) } this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } @@ -79,8 +105,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetName: String? = null private var endingBefore: String? = null @@ -108,7 +135,19 @@ constructor( } /** Name of the dataset to search for */ - fun datasetName(datasetName: String) = apply { this.datasetName = datasetName } + fun datasetName(datasetName: String?) = apply { this.datasetName = datasetName } + + /** Name of the dataset to search for */ + fun datasetName(datasetName: Optional) = datasetName(datasetName.orElse(null)) + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. @@ -117,37 +156,59 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = apply { this.projectId = projectId } + + /** Project id */ + fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + + /** Name of the project to search for */ + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) /** * Pagination cursor id. @@ -156,7 +217,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -271,6 +342,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -280,8 +355,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -304,15 +377,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -338,18 +402,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -365,7 +439,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index c24a97c2..a436da98 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a dataset object by its id */ class DatasetRetrieveParams -constructor( +private constructor( private val datasetId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Dataset id */ fun datasetId(): String = datasetId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): DatasetRetrieveParams = DatasetRetrieveParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + checkRequired("datasetId", datasetId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 143a45ee..e9f018f2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -3,32 +3,35 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects import java.util.Optional +/** Summarize dataset */ class DatasetSummarizeParams -constructor( +private constructor( private val datasetId: String, private val summarizeData: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Dataset id */ fun datasetId(): String = datasetId + /** Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ fun summarizeData(): Optional = Optional.ofNullable(summarizeData) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.summarizeData?.let { queryParams.put("summarize_data", listOf(it.toString())) } queryParams.putAll(additionalQueryParams) @@ -49,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetSummarizeParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetId: String? = null private var summarizeData: Boolean? = null @@ -71,7 +75,19 @@ constructor( /** * Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ - fun summarizeData(summarizeData: Boolean) = apply { this.summarizeData = summarizeData } + fun summarizeData(summarizeData: Boolean?) = apply { this.summarizeData = summarizeData } + + /** + * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + */ + fun summarizeData(summarizeData: Boolean) = summarizeData(summarizeData as Boolean?) + + /** + * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun summarizeData(summarizeData: Optional) = + summarizeData(summarizeData.orElse(null) as Boolean?) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -173,7 +189,7 @@ constructor( fun build(): DatasetSummarizeParams = DatasetSummarizeParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, + checkRequired("datasetId", datasetId), summarizeData, additionalHeaders.build(), additionalQueryParams.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 102ed380..9b5950db 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -3,57 +3,68 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update a dataset object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. + */ class DatasetUpdateParams -constructor( +private constructor( private val datasetId: String, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, + private val body: DatasetUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Dataset id */ fun datasetId(): String = datasetId - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the dataset */ + fun description(): Optional = body.description() - fun metadata(): Optional = Optional.ofNullable(metadata) + /** User-controlled metadata about the dataset */ + fun metadata(): Optional = body.metadata() + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(): Optional = body.name() + + /** Textual description of the dataset */ + fun _description(): JsonField = body._description() + + /** User-controlled metadata about the dataset */ + fun _metadata(): JsonField = body._metadata() + + /** Name of the dataset. Within a project, dataset names are unique */ + fun _name(): JsonField = body._name() - fun name(): Optional = Optional.ofNullable(name) + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun _body(): DatasetUpdateBody = body - @JvmSynthetic - internal fun getBody(): DatasetUpdateBody { - return DatasetUpdateBody( - description, - metadata, - name, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -62,29 +73,61 @@ constructor( } } - @JsonDeserialize(builder = DatasetUpdateBody.Builder::class) @NoAutoDetect class DatasetUpdateBody + @JsonCreator internal constructor( - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val additionalProperties: Map, + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Textual description of the dataset */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(): String? = name + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Textual description of the dataset */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** User-controlled metadata about the dataset */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** Name of the dataset. Within a project, dataset names are unique */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DatasetUpdateBody = apply { + if (validated) { + return@apply + } + + description() + metadata().ifPresent { it.validate() } + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -92,46 +135,70 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DatasetUpdateBody]. */ + class Builder internal constructor() { - private var description: String? = null - private var metadata: Metadata? = null - private var name: String? = null + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetUpdateBody: DatasetUpdateBody) = apply { - this.description = datasetUpdateBody.description - this.metadata = datasetUpdateBody.metadata - this.name = datasetUpdateBody.name - additionalProperties(datasetUpdateBody.additionalProperties) + description = datasetUpdateBody.description + metadata = datasetUpdateBody.metadata + name = datasetUpdateBody.name + additionalProperties = datasetUpdateBody.additionalProperties.toMutableMap() } /** Textual description of the dataset */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the dataset */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the dataset */ + fun description(description: JsonField) = apply { + this.description = description + } /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): DatasetUpdateBody = DatasetUpdateBody( description, @@ -166,39 +233,71 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [DatasetUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var datasetId: String? = null - private var description: String? = null - private var metadata: Metadata? = null - private var name: String? = null + private var body: DatasetUpdateBody.Builder = DatasetUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetUpdateParams: DatasetUpdateParams) = apply { datasetId = datasetUpdateParams.datasetId - description = datasetUpdateParams.description - metadata = datasetUpdateParams.metadata - name = datasetUpdateParams.name + body = datasetUpdateParams.body.toBuilder() additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = datasetUpdateParams.additionalBodyProperties.toMutableMap() } /** Dataset id */ fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** Textual description of the dataset */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the dataset */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the dataset */ + fun description(description: JsonField) = apply { body.description(description) } + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** User-controlled metadata about the dataset */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(name: String?) = apply { body.name(name) } + + /** Name of the dataset. Within a project, dataset names are unique */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -298,52 +397,38 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): DatasetUpdateParams = DatasetUpdateParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - description, - metadata, - name, + checkRequired("datasetId", datasetId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } /** User-controlled metadata about the dataset */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -351,29 +436,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -399,11 +490,11 @@ constructor( return true } - return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && description == other.description && metadata == other.metadata && name == other.name && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, description, metadata, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "DatasetUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index f9b4c49d..4ef7096d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -8,43 +8,50 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = EnvVar.Builder::class) @NoAutoDetect class EnvVar +@JsonCreator private constructor( - private val id: JsonField, - private val objectType: JsonField, - private val objectId: JsonField, - private val name: JsonField, - private val created: JsonField, - private val used: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("used") + @ExcludeMissing + private val used: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the environment variable */ fun id(): String = id.getRequired("id") - /** The type of the object the environment variable is scoped for */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + /** The name of the environment variable */ + fun name(): String = name.getRequired("name") /** The id of the object the environment variable is scoped for */ fun objectId(): String = objectId.getRequired("object_id") - /** The name of the environment variable */ - fun name(): String = name.getRequired("name") + /** The type of the object the environment variable is scoped for */ + fun objectType(): ObjectType = objectType.getRequired("object_type") /** Date of environment variable creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) @@ -53,37 +60,43 @@ private constructor( fun used(): Optional = Optional.ofNullable(used.getNullable("used")) /** Unique identifier for the environment variable */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The type of the object the environment variable is scoped for */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + /** The name of the environment variable */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + /** The type of the object the environment variable is scoped for */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** Date of environment variable creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date the environment variable was last used */ - @JsonProperty("used") @ExcludeMissing fun _used() = used + @JsonProperty("used") @ExcludeMissing fun _used(): JsonField = used @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): EnvVar = apply { - if (!validated) { - id() - objectType() - objectId() - name() - created() - used() - validated = true + if (validated) { + return@apply } + + id() + name() + objectId() + objectType() + created() + used() + validated = true } fun toBuilder() = Builder().from(this) @@ -93,143 +106,162 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EnvVar]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null private var created: JsonField = JsonMissing.of() private var used: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVar: EnvVar) = apply { - this.id = envVar.id - this.objectType = envVar.objectType - this.objectId = envVar.objectId - this.name = envVar.name - this.created = envVar.created - this.used = envVar.used - additionalProperties(envVar.additionalProperties) + id = envVar.id + name = envVar.name + objectId = envVar.objectId + objectType = envVar.objectType + created = envVar.created + used = envVar.used + additionalProperties = envVar.additionalProperties.toMutableMap() } /** Unique identifier for the environment variable */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the environment variable */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + /** The name of the environment variable */ + fun name(name: String) = name(JsonField.of(name)) - /** The type of the object the environment variable is scoped for */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + /** The name of the environment variable */ + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") - @ExcludeMissing fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - /** The name of the environment variable */ - fun name(name: String) = name(JsonField.of(name)) + /** The type of the object the environment variable is scoped for */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - /** The name of the environment variable */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** The type of the object the environment variable is scoped for */ + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } /** Date of environment variable creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** Date of environment variable creation */ + fun created(created: Optional) = created(created.orElse(null)) /** Date of environment variable creation */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } /** Date the environment variable was last used */ - fun used(used: OffsetDateTime) = used(JsonField.of(used)) + fun used(used: OffsetDateTime?) = used(JsonField.ofNullable(used)) + + /** Date the environment variable was last used */ + fun used(used: Optional) = used(used.orElse(null)) /** Date the environment variable was last used */ - @JsonProperty("used") - @ExcludeMissing fun used(used: JsonField) = apply { this.used = used } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): EnvVar = EnvVar( - id, - objectType, - objectId, - name, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), created, used, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + @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 @@ -238,6 +270,15 @@ private constructor( 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 @@ -247,6 +288,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -254,15 +307,15 @@ private constructor( return true } - return /* spotless:off */ other is EnvVar && id == other.id && objectType == other.objectType && objectId == other.objectId && name == other.name && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVar && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, objectType, objectId, name, created, used, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, objectId, objectType, created, used, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "EnvVar{id=$id, objectType=$objectType, objectId=$objectId, name=$name, created=$created, used=$used, additionalProperties=$additionalProperties}" + "EnvVar{id=$id, name=$name, objectId=$objectId, objectType=$objectType, created=$created, used=$used, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index c302f4fe..a441ab30 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -5,88 +5,134 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new env_var. If there is an existing env_var with the same name as the one specified in + * the request, will return the existing env_var unmodified + */ class EnvVarCreateParams -constructor( - private val name: String, - private val objectId: String, - private val objectType: ObjectType, - private val value: String?, +private constructor( + private val body: EnvVarCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** The name of the environment variable */ + fun name(): String = body.name() - fun objectId(): String = objectId + /** The id of the object the environment variable is scoped for */ + fun objectId(): String = body.objectId() - fun objectType(): ObjectType = objectType + /** The type of the object the environment variable is scoped for */ + fun objectType(): ObjectType = body.objectType() - fun value(): Optional = Optional.ofNullable(value) + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(): Optional = body.value() + + /** The name of the environment variable */ + fun _name(): JsonField = body._name() + + /** The id of the object the environment variable is scoped for */ + fun _objectId(): JsonField = body._objectId() + + /** The type of the object the environment variable is scoped for */ + fun _objectType(): JsonField = body._objectType() + + /** The value of the environment variable. Will be encrypted at rest. */ + fun _value(): JsonField = body._value() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): EnvVarCreateBody { - return EnvVarCreateBody( - name, - objectId, - objectType, - value, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): EnvVarCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = EnvVarCreateBody.Builder::class) @NoAutoDetect class EnvVarCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val objectId: String?, - private val objectType: ObjectType?, - private val value: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the environment variable */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** The id of the object the environment variable is scoped for */ + fun objectId(): String = objectId.getRequired("object_id") + + /** The type of the object the environment variable is scoped for */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The name of the environment variable */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") fun value(): String? = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EnvVarCreateBody = apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + value() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -94,56 +140,77 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EnvVarCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var value: String? = null + private var name: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVarCreateBody: EnvVarCreateBody) = apply { - this.name = envVarCreateBody.name - this.objectId = envVarCreateBody.objectId - this.objectType = envVarCreateBody.objectType - this.value = envVarCreateBody.value - additionalProperties(envVarCreateBody.additionalProperties) + name = envVarCreateBody.name + objectId = envVarCreateBody.objectId + objectType = envVarCreateBody.objectType + value = envVarCreateBody.value + additionalProperties = envVarCreateBody.additionalProperties.toMutableMap() } /** The name of the environment variable */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the environment variable */ + fun name(name: JsonField) = apply { this.name = name } + + /** The id of the object the environment variable is scoped for */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The type of the object the environment variable is scoped for */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The type of the object the environment variable is scoped for */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") fun value(value: String) = apply { this.value = value } + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: Optional) = value(value.orElse(null)) + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): EnvVarCreateBody = EnvVarCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), value, additionalProperties.toImmutable(), ) @@ -174,39 +241,66 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [EnvVarCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var value: String? = null + private var body: EnvVarCreateBody.Builder = EnvVarCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVarCreateParams: EnvVarCreateParams) = apply { - name = envVarCreateParams.name - objectId = envVarCreateParams.objectId - objectType = envVarCreateParams.objectType - value = envVarCreateParams.value + body = envVarCreateParams.body.toBuilder() additionalHeaders = envVarCreateParams.additionalHeaders.toBuilder() additionalQueryParams = envVarCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = envVarCreateParams.additionalBodyProperties.toMutableMap() } /** The name of the environment variable */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** The name of the environment variable */ + fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { body.objectId(objectId) } + + /** The id of the object the environment variable is scoped for */ + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + + /** The type of the object the environment variable is scoped for */ + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String) = apply { this.value = value } + fun value(value: String?) = apply { body.value(value) } + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: Optional) = value(value.orElse(null)) + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: JsonField) = apply { body.value(value) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -306,84 +400,75 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): EnvVarCreateParams = EnvVarCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - value, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + @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 @@ -392,6 +477,15 @@ constructor( 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 @@ -401,6 +495,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -408,11 +514,11 @@ constructor( return true } - return /* spotless:off */ other is EnvVarCreateParams && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "EnvVarCreateParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "EnvVarCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index 93b1b39f..d8742267 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete an env_var object by its id */ class EnvVarDeleteParams -constructor( +private constructor( private val envVarId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** EnvVar id */ fun envVarId(): String = envVarId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [EnvVarDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var envVarId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): EnvVarDeleteParams = EnvVarDeleteParams( - checkNotNull(envVarId) { "`envVarId` is required but was not set" }, + checkRequired("envVarId", envVarId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), 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 fb3972cd..850813c0 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 @@ -8,11 +8,11 @@ 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 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.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -24,8 +24,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all env_vars. The env_vars are sorted by creation date, with the most recently-created + * env_vars coming first + */ class EnvVarListParams -constructor( +private constructor( private val envVarName: String?, private val ids: Ids?, private val limit: Long?, @@ -33,26 +37,33 @@ constructor( private val objectType: ObjectType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Name of the env_var to search for */ fun envVarName(): Optional = Optional.ofNullable(envVarName) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** The id of the object the environment variable is scoped for */ fun objectId(): Optional = Optional.ofNullable(objectId) + /** The type of the object the environment variable is scoped for */ fun objectType(): Optional = Optional.ofNullable(objectType) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.envVarName?.let { queryParams.put("env_var_name", listOf(it.toString())) } this.ids?.let { queryParams.put("ids", listOf(it.toString())) } @@ -70,8 +81,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [EnvVarListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var envVarName: String? = null private var ids: Ids? = null @@ -93,34 +105,56 @@ constructor( } /** Name of the env_var to search for */ - fun envVarName(envVarName: String) = apply { this.envVarName = envVarName } + fun envVarName(envVarName: String?) = apply { this.envVarName = envVarName } + + /** Name of the env_var to search for */ + fun envVarName(envVarName: Optional) = envVarName(envVarName.orElse(null)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = ids(Ids.ofString(string)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Limit the number of objects to return */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** The id of the object the environment variable is scoped for */ + fun objectId(objectId: String?) = apply { this.objectId = objectId } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: Optional) = objectId(objectId.orElse(null)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType?) = apply { this.objectType = objectType } + + /** The type of the object the environment variable is scoped for */ + fun objectType(objectType: Optional) = objectType(objectType.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -232,6 +266,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -241,8 +279,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -265,15 +301,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -299,18 +326,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -326,7 +363,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, @@ -343,50 +380,67 @@ 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + @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 @@ -395,6 +449,15 @@ constructor( 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 @@ -404,6 +467,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 9c258975..9fffe418 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -7,38 +7,44 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects -@JsonDeserialize(builder = EnvVarListResponse.Builder::class) @NoAutoDetect class EnvVarListResponse +@JsonCreator private constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + @ExcludeMissing + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** A list of env_var objects */ fun objects(): List = objects.getRequired("objects") /** A list of env_var objects */ - @JsonProperty("objects") @ExcludeMissing fun _objects() = objects + @JsonProperty("objects") @ExcludeMissing fun _objects(): JsonField> = objects @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): EnvVarListResponse = apply { - if (!validated) { - objects().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -48,41 +54,64 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EnvVarListResponse]. */ + class Builder internal constructor() { - private var objects: JsonField> = JsonMissing.of() + private var objects: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVarListResponse: EnvVarListResponse) = apply { - this.objects = envVarListResponse.objects - additionalProperties(envVarListResponse.additionalProperties) + objects = envVarListResponse.objects.map { it.toMutableList() } + additionalProperties = envVarListResponse.additionalProperties.toMutableMap() } /** A list of env_var objects */ fun objects(objects: List) = objects(JsonField.of(objects)) /** A list of env_var objects */ - @JsonProperty("objects") - @ExcludeMissing - fun objects(objects: JsonField>) = apply { this.objects = objects } + fun objects(objects: JsonField>) = apply { + this.objects = objects.map { it.toMutableList() } + } + + /** A list of env_var objects */ + fun addObject(object_: EnvVar) = apply { + objects = + (objects ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(object_) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): EnvVarListResponse = - EnvVarListResponse(objects.map { it.toImmutable() }, additionalProperties.toImmutable()) + EnvVarListResponse( + checkRequired("objects", objects).map { it.toImmutable() }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index c08b94ac..e74d281e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -5,88 +5,134 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create or replace env_var. If there is an existing env_var with the same name as the one + * specified in the request, will replace the existing env_var with the provided fields + */ class EnvVarReplaceParams -constructor( - private val name: String, - private val objectId: String, - private val objectType: ObjectType, - private val value: String?, +private constructor( + private val body: EnvVarReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** The name of the environment variable */ + fun name(): String = body.name() - fun objectId(): String = objectId + /** The id of the object the environment variable is scoped for */ + fun objectId(): String = body.objectId() - fun objectType(): ObjectType = objectType + /** The type of the object the environment variable is scoped for */ + fun objectType(): ObjectType = body.objectType() - fun value(): Optional = Optional.ofNullable(value) + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(): Optional = body.value() + + /** The name of the environment variable */ + fun _name(): JsonField = body._name() + + /** The id of the object the environment variable is scoped for */ + fun _objectId(): JsonField = body._objectId() + + /** The type of the object the environment variable is scoped for */ + fun _objectType(): JsonField = body._objectType() + + /** The value of the environment variable. Will be encrypted at rest. */ + fun _value(): JsonField = body._value() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): EnvVarReplaceBody { - return EnvVarReplaceBody( - name, - objectId, - objectType, - value, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): EnvVarReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = EnvVarReplaceBody.Builder::class) @NoAutoDetect class EnvVarReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val objectId: String?, - private val objectType: ObjectType?, - private val value: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the environment variable */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** The id of the object the environment variable is scoped for */ + fun objectId(): String = objectId.getRequired("object_id") + + /** The type of the object the environment variable is scoped for */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The name of the environment variable */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") fun value(): String? = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EnvVarReplaceBody = apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + value() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -94,56 +140,77 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EnvVarReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var value: String? = null + private var name: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVarReplaceBody: EnvVarReplaceBody) = apply { - this.name = envVarReplaceBody.name - this.objectId = envVarReplaceBody.objectId - this.objectType = envVarReplaceBody.objectType - this.value = envVarReplaceBody.value - additionalProperties(envVarReplaceBody.additionalProperties) + name = envVarReplaceBody.name + objectId = envVarReplaceBody.objectId + objectType = envVarReplaceBody.objectType + value = envVarReplaceBody.value + additionalProperties = envVarReplaceBody.additionalProperties.toMutableMap() } /** The name of the environment variable */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the environment variable */ + fun name(name: JsonField) = apply { this.name = name } + + /** The id of the object the environment variable is scoped for */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The type of the object the environment variable is scoped for */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The type of the object the environment variable is scoped for */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") fun value(value: String) = apply { this.value = value } + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: Optional) = value(value.orElse(null)) + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): EnvVarReplaceBody = EnvVarReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), value, additionalProperties.toImmutable(), ) @@ -174,39 +241,66 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [EnvVarReplaceParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var value: String? = null + private var body: EnvVarReplaceBody.Builder = EnvVarReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVarReplaceParams: EnvVarReplaceParams) = apply { - name = envVarReplaceParams.name - objectId = envVarReplaceParams.objectId - objectType = envVarReplaceParams.objectType - value = envVarReplaceParams.value + body = envVarReplaceParams.body.toBuilder() additionalHeaders = envVarReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = envVarReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = envVarReplaceParams.additionalBodyProperties.toMutableMap() } /** The name of the environment variable */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** The name of the environment variable */ + fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { body.objectId(objectId) } + + /** The id of the object the environment variable is scoped for */ + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + + /** The type of the object the environment variable is scoped for */ + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String) = apply { this.value = value } + fun value(value: String?) = apply { body.value(value) } + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: Optional) = value(value.orElse(null)) + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: JsonField) = apply { body.value(value) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -306,84 +400,75 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): EnvVarReplaceParams = EnvVarReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - value, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + @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 @@ -392,6 +477,15 @@ constructor( 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 @@ -401,6 +495,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -408,11 +514,11 @@ constructor( return true } - return /* spotless:off */ other is EnvVarReplaceParams && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "EnvVarReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "EnvVarReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 8524af2e..689b946a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get an env_var object by its id */ class EnvVarRetrieveParams -constructor( +private constructor( private val envVarId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** EnvVar id */ fun envVarId(): String = envVarId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [EnvVarRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var envVarId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( - checkNotNull(envVarId) { "`envVarId` is required but was not set" }, + checkRequired("envVarId", envVarId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 9b59ba36..145dc69f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -3,53 +3,62 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update an env_var object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. + */ class EnvVarUpdateParams -constructor( +private constructor( private val envVarId: String, - private val name: String, - private val value: String?, + private val body: EnvVarUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** EnvVar id */ fun envVarId(): String = envVarId - fun name(): String = name + /** The name of the environment variable */ + fun name(): String = body.name() - fun value(): Optional = Optional.ofNullable(value) + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(): Optional = body.value() + + /** The name of the environment variable */ + fun _name(): JsonField = body._name() + + /** The value of the environment variable. Will be encrypted at rest. */ + fun _value(): JsonField = body._value() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): EnvVarUpdateBody { - return EnvVarUpdateBody( - name, - value, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): EnvVarUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -58,25 +67,48 @@ constructor( } } - @JsonDeserialize(builder = EnvVarUpdateBody.Builder::class) @NoAutoDetect class EnvVarUpdateBody + @JsonCreator internal constructor( - private val name: String?, - private val value: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the environment variable */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The name of the environment variable */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") fun value(): String? = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EnvVarUpdateBody = apply { + if (validated) { + return@apply + } + + name() + value() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -84,42 +116,57 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EnvVarUpdateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var value: String? = null + private var name: JsonField? = null + private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVarUpdateBody: EnvVarUpdateBody) = apply { - this.name = envVarUpdateBody.name - this.value = envVarUpdateBody.value - additionalProperties(envVarUpdateBody.additionalProperties) + name = envVarUpdateBody.name + value = envVarUpdateBody.value + additionalProperties = envVarUpdateBody.additionalProperties.toMutableMap() } /** The name of the environment variable */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the environment variable */ + fun name(name: JsonField) = apply { this.name = name } + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: String?) = value(JsonField.ofNullable(value)) /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") fun value(value: String) = apply { this.value = value } + fun value(value: Optional) = value(value.orElse(null)) + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): EnvVarUpdateBody = EnvVarUpdateBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), value, additionalProperties.toImmutable(), ) @@ -150,34 +197,59 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [EnvVarUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var envVarId: String? = null - private var name: String? = null - private var value: String? = null + private var body: EnvVarUpdateBody.Builder = EnvVarUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(envVarUpdateParams: EnvVarUpdateParams) = apply { envVarId = envVarUpdateParams.envVarId - name = envVarUpdateParams.name - value = envVarUpdateParams.value + body = envVarUpdateParams.body.toBuilder() additionalHeaders = envVarUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = envVarUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = envVarUpdateParams.additionalBodyProperties.toMutableMap() } /** EnvVar id */ fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } /** The name of the environment variable */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** The name of the environment variable */ + fun name(name: JsonField) = apply { body.name(name) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String) = apply { this.value = value } + fun value(value: String?) = apply { body.value(value) } + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: Optional) = value(value.orElse(null)) + + /** The value of the environment variable. Will be encrypted at rest. */ + fun value(value: JsonField) = apply { body.value(value) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -277,36 +349,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): EnvVarUpdateParams = EnvVarUpdateParams( - checkNotNull(envVarId) { "`envVarId` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - value, + checkRequired("envVarId", envVarId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -315,11 +363,11 @@ constructor( return true } - return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && name == other.name && value == other.value && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, name, value, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "EnvVarUpdateParams{envVarId=$envVarId, name=$name, value=$value, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "EnvVarUpdateParams{envVarId=$envVarId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 31008b33..bb4bde1d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -10,12 +10,14 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow 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.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -30,192 +32,424 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into the + * Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and scoring + * functions. The API will then run the evaluation, create an experiment, and return the results + * along with a link to the experiment. To learn more about evals, see the + * [Evals guide](https://www.braintrust.dev/docs/guides/evals). + */ class EvalCreateParams -constructor( - private val data: Data, - private val projectId: String, - private val scores: List, - private val task: Task, - private val baseExperimentId: String?, - private val baseExperimentName: String?, - private val experimentName: String?, - private val gitMetadataSettings: GitMetadataSettings?, - private val isPublic: Boolean?, - private val maxConcurrency: Double?, - private val metadata: Metadata?, - private val repoInfo: RepoInfo?, - private val stream: Boolean?, - private val timeout: Double?, - private val trialCount: Double?, +private constructor( + private val body: EvalCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun data(): Data = data + /** The dataset to use */ + fun data(): Data = body.data() - fun projectId(): String = projectId + /** Unique identifier for the project to run the eval in */ + fun projectId(): String = body.projectId() - fun scores(): List = scores + /** The functions to score the eval on */ + fun scores(): List = body.scores() - fun task(): Task = task + /** The function to evaluate */ + fun task(): Task = body.task() - fun baseExperimentId(): Optional = Optional.ofNullable(baseExperimentId) + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentId(): Optional = body.baseExperimentId() + + /** + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentName(): Optional = body.baseExperimentName() + + /** + * An optional name for the experiment created by this eval. If it conflicts with an existing + * experiment, it will be suffixed with a unique identifier. + */ + fun experimentName(): Optional = body.experimentName() + + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + fun gitMetadataSettings(): Optional = body.gitMetadataSettings() + + /** Whether the experiment should be public. Defaults to false. */ + fun isPublic(): Optional = body.isPublic() + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in + * which case there is no max concurrency. + */ + fun maxConcurrency(): Optional = body.maxConcurrency() + + /** + * Optional experiment-level metadata to store about the evaluation. You can later use this to + * slice & dice across experiments. + */ + fun metadata(): Optional = body.metadata() + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(): Optional = body.repoInfo() + + /** + * Whether to stream the results of the eval. If true, the request will return two events: one + * to indicate the experiment has started, and another upon completion. If false, the request + * will return the evaluation's summary upon completion. + */ + fun stream(): Optional = body.stream() + + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which + * case there is no timeout. + */ + fun timeout(): Optional = body.timeout() + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. + */ + fun trialCount(): Optional = body.trialCount() + + /** The dataset to use */ + fun _data(): JsonField = body._data() + + /** Unique identifier for the project to run the eval in */ + fun _projectId(): JsonField = body._projectId() + + /** The functions to score the eval on */ + fun _scores(): JsonField> = body._scores() + + /** The function to evaluate */ + fun _task(): JsonField = body._task() - fun baseExperimentName(): Optional = Optional.ofNullable(baseExperimentName) + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun _baseExperimentId(): JsonField = body._baseExperimentId() + + /** + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun _baseExperimentName(): JsonField = body._baseExperimentName() + + /** + * An optional name for the experiment created by this eval. If it conflicts with an existing + * experiment, it will be suffixed with a unique identifier. + */ + fun _experimentName(): JsonField = body._experimentName() - fun experimentName(): Optional = Optional.ofNullable(experimentName) + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + fun _gitMetadataSettings(): JsonField = body._gitMetadataSettings() - fun gitMetadataSettings(): Optional = - Optional.ofNullable(gitMetadataSettings) + /** Whether the experiment should be public. Defaults to false. */ + fun _isPublic(): JsonField = body._isPublic() - fun isPublic(): Optional = Optional.ofNullable(isPublic) + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in + * which case there is no max concurrency. + */ + fun _maxConcurrency(): JsonField = body._maxConcurrency() - fun maxConcurrency(): Optional = Optional.ofNullable(maxConcurrency) + /** + * Optional experiment-level metadata to store about the evaluation. You can later use this to + * slice & dice across experiments. + */ + fun _metadata(): JsonField = body._metadata() - fun metadata(): Optional = Optional.ofNullable(metadata) + /** Metadata about the state of the repo when the experiment was created */ + fun _repoInfo(): JsonField = body._repoInfo() - fun repoInfo(): Optional = Optional.ofNullable(repoInfo) + /** + * Whether to stream the results of the eval. If true, the request will return two events: one + * to indicate the experiment has started, and another upon completion. If false, the request + * will return the evaluation's summary upon completion. + */ + fun _stream(): JsonField = body._stream() - fun stream(): Optional = Optional.ofNullable(stream) + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which + * case there is no timeout. + */ + fun _timeout(): JsonField = body._timeout() - fun timeout(): Optional = Optional.ofNullable(timeout) + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. + */ + fun _trialCount(): JsonField = body._trialCount() - fun trialCount(): Optional = Optional.ofNullable(trialCount) + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): EvalCreateBody { - return EvalCreateBody( - data, - projectId, - scores, - task, - baseExperimentId, - baseExperimentName, - experimentName, - gitMetadataSettings, - isPublic, - maxConcurrency, - metadata, - repoInfo, - stream, - timeout, - trialCount, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): EvalCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = EvalCreateBody.Builder::class) @NoAutoDetect class EvalCreateBody + @JsonCreator internal constructor( - private val data: Data?, - private val projectId: String?, - private val scores: List?, - private val task: Task?, - private val baseExperimentId: String?, - private val baseExperimentName: String?, - private val experimentName: String?, - private val gitMetadataSettings: GitMetadataSettings?, - private val isPublic: Boolean?, - private val maxConcurrency: Double?, - private val metadata: Metadata?, - private val repoInfo: RepoInfo?, - private val stream: Boolean?, - private val timeout: Double?, - private val trialCount: Double?, - private val additionalProperties: Map, + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField> = JsonMissing.of(), + @JsonProperty("task") @ExcludeMissing private val task: JsonField = JsonMissing.of(), + @JsonProperty("base_experiment_id") + @ExcludeMissing + private val baseExperimentId: JsonField = JsonMissing.of(), + @JsonProperty("base_experiment_name") + @ExcludeMissing + private val baseExperimentName: JsonField = JsonMissing.of(), + @JsonProperty("experiment_name") + @ExcludeMissing + private val experimentName: JsonField = JsonMissing.of(), + @JsonProperty("git_metadata_settings") + @ExcludeMissing + private val gitMetadataSettings: JsonField = JsonMissing.of(), + @JsonProperty("is_public") + @ExcludeMissing + private val isPublic: JsonField = JsonMissing.of(), + @JsonProperty("max_concurrency") + @ExcludeMissing + private val maxConcurrency: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") + @ExcludeMissing + private val repoInfo: JsonField = JsonMissing.of(), + @JsonProperty("stream") + @ExcludeMissing + private val stream: JsonField = JsonMissing.of(), + @JsonProperty("timeout") + @ExcludeMissing + private val timeout: JsonField = JsonMissing.of(), + @JsonProperty("trial_count") + @ExcludeMissing + private val trialCount: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The dataset to use */ - @JsonProperty("data") fun data(): Data? = data + fun data(): Data = data.getRequired("data") /** Unique identifier for the project to run the eval in */ - @JsonProperty("project_id") fun projectId(): String? = projectId + fun projectId(): String = projectId.getRequired("project_id") /** The functions to score the eval on */ - @JsonProperty("scores") fun scores(): List? = scores + fun scores(): List = scores.getRequired("scores") /** The function to evaluate */ - @JsonProperty("task") fun task(): Task? = task + fun task(): Task = task.getRequired("task") /** * An optional experiment id to use as a base. If specified, the new experiment will be * summarized and compared to this experiment. */ - @JsonProperty("base_experiment_id") fun baseExperimentId(): String? = baseExperimentId + fun baseExperimentId(): Optional = + Optional.ofNullable(baseExperimentId.getNullable("base_experiment_id")) /** * An optional experiment name to use as a base. If specified, the new experiment will be * summarized and compared to this experiment. */ - @JsonProperty("base_experiment_name") fun baseExperimentName(): String? = baseExperimentName + fun baseExperimentName(): Optional = + Optional.ofNullable(baseExperimentName.getNullable("base_experiment_name")) /** * An optional name for the experiment created by this eval. If it conflicts with an * existing experiment, it will be suffixed with a unique identifier. */ - @JsonProperty("experiment_name") fun experimentName(): String? = experimentName + fun experimentName(): Optional = + Optional.ofNullable(experimentName.getNullable("experiment_name")) + + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + fun gitMetadataSettings(): Optional = + Optional.ofNullable(gitMetadataSettings.getNullable("git_metadata_settings")) + + /** Whether the experiment should be public. Defaults to false. */ + fun isPublic(): Optional = Optional.ofNullable(isPublic.getNullable("is_public")) + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. + */ + fun maxConcurrency(): Optional = + Optional.ofNullable(maxConcurrency.getNullable("max_concurrency")) + + /** + * Optional experiment-level metadata to store about the evaluation. You can later use this + * to slice & dice across experiments. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) + + /** + * Whether to stream the results of the eval. If true, the request will return two events: + * one to indicate the experiment has started, and another upon completion. If false, the + * request will return the evaluation's summary upon completion. + */ + fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) + + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. + */ + fun timeout(): Optional = Optional.ofNullable(timeout.getNullable("timeout")) + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. + */ + fun trialCount(): Optional = + Optional.ofNullable(trialCount.getNullable("trial_count")) + + /** The dataset to use */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** Unique identifier for the project to run the eval in */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** The functions to score the eval on */ + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField> = scores + + /** The function to evaluate */ + @JsonProperty("task") @ExcludeMissing fun _task(): JsonField = task + + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + @JsonProperty("base_experiment_id") + @ExcludeMissing + fun _baseExperimentId(): JsonField = baseExperimentId + + /** + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + @JsonProperty("base_experiment_name") + @ExcludeMissing + fun _baseExperimentName(): JsonField = baseExperimentName + + /** + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. + */ + @JsonProperty("experiment_name") + @ExcludeMissing + fun _experimentName(): JsonField = experimentName /** * Optional settings for collecting git metadata. By default, will collect all git metadata * fields allowed in org-level settings. */ @JsonProperty("git_metadata_settings") - fun gitMetadataSettings(): GitMetadataSettings? = gitMetadataSettings + @ExcludeMissing + fun _gitMetadataSettings(): JsonField = gitMetadataSettings /** Whether the experiment should be public. Defaults to false. */ - @JsonProperty("is_public") fun isPublic(): Boolean? = isPublic + @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField = isPublic /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, * in which case there is no max concurrency. */ - @JsonProperty("max_concurrency") fun maxConcurrency(): Double? = maxConcurrency + @JsonProperty("max_concurrency") + @ExcludeMissing + fun _maxConcurrency(): JsonField = maxConcurrency /** * Optional experiment-level metadata to store about the evaluation. You can later use this * to slice & dice across experiments. */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo /** * Whether to stream the results of the eval. If true, the request will return two events: * one to indicate the experiment has started, and another upon completion. If false, the * request will return the evaluation's summary upon completion. */ - @JsonProperty("stream") fun stream(): Boolean? = stream + @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream /** * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in * which case there is no timeout. */ - @JsonProperty("timeout") fun timeout(): Double? = timeout + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout /** * The number of times to run the evaluator per input. This is useful for evaluating * applications that have non-deterministic behavior and gives you both a stronger aggregate * measure and a sense of the variance in the results. */ - @JsonProperty("trial_count") fun trialCount(): Double? = trialCount + @JsonProperty("trial_count") + @ExcludeMissing + fun _trialCount(): JsonField = trialCount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EvalCreateBody = apply { + if (validated) { + return@apply + } + + data().validate() + projectId() + scores().forEach { it.validate() } + task().validate() + baseExperimentId() + baseExperimentName() + experimentName() + gitMetadataSettings().ifPresent { it.validate() } + isPublic() + maxConcurrency() + metadata().ifPresent { it.validate() } + repoInfo().ifPresent { it.validate() } + stream() + timeout() + trialCount() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -223,64 +457,154 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var data: Data? = null - private var projectId: String? = null - private var scores: List? = null - private var task: Task? = null - private var baseExperimentId: String? = null - private var baseExperimentName: String? = null - private var experimentName: String? = null - private var gitMetadataSettings: GitMetadataSettings? = null - private var isPublic: Boolean? = null - private var maxConcurrency: Double? = null - private var metadata: Metadata? = null - private var repoInfo: RepoInfo? = null - private var stream: Boolean? = null - private var timeout: Double? = null - private var trialCount: Double? = null + /** A builder for [EvalCreateBody]. */ + class Builder internal constructor() { + + private var data: JsonField? = null + private var projectId: JsonField? = null + private var scores: JsonField>? = null + private var task: JsonField? = null + private var baseExperimentId: JsonField = JsonMissing.of() + private var baseExperimentName: JsonField = JsonMissing.of() + private var experimentName: JsonField = JsonMissing.of() + private var gitMetadataSettings: JsonField = JsonMissing.of() + private var isPublic: JsonField = JsonMissing.of() + private var maxConcurrency: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var repoInfo: JsonField = JsonMissing.of() + private var stream: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var trialCount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(evalCreateBody: EvalCreateBody) = apply { - this.data = evalCreateBody.data - this.projectId = evalCreateBody.projectId - this.scores = evalCreateBody.scores - this.task = evalCreateBody.task - this.baseExperimentId = evalCreateBody.baseExperimentId - this.baseExperimentName = evalCreateBody.baseExperimentName - this.experimentName = evalCreateBody.experimentName - this.gitMetadataSettings = evalCreateBody.gitMetadataSettings - this.isPublic = evalCreateBody.isPublic - this.maxConcurrency = evalCreateBody.maxConcurrency - this.metadata = evalCreateBody.metadata - this.repoInfo = evalCreateBody.repoInfo - this.stream = evalCreateBody.stream - this.timeout = evalCreateBody.timeout - this.trialCount = evalCreateBody.trialCount - additionalProperties(evalCreateBody.additionalProperties) + data = evalCreateBody.data + projectId = evalCreateBody.projectId + scores = evalCreateBody.scores.map { it.toMutableList() } + task = evalCreateBody.task + baseExperimentId = evalCreateBody.baseExperimentId + baseExperimentName = evalCreateBody.baseExperimentName + experimentName = evalCreateBody.experimentName + gitMetadataSettings = evalCreateBody.gitMetadataSettings + isPublic = evalCreateBody.isPublic + maxConcurrency = evalCreateBody.maxConcurrency + metadata = evalCreateBody.metadata + repoInfo = evalCreateBody.repoInfo + stream = evalCreateBody.stream + timeout = evalCreateBody.timeout + trialCount = evalCreateBody.trialCount + additionalProperties = evalCreateBody.additionalProperties.toMutableMap() } /** The dataset to use */ - @JsonProperty("data") fun data(data: Data) = apply { this.data = data } + fun data(data: Data) = data(JsonField.of(data)) + + /** The dataset to use */ + fun data(data: JsonField) = apply { this.data = data } + + /** Dataset id */ + fun data(datasetId: Data.DatasetId) = data(Data.ofDatasetId(datasetId)) + + /** Project and dataset name */ + fun data(projectDatasetName: Data.ProjectDatasetName) = + data(Data.ofProjectDatasetName(projectDatasetName)) /** Unique identifier for the project to run the eval in */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project to run the eval in */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** The functions to score the eval on */ + fun scores(scores: List) = scores(JsonField.of(scores)) + + /** The functions to score the eval on */ + fun scores(scores: JsonField>) = apply { + this.scores = scores.map { it.toMutableList() } + } /** The functions to score the eval on */ - @JsonProperty("scores") fun scores(scores: List) = apply { this.scores = scores } + fun addScore(score: Score) = apply { + scores = + (scores ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(score) + } + } + + /** Function id */ + fun addScore(functionId: Score.FunctionId) = addScore(Score.ofFunctionId(functionId)) + + /** Project name and slug */ + fun addScore(projectSlug: Score.ProjectSlug) = + addScore(Score.ofProjectSlug(projectSlug)) + + /** Global function name */ + fun addScore(globalFunction: Score.GlobalFunction) = + addScore(Score.ofGlobalFunction(globalFunction)) + + /** Prompt session id */ + fun addScore(promptSessionId: Score.PromptSessionId) = + addScore(Score.ofPromptSessionId(promptSessionId)) + + /** Inline code function */ + fun addScore(inlineCode: Score.InlineCode) = addScore(Score.ofInlineCode(inlineCode)) + + /** Inline prompt definition */ + fun addScore(inlinePrompt: Score.InlinePrompt) = + addScore(Score.ofInlinePrompt(inlinePrompt)) /** The function to evaluate */ - @JsonProperty("task") fun task(task: Task) = apply { this.task = task } + fun task(task: Task) = task(JsonField.of(task)) + + /** The function to evaluate */ + fun task(task: JsonField) = apply { this.task = task } + + /** Function id */ + fun task(functionId: Task.FunctionId) = task(Task.ofFunctionId(functionId)) + + /** Project name and slug */ + fun task(projectSlug: Task.ProjectSlug) = task(Task.ofProjectSlug(projectSlug)) + + /** Global function name */ + fun task(globalFunction: Task.GlobalFunction) = + task(Task.ofGlobalFunction(globalFunction)) + + /** Prompt session id */ + fun task(promptSessionId: Task.PromptSessionId) = + task(Task.ofPromptSessionId(promptSessionId)) + + /** Inline code function */ + fun task(inlineCode: Task.InlineCode) = task(Task.ofInlineCode(inlineCode)) + + /** Inline prompt definition */ + fun task(inlinePrompt: Task.InlinePrompt) = task(Task.ofInlinePrompt(inlinePrompt)) + + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentId(baseExperimentId: String?) = + baseExperimentId(JsonField.ofNullable(baseExperimentId)) /** * An optional experiment id to use as a base. If specified, the new experiment will be * summarized and compared to this experiment. */ - @JsonProperty("base_experiment_id") - fun baseExperimentId(baseExperimentId: String) = apply { + fun baseExperimentId(baseExperimentId: Optional) = + baseExperimentId(baseExperimentId.orElse(null)) + + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentId(baseExperimentId: JsonField) = apply { this.baseExperimentId = baseExperimentId } @@ -288,8 +612,21 @@ constructor( * An optional experiment name to use as a base. If specified, the new experiment will * be summarized and compared to this experiment. */ - @JsonProperty("base_experiment_name") - fun baseExperimentName(baseExperimentName: String) = apply { + fun baseExperimentName(baseExperimentName: String?) = + baseExperimentName(JsonField.ofNullable(baseExperimentName)) + + /** + * An optional experiment name to use as a base. If specified, the new experiment will + * be summarized and compared to this experiment. + */ + fun baseExperimentName(baseExperimentName: Optional) = + baseExperimentName(baseExperimentName.orElse(null)) + + /** + * An optional experiment name to use as a base. If specified, the new experiment will + * be summarized and compared to this experiment. + */ + fun baseExperimentName(baseExperimentName: JsonField) = apply { this.baseExperimentName = baseExperimentName } @@ -297,8 +634,14 @@ constructor( * An optional name for the experiment created by this eval. If it conflicts with an * existing experiment, it will be suffixed with a unique identifier. */ - @JsonProperty("experiment_name") - fun experimentName(experimentName: String) = apply { + fun experimentName(experimentName: String) = + experimentName(JsonField.of(experimentName)) + + /** + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. + */ + fun experimentName(experimentName: JsonField) = apply { this.experimentName = experimentName } @@ -306,21 +649,63 @@ constructor( * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - @JsonProperty("git_metadata_settings") - fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings) = apply { + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = + gitMetadataSettings(JsonField.ofNullable(gitMetadataSettings)) + + /** + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. + */ + fun gitMetadataSettings(gitMetadataSettings: Optional) = + gitMetadataSettings(gitMetadataSettings.orElse(null)) + + /** + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. + */ + fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { this.gitMetadataSettings = gitMetadataSettings } /** Whether the experiment should be public. Defaults to false. */ - @JsonProperty("is_public") - fun isPublic(isPublic: Boolean) = apply { this.isPublic = isPublic } + fun isPublic(isPublic: Boolean?) = isPublic(JsonField.ofNullable(isPublic)) + + /** Whether the experiment should be public. Defaults to false. */ + fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) + + /** Whether the experiment should be public. Defaults to false. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isPublic(isPublic: Optional) = isPublic(isPublic.orElse(null) as Boolean?) + + /** Whether the experiment should be public. Defaults to false. */ + fun isPublic(isPublic: JsonField) = apply { this.isPublic = isPublic } + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. + */ + fun maxConcurrency(maxConcurrency: Double?) = + maxConcurrency(JsonField.ofNullable(maxConcurrency)) + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. + */ + fun maxConcurrency(maxConcurrency: Double) = maxConcurrency(maxConcurrency as Double?) + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maxConcurrency(maxConcurrency: Optional) = + maxConcurrency(maxConcurrency.orElse(null) as Double?) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - @JsonProperty("max_concurrency") - fun maxConcurrency(maxConcurrency: Double) = apply { + fun maxConcurrency(maxConcurrency: JsonField) = apply { this.maxConcurrency = maxConcurrency } @@ -328,54 +713,117 @@ constructor( * Optional experiment-level metadata to store about the evaluation. You can later use * this to slice & dice across experiments. */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Optional experiment-level metadata to store about the evaluation. You can later use + * this to slice & dice across experiments. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + + /** + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. If + * false, the request will return the evaluation's summary upon completion. + */ + fun stream(stream: Boolean) = stream(JsonField.of(stream)) /** * Whether to stream the results of the eval. If true, the request will return two * events: one to indicate the experiment has started, and another upon completion. If * false, the request will return the evaluation's summary upon completion. */ - @JsonProperty("stream") fun stream(stream: Boolean) = apply { this.stream = stream } + fun stream(stream: JsonField) = apply { this.stream = stream } + + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, + * in which case there is no timeout. + */ + fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) + + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, + * in which case there is no timeout. + */ + fun timeout(timeout: Double) = timeout(timeout as Double?) + + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, + * in which case there is no timeout. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun timeout(timeout: Optional) = timeout(timeout.orElse(null) as Double?) /** * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, * in which case there is no timeout. */ - @JsonProperty("timeout") fun timeout(timeout: Double) = apply { this.timeout = timeout } + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger + * aggregate measure and a sense of the variance in the results. + */ + fun trialCount(trialCount: Double?) = trialCount(JsonField.ofNullable(trialCount)) + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger + * aggregate measure and a sense of the variance in the results. + */ + fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger + * aggregate measure and a sense of the variance in the results. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun trialCount(trialCount: Optional) = + trialCount(trialCount.orElse(null) as Double?) /** * The number of times to run the evaluator per input. This is useful for evaluating * applications that have non-deterministic behavior and gives you both a stronger * aggregate measure and a sense of the variance in the results. */ - @JsonProperty("trial_count") - fun trialCount(trialCount: Double) = apply { this.trialCount = trialCount } + fun trialCount(trialCount: JsonField) = apply { this.trialCount = trialCount } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): EvalCreateBody = EvalCreateBody( - checkNotNull(data) { "`data` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(scores) { "`scores` is required but was not set" }.toImmutable(), - checkNotNull(task) { "`task` is required but was not set" }, + checkRequired("data", data), + checkRequired("projectId", projectId), + checkRequired("scores", scores).map { it.toImmutable() }, + checkRequired("task", task), baseExperimentId, baseExperimentName, experimentName, @@ -416,169 +864,326 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [EvalCreateParams]. */ @NoAutoDetect - class Builder { - - private var data: Data? = null - private var projectId: String? = null - private var scores: MutableList = mutableListOf() - private var task: Task? = null - private var baseExperimentId: String? = null - private var baseExperimentName: String? = null - private var experimentName: String? = null - private var gitMetadataSettings: GitMetadataSettings? = null - private var isPublic: Boolean? = null - private var maxConcurrency: Double? = null - private var metadata: Metadata? = null - private var repoInfo: RepoInfo? = null - private var stream: Boolean? = null - private var timeout: Double? = null - private var trialCount: Double? = null + class Builder internal constructor() { + + private var body: EvalCreateBody.Builder = EvalCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(evalCreateParams: EvalCreateParams) = apply { - data = evalCreateParams.data - projectId = evalCreateParams.projectId - scores = evalCreateParams.scores.toMutableList() - task = evalCreateParams.task - baseExperimentId = evalCreateParams.baseExperimentId - baseExperimentName = evalCreateParams.baseExperimentName - experimentName = evalCreateParams.experimentName - gitMetadataSettings = evalCreateParams.gitMetadataSettings - isPublic = evalCreateParams.isPublic - maxConcurrency = evalCreateParams.maxConcurrency - metadata = evalCreateParams.metadata - repoInfo = evalCreateParams.repoInfo - stream = evalCreateParams.stream - timeout = evalCreateParams.timeout - trialCount = evalCreateParams.trialCount + body = evalCreateParams.body.toBuilder() additionalHeaders = evalCreateParams.additionalHeaders.toBuilder() additionalQueryParams = evalCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = evalCreateParams.additionalBodyProperties.toMutableMap() } /** The dataset to use */ - fun data(data: Data) = apply { this.data = data } + fun data(data: Data) = apply { body.data(data) } /** The dataset to use */ - fun data(datasetId: Data.DatasetId) = apply { this.data = Data.ofDatasetId(datasetId) } + fun data(data: JsonField) = apply { body.data(data) } - /** The dataset to use */ + /** Dataset id */ + fun data(datasetId: Data.DatasetId) = apply { body.data(datasetId) } + + /** Project and dataset name */ fun data(projectDatasetName: Data.ProjectDatasetName) = apply { - this.data = Data.ofProjectDatasetName(projectDatasetName) + body.data(projectDatasetName) } /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { body.projectId(projectId) } + + /** Unique identifier for the project to run the eval in */ + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The functions to score the eval on */ - fun scores(scores: List) = apply { - this.scores.clear() - this.scores.addAll(scores) - } + fun scores(scores: List) = apply { body.scores(scores) } /** The functions to score the eval on */ - fun addScore(score: Score) = apply { this.scores.add(score) } + fun scores(scores: JsonField>) = apply { body.scores(scores) } - /** The function to evaluate */ - fun task(task: Task) = apply { this.task = task } + /** The functions to score the eval on */ + fun addScore(score: Score) = apply { body.addScore(score) } + + /** Function id */ + fun addScore(functionId: Score.FunctionId) = apply { body.addScore(functionId) } + + /** Project name and slug */ + fun addScore(projectSlug: Score.ProjectSlug) = apply { body.addScore(projectSlug) } + + /** Global function name */ + fun addScore(globalFunction: Score.GlobalFunction) = apply { body.addScore(globalFunction) } + + /** Prompt session id */ + fun addScore(promptSessionId: Score.PromptSessionId) = apply { + body.addScore(promptSessionId) + } + + /** Inline code function */ + fun addScore(inlineCode: Score.InlineCode) = apply { body.addScore(inlineCode) } + + /** Inline prompt definition */ + fun addScore(inlinePrompt: Score.InlinePrompt) = apply { body.addScore(inlinePrompt) } /** The function to evaluate */ - fun task(functionId: Task.FunctionId) = apply { this.task = Task.ofFunctionId(functionId) } + fun task(task: Task) = apply { body.task(task) } /** The function to evaluate */ - fun task(projectSlug: Task.ProjectSlug) = apply { - this.task = Task.ofProjectSlug(projectSlug) + fun task(task: JsonField) = apply { body.task(task) } + + /** Function id */ + fun task(functionId: Task.FunctionId) = apply { body.task(functionId) } + + /** Project name and slug */ + fun task(projectSlug: Task.ProjectSlug) = apply { body.task(projectSlug) } + + /** Global function name */ + fun task(globalFunction: Task.GlobalFunction) = apply { body.task(globalFunction) } + + /** Prompt session id */ + fun task(promptSessionId: Task.PromptSessionId) = apply { body.task(promptSessionId) } + + /** Inline code function */ + fun task(inlineCode: Task.InlineCode) = apply { body.task(inlineCode) } + + /** Inline prompt definition */ + fun task(inlinePrompt: Task.InlinePrompt) = apply { body.task(inlinePrompt) } + + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentId(baseExperimentId: String?) = apply { + body.baseExperimentId(baseExperimentId) } - /** The function to evaluate */ - fun task(globalFunction: Task.GlobalFunction) = apply { - this.task = Task.ofGlobalFunction(globalFunction) + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentId(baseExperimentId: Optional) = + baseExperimentId(baseExperimentId.orElse(null)) + + /** + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentId(baseExperimentId: JsonField) = apply { + body.baseExperimentId(baseExperimentId) } - /** The function to evaluate */ - fun task(promptSessionId: Task.PromptSessionId) = apply { - this.task = Task.ofPromptSessionId(promptSessionId) + /** + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentName(baseExperimentName: String?) = apply { + body.baseExperimentName(baseExperimentName) } - /** The function to evaluate */ - fun task(inlineCode: Task.InlineCode) = apply { this.task = Task.ofInlineCode(inlineCode) } + /** + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentName(baseExperimentName: Optional) = + baseExperimentName(baseExperimentName.orElse(null)) - /** The function to evaluate */ - fun task(inlinePrompt: Task.InlinePrompt) = apply { - this.task = Task.ofInlinePrompt(inlinePrompt) + /** + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. + */ + fun baseExperimentName(baseExperimentName: JsonField) = apply { + body.baseExperimentName(baseExperimentName) } /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. + */ + fun experimentName(experimentName: String) = apply { body.experimentName(experimentName) } + + /** + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. + */ + fun experimentName(experimentName: JsonField) = apply { + body.experimentName(experimentName) + } + + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = apply { + body.gitMetadataSettings(gitMetadataSettings) + } + + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + fun gitMetadataSettings(gitMetadataSettings: Optional) = + gitMetadataSettings(gitMetadataSettings.orElse(null)) + + /** + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. + */ + fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { + body.gitMetadataSettings(gitMetadataSettings) + } + + /** Whether the experiment should be public. Defaults to false. */ + fun isPublic(isPublic: Boolean?) = apply { body.isPublic(isPublic) } + + /** Whether the experiment should be public. Defaults to false. */ + fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) + + /** Whether the experiment should be public. Defaults to false. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isPublic(isPublic: Optional) = isPublic(isPublic.orElse(null) as Boolean?) + + /** Whether the experiment should be public. Defaults to false. */ + fun isPublic(isPublic: JsonField) = apply { body.isPublic(isPublic) } + + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ - fun baseExperimentId(baseExperimentId: String) = apply { - this.baseExperimentId = baseExperimentId - } + fun maxConcurrency(maxConcurrency: Double?) = apply { body.maxConcurrency(maxConcurrency) } /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ - fun baseExperimentName(baseExperimentName: String) = apply { - this.baseExperimentName = baseExperimentName - } + fun maxConcurrency(maxConcurrency: Double) = maxConcurrency(maxConcurrency as Double?) /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ - fun experimentName(experimentName: String) = apply { this.experimentName = experimentName } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maxConcurrency(maxConcurrency: Optional) = + maxConcurrency(maxConcurrency.orElse(null) as Double?) /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ - fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings) = apply { - this.gitMetadataSettings = gitMetadataSettings + fun maxConcurrency(maxConcurrency: JsonField) = apply { + body.maxConcurrency(maxConcurrency) } - /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: Boolean) = apply { this.isPublic = isPublic } - /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * Optional experiment-level metadata to store about the evaluation. You can later use this + * to slice & dice across experiments. */ - fun maxConcurrency(maxConcurrency: Double) = apply { this.maxConcurrency = maxConcurrency } + fun metadata(metadata: Metadata) = apply { body.metadata(metadata) } /** * Optional experiment-level metadata to store about the evaluation. You can later use this * to slice & dice across experiments. */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + + /** + * Whether to stream the results of the eval. If true, the request will return two events: + * one to indicate the experiment has started, and another upon completion. If false, the + * request will return the evaluation's summary upon completion. + */ + fun stream(stream: Boolean) = apply { body.stream(stream) } /** * Whether to stream the results of the eval. If true, the request will return two events: * one to indicate the experiment has started, and another upon completion. If false, the * request will return the evaluation's summary upon completion. */ - fun stream(stream: Boolean) = apply { this.stream = stream } + fun stream(stream: JsonField) = apply { body.stream(stream) } + + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. + */ + fun timeout(timeout: Double?) = apply { body.timeout(timeout) } + + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. + */ + fun timeout(timeout: Double) = timeout(timeout as Double?) + + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun timeout(timeout: Optional) = timeout(timeout.orElse(null) as Double?) /** * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in * which case there is no timeout. */ - fun timeout(timeout: Double) = apply { this.timeout = timeout } + fun timeout(timeout: JsonField) = apply { body.timeout(timeout) } + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. + */ + fun trialCount(trialCount: Double?) = apply { body.trialCount(trialCount) } + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. + */ + fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) + + /** + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun trialCount(trialCount: Optional) = + trialCount(trialCount.orElse(null) as Double?) /** * The number of times to run the evaluator per input. This is useful for evaluating * applications that have non-deterministic behavior and gives you both a stronger aggregate * measure and a sense of the variance in the results. */ - fun trialCount(trialCount: Double) = apply { this.trialCount = trialCount } + fun trialCount(trialCount: JsonField) = apply { body.trialCount(trialCount) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -678,51 +1283,15 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): EvalCreateParams = EvalCreateParams( - checkNotNull(data) { "`data` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - scores.toImmutable(), - checkNotNull(task) { "`task` is required but was not set" }, - baseExperimentId, - baseExperimentName, - experimentName, - gitMetadataSettings, - isPublic, - maxConcurrency, - metadata, - repoInfo, - stream, - timeout, - trialCount, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** The dataset to use */ @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) class Data @@ -732,10 +1301,9 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** Dataset id */ fun datasetId(): Optional = Optional.ofNullable(datasetId) + /** Project and dataset name */ fun projectDatasetName(): Optional = Optional.ofNullable(projectDatasetName) @@ -744,8 +1312,10 @@ constructor( fun isProjectDatasetName(): Boolean = projectDatasetName != null + /** Dataset id */ fun asDatasetId(): DatasetId = datasetId.getOrThrow("datasetId") + /** Project and dataset name */ fun asProjectDatasetName(): ProjectDatasetName = projectDatasetName.getOrThrow("projectDatasetName") @@ -759,15 +1329,25 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Data = apply { - if (!validated) { - if (datasetId == null && projectDatasetName == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - datasetId?.validate() - projectDatasetName?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitDatasetId(datasetId: DatasetId) { + datasetId.validate() + } + + override fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName) { + projectDatasetName.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -790,25 +1370,39 @@ constructor( companion object { + /** Dataset id */ @JvmStatic fun ofDatasetId(datasetId: DatasetId) = Data(datasetId = datasetId) + /** Project and dataset name */ @JvmStatic fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = Data(projectDatasetName = projectDatasetName) } + /** An interface that defines how to map each variant of [Data] to a value of type [T]. */ interface Visitor { + /** Dataset id */ fun visitDatasetId(datasetId: DatasetId): T + /** Project and dataset name */ fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName): T + /** + * Maps an unknown variant of [Data] to a value of type [T]. + * + * An instance of [Data] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Data: $json") } } - class Deserializer : BaseDeserializer(Data::class) { + internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) @@ -826,7 +1420,7 @@ constructor( } } - class Serializer : BaseSerializer(Data::class) { + internal class Serializer : BaseSerializer(Data::class) { override fun serialize( value: Data, @@ -844,29 +1438,36 @@ constructor( } /** Dataset id */ - @JsonDeserialize(builder = DatasetId.Builder::class) @NoAutoDetect class DatasetId + @JsonCreator private constructor( - private val datasetId: JsonField, - private val additionalProperties: Map, + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun datasetId(): String = datasetId.getRequired("dataset_id") - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): DatasetId = apply { - if (!validated) { - datasetId() - validated = true + if (validated) { + return@apply } + + datasetId() + validated = true } fun toBuilder() = Builder().from(this) @@ -876,31 +1477,29 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DatasetId]. */ + class Builder internal constructor() { - private var datasetId: JsonField = JsonMissing.of() + private var datasetId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetId: DatasetId) = apply { this.datasetId = datasetId.datasetId - additionalProperties(datasetId.additionalProperties) + additionalProperties = datasetId.additionalProperties.toMutableMap() } fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - @JsonProperty("dataset_id") - @ExcludeMissing fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -908,7 +1507,19 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetId = DatasetId(datasetId, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): DatasetId = + DatasetId( + checkRequired("datasetId", datasetId), + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -930,35 +1541,46 @@ constructor( } /** Project and dataset name */ - @JsonDeserialize(builder = ProjectDatasetName.Builder::class) @NoAutoDetect class ProjectDatasetName + @JsonCreator private constructor( - private val projectName: JsonField, - private val datasetName: JsonField, - private val additionalProperties: Map, + @JsonProperty("dataset_name") + @ExcludeMissing + private val datasetName: JsonField = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun datasetName(): String = datasetName.getRequired("dataset_name") fun projectName(): String = projectName.getRequired("project_name") - fun datasetName(): String = datasetName.getRequired("dataset_name") - - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName + @JsonProperty("dataset_name") + @ExcludeMissing + fun _datasetName(): JsonField = datasetName - @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName() = datasetName + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName(): JsonField = projectName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectDatasetName = apply { - if (!validated) { - projectName() - datasetName() - validated = true + if (validated) { + return@apply } + + datasetName() + projectName() + validated = true } fun toBuilder() = Builder().from(this) @@ -968,43 +1590,39 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectDatasetName]. */ + class Builder internal constructor() { - private var projectName: JsonField = JsonMissing.of() - private var datasetName: JsonField = JsonMissing.of() + private var datasetName: JsonField? = null + private var projectName: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectDatasetName: ProjectDatasetName) = apply { - this.projectName = projectDatasetName.projectName - this.datasetName = projectDatasetName.datasetName - additionalProperties(projectDatasetName.additionalProperties) - } - - fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - - @JsonProperty("project_name") - @ExcludeMissing - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName + datasetName = projectDatasetName.datasetName + projectName = projectDatasetName.projectName + additionalProperties = projectDatasetName.additionalProperties.toMutableMap() } fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) - @JsonProperty("dataset_name") - @ExcludeMissing fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } + fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + + fun projectName(projectName: JsonField) = apply { + this.projectName = projectName + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1012,10 +1630,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectDatasetName = ProjectDatasetName( - projectName, - datasetName, + checkRequired("datasetName", datasetName), + checkRequired("projectName", projectName), additionalProperties.toImmutable(), ) } @@ -1025,20 +1651,21 @@ constructor( return true } - return /* spotless:off */ other is ProjectDatasetName && projectName == other.projectName && datasetName == other.datasetName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(projectName, datasetName, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(datasetName, projectName, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectDatasetName{projectName=$projectName, datasetName=$datasetName, additionalProperties=$additionalProperties}" + "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" } } + /** The function to evaluate */ @JsonDeserialize(using = Score.Deserializer::class) @JsonSerialize(using = Score.Serializer::class) class Score @@ -1052,18 +1679,21 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** Function id */ fun functionId(): Optional = Optional.ofNullable(functionId) + /** Project name and slug */ fun projectSlug(): Optional = Optional.ofNullable(projectSlug) + /** Global function name */ fun globalFunction(): Optional = Optional.ofNullable(globalFunction) + /** Prompt session id */ fun promptSessionId(): Optional = Optional.ofNullable(promptSessionId) + /** Inline code function */ fun inlineCode(): Optional = Optional.ofNullable(inlineCode) + /** Inline prompt definition */ fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt) @@ -1079,16 +1709,22 @@ constructor( fun isInlinePrompt(): Boolean = inlinePrompt != null + /** Function id */ fun asFunctionId(): FunctionId = functionId.getOrThrow("functionId") + /** Project name and slug */ fun asProjectSlug(): ProjectSlug = projectSlug.getOrThrow("projectSlug") + /** Global function name */ fun asGlobalFunction(): GlobalFunction = globalFunction.getOrThrow("globalFunction") + /** Prompt session id */ fun asPromptSessionId(): PromptSessionId = promptSessionId.getOrThrow("promptSessionId") + /** Inline code function */ fun asInlineCode(): InlineCode = inlineCode.getOrThrow("inlineCode") + /** Inline prompt definition */ fun asInlinePrompt(): InlinePrompt = inlinePrompt.getOrThrow("inlinePrompt") fun _json(): Optional = Optional.ofNullable(_json) @@ -1105,26 +1741,41 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Score = apply { - if (!validated) { - if ( - functionId == null && - projectSlug == null && - globalFunction == null && - promptSessionId == null && - inlineCode == null && - inlinePrompt == null - ) { - throw BraintrustInvalidDataException("Unknown Score: $_json") - } - functionId?.validate() - projectSlug?.validate() - globalFunction?.validate() - promptSessionId?.validate() - inlineCode?.validate() - inlinePrompt?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitFunctionId(functionId: FunctionId) { + functionId.validate() + } + + override fun visitProjectSlug(projectSlug: ProjectSlug) { + projectSlug.validate() + } + + override fun visitGlobalFunction(globalFunction: GlobalFunction) { + globalFunction.validate() + } + + override fun visitPromptSessionId(promptSessionId: PromptSessionId) { + promptSessionId.validate() + } + + override fun visitInlineCode(inlineCode: InlineCode) { + inlineCode.validate() + } + + override fun visitInlinePrompt(inlinePrompt: InlinePrompt) { + inlinePrompt.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -1151,45 +1802,68 @@ constructor( companion object { + /** Function id */ @JvmStatic fun ofFunctionId(functionId: FunctionId) = Score(functionId = functionId) + /** Project name and slug */ @JvmStatic fun ofProjectSlug(projectSlug: ProjectSlug) = Score(projectSlug = projectSlug) + /** Global function name */ @JvmStatic fun ofGlobalFunction(globalFunction: GlobalFunction) = Score(globalFunction = globalFunction) + /** Prompt session id */ @JvmStatic fun ofPromptSessionId(promptSessionId: PromptSessionId) = Score(promptSessionId = promptSessionId) + /** Inline code function */ @JvmStatic fun ofInlineCode(inlineCode: InlineCode) = Score(inlineCode = inlineCode) + /** Inline prompt definition */ @JvmStatic fun ofInlinePrompt(inlinePrompt: InlinePrompt) = Score(inlinePrompt = inlinePrompt) } + /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ interface Visitor { + /** Function id */ fun visitFunctionId(functionId: FunctionId): T + /** Project name and slug */ fun visitProjectSlug(projectSlug: ProjectSlug): T + /** Global function name */ fun visitGlobalFunction(globalFunction: GlobalFunction): T + /** Prompt session id */ fun visitPromptSessionId(promptSessionId: PromptSessionId): T + /** Inline code function */ fun visitInlineCode(inlineCode: InlineCode): T + /** Inline prompt definition */ fun visitInlinePrompt(inlinePrompt: InlinePrompt): T + /** + * Maps an unknown variant of [Score] to a value of type [T]. + * + * An instance of [Score] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Score: $json") } } - class Deserializer : BaseDeserializer(Score::class) { + internal class Deserializer : BaseDeserializer(Score::class) { override fun ObjectCodec.deserialize(node: JsonNode): Score { val json = JsonValue.fromJsonNode(node) @@ -1223,7 +1897,7 @@ constructor( } } - class Serializer : BaseSerializer(Score::class) { + internal class Serializer : BaseSerializer(Score::class) { override fun serialize( value: Score, @@ -1244,17 +1918,20 @@ constructor( } /** Function id */ - @JsonDeserialize(builder = FunctionId.Builder::class) @NoAutoDetect class FunctionId + @JsonCreator private constructor( - private val functionId: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("function_id") + @ExcludeMissing + private val functionId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The ID of the function */ fun functionId(): String = functionId.getRequired("function_id") @@ -1262,21 +1939,27 @@ constructor( fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** The ID of the function */ - @JsonProperty("function_id") @ExcludeMissing fun _functionId() = functionId + @JsonProperty("function_id") + @ExcludeMissing + fun _functionId(): JsonField = functionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FunctionId = apply { - if (!validated) { - functionId() - version() - validated = true + if (validated) { + return@apply } + + functionId() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1286,25 +1969,24 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionId]. */ + class Builder internal constructor() { - private var functionId: JsonField = JsonMissing.of() + private var functionId: JsonField? = null private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionId: FunctionId) = apply { this.functionId = functionId.functionId - this.version = functionId.version - additionalProperties(functionId.additionalProperties) + version = functionId.version + additionalProperties = functionId.additionalProperties.toMutableMap() } /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) /** The ID of the function */ - @JsonProperty("function_id") - @ExcludeMissing fun functionId(functionId: JsonField) = apply { this.functionId = functionId } @@ -1313,18 +1995,15 @@ constructor( fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1332,9 +2011,17 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionId = FunctionId( - functionId, + checkRequired("functionId", functionId), version, additionalProperties.toImmutable(), ) @@ -1359,18 +2046,23 @@ constructor( } /** Project name and slug */ - @JsonDeserialize(builder = ProjectSlug.Builder::class) @NoAutoDetect class ProjectSlug + @JsonCreator private constructor( - private val projectName: JsonField, - private val slug: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The name of the project containing the function */ fun projectName(): String = projectName.getRequired("project_name") @@ -1381,25 +2073,31 @@ constructor( fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** The name of the project containing the function */ - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName(): JsonField = projectName /** The slug of the function */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectSlug = apply { - if (!validated) { - projectName() - slug() - version() - validated = true + if (validated) { + return@apply } + + projectName() + slug() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1409,27 +2107,26 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectSlug]. */ + class Builder internal constructor() { - private var projectName: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() + private var projectName: JsonField? = null + private var slug: JsonField? = null private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectSlug: ProjectSlug) = apply { - this.projectName = projectSlug.projectName - this.slug = projectSlug.slug - this.version = projectSlug.version - additionalProperties(projectSlug.additionalProperties) + projectName = projectSlug.projectName + slug = projectSlug.slug + version = projectSlug.version + additionalProperties = projectSlug.additionalProperties.toMutableMap() } /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** The name of the project containing the function */ - @JsonProperty("project_name") - @ExcludeMissing fun projectName(projectName: JsonField) = apply { this.projectName = projectName } @@ -1438,26 +2135,21 @@ constructor( fun slug(slug: String) = slug(JsonField.of(slug)) /** The slug of the function */ - @JsonProperty("slug") - @ExcludeMissing fun slug(slug: JsonField) = apply { this.slug = slug } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1465,10 +2157,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectSlug = ProjectSlug( - projectName, - slug, + checkRequired("projectName", projectName), + checkRequired("slug", slug), version, additionalProperties.toImmutable(), ) @@ -1493,16 +2193,17 @@ constructor( } /** Global function name */ - @JsonDeserialize(builder = GlobalFunction.Builder::class) @NoAutoDetect class GlobalFunction + @JsonCreator private constructor( - private val globalFunction: JsonField, - private val additionalProperties: Map, + @JsonProperty("global_function") + @ExcludeMissing + private val globalFunction: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals @@ -1513,17 +2214,23 @@ constructor( * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - @JsonProperty("global_function") @ExcludeMissing fun _globalFunction() = globalFunction + @JsonProperty("global_function") + @ExcludeMissing + fun _globalFunction(): JsonField = globalFunction @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): GlobalFunction = apply { - if (!validated) { - globalFunction() - validated = true + if (validated) { + return@apply } + + globalFunction() + validated = true } fun toBuilder() = Builder().from(this) @@ -1533,15 +2240,16 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [GlobalFunction]. */ + class Builder internal constructor() { - private var globalFunction: JsonField = JsonMissing.of() + private var globalFunction: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(globalFunction: GlobalFunction) = apply { this.globalFunction = globalFunction.globalFunction - additionalProperties(globalFunction.additionalProperties) + additionalProperties = globalFunction.additionalProperties.toMutableMap() } /** @@ -1555,20 +2263,17 @@ constructor( * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - @JsonProperty("global_function") - @ExcludeMissing fun globalFunction(globalFunction: JsonField) = apply { this.globalFunction = globalFunction } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1576,8 +2281,19 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): GlobalFunction = - GlobalFunction(globalFunction, additionalProperties.toImmutable()) + GlobalFunction( + checkRequired("globalFunction", globalFunction), + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -1599,52 +2315,61 @@ constructor( } /** Prompt session id */ - @JsonDeserialize(builder = PromptSessionId.Builder::class) @NoAutoDetect class PromptSessionId + @JsonCreator private constructor( - private val promptSessionId: JsonField, - private val promptSessionFunctionId: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("prompt_session_function_id") + @ExcludeMissing + private val promptSessionFunctionId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_session_id") + @ExcludeMissing + private val promptSessionId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** The ID of the prompt session */ - fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") - /** The ID of the function in the prompt session */ fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") + /** The ID of the prompt session */ + fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") + /** The version of the function */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** The ID of the prompt session */ - @JsonProperty("prompt_session_id") - @ExcludeMissing - fun _promptSessionId() = promptSessionId - /** The ID of the function in the prompt session */ @JsonProperty("prompt_session_function_id") @ExcludeMissing - fun _promptSessionFunctionId() = promptSessionFunctionId + fun _promptSessionFunctionId(): JsonField = promptSessionFunctionId + + /** The ID of the prompt session */ + @JsonProperty("prompt_session_id") + @ExcludeMissing + fun _promptSessionId(): JsonField = promptSessionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): PromptSessionId = apply { - if (!validated) { - promptSessionId() - promptSessionFunctionId() - version() - validated = true + if (validated) { + return@apply } + + promptSessionFunctionId() + promptSessionId() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1654,30 +2379,20 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PromptSessionId]. */ + class Builder internal constructor() { - private var promptSessionId: JsonField = JsonMissing.of() - private var promptSessionFunctionId: JsonField = JsonMissing.of() + private var promptSessionFunctionId: JsonField? = null + private var promptSessionId: JsonField? = null private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptSessionId: PromptSessionId) = apply { + promptSessionFunctionId = promptSessionId.promptSessionFunctionId this.promptSessionId = promptSessionId.promptSessionId - this.promptSessionFunctionId = promptSessionId.promptSessionFunctionId - this.version = promptSessionId.version - additionalProperties(promptSessionId.additionalProperties) - } - - /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: String) = - promptSessionId(JsonField.of(promptSessionId)) - - /** The ID of the prompt session */ - @JsonProperty("prompt_session_id") - @ExcludeMissing - fun promptSessionId(promptSessionId: JsonField) = apply { - this.promptSessionId = promptSessionId + version = promptSessionId.version + additionalProperties = promptSessionId.additionalProperties.toMutableMap() } /** The ID of the function in the prompt session */ @@ -1685,28 +2400,32 @@ constructor( promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) /** The ID of the function in the prompt session */ - @JsonProperty("prompt_session_function_id") - @ExcludeMissing fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { this.promptSessionFunctionId = promptSessionFunctionId } + /** The ID of the prompt session */ + fun promptSessionId(promptSessionId: String) = + promptSessionId(JsonField.of(promptSessionId)) + + /** The ID of the prompt session */ + fun promptSessionId(promptSessionId: JsonField) = apply { + this.promptSessionId = promptSessionId + } + /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1714,10 +2433,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PromptSessionId = PromptSessionId( - promptSessionId, - promptSessionFunctionId, + checkRequired("promptSessionFunctionId", promptSessionFunctionId), + checkRequired("promptSessionId", promptSessionId), version, additionalProperties.toImmutable(), ) @@ -1728,59 +2455,70 @@ constructor( return true } - return /* spotless:off */ other is PromptSessionId && promptSessionId == other.promptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(promptSessionId, promptSessionFunctionId, version, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(promptSessionFunctionId, promptSessionId, version, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PromptSessionId{promptSessionId=$promptSessionId, promptSessionFunctionId=$promptSessionFunctionId, version=$version, additionalProperties=$additionalProperties}" + "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ - @JsonDeserialize(builder = InlineCode.Builder::class) @NoAutoDetect class InlineCode + @JsonCreator private constructor( - private val inlineContext: JsonField, - private val code: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("inline_context") + @ExcludeMissing + private val inlineContext: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun inlineContext(): InlineContext = inlineContext.getRequired("inline_context") - /** The inline code to execute */ fun code(): String = code.getRequired("code") + fun inlineContext(): InlineContext = inlineContext.getRequired("inline_context") + /** The name of the inline code function */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext() = inlineContext - /** The inline code to execute */ - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + @JsonProperty("inline_context") + @ExcludeMissing + fun _inlineContext(): JsonField = inlineContext /** The name of the inline code function */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InlineCode = apply { - if (!validated) { - inlineContext().validate() - code() - name() - validated = true + if (validated) { + return@apply } + + code() + inlineContext().validate() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1790,54 +2528,51 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InlineCode]. */ + class Builder internal constructor() { - private var inlineContext: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var inlineContext: JsonField? = null private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inlineCode: InlineCode) = apply { - this.inlineContext = inlineCode.inlineContext - this.code = inlineCode.code - this.name = inlineCode.name - additionalProperties(inlineCode.additionalProperties) + code = inlineCode.code + inlineContext = inlineCode.inlineContext + name = inlineCode.name + additionalProperties = inlineCode.additionalProperties.toMutableMap() } + /** The inline code to execute */ + fun code(code: String) = code(JsonField.of(code)) + + /** The inline code to execute */ + fun code(code: JsonField) = apply { this.code = code } + fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) - @JsonProperty("inline_context") - @ExcludeMissing fun inlineContext(inlineContext: JsonField) = apply { this.inlineContext = inlineContext } - /** The inline code to execute */ - fun code(code: String) = code(JsonField.of(code)) - - /** The inline code to execute */ - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + /** The name of the inline code function */ + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name of the inline code function */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: Optional) = name(name.orElse(null)) /** The name of the inline code function */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1845,44 +2580,61 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InlineCode = InlineCode( - inlineContext, - code, + checkRequired("code", code), + checkRequired("inlineContext", inlineContext), name, additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = InlineContext.Builder::class) @NoAutoDetect class InlineContext + @JsonCreator private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InlineContext = apply { - if (!validated) { - runtime() - version() - validated = true + if (validated) { + return@apply } + + runtime() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1892,39 +2644,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InlineContext]. */ + class Builder internal constructor() { - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var runtime: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inlineContext: InlineContext) = apply { - this.runtime = inlineContext.runtime - this.version = inlineContext.version - additionalProperties(inlineContext.additionalProperties) + runtime = inlineContext.runtime + version = inlineContext.version + additionalProperties = inlineContext.additionalProperties.toMutableMap() } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - @JsonProperty("runtime") - @ExcludeMissing fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1932,10 +2680,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InlineContext = InlineContext( - runtime, - version, + checkRequired("runtime", runtime), + checkRequired("version", version), additionalProperties.toImmutable(), ) } @@ -1946,41 +2702,58 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val NODE = Runtime(JsonField.of("node")) + @JvmField val NODE = of("node") - @JvmField val PYTHON = Runtime(JsonField.of("python")) + @JvmField val PYTHON = of("python") @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) } + /** An enum containing [Runtime]'s known values. */ enum class Known { NODE, PYTHON, } + /** + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] 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 { NODE, PYTHON, + /** + * An enum member indicating that [Runtime] 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) { NODE -> Value.NODE @@ -1988,6 +2761,15 @@ constructor( 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) { NODE -> Known.NODE @@ -1996,6 +2778,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2021,31 +2815,34 @@ constructor( return true } - return /* spotless:off */ other is InlineCode && inlineContext == other.inlineContext && code == other.code && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(inlineContext, code, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, inlineContext, name, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InlineCode{inlineContext=$inlineContext, code=$code, name=$name, additionalProperties=$additionalProperties}" + "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ - @JsonDeserialize(builder = InlinePrompt.Builder::class) @NoAutoDetect class InlinePrompt + @JsonCreator private constructor( - private val inlinePrompt: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("inline_prompt") + @ExcludeMissing + private val inlinePrompt: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The prompt, model, and its parameters */ fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) @@ -2054,21 +2851,27 @@ constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The prompt, model, and its parameters */ - @JsonProperty("inline_prompt") @ExcludeMissing fun _inlinePrompt() = inlinePrompt + @JsonProperty("inline_prompt") + @ExcludeMissing + fun _inlinePrompt(): JsonField = inlinePrompt /** The name of the inline prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InlinePrompt = apply { - if (!validated) { - inlinePrompt().map { it.validate() } - name() - validated = true + if (validated) { + return@apply } + + inlinePrompt().ifPresent { it.validate() } + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -2078,46 +2881,49 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InlinePrompt]. */ + class Builder internal constructor() { - private var inlinePrompt: JsonField = JsonMissing.of() + private var inlinePrompt: JsonField? = null private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inlinePrompt: InlinePrompt) = apply { this.inlinePrompt = inlinePrompt.inlinePrompt - this.name = inlinePrompt.name - additionalProperties(inlinePrompt.additionalProperties) + name = inlinePrompt.name + additionalProperties = inlinePrompt.additionalProperties.toMutableMap() } /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: PromptData) = - inlinePrompt(JsonField.of(inlinePrompt)) + fun inlinePrompt(inlinePrompt: PromptData?) = + inlinePrompt(JsonField.ofNullable(inlinePrompt)) + + /** The prompt, model, and its parameters */ + fun inlinePrompt(inlinePrompt: Optional) = + inlinePrompt(inlinePrompt.orElse(null)) /** The prompt, model, and its parameters */ - @JsonProperty("inline_prompt") - @ExcludeMissing fun inlinePrompt(inlinePrompt: JsonField) = apply { this.inlinePrompt = inlinePrompt } /** The name of the inline prompt */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The name of the inline prompt */ + fun name(name: Optional) = name(name.orElse(null)) /** The name of the inline prompt */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2125,9 +2931,17 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InlinePrompt = InlinePrompt( - inlinePrompt, + checkRequired("inlinePrompt", inlinePrompt), name, additionalProperties.toImmutable(), ) @@ -2152,6 +2966,7 @@ constructor( } } + /** The function to evaluate */ @JsonDeserialize(using = Task.Deserializer::class) @JsonSerialize(using = Task.Serializer::class) class Task @@ -2165,18 +2980,21 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** Function id */ fun functionId(): Optional = Optional.ofNullable(functionId) + /** Project name and slug */ fun projectSlug(): Optional = Optional.ofNullable(projectSlug) + /** Global function name */ fun globalFunction(): Optional = Optional.ofNullable(globalFunction) + /** Prompt session id */ fun promptSessionId(): Optional = Optional.ofNullable(promptSessionId) + /** Inline code function */ fun inlineCode(): Optional = Optional.ofNullable(inlineCode) + /** Inline prompt definition */ fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt) @@ -2192,16 +3010,22 @@ constructor( fun isInlinePrompt(): Boolean = inlinePrompt != null + /** Function id */ fun asFunctionId(): FunctionId = functionId.getOrThrow("functionId") + /** Project name and slug */ fun asProjectSlug(): ProjectSlug = projectSlug.getOrThrow("projectSlug") + /** Global function name */ fun asGlobalFunction(): GlobalFunction = globalFunction.getOrThrow("globalFunction") + /** Prompt session id */ fun asPromptSessionId(): PromptSessionId = promptSessionId.getOrThrow("promptSessionId") + /** Inline code function */ fun asInlineCode(): InlineCode = inlineCode.getOrThrow("inlineCode") + /** Inline prompt definition */ fun asInlinePrompt(): InlinePrompt = inlinePrompt.getOrThrow("inlinePrompt") fun _json(): Optional = Optional.ofNullable(_json) @@ -2218,26 +3042,41 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Task = apply { - if (!validated) { - if ( - functionId == null && - projectSlug == null && - globalFunction == null && - promptSessionId == null && - inlineCode == null && - inlinePrompt == null - ) { - throw BraintrustInvalidDataException("Unknown Task: $_json") - } - functionId?.validate() - projectSlug?.validate() - globalFunction?.validate() - promptSessionId?.validate() - inlineCode?.validate() - inlinePrompt?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitFunctionId(functionId: FunctionId) { + functionId.validate() + } + + override fun visitProjectSlug(projectSlug: ProjectSlug) { + projectSlug.validate() + } + + override fun visitGlobalFunction(globalFunction: GlobalFunction) { + globalFunction.validate() + } + + override fun visitPromptSessionId(promptSessionId: PromptSessionId) { + promptSessionId.validate() + } + + override fun visitInlineCode(inlineCode: InlineCode) { + inlineCode.validate() + } + + override fun visitInlinePrompt(inlinePrompt: InlinePrompt) { + inlinePrompt.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -2264,44 +3103,66 @@ constructor( companion object { + /** Function id */ @JvmStatic fun ofFunctionId(functionId: FunctionId) = Task(functionId = functionId) + /** Project name and slug */ @JvmStatic fun ofProjectSlug(projectSlug: ProjectSlug) = Task(projectSlug = projectSlug) + /** Global function name */ @JvmStatic fun ofGlobalFunction(globalFunction: GlobalFunction) = Task(globalFunction = globalFunction) + /** Prompt session id */ @JvmStatic fun ofPromptSessionId(promptSessionId: PromptSessionId) = Task(promptSessionId = promptSessionId) + /** Inline code function */ @JvmStatic fun ofInlineCode(inlineCode: InlineCode) = Task(inlineCode = inlineCode) + /** Inline prompt definition */ @JvmStatic fun ofInlinePrompt(inlinePrompt: InlinePrompt) = Task(inlinePrompt = inlinePrompt) } + /** An interface that defines how to map each variant of [Task] to a value of type [T]. */ interface Visitor { + /** Function id */ fun visitFunctionId(functionId: FunctionId): T + /** Project name and slug */ fun visitProjectSlug(projectSlug: ProjectSlug): T + /** Global function name */ fun visitGlobalFunction(globalFunction: GlobalFunction): T + /** Prompt session id */ fun visitPromptSessionId(promptSessionId: PromptSessionId): T + /** Inline code function */ fun visitInlineCode(inlineCode: InlineCode): T + /** Inline prompt definition */ fun visitInlinePrompt(inlinePrompt: InlinePrompt): T + /** + * Maps an unknown variant of [Task] to a value of type [T]. + * + * An instance of [Task] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Task: $json") } } - class Deserializer : BaseDeserializer(Task::class) { + internal class Deserializer : BaseDeserializer(Task::class) { override fun ObjectCodec.deserialize(node: JsonNode): Task { val json = JsonValue.fromJsonNode(node) @@ -2335,7 +3196,7 @@ constructor( } } - class Serializer : BaseSerializer(Task::class) { + internal class Serializer : BaseSerializer(Task::class) { override fun serialize( value: Task, @@ -2356,17 +3217,20 @@ constructor( } /** Function id */ - @JsonDeserialize(builder = FunctionId.Builder::class) @NoAutoDetect class FunctionId + @JsonCreator private constructor( - private val functionId: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("function_id") + @ExcludeMissing + private val functionId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The ID of the function */ fun functionId(): String = functionId.getRequired("function_id") @@ -2374,21 +3238,27 @@ constructor( fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** The ID of the function */ - @JsonProperty("function_id") @ExcludeMissing fun _functionId() = functionId + @JsonProperty("function_id") + @ExcludeMissing + fun _functionId(): JsonField = functionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FunctionId = apply { - if (!validated) { - functionId() - version() - validated = true + if (validated) { + return@apply } + + functionId() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -2398,25 +3268,24 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionId]. */ + class Builder internal constructor() { - private var functionId: JsonField = JsonMissing.of() + private var functionId: JsonField? = null private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionId: FunctionId) = apply { this.functionId = functionId.functionId - this.version = functionId.version - additionalProperties(functionId.additionalProperties) + version = functionId.version + additionalProperties = functionId.additionalProperties.toMutableMap() } /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) /** The ID of the function */ - @JsonProperty("function_id") - @ExcludeMissing fun functionId(functionId: JsonField) = apply { this.functionId = functionId } @@ -2425,18 +3294,15 @@ constructor( fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2444,9 +3310,17 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionId = FunctionId( - functionId, + checkRequired("functionId", functionId), version, additionalProperties.toImmutable(), ) @@ -2471,18 +3345,23 @@ constructor( } /** Project name and slug */ - @JsonDeserialize(builder = ProjectSlug.Builder::class) @NoAutoDetect class ProjectSlug + @JsonCreator private constructor( - private val projectName: JsonField, - private val slug: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The name of the project containing the function */ fun projectName(): String = projectName.getRequired("project_name") @@ -2493,25 +3372,31 @@ constructor( fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** The name of the project containing the function */ - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName(): JsonField = projectName /** The slug of the function */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectSlug = apply { - if (!validated) { - projectName() - slug() - version() - validated = true + if (validated) { + return@apply } + + projectName() + slug() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -2521,27 +3406,26 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectSlug]. */ + class Builder internal constructor() { - private var projectName: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() + private var projectName: JsonField? = null + private var slug: JsonField? = null private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectSlug: ProjectSlug) = apply { - this.projectName = projectSlug.projectName - this.slug = projectSlug.slug - this.version = projectSlug.version - additionalProperties(projectSlug.additionalProperties) + projectName = projectSlug.projectName + slug = projectSlug.slug + version = projectSlug.version + additionalProperties = projectSlug.additionalProperties.toMutableMap() } /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** The name of the project containing the function */ - @JsonProperty("project_name") - @ExcludeMissing fun projectName(projectName: JsonField) = apply { this.projectName = projectName } @@ -2550,26 +3434,21 @@ constructor( fun slug(slug: String) = slug(JsonField.of(slug)) /** The slug of the function */ - @JsonProperty("slug") - @ExcludeMissing fun slug(slug: JsonField) = apply { this.slug = slug } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2577,10 +3456,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectSlug = ProjectSlug( - projectName, - slug, + checkRequired("projectName", projectName), + checkRequired("slug", slug), version, additionalProperties.toImmutable(), ) @@ -2605,16 +3492,17 @@ constructor( } /** Global function name */ - @JsonDeserialize(builder = GlobalFunction.Builder::class) @NoAutoDetect class GlobalFunction + @JsonCreator private constructor( - private val globalFunction: JsonField, - private val additionalProperties: Map, + @JsonProperty("global_function") + @ExcludeMissing + private val globalFunction: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals @@ -2625,17 +3513,23 @@ constructor( * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - @JsonProperty("global_function") @ExcludeMissing fun _globalFunction() = globalFunction + @JsonProperty("global_function") + @ExcludeMissing + fun _globalFunction(): JsonField = globalFunction @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): GlobalFunction = apply { - if (!validated) { - globalFunction() - validated = true + if (validated) { + return@apply } + + globalFunction() + validated = true } fun toBuilder() = Builder().from(this) @@ -2645,15 +3539,16 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [GlobalFunction]. */ + class Builder internal constructor() { - private var globalFunction: JsonField = JsonMissing.of() + private var globalFunction: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(globalFunction: GlobalFunction) = apply { this.globalFunction = globalFunction.globalFunction - additionalProperties(globalFunction.additionalProperties) + additionalProperties = globalFunction.additionalProperties.toMutableMap() } /** @@ -2667,20 +3562,17 @@ constructor( * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - @JsonProperty("global_function") - @ExcludeMissing fun globalFunction(globalFunction: JsonField) = apply { this.globalFunction = globalFunction } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2688,8 +3580,19 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): GlobalFunction = - GlobalFunction(globalFunction, additionalProperties.toImmutable()) + GlobalFunction( + checkRequired("globalFunction", globalFunction), + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -2711,52 +3614,61 @@ constructor( } /** Prompt session id */ - @JsonDeserialize(builder = PromptSessionId.Builder::class) @NoAutoDetect class PromptSessionId + @JsonCreator private constructor( - private val promptSessionId: JsonField, - private val promptSessionFunctionId: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("prompt_session_function_id") + @ExcludeMissing + private val promptSessionFunctionId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_session_id") + @ExcludeMissing + private val promptSessionId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** The ID of the prompt session */ - fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") - /** The ID of the function in the prompt session */ fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") + /** The ID of the prompt session */ + fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") + /** The version of the function */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** The ID of the prompt session */ - @JsonProperty("prompt_session_id") - @ExcludeMissing - fun _promptSessionId() = promptSessionId - /** The ID of the function in the prompt session */ @JsonProperty("prompt_session_function_id") @ExcludeMissing - fun _promptSessionFunctionId() = promptSessionFunctionId + fun _promptSessionFunctionId(): JsonField = promptSessionFunctionId + + /** The ID of the prompt session */ + @JsonProperty("prompt_session_id") + @ExcludeMissing + fun _promptSessionId(): JsonField = promptSessionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): PromptSessionId = apply { - if (!validated) { - promptSessionId() - promptSessionFunctionId() - version() - validated = true + if (validated) { + return@apply } + + promptSessionFunctionId() + promptSessionId() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -2766,30 +3678,20 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PromptSessionId]. */ + class Builder internal constructor() { - private var promptSessionId: JsonField = JsonMissing.of() - private var promptSessionFunctionId: JsonField = JsonMissing.of() + private var promptSessionFunctionId: JsonField? = null + private var promptSessionId: JsonField? = null private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptSessionId: PromptSessionId) = apply { + promptSessionFunctionId = promptSessionId.promptSessionFunctionId this.promptSessionId = promptSessionId.promptSessionId - this.promptSessionFunctionId = promptSessionId.promptSessionFunctionId - this.version = promptSessionId.version - additionalProperties(promptSessionId.additionalProperties) - } - - /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: String) = - promptSessionId(JsonField.of(promptSessionId)) - - /** The ID of the prompt session */ - @JsonProperty("prompt_session_id") - @ExcludeMissing - fun promptSessionId(promptSessionId: JsonField) = apply { - this.promptSessionId = promptSessionId + version = promptSessionId.version + additionalProperties = promptSessionId.additionalProperties.toMutableMap() } /** The ID of the function in the prompt session */ @@ -2797,28 +3699,32 @@ constructor( promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) /** The ID of the function in the prompt session */ - @JsonProperty("prompt_session_function_id") - @ExcludeMissing fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { this.promptSessionFunctionId = promptSessionFunctionId } + /** The ID of the prompt session */ + fun promptSessionId(promptSessionId: String) = + promptSessionId(JsonField.of(promptSessionId)) + + /** The ID of the prompt session */ + fun promptSessionId(promptSessionId: JsonField) = apply { + this.promptSessionId = promptSessionId + } + /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2826,10 +3732,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PromptSessionId = PromptSessionId( - promptSessionId, - promptSessionFunctionId, + checkRequired("promptSessionFunctionId", promptSessionFunctionId), + checkRequired("promptSessionId", promptSessionId), version, additionalProperties.toImmutable(), ) @@ -2840,59 +3754,70 @@ constructor( return true } - return /* spotless:off */ other is PromptSessionId && promptSessionId == other.promptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(promptSessionId, promptSessionFunctionId, version, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(promptSessionFunctionId, promptSessionId, version, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PromptSessionId{promptSessionId=$promptSessionId, promptSessionFunctionId=$promptSessionFunctionId, version=$version, additionalProperties=$additionalProperties}" + "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ - @JsonDeserialize(builder = InlineCode.Builder::class) @NoAutoDetect class InlineCode + @JsonCreator private constructor( - private val inlineContext: JsonField, - private val code: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("inline_context") + @ExcludeMissing + private val inlineContext: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun inlineContext(): InlineContext = inlineContext.getRequired("inline_context") - /** The inline code to execute */ fun code(): String = code.getRequired("code") + fun inlineContext(): InlineContext = inlineContext.getRequired("inline_context") + /** The name of the inline code function */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext() = inlineContext - /** The inline code to execute */ - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + @JsonProperty("inline_context") + @ExcludeMissing + fun _inlineContext(): JsonField = inlineContext /** The name of the inline code function */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InlineCode = apply { - if (!validated) { - inlineContext().validate() - code() - name() - validated = true + if (validated) { + return@apply } + + code() + inlineContext().validate() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -2902,54 +3827,51 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InlineCode]. */ + class Builder internal constructor() { - private var inlineContext: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var inlineContext: JsonField? = null private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inlineCode: InlineCode) = apply { - this.inlineContext = inlineCode.inlineContext - this.code = inlineCode.code - this.name = inlineCode.name - additionalProperties(inlineCode.additionalProperties) + code = inlineCode.code + inlineContext = inlineCode.inlineContext + name = inlineCode.name + additionalProperties = inlineCode.additionalProperties.toMutableMap() } + /** The inline code to execute */ + fun code(code: String) = code(JsonField.of(code)) + + /** The inline code to execute */ + fun code(code: JsonField) = apply { this.code = code } + fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) - @JsonProperty("inline_context") - @ExcludeMissing fun inlineContext(inlineContext: JsonField) = apply { this.inlineContext = inlineContext } - /** The inline code to execute */ - fun code(code: String) = code(JsonField.of(code)) - - /** The inline code to execute */ - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + /** The name of the inline code function */ + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name of the inline code function */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: Optional) = name(name.orElse(null)) /** The name of the inline code function */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2957,44 +3879,61 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InlineCode = InlineCode( - inlineContext, - code, + checkRequired("code", code), + checkRequired("inlineContext", inlineContext), name, additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = InlineContext.Builder::class) @NoAutoDetect class InlineContext + @JsonCreator private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InlineContext = apply { - if (!validated) { - runtime() - version() - validated = true + if (validated) { + return@apply } + + runtime() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -3004,39 +3943,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InlineContext]. */ + class Builder internal constructor() { - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var runtime: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inlineContext: InlineContext) = apply { - this.runtime = inlineContext.runtime - this.version = inlineContext.version - additionalProperties(inlineContext.additionalProperties) + runtime = inlineContext.runtime + version = inlineContext.version + additionalProperties = inlineContext.additionalProperties.toMutableMap() } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - @JsonProperty("runtime") - @ExcludeMissing fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -3044,10 +3979,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InlineContext = InlineContext( - runtime, - version, + checkRequired("runtime", runtime), + checkRequired("version", version), additionalProperties.toImmutable(), ) } @@ -3058,41 +4001,58 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val NODE = Runtime(JsonField.of("node")) + @JvmField val NODE = of("node") - @JvmField val PYTHON = Runtime(JsonField.of("python")) + @JvmField val PYTHON = of("python") @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) } + /** An enum containing [Runtime]'s known values. */ enum class Known { NODE, PYTHON, } + /** + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] 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 { NODE, PYTHON, + /** + * An enum member indicating that [Runtime] 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) { NODE -> Value.NODE @@ -3100,6 +4060,15 @@ constructor( 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) { NODE -> Known.NODE @@ -3108,6 +4077,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -3133,31 +4114,34 @@ constructor( return true } - return /* spotless:off */ other is InlineCode && inlineContext == other.inlineContext && code == other.code && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(inlineContext, code, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, inlineContext, name, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InlineCode{inlineContext=$inlineContext, code=$code, name=$name, additionalProperties=$additionalProperties}" + "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ - @JsonDeserialize(builder = InlinePrompt.Builder::class) @NoAutoDetect class InlinePrompt + @JsonCreator private constructor( - private val inlinePrompt: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("inline_prompt") + @ExcludeMissing + private val inlinePrompt: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The prompt, model, and its parameters */ fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) @@ -3166,21 +4150,27 @@ constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The prompt, model, and its parameters */ - @JsonProperty("inline_prompt") @ExcludeMissing fun _inlinePrompt() = inlinePrompt + @JsonProperty("inline_prompt") + @ExcludeMissing + fun _inlinePrompt(): JsonField = inlinePrompt /** The name of the inline prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InlinePrompt = apply { - if (!validated) { - inlinePrompt().map { it.validate() } - name() - validated = true + if (validated) { + return@apply } + + inlinePrompt().ifPresent { it.validate() } + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -3190,46 +4180,49 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InlinePrompt]. */ + class Builder internal constructor() { - private var inlinePrompt: JsonField = JsonMissing.of() + private var inlinePrompt: JsonField? = null private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inlinePrompt: InlinePrompt) = apply { this.inlinePrompt = inlinePrompt.inlinePrompt - this.name = inlinePrompt.name - additionalProperties(inlinePrompt.additionalProperties) + name = inlinePrompt.name + additionalProperties = inlinePrompt.additionalProperties.toMutableMap() } /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: PromptData) = - inlinePrompt(JsonField.of(inlinePrompt)) + fun inlinePrompt(inlinePrompt: PromptData?) = + inlinePrompt(JsonField.ofNullable(inlinePrompt)) + + /** The prompt, model, and its parameters */ + fun inlinePrompt(inlinePrompt: Optional) = + inlinePrompt(inlinePrompt.orElse(null)) /** The prompt, model, and its parameters */ - @JsonProperty("inline_prompt") - @ExcludeMissing fun inlinePrompt(inlinePrompt: JsonField) = apply { this.inlinePrompt = inlinePrompt } /** The name of the inline prompt */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The name of the inline prompt */ + fun name(name: Optional) = name(name.orElse(null)) /** The name of the inline prompt */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -3237,9 +4230,17 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InlinePrompt = InlinePrompt( - inlinePrompt, + checkRequired("inlinePrompt", inlinePrompt), name, additionalProperties.toImmutable(), ) @@ -3268,23 +4269,44 @@ constructor( * Optional settings for collecting git metadata. By default, will collect all git metadata * fields allowed in org-level settings. */ - @JsonDeserialize(builder = GitMetadataSettings.Builder::class) @NoAutoDetect class GitMetadataSettings + @JsonCreator private constructor( - private val collect: Collect?, - private val fields: List?, - private val additionalProperties: Map, + @JsonProperty("collect") + @ExcludeMissing + private val collect: JsonField = JsonMissing.of(), + @JsonProperty("fields") + @ExcludeMissing + private val fields: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("collect") fun collect(): Collect? = collect + fun collect(): Collect = collect.getRequired("collect") + + fun fields(): Optional> = Optional.ofNullable(fields.getNullable("fields")) + + @JsonProperty("collect") @ExcludeMissing fun _collect(): JsonField = collect - @JsonProperty("fields") fun fields(): List? = fields + @JsonProperty("fields") @ExcludeMissing fun _fields(): JsonField> = fields @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GitMetadataSettings = apply { + if (validated) { + return@apply + } + + collect() + fields() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3292,42 +4314,66 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [GitMetadataSettings]. */ + class Builder internal constructor() { - private var collect: Collect? = null - private var fields: List? = null + private var collect: JsonField? = null + private var fields: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(gitMetadataSettings: GitMetadataSettings) = apply { - this.collect = gitMetadataSettings.collect - this.fields = gitMetadataSettings.fields - additionalProperties(gitMetadataSettings.additionalProperties) + collect = gitMetadataSettings.collect + fields = gitMetadataSettings.fields.map { it.toMutableList() } + additionalProperties = gitMetadataSettings.additionalProperties.toMutableMap() } - @JsonProperty("collect") - fun collect(collect: Collect) = apply { this.collect = collect } + fun collect(collect: Collect) = collect(JsonField.of(collect)) + + fun collect(collect: JsonField) = apply { this.collect = collect } + + fun fields(fields: List) = fields(JsonField.of(fields)) - @JsonProperty("fields") fun fields(fields: List) = apply { this.fields = fields } + fun fields(fields: JsonField>) = apply { + this.fields = fields.map { it.toMutableList() } + } + + fun addField(field: Field) = apply { + fields = + (fields ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(field) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): GitMetadataSettings = GitMetadataSettings( - checkNotNull(collect) { "`collect` is required but was not set" }, - fields?.toImmutable(), + checkRequired("collect", collect), + (fields ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -3338,44 +4384,60 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val ALL = Collect(JsonField.of("all")) + @JvmField val ALL = of("all") - @JvmField val NONE = Collect(JsonField.of("none")) + @JvmField val NONE = of("none") - @JvmField val SOME = Collect(JsonField.of("some")) + @JvmField val SOME = of("some") @JvmStatic fun of(value: String) = Collect(JsonField.of(value)) } + /** An enum containing [Collect]'s known values. */ enum class Known { ALL, NONE, SOME, } + /** + * An enum containing [Collect]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Collect] 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 { ALL, NONE, SOME, + /** + * An enum member indicating that [Collect] 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) { ALL -> Value.ALL @@ -3384,6 +4446,15 @@ constructor( 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) { ALL -> Known.ALL @@ -3393,51 +4464,60 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class Field - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Field && value == other.value /* spotless:on */ + return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() override fun toString() = value.toString() + } + + class Field + @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 COMMIT = Field(JsonField.of("commit")) + @JvmField val COMMIT = of("commit") - @JvmField val BRANCH = Field(JsonField.of("branch")) + @JvmField val BRANCH = of("branch") - @JvmField val TAG = Field(JsonField.of("tag")) + @JvmField val TAG = of("tag") - @JvmField val DIRTY = Field(JsonField.of("dirty")) + @JvmField val DIRTY = of("dirty") - @JvmField val AUTHOR_NAME = Field(JsonField.of("author_name")) + @JvmField val AUTHOR_NAME = of("author_name") - @JvmField val AUTHOR_EMAIL = Field(JsonField.of("author_email")) + @JvmField val AUTHOR_EMAIL = of("author_email") - @JvmField val COMMIT_MESSAGE = Field(JsonField.of("commit_message")) + @JvmField val COMMIT_MESSAGE = of("commit_message") - @JvmField val COMMIT_TIME = Field(JsonField.of("commit_time")) + @JvmField val COMMIT_TIME = of("commit_time") - @JvmField val GIT_DIFF = Field(JsonField.of("git_diff")) + @JvmField val GIT_DIFF = of("git_diff") @JvmStatic fun of(value: String) = Field(JsonField.of(value)) } + /** An enum containing [Field]'s known values. */ enum class Known { COMMIT, BRANCH, @@ -3450,6 +4530,15 @@ constructor( GIT_DIFF, } + /** + * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Field] 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 { COMMIT, BRANCH, @@ -3460,9 +4549,19 @@ constructor( COMMIT_MESSAGE, COMMIT_TIME, GIT_DIFF, + /** + * An enum member indicating that [Field] 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) { COMMIT -> Value.COMMIT @@ -3477,6 +4576,15 @@ constructor( 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) { COMMIT -> Known.COMMIT @@ -3492,6 +4600,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Field && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -3516,17 +4636,28 @@ constructor( * Optional experiment-level metadata to store about the evaluation. You can later use this to * slice & dice across experiments. */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3534,29 +4665,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -3582,11 +4719,11 @@ constructor( return true } - return /* spotless:off */ other is EvalCreateParams && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EvalCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "EvalCreateParams{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "EvalCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 5d342b8f..964fcd1f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -7,66 +7,85 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = Experiment.Builder::class) @NoAutoDetect class Experiment +@JsonCreator private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val created: JsonField, - private val repoInfo: JsonField, - private val commit: JsonField, - private val baseExpId: JsonField, - private val deletedAt: JsonField, - private val datasetId: JsonField, - private val datasetVersion: JsonField, - private val public_: JsonField, - private val userId: JsonField, - private val metadata: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("public") + @ExcludeMissing + private val public_: JsonField = JsonMissing.of(), + @JsonProperty("base_exp_id") + @ExcludeMissing + private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("commit") + @ExcludeMissing + private val commit: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") + @ExcludeMissing + private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") + @ExcludeMissing + private val repoInfo: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the experiment */ fun id(): String = id.getRequired("id") - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - /** Name of the experiment. Within a project, experiment names are unique */ fun name(): String = name.getRequired("name") - /** Textual description of the experiment */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(): String = projectId.getRequired("project_id") - /** Date of experiment creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + fun public_(): Boolean = public_.getRequired("public") - /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** Commit, taken directly from `repo_info.commit` */ fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) - /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) - - /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + /** Date of experiment creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) @@ -78,88 +97,101 @@ private constructor( fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization - */ - fun public_(): Boolean = public_.getRequired("public") + /** Date of experiment deletion, or null if the experiment is still active */ + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Identifies the user who created the experiment */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** Textual description of the experiment */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Unique identifier for the experiment */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + /** Identifies the user who created the experiment */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** Unique identifier for the experiment */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Textual description of the experiment */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + /** Unique identifier for the project that the experiment belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Date of experiment creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ - /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo() = repoInfo + /** Id of default base experiment to compare against when viewing this experiment */ + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId /** Commit, taken directly from `repo_info.commit` */ - @JsonProperty("commit") @ExcludeMissing fun _commit() = commit + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit - /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId() = baseExpId - - /** Date of experiment deletion, or null if the experiment is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + /** Date of experiment creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion() = datasetVersion + @JsonProperty("dataset_version") + @ExcludeMissing + fun _datasetVersion(): JsonField = datasetVersion - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization - */ - @JsonProperty("public") @ExcludeMissing fun _public_() = public_ + /** Date of experiment deletion, or null if the experiment is still active */ + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt - /** Identifies the user who created the experiment */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + /** Textual description of the experiment */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** Metadata about the state of the repo when the experiment was created */ + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + + /** Identifies the user who created the experiment */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Experiment = apply { - if (!validated) { - id() - projectId() - name() - description() - created() - repoInfo().map { it.validate() } - commit() - baseExpId() - deletedAt() - datasetId() - datasetVersion() - public_() - userId() - metadata().map { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + name() + projectId() + public_() + baseExpId() + commit() + created() + datasetId() + datasetVersion() + deletedAt() + description() + metadata().ifPresent { it.validate() } + repoInfo().ifPresent { it.validate() } + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -169,223 +201,243 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Experiment]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var repoInfo: JsonField = JsonMissing.of() - private var commit: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var public_: JsonField? = null private var baseExpId: JsonField = JsonMissing.of() - private var deletedAt: JsonField = JsonMissing.of() + private var commit: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() private var datasetId: JsonField = JsonMissing.of() private var datasetVersion: JsonField = JsonMissing.of() - private var public_: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() + private var deletedAt: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var repoInfo: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experiment: Experiment) = apply { - this.id = experiment.id - this.projectId = experiment.projectId - this.name = experiment.name - this.description = experiment.description - this.created = experiment.created - this.repoInfo = experiment.repoInfo - this.commit = experiment.commit - this.baseExpId = experiment.baseExpId - this.deletedAt = experiment.deletedAt - this.datasetId = experiment.datasetId - this.datasetVersion = experiment.datasetVersion - this.public_ = experiment.public_ - this.userId = experiment.userId - this.metadata = experiment.metadata - additionalProperties(experiment.additionalProperties) + id = experiment.id + name = experiment.name + projectId = experiment.projectId + public_ = experiment.public_ + baseExpId = experiment.baseExpId + commit = experiment.commit + created = experiment.created + datasetId = experiment.datasetId + datasetVersion = experiment.datasetVersion + deletedAt = experiment.deletedAt + description = experiment.description + metadata = experiment.metadata + repoInfo = experiment.repoInfo + userId = experiment.userId + additionalProperties = experiment.additionalProperties.toMutableMap() } /** Unique identifier for the experiment */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the experiment */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun id(id: JsonField) = apply { this.id = id } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } - /** Textual description of the experiment */ - fun description(description: String) = description(JsonField.of(description)) + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Textual description of the experiment */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - /** Date of experiment creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean) = public_(JsonField.of(public_)) - /** Date of experiment creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: JsonField) = apply { this.public_ = public_ } - /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = repoInfo(JsonField.of(repoInfo)) + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) - /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - @ExcludeMissing - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } /** Commit, taken directly from `repo_info.commit` */ - fun commit(commit: String) = commit(JsonField.of(commit)) + fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) + + /** Commit, taken directly from `repo_info.commit` */ + fun commit(commit: Optional) = commit(commit.orElse(null)) /** Commit, taken directly from `repo_info.commit` */ - @JsonProperty("commit") - @ExcludeMissing fun commit(commit: JsonField) = apply { this.commit = commit } - /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = baseExpId(JsonField.of(baseExpId)) + /** Date of experiment creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - @ExcludeMissing - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + /** Date of experiment creation */ + fun created(created: Optional) = created(created.orElse(null)) - /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + /** Date of experiment creation */ + fun created(created: JsonField) = apply { this.created = created } - /** Date of experiment deletion, or null if the experiment is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") - @ExcludeMissing fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String) = datasetVersion(JsonField.of(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = + datasetVersion(JsonField.ofNullable(datasetVersion)) + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.orElse(null)) /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") - @ExcludeMissing fun datasetVersion(datasetVersion: JsonField) = apply { this.datasetVersion = datasetVersion } - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - fun public_(public_: Boolean) = public_(JsonField.of(public_)) + /** Date of experiment deletion, or null if the experiment is still active */ + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - @JsonProperty("public") - @ExcludeMissing - fun public_(public_: JsonField) = apply { this.public_ = public_ } + /** Date of experiment deletion, or null if the experiment is still active */ + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) - /** Identifies the user who created the experiment */ - fun userId(userId: String) = userId(JsonField.of(userId)) + /** Date of experiment deletion, or null if the experiment is still active */ + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } - /** Identifies the user who created the experiment */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + /** Textual description of the experiment */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the experiment */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the experiment */ + fun description(description: JsonField) = apply { this.description = description } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + + /** Identifies the user who created the experiment */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Identifies the user who created the experiment */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Identifies the user who created the experiment */ + fun userId(userId: JsonField) = apply { this.userId = userId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Experiment = Experiment( - id, - projectId, - name, - description, - created, - repoInfo, - commit, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("public_", public_), baseExpId, - deletedAt, + commit, + created, datasetId, datasetVersion, - public_, - userId, + deletedAt, + description, metadata, + repoInfo, + userId, additionalProperties.toImmutable(), ) } /** User-controlled metadata about the experiment */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -395,29 +447,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -443,15 +501,15 @@ private constructor( return true } - return /* spotless:off */ other is Experiment && id == other.id && projectId == other.projectId && name == other.name && description == other.description && created == other.created && repoInfo == other.repoInfo && commit == other.commit && baseExpId == other.baseExpId && deletedAt == other.deletedAt && datasetId == other.datasetId && datasetVersion == other.datasetVersion && public_ == other.public_ && userId == other.userId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && id == other.id && name == other.name && projectId == other.projectId && public_ == other.public_ && baseExpId == other.baseExpId && commit == other.commit && created == other.created && datasetId == other.datasetId && datasetVersion == other.datasetVersion && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && repoInfo == other.repoInfo && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, name, description, created, repoInfo, commit, baseExpId, deletedAt, datasetId, datasetVersion, public_, userId, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, projectId, public_, baseExpId, commit, created, datasetId, datasetVersion, deletedAt, description, metadata, repoInfo, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Experiment{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, repoInfo=$repoInfo, commit=$commit, baseExpId=$baseExpId, deletedAt=$deletedAt, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" + "Experiment{id=$id, name=$name, projectId=$projectId, public_=$public_, baseExpId=$baseExpId, commit=$commit, created=$created, datasetId=$datasetId, datasetVersion=$datasetVersion, deletedAt=$deletedAt, description=$description, metadata=$metadata, repoInfo=$repoInfo, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index b8273443..7dad203e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -3,146 +3,280 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new experiment. If there is an existing experiment in the project with the same name as + * the one specified in the request, will return the existing experiment unmodified + */ class ExperimentCreateParams -constructor( - private val projectId: String, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val ensureNew: Boolean?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, +private constructor( + private val body: ExperimentCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun projectId(): String = projectId + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(): String = body.projectId() - fun baseExpId(): Optional = Optional.ofNullable(baseExpId) + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(): Optional = body.baseExpId() - fun datasetId(): Optional = Optional.ofNullable(datasetId) + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + fun datasetId(): Optional = body.datasetId() - fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion) + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(): Optional = body.datasetVersion() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the experiment */ + fun description(): Optional = body.description() - fun ensureNew(): Optional = Optional.ofNullable(ensureNew) + /** + * Normally, creating an experiment with the same name as an existing experiment will return the + * existing one un-modified. But if `ensure_new` is true, registration will generate a new + * experiment with a unique name in case of a conflict. + */ + fun ensureNew(): Optional = body.ensureNew() - fun metadata(): Optional = Optional.ofNullable(metadata) + /** User-controlled metadata about the experiment */ + fun metadata(): Optional = body.metadata() + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(): Optional = body.name() + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + fun public_(): Optional = body.public_() + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(): Optional = body.repoInfo() + + /** Unique identifier for the project that the experiment belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** Id of default base experiment to compare against when viewing this experiment */ + fun _baseExpId(): JsonField = body._baseExpId() + + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + fun _datasetId(): JsonField = body._datasetId() + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun _datasetVersion(): JsonField = body._datasetVersion() - fun name(): Optional = Optional.ofNullable(name) + /** Textual description of the experiment */ + fun _description(): JsonField = body._description() - fun public_(): Optional = Optional.ofNullable(public_) + /** + * Normally, creating an experiment with the same name as an existing experiment will return the + * existing one un-modified. But if `ensure_new` is true, registration will generate a new + * experiment with a unique name in case of a conflict. + */ + fun _ensureNew(): JsonField = body._ensureNew() - fun repoInfo(): Optional = Optional.ofNullable(repoInfo) + /** User-controlled metadata about the experiment */ + fun _metadata(): JsonField = body._metadata() + + /** Name of the experiment. Within a project, experiment names are unique */ + fun _name(): JsonField = body._name() + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + fun _public_(): JsonField = body._public_() + + /** Metadata about the state of the repo when the experiment was created */ + fun _repoInfo(): JsonField = body._repoInfo() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ExperimentCreateBody { - return ExperimentCreateBody( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ExperimentCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = ExperimentCreateBody.Builder::class) @NoAutoDetect class ExperimentCreateBody + @JsonCreator internal constructor( - private val projectId: String?, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val ensureNew: Boolean?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalProperties: Map, + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("base_exp_id") + @ExcludeMissing + private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") + @ExcludeMissing + private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("ensure_new") + @ExcludeMissing + private val ensureNew: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("public") + @ExcludeMissing + private val public_: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") + @ExcludeMissing + private val repoInfo: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + fun projectId(): String = projectId.getRequired("project_id") + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(): Optional = + Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(): Optional = + Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + + /** Textual description of the experiment */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. + */ + fun ensureNew(): Optional = + Optional.ofNullable(ensureNew.getNullable("ensure_new")) + + /** User-controlled metadata about the experiment */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) + + /** Unique identifier for the project that the experiment belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") fun baseExpId(): String? = baseExpId + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") fun datasetId(): String? = datasetId + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") fun datasetVersion(): String? = datasetVersion + @JsonProperty("dataset_version") + @ExcludeMissing + fun _datasetVersion(): JsonField = datasetVersion /** Textual description of the experiment */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** * Normally, creating an experiment with the same name as an existing experiment will return * the existing one un-modified. But if `ensure_new` is true, registration will generate a * new experiment with a unique name in case of a conflict. */ - @JsonProperty("ensure_new") fun ensureNew(): Boolean? = ensureNew + @JsonProperty("ensure_new") @ExcludeMissing fun _ensureNew(): JsonField = ensureNew /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - @JsonProperty("public") fun public_(): Boolean? = public_ + @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExperimentCreateBody = apply { + if (validated) { + return@apply + } + + projectId() + baseExpId() + datasetId() + datasetVersion() + description() + ensureNew() + metadata().ifPresent { it.validate() } + name() + public_() + repoInfo().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -150,105 +284,206 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ExperimentCreateBody]. */ + class Builder internal constructor() { - private var projectId: String? = null - private var baseExpId: String? = null - private var datasetId: String? = null - private var datasetVersion: String? = null - private var description: String? = null - private var ensureNew: Boolean? = null - private var metadata: Metadata? = null - private var name: String? = null - private var public_: Boolean? = null - private var repoInfo: RepoInfo? = null + private var projectId: JsonField? = null + private var baseExpId: JsonField = JsonMissing.of() + private var datasetId: JsonField = JsonMissing.of() + private var datasetVersion: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var ensureNew: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var public_: JsonField = JsonMissing.of() + private var repoInfo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentCreateBody: ExperimentCreateBody) = apply { - this.projectId = experimentCreateBody.projectId - this.baseExpId = experimentCreateBody.baseExpId - this.datasetId = experimentCreateBody.datasetId - this.datasetVersion = experimentCreateBody.datasetVersion - this.description = experimentCreateBody.description - this.ensureNew = experimentCreateBody.ensureNew - this.metadata = experimentCreateBody.metadata - this.name = experimentCreateBody.name - this.public_ = experimentCreateBody.public_ - this.repoInfo = experimentCreateBody.repoInfo - additionalProperties(experimentCreateBody.additionalProperties) + projectId = experimentCreateBody.projectId + baseExpId = experimentCreateBody.baseExpId + datasetId = experimentCreateBody.datasetId + datasetVersion = experimentCreateBody.datasetVersion + description = experimentCreateBody.description + ensureNew = experimentCreateBody.ensureNew + metadata = experimentCreateBody.metadata + name = experimentCreateBody.name + public_ = experimentCreateBody.public_ + repoInfo = experimentCreateBody.repoInfo + additionalProperties = experimentCreateBody.additionalProperties.toMutableMap() } /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ + fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) /** * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - @JsonProperty("dataset_id") - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + + /** + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: String?) = + datasetVersion(JsonField.ofNullable(datasetVersion)) + + /** + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.orElse(null)) /** * Version number of the linked dataset the experiment was run against. This can be used * to reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") - fun datasetVersion(datasetVersion: String) = apply { + fun datasetVersion(datasetVersion: JsonField) = apply { this.datasetVersion = datasetVersion } /** Textual description of the experiment */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the experiment */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the experiment */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Normally, creating an experiment with the same name as an existing experiment will + * return the existing one un-modified. But if `ensure_new` is true, registration will + * generate a new experiment with a unique name in case of a conflict. + */ + fun ensureNew(ensureNew: Boolean?) = ensureNew(JsonField.ofNullable(ensureNew)) + + /** + * Normally, creating an experiment with the same name as an existing experiment will + * return the existing one un-modified. But if `ensure_new` is true, registration will + * generate a new experiment with a unique name in case of a conflict. + */ + fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) + + /** + * Normally, creating an experiment with the same name as an existing experiment will + * return the existing one un-modified. But if `ensure_new` is true, registration will + * generate a new experiment with a unique name in case of a conflict. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun ensureNew(ensureNew: Optional) = + ensureNew(ensureNew.orElse(null) as Boolean?) /** * Normally, creating an experiment with the same name as an existing experiment will * return the existing one un-modified. But if `ensure_new` is true, registration will * generate a new experiment with a unique name in case of a conflict. */ - @JsonProperty("ensure_new") - fun ensureNew(ensureNew: Boolean) = apply { this.ensureNew = ensureNew } + fun ensureNew(ensureNew: JsonField) = apply { this.ensureNew = ensureNew } /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean) = public_(public_ as Boolean?) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun public_(public_: Optional) = public_(public_.orElse(null) as Boolean?) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - @JsonProperty("public") fun public_(public_: Boolean) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = apply { this.public_ = public_ } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ExperimentCreateBody = ExperimentCreateBody( - checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkRequired("projectId", projectId), baseExpId, datasetId, datasetVersion, @@ -287,82 +522,180 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentCreateParams]. */ @NoAutoDetect - class Builder { - - private var projectId: String? = null - private var baseExpId: String? = null - private var datasetId: String? = null - private var datasetVersion: String? = null - private var description: String? = null - private var ensureNew: Boolean? = null - private var metadata: Metadata? = null - private var name: String? = null - private var public_: Boolean? = null - private var repoInfo: RepoInfo? = null + class Builder internal constructor() { + + private var body: ExperimentCreateBody.Builder = ExperimentCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentCreateParams: ExperimentCreateParams) = apply { - projectId = experimentCreateParams.projectId - baseExpId = experimentCreateParams.baseExpId - datasetId = experimentCreateParams.datasetId - datasetVersion = experimentCreateParams.datasetVersion - description = experimentCreateParams.description - ensureNew = experimentCreateParams.ensureNew - metadata = experimentCreateParams.metadata - name = experimentCreateParams.name - public_ = experimentCreateParams.public_ - repoInfo = experimentCreateParams.repoInfo + body = experimentCreateParams.body.toBuilder() additionalHeaders = experimentCreateParams.additionalHeaders.toBuilder() additionalQueryParams = experimentCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - experimentCreateParams.additionalBodyProperties.toMutableMap() } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { body.projectId(projectId) } + + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.orElse(null)) /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String) = apply { this.datasetVersion = datasetVersion } + fun datasetVersion(datasetVersion: JsonField) = apply { + body.datasetVersion(datasetVersion) + } + + /** Textual description of the experiment */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the experiment */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the experiment */ - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { body.description(description) } + + /** + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. + */ + fun ensureNew(ensureNew: Boolean?) = apply { body.ensureNew(ensureNew) } + + /** + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. + */ + fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) + + /** + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.orElse(null) as Boolean?) /** * Normally, creating an experiment with the same name as an existing experiment will return * the existing one un-modified. But if `ensure_new` is true, registration will generate a * new experiment with a unique name in case of a conflict. */ - fun ensureNew(ensureNew: Boolean) = apply { this.ensureNew = ensureNew } + fun ensureNew(ensureNew: JsonField) = apply { body.ensureNew(ensureNew) } + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: String?) = apply { body.name(name) } + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { body.name(name) } + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean?) = apply { body.public_(public_) } + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean) = public_(public_ as Boolean?) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun public_(public_: Optional) = public_(public_.orElse(null) as Boolean?) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - fun public_(public_: Boolean) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = apply { body.public_(public_) } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -462,58 +795,37 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ExperimentCreateParams = ExperimentCreateParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } /** User-controlled metadata about the experiment */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -521,29 +833,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -569,11 +887,11 @@ constructor( return true } - return /* spotless:off */ other is ExperimentCreateParams && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, baseExpId, datasetId, datasetVersion, description, ensureNew, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index d6273fe6..ef78cc66 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete an experiment object by its id */ class ExperimentDeleteParams -constructor( +private constructor( private val experimentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Experiment id */ fun experimentId(): String = experimentId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var experimentId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -192,7 +195,7 @@ constructor( fun build(): ExperimentDeleteParams = ExperimentDeleteParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + checkRequired("experimentId", experimentId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index bbd2b249..53e1f675 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -8,60 +8,84 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ExperimentEvent.Builder::class) @NoAutoDetect class ExperimentEvent +@JsonCreator private constructor( - private val id: JsonField, - private val datasetRecordId: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val experimentId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val isRoot: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("experiment_id") + @ExcludeMissing + private val experimentId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + private val context: JsonField = JsonMissing.of(), + @JsonProperty("dataset_record_id") + @ExcludeMissing + private val datasetRecordId: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), + @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), + @JsonProperty("is_root") + @ExcludeMissing + private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") + @ExcludeMissing + private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * A unique identifier for the experiment event. If you don't provide one, BrainTrust will * generate one for you */ fun id(): String = id.getRequired("id") - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) - /** * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve @@ -72,28 +96,38 @@ private constructor( /** The timestamp the experiment event was created */ fun created(): OffsetDateTime = created.getRequired("created") + /** Unique identifier for the experiment */ + fun experimentId(): String = experimentId.getRequired("experiment_id") + /** Unique identifier for the project that the experiment belongs under */ fun projectId(): String = projectId.getRequired("project_id") - /** Unique identifier for the experiment */ - fun experimentId(): String = experimentId.getRequired("experiment_id") + /** A unique identifier for the trace this experiment event belongs to */ + fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - fun input(): JsonValue = input + fun spanId(): String = spanId.getRequired("span_id") /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event */ - fun output(): JsonValue = output + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to @@ -103,21 +137,18 @@ private constructor( * digging into analyses. However, we may later use these values to re-score outputs or * fine-tune your models */ - fun expected(): JsonValue = expected - - /** The error that occurred, if any. */ - fun error(): JsonValue = error + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + + /** Whether this span is a root span */ + fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -128,9 +159,6 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** * Metrics are numerical measurements tracking the execution of the code that produced the * experiment event. Use "start" and "end" to track the time span over which the experiment @@ -138,19 +166,32 @@ private constructor( */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ - fun spanId(): String = spanId.getRequired("span_id") + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** * An array of the parent `span_ids` of this experiment event. This should be empty for the root @@ -159,87 +200,60 @@ private constructor( fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** A unique identifier for the trace this experiment event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - - /** Whether this span is a root span */ - fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) - - /** Indicates the event was copied from another object. */ - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** * A unique identifier for the experiment event. If you don't provide one, BrainTrust will * generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the experiment (see the `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** Unique identifier for the experiment */ + @JsonProperty("experiment_id") + @ExcludeMissing + fun _experimentId(): JsonField = experimentId /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") @ExcludeMissing fun _experimentId() = experimentId + /** A unique identifier for the trace this experiment event belongs to */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("input") @ExcludeMissing fun _input() = input + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event */ - @JsonProperty("output") @ExcludeMissing fun _output() = output + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error + @JsonProperty("dataset_record_id") + @ExcludeMissing + fun _datasetRecordId(): JsonField = datasetRecordId - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + /** Whether this span is a root span */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** * A dictionary with additional data about the test example, model outputs, or just about @@ -248,79 +262,74 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * Metrics are numerical measurements tracking the execution of the code that produced the * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics - /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes(): JsonField = spanAttributes /** * An array of the parent `span_ids` of this experiment event. This should be empty for the root * span of a trace, and should most often contain just one parent element for subspans */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents - - /** A unique identifier for the trace this experiment event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot() = isRoot + @JsonProperty("span_parents") + @ExcludeMissing + fun _spanParents(): JsonField> = spanParents - /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ExperimentEvent = apply { - if (!validated) { - id() - datasetRecordId() - _xactId() - created() - projectId() - experimentId() - input() - output() - expected() - error() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanId() - spanParents() - rootSpanId() - spanAttributes().map { it.validate() } - isRoot() - origin().map { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + _xactId() + created() + experimentId() + projectId() + rootSpanId() + spanId() + context().ifPresent { it.validate() } + datasetRecordId() + isRoot() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanParents() + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -330,55 +339,56 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ExperimentEvent]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var created: JsonField? = null + private var experimentId: JsonField? = null + private var projectId: JsonField? = null + private var rootSpanId: JsonField? = null + private var spanId: JsonField? = null + private var context: JsonField = JsonMissing.of() private var datasetRecordId: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var experimentId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() private var error: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() + private var isRoot: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var isRoot: JsonField = JsonMissing.of() private var origin: JsonField = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var spanAttributes: JsonField = JsonMissing.of() + private var spanParents: JsonField>? = null + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentEvent: ExperimentEvent) = apply { - this.id = experimentEvent.id - this.datasetRecordId = experimentEvent.datasetRecordId - this._xactId = experimentEvent._xactId - this.created = experimentEvent.created - this.projectId = experimentEvent.projectId - this.experimentId = experimentEvent.experimentId - this.input = experimentEvent.input - this.output = experimentEvent.output - this.expected = experimentEvent.expected - this.error = experimentEvent.error - this.scores = experimentEvent.scores - this.metadata = experimentEvent.metadata - this.tags = experimentEvent.tags - this.metrics = experimentEvent.metrics - this.context = experimentEvent.context - this.spanId = experimentEvent.spanId - this.spanParents = experimentEvent.spanParents - this.rootSpanId = experimentEvent.rootSpanId - this.spanAttributes = experimentEvent.spanAttributes - this.isRoot = experimentEvent.isRoot - this.origin = experimentEvent.origin - additionalProperties(experimentEvent.additionalProperties) + id = experimentEvent.id + _xactId = experimentEvent._xactId + created = experimentEvent.created + experimentId = experimentEvent.experimentId + projectId = experimentEvent.projectId + rootSpanId = experimentEvent.rootSpanId + spanId = experimentEvent.spanId + context = experimentEvent.context + datasetRecordId = experimentEvent.datasetRecordId + error = experimentEvent.error + expected = experimentEvent.expected + input = experimentEvent.input + isRoot = experimentEvent.isRoot + metadata = experimentEvent.metadata + metrics = experimentEvent.metrics + origin = experimentEvent.origin + output = experimentEvent.output + scores = experimentEvent.scores + spanAttributes = experimentEvent.spanAttributes + spanParents = experimentEvent.spanParents.map { it.toMutableList() } + tags = experimentEvent.tags.map { it.toMutableList() } + additionalProperties = experimentEvent.additionalProperties.toMutableMap() } /** @@ -391,24 +401,7 @@ private constructor( * A unique identifier for the experiment event. If you don't provide one, BrainTrust will * generate one for you */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } + fun id(id: JsonField) = apply { this.id = id } /** * The transaction id of an event is unique to the network operation that processed the @@ -422,56 +415,93 @@ private constructor( * event insertion. Transaction ids are monotonically increasing over time and can be used * to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - /** Unique identifier for the experiment */ fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") - @ExcludeMissing fun experimentId(experimentId: JsonField) = apply { this.experimentId = experimentId } + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the experiment belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** A unique identifier for the trace this experiment event belongs to */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** A unique identifier for the trace this experiment event belongs to */ + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + fun context(context: Context?) = context(JsonField.ofNullable(context)) + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + fun context(context: Optional) = context(context.orElse(null)) + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + fun context(context: JsonField) = apply { this.context = context } + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: String?) = + datasetRecordId(JsonField.ofNullable(datasetRecordId)) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: Optional) = + datasetRecordId(datasetRecordId.orElse(null)) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: JsonField) = apply { + this.datasetRecordId = datasetRecordId + } + + /** The error that occurred, if any. */ + fun error(error: JsonValue) = apply { this.error = error } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to @@ -481,38 +511,37 @@ private constructor( * while digging into analyses. However, we may later use these values to re-score outputs * or fine-tune your models */ - @JsonProperty("expected") - @ExcludeMissing fun expected(expected: JsonValue) = apply { this.expected = expected } - /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) + fun input(input: JsonValue) = apply { this.input = input } + + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) + + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) + + /** Whether this span is a root span */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isRoot(isRoot: Optional) = isRoot(isRoot.orElse(null) as Boolean?) + + /** Whether this span is a root span */ + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -521,7 +550,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -530,154 +559,197 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** * Metrics are numerical measurements tracking the execution of the code that produced the * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) /** * Metrics are numerical measurements tracking the execution of the code that produced the * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced */ - @JsonProperty("metrics") - @ExcludeMissing fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + /** Indicates the event was copied from another object. */ + fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.orElse(null)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } + /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question */ - fun context(context: Context) = context(JsonField.of(context)) + fun output(output: JsonValue) = apply { this.output = output } /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } + fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + fun scores(scores: Optional) = scores(scores.orElse(null)) /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes?) = + spanAttributes(JsonField.ofNullable(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: Optional) = + spanAttributes(spanAttributes.orElse(null)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } /** * An array of the parent `span_ids` of this experiment event. This should be empty for the * root span of a trace, and should most often contain just one parent element for subspans */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) + + /** + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans + */ + fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) /** * An array of the parent `span_ids` of this experiment event. This should be empty for the * root span of a trace, and should most often contain just one parent element for subspans */ - @JsonProperty("span_parents") - @ExcludeMissing fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents + this.spanParents = spanParents.map { it.toMutableList() } } - /** A unique identifier for the trace this experiment event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - - /** A unique identifier for the trace this experiment event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes + /** + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans + */ + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(spanParent) + } } - /** Whether this span is a root span */ - fun isRoot(isRoot: Boolean) = isRoot(JsonField.of(isRoot)) + /** A list of tags to log */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** Whether this span is a root span */ - @JsonProperty("is_root") - @ExcludeMissing - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + /** A list of tags to log */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) - /** Indicates the event was copied from another object. */ - fun origin(origin: Origin) = origin(JsonField.of(origin)) + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } - /** Indicates the event was copied from another object. */ - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ExperimentEvent = ExperimentEvent( - id, + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("created", created), + checkRequired("experimentId", experimentId), + checkRequired("projectId", projectId), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), + context, datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, error, - scores, + expected, + input, + isRoot, metadata, - tags.map { it.toImmutable() }, metrics, - context, - spanId, - spanParents.map { it.toImmutable() }, - rootSpanId, - spanAttributes, - isRoot, origin, + output, + scores, + spanAttributes, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -687,52 +759,65 @@ private constructor( * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the * location in code which produced the experiment event */ - @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect class Context + @JsonCreator private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Name of the file in code where the experiment event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the experiment event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - /** Line of code where the experiment event was created */ fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + /** Name of the file in code where the experiment event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename(): JsonField = callerFilename + /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + fun _callerFunctionname(): JsonField = callerFunctionname /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonField = callerLineno @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + if (validated) { + return@apply } + + callerFilename() + callerFunctionname() + callerLineno() + validated = true } fun toBuilder() = Builder().from(this) @@ -742,71 +827,87 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Context]. */ + class Builder internal constructor() { - private var callerFunctionname: JsonField = JsonMissing.of() private var callerFilename: JsonField = JsonMissing.of() + private var callerFunctionname: JsonField = JsonMissing.of() private var callerLineno: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: String?) = + callerFilename(JsonField.ofNullable(callerFilename)) + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: Optional) = + callerFilename(callerFilename.orElse(null)) + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = + callerFunctionname(JsonField.ofNullable(callerFunctionname)) + + /** The function in code which created the experiment event */ + fun callerFunctionname(callerFunctionname: Optional) = + callerFunctionname(callerFunctionname.orElse(null)) /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing fun callerFunctionname(callerFunctionname: JsonField) = apply { this.callerFunctionname = callerFunctionname } - /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + /** Line of code where the experiment event was created */ + fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + /** Line of code where the experiment event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun callerLineno(callerLineno: Optional) = + callerLineno(callerLineno.orElse(null) as Long?) /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing fun callerLineno(callerLineno: JsonField) = apply { this.callerLineno = callerLineno } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Context = Context( - callerFunctionname, callerFilename, + callerFunctionname, callerLineno, additionalProperties.toImmutable(), ) @@ -817,17 +918,17 @@ private constructor( return true } - return /* spotless:off */ other is Context && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(callerFilename, callerFunctionname, callerLineno, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -837,23 +938,26 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -863,29 +967,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -911,78 +1021,77 @@ private constructor( * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced */ - @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect class Metrics + @JsonCreator private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val callerFunctionname: JsonValue, - private val callerFilename: JsonValue, - private val callerLineno: JsonValue, - private val additionalProperties: Map, + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + private val completionTokens: JsonField = JsonMissing.of(), + @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") + @ExcludeMissing + private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** - * A unix timestamp recording when the section of code which produced the experiment event - * started - */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - - /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished - */ - fun end(): Optional = Optional.ofNullable(end.getNullable("end")) - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) - - /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) - */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - /** This metric is deprecated */ - fun callerFunctionname(): JsonValue = callerFunctionname + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename(): JsonValue = callerFilename /** This metric is deprecated */ - fun callerFilename(): JsonValue = callerFilename + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - fun callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** * A unix timestamp recording when the section of code which produced the experiment event * finished */ - @JsonProperty("end") @ExcludeMissing fun _end() = end + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + + /** + * A unix timestamp recording when the section of code which produced the experiment event + * started + */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** * The number of tokens in the completion generated by the model (only set if this is an LLM @@ -990,38 +1099,48 @@ private constructor( */ @JsonProperty("completion_tokens") @ExcludeMissing - fun _completionTokens() = completionTokens + fun _completionTokens(): JsonField = completionTokens - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + /** + * A unix timestamp recording when the section of code which produced the experiment event + * finished + */ + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end - /** This metric is deprecated */ - @JsonProperty("caller_functionname") + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") @ExcludeMissing - fun _callerFunctionname() = callerFunctionname + fun _promptTokens(): JsonField = promptTokens - /** This metric is deprecated */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + /** + * A unix timestamp recording when the section of code which produced the experiment event + * started + */ + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start - /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + /** The total number of tokens in the input and output of the experiment event. */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - callerFunctionname() - callerFilename() - callerLineno() - validated = true + if (validated) { + return@apply } + + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true } fun toBuilder() = Builder().from(this) @@ -1031,143 +1150,195 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metrics]. */ + class Builder internal constructor() { - private var start: JsonField = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() private var end: JsonField = JsonMissing.of() private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() + private var start: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() - private var callerFunctionname: JsonValue = JsonMissing.of() - private var callerFilename: JsonValue = JsonMissing.of() - private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - this.callerFunctionname = metrics.callerFunctionname - this.callerFilename = metrics.callerFilename - this.callerLineno = metrics.callerLineno - additionalProperties(metrics.additionalProperties) + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } + + /** This metric is deprecated */ + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.orElse(null) as Long?) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens } /** * A unix timestamp recording when the section of code which produced the experiment - * event started + * event finished */ - fun start(start: Double) = start(JsonField.of(start)) + fun end(end: Double?) = end(JsonField.ofNullable(end)) /** * A unix timestamp recording when the section of code which produced the experiment - * event started + * event finished */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun end(end: Double) = end(end as Double?) /** * A unix timestamp recording when the section of code which produced the experiment * event finished */ - fun end(end: Double) = end(JsonField.of(end)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun end(end: Optional) = end(end.orElse(null) as Double?) /** * A unix timestamp recording when the section of code which produced the experiment * event finished */ - @JsonProperty("end") - @ExcludeMissing fun end(end: JsonField) = apply { this.end = end } /** * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun promptTokens(promptTokens: Optional) = + promptTokens(promptTokens.orElse(null) as Long?) /** * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) + fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun start(start: Double) = start(start as Double?) - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun start(start: Optional) = start(start.orElse(null) as Double?) + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(tokens: Long) = tokens(tokens as Long?) - /** This metric is deprecated */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + /** The total number of tokens in the input and output of the experiment event. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun tokens(tokens: Optional) = tokens(tokens.orElse(null) as Long?) - /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metrics = Metrics( - start, + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, end, promptTokens, - completionTokens, + start, tokens, - callerFunctionname, - callerFilename, - callerLineno, additionalProperties.toImmutable(), ) } @@ -1177,69 +1348,80 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && start == other.start && end == other.end && promptTokens == other.promptTokens && completionTokens == other.completionTokens && tokens == other.tokens && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(callerFilename, callerFunctionname, callerLineno, completionTokens, end, promptTokens, start, tokens, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** Indicates the event was copied from another object. */ - @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect class Origin + @JsonCreator private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val id: JsonField, - private val _xactId: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - /** ID of the original event. */ fun id(): String = id.getRequired("id") /** Transaction ID of the original event. */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + fun objectId(): String = objectId.getRequired("object_id") + + /** Type of the object the event is originating from. */ + fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Origin = apply { - if (!validated) { - objectType() - objectId() - id() - _xactId() - validated = true + if (validated) { + return@apply } + + id() + _xactId() + objectId() + objectType() + validated = true } fun toBuilder() = Builder().from(this) @@ -1249,118 +1431,114 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Origin]. */ + class Builder internal constructor() { - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(origin: Origin) = apply { - this.objectType = origin.objectType - this.objectId = origin.objectId - this.id = origin.id - this._xactId = origin._xactId - additionalProperties(origin.additionalProperties) - } - - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() } - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") - @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") - @ExcludeMissing fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + /** ID of the object the event is originating from. */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** ID of the object the event is originating from. */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** Type of the object the event is originating from. */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** Type of the object the event is originating from. */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Origin = Origin( - objectType, - objectId, - id, - _xactId, + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), additionalProperties.toImmutable(), ) } + /** Type of the object the event is originating from. */ 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 - 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() - companion object { - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + @JvmField val FUNCTION = of("function") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val PROJECT_LOGS = ObjectType(JsonField.of("project_logs")) + @JvmField val PROJECT_LOGS = of("project_logs") @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) } + /** An enum containing [ObjectType]'s known values. */ enum class Known { EXPERIMENT, DATASET, @@ -1370,6 +1548,15 @@ private constructor( PROJECT_LOGS, } + /** + * 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 { EXPERIMENT, DATASET, @@ -1377,9 +1564,20 @@ private constructor( FUNCTION, PROMPT_SESSION, PROJECT_LOGS, + /** + * 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) { EXPERIMENT -> Value.EXPERIMENT @@ -1391,6 +1589,15 @@ private constructor( 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) { EXPERIMENT -> Known.EXPERIMENT @@ -1403,6 +1610,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1410,17 +1629,17 @@ private constructor( return true } - return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && id == other.id && _xactId == other._xactId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, id, _xactId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" + "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } /** @@ -1432,23 +1651,26 @@ private constructor( * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect class Scores + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Scores = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1458,29 +1680,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Scores]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) + additionalProperties = scores.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Scores = Scores(additionalProperties.toImmutable()) } @@ -1506,15 +1734,15 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentEvent && id == other.id && datasetRecordId == other.datasetRecordId && _xactId == other._xactId && created == other.created && projectId == other.projectId && experimentId == other.experimentId && input == other.input && output == other.output && expected == other.expected && error == other.error && scores == other.scores && metadata == other.metadata && tags == other.tags && metrics == other.metrics && context == other.context && spanId == other.spanId && spanParents == other.spanParents && rootSpanId == other.rootSpanId && spanAttributes == other.spanAttributes && isRoot == other.isRoot && origin == other.origin && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, datasetRecordId, _xactId, created, projectId, experimentId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, spanAttributes, isRoot, origin, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, experimentId, projectId, rootSpanId, spanId, context, datasetRecordId, error, expected, input, isRoot, metadata, metrics, origin, output, scores, spanAttributes, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, isRoot=$isRoot, origin=$origin, additionalProperties=$additionalProperties}" + "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 11386697..a7ee93f5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -3,45 +3,51 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects +/** Log feedback for a set of experiment events */ class ExperimentFeedbackParams -constructor( +private constructor( private val experimentId: String, - private val feedback: List, + private val body: ExperimentFeedbackBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Experiment id */ fun experimentId(): String = experimentId - fun feedback(): List = feedback + /** A list of experiment feedback items */ + fun feedback(): List = body.feedback() + + /** A list of experiment feedback items */ + fun _feedback(): JsonField> = body._feedback() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ExperimentFeedbackBody { - return ExperimentFeedbackBody(feedback, additionalBodyProperties) - } + @JvmSynthetic internal fun _body(): ExperimentFeedbackBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,21 +56,40 @@ constructor( } } - @JsonDeserialize(builder = ExperimentFeedbackBody.Builder::class) @NoAutoDetect class ExperimentFeedbackBody + @JsonCreator internal constructor( - private val feedback: List?, - private val additionalProperties: Map, + @JsonProperty("feedback") + @ExcludeMissing + private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of experiment feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + fun feedback(): List = feedback.getRequired("feedback") + + /** A list of experiment feedback items */ + @JsonProperty("feedback") + @ExcludeMissing + fun _feedback(): JsonField> = feedback @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExperimentFeedbackBody = apply { + if (validated) { + return@apply + } + + feedback().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,41 +97,62 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ExperimentFeedbackBody]. */ + class Builder internal constructor() { - private var feedback: List? = null + private var feedback: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentFeedbackBody: ExperimentFeedbackBody) = apply { - this.feedback = experimentFeedbackBody.feedback - additionalProperties(experimentFeedbackBody.additionalProperties) + feedback = experimentFeedbackBody.feedback.map { it.toMutableList() } + additionalProperties = experimentFeedbackBody.additionalProperties.toMutableMap() } /** A list of experiment feedback items */ - @JsonProperty("feedback") - fun feedback(feedback: List) = apply { - this.feedback = feedback + fun feedback(feedback: List) = feedback(JsonField.of(feedback)) + + /** A list of experiment feedback items */ + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback.map { it.toMutableList() } + } + + /** A list of experiment feedback items */ + fun addFeedback(feedback: FeedbackExperimentItem) = apply { + this.feedback = + (this.feedback ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(feedback) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ExperimentFeedbackBody = ExperimentFeedbackBody( - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toImmutable(), + checkRequired("feedback", feedback).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -136,36 +182,55 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentFeedbackParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var experimentId: String? = null - private var feedback: MutableList = mutableListOf() + private var body: ExperimentFeedbackBody.Builder = ExperimentFeedbackBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = apply { experimentId = experimentFeedbackParams.experimentId - feedback = experimentFeedbackParams.feedback.toMutableList() + body = experimentFeedbackParams.body.toBuilder() additionalHeaders = experimentFeedbackParams.additionalHeaders.toBuilder() additionalQueryParams = experimentFeedbackParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - experimentFeedbackParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment feedback items */ - fun feedback(feedback: List) = apply { - this.feedback.clear() - this.feedback.addAll(feedback) + fun feedback(feedback: List) = apply { body.feedback(feedback) } + + /** A list of experiment feedback items */ + fun feedback(feedback: JsonField>) = apply { + body.feedback(feedback) } /** A list of experiment feedback items */ - fun addFeedback(feedback: FeedbackExperimentItem) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackExperimentItem) = apply { body.addFeedback(feedback) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -265,35 +330,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - feedback.toImmutable(), + checkRequired("experimentId", experimentId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -302,11 +344,11 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentFeedbackParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 5d243ca8..85fe08a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -3,14 +3,20 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects import java.util.Optional +/** + * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use the + * `POST /btql` endpoint. + */ class ExperimentFetchParams -constructor( +private constructor( private val experimentId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -18,26 +24,70 @@ constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Experiment id */ fun experimentId(): String = experimentId + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ fun limit(): Optional = Optional.ofNullable(limit) + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ fun version(): Optional = Optional.ofNullable(version) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.limit?.let { queryParams.put("limit", listOf(it.toString())) } this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } @@ -61,8 +111,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentFetchParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var experimentId: String? = null private var limit: Long? = null @@ -101,7 +152,42 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -115,7 +201,7 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -129,7 +215,44 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: String?) = apply { this.version = version } /** * Retrieve a snapshot of events from a past time @@ -137,7 +260,7 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { this.version = version } + fun version(version: Optional) = version(version.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -239,7 +362,7 @@ constructor( fun build(): ExperimentFetchParams = ExperimentFetchParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + checkRequired("experimentId", experimentId), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 14451928..a5f7a4d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -3,65 +3,170 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use the + * `POST /btql` endpoint. + */ class ExperimentFetchPostParams -constructor( +private constructor( private val experimentId: String, - private val cursor: String?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, + private val body: ExperimentFetchPostBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Experiment id */ fun experimentId(): String = experimentId - fun cursor(): Optional = Optional.ofNullable(cursor) - - fun limit(): Optional = Optional.ofNullable(limit) - - fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) - - fun maxXactId(): Optional = Optional.ofNullable(maxXactId) - - fun version(): Optional = Optional.ofNullable(version) + /** + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch query + */ + fun cursor(): Optional = body.cursor() + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ + fun limit(): Optional = body.limit() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun maxRootSpanId(): Optional = body.maxRootSpanId() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun maxXactId(): Optional = body.maxXactId() + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(): Optional = body.version() + + /** + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch query + */ + fun _cursor(): JsonField = body._cursor() + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ + fun _limit(): JsonField = body._limit() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun _maxRootSpanId(): JsonField = body._maxRootSpanId() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun _maxXactId(): JsonField = body._maxXactId() + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun _version(): JsonField = body._version() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ExperimentFetchPostBody { - return ExperimentFetchPostBody( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ExperimentFetchPostBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -70,16 +175,27 @@ constructor( } } - @JsonDeserialize(builder = ExperimentFetchPostBody.Builder::class) @NoAutoDetect class ExperimentFetchPostBody + @JsonCreator internal constructor( - private val cursor: String?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") + @ExcludeMissing + private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") + @ExcludeMissing + private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") + @ExcludeMissing + private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -89,7 +205,7 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - @JsonProperty("cursor") fun cursor(): String? = cursor + fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched @@ -106,7 +222,7 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @JsonProperty("limit") fun limit(): Long? = limit + fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -120,7 +236,8 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - @JsonProperty("max_root_span_id") fun maxRootSpanId(): String? = maxRootSpanId + fun maxRootSpanId(): Optional = + Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -134,7 +251,8 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - @JsonProperty("max_xact_id") fun maxXactId(): String? = maxXactId + fun maxXactId(): Optional = + Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time @@ -142,12 +260,91 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") fun version(): String? = version + fun version(): Optional = Optional.ofNullable(version.getNullable("version")) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + @JsonProperty("max_root_span_id") + @ExcludeMissing + fun _maxRootSpanId(): JsonField = maxRootSpanId + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExperimentFetchPostBody = apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -155,23 +352,24 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ExperimentFetchPostBody]. */ + class Builder internal constructor() { - private var cursor: String? = null - private var limit: Long? = null - private var maxRootSpanId: String? = null - private var maxXactId: String? = null - private var version: String? = null + private var cursor: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var maxRootSpanId: JsonField = JsonMissing.of() + private var maxXactId: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentFetchPostBody: ExperimentFetchPostBody) = apply { - this.cursor = experimentFetchPostBody.cursor - this.limit = experimentFetchPostBody.limit - this.maxRootSpanId = experimentFetchPostBody.maxRootSpanId - this.maxXactId = experimentFetchPostBody.maxXactId - this.version = experimentFetchPostBody.version - additionalProperties(experimentFetchPostBody.additionalProperties) + cursor = experimentFetchPostBody.cursor + limit = experimentFetchPostBody.limit + maxRootSpanId = experimentFetchPostBody.maxRootSpanId + maxXactId = experimentFetchPostBody.maxXactId + version = experimentFetchPostBody.version + additionalProperties = experimentFetchPostBody.additionalProperties.toMutableMap() } /** @@ -181,7 +379,25 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } /** * limit the number of traces fetched @@ -198,7 +414,119 @@ constructor( * with more individual rows than the specified limit if you are fetching events * containing traces. */ - @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: String?) = + maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + this.maxRootSpanId = maxRootSpanId + } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -212,8 +540,7 @@ constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - @JsonProperty("max_root_span_id") - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -227,8 +554,25 @@ constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. + */ + fun version(version: String?) = version(JsonField.ofNullable(version)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. + */ + fun version(version: Optional) = version(version.orElse(null)) /** * Retrieve a snapshot of events from a past time @@ -237,22 +581,27 @@ constructor( * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact * fetch. */ - @JsonProperty("version") fun version(version: String) = apply { this.version = version } + fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ExperimentFetchPostBody = ExperimentFetchPostBody( cursor, @@ -289,31 +638,21 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentFetchPostParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var experimentId: String? = null - private var cursor: String? = null - private var limit: Long? = null - private var maxRootSpanId: String? = null - private var maxXactId: String? = null - private var version: String? = null + private var body: ExperimentFetchPostBody.Builder = ExperimentFetchPostBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = apply { experimentId = experimentFetchPostParams.experimentId - cursor = experimentFetchPostParams.cursor - limit = experimentFetchPostParams.limit - maxRootSpanId = experimentFetchPostParams.maxRootSpanId - maxXactId = experimentFetchPostParams.maxXactId - version = experimentFetchPostParams.version + body = experimentFetchPostParams.body.toBuilder() additionalHeaders = experimentFetchPostParams.additionalHeaders.toBuilder() additionalQueryParams = experimentFetchPostParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - experimentFetchPostParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ @@ -326,7 +665,25 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: String) = apply { this.cursor = cursor } + fun cursor(cursor: String?) = apply { body.cursor(cursor) } + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } /** * limit the number of traces fetched @@ -343,7 +700,59 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = apply { body.limit(limit) } + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: JsonField) = apply { body.limit(limit) } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -357,7 +766,7 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -371,7 +780,74 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + body.maxRootSpanId(maxRootSpanId) + } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: String?) = apply { body.version(version) } /** * Retrieve a snapshot of events from a past time @@ -379,7 +855,34 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { this.version = version } + fun version(version: Optional) = version(version.orElse(null)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: JsonField) = apply { body.version(version) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -479,39 +982,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ExperimentFetchPostParams = ExperimentFetchPostParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - cursor, - limit, - maxRootSpanId, - maxXactId, - version, + checkRequired("experimentId", experimentId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -520,11 +996,11 @@ constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentFetchPostParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index f0f02b2b..6acaea61 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -3,45 +3,51 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects +/** Insert a set of events into the experiment */ class ExperimentInsertParams -constructor( +private constructor( private val experimentId: String, - private val events: List, + private val body: ExperimentInsertBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Experiment id */ fun experimentId(): String = experimentId - fun events(): List = events + /** A list of experiment events to insert */ + fun events(): List = body.events() + + /** A list of experiment events to insert */ + fun _events(): JsonField> = body._events() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ExperimentInsertBody { - return ExperimentInsertBody(events, additionalBodyProperties) - } + @JvmSynthetic internal fun _body(): ExperimentInsertBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,21 +56,40 @@ constructor( } } - @JsonDeserialize(builder = ExperimentInsertBody.Builder::class) @NoAutoDetect class ExperimentInsertBody + @JsonCreator internal constructor( - private val events: List?, - private val additionalProperties: Map, + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of experiment events to insert */ - @JsonProperty("events") fun events(): List? = events + fun events(): List = events.getRequired("events") + + /** A list of experiment events to insert */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExperimentInsertBody = apply { + if (validated) { + return@apply + } + + events().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,38 +97,62 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ExperimentInsertBody]. */ + class Builder internal constructor() { - private var events: List? = null + private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentInsertBody: ExperimentInsertBody) = apply { - this.events = experimentInsertBody.events - additionalProperties(experimentInsertBody.additionalProperties) + events = experimentInsertBody.events.map { it.toMutableList() } + additionalProperties = experimentInsertBody.additionalProperties.toMutableMap() + } + + /** A list of experiment events to insert */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of experiment events to insert */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } } /** A list of experiment events to insert */ - @JsonProperty("events") - fun events(events: List) = apply { this.events = events } + fun addEvent(event: InsertExperimentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(event) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ExperimentInsertBody = ExperimentInsertBody( - checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + checkRequired("events", events).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -133,36 +182,53 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentInsertParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var experimentId: String? = null - private var events: MutableList = mutableListOf() + private var body: ExperimentInsertBody.Builder = ExperimentInsertBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentInsertParams: ExperimentInsertParams) = apply { experimentId = experimentInsertParams.experimentId - events = experimentInsertParams.events.toMutableList() + body = experimentInsertParams.body.toBuilder() additionalHeaders = experimentInsertParams.additionalHeaders.toBuilder() additionalQueryParams = experimentInsertParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - experimentInsertParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment events to insert */ - fun events(events: List) = apply { - this.events.clear() - this.events.addAll(events) - } + fun events(events: List) = apply { body.events(events) } /** A list of experiment events to insert */ - fun addEvent(event: InsertExperimentEvent) = apply { this.events.add(event) } + fun events(events: JsonField>) = apply { body.events(events) } + + /** A list of experiment events to insert */ + fun addEvent(event: InsertExperimentEvent) = apply { body.addEvent(event) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -262,35 +328,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ExperimentInsertParams = ExperimentInsertParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - events.toImmutable(), + checkRequired("experimentId", experimentId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -299,11 +342,11 @@ constructor( return true } - return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentInsertParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 38837f0d..de9aff31 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.ExperimentService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first + */ class ExperimentListPage private constructor( private val experimentsService: ExperimentService, @@ -89,16 +94,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -108,11 +113,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -148,10 +157,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -160,8 +167,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ExperimentListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index a1459960..63d7b8ac 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.ExperimentServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first + */ class ExperimentListPageAsync private constructor( private val experimentsService: ExperimentServiceAsync, @@ -92,16 +97,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +116,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +160,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +170,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ExperimentListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 72788281..d51ea84a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first + */ class ExperimentListParams -constructor( +private constructor( private val endingBefore: String?, private val experimentName: String?, private val ids: Ids?, @@ -33,32 +37,54 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** Name of the experiment to search for */ fun experimentName(): Optional = Optional.ofNullable(experimentName) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Project id */ fun projectId(): Optional = Optional.ofNullable(projectId) + /** Name of the project to search for */ fun projectName(): Optional = Optional.ofNullable(projectName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.experimentName?.let { queryParams.put("experiment_name", listOf(it.toString())) } @@ -79,8 +105,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var experimentName: String? = null @@ -114,40 +141,75 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + + /** Name of the experiment to search for */ + fun experimentName(experimentName: String?) = apply { this.experimentName = experimentName } /** Name of the experiment to search for */ - fun experimentName(experimentName: String) = apply { this.experimentName = experimentName } + fun experimentName(experimentName: Optional) = + experimentName(experimentName.orElse(null)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = ids(Ids.ofString(string)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = apply { this.projectId = projectId } + + /** Project id */ + fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + + /** Name of the project to search for */ + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) /** * Pagination cursor id. @@ -156,7 +218,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -271,6 +343,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -280,8 +356,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -304,15 +378,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -338,18 +403,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -365,7 +440,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 78835532..0da1e565 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get an experiment object by its id */ class ExperimentRetrieveParams -constructor( +private constructor( private val experimentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Experiment id */ fun experimentId(): String = experimentId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var experimentId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + checkRequired("experimentId", experimentId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 4d1a2b52..490d80a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -3,35 +3,46 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects import java.util.Optional +/** Summarize experiment */ class ExperimentSummarizeParams -constructor( +private constructor( private val experimentId: String, private val comparisonExperimentId: String?, private val summarizeScores: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Experiment id */ fun experimentId(): String = experimentId + /** + * The experiment to compare against, if summarizing scores and metrics. If omitted, will fall + * back to the `base_exp_id` stored in the experiment metadata, and then to the most recent + * experiment run in the same project. Must pass `summarize_scores=true` for this id to be used + */ fun comparisonExperimentId(): Optional = Optional.ofNullable(comparisonExperimentId) + /** + * Whether to summarize the scores and metrics. If false (or omitted), only the metadata will be + * returned. + */ fun summarizeScores(): Optional = Optional.ofNullable(summarizeScores) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.comparisonExperimentId?.let { queryParams.put("comparison_experiment_id", listOf(it.toString())) @@ -55,8 +66,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentSummarizeParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var experimentId: String? = null private var comparisonExperimentId: String? = null @@ -82,18 +94,41 @@ constructor( * recent experiment run in the same project. Must pass `summarize_scores=true` for this id * to be used */ - fun comparisonExperimentId(comparisonExperimentId: String) = apply { + fun comparisonExperimentId(comparisonExperimentId: String?) = apply { this.comparisonExperimentId = comparisonExperimentId } + /** + * The experiment to compare against, if summarizing scores and metrics. If omitted, will + * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most + * recent experiment run in the same project. Must pass `summarize_scores=true` for this id + * to be used + */ + fun comparisonExperimentId(comparisonExperimentId: Optional) = + comparisonExperimentId(comparisonExperimentId.orElse(null)) + /** * Whether to summarize the scores and metrics. If false (or omitted), only the metadata * will be returned. */ - fun summarizeScores(summarizeScores: Boolean) = apply { + fun summarizeScores(summarizeScores: Boolean?) = apply { this.summarizeScores = summarizeScores } + /** + * Whether to summarize the scores and metrics. If false (or omitted), only the metadata + * will be returned. + */ + fun summarizeScores(summarizeScores: Boolean) = summarizeScores(summarizeScores as Boolean?) + + /** + * Whether to summarize the scores and metrics. If false (or omitted), only the metadata + * will be returned. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun summarizeScores(summarizeScores: Optional) = + summarizeScores(summarizeScores.orElse(null) as Boolean?) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -194,7 +229,7 @@ constructor( fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, + checkRequired("experimentId", experimentId), comparisonExperimentId, summarizeScores, additionalHeaders.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index ce106713..9978756e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -3,77 +3,110 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update an experiment object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ class ExperimentUpdateParams -constructor( +private constructor( private val experimentId: String, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, + private val body: ExperimentUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Experiment id */ fun experimentId(): String = experimentId - fun baseExpId(): Optional = Optional.ofNullable(baseExpId) + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(): Optional = body.baseExpId() - fun datasetId(): Optional = Optional.ofNullable(datasetId) + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + fun datasetId(): Optional = body.datasetId() - fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion) + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(): Optional = body.datasetVersion() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the experiment */ + fun description(): Optional = body.description() - fun metadata(): Optional = Optional.ofNullable(metadata) + /** User-controlled metadata about the experiment */ + fun metadata(): Optional = body.metadata() + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(): Optional = body.name() + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + fun public_(): Optional = body.public_() + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(): Optional = body.repoInfo() - fun name(): Optional = Optional.ofNullable(name) + /** Id of default base experiment to compare against when viewing this experiment */ + fun _baseExpId(): JsonField = body._baseExpId() - fun public_(): Optional = Optional.ofNullable(public_) + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + fun _datasetId(): JsonField = body._datasetId() - fun repoInfo(): Optional = Optional.ofNullable(repoInfo) + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun _datasetVersion(): JsonField = body._datasetVersion() + + /** Textual description of the experiment */ + fun _description(): JsonField = body._description() + + /** User-controlled metadata about the experiment */ + fun _metadata(): JsonField = body._metadata() + + /** Name of the experiment. Within a project, experiment names are unique */ + fun _name(): JsonField = body._name() + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization + */ + fun _public_(): JsonField = body._public_() + + /** Metadata about the state of the repo when the experiment was created */ + fun _repoInfo(): JsonField = body._repoInfo() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ExperimentUpdateBody { - return ExperimentUpdateBody( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ExperimentUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -82,57 +115,131 @@ constructor( } } - @JsonDeserialize(builder = ExperimentUpdateBody.Builder::class) @NoAutoDetect class ExperimentUpdateBody + @JsonCreator internal constructor( - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalProperties: Map, + @JsonProperty("base_exp_id") + @ExcludeMissing + private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") + @ExcludeMissing + private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("public") + @ExcludeMissing + private val public_: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") + @ExcludeMissing + private val repoInfo: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") fun baseExpId(): String? = baseExpId + fun baseExpId(): Optional = + Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") fun datasetId(): String? = datasetId + fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") fun datasetVersion(): String? = datasetVersion + fun datasetVersion(): Optional = + Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Textual description of the experiment */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(): String? = name + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - @JsonProperty("public") fun public_(): Boolean? = public_ + fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo + fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) + + /** Id of default base experiment to compare against when viewing this experiment */ + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + @JsonProperty("dataset_version") + @ExcludeMissing + fun _datasetVersion(): JsonField = datasetVersion + + /** Textual description of the experiment */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** User-controlled metadata about the experiment */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** Name of the experiment. Within a project, experiment names are unique */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ + + /** Metadata about the state of the repo when the experiment was created */ + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExperimentUpdateBody = apply { + if (validated) { + return@apply + } + + baseExpId() + datasetId() + datasetVersion() + description() + metadata().ifPresent { it.validate() } + name() + public_() + repoInfo().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -140,86 +247,163 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ExperimentUpdateBody]. */ + class Builder internal constructor() { - private var baseExpId: String? = null - private var datasetId: String? = null - private var datasetVersion: String? = null - private var description: String? = null - private var metadata: Metadata? = null - private var name: String? = null - private var public_: Boolean? = null - private var repoInfo: RepoInfo? = null + private var baseExpId: JsonField = JsonMissing.of() + private var datasetId: JsonField = JsonMissing.of() + private var datasetVersion: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var public_: JsonField = JsonMissing.of() + private var repoInfo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentUpdateBody: ExperimentUpdateBody) = apply { - this.baseExpId = experimentUpdateBody.baseExpId - this.datasetId = experimentUpdateBody.datasetId - this.datasetVersion = experimentUpdateBody.datasetVersion - this.description = experimentUpdateBody.description - this.metadata = experimentUpdateBody.metadata - this.name = experimentUpdateBody.name - this.public_ = experimentUpdateBody.public_ - this.repoInfo = experimentUpdateBody.repoInfo - additionalProperties(experimentUpdateBody.additionalProperties) + baseExpId = experimentUpdateBody.baseExpId + datasetId = experimentUpdateBody.datasetId + datasetVersion = experimentUpdateBody.datasetVersion + description = experimentUpdateBody.description + metadata = experimentUpdateBody.metadata + name = experimentUpdateBody.name + public_ = experimentUpdateBody.public_ + repoInfo = experimentUpdateBody.repoInfo + additionalProperties = experimentUpdateBody.additionalProperties.toMutableMap() } /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ + fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ + fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) /** * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - @JsonProperty("dataset_id") - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** * Version number of the linked dataset the experiment was run against. This can be used * to reproduce the experiment after the dataset has been modified. */ - @JsonProperty("dataset_version") - fun datasetVersion(datasetVersion: String) = apply { + fun datasetVersion(datasetVersion: String?) = + datasetVersion(JsonField.ofNullable(datasetVersion)) + + /** + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.orElse(null)) + + /** + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: JsonField) = apply { this.datasetVersion = datasetVersion } /** Textual description of the experiment */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the experiment */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the experiment */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: JsonField) = apply { this.name = name } /** * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - @JsonProperty("public") fun public_(public_: Boolean) = apply { this.public_ = public_ } + fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean) = public_(public_ as Boolean?) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun public_(public_: Optional) = public_(public_.orElse(null) as Boolean?) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: JsonField) = apply { this.public_ = public_ } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ExperimentUpdateBody = ExperimentUpdateBody( baseExpId, @@ -259,73 +443,150 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ExperimentUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var experimentId: String? = null - private var baseExpId: String? = null - private var datasetId: String? = null - private var datasetVersion: String? = null - private var description: String? = null - private var metadata: Metadata? = null - private var name: String? = null - private var public_: Boolean? = null - private var repoInfo: RepoInfo? = null + private var body: ExperimentUpdateBody.Builder = ExperimentUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(experimentUpdateParams: ExperimentUpdateParams) = apply { experimentId = experimentUpdateParams.experimentId - baseExpId = experimentUpdateParams.baseExpId - datasetId = experimentUpdateParams.datasetId - datasetVersion = experimentUpdateParams.datasetVersion - description = experimentUpdateParams.description - metadata = experimentUpdateParams.metadata - name = experimentUpdateParams.name - public_ = experimentUpdateParams.public_ - repoInfo = experimentUpdateParams.repoInfo + body = experimentUpdateParams.body.toBuilder() additionalHeaders = experimentUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = experimentUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - experimentUpdateParams.additionalBodyProperties.toMutableMap() } /** Experiment id */ fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + + /** Id of default base experiment to compare against when viewing this experiment */ + fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) + + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String) = apply { this.datasetVersion = datasetVersion } + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.orElse(null)) + + /** + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. + */ + fun datasetVersion(datasetVersion: JsonField) = apply { + body.datasetVersion(datasetVersion) + } /** Textual description of the experiment */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the experiment */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the experiment */ + fun description(description: JsonField) = apply { body.description(description) } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + /** User-controlled metadata about the experiment */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: String?) = apply { body.name(name) } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the experiment. Within a project, experiment names are unique */ + fun name(name: JsonField) = apply { body.name(name) } + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: Boolean?) = apply { body.public_(public_) } /** * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - fun public_(public_: Boolean) = apply { this.public_ = public_ } + fun public_(public_: Boolean) = public_(public_ as Boolean?) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun public_(public_: Optional) = public_(public_.orElse(null) as Boolean?) + + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization + */ + fun public_(public_: JsonField) = apply { body.public_(public_) } + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + + /** Metadata about the state of the repo when the experiment was created */ + fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -425,57 +686,38 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ExperimentUpdateParams = ExperimentUpdateParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, + checkRequired("experimentId", experimentId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } /** User-controlled metadata about the experiment */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -483,29 +725,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -531,11 +779,11 @@ constructor( return true } - return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, baseExpId, datasetId, datasetVersion, description, metadata, name, public_, repoInfo, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExperimentUpdateParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index e5a4bef7..2821649e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -8,30 +8,37 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = FeedbackDatasetItem.Builder::class) @NoAutoDetect class FeedbackDatasetItem +@JsonCreator private constructor( - private val id: JsonField, - private val comment: JsonField, - private val metadata: JsonField, - private val source: JsonField, - private val tags: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("comment") + @ExcludeMissing + private val comment: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * The id of the dataset event to log feedback for. This is the row `id` returned by `POST * /v1/dataset/{dataset_id}/insert` @@ -58,37 +65,41 @@ private constructor( * The id of the dataset event to log feedback for. This is the row `id` returned by `POST * /v1/dataset/{dataset_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FeedbackDatasetItem = apply { - if (!validated) { - id() - comment() - metadata().map { it.validate() } - source() - tags() - validated = true + if (validated) { + return@apply } + + id() + comment() + metadata().ifPresent { it.validate() } + source() + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -98,23 +109,24 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FeedbackDatasetItem]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var comment: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(feedbackDatasetItem: FeedbackDatasetItem) = apply { - this.id = feedbackDatasetItem.id - this.comment = feedbackDatasetItem.comment - this.metadata = feedbackDatasetItem.metadata - this.source = feedbackDatasetItem.source - this.tags = feedbackDatasetItem.tags - additionalProperties(feedbackDatasetItem.additionalProperties) + id = feedbackDatasetItem.id + comment = feedbackDatasetItem.comment + metadata = feedbackDatasetItem.metadata + source = feedbackDatasetItem.source + tags = feedbackDatasetItem.tags.map { it.toMutableList() } + additionalProperties = feedbackDatasetItem.additionalProperties.toMutableMap() } /** @@ -127,14 +139,15 @@ private constructor( * The id of the dataset event to log feedback for. This is the row `id` returned by `POST * /v1/dataset/{dataset_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } /** An optional comment string to log about the dataset event */ - fun comment(comment: String) = comment(JsonField.of(comment)) + fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) + + /** An optional comment string to log about the dataset event */ + fun comment(comment: Optional) = comment(comment.orElse(null)) /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") - @ExcludeMissing fun comment(comment: JsonField) = apply { this.comment = comment } /** @@ -142,54 +155,82 @@ private constructor( * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: Source) = source(JsonField.of(source)) + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(source: Optional) = source(source.orElse(null)) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FeedbackDatasetItem = FeedbackDatasetItem( - id, + checkRequired("id", id), comment, metadata, source, - tags.map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -199,23 +240,26 @@ private constructor( * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -225,29 +269,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -268,50 +318,65 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ class Source @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val APP = Source(JsonField.of("app")) + @JvmField val APP = of("app") - @JvmField val API = Source(JsonField.of("api")) + @JvmField val API = of("api") - @JvmField val EXTERNAL = Source(JsonField.of("external")) + @JvmField val EXTERNAL = of("external") @JvmStatic fun of(value: String) = Source(JsonField.of(value)) } + /** An enum containing [Source]'s known values. */ enum class Known { APP, API, EXTERNAL, } + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { APP, API, EXTERNAL, + /** An enum member indicating that [Source] 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) { APP -> Value.APP @@ -320,6 +385,15 @@ private constructor( 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) { APP -> Known.APP @@ -329,6 +403,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Source && 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/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index e4613f52..9abb9867 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -8,52 +8,55 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = FeedbackExperimentItem.Builder::class) @NoAutoDetect class FeedbackExperimentItem +@JsonCreator private constructor( - private val id: JsonField, - private val scores: JsonField, - private val expected: JsonValue, - private val comment: JsonField, - private val metadata: JsonField, - private val source: JsonField, - private val tags: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("comment") + @ExcludeMissing + private val comment: JsonField = JsonMissing.of(), + @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * The id of the experiment event to log feedback for. This is the row `id` returned by `POST * /v1/experiment/{experiment_id}/insert` */ fun id(): String = id.getRequired("id") - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + /** An optional comment string to log about the experiment event */ + fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to * `output` to determine if your `output` value is correct or not */ - fun expected(): JsonValue = expected - - /** An optional comment string to log about the experiment event */ - fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it @@ -62,6 +65,12 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the experiment event + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) @@ -72,51 +81,48 @@ private constructor( * The id of the experiment event to log feedback for. This is the row `id` returned by `POST * /v1/experiment/{experiment_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the experiment event + */ + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FeedbackExperimentItem = apply { - if (!validated) { - id() - scores().map { it.validate() } - expected() - comment() - metadata().map { it.validate() } - source() - tags() - validated = true + if (validated) { + return@apply } + + id() + comment() + metadata().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + source() + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -126,27 +132,28 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FeedbackExperimentItem]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() + private var id: JsonField? = null private var comment: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(feedbackExperimentItem: FeedbackExperimentItem) = apply { - this.id = feedbackExperimentItem.id - this.scores = feedbackExperimentItem.scores - this.expected = feedbackExperimentItem.expected - this.comment = feedbackExperimentItem.comment - this.metadata = feedbackExperimentItem.metadata - this.source = feedbackExperimentItem.source - this.tags = feedbackExperimentItem.tags - additionalProperties(feedbackExperimentItem.additionalProperties) + id = feedbackExperimentItem.id + comment = feedbackExperimentItem.comment + expected = feedbackExperimentItem.expected + metadata = feedbackExperimentItem.metadata + scores = feedbackExperimentItem.scores + source = feedbackExperimentItem.source + tags = feedbackExperimentItem.tags.map { it.toMutableList() } + additionalProperties = feedbackExperimentItem.additionalProperties.toMutableMap() } /** @@ -159,93 +166,124 @@ private constructor( * The id of the experiment event to log feedback for. This is the row `id` returned by * `POST /v1/experiment/{experiment_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) + /** An optional comment string to log about the experiment event */ + fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + /** An optional comment string to log about the experiment event */ + fun comment(comment: Optional) = comment(comment.orElse(null)) + + /** An optional comment string to log about the experiment event */ + fun comment(comment: JsonField) = apply { this.comment = comment } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to * `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") - @ExcludeMissing fun expected(expected: JsonValue) = apply { this.expected = expected } - /** An optional comment string to log about the experiment event */ - fun comment(comment: String) = comment(JsonField.of(comment)) - - /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") - @ExcludeMissing - fun comment(comment: JsonField) = apply { this.comment = comment } + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event + */ + fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event + */ + fun scores(scores: Optional) = scores(scores.orElse(null)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event + */ + fun scores(scores: JsonField) = apply { this.scores = scores } + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: Source) = source(JsonField.of(source)) + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(source: Optional) = source(source.orElse(null)) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FeedbackExperimentItem = FeedbackExperimentItem( - id, - scores, - expected, + checkRequired("id", id), comment, + expected, metadata, + scores, source, - tags.map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -255,23 +293,26 @@ private constructor( * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -281,29 +322,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -328,23 +375,26 @@ private constructor( * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the * existing scores for the experiment event */ - @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect class Scores + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Scores = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -354,29 +404,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Scores]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) + additionalProperties = scores.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Scores = Scores(additionalProperties.toImmutable()) } @@ -397,50 +453,65 @@ private constructor( override fun toString() = "Scores{additionalProperties=$additionalProperties}" } + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ class Source @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val APP = Source(JsonField.of("app")) + @JvmField val APP = of("app") - @JvmField val API = Source(JsonField.of("api")) + @JvmField val API = of("api") - @JvmField val EXTERNAL = Source(JsonField.of("external")) + @JvmField val EXTERNAL = of("external") @JvmStatic fun of(value: String) = Source(JsonField.of(value)) } + /** An enum containing [Source]'s known values. */ enum class Known { APP, API, EXTERNAL, } + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { APP, API, EXTERNAL, + /** An enum member indicating that [Source] 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) { APP -> Value.APP @@ -449,6 +520,15 @@ private constructor( 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) { APP -> Known.APP @@ -458,6 +538,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -465,15 +557,15 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && scores == other.scores && expected == other.expected && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, comment, expected, metadata, scores, source, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + "FeedbackExperimentItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index a77a10aa..7f7fbb08 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -8,52 +8,55 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = FeedbackProjectLogsItem.Builder::class) @NoAutoDetect class FeedbackProjectLogsItem +@JsonCreator private constructor( - private val id: JsonField, - private val scores: JsonField, - private val expected: JsonValue, - private val comment: JsonField, - private val metadata: JsonField, - private val source: JsonField, - private val tags: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("comment") + @ExcludeMissing + private val comment: JsonField = JsonMissing.of(), + @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * The id of the project logs event to log feedback for. This is the row `id` returned by `POST * /v1/project_logs/{project_id}/insert` */ fun id(): String = id.getRequired("id") - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + /** An optional comment string to log about the project logs event */ + fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to * `output` to determine if your `output` value is correct or not */ - fun expected(): JsonValue = expected - - /** An optional comment string to log about the project logs event */ - fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it @@ -62,6 +65,12 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the project logs event + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) @@ -72,51 +81,48 @@ private constructor( * The id of the project logs event to log feedback for. This is the row `id` returned by `POST * /v1/project_logs/{project_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the project logs event + */ + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FeedbackProjectLogsItem = apply { - if (!validated) { - id() - scores().map { it.validate() } - expected() - comment() - metadata().map { it.validate() } - source() - tags() - validated = true + if (validated) { + return@apply } + + id() + comment() + metadata().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + source() + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -126,27 +132,28 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FeedbackProjectLogsItem]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() + private var id: JsonField? = null private var comment: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(feedbackProjectLogsItem: FeedbackProjectLogsItem) = apply { - this.id = feedbackProjectLogsItem.id - this.scores = feedbackProjectLogsItem.scores - this.expected = feedbackProjectLogsItem.expected - this.comment = feedbackProjectLogsItem.comment - this.metadata = feedbackProjectLogsItem.metadata - this.source = feedbackProjectLogsItem.source - this.tags = feedbackProjectLogsItem.tags - additionalProperties(feedbackProjectLogsItem.additionalProperties) + id = feedbackProjectLogsItem.id + comment = feedbackProjectLogsItem.comment + expected = feedbackProjectLogsItem.expected + metadata = feedbackProjectLogsItem.metadata + scores = feedbackProjectLogsItem.scores + source = feedbackProjectLogsItem.source + tags = feedbackProjectLogsItem.tags.map { it.toMutableList() } + additionalProperties = feedbackProjectLogsItem.additionalProperties.toMutableMap() } /** @@ -159,93 +166,124 @@ private constructor( * The id of the project logs event to log feedback for. This is the row `id` returned by * `POST /v1/project_logs/{project_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) + /** An optional comment string to log about the project logs event */ + fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + /** An optional comment string to log about the project logs event */ + fun comment(comment: Optional) = comment(comment.orElse(null)) + + /** An optional comment string to log about the project logs event */ + fun comment(comment: JsonField) = apply { this.comment = comment } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to * `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") - @ExcludeMissing fun expected(expected: JsonValue) = apply { this.expected = expected } - /** An optional comment string to log about the project logs event */ - fun comment(comment: String) = comment(JsonField.of(comment)) - - /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") - @ExcludeMissing - fun comment(comment: JsonField) = apply { this.comment = comment } + /** + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event + */ + fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event + */ + fun scores(scores: Optional) = scores(scores.orElse(null)) + + /** + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event + */ + fun scores(scores: JsonField) = apply { this.scores = scores } + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: Source) = source(JsonField.of(source)) + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + fun source(source: Optional) = source(source.orElse(null)) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - @ExcludeMissing fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FeedbackProjectLogsItem = FeedbackProjectLogsItem( - id, - scores, - expected, + checkRequired("id", id), comment, + expected, metadata, + scores, source, - tags.map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -255,23 +293,26 @@ private constructor( * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -281,29 +322,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -328,23 +375,26 @@ private constructor( * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the * existing scores for the project logs event */ - @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect class Scores + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Scores = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -354,29 +404,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Scores]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) + additionalProperties = scores.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Scores = Scores(additionalProperties.toImmutable()) } @@ -397,50 +453,65 @@ private constructor( override fun toString() = "Scores{additionalProperties=$additionalProperties}" } + /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ class Source @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val APP = Source(JsonField.of("app")) + @JvmField val APP = of("app") - @JvmField val API = Source(JsonField.of("api")) + @JvmField val API = of("api") - @JvmField val EXTERNAL = Source(JsonField.of("external")) + @JvmField val EXTERNAL = of("external") @JvmStatic fun of(value: String) = Source(JsonField.of(value)) } + /** An enum containing [Source]'s known values. */ enum class Known { APP, API, EXTERNAL, } + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { APP, API, EXTERNAL, + /** An enum member indicating that [Source] 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) { APP -> Value.APP @@ -449,6 +520,15 @@ private constructor( 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) { APP -> Known.APP @@ -458,6 +538,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -465,15 +557,15 @@ private constructor( return true } - return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && scores == other.scores && expected == other.expected && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, scores, expected, comment, metadata, source, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, comment, expected, metadata, scores, source, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + "FeedbackProjectLogsItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index 9079670a..9268d6bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -8,38 +8,43 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects -@JsonDeserialize(builder = FeedbackResponseSchema.Builder::class) @NoAutoDetect class FeedbackResponseSchema +@JsonCreator private constructor( - private val status: JsonField, - private val additionalProperties: Map, + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun status(): Status = status.getRequired("status") - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FeedbackResponseSchema = apply { - if (!validated) { - status() - validated = true + if (validated) { + return@apply } + + status() + validated = true } fun toBuilder() = Builder().from(this) @@ -49,39 +54,46 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FeedbackResponseSchema]. */ + class Builder internal constructor() { - private var status: JsonField = JsonMissing.of() + private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(feedbackResponseSchema: FeedbackResponseSchema) = apply { - this.status = feedbackResponseSchema.status - additionalProperties(feedbackResponseSchema.additionalProperties) + status = feedbackResponseSchema.status + additionalProperties = feedbackResponseSchema.additionalProperties.toMutableMap() } fun status(status: Status) = status(JsonField.of(status)) - @JsonProperty("status") - @ExcludeMissing fun status(status: JsonField) = apply { this.status = status } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FeedbackResponseSchema = - FeedbackResponseSchema(status, additionalProperties.toImmutable()) + FeedbackResponseSchema( + checkRequired("status", status), + additionalProperties.toImmutable() + ) } class Status @@ -90,42 +102,65 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val SUCCESS = Status(JsonField.of("success")) + @JvmField val SUCCESS = of("success") @JvmStatic fun of(value: String) = Status(JsonField.of(value)) } + /** An enum containing [Status]'s known values. */ enum class Known { SUCCESS, } + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { SUCCESS, + /** An enum member indicating that [Status] 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) { SUCCESS -> Value.SUCCESS 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) { SUCCESS -> Known.SUCCESS @@ -133,6 +168,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && 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/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index d921c8ca..f5b606e7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -7,25 +7,29 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = FetchDatasetEventsResponse.Builder::class) @NoAutoDetect class FetchDatasetEventsResponse +@JsonCreator private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** A list of fetched events */ fun events(): List = events.getRequired("events") @@ -38,7 +42,7 @@ private constructor( fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Pagination cursor @@ -46,18 +50,22 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the next * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FetchDatasetEventsResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + if (validated) { + return@apply } + + events().forEach { it.validate() } + cursor() + validated = true } fun toBuilder() = Builder().from(this) @@ -67,26 +75,41 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FetchDatasetEventsResponse]. */ + class Builder internal constructor() { - private var events: JsonField> = JsonMissing.of() + private var events: JsonField>? = null private var cursor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(fetchDatasetEventsResponse: FetchDatasetEventsResponse) = apply { - this.events = fetchDatasetEventsResponse.events - this.cursor = fetchDatasetEventsResponse.cursor - additionalProperties(fetchDatasetEventsResponse.additionalProperties) + events = fetchDatasetEventsResponse.events.map { it.toMutableList() } + cursor = fetchDatasetEventsResponse.cursor + additionalProperties = fetchDatasetEventsResponse.additionalProperties.toMutableMap() } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of fetched events */ + fun addEvent(event: DatasetEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(event) + } + } /** * Pagination cursor @@ -94,7 +117,15 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: String) = cursor(JsonField.of(cursor)) + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) /** * Pagination cursor @@ -102,27 +133,30 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FetchDatasetEventsResponse = FetchDatasetEventsResponse( - events.map { it.toImmutable() }, + checkRequired("events", events).map { it.toImmutable() }, cursor, additionalProperties.toImmutable(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 98314805..53fb6159 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -7,25 +7,29 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = FetchExperimentEventsResponse.Builder::class) @NoAutoDetect class FetchExperimentEventsResponse +@JsonCreator private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** A list of fetched events */ fun events(): List = events.getRequired("events") @@ -38,7 +42,7 @@ private constructor( fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Pagination cursor @@ -46,18 +50,22 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the next * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FetchExperimentEventsResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + if (validated) { + return@apply } + + events().forEach { it.validate() } + cursor() + validated = true } fun toBuilder() = Builder().from(this) @@ -67,26 +75,41 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FetchExperimentEventsResponse]. */ + class Builder internal constructor() { - private var events: JsonField> = JsonMissing.of() + private var events: JsonField>? = null private var cursor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(fetchExperimentEventsResponse: FetchExperimentEventsResponse) = apply { - this.events = fetchExperimentEventsResponse.events - this.cursor = fetchExperimentEventsResponse.cursor - additionalProperties(fetchExperimentEventsResponse.additionalProperties) + events = fetchExperimentEventsResponse.events.map { it.toMutableList() } + cursor = fetchExperimentEventsResponse.cursor + additionalProperties = fetchExperimentEventsResponse.additionalProperties.toMutableMap() } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of fetched events */ + fun addEvent(event: ExperimentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(event) + } + } /** * Pagination cursor @@ -94,7 +117,15 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: String) = cursor(JsonField.of(cursor)) + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) /** * Pagination cursor @@ -102,27 +133,30 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FetchExperimentEventsResponse = FetchExperimentEventsResponse( - events.map { it.toImmutable() }, + checkRequired("events", events).map { it.toImmutable() }, cursor, additionalProperties.toImmutable(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index e3812840..9db30ae3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -7,25 +7,29 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = FetchProjectLogsEventsResponse.Builder::class) @NoAutoDetect class FetchProjectLogsEventsResponse +@JsonCreator private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** A list of fetched events */ fun events(): List = events.getRequired("events") @@ -38,7 +42,9 @@ private constructor( fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events /** * Pagination cursor @@ -46,18 +52,22 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the next * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FetchProjectLogsEventsResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + if (validated) { + return@apply } + + events().forEach { it.validate() } + cursor() + validated = true } fun toBuilder() = Builder().from(this) @@ -67,26 +77,42 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FetchProjectLogsEventsResponse]. */ + class Builder internal constructor() { - private var events: JsonField> = JsonMissing.of() + private var events: JsonField>? = null private var cursor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(fetchProjectLogsEventsResponse: FetchProjectLogsEventsResponse) = apply { - this.events = fetchProjectLogsEventsResponse.events - this.cursor = fetchProjectLogsEventsResponse.cursor - additionalProperties(fetchProjectLogsEventsResponse.additionalProperties) + events = fetchProjectLogsEventsResponse.events.map { it.toMutableList() } + cursor = fetchProjectLogsEventsResponse.cursor + additionalProperties = + fetchProjectLogsEventsResponse.additionalProperties.toMutableMap() } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of fetched events */ + fun addEvent(event: ProjectLogsEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(event) + } + } /** * Pagination cursor @@ -94,7 +120,15 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: String) = cursor(JsonField.of(cursor)) + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** + * Pagination cursor + * + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) /** * Pagination cursor @@ -102,27 +136,30 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing fun cursor(cursor: JsonField) = apply { this.cursor = cursor } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse( - events.map { it.toImmutable() }, + checkRequired("events", events).map { it.toImmutable() }, cursor, additionalProperties.toImmutable(), ) 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 66256d5d..42e7a83b 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 @@ -10,7 +10,9 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -28,31 +30,51 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function +@JsonCreator private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val functionType: JsonField, - private val functionData: JsonField, - private val origin: JsonField, - private val functionSchema: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("function_data") + @ExcludeMissing + private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") + @ExcludeMissing + private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") @@ -63,122 +85,134 @@ private constructor( */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") + fun functionData(): FunctionData = functionData.getRequired("function_data") /** A literal 'p' which identifies the object as a project prompt */ fun logId(): LogId = logId.getRequired("log_id") + /** Name of the prompt */ + fun name(): String = name.getRequired("name") + /** Unique identifier for the organization */ fun orgId(): String = orgId.getRequired("org_id") - /** Name of the prompt */ - fun name(): String = name.getRequired("name") + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = projectId.getRequired("project_id") /** Unique identifier for the prompt */ fun slug(): String = slug.getRequired("slug") - /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - /** Date of prompt creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) - - /** A list of tags for the prompt */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) - /** User-controlled metadata about the prompt */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** JSON schema for the function's parameters and return type */ + fun functionSchema(): Optional = + Optional.ofNullable(functionSchema.getNullable("function_schema")) fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) - fun functionData(): FunctionData = functionData.getRequired("function_data") + /** User-controlled metadata about the prompt */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = - Optional.ofNullable(functionSchema.getNullable("function_schema")) + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the prompt (see the `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("function_data") + @ExcludeMissing + fun _functionData(): JsonField = functionData /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId + + /** Name of the prompt */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + /** Unique identifier for the project that the prompt belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData + /** Textual description of the prompt */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + /** JSON schema for the function's parameters and return type */ + @JsonProperty("function_schema") + @ExcludeMissing + fun _functionSchema(): JsonField = functionSchema - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("function_type") + @ExcludeMissing + fun _functionType(): JsonField = functionType - @JsonProperty("function_type") @ExcludeMissing fun _functionType() = functionType + /** User-controlled metadata about the prompt */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("function_data") @ExcludeMissing fun _functionData() = functionData + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData(): JsonField = promptData - /** JSON schema for the function's parameters and return type */ - @JsonProperty("function_schema") @ExcludeMissing fun _functionSchema() = functionSchema + /** A list of tags for the prompt */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - functionType() - functionData() - origin().map { it.validate() } - functionSchema().map { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + _xactId() + functionData().validate() + logId() + name() + orgId() + projectId() + slug() + created() + description() + functionSchema().ifPresent { it.validate() } + functionType() + metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -188,52 +222,53 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() + /** A builder for [Function]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var functionData: JsonField? = null + private var logId: JsonField? = null + private var name: JsonField? = null + private var orgId: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null private var created: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var functionSchema: JsonField = JsonMissing.of() private var functionType: JsonField = JsonMissing.of() - private var functionData: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var origin: JsonField = JsonMissing.of() - private var functionSchema: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.id = function.id - this._xactId = function._xactId - this.projectId = function.projectId - this.logId = function.logId - this.orgId = function.orgId - this.name = function.name - this.slug = function.slug - this.description = function.description - this.created = function.created - this.promptData = function.promptData - this.tags = function.tags - this.metadata = function.metadata - this.functionType = function.functionType - this.functionData = function.functionData - this.origin = function.origin - this.functionSchema = function.functionSchema - additionalProperties(function.additionalProperties) + id = function.id + _xactId = function._xactId + functionData = function.functionData + logId = function.logId + name = function.name + orgId = function.orgId + projectId = function.projectId + slug = function.slug + created = function.created + description = function.description + functionSchema = function.functionSchema + functionType = function.functionType + metadata = function.metadata + origin = function.origin + promptData = function.promptData + tags = function.tags.map { it.toMutableList() } + additionalProperties = function.additionalProperties.toMutableMap() } /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } /** * The transaction id of an event is unique to the network operation that processed the @@ -247,155 +282,177 @@ private constructor( * event insertion. Transaction ids are monotonically increasing over time and can be used * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun functionData(functionData: JsonField) = apply { + this.functionData = functionData + } + + fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) + + fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) + + fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing fun logId(logId: JsonField) = apply { this.logId = logId } + /** Name of the prompt */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the prompt */ + fun name(name: JsonField) = apply { this.name = name } + /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing fun slug(slug: JsonField) = apply { this.slug = slug } - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + /** Date of prompt creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of prompt creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: Optional) = created(created.orElse(null)) /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) + /** Textual description of the prompt */ + fun description(description: String?) = description(JsonField.ofNullable(description)) - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) + /** Textual description of the prompt */ + fun description(description: JsonField) = apply { this.description = description } - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: FunctionSchema?) = + functionSchema(JsonField.ofNullable(functionSchema)) - /** User-controlled metadata about the prompt */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.orElse(null)) - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: JsonField) = apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType) = functionType(JsonField.of(functionType)) + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) + + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) - @JsonProperty("function_type") - @ExcludeMissing fun functionType(functionType: JsonField) = apply { this.functionType = functionType } - fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + /** User-controlled metadata about the prompt */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - @JsonProperty("function_data") - @ExcludeMissing - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + /** User-controlled metadata about the prompt */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - fun origin(origin: Origin) = origin(JsonField.of(origin)) + /** User-controlled metadata about the prompt */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + + fun origin(origin: Optional) = origin(origin.orElse(null)) - @JsonProperty("origin") - @ExcludeMissing fun origin(origin: JsonField) = apply { this.origin = origin } - /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema) = - functionSchema(JsonField.of(functionSchema)) + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** JSON schema for the function's parameters and return type */ - @JsonProperty("function_schema") - @ExcludeMissing - fun functionSchema(functionSchema: JsonField) = apply { - this.functionSchema = functionSchema + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + + /** A list of tags for the prompt */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags for the prompt */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Function = Function( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("functionData", functionData), + checkRequired("logId", logId), + checkRequired("name", name), + checkRequired("orgId", orgId), + checkRequired("projectId", projectId), + checkRequired("slug", slug), created, - promptData, - tags.map { it.toImmutable() }, - metadata, + description, + functionSchema, functionType, - functionData, + metadata, origin, - functionSchema, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -410,8 +467,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun prompt(): Optional = Optional.ofNullable(prompt) fun code(): Optional = Optional.ofNullable(code) @@ -441,16 +496,29 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): FunctionData = apply { - if (!validated) { - if (prompt == null && code == null && global == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitPrompt(prompt: Prompt) { + prompt.validate() + } + + override fun visitCode(code: Code) { + code.validate() + } + + override fun visitGlobal(global: Global) { + global.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -481,6 +549,10 @@ private constructor( @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } + /** + * An interface that defines how to map each variant of [FunctionData] to a value of type + * [T]. + */ interface Visitor { fun visitPrompt(prompt: Prompt): T @@ -489,12 +561,22 @@ private constructor( fun visitGlobal(global: Global): T + /** + * Maps an unknown variant of [FunctionData] to a value of type [T]. + * + * An instance of [FunctionData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } - class Deserializer : BaseDeserializer(FunctionData::class) { + internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { val json = JsonValue.fromJsonNode(node) @@ -516,7 +598,7 @@ private constructor( } } - class Serializer : BaseSerializer(FunctionData::class) { + internal class Serializer : BaseSerializer(FunctionData::class) { override fun serialize( value: FunctionData, @@ -533,29 +615,34 @@ private constructor( } } - @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect class Prompt + @JsonCreator private constructor( - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Prompt = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -565,31 +652,29 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Prompt]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(prompt: Prompt) = apply { - this.type = prompt.type - additionalProperties(prompt.additionalProperties) + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -597,7 +682,16 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt(type, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Prompt = + Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } class Type @@ -606,42 +700,67 @@ 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 - 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() - companion object { - @JvmField val PROMPT = Type(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { PROMPT, } + /** + * 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 { PROMPT, + /** + * 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) { PROMPT -> Value.PROMPT 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) { PROMPT -> Known.PROMPT @@ -649,6 +768,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -669,35 +800,42 @@ private constructor( "Prompt{type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect class Code + @JsonCreator private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - fun data(): Data = data.getRequired("data") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Code = apply { - if (!validated) { - type() - data() - validated = true + if (validated) { + return@apply } + + data().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -707,39 +845,39 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Code]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(code: Code) = apply { - this.type = code.type - this.data = code.data - additionalProperties(code.additionalProperties) + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } + fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) + + fun data(inline: Data.Inline) = data(Data.ofInline(inline)) + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -747,10 +885,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Code = Code( - type, - data, + checkRequired("data", data), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -764,8 +910,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun bundle(): Optional = Optional.ofNullable(bundle) fun inline(): Optional = Optional.ofNullable(inline) @@ -788,14 +932,25 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): Data = apply { - if (!validated) { - if (bundle == null && inline == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - inline?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitBundle(bundle: Bundle) { + bundle.validate() + } + + override fun visitInline(inline: Inline) { + inline.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -823,25 +978,40 @@ private constructor( @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) } + /** + * An interface that defines how to map each variant of [Data] to a value of type + * [T]. + */ interface Visitor { fun visitBundle(bundle: Bundle): T fun visitInline(inline: Inline): T + /** + * Maps an unknown variant of [Data] to a value of type [T]. + * + * An instance of [Data] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Data: $json") } } - class Deserializer : BaseDeserializer(Data::class) { + internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Data(bundle = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(bundle = it, _json = json) + } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Data(inline = it, _json = json) @@ -851,7 +1021,7 @@ private constructor( } } - class Serializer : BaseSerializer(Data::class) { + internal class Serializer : BaseSerializer(Data::class) { override fun serialize( value: Data, @@ -867,26 +1037,36 @@ private constructor( } } - @JsonDeserialize(builder = Bundle.Builder::class) @NoAutoDetect class Bundle + @JsonCreator private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = + JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun bundleId(): String = bundleId.getRequired("bundle_id") + fun runtimeContext(): CodeBundle.RuntimeContext = + runtimeContext.getRequired("runtime_context") /** A preview of the code */ fun preview(): Optional = @@ -894,40 +1074,50 @@ private constructor( fun type(): Type = type.getRequired("type") - fun toCodeBundle(): CodeBundle = - CodeBundle.builder() - .runtimeContext(runtimeContext) - .location(location) - .bundleId(bundleId) - .preview(preview) - .build() - - @JsonProperty("runtime_context") + @JsonProperty("bundle_id") @ExcludeMissing - fun _runtimeContext() = runtimeContext + fun _bundleId(): JsonField = bundleId - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("runtime_context") + @ExcludeMissing + fun _runtimeContext(): JsonField = runtimeContext /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toCodeBundle(): CodeBundle = + CodeBundle.builder() + .bundleId(bundleId) + .location(location) + .runtimeContext(runtimeContext) + .preview(preview) + .build() + + private var validated: Boolean = false + fun validate(): Bundle = apply { - if (!validated) { - runtimeContext().validate() - location() - bundleId() - preview() - type() - validated = true + if (validated) { + return@apply } + + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -937,90 +1127,96 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Bundle]. */ + class Builder internal constructor() { - private var runtimeContext: JsonField = - JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var bundleId: JsonField = JsonMissing.of() + private var bundleId: JsonField? = null + private var location: JsonField? = null + private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bundle: Bundle) = apply { - this.runtimeContext = bundle.runtimeContext - this.location = bundle.location - this.bundleId = bundle.bundleId - this.preview = bundle.preview - this.type = bundle.type - additionalProperties(bundle.additionalProperties) + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() } - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - @JsonProperty("runtime_context") - @ExcludeMissing - fun runtimeContext(runtimeContext: JsonField) = - apply { - this.runtimeContext = runtimeContext - } + fun bundleId(bundleId: JsonField) = apply { + this.bundleId = bundleId + } fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - @JsonProperty("location") - @ExcludeMissing fun location(location: JsonField) = apply { this.location = location } - fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + fun location(experiment: CodeBundle.Location.Experiment) = + location(CodeBundle.Location.ofExperiment(experiment)) - @JsonProperty("bundle_id") - @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun location(function: CodeBundle.Location.Function) = + location(CodeBundle.Location.ofFunction(function)) + + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) + + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } /** A preview of the code */ - fun preview(preview: String) = preview(JsonField.of(preview)) + fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) + + /** A preview of the code */ + fun preview(preview: Optional) = preview(preview.orElse(null)) /** A preview of the code */ - @JsonProperty("preview") - @ExcludeMissing fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Bundle = Bundle( - runtimeContext, - location, - bundleId, + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), preview, - type, + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -1031,43 +1227,70 @@ 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 - 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() - companion object { - @JvmField val BUNDLE = Type(JsonField.of("bundle")) + @JvmField val BUNDLE = of("bundle") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { BUNDLE, } + /** + * 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 { BUNDLE, + /** + * 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) { BUNDLE -> Value.BUNDLE 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) { BUNDLE -> Known.BUNDLE @@ -1075,6 +1298,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1082,57 +1317,66 @@ private constructor( return true } - return /* spotless:off */ other is Bundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(bundleId, location, runtimeContext, preview, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Inline.Builder::class) @NoAutoDetect class Inline + @JsonCreator private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val code: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") + fun code(): String = code.getRequired("code") fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") - fun code(): String = code.getRequired("code") + fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing - fun _runtimeContext() = runtimeContext + fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Inline = apply { - if (!validated) { - type() - runtimeContext().validate() - code() - validated = true + if (validated) { + return@apply } + + code() + runtimeContext().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1142,96 +1386,110 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Inline]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var runtimeContext: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var runtimeContext: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inline: Inline) = apply { - this.type = inline.type - this.runtimeContext = inline.runtimeContext - this.code = inline.code - additionalProperties(inline.additionalProperties) + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) + fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun code(code: JsonField) = apply { this.code = code } fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - @JsonProperty("runtime_context") - @ExcludeMissing fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } - fun code(code: String) = code(JsonField.of(code)) + fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Inline = Inline( - type, - runtimeContext, - code, + checkRequired("code", code), + checkRequired("runtimeContext", runtimeContext), + checkRequired("type", type), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect class RuntimeContext + @JsonCreator private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): RuntimeContext = apply { - if (!validated) { - runtime() - version() - validated = true + if (validated) { + return@apply } + + runtime() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1241,32 +1499,30 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RuntimeContext]. */ + class Builder internal constructor() { - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var runtime: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { - this.runtime = runtimeContext.runtime - this.version = runtimeContext.version - additionalProperties(runtimeContext.additionalProperties) + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = + runtimeContext.additionalProperties.toMutableMap() } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - @JsonProperty("runtime") - @ExcludeMissing fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } @@ -1274,22 +1530,29 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RuntimeContext = RuntimeContext( - runtime, - version, + checkRequired("runtime", runtime), + checkRequired("version", version), additionalProperties.toImmutable(), ) } @@ -1300,41 +1563,61 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val NODE = Runtime(JsonField.of("node")) + @JvmField val NODE = of("node") - @JvmField val PYTHON = Runtime(JsonField.of("python")) + @JvmField val PYTHON = of("python") @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) } + /** An enum containing [Runtime]'s known values. */ enum class Known { NODE, PYTHON, } + /** + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Runtime] 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 { NODE, PYTHON, + /** + * An enum member indicating that [Runtime] 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) { NODE -> Value.NODE @@ -1342,6 +1625,15 @@ private constructor( 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) { NODE -> Known.NODE @@ -1353,6 +1645,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1379,50 +1683,89 @@ 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 - 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() - companion object { - @JvmField val INLINE = Type(JsonField.of("inline")) + @JvmField val INLINE = of("inline") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { INLINE, } + /** + * 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 { INLINE, + /** + * 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) { INLINE -> Value.INLINE 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) { INLINE -> Known.INLINE else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1430,17 +1773,17 @@ private constructor( return true } - return /* spotless:off */ other is Inline && type == other.type && runtimeContext == other.runtimeContext && code == other.code && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, runtimeContext, code, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, runtimeContext, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" + "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } @@ -1450,42 +1793,67 @@ 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 - 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() - companion object { - @JvmField val CODE = Type(JsonField.of("code")) + @JvmField val CODE = of("code") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { CODE, } + /** + * 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 { CODE, + /** + * 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) { CODE -> Value.CODE 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) { CODE -> Known.CODE @@ -1493,6 +1861,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1500,48 +1880,55 @@ private constructor( return true } - return /* spotless:off */ other is Code && type == other.type && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, data, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect class Global + @JsonCreator private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - fun name(): String = name.getRequired("name") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Global = apply { - if (!validated) { - type() - name() - validated = true + if (validated) { + return@apply } + + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1551,39 +1938,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Global]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(global: Global) = apply { - this.type = global.type - this.name = global.name - additionalProperties(global.additionalProperties) + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1591,10 +1974,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Global = Global( - type, - name, + checkRequired("name", name), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -1605,42 +1996,67 @@ 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 - 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() - companion object { - @JvmField val GLOBAL = Type(JsonField.of("global")) + @JvmField val GLOBAL = of("global") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { GLOBAL, } + /** + * 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 { GLOBAL, + /** + * 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) { GLOBAL -> Value.GLOBAL 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) { GLOBAL -> Known.GLOBAL @@ -1648,6 +2064,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1655,62 +2083,86 @@ private constructor( return true } - return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } + /** A literal 'p' which identifies the object as a project prompt */ class LogId @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val P = LogId(JsonField.of("p")) + @JvmField val P = of("p") @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) } + /** An enum containing [LogId]'s known values. */ enum class Known { P, } + /** + * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [LogId] 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 { P, + /** An enum member indicating that [LogId] 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) { P -> Value.P 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) { P -> Known.P @@ -1718,38 +2170,49 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** JSON schema for the function's parameters and return type */ - @JsonDeserialize(builder = FunctionSchema.Builder::class) @NoAutoDetect class FunctionSchema + @JsonCreator private constructor( - private val parameters: JsonValue, - private val returns: JsonValue, - private val additionalProperties: Map, + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonValue = JsonMissing.of(), + @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun parameters(): JsonValue = parameters - - fun returns(): JsonValue = returns - - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters - @JsonProperty("returns") @ExcludeMissing fun _returns() = returns + @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FunctionSchema = apply { - if (!validated) { - parameters() - returns() - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1759,7 +2222,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionSchema]. */ + class Builder internal constructor() { private var parameters: JsonValue = JsonMissing.of() private var returns: JsonValue = JsonMissing.of() @@ -1767,33 +2231,34 @@ private constructor( @JvmSynthetic internal fun from(functionSchema: FunctionSchema) = apply { - this.parameters = functionSchema.parameters - this.returns = functionSchema.returns - additionalProperties(functionSchema.additionalProperties) + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() } - @JsonProperty("parameters") - @ExcludeMissing fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } - @JsonProperty("returns") - @ExcludeMissing fun returns(returns: JsonValue) = apply { this.returns = returns } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionSchema = FunctionSchema( parameters, @@ -1826,33 +2291,30 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val LLM = FunctionType(JsonField.of("llm")) + @JvmField val LLM = of("llm") - @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val SCORER = of("scorer") - @JvmField val TASK = FunctionType(JsonField.of("task")) + @JvmField val TASK = of("task") - @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmField val TOOL = of("tool") @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } + /** An enum containing [FunctionType]'s known values. */ enum class Known { LLM, SCORER, @@ -1860,14 +2322,33 @@ private constructor( TOOL, } + /** + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FunctionType] 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, SCORER, TASK, TOOL, + /** + * An enum member indicating that [FunctionType] 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 @@ -1877,6 +2358,15 @@ private constructor( 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 @@ -1887,26 +2377,41 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** User-controlled metadata about the prompt */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1916,29 +2421,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -1959,53 +2470,64 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect class Origin + @JsonCreator private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val internal_: JsonField, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") + @ExcludeMissing + private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Id of the object the function is originating from */ + fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ fun objectType(): ObjectType = objectType.getRequired("object_type") - /** Id of the object the function is originating from */ - fun objectId(): String = objectId.getRequired("object_id") - /** * The function exists for internal purposes and should not be displayed in the list of * functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) - /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType - /** Id of the object the function is originating from */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @JsonProperty("internal") @ExcludeMissing fun _internal_() = internal_ + @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Origin = apply { - if (!validated) { - objectType() - objectId() - internal_() - validated = true + if (validated) { + return@apply } + + objectId() + objectType() + internal_() + validated = true } fun toBuilder() = Builder().from(this) @@ -2015,123 +2537,135 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Origin]. */ + class Builder internal constructor() { - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() + private var objectId: JsonField? = null + private var objectType: JsonField? = null private var internal_: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(origin: Origin) = apply { - this.objectType = origin.objectType - this.objectId = origin.objectId - this.internal_ = origin.internal_ - additionalProperties(origin.additionalProperties) + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() } + /** Id of the object the function is originating from */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** Id of the object the function is originating from */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing fun objectType(objectType: JsonField) = apply { this.objectType = objectType } - /** Id of the object the function is originating from */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) - /** Id of the object the function is originating from */ - @JsonProperty("object_id") - @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** * The function exists for internal purposes and should not be displayed in the list of * functions. */ - fun internal_(internal_: Boolean) = internal_(JsonField.of(internal_)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun internal_(internal_: Optional) = + internal_(internal_.orElse(null) as Boolean?) /** * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @JsonProperty("internal") - @ExcludeMissing fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Origin = Origin( - objectType, - objectId, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), internal_, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -2146,6 +2680,15 @@ private constructor( 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, @@ -2158,9 +2701,20 @@ private constructor( 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 @@ -2177,6 +2731,15 @@ private constructor( 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 @@ -2194,6 +2757,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -2201,17 +2776,17 @@ private constructor( return true } - return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, internal_, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, internal_, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" + "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -2219,15 +2794,15 @@ private constructor( return true } - return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && projectId == other.projectId && logId == other.logId && orgId == other.orgId && name == other.name && slug == other.slug && description == other.description && created == other.created && promptData == other.promptData && tags == other.tags && metadata == other.metadata && functionType == other.functionType && functionData == other.functionData && origin == other.origin && functionSchema == other.functionSchema && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && functionData == other.functionData && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && metadata == other.metadata && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, projectId, logId, orgId, name, slug, description, created, promptData, tags, metadata, functionType, functionData, origin, functionSchema, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, functionData, logId, name, orgId, projectId, slug, created, description, functionSchema, functionType, metadata, origin, promptData, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Function{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, functionData=$functionData, origin=$origin, functionSchema=$functionSchema, additionalProperties=$additionalProperties}" + "Function{id=$id, _xactId=$_xactId, functionData=$functionData, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionSchema=$functionSchema, functionType=$functionType, metadata=$metadata, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } 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 94748ae5..43ce5e69 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 @@ -10,9 +10,12 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow 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.braintrustdata.api.models.CodeBundle.* @@ -30,118 +33,213 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * Create a new function. If there is an existing function in the project with the same slug as the + * one specified in the request, will return the existing function unmodified + */ class FunctionCreateParams -constructor( - private val functionData: FunctionData, - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val functionSchema: FunctionSchema?, - private val functionType: FunctionType?, - private val origin: Origin?, - private val promptData: PromptData?, - private val tags: List?, +private constructor( + private val body: FunctionCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun functionData(): FunctionData = functionData + fun functionData(): FunctionData = body.functionData() - fun name(): String = name + /** Name of the prompt */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = body.projectId() - fun slug(): String = slug + /** Unique identifier for the prompt */ + fun slug(): String = body.slug() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the prompt */ + fun description(): Optional = body.description() - fun functionSchema(): Optional = Optional.ofNullable(functionSchema) + /** JSON schema for the function's parameters and return type */ + fun functionSchema(): Optional = body.functionSchema() + + fun functionType(): Optional = body.functionType() + + fun origin(): Optional = body.origin() + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = body.promptData() + + /** A list of tags for the prompt */ + fun tags(): Optional> = body.tags() + + fun _functionData(): JsonField = body._functionData() + + /** Name of the prompt */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the prompt belongs under */ + fun _projectId(): JsonField = body._projectId() - fun functionType(): Optional = Optional.ofNullable(functionType) + /** Unique identifier for the prompt */ + fun _slug(): JsonField = body._slug() - fun origin(): Optional = Optional.ofNullable(origin) + /** Textual description of the prompt */ + fun _description(): JsonField = body._description() - fun promptData(): Optional = Optional.ofNullable(promptData) + /** JSON schema for the function's parameters and return type */ + fun _functionSchema(): JsonField = body._functionSchema() + + fun _functionType(): JsonField = body._functionType() + + fun _origin(): JsonField = body._origin() + + /** The prompt, model, and its parameters */ + fun _promptData(): JsonField = body._promptData() - fun tags(): Optional> = Optional.ofNullable(tags) + /** A list of tags for the prompt */ + fun _tags(): JsonField> = body._tags() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): FunctionCreateBody { - return FunctionCreateBody( - functionData, - name, - projectId, - slug, - description, - functionSchema, - functionType, - origin, - promptData, - tags, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): FunctionCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = FunctionCreateBody.Builder::class) @NoAutoDetect class FunctionCreateBody + @JsonCreator internal constructor( - private val functionData: FunctionData?, - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val functionSchema: FunctionSchema?, - private val functionType: FunctionType?, - private val origin: Origin?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + @JsonProperty("function_data") + @ExcludeMissing + private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") + @ExcludeMissing + private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("function_data") fun functionData(): FunctionData? = functionData + fun functionData(): FunctionData = functionData.getRequired("function_data") + + /** Name of the prompt */ + fun name(): String = name.getRequired("name") + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Unique identifier for the prompt */ + fun slug(): String = slug.getRequired("slug") + + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(): Optional = + Optional.ofNullable(functionSchema.getNullable("function_schema")) + + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) + + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + @JsonProperty("function_data") + @ExcludeMissing + fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** JSON schema for the function's parameters and return type */ - @JsonProperty("function_schema") fun functionSchema(): FunctionSchema? = functionSchema + @JsonProperty("function_schema") + @ExcludeMissing + fun _functionSchema(): JsonField = functionSchema - @JsonProperty("function_type") fun functionType(): FunctionType? = functionType + @JsonProperty("function_type") + @ExcludeMissing + fun _functionType(): JsonField = functionType - @JsonProperty("origin") fun origin(): Origin? = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FunctionCreateBody = apply { + if (validated) { + return@apply + } + + functionData().validate() + name() + projectId() + slug() + description() + functionSchema().ifPresent { it.validate() } + functionType() + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -149,100 +247,175 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var functionData: FunctionData? = null - private var name: String? = null - private var projectId: String? = null - private var slug: String? = null - private var description: String? = null - private var functionSchema: FunctionSchema? = null - private var functionType: FunctionType? = null - private var origin: Origin? = null - private var promptData: PromptData? = null - private var tags: List? = null + /** A builder for [FunctionCreateBody]. */ + class Builder internal constructor() { + + private var functionData: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var functionSchema: JsonField = JsonMissing.of() + private var functionType: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionCreateBody: FunctionCreateBody) = apply { - this.functionData = functionCreateBody.functionData - this.name = functionCreateBody.name - this.projectId = functionCreateBody.projectId - this.slug = functionCreateBody.slug - this.description = functionCreateBody.description - this.functionSchema = functionCreateBody.functionSchema - this.functionType = functionCreateBody.functionType - this.origin = functionCreateBody.origin - this.promptData = functionCreateBody.promptData - this.tags = functionCreateBody.tags - additionalProperties(functionCreateBody.additionalProperties) + functionData = functionCreateBody.functionData + name = functionCreateBody.name + projectId = functionCreateBody.projectId + slug = functionCreateBody.slug + description = functionCreateBody.description + functionSchema = functionCreateBody.functionSchema + functionType = functionCreateBody.functionType + origin = functionCreateBody.origin + promptData = functionCreateBody.promptData + tags = functionCreateBody.tags.map { it.toMutableList() } + additionalProperties = functionCreateBody.additionalProperties.toMutableMap() } - @JsonProperty("function_data") - fun functionData(functionData: FunctionData) = apply { + fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + + fun functionData(functionData: JsonField) = apply { this.functionData = functionData } + fun functionData(prompt: FunctionData.Prompt) = + functionData(FunctionData.ofPrompt(prompt)) + + fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) + + fun functionData(global: FunctionData.Global) = + functionData(FunctionData.ofGlobal(global)) + + /** Name of the prompt */ + fun name(name: String) = name(JsonField.of(name)) + /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: JsonField) = apply { this.slug = slug } + + /** Textual description of the prompt */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the prompt */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: FunctionSchema?) = + functionSchema(JsonField.ofNullable(functionSchema)) + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.orElse(null)) /** JSON schema for the function's parameters and return type */ - @JsonProperty("function_schema") - fun functionSchema(functionSchema: FunctionSchema) = apply { + fun functionSchema(functionSchema: JsonField) = apply { this.functionSchema = functionSchema } - @JsonProperty("function_type") - fun functionType(functionType: FunctionType) = apply { + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) + + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) + + fun functionType(functionType: JsonField) = apply { this.functionType = functionType } - @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } + fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + + fun origin(origin: Optional) = origin(origin.orElse(null)) + + fun origin(origin: JsonField) = apply { this.origin = origin } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } + + /** A list of tags for the prompt */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionCreateBody = FunctionCreateBody( - checkNotNull(functionData) { "`functionData` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, + checkRequired("functionData", functionData), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("slug", slug), description, functionSchema, functionType, origin, promptData, - tags?.toImmutable(), + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -272,86 +445,128 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [FunctionCreateParams]. */ @NoAutoDetect - class Builder { - - private var functionData: FunctionData? = null - private var name: String? = null - private var projectId: String? = null - private var slug: String? = null - private var description: String? = null - private var functionSchema: FunctionSchema? = null - private var functionType: FunctionType? = null - private var origin: Origin? = null - private var promptData: PromptData? = null - private var tags: MutableList = mutableListOf() + class Builder internal constructor() { + + private var body: FunctionCreateBody.Builder = FunctionCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionCreateParams: FunctionCreateParams) = apply { - functionData = functionCreateParams.functionData - name = functionCreateParams.name - projectId = functionCreateParams.projectId - slug = functionCreateParams.slug - description = functionCreateParams.description - functionSchema = functionCreateParams.functionSchema - functionType = functionCreateParams.functionType - origin = functionCreateParams.origin - promptData = functionCreateParams.promptData - tags = functionCreateParams.tags?.toMutableList() ?: mutableListOf() + body = functionCreateParams.body.toBuilder() additionalHeaders = functionCreateParams.additionalHeaders.toBuilder() additionalQueryParams = functionCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = functionCreateParams.additionalBodyProperties.toMutableMap() } - fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } + fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } - fun functionData(prompt: FunctionData.Prompt) = apply { - this.functionData = FunctionData.ofPrompt(prompt) + fun functionData(functionData: JsonField) = apply { + body.functionData(functionData) } - fun functionData(code: FunctionData.Code) = apply { - this.functionData = FunctionData.ofCode(code) - } + fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } - fun functionData(global: FunctionData.Global) = apply { - this.functionData = FunctionData.ofGlobal(global) - } + fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + + fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + + /** Name of the prompt */ + fun name(name: String) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: JsonField) = apply { body.slug(slug) } + + /** Textual description of the prompt */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { body.description(description) } + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: FunctionSchema?) = apply { + body.functionSchema(functionSchema) + } + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.orElse(null)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema) = apply { - this.functionSchema = functionSchema + fun functionSchema(functionSchema: JsonField) = apply { + body.functionSchema(functionSchema) + } + + fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) + + fun functionType(functionType: JsonField) = apply { + body.functionType(functionType) } - fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } + fun origin(origin: Origin?) = apply { body.origin(origin) } - fun origin(origin: Origin) = apply { this.origin = origin } + fun origin(origin: Optional) = origin(origin.orElse(null)) + + fun origin(origin: JsonField) = apply { body.origin(origin) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List) = apply { - this.tags.clear() - this.tags.addAll(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun tags(tags: JsonField>) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -451,43 +666,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): FunctionCreateParams = FunctionCreateParams( - checkNotNull(functionData) { "`functionData` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionSchema, - functionType, - origin, - promptData, - tags.toImmutable().ifEmpty { null }, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -501,8 +684,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun prompt(): Optional = Optional.ofNullable(prompt) fun code(): Optional = Optional.ofNullable(code) @@ -532,16 +713,29 @@ constructor( } } + private var validated: Boolean = false + fun validate(): FunctionData = apply { - if (!validated) { - if (prompt == null && code == null && global == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitPrompt(prompt: Prompt) { + prompt.validate() + } + + override fun visitCode(code: Code) { + code.validate() + } + + override fun visitGlobal(global: Global) { + global.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -572,6 +766,10 @@ constructor( @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } + /** + * An interface that defines how to map each variant of [FunctionData] to a value of type + * [T]. + */ interface Visitor { fun visitPrompt(prompt: Prompt): T @@ -580,12 +778,22 @@ constructor( fun visitGlobal(global: Global): T + /** + * Maps an unknown variant of [FunctionData] to a value of type [T]. + * + * An instance of [FunctionData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } - class Deserializer : BaseDeserializer(FunctionData::class) { + internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { val json = JsonValue.fromJsonNode(node) @@ -607,7 +815,7 @@ constructor( } } - class Serializer : BaseSerializer(FunctionData::class) { + internal class Serializer : BaseSerializer(FunctionData::class) { override fun serialize( value: FunctionData, @@ -624,29 +832,34 @@ constructor( } } - @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect class Prompt + @JsonCreator private constructor( - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Prompt = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -656,31 +869,29 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Prompt]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(prompt: Prompt) = apply { - this.type = prompt.type - additionalProperties(prompt.additionalProperties) + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -688,7 +899,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt(type, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Prompt = + Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } class Type @@ -697,42 +917,67 @@ 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 - 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() - companion object { - @JvmField val PROMPT = Type(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { PROMPT, } + /** + * 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 { PROMPT, + /** + * 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) { PROMPT -> Value.PROMPT 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) { PROMPT -> Known.PROMPT @@ -740,6 +985,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -760,35 +1017,42 @@ constructor( "Prompt{type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect class Code + @JsonCreator private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - fun data(): Data = data.getRequired("data") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Code = apply { - if (!validated) { - type() - data() - validated = true + if (validated) { + return@apply } + + data().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -798,39 +1062,39 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Code]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(code: Code) = apply { - this.type = code.type - this.data = code.data - additionalProperties(code.additionalProperties) + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } + fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) + + fun data(inline: Data.Inline) = data(Data.ofInline(inline)) + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -838,10 +1102,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Code = Code( - type, - data, + checkRequired("data", data), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -855,8 +1127,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun bundle(): Optional = Optional.ofNullable(bundle) fun inline(): Optional = Optional.ofNullable(inline) @@ -879,14 +1149,25 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Data = apply { - if (!validated) { - if (bundle == null && inline == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - inline?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitBundle(bundle: Bundle) { + bundle.validate() + } + + override fun visitInline(inline: Inline) { + inline.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -914,25 +1195,40 @@ constructor( @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) } + /** + * An interface that defines how to map each variant of [Data] to a value of type + * [T]. + */ interface Visitor { fun visitBundle(bundle: Bundle): T fun visitInline(inline: Inline): T + /** + * Maps an unknown variant of [Data] to a value of type [T]. + * + * An instance of [Data] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Data: $json") } } - class Deserializer : BaseDeserializer(Data::class) { + internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Data(bundle = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(bundle = it, _json = json) + } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Data(inline = it, _json = json) @@ -942,7 +1238,7 @@ constructor( } } - class Serializer : BaseSerializer(Data::class) { + internal class Serializer : BaseSerializer(Data::class) { override fun serialize( value: Data, @@ -958,26 +1254,36 @@ constructor( } } - @JsonDeserialize(builder = Bundle.Builder::class) @NoAutoDetect class Bundle + @JsonCreator private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = + JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun bundleId(): String = bundleId.getRequired("bundle_id") - fun location(): Location = location.getRequired("location") + fun location(): CodeBundle.Location = location.getRequired("location") - fun bundleId(): String = bundleId.getRequired("bundle_id") + fun runtimeContext(): CodeBundle.RuntimeContext = + runtimeContext.getRequired("runtime_context") /** A preview of the code */ fun preview(): Optional = @@ -985,40 +1291,50 @@ constructor( fun type(): Type = type.getRequired("type") - fun toCodeBundle(): CodeBundle = - CodeBundle.builder() - .runtimeContext(runtimeContext) - .location(location) - .bundleId(bundleId) - .preview(preview) - .build() - - @JsonProperty("runtime_context") + @JsonProperty("bundle_id") @ExcludeMissing - fun _runtimeContext() = runtimeContext + fun _bundleId(): JsonField = bundleId - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("runtime_context") + @ExcludeMissing + fun _runtimeContext(): JsonField = runtimeContext /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toCodeBundle(): CodeBundle = + CodeBundle.builder() + .bundleId(bundleId) + .location(location) + .runtimeContext(runtimeContext) + .preview(preview) + .build() + + private var validated: Boolean = false + fun validate(): Bundle = apply { - if (!validated) { - runtimeContext().validate() - location() - bundleId() - preview() - type() - validated = true + if (validated) { + return@apply } + + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1028,87 +1344,96 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Bundle]. */ + class Builder internal constructor() { - private var runtimeContext: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var bundleId: JsonField = JsonMissing.of() + private var bundleId: JsonField? = null + private var location: JsonField? = null + private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bundle: Bundle) = apply { - this.runtimeContext = bundle.runtimeContext - this.location = bundle.location - this.bundleId = bundle.bundleId - this.preview = bundle.preview - this.type = bundle.type - additionalProperties(bundle.additionalProperties) + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - @JsonProperty("runtime_context") - @ExcludeMissing - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext + fun bundleId(bundleId: JsonField) = apply { + this.bundleId = bundleId } - fun location(location: Location) = location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = + location(JsonField.of(location)) - @JsonProperty("location") - @ExcludeMissing - fun location(location: JsonField) = apply { + fun location(location: JsonField) = apply { this.location = location } - fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + fun location(experiment: CodeBundle.Location.Experiment) = + location(CodeBundle.Location.ofExperiment(experiment)) - @JsonProperty("bundle_id") - @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun location(function: CodeBundle.Location.Function) = + location(CodeBundle.Location.ofFunction(function)) + + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) + + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } /** A preview of the code */ - fun preview(preview: String) = preview(JsonField.of(preview)) + fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) + + /** A preview of the code */ + fun preview(preview: Optional) = preview(preview.orElse(null)) /** A preview of the code */ - @JsonProperty("preview") - @ExcludeMissing fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Bundle = Bundle( - runtimeContext, - location, - bundleId, + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), preview, - type, + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -1119,43 +1444,70 @@ 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 - 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() - companion object { - @JvmField val BUNDLE = Type(JsonField.of("bundle")) + @JvmField val BUNDLE = of("bundle") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { BUNDLE, } + /** + * 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 { BUNDLE, + /** + * 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) { BUNDLE -> Value.BUNDLE 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) { BUNDLE -> Known.BUNDLE @@ -1163,6 +1515,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1170,57 +1534,66 @@ constructor( return true } - return /* spotless:off */ other is Bundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(bundleId, location, runtimeContext, preview, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Inline.Builder::class) @NoAutoDetect class Inline + @JsonCreator private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val code: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") + fun code(): String = code.getRequired("code") fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") - fun code(): String = code.getRequired("code") + fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing - fun _runtimeContext() = runtimeContext + fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Inline = apply { - if (!validated) { - type() - runtimeContext().validate() - code() - validated = true + if (validated) { + return@apply } + + code() + runtimeContext().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1230,96 +1603,110 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Inline]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var runtimeContext: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var runtimeContext: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inline: Inline) = apply { - this.type = inline.type - this.runtimeContext = inline.runtimeContext - this.code = inline.code - additionalProperties(inline.additionalProperties) + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) + fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun code(code: JsonField) = apply { this.code = code } fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - @JsonProperty("runtime_context") - @ExcludeMissing fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } - fun code(code: String) = code(JsonField.of(code)) + fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Inline = Inline( - type, - runtimeContext, - code, + checkRequired("code", code), + checkRequired("runtimeContext", runtimeContext), + checkRequired("type", type), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect class RuntimeContext + @JsonCreator private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): RuntimeContext = apply { - if (!validated) { - runtime() - version() - validated = true + if (validated) { + return@apply } + + runtime() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1329,32 +1716,30 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RuntimeContext]. */ + class Builder internal constructor() { - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var runtime: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { - this.runtime = runtimeContext.runtime - this.version = runtimeContext.version - additionalProperties(runtimeContext.additionalProperties) + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = + runtimeContext.additionalProperties.toMutableMap() } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - @JsonProperty("runtime") - @ExcludeMissing fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } @@ -1362,22 +1747,29 @@ constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RuntimeContext = RuntimeContext( - runtime, - version, + checkRequired("runtime", runtime), + checkRequired("version", version), additionalProperties.toImmutable(), ) } @@ -1388,41 +1780,61 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val NODE = Runtime(JsonField.of("node")) + @JvmField val NODE = of("node") - @JvmField val PYTHON = Runtime(JsonField.of("python")) + @JvmField val PYTHON = of("python") @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) } + /** An enum containing [Runtime]'s known values. */ enum class Known { NODE, PYTHON, } + /** + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Runtime] 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 { NODE, PYTHON, + /** + * An enum member indicating that [Runtime] 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) { NODE -> Value.NODE @@ -1430,6 +1842,15 @@ constructor( 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) { NODE -> Known.NODE @@ -1441,6 +1862,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1467,43 +1900,70 @@ 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 - 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() - companion object { - @JvmField val INLINE = Type(JsonField.of("inline")) + @JvmField val INLINE = of("inline") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { INLINE, } + /** + * 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 { INLINE, + /** + * 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) { INLINE -> Value.INLINE 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) { INLINE -> Known.INLINE @@ -1511,6 +1971,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1518,17 +1990,17 @@ constructor( return true } - return /* spotless:off */ other is Inline && type == other.type && runtimeContext == other.runtimeContext && code == other.code && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, runtimeContext, code, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, runtimeContext, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" + "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } @@ -1538,42 +2010,67 @@ 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 - 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() - companion object { - @JvmField val CODE = Type(JsonField.of("code")) + @JvmField val CODE = of("code") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { CODE, } + /** + * 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 { CODE, + /** + * 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) { CODE -> Value.CODE 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) { CODE -> Known.CODE @@ -1581,6 +2078,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1588,48 +2097,55 @@ constructor( return true } - return /* spotless:off */ other is Code && type == other.type && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, data, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect class Global + @JsonCreator private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - fun name(): String = name.getRequired("name") + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Global = apply { - if (!validated) { - type() - name() - validated = true + if (validated) { + return@apply } + + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1639,39 +2155,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Global]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(global: Global) = apply { - this.type = global.type - this.name = global.name - additionalProperties(global.additionalProperties) + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1679,10 +2191,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Global = Global( - type, - name, + checkRequired("name", name), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -1693,42 +2213,67 @@ 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 - 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() - companion object { - @JvmField val GLOBAL = Type(JsonField.of("global")) + @JvmField val GLOBAL = of("global") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { GLOBAL, } + /** + * 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 { GLOBAL, + /** + * 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) { GLOBAL -> Value.GLOBAL 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) { GLOBAL -> Known.GLOBAL @@ -1736,6 +2281,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1743,38 +2300,51 @@ constructor( return true } - return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** JSON schema for the function's parameters and return type */ - @JsonDeserialize(builder = FunctionSchema.Builder::class) @NoAutoDetect class FunctionSchema + @JsonCreator private constructor( - private val parameters: JsonValue?, - private val returns: JsonValue?, - private val additionalProperties: Map, + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonValue = JsonMissing.of(), + @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("parameters") fun parameters(): JsonValue? = parameters + @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters - @JsonProperty("returns") fun returns(): JsonValue? = returns + @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FunctionSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1782,39 +2352,43 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionSchema]. */ + class Builder internal constructor() { - private var parameters: JsonValue? = null - private var returns: JsonValue? = null + private var parameters: JsonValue = JsonMissing.of() + private var returns: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionSchema: FunctionSchema) = apply { - this.parameters = functionSchema.parameters - this.returns = functionSchema.returns - additionalProperties(functionSchema.additionalProperties) + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() } - @JsonProperty("parameters") fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } - @JsonProperty("returns") fun returns(returns: JsonValue) = apply { this.returns = returns } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionSchema = FunctionSchema( parameters, @@ -1847,33 +2421,30 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val LLM = FunctionType(JsonField.of("llm")) + @JvmField val LLM = of("llm") - @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val SCORER = of("scorer") - @JvmField val TASK = FunctionType(JsonField.of("task")) + @JvmField val TASK = of("task") - @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmField val TOOL = of("tool") @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } + /** An enum containing [FunctionType]'s known values. */ enum class Known { LLM, SCORER, @@ -1881,14 +2452,33 @@ constructor( TOOL, } + /** + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FunctionType] 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, SCORER, TASK, TOOL, + /** + * An enum member indicating that [FunctionType] 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 @@ -1898,6 +2488,15 @@ constructor( 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 @@ -1908,34 +2507,80 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect class Origin + @JsonCreator private constructor( - private val objectType: ObjectType?, - private val objectId: String?, - private val internal_: Boolean?, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") + @ExcludeMissing + private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** Id of the object the function is originating from */ + fun objectId(): String = objectId.getRequired("object_id") + /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @JsonProperty("internal") fun internal_(): Boolean? = internal_ + @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Origin = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + internal_() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1943,106 +2588,135 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Origin]. */ + class Builder internal constructor() { - private var objectType: ObjectType? = null - private var objectId: String? = null - private var internal_: Boolean? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var internal_: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(origin: Origin) = apply { - this.objectType = origin.objectType - this.objectId = origin.objectId - this.internal_ = origin.internal_ - additionalProperties(origin.additionalProperties) + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() } - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + /** Id of the object the function is originating from */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @JsonProperty("internal") - fun internal_(internal_: Boolean) = apply { this.internal_ = internal_ } + fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) + + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun internal_(internal_: Optional) = + internal_(internal_.orElse(null) as Boolean?) + + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Origin = Origin( - checkNotNull(objectType) { "`objectType` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), internal_, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -2057,6 +2731,15 @@ constructor( 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, @@ -2069,9 +2752,20 @@ constructor( 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 @@ -2088,6 +2782,15 @@ constructor( 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 @@ -2105,6 +2808,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -2112,17 +2827,17 @@ constructor( return true } - return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, internal_, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, internal_, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" + "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -2130,11 +2845,11 @@ constructor( return true } - return /* spotless:off */ other is FunctionCreateParams && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "FunctionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index fb4cf4c1..c017f44d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a function object by its id */ class FunctionDeleteParams -constructor( +private constructor( private val functionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Function id */ fun functionId(): String = functionId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [FunctionDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var functionId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): FunctionDeleteParams = FunctionDeleteParams( - checkNotNull(functionId) { "`functionId` is required but was not set" }, + checkRequired("functionId", functionId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 42017edc..c8168be4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -10,12 +10,14 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow 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.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -30,56 +32,68 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** Invoke a function. */ class FunctionInvokeParams -constructor( +private constructor( private val functionId: String, - private val input: JsonValue?, - private val messages: List?, - private val mode: Mode?, - private val parent: Parent?, - private val stream: Boolean?, - private val version: String?, + private val body: FunctionInvokeBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Function id */ fun functionId(): String = functionId - fun input(): Optional = Optional.ofNullable(input) + /** Argument to the function, which can be any JSON serializable value */ + fun _input(): JsonValue = body._input() - fun messages(): Optional> = Optional.ofNullable(messages) + /** If the function is an LLM, additional messages to pass along to it */ + fun messages(): Optional> = body.messages() - fun mode(): Optional = Optional.ofNullable(mode) + /** The mode format of the returned value (defaults to 'auto') */ + fun mode(): Optional = body.mode() - fun parent(): Optional = Optional.ofNullable(parent) + /** Options for tracing the function call */ + fun parent(): Optional = body.parent() - fun stream(): Optional = Optional.ofNullable(stream) + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. + */ + fun stream(): Optional = body.stream() - fun version(): Optional = Optional.ofNullable(version) + /** The version of the function */ + fun version(): Optional = body.version() + + /** If the function is an LLM, additional messages to pass along to it */ + fun _messages(): JsonField> = body._messages() + + /** The mode format of the returned value (defaults to 'auto') */ + fun _mode(): JsonField = body._mode() + + /** Options for tracing the function call */ + fun _parent(): JsonField = body._parent() + + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. + */ + fun _stream(): JsonField = body._stream() + + /** The version of the function */ + fun _version(): JsonField = body._version() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): FunctionInvokeBody { - return FunctionInvokeBody( - input, - messages, - mode, - parent, - stream, - version, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): FunctionInvokeBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -89,44 +103,89 @@ constructor( } /** The request to invoke a function */ - @JsonDeserialize(builder = FunctionInvokeBody.Builder::class) @NoAutoDetect class FunctionInvokeBody + @JsonCreator internal constructor( - private val input: JsonValue?, - private val messages: List?, - private val mode: Mode?, - private val parent: Parent?, - private val stream: Boolean?, - private val version: String?, - private val additionalProperties: Map, + @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), + @JsonProperty("messages") + @ExcludeMissing + private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing private val mode: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonProperty("stream") + @ExcludeMissing + private val stream: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Argument to the function, which can be any JSON serializable value */ - @JsonProperty("input") fun input(): JsonValue? = input + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + + /** If the function is an LLM, additional messages to pass along to it */ + fun messages(): Optional> = + Optional.ofNullable(messages.getNullable("messages")) + + /** The mode format of the returned value (defaults to 'auto') */ + fun mode(): Optional = Optional.ofNullable(mode.getNullable("mode")) + + /** Options for tracing the function call */ + fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) + + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. + */ + fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) + + /** The version of the function */ + fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** If the function is an LLM, additional messages to pass along to it */ - @JsonProperty("messages") fun messages(): List? = messages + @JsonProperty("messages") + @ExcludeMissing + fun _messages(): JsonField> = messages /** The mode format of the returned value (defaults to 'auto') */ - @JsonProperty("mode") fun mode(): Mode? = mode + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode /** Options for tracing the function call */ - @JsonProperty("parent") fun parent(): Parent? = parent + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent /** * Whether to stream the response. If true, results will be returned in the Braintrust SSE * format. */ - @JsonProperty("stream") fun stream(): Boolean? = stream + @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream /** The version of the function */ - @JsonProperty("version") fun version(): String? = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FunctionInvokeBody = apply { + if (validated) { + return@apply + } + + messages().ifPresent { it.forEach { it.validate() } } + mode() + parent().ifPresent { it.validate() } + stream() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -134,67 +193,148 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionInvokeBody]. */ + class Builder internal constructor() { - private var input: JsonValue? = null - private var messages: List? = null - private var mode: Mode? = null - private var parent: Parent? = null - private var stream: Boolean? = null - private var version: String? = null + private var input: JsonValue = JsonMissing.of() + private var messages: JsonField>? = null + private var mode: JsonField = JsonMissing.of() + private var parent: JsonField = JsonMissing.of() + private var stream: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionInvokeBody: FunctionInvokeBody) = apply { - this.input = functionInvokeBody.input - this.messages = functionInvokeBody.messages - this.mode = functionInvokeBody.mode - this.parent = functionInvokeBody.parent - this.stream = functionInvokeBody.stream - this.version = functionInvokeBody.version - additionalProperties(functionInvokeBody.additionalProperties) + input = functionInvokeBody.input + messages = functionInvokeBody.messages.map { it.toMutableList() } + mode = functionInvokeBody.mode + parent = functionInvokeBody.parent + stream = functionInvokeBody.stream + version = functionInvokeBody.version + additionalProperties = functionInvokeBody.additionalProperties.toMutableMap() } /** Argument to the function, which can be any JSON serializable value */ - @JsonProperty("input") fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { this.input = input } /** If the function is an LLM, additional messages to pass along to it */ - @JsonProperty("messages") - fun messages(messages: List) = apply { this.messages = messages } + fun messages(messages: List) = messages(JsonField.of(messages)) + + /** If the function is an LLM, additional messages to pass along to it */ + fun messages(messages: JsonField>) = apply { + this.messages = messages.map { it.toMutableList() } + } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(message: Message) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(message) + } + } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(assistant: Message.Assistant) = + addMessage(Message.ofAssistant(assistant)) + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(function: Message.Function) = addMessage(Message.ofFunction(function)) + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(fallback: Message.Fallback) = addMessage(Message.ofFallback(fallback)) + + /** The mode format of the returned value (defaults to 'auto') */ + fun mode(mode: Mode?) = mode(JsonField.ofNullable(mode)) + + /** The mode format of the returned value (defaults to 'auto') */ + fun mode(mode: Optional) = mode(mode.orElse(null)) /** The mode format of the returned value (defaults to 'auto') */ - @JsonProperty("mode") fun mode(mode: Mode) = apply { this.mode = mode } + fun mode(mode: JsonField) = apply { this.mode = mode } + + /** Options for tracing the function call */ + fun parent(parent: Parent) = parent(JsonField.of(parent)) /** Options for tracing the function call */ - @JsonProperty("parent") fun parent(parent: Parent) = apply { this.parent = parent } + fun parent(parent: JsonField) = apply { this.parent = parent } + + /** Span parent properties */ + fun parent(spanParentStruct: Parent.SpanParentStruct) = + parent(Parent.ofSpanParentStruct(spanParentStruct)) + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun parent(string: String) = parent(Parent.ofString(string)) + + /** + * Whether to stream the response. If true, results will be returned in the Braintrust + * SSE format. + */ + fun stream(stream: Boolean?) = stream(JsonField.ofNullable(stream)) + + /** + * Whether to stream the response. If true, results will be returned in the Braintrust + * SSE format. + */ + fun stream(stream: Boolean) = stream(stream as Boolean?) + + /** + * Whether to stream the response. If true, results will be returned in the Braintrust + * SSE format. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun stream(stream: Optional) = stream(stream.orElse(null) as Boolean?) /** * Whether to stream the response. If true, results will be returned in the Braintrust * SSE format. */ - @JsonProperty("stream") fun stream(stream: Boolean) = apply { this.stream = stream } + fun stream(stream: JsonField) = apply { this.stream = stream } /** The version of the function */ - @JsonProperty("version") fun version(version: String) = apply { this.version = version } + fun version(version: String) = version(JsonField.of(version)) + + /** The version of the function */ + fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionInvokeBody = FunctionInvokeBody( input, - messages?.toImmutable(), + (messages ?: JsonMissing.of()).map { it.toImmutable() }, mode, parent, stream, @@ -228,71 +368,128 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [FunctionInvokeParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var functionId: String? = null - private var input: JsonValue? = null - private var messages: MutableList = mutableListOf() - private var mode: Mode? = null - private var parent: Parent? = null - private var stream: Boolean? = null - private var version: String? = null + private var body: FunctionInvokeBody.Builder = FunctionInvokeBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionInvokeParams: FunctionInvokeParams) = apply { functionId = functionInvokeParams.functionId - input = functionInvokeParams.input - messages = functionInvokeParams.messages?.toMutableList() ?: mutableListOf() - mode = functionInvokeParams.mode - parent = functionInvokeParams.parent - stream = functionInvokeParams.stream - version = functionInvokeParams.version + body = functionInvokeParams.body.toBuilder() additionalHeaders = functionInvokeParams.additionalHeaders.toBuilder() additionalQueryParams = functionInvokeParams.additionalQueryParams.toBuilder() - additionalBodyProperties = functionInvokeParams.additionalBodyProperties.toMutableMap() } /** Function id */ fun functionId(functionId: String) = apply { this.functionId = functionId } /** Argument to the function, which can be any JSON serializable value */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { body.input(input) } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: List) = apply { - this.messages.clear() - this.messages.addAll(messages) - } + fun messages(messages: List) = apply { body.messages(messages) } + + /** If the function is an LLM, additional messages to pass along to it */ + fun messages(messages: JsonField>) = apply { body.messages(messages) } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(message: Message) = apply { body.addMessage(message) } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(system: Message.System) = apply { body.addMessage(system) } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(user: Message.User) = apply { body.addMessage(user) } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(assistant: Message.Assistant) = apply { body.addMessage(assistant) } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(tool: Message.Tool) = apply { body.addMessage(tool) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: Message) = apply { this.messages.add(message) } + fun addMessage(function: Message.Function) = apply { body.addMessage(function) } + + /** If the function is an LLM, additional messages to pass along to it */ + fun addMessage(fallback: Message.Fallback) = apply { body.addMessage(fallback) } + + /** The mode format of the returned value (defaults to 'auto') */ + fun mode(mode: Mode?) = apply { body.mode(mode) } /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: Mode) = apply { this.mode = mode } + fun mode(mode: Optional) = mode(mode.orElse(null)) + + /** The mode format of the returned value (defaults to 'auto') */ + fun mode(mode: JsonField) = apply { body.mode(mode) } /** Options for tracing the function call */ - fun parent(parent: Parent) = apply { this.parent = parent } + fun parent(parent: Parent) = apply { body.parent(parent) } /** Options for tracing the function call */ + fun parent(parent: JsonField) = apply { body.parent(parent) } + + /** Span parent properties */ fun parent(spanParentStruct: Parent.SpanParentStruct) = apply { - this.parent = Parent.ofSpanParentStruct(spanParentStruct) + body.parent(spanParentStruct) } - /** Options for tracing the function call */ - fun parent(string: String) = apply { this.parent = Parent.ofString(string) } + /** The parent's span identifier, created by calling `.export()` on a span */ + fun parent(string: String) = apply { body.parent(string) } + + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. + */ + fun stream(stream: Boolean?) = apply { body.stream(stream) } + + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. + */ + fun stream(stream: Boolean) = stream(stream as Boolean?) + + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun stream(stream: Optional) = stream(stream.orElse(null) as Boolean?) /** * Whether to stream the response. If true, results will be returned in the Braintrust SSE * format. */ - fun stream(stream: Boolean) = apply { this.stream = stream } + fun stream(stream: JsonField) = apply { body.stream(stream) } + + /** The version of the function */ + fun version(version: String) = apply { body.version(version) } /** The version of the function */ - fun version(version: String) = apply { this.version = version } + fun version(version: JsonField) = apply { body.version(version) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -392,40 +589,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): FunctionInvokeParams = FunctionInvokeParams( - checkNotNull(functionId) { "`functionId` is required but was not set" }, - input, - messages.toImmutable().ifEmpty { null }, - mode, - parent, - stream, - version, + checkRequired("functionId", functionId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -442,8 +611,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun system(): Optional = Optional.ofNullable(system) fun user(): Optional = Optional.ofNullable(user) @@ -494,26 +661,41 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Message = apply { - if (!validated) { - if ( - system == null && - user == null && - assistant == null && - tool == null && - function == null && - fallback == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - system?.validate() - user?.validate() - assistant?.validate() - tool?.validate() - function?.validate() - fallback?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitSystem(system: System) { + system.validate() + } + + override fun visitUser(user: User) { + user.validate() + } + + override fun visitAssistant(assistant: Assistant) { + assistant.validate() + } + + override fun visitTool(tool: Tool) { + tool.validate() + } + + override fun visitFunction(function: Function) { + function.validate() + } + + override fun visitFallback(fallback: Fallback) { + fallback.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -553,6 +735,9 @@ constructor( @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } + /** + * An interface that defines how to map each variant of [Message] to a value of type [T]. + */ interface Visitor { fun visitSystem(system: System): T @@ -567,12 +752,22 @@ constructor( fun visitFallback(fallback: Fallback): T + /** + * Maps an unknown variant of [Message] to a value of type [T]. + * + * An instance of [Message] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Message: $json") } } - class Deserializer : BaseDeserializer(Message::class) { + internal class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { val json = JsonValue.fromJsonNode(node) @@ -606,7 +801,7 @@ constructor( } } - class Serializer : BaseSerializer(Message::class) { + internal class Serializer : BaseSerializer(Message::class) { override fun serialize( value: Message, @@ -626,41 +821,50 @@ constructor( } } - @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect class System + @JsonCreator private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun role(): Role = role.getRequired("role") - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): System = apply { - if (!validated) { - content() - role() - name() - validated = true + if (validated) { + return@apply } + + role() + content() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -670,47 +874,41 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [System]. */ + class Builder internal constructor() { + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(system: System) = apply { - this.content = system.content - this.role = system.role - this.name = system.name - additionalProperties(system.additionalProperties) + role = system.role + content = system.content + name = system.name + additionalProperties = system.additionalProperties.toMutableMap() } - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } + fun content(content: String) = content(JsonField.of(content)) + + fun content(content: JsonField) = apply { this.content = content } + fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -718,10 +916,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): System = System( + checkRequired("role", role), content, - role, name, additionalProperties.toImmutable(), ) @@ -733,42 +939,67 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val SYSTEM = Role(JsonField.of("system")) + @JvmField val SYSTEM = of("system") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { SYSTEM, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { SYSTEM, + /** + * An enum member indicating that [Role] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ fun value(): Value = when (this) { SYSTEM -> Value.SYSTEM 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) { SYSTEM -> Known.SYSTEM @@ -776,6 +1007,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -783,54 +1026,63 @@ constructor( return true } - return /* spotless:off */ other is System && content == other.content && role == other.role && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(content, role, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(role, content, name, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect class User + @JsonCreator private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun role(): Role = role.getRequired("role") - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): User = apply { - if (!validated) { - content() - role() - name() - validated = true + if (validated) { + return@apply } + + role() + content().ifPresent { it.validate() } + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -840,47 +1092,46 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [User]. */ + class Builder internal constructor() { + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(user: User) = apply { - this.content = user.content - this.role = user.role - this.name = user.name - additionalProperties(user.additionalProperties) + role = user.role + content = user.content + name = user.name + additionalProperties = user.additionalProperties.toMutableMap() } + fun role(role: Role) = role(JsonField.of(role)) + + fun role(role: JsonField) = apply { this.role = role } + fun content(content: Content) = content(JsonField.of(content)) - @JsonProperty("content") - @ExcludeMissing fun content(content: JsonField) = apply { this.content = content } - fun role(role: Role) = role(JsonField.of(role)) + fun content(text: String) = content(Content.ofText(text)) - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } + fun contentOfArray(array: List) = + content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -888,10 +1139,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): User = User( + checkRequired("role", role), content, - role, name, additionalProperties.toImmutable(), ) @@ -903,42 +1162,67 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val USER = Role(JsonField.of("user")) + @JvmField val USER = of("user") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { USER, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { USER, + /** + * An enum member indicating that [Role] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ fun value(): Value = when (this) { USER -> Value.USER 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) { USER -> Known.USER @@ -946,6 +1230,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } @JsonDeserialize(using = Content.Deserializer::class) @@ -957,8 +1253,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun text(): Optional = Optional.ofNullable(text) fun array(): Optional> = Optional.ofNullable(array) @@ -981,13 +1275,23 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Content = apply { - if (!validated) { - if (text == null && array == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitText(text: String) {} + + override fun visitArray(array: List) { + array.forEach { it.validate() } + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -1016,18 +1320,32 @@ constructor( fun ofArray(array: List) = Content(array = array) } + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ interface Visitor { fun visitText(text: String): T fun visitArray(array: List): T + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Content: $json") } } - class Deserializer : BaseDeserializer(Content::class) { + internal class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { val json = JsonValue.fromJsonNode(node) @@ -1035,7 +1353,9 @@ constructor( tryDeserialize(node, jacksonTypeRef())?.let { return Content(text = it, _json = json) } - tryDeserialize(node, jacksonTypeRef>()) + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } ?.let { return Content(array = it, _json = json) } @@ -1044,7 +1364,7 @@ constructor( } } - class Serializer : BaseSerializer(Content::class) { + internal class Serializer : BaseSerializer(Content::class) { override fun serialize( value: Content, @@ -1064,63 +1384,53 @@ constructor( @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) class ChatCompletionContentPart private constructor( - private val chatCompletionContentPartText: ChatCompletionContentPartText? = - null, - private val chatCompletionContentPartImage: ChatCompletionContentPartImage? = - null, + private val text: ChatCompletionContentPartText? = null, + private val image: ChatCompletionContentPartImage? = null, private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - - fun chatCompletionContentPartText(): Optional = - Optional.ofNullable(chatCompletionContentPartText) + fun text(): Optional = Optional.ofNullable(text) - fun chatCompletionContentPartImage(): Optional = - Optional.ofNullable(chatCompletionContentPartImage) + fun image(): Optional = + Optional.ofNullable(image) - fun isChatCompletionContentPartText(): Boolean = - chatCompletionContentPartText != null + fun isText(): Boolean = text != null - fun isChatCompletionContentPartImage(): Boolean = - chatCompletionContentPartImage != null + fun isImage(): Boolean = image != null - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow("chatCompletionContentPartText") + fun asText(): ChatCompletionContentPartText = text.getOrThrow("text") - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow("chatCompletionContentPartImage") + fun asImage(): ChatCompletionContentPartImage = image.getOrThrow("image") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText( - chatCompletionContentPartText - ) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage( - chatCompletionContentPartImage - ) + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) else -> visitor.unknown(_json) } } + private var validated: Boolean = false + fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && - chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitText(text: ChatCompletionContentPartText) { + text.validate() + } + + override fun visitImage(image: ChatCompletionContentPartImage) { + image.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -1128,17 +1438,15 @@ constructor( return true } - return /* spotless:off */ other is ChatCompletionContentPart && chatCompletionContentPartText == other.chatCompletionContentPartText && chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, image) /* spotless:on */ override fun toString(): String = when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + text != null -> "ChatCompletionContentPart{text=$text}" + image != null -> "ChatCompletionContentPart{image=$image}" _json != null -> "ChatCompletionContentPart{_unknown=$_json}" else -> throw IllegalStateException("Invalid ChatCompletionContentPart") } @@ -1146,32 +1454,35 @@ constructor( companion object { @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = chatCompletionContentPartText - ) + fun ofText(text: ChatCompletionContentPartText) = + ChatCompletionContentPart(text = text) @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = chatCompletionContentPartImage - ) + fun ofImage(image: ChatCompletionContentPartImage) = + ChatCompletionContentPart(image = image) } + /** + * An interface that defines how to map each variant of + * [ChatCompletionContentPart] to a value of type [T]. + */ interface Visitor { - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - + fun visitText(text: ChatCompletionContentPartText): T + + fun visitImage(image: ChatCompletionContentPartImage): T + + /** + * Maps an unknown variant of [ChatCompletionContentPart] to a value of type + * [T]. + * + * An instance of [ChatCompletionContentPart] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. + * For example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException( "Unknown ChatCompletionContentPart: $json" @@ -1179,7 +1490,7 @@ constructor( } } - class Deserializer : + internal class Deserializer : BaseDeserializer( ChatCompletionContentPart::class ) { @@ -1193,26 +1504,20 @@ constructor( it.validate() } ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartText = it, - _json = json - ) + return ChatCompletionContentPart(text = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return ChatCompletionContentPart( - chatCompletionContentPartImage = it, - _json = json - ) + return ChatCompletionContentPart(image = it, _json = json) } return ChatCompletionContentPart(_json = json) } } - class Serializer : + internal class Serializer : BaseSerializer( ChatCompletionContentPart::class ) { @@ -1223,10 +1528,8 @@ constructor( provider: SerializerProvider ) { when { - value.chatCompletionContentPartText != null -> - generator.writeObject(value.chatCompletionContentPartText) - value.chatCompletionContentPartImage != null -> - generator.writeObject(value.chatCompletionContentPartImage) + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ChatCompletionContentPart") @@ -1241,33 +1544,43 @@ constructor( return true } - return /* spotless:off */ other is User && content == other.content && role == other.role && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(content, role, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(role, content, name, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect class Assistant + @JsonCreator private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tool_calls") + @ExcludeMissing + private val toolCalls: JsonField> = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) @@ -1280,29 +1593,37 @@ constructor( fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall + @JsonProperty("function_call") + @ExcludeMissing + fun _functionCall(): JsonField = functionCall - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") + @ExcludeMissing + fun _toolCalls(): JsonField> = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Assistant = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + if (validated) { + return@apply } + + role() + content() + functionCall().ifPresent { it.validate() } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true } fun toBuilder() = Builder().from(this) @@ -1312,70 +1633,82 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Assistant]. */ + class Builder internal constructor() { - private var role: JsonField = JsonMissing.of() + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = - JsonMissing.of() + private var toolCalls: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(assistant: Assistant) = apply { - this.role = assistant.role - this.content = assistant.content - this.functionCall = assistant.functionCall - this.name = assistant.name - this.toolCalls = assistant.toolCalls - additionalProperties(assistant.additionalProperties) + role = assistant.role + content = assistant.content + functionCall = assistant.functionCall + name = assistant.name + toolCalls = assistant.toolCalls.map { it.toMutableList() } + additionalProperties = assistant.additionalProperties.toMutableMap() } fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } - fun content(content: String) = content(JsonField.of(content)) + fun content(content: String?) = content(JsonField.ofNullable(content)) + + fun content(content: Optional) = content(content.orElse(null)) - @JsonProperty("content") - @ExcludeMissing fun content(content: JsonField) = apply { this.content = content } - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall?) = + functionCall(JsonField.ofNullable(functionCall)) + + fun functionCall(functionCall: Optional) = + functionCall(functionCall.orElse(null)) - @JsonProperty("function_call") - @ExcludeMissing fun functionCall(functionCall: JsonField) = apply { this.functionCall = functionCall } - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List?) = + toolCalls(JsonField.ofNullable(toolCalls)) + + fun toolCalls(toolCalls: Optional>) = + toolCalls(toolCalls.orElse(null)) - @JsonProperty("tool_calls") - @ExcludeMissing fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls + this.toolCalls = toolCalls.map { it.toMutableList() } + } + + fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { + toolCalls = + (toolCalls ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(toolCall) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1383,13 +1716,21 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Assistant = Assistant( - role, + checkRequired("role", role), content, functionCall, name, - toolCalls.map { it.toImmutable() }, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -1400,42 +1741,67 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) + @JvmField val ASSISTANT = of("assistant") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { ASSISTANT, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] 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 { ASSISTANT, + /** + * An enum member indicating that [Role] 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) { ASSISTANT -> Value.ASSISTANT 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) { ASSISTANT -> Known.ASSISTANT @@ -1443,37 +1809,58 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect class FunctionCall + @JsonCreator private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("arguments") + @ExcludeMissing + private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true + if (validated) { + return@apply } + + arguments() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1483,41 +1870,37 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionCall]. */ + class Builder internal constructor() { - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var arguments: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) + arguments = functionCall.arguments + name = functionCall.name + additionalProperties = functionCall.additionalProperties.toMutableMap() } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - @JsonProperty("arguments") - @ExcludeMissing fun arguments(arguments: JsonField) = apply { this.arguments = arguments } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1525,10 +1908,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionCall = FunctionCall( - arguments, - name, + checkRequired("arguments", arguments), + checkRequired("name", name), additionalProperties.toImmutable(), ) } @@ -1569,42 +1960,53 @@ constructor( "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect class Tool + @JsonCreator private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + private val toolCallId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId(): JsonField = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Tool = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true + if (validated) { + return@apply } + + role() + content() + toolCallId() + validated = true } fun toBuilder() = Builder().from(this) @@ -1614,49 +2016,43 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Tool]. */ + class Builder internal constructor() { + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tool: Tool) = apply { - this.content = tool.content - this.role = tool.role - this.toolCallId = tool.toolCallId - additionalProperties(tool.additionalProperties) + role = tool.role + content = tool.content + toolCallId = tool.toolCallId + additionalProperties = tool.additionalProperties.toMutableMap() } - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } + fun content(content: String) = content(JsonField.of(content)) + + fun content(content: JsonField) = apply { this.content = content } + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - @JsonProperty("tool_call_id") - @ExcludeMissing fun toolCallId(toolCallId: JsonField) = apply { this.toolCallId = toolCallId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1664,10 +2060,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Tool = Tool( + checkRequired("role", role), content, - role, toolCallId, additionalProperties.toImmutable(), ) @@ -1679,42 +2083,67 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val TOOL = Role(JsonField.of("tool")) + @JvmField val TOOL = of("tool") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { TOOL, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] 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 { TOOL, + /** + * An enum member indicating that [Role] 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) { 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) { TOOL -> Known.TOOL @@ -1722,6 +2151,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1729,54 +2170,63 @@ constructor( return true } - return /* spotless:off */ other is Tool && content == other.content && role == other.role && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(content, role, toolCallId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(role, content, toolCallId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function + @JsonCreator private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") @ExcludeMissing fun _content() = content + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - content() - name() - role() - validated = true + if (validated) { + return@apply } + + name() + role() + content() + validated = true } fun toBuilder() = Builder().from(this) @@ -1786,47 +2236,41 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Function]. */ + class Builder internal constructor() { + private var name: JsonField? = null + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.content = function.content - this.name = function.name - this.role = function.role - additionalProperties(function.additionalProperties) + name = function.name + role = function.role + content = function.content + additionalProperties = function.additionalProperties.toMutableMap() } - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } + fun content(content: String) = content(JsonField.of(content)) + + fun content(content: JsonField) = apply { this.content = content } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1834,11 +2278,19 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Function = Function( + checkRequired("name", name), + checkRequired("role", role), content, - name, - role, additionalProperties.toImmutable(), ) } @@ -1849,42 +2301,67 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val FUNCTION = Role(JsonField.of("function")) + @JvmField val FUNCTION = of("function") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { FUNCTION, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] 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 { FUNCTION, + /** + * An enum member indicating that [Role] 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) { 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) { FUNCTION -> Known.FUNCTION @@ -1892,6 +2369,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1899,48 +2388,55 @@ constructor( return true } - return /* spotless:off */ other is Function && content == other.content && name == other.name && role == other.role && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(content, name, role, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, role, content, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect class Fallback + @JsonCreator private constructor( - private val role: JsonField, - private val content: JsonField, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Fallback = apply { - if (!validated) { - role() - content() - validated = true + if (validated) { + return@apply } + + role() + content() + validated = true } fun toBuilder() = Builder().from(this) @@ -1950,39 +2446,37 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Fallback]. */ + class Builder internal constructor() { - private var role: JsonField = JsonMissing.of() + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(fallback: Fallback) = apply { - this.role = fallback.role - this.content = fallback.content - additionalProperties(fallback.additionalProperties) + role = fallback.role + content = fallback.content + additionalProperties = fallback.additionalProperties.toMutableMap() } fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } - fun content(content: String) = content(JsonField.of(content)) + fun content(content: String?) = content(JsonField.ofNullable(content)) + + fun content(content: Optional) = content(content.orElse(null)) - @JsonProperty("content") - @ExcludeMissing fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1990,9 +2484,17 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Fallback = Fallback( - role, + checkRequired("role", role), content, additionalProperties.toImmutable(), ) @@ -2004,42 +2506,67 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val MODEL = Role(JsonField.of("model")) + @JvmField val MODEL = of("model") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { MODEL, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] 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 { MODEL, + /** + * An enum member indicating that [Role] 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) { MODEL -> Value.MODEL 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) { MODEL -> Known.MODEL @@ -2047,6 +2574,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2068,46 +2607,61 @@ constructor( } } + /** The mode format of the returned value (defaults to 'auto') */ class Mode @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val AUTO = Mode(JsonField.of("auto")) + @JvmField val AUTO = of("auto") - @JvmField val PARALLEL = Mode(JsonField.of("parallel")) + @JvmField val PARALLEL = of("parallel") @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) } + /** An enum containing [Mode]'s known values. */ enum class Known { AUTO, PARALLEL, } + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Mode] 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 { AUTO, PARALLEL, + /** An enum member indicating that [Mode] 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) { AUTO -> Value.AUTO @@ -2115,6 +2669,15 @@ constructor( 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) { AUTO -> Known.AUTO @@ -2123,8 +2686,21 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } + /** Options for tracing the function call */ @JsonDeserialize(using = Parent.Deserializer::class) @JsonSerialize(using = Parent.Serializer::class) class Parent @@ -2134,10 +2710,9 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** Span parent properties */ fun spanParentStruct(): Optional = Optional.ofNullable(spanParentStruct) + /** The parent's span identifier, created by calling `.export()` on a span */ fun string(): Optional = Optional.ofNullable(string) @@ -2145,8 +2720,10 @@ constructor( fun isString(): Boolean = string != null + /** Span parent properties */ fun asSpanParentStruct(): SpanParentStruct = spanParentStruct.getOrThrow("spanParentStruct") + /** The parent's span identifier, created by calling `.export()` on a span */ fun asString(): String = string.getOrThrow("string") fun _json(): Optional = Optional.ofNullable(_json) @@ -2159,14 +2736,23 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Parent = apply { - if (!validated) { - if (spanParentStruct == null && string == null) { - throw BraintrustInvalidDataException("Unknown Parent: $_json") - } - spanParentStruct?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitSpanParentStruct(spanParentStruct: SpanParentStruct) { + spanParentStruct.validate() + } + + override fun visitString(string: String) {} + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -2189,25 +2775,40 @@ constructor( companion object { + /** Span parent properties */ @JvmStatic fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = Parent(spanParentStruct = spanParentStruct) + /** The parent's span identifier, created by calling `.export()` on a span */ @JvmStatic fun ofString(string: String) = Parent(string = string) } + /** An interface that defines how to map each variant of [Parent] to a value of type [T]. */ interface Visitor { + /** Span parent properties */ fun visitSpanParentStruct(spanParentStruct: SpanParentStruct): T + /** The parent's span identifier, created by calling `.export()` on a span */ fun visitString(string: String): T + /** + * Maps an unknown variant of [Parent] to a value of type [T]. + * + * An instance of [Parent] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Parent: $json") } } - class Deserializer : BaseDeserializer(Parent::class) { + internal class Deserializer : BaseDeserializer(Parent::class) { override fun ObjectCodec.deserialize(node: JsonNode): Parent { val json = JsonValue.fromJsonNode(node) @@ -2224,7 +2825,7 @@ constructor( } } - class Serializer : BaseSerializer(Parent::class) { + internal class Serializer : BaseSerializer(Parent::class) { override fun serialize( value: Parent, @@ -2241,56 +2842,69 @@ constructor( } /** Span parent properties */ - @JsonDeserialize(builder = SpanParentStruct.Builder::class) @NoAutoDetect class SpanParentStruct + @JsonCreator private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val rowIds: JsonField, - private val propagatedEvent: JsonField, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("propagated_event") + @ExcludeMissing + private val propagatedEvent: JsonField = JsonMissing.of(), + @JsonProperty("row_ids") + @ExcludeMissing + private val rowIds: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun objectType(): ObjectType = objectType.getRequired("object_type") - /** The id of the container object you are logging to */ fun objectId(): String = objectId.getRequired("object_id") - /** Identifiers for the row to to log a subspan under */ - fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) + fun objectType(): ObjectType = objectType.getRequired("object_type") /** Include these properties in every span created under this parent */ fun propagatedEvent(): Optional = Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + /** Identifiers for the row to to log a subspan under */ + fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) /** The id of the container object you are logging to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** Identifiers for the row to to log a subspan under */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** Include these properties in every span created under this parent */ @JsonProperty("propagated_event") @ExcludeMissing - fun _propagatedEvent() = propagatedEvent + fun _propagatedEvent(): JsonField = propagatedEvent + + /** Identifiers for the row to to log a subspan under */ + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField = rowIds @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): SpanParentStruct = apply { - if (!validated) { - objectType() - objectId() - rowIds().map { it.validate() } - propagatedEvent().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objectId() + objectType() + propagatedEvent().ifPresent { it.validate() } + rowIds().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -2300,66 +2914,65 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SpanParentStruct]. */ + class Builder internal constructor() { - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var rowIds: JsonField = JsonMissing.of() + private var objectId: JsonField? = null + private var objectType: JsonField? = null private var propagatedEvent: JsonField = JsonMissing.of() + private var rowIds: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(spanParentStruct: SpanParentStruct) = apply { - this.objectType = spanParentStruct.objectType - this.objectId = spanParentStruct.objectId - this.rowIds = spanParentStruct.rowIds - this.propagatedEvent = spanParentStruct.propagatedEvent - additionalProperties(spanParentStruct.additionalProperties) - } - - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType + objectId = spanParentStruct.objectId + objectType = spanParentStruct.objectType + propagatedEvent = spanParentStruct.propagatedEvent + rowIds = spanParentStruct.rowIds + additionalProperties = spanParentStruct.additionalProperties.toMutableMap() } /** The id of the container object you are logging to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the container object you are logging to */ - @JsonProperty("object_id") - @ExcludeMissing fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - /** Identifiers for the row to to log a subspan under */ - fun rowIds(rowIds: RowIds) = rowIds(JsonField.of(rowIds)) + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - /** Identifiers for the row to to log a subspan under */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: PropagatedEvent) = - propagatedEvent(JsonField.of(propagatedEvent)) + fun propagatedEvent(propagatedEvent: PropagatedEvent?) = + propagatedEvent(JsonField.ofNullable(propagatedEvent)) + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(propagatedEvent: Optional) = + propagatedEvent(propagatedEvent.orElse(null)) /** Include these properties in every span created under this parent */ - @JsonProperty("propagated_event") - @ExcludeMissing fun propagatedEvent(propagatedEvent: JsonField) = apply { this.propagatedEvent = propagatedEvent } + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: Optional) = rowIds(rowIds.orElse(null)) + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2367,12 +2980,20 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): SpanParentStruct = SpanParentStruct( - objectType, - objectId, - rowIds, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), propagatedEvent, + rowIds, additionalProperties.toImmutable(), ) } @@ -2383,40 +3004,57 @@ 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 - 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() - companion object { - @JvmField val PROJECT_LOGS = ObjectType(JsonField.of("project_logs")) + @JvmField val PROJECT_LOGS = of("project_logs") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) } + /** An enum containing [ObjectType]'s known values. */ enum class Known { PROJECT_LOGS, EXPERIMENT, } + /** + * 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 { PROJECT_LOGS, EXPERIMENT, + /** + * 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) { PROJECT_LOGS -> Value.PROJECT_LOGS @@ -2424,6 +3062,15 @@ constructor( 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) { PROJECT_LOGS -> Known.PROJECT_LOGS @@ -2432,26 +3079,41 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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() } /** Include these properties in every span created under this parent */ - @JsonDeserialize(builder = PropagatedEvent.Builder::class) @NoAutoDetect class PropagatedEvent + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): PropagatedEvent = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -2461,23 +3123,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PropagatedEvent]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(propagatedEvent: PropagatedEvent) = apply { - additionalProperties(propagatedEvent.additionalProperties) + additionalProperties = propagatedEvent.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2485,6 +3147,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PropagatedEvent = PropagatedEvent(additionalProperties.toImmutable()) } @@ -2508,47 +3178,58 @@ constructor( } /** Identifiers for the row to to log a subspan under */ - @JsonDeserialize(builder = RowIds.Builder::class) @NoAutoDetect class RowIds + @JsonCreator private constructor( - private val id: JsonField, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The id of the row */ fun id(): String = id.getRequired("id") - /** The span_id of the row */ - fun spanId(): String = spanId.getRequired("span_id") - /** The root_span_id of the row */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - /** The id of the row */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - /** The span_id of the row */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + fun spanId(): String = spanId.getRequired("span_id") + + /** The id of the row */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The root_span_id of the row */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId + + /** The span_id of the row */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): RowIds = apply { - if (!validated) { - id() - spanId() - rootSpanId() - validated = true + if (validated) { + return@apply } + + id() + rootSpanId() + spanId() + validated = true } fun toBuilder() = Builder().from(this) @@ -2558,55 +3239,49 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RowIds]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var rootSpanId: JsonField? = null + private var spanId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(rowIds: RowIds) = apply { - this.id = rowIds.id - this.spanId = rowIds.spanId - this.rootSpanId = rowIds.rootSpanId - additionalProperties(rowIds.additionalProperties) + id = rowIds.id + rootSpanId = rowIds.rootSpanId + spanId = rowIds.spanId + additionalProperties = rowIds.additionalProperties.toMutableMap() } /** The id of the row */ fun id(id: String) = id(JsonField.of(id)) /** The id of the row */ - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - /** The span_id of the row */ - fun spanId(spanId: String) = spanId(JsonField.of(spanId)) - - /** The span_id of the row */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - /** The root_span_id of the row */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** The root_span_id of the row */ - @JsonProperty("root_span_id") - @ExcludeMissing fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + /** The span_id of the row */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** The span_id of the row */ + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2614,11 +3289,19 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RowIds = RowIds( - id, - spanId, - rootSpanId, + checkRequired("id", id), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), additionalProperties.toImmutable(), ) } @@ -2628,17 +3311,17 @@ constructor( return true } - return /* spotless:off */ other is RowIds && id == other.id && spanId == other.spanId && rootSpanId == other.rootSpanId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, spanId, rootSpanId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, rootSpanId, spanId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "RowIds{id=$id, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" + "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -2646,17 +3329,17 @@ constructor( return true } - return /* spotless:off */ other is SpanParentStruct && objectType == other.objectType && objectId == other.objectId && rowIds == other.rowIds && propagatedEvent == other.propagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, rowIds, propagatedEvent, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, propagatedEvent, rowIds, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SpanParentStruct{objectType=$objectType, objectId=$objectId, rowIds=$rowIds, propagatedEvent=$propagatedEvent, additionalProperties=$additionalProperties}" + "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" } } @@ -2665,11 +3348,11 @@ constructor( return true } - return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, input, messages, mode, parent, stream, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "FunctionInvokeParams{functionId=$functionId, input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "FunctionInvokeParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 505e191b..835ed858 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -5,29 +5,32 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects -@JsonDeserialize(builder = FunctionInvokeResponse.Builder::class) @NoAutoDetect class FunctionInvokeResponse +@JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FunctionInvokeResponse = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -37,29 +40,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionInvokeResponse]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionInvokeResponse: FunctionInvokeResponse) = apply { - additionalProperties(functionInvokeResponse.additionalProperties) + additionalProperties = functionInvokeResponse.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionInvokeResponse = FunctionInvokeResponse(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 828cf5ea..e6a195bf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.FunctionService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all functions. The functions are sorted by creation date, with the most recently-created + * functions coming first + */ class FunctionListPage private constructor( private val functionsService: FunctionService, @@ -85,16 +90,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -104,11 +108,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -144,10 +152,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -156,8 +162,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: FunctionListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 9ebdcf18..6fe2a2d9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.FunctionServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all functions. The functions are sorted by creation date, with the most recently-created + * functions coming first + */ class FunctionListPageAsync private constructor( private val functionsService: FunctionServiceAsync, @@ -92,16 +97,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +115,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +159,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +169,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: FunctionListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 5ef0037b..581a6807 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all functions. The functions are sorted by creation date, with the most recently-created + * functions coming first + */ class FunctionListParams -constructor( +private constructor( private val endingBefore: String?, private val functionName: String?, private val ids: Ids?, @@ -35,36 +39,65 @@ constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** Name of the function to search for */ fun functionName(): Optional = Optional.ofNullable(functionName) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Project id */ fun projectId(): Optional = Optional.ofNullable(projectId) + /** Name of the project to search for */ fun projectName(): Optional = Optional.ofNullable(projectName) + /** Retrieve prompt with a specific slug */ fun slug(): Optional = Optional.ofNullable(slug) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + /** + * Retrieve prompt at a specific version. + * + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). + */ fun version(): Optional = Optional.ofNullable(version) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.functionName?.let { queryParams.put("function_name", listOf(it.toString())) } @@ -87,8 +120,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [FunctionListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var functionName: String? = null @@ -126,43 +160,89 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** Name of the function to search for */ - fun functionName(functionName: String) = apply { this.functionName = functionName } + fun functionName(functionName: String?) = apply { this.functionName = functionName } + + /** Name of the function to search for */ + fun functionName(functionName: Optional) = functionName(functionName.orElse(null)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = ids(Ids.ofString(string)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long) = limit(limit as Long?) + + /** Limit the number of objects to return */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** Filter search results to within a particular organization */ + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** Project id */ + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = apply { this.projectName = projectName } + + /** Name of the project to search for */ + fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + + /** Retrieve prompt with a specific slug */ + fun slug(slug: String?) = apply { this.slug = slug } /** Retrieve prompt with a specific slug */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: Optional) = slug(slug.orElse(null)) + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. @@ -171,7 +251,8 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) /** * Retrieve prompt at a specific version. @@ -179,7 +260,15 @@ constructor( * The version id can either be a transaction id (e.g. '1000192656880881099') or a version * identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String) = apply { this.version = version } + fun version(version: String?) = apply { this.version = version } + + /** + * Retrieve prompt at a specific version. + * + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). + */ + fun version(version: Optional) = version(version.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -296,6 +385,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -305,8 +398,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -329,15 +420,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -363,18 +445,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -390,7 +482,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, 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 d5f5ef69..7cc5822d 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 @@ -10,9 +10,12 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow 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.braintrustdata.api.models.CodeBundle.* @@ -30,118 +33,213 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * Create or replace function. If there is an existing function in the project with the same slug as + * the one specified in the request, will replace the existing function with the provided fields + */ class FunctionReplaceParams -constructor( - private val functionData: FunctionData, - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val functionSchema: FunctionSchema?, - private val functionType: FunctionType?, - private val origin: Origin?, - private val promptData: PromptData?, - private val tags: List?, +private constructor( + private val body: FunctionReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun functionData(): FunctionData = functionData + fun functionData(): FunctionData = body.functionData() - fun name(): String = name + /** Name of the prompt */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = body.projectId() - fun slug(): String = slug + /** Unique identifier for the prompt */ + fun slug(): String = body.slug() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the prompt */ + fun description(): Optional = body.description() - fun functionSchema(): Optional = Optional.ofNullable(functionSchema) + /** JSON schema for the function's parameters and return type */ + fun functionSchema(): Optional = body.functionSchema() + + fun functionType(): Optional = body.functionType() + + fun origin(): Optional = body.origin() + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = body.promptData() + + /** A list of tags for the prompt */ + fun tags(): Optional> = body.tags() + + fun _functionData(): JsonField = body._functionData() + + /** Name of the prompt */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the prompt belongs under */ + fun _projectId(): JsonField = body._projectId() - fun functionType(): Optional = Optional.ofNullable(functionType) + /** Unique identifier for the prompt */ + fun _slug(): JsonField = body._slug() - fun origin(): Optional = Optional.ofNullable(origin) + /** Textual description of the prompt */ + fun _description(): JsonField = body._description() - fun promptData(): Optional = Optional.ofNullable(promptData) + /** JSON schema for the function's parameters and return type */ + fun _functionSchema(): JsonField = body._functionSchema() + + fun _functionType(): JsonField = body._functionType() + + fun _origin(): JsonField = body._origin() + + /** The prompt, model, and its parameters */ + fun _promptData(): JsonField = body._promptData() - fun tags(): Optional> = Optional.ofNullable(tags) + /** A list of tags for the prompt */ + fun _tags(): JsonField> = body._tags() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): FunctionReplaceBody { - return FunctionReplaceBody( - functionData, - name, - projectId, - slug, - description, - functionSchema, - functionType, - origin, - promptData, - tags, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): FunctionReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = FunctionReplaceBody.Builder::class) @NoAutoDetect class FunctionReplaceBody + @JsonCreator internal constructor( - private val functionData: FunctionData?, - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val functionSchema: FunctionSchema?, - private val functionType: FunctionType?, - private val origin: Origin?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + @JsonProperty("function_data") + @ExcludeMissing + private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") + @ExcludeMissing + private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("function_data") fun functionData(): FunctionData? = functionData + fun functionData(): FunctionData = functionData.getRequired("function_data") + + /** Name of the prompt */ + fun name(): String = name.getRequired("name") + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Unique identifier for the prompt */ + fun slug(): String = slug.getRequired("slug") + + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(): Optional = + Optional.ofNullable(functionSchema.getNullable("function_schema")) + + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) + + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + @JsonProperty("function_data") + @ExcludeMissing + fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** JSON schema for the function's parameters and return type */ - @JsonProperty("function_schema") fun functionSchema(): FunctionSchema? = functionSchema + @JsonProperty("function_schema") + @ExcludeMissing + fun _functionSchema(): JsonField = functionSchema - @JsonProperty("function_type") fun functionType(): FunctionType? = functionType + @JsonProperty("function_type") + @ExcludeMissing + fun _functionType(): JsonField = functionType - @JsonProperty("origin") fun origin(): Origin? = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FunctionReplaceBody = apply { + if (validated) { + return@apply + } + + functionData().validate() + name() + projectId() + slug() + description() + functionSchema().ifPresent { it.validate() } + functionType() + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -149,100 +247,175 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var functionData: FunctionData? = null - private var name: String? = null - private var projectId: String? = null - private var slug: String? = null - private var description: String? = null - private var functionSchema: FunctionSchema? = null - private var functionType: FunctionType? = null - private var origin: Origin? = null - private var promptData: PromptData? = null - private var tags: List? = null + /** A builder for [FunctionReplaceBody]. */ + class Builder internal constructor() { + + private var functionData: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var functionSchema: JsonField = JsonMissing.of() + private var functionType: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionReplaceBody: FunctionReplaceBody) = apply { - this.functionData = functionReplaceBody.functionData - this.name = functionReplaceBody.name - this.projectId = functionReplaceBody.projectId - this.slug = functionReplaceBody.slug - this.description = functionReplaceBody.description - this.functionSchema = functionReplaceBody.functionSchema - this.functionType = functionReplaceBody.functionType - this.origin = functionReplaceBody.origin - this.promptData = functionReplaceBody.promptData - this.tags = functionReplaceBody.tags - additionalProperties(functionReplaceBody.additionalProperties) + functionData = functionReplaceBody.functionData + name = functionReplaceBody.name + projectId = functionReplaceBody.projectId + slug = functionReplaceBody.slug + description = functionReplaceBody.description + functionSchema = functionReplaceBody.functionSchema + functionType = functionReplaceBody.functionType + origin = functionReplaceBody.origin + promptData = functionReplaceBody.promptData + tags = functionReplaceBody.tags.map { it.toMutableList() } + additionalProperties = functionReplaceBody.additionalProperties.toMutableMap() } - @JsonProperty("function_data") - fun functionData(functionData: FunctionData) = apply { + fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + + fun functionData(functionData: JsonField) = apply { this.functionData = functionData } + fun functionData(prompt: FunctionData.Prompt) = + functionData(FunctionData.ofPrompt(prompt)) + + fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) + + fun functionData(global: FunctionData.Global) = + functionData(FunctionData.ofGlobal(global)) + + /** Name of the prompt */ + fun name(name: String) = name(JsonField.of(name)) + /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: JsonField) = apply { this.slug = slug } + + /** Textual description of the prompt */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the prompt */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: FunctionSchema?) = + functionSchema(JsonField.ofNullable(functionSchema)) + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.orElse(null)) /** JSON schema for the function's parameters and return type */ - @JsonProperty("function_schema") - fun functionSchema(functionSchema: FunctionSchema) = apply { + fun functionSchema(functionSchema: JsonField) = apply { this.functionSchema = functionSchema } - @JsonProperty("function_type") - fun functionType(functionType: FunctionType) = apply { + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) + + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) + + fun functionType(functionType: JsonField) = apply { this.functionType = functionType } - @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } + fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + + fun origin(origin: Optional) = origin(origin.orElse(null)) + + fun origin(origin: JsonField) = apply { this.origin = origin } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } + + /** A list of tags for the prompt */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionReplaceBody = FunctionReplaceBody( - checkNotNull(functionData) { "`functionData` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, + checkRequired("functionData", functionData), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("slug", slug), description, functionSchema, functionType, origin, promptData, - tags?.toImmutable(), + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -272,86 +445,128 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [FunctionReplaceParams]. */ @NoAutoDetect - class Builder { - - private var functionData: FunctionData? = null - private var name: String? = null - private var projectId: String? = null - private var slug: String? = null - private var description: String? = null - private var functionSchema: FunctionSchema? = null - private var functionType: FunctionType? = null - private var origin: Origin? = null - private var promptData: PromptData? = null - private var tags: MutableList = mutableListOf() + class Builder internal constructor() { + + private var body: FunctionReplaceBody.Builder = FunctionReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionReplaceParams: FunctionReplaceParams) = apply { - functionData = functionReplaceParams.functionData - name = functionReplaceParams.name - projectId = functionReplaceParams.projectId - slug = functionReplaceParams.slug - description = functionReplaceParams.description - functionSchema = functionReplaceParams.functionSchema - functionType = functionReplaceParams.functionType - origin = functionReplaceParams.origin - promptData = functionReplaceParams.promptData - tags = functionReplaceParams.tags?.toMutableList() ?: mutableListOf() + body = functionReplaceParams.body.toBuilder() additionalHeaders = functionReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = functionReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = functionReplaceParams.additionalBodyProperties.toMutableMap() } - fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } + fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } - fun functionData(prompt: FunctionData.Prompt) = apply { - this.functionData = FunctionData.ofPrompt(prompt) + fun functionData(functionData: JsonField) = apply { + body.functionData(functionData) } - fun functionData(code: FunctionData.Code) = apply { - this.functionData = FunctionData.ofCode(code) - } + fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } - fun functionData(global: FunctionData.Global) = apply { - this.functionData = FunctionData.ofGlobal(global) - } + fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + + fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + + /** Name of the prompt */ + fun name(name: String) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: JsonField) = apply { body.slug(slug) } + + /** Textual description of the prompt */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { body.description(description) } + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: FunctionSchema?) = apply { + body.functionSchema(functionSchema) + } + + /** JSON schema for the function's parameters and return type */ + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.orElse(null)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema) = apply { - this.functionSchema = functionSchema + fun functionSchema(functionSchema: JsonField) = apply { + body.functionSchema(functionSchema) + } + + fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) + + fun functionType(functionType: JsonField) = apply { + body.functionType(functionType) } - fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } + fun origin(origin: Origin?) = apply { body.origin(origin) } - fun origin(origin: Origin) = apply { this.origin = origin } + fun origin(origin: Optional) = origin(origin.orElse(null)) + + fun origin(origin: JsonField) = apply { body.origin(origin) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List) = apply { - this.tags.clear() - this.tags.addAll(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun tags(tags: JsonField>) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -451,43 +666,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): FunctionReplaceParams = FunctionReplaceParams( - checkNotNull(functionData) { "`functionData` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionSchema, - functionType, - origin, - promptData, - tags.toImmutable().ifEmpty { null }, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -501,8 +684,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun prompt(): Optional = Optional.ofNullable(prompt) fun code(): Optional = Optional.ofNullable(code) @@ -532,16 +713,29 @@ constructor( } } + private var validated: Boolean = false + fun validate(): FunctionData = apply { - if (!validated) { - if (prompt == null && code == null && global == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitPrompt(prompt: Prompt) { + prompt.validate() + } + + override fun visitCode(code: Code) { + code.validate() + } + + override fun visitGlobal(global: Global) { + global.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -572,6 +766,10 @@ constructor( @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } + /** + * An interface that defines how to map each variant of [FunctionData] to a value of type + * [T]. + */ interface Visitor { fun visitPrompt(prompt: Prompt): T @@ -580,12 +778,22 @@ constructor( fun visitGlobal(global: Global): T + /** + * Maps an unknown variant of [FunctionData] to a value of type [T]. + * + * An instance of [FunctionData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } - class Deserializer : BaseDeserializer(FunctionData::class) { + internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { val json = JsonValue.fromJsonNode(node) @@ -607,7 +815,7 @@ constructor( } } - class Serializer : BaseSerializer(FunctionData::class) { + internal class Serializer : BaseSerializer(FunctionData::class) { override fun serialize( value: FunctionData, @@ -624,29 +832,34 @@ constructor( } } - @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect class Prompt + @JsonCreator private constructor( - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Prompt = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -656,31 +869,29 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Prompt]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(prompt: Prompt) = apply { - this.type = prompt.type - additionalProperties(prompt.additionalProperties) + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -688,7 +899,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt(type, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Prompt = + Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } class Type @@ -697,42 +917,67 @@ 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 - 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() - companion object { - @JvmField val PROMPT = Type(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { PROMPT, } + /** + * 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 { PROMPT, + /** + * 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) { PROMPT -> Value.PROMPT 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) { PROMPT -> Known.PROMPT @@ -740,6 +985,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -760,35 +1017,42 @@ constructor( "Prompt{type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect class Code + @JsonCreator private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - fun data(): Data = data.getRequired("data") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Code = apply { - if (!validated) { - type() - data() - validated = true + if (validated) { + return@apply } + + data().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -798,39 +1062,39 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Code]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(code: Code) = apply { - this.type = code.type - this.data = code.data - additionalProperties(code.additionalProperties) + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } + fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) + + fun data(inline: Data.Inline) = data(Data.ofInline(inline)) + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -838,10 +1102,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Code = Code( - type, - data, + checkRequired("data", data), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -855,8 +1127,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun bundle(): Optional = Optional.ofNullable(bundle) fun inline(): Optional = Optional.ofNullable(inline) @@ -879,14 +1149,25 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Data = apply { - if (!validated) { - if (bundle == null && inline == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - inline?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitBundle(bundle: Bundle) { + bundle.validate() + } + + override fun visitInline(inline: Inline) { + inline.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -914,25 +1195,40 @@ constructor( @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) } + /** + * An interface that defines how to map each variant of [Data] to a value of type + * [T]. + */ interface Visitor { fun visitBundle(bundle: Bundle): T fun visitInline(inline: Inline): T + /** + * Maps an unknown variant of [Data] to a value of type [T]. + * + * An instance of [Data] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Data: $json") } } - class Deserializer : BaseDeserializer(Data::class) { + internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Data(bundle = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(bundle = it, _json = json) + } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Data(inline = it, _json = json) @@ -942,7 +1238,7 @@ constructor( } } - class Serializer : BaseSerializer(Data::class) { + internal class Serializer : BaseSerializer(Data::class) { override fun serialize( value: Data, @@ -958,26 +1254,36 @@ constructor( } } - @JsonDeserialize(builder = Bundle.Builder::class) @NoAutoDetect class Bundle + @JsonCreator private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = + JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun bundleId(): String = bundleId.getRequired("bundle_id") - fun location(): Location = location.getRequired("location") + fun location(): CodeBundle.Location = location.getRequired("location") - fun bundleId(): String = bundleId.getRequired("bundle_id") + fun runtimeContext(): CodeBundle.RuntimeContext = + runtimeContext.getRequired("runtime_context") /** A preview of the code */ fun preview(): Optional = @@ -985,40 +1291,50 @@ constructor( fun type(): Type = type.getRequired("type") - fun toCodeBundle(): CodeBundle = - CodeBundle.builder() - .runtimeContext(runtimeContext) - .location(location) - .bundleId(bundleId) - .preview(preview) - .build() - - @JsonProperty("runtime_context") + @JsonProperty("bundle_id") @ExcludeMissing - fun _runtimeContext() = runtimeContext + fun _bundleId(): JsonField = bundleId - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("runtime_context") + @ExcludeMissing + fun _runtimeContext(): JsonField = runtimeContext /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toCodeBundle(): CodeBundle = + CodeBundle.builder() + .bundleId(bundleId) + .location(location) + .runtimeContext(runtimeContext) + .preview(preview) + .build() + + private var validated: Boolean = false + fun validate(): Bundle = apply { - if (!validated) { - runtimeContext().validate() - location() - bundleId() - preview() - type() - validated = true + if (validated) { + return@apply } + + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1028,87 +1344,96 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Bundle]. */ + class Builder internal constructor() { - private var runtimeContext: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var bundleId: JsonField = JsonMissing.of() + private var bundleId: JsonField? = null + private var location: JsonField? = null + private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bundle: Bundle) = apply { - this.runtimeContext = bundle.runtimeContext - this.location = bundle.location - this.bundleId = bundle.bundleId - this.preview = bundle.preview - this.type = bundle.type - additionalProperties(bundle.additionalProperties) + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - @JsonProperty("runtime_context") - @ExcludeMissing - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext + fun bundleId(bundleId: JsonField) = apply { + this.bundleId = bundleId } - fun location(location: Location) = location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = + location(JsonField.of(location)) - @JsonProperty("location") - @ExcludeMissing - fun location(location: JsonField) = apply { + fun location(location: JsonField) = apply { this.location = location } - fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + fun location(experiment: CodeBundle.Location.Experiment) = + location(CodeBundle.Location.ofExperiment(experiment)) - @JsonProperty("bundle_id") - @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun location(function: CodeBundle.Location.Function) = + location(CodeBundle.Location.ofFunction(function)) + + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) + + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } /** A preview of the code */ - fun preview(preview: String) = preview(JsonField.of(preview)) + fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) + + /** A preview of the code */ + fun preview(preview: Optional) = preview(preview.orElse(null)) /** A preview of the code */ - @JsonProperty("preview") - @ExcludeMissing fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Bundle = Bundle( - runtimeContext, - location, - bundleId, + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), preview, - type, + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -1119,43 +1444,70 @@ 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 - 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() - companion object { - @JvmField val BUNDLE = Type(JsonField.of("bundle")) + @JvmField val BUNDLE = of("bundle") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { BUNDLE, } + /** + * 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 { BUNDLE, + /** + * 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) { BUNDLE -> Value.BUNDLE 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) { BUNDLE -> Known.BUNDLE @@ -1163,6 +1515,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1170,57 +1534,66 @@ constructor( return true } - return /* spotless:off */ other is Bundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(bundleId, location, runtimeContext, preview, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Inline.Builder::class) @NoAutoDetect class Inline + @JsonCreator private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val code: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") + fun code(): String = code.getRequired("code") fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") - fun code(): String = code.getRequired("code") + fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing - fun _runtimeContext() = runtimeContext + fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Inline = apply { - if (!validated) { - type() - runtimeContext().validate() - code() - validated = true + if (validated) { + return@apply } + + code() + runtimeContext().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1230,96 +1603,110 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Inline]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var runtimeContext: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var runtimeContext: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inline: Inline) = apply { - this.type = inline.type - this.runtimeContext = inline.runtimeContext - this.code = inline.code - additionalProperties(inline.additionalProperties) + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) + fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun code(code: JsonField) = apply { this.code = code } fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - @JsonProperty("runtime_context") - @ExcludeMissing fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } - fun code(code: String) = code(JsonField.of(code)) + fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Inline = Inline( - type, - runtimeContext, - code, + checkRequired("code", code), + checkRequired("runtimeContext", runtimeContext), + checkRequired("type", type), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect class RuntimeContext + @JsonCreator private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): RuntimeContext = apply { - if (!validated) { - runtime() - version() - validated = true + if (validated) { + return@apply } + + runtime() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1329,32 +1716,30 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RuntimeContext]. */ + class Builder internal constructor() { - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var runtime: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { - this.runtime = runtimeContext.runtime - this.version = runtimeContext.version - additionalProperties(runtimeContext.additionalProperties) + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = + runtimeContext.additionalProperties.toMutableMap() } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - @JsonProperty("runtime") - @ExcludeMissing fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } @@ -1362,22 +1747,29 @@ constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RuntimeContext = RuntimeContext( - runtime, - version, + checkRequired("runtime", runtime), + checkRequired("version", version), additionalProperties.toImmutable(), ) } @@ -1388,41 +1780,61 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val NODE = Runtime(JsonField.of("node")) + @JvmField val NODE = of("node") - @JvmField val PYTHON = Runtime(JsonField.of("python")) + @JvmField val PYTHON = of("python") @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) } + /** An enum containing [Runtime]'s known values. */ enum class Known { NODE, PYTHON, } + /** + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Runtime] 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 { NODE, PYTHON, + /** + * An enum member indicating that [Runtime] 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) { NODE -> Value.NODE @@ -1430,6 +1842,15 @@ constructor( 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) { NODE -> Known.NODE @@ -1441,6 +1862,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1467,43 +1900,70 @@ 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 - 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() - companion object { - @JvmField val INLINE = Type(JsonField.of("inline")) + @JvmField val INLINE = of("inline") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { INLINE, } + /** + * 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 { INLINE, + /** + * 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) { INLINE -> Value.INLINE 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) { INLINE -> Known.INLINE @@ -1511,6 +1971,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1518,17 +1990,17 @@ constructor( return true } - return /* spotless:off */ other is Inline && type == other.type && runtimeContext == other.runtimeContext && code == other.code && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, runtimeContext, code, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, runtimeContext, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" + "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } @@ -1538,42 +2010,67 @@ 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 - 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() - companion object { - @JvmField val CODE = Type(JsonField.of("code")) + @JvmField val CODE = of("code") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { CODE, } + /** + * 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 { CODE, + /** + * 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) { CODE -> Value.CODE 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) { CODE -> Known.CODE @@ -1581,6 +2078,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1588,48 +2097,55 @@ constructor( return true } - return /* spotless:off */ other is Code && type == other.type && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, data, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect class Global + @JsonCreator private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - fun name(): String = name.getRequired("name") + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Global = apply { - if (!validated) { - type() - name() - validated = true + if (validated) { + return@apply } + + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1639,39 +2155,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Global]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(global: Global) = apply { - this.type = global.type - this.name = global.name - additionalProperties(global.additionalProperties) + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1679,10 +2191,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Global = Global( - type, - name, + checkRequired("name", name), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -1693,42 +2213,67 @@ 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 - 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() - companion object { - @JvmField val GLOBAL = Type(JsonField.of("global")) + @JvmField val GLOBAL = of("global") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { GLOBAL, } + /** + * 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 { GLOBAL, + /** + * 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) { GLOBAL -> Value.GLOBAL 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) { GLOBAL -> Known.GLOBAL @@ -1736,6 +2281,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1743,38 +2300,51 @@ constructor( return true } - return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** JSON schema for the function's parameters and return type */ - @JsonDeserialize(builder = FunctionSchema.Builder::class) @NoAutoDetect class FunctionSchema + @JsonCreator private constructor( - private val parameters: JsonValue?, - private val returns: JsonValue?, - private val additionalProperties: Map, + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonValue = JsonMissing.of(), + @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("parameters") fun parameters(): JsonValue? = parameters + @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters - @JsonProperty("returns") fun returns(): JsonValue? = returns + @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FunctionSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1782,39 +2352,43 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionSchema]. */ + class Builder internal constructor() { - private var parameters: JsonValue? = null - private var returns: JsonValue? = null + private var parameters: JsonValue = JsonMissing.of() + private var returns: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionSchema: FunctionSchema) = apply { - this.parameters = functionSchema.parameters - this.returns = functionSchema.returns - additionalProperties(functionSchema.additionalProperties) + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() } - @JsonProperty("parameters") fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } - @JsonProperty("returns") fun returns(returns: JsonValue) = apply { this.returns = returns } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionSchema = FunctionSchema( parameters, @@ -1847,33 +2421,30 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val LLM = FunctionType(JsonField.of("llm")) + @JvmField val LLM = of("llm") - @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val SCORER = of("scorer") - @JvmField val TASK = FunctionType(JsonField.of("task")) + @JvmField val TASK = of("task") - @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmField val TOOL = of("tool") @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } + /** An enum containing [FunctionType]'s known values. */ enum class Known { LLM, SCORER, @@ -1881,14 +2452,33 @@ constructor( TOOL, } + /** + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FunctionType] 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, SCORER, TASK, TOOL, + /** + * An enum member indicating that [FunctionType] 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 @@ -1898,6 +2488,15 @@ constructor( 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 @@ -1908,34 +2507,80 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect class Origin + @JsonCreator private constructor( - private val objectType: ObjectType?, - private val objectId: String?, - private val internal_: Boolean?, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") + @ExcludeMissing + private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** Id of the object the function is originating from */ + fun objectId(): String = objectId.getRequired("object_id") + /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @JsonProperty("internal") fun internal_(): Boolean? = internal_ + @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Origin = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + internal_() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1943,106 +2588,135 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Origin]. */ + class Builder internal constructor() { - private var objectType: ObjectType? = null - private var objectId: String? = null - private var internal_: Boolean? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var internal_: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(origin: Origin) = apply { - this.objectType = origin.objectType - this.objectId = origin.objectId - this.internal_ = origin.internal_ - additionalProperties(origin.additionalProperties) + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() } - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + /** Id of the object the function is originating from */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @JsonProperty("internal") - fun internal_(internal_: Boolean) = apply { this.internal_ = internal_ } + fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) + + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun internal_(internal_: Optional) = + internal_(internal_.orElse(null) as Boolean?) + + /** + * The function exists for internal purposes and should not be displayed in the list of + * functions. + */ + fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Origin = Origin( - checkNotNull(objectType) { "`objectType` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), internal_, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -2057,6 +2731,15 @@ constructor( 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, @@ -2069,9 +2752,20 @@ constructor( 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 @@ -2088,6 +2782,15 @@ constructor( 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 @@ -2105,6 +2808,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -2112,17 +2827,17 @@ constructor( return true } - return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, internal_, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, internal_, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" + "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -2130,11 +2845,11 @@ constructor( return true } - return /* spotless:off */ other is FunctionReplaceParams && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionData, name, projectId, slug, description, functionSchema, functionType, origin, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "FunctionReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index e7aed157..76d7beb1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a function object by its id */ class FunctionRetrieveParams -constructor( +private constructor( private val functionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Function id */ fun functionId(): String = functionId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [FunctionRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var functionId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): FunctionRetrieveParams = FunctionRetrieveParams( - checkNotNull(functionId) { "`functionId` is required but was not set" }, + checkRequired("functionId", functionId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 48fbfd55..49dd90a1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -10,9 +10,12 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow 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.braintrustdata.api.models.CodeBundle.* @@ -30,52 +33,61 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * Partially update a function object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. + */ class FunctionUpdateParams -constructor( +private constructor( private val functionId: String, - private val description: String?, - private val functionData: FunctionData?, - private val name: String?, - private val promptData: PromptData?, - private val tags: List?, + private val body: FunctionUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Function id */ fun functionId(): String = functionId - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the prompt */ + fun description(): Optional = body.description() - fun functionData(): Optional = Optional.ofNullable(functionData) + fun functionData(): Optional = body.functionData() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the prompt */ + fun name(): Optional = body.name() - fun promptData(): Optional = Optional.ofNullable(promptData) + /** The prompt, model, and its parameters */ + fun promptData(): Optional = body.promptData() - fun tags(): Optional> = Optional.ofNullable(tags) + /** A list of tags for the prompt */ + fun tags(): Optional> = body.tags() + + /** Textual description of the prompt */ + fun _description(): JsonField = body._description() + + fun _functionData(): JsonField = body._functionData() + + /** Name of the prompt */ + fun _name(): JsonField = body._name() + + /** The prompt, model, and its parameters */ + fun _promptData(): JsonField = body._promptData() + + /** A list of tags for the prompt */ + fun _tags(): JsonField> = body._tags() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): FunctionUpdateBody { - return FunctionUpdateBody( - description, - functionData, - name, - promptData, - tags, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): FunctionUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -84,36 +96,85 @@ constructor( } } - @JsonDeserialize(builder = FunctionUpdateBody.Builder::class) @NoAutoDetect class FunctionUpdateBody + @JsonCreator internal constructor( - private val description: String?, - private val functionData: FunctionData?, - private val name: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_data") + @ExcludeMissing + private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + fun functionData(): Optional = + Optional.ofNullable(functionData.getNullable("function_data")) + + /** Name of the prompt */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** Textual description of the prompt */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("function_data") fun functionData(): FunctionData? = functionData + @JsonProperty("function_data") + @ExcludeMissing + fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FunctionUpdateBody = apply { + if (validated) { + return@apply + } + + description() + functionData().ifPresent { it.validate() } + name() + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -121,65 +182,125 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionUpdateBody]. */ + class Builder internal constructor() { - private var description: String? = null - private var functionData: FunctionData? = null - private var name: String? = null - private var promptData: PromptData? = null - private var tags: List? = null + private var description: JsonField = JsonMissing.of() + private var functionData: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionUpdateBody: FunctionUpdateBody) = apply { - this.description = functionUpdateBody.description - this.functionData = functionUpdateBody.functionData - this.name = functionUpdateBody.name - this.promptData = functionUpdateBody.promptData - this.tags = functionUpdateBody.tags - additionalProperties(functionUpdateBody.additionalProperties) + description = functionUpdateBody.description + functionData = functionUpdateBody.functionData + name = functionUpdateBody.name + promptData = functionUpdateBody.promptData + tags = functionUpdateBody.tags.map { it.toMutableList() } + additionalProperties = functionUpdateBody.additionalProperties.toMutableMap() } /** Textual description of the prompt */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) - @JsonProperty("function_data") - fun functionData(functionData: FunctionData) = apply { + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the prompt */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + + fun functionData(functionData: JsonField) = apply { this.functionData = functionData } + fun functionData(prompt: FunctionData.Prompt) = + functionData(FunctionData.ofPrompt(prompt)) + + fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) + + fun functionData(global: FunctionData.Global) = + functionData(FunctionData.ofGlobal(global)) + + fun functionData(nullableVariant: FunctionData.NullableVariant) = + functionData(FunctionData.ofNullableVariant(nullableVariant)) + + /** Name of the prompt */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the prompt */ + fun name(name: JsonField) = apply { this.name = name } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } + + /** A list of tags for the prompt */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags for the prompt */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionUpdateBody = FunctionUpdateBody( description, functionData, name, promptData, - tags?.toImmutable(), + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -209,70 +330,99 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [FunctionUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var functionId: String? = null - private var description: String? = null - private var functionData: FunctionData? = null - private var name: String? = null - private var promptData: PromptData? = null - private var tags: MutableList = mutableListOf() + private var body: FunctionUpdateBody.Builder = FunctionUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionUpdateParams: FunctionUpdateParams) = apply { functionId = functionUpdateParams.functionId - description = functionUpdateParams.description - functionData = functionUpdateParams.functionData - name = functionUpdateParams.name - promptData = functionUpdateParams.promptData - tags = functionUpdateParams.tags?.toMutableList() ?: mutableListOf() + body = functionUpdateParams.body.toBuilder() additionalHeaders = functionUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = functionUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = functionUpdateParams.additionalBodyProperties.toMutableMap() } /** Function id */ fun functionId(functionId: String) = apply { this.functionId = functionId } /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } - fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) - fun functionData(prompt: FunctionData.Prompt) = apply { - this.functionData = FunctionData.ofPrompt(prompt) - } + /** Textual description of the prompt */ + fun description(description: JsonField) = apply { body.description(description) } - fun functionData(code: FunctionData.Code) = apply { - this.functionData = FunctionData.ofCode(code) - } + fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } - fun functionData(global: FunctionData.Global) = apply { - this.functionData = FunctionData.ofGlobal(global) + fun functionData(functionData: JsonField) = apply { + body.functionData(functionData) } + fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + + fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + + fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + fun functionData(nullableVariant: FunctionData.NullableVariant) = apply { - this.functionData = FunctionData.ofNullableVariant(nullableVariant) + body.functionData(nullableVariant) } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String?) = apply { body.name(name) } + + /** Name of the prompt */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the prompt */ + fun name(name: JsonField) = apply { body.name(name) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List) = apply { - this.tags.clear() - this.tags.addAll(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun tags(tags: JsonField>) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -372,39 +522,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): FunctionUpdateParams = FunctionUpdateParams( - checkNotNull(functionId) { "`functionId` is required but was not set" }, - description, - functionData, - name, - promptData, - tags.toImmutable().ifEmpty { null }, + checkRequired("functionId", functionId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -419,8 +542,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun prompt(): Optional = Optional.ofNullable(prompt) fun code(): Optional = Optional.ofNullable(code) @@ -457,17 +578,33 @@ constructor( } } + private var validated: Boolean = false + fun validate(): FunctionData = apply { - if (!validated) { - if (prompt == null && code == null && global == null && nullableVariant == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - nullableVariant?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitPrompt(prompt: Prompt) { + prompt.validate() + } + + override fun visitCode(code: Code) { + code.validate() + } + + override fun visitGlobal(global: Global) { + global.validate() + } + + override fun visitNullableVariant(nullableVariant: NullableVariant) { + nullableVariant.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -503,6 +640,10 @@ constructor( FunctionData(nullableVariant = nullableVariant) } + /** + * An interface that defines how to map each variant of [FunctionData] to a value of type + * [T]. + */ interface Visitor { fun visitPrompt(prompt: Prompt): T @@ -513,12 +654,22 @@ constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T + /** + * Maps an unknown variant of [FunctionData] to a value of type [T]. + * + * An instance of [FunctionData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } - class Deserializer : BaseDeserializer(FunctionData::class) { + internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { val json = JsonValue.fromJsonNode(node) @@ -544,7 +695,7 @@ constructor( } } - class Serializer : BaseSerializer(FunctionData::class) { + internal class Serializer : BaseSerializer(FunctionData::class) { override fun serialize( value: FunctionData, @@ -562,29 +713,34 @@ constructor( } } - @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect class Prompt + @JsonCreator private constructor( - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Prompt = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -594,31 +750,29 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Prompt]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(prompt: Prompt) = apply { - this.type = prompt.type - additionalProperties(prompt.additionalProperties) + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -626,7 +780,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = Prompt(type, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Prompt = + Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } class Type @@ -635,42 +798,67 @@ 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 - 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() - companion object { - @JvmField val PROMPT = Type(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { PROMPT, } + /** + * 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 { PROMPT, + /** + * 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) { PROMPT -> Value.PROMPT 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) { PROMPT -> Known.PROMPT @@ -678,6 +866,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -698,35 +898,42 @@ constructor( "Prompt{type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect class Code + @JsonCreator private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - fun data(): Data = data.getRequired("data") + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Code = apply { - if (!validated) { - type() - data() - validated = true + if (validated) { + return@apply } + + data().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -736,39 +943,39 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Code]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(code: Code) = apply { - this.type = code.type - this.data = code.data - additionalProperties(code.additionalProperties) + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun data(data: Data) = data(JsonField.of(data)) - @JsonProperty("data") - @ExcludeMissing fun data(data: JsonField) = apply { this.data = data } + fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) + + fun data(inline: Data.Inline) = data(Data.ofInline(inline)) + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -776,10 +983,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Code = Code( - type, - data, + checkRequired("data", data), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -793,8 +1008,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun bundle(): Optional = Optional.ofNullable(bundle) fun inline(): Optional = Optional.ofNullable(inline) @@ -817,14 +1030,25 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Data = apply { - if (!validated) { - if (bundle == null && inline == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - inline?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitBundle(bundle: Bundle) { + bundle.validate() + } + + override fun visitInline(inline: Inline) { + inline.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -852,25 +1076,40 @@ constructor( @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) } + /** + * An interface that defines how to map each variant of [Data] to a value of type + * [T]. + */ interface Visitor { fun visitBundle(bundle: Bundle): T fun visitInline(inline: Inline): T + /** + * Maps an unknown variant of [Data] to a value of type [T]. + * + * An instance of [Data] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Data: $json") } } - class Deserializer : BaseDeserializer(Data::class) { + internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Data(bundle = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(bundle = it, _json = json) + } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { return Data(inline = it, _json = json) @@ -880,7 +1119,7 @@ constructor( } } - class Serializer : BaseSerializer(Data::class) { + internal class Serializer : BaseSerializer(Data::class) { override fun serialize( value: Data, @@ -896,26 +1135,36 @@ constructor( } } - @JsonDeserialize(builder = Bundle.Builder::class) @NoAutoDetect class Bundle + @JsonCreator private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = + JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun bundleId(): String = bundleId.getRequired("bundle_id") - fun location(): Location = location.getRequired("location") + fun location(): CodeBundle.Location = location.getRequired("location") - fun bundleId(): String = bundleId.getRequired("bundle_id") + fun runtimeContext(): CodeBundle.RuntimeContext = + runtimeContext.getRequired("runtime_context") /** A preview of the code */ fun preview(): Optional = @@ -923,40 +1172,50 @@ constructor( fun type(): Type = type.getRequired("type") - fun toCodeBundle(): CodeBundle = - CodeBundle.builder() - .runtimeContext(runtimeContext) - .location(location) - .bundleId(bundleId) - .preview(preview) - .build() - - @JsonProperty("runtime_context") + @JsonProperty("bundle_id") @ExcludeMissing - fun _runtimeContext() = runtimeContext + fun _bundleId(): JsonField = bundleId - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("runtime_context") + @ExcludeMissing + fun _runtimeContext(): JsonField = runtimeContext /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + fun toCodeBundle(): CodeBundle = + CodeBundle.builder() + .bundleId(bundleId) + .location(location) + .runtimeContext(runtimeContext) + .preview(preview) + .build() + + private var validated: Boolean = false + fun validate(): Bundle = apply { - if (!validated) { - runtimeContext().validate() - location() - bundleId() - preview() - type() - validated = true + if (validated) { + return@apply } + + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -966,87 +1225,96 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Bundle]. */ + class Builder internal constructor() { - private var runtimeContext: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var bundleId: JsonField = JsonMissing.of() + private var bundleId: JsonField? = null + private var location: JsonField? = null + private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bundle: Bundle) = apply { - this.runtimeContext = bundle.runtimeContext - this.location = bundle.location - this.bundleId = bundle.bundleId - this.preview = bundle.preview - this.type = bundle.type - additionalProperties(bundle.additionalProperties) + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - @JsonProperty("runtime_context") - @ExcludeMissing - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext + fun bundleId(bundleId: JsonField) = apply { + this.bundleId = bundleId } - fun location(location: Location) = location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = + location(JsonField.of(location)) - @JsonProperty("location") - @ExcludeMissing - fun location(location: JsonField) = apply { + fun location(location: JsonField) = apply { this.location = location } - fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + fun location(experiment: CodeBundle.Location.Experiment) = + location(CodeBundle.Location.ofExperiment(experiment)) - @JsonProperty("bundle_id") - @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun location(function: CodeBundle.Location.Function) = + location(CodeBundle.Location.ofFunction(function)) + + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) + + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } /** A preview of the code */ - fun preview(preview: String) = preview(JsonField.of(preview)) + fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) + + /** A preview of the code */ + fun preview(preview: Optional) = preview(preview.orElse(null)) /** A preview of the code */ - @JsonProperty("preview") - @ExcludeMissing fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Bundle = Bundle( - runtimeContext, - location, - bundleId, + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), preview, - type, + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -1057,43 +1325,70 @@ 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 - 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() - companion object { - @JvmField val BUNDLE = Type(JsonField.of("bundle")) + @JvmField val BUNDLE = of("bundle") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { BUNDLE, } + /** + * 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 { BUNDLE, + /** + * 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) { BUNDLE -> Value.BUNDLE 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) { BUNDLE -> Known.BUNDLE @@ -1101,6 +1396,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1108,57 +1415,66 @@ constructor( return true } - return /* spotless:off */ other is Bundle && runtimeContext == other.runtimeContext && location == other.location && bundleId == other.bundleId && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(runtimeContext, location, bundleId, preview, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(bundleId, location, runtimeContext, preview, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Bundle{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Inline.Builder::class) @NoAutoDetect class Inline + @JsonCreator private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val code: JsonField, - private val additionalProperties: Map, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun type(): Type = type.getRequired("type") + fun code(): String = code.getRequired("code") fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") - fun code(): String = code.getRequired("code") + fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing - fun _runtimeContext() = runtimeContext + fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Inline = apply { - if (!validated) { - type() - runtimeContext().validate() - code() - validated = true + if (validated) { + return@apply } + + code() + runtimeContext().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1168,96 +1484,110 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Inline]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var runtimeContext: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var runtimeContext: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inline: Inline) = apply { - this.type = inline.type - this.runtimeContext = inline.runtimeContext - this.code = inline.code - additionalProperties(inline.additionalProperties) + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) + fun code(code: String) = code(JsonField.of(code)) - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun code(code: JsonField) = apply { this.code = code } fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - @JsonProperty("runtime_context") - @ExcludeMissing fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } - fun code(code: String) = code(JsonField.of(code)) + fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("code") - @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Inline = Inline( - type, - runtimeContext, - code, + checkRequired("code", code), + checkRequired("runtimeContext", runtimeContext), + checkRequired("type", type), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect class RuntimeContext + @JsonCreator private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): RuntimeContext = apply { - if (!validated) { - runtime() - version() - validated = true + if (validated) { + return@apply } + + runtime() + version() + validated = true } fun toBuilder() = Builder().from(this) @@ -1267,32 +1597,30 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RuntimeContext]. */ + class Builder internal constructor() { - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var runtime: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(runtimeContext: RuntimeContext) = apply { - this.runtime = runtimeContext.runtime - this.version = runtimeContext.version - additionalProperties(runtimeContext.additionalProperties) + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = + runtimeContext.additionalProperties.toMutableMap() } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - @JsonProperty("runtime") - @ExcludeMissing fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - @JsonProperty("version") - @ExcludeMissing fun version(version: JsonField) = apply { this.version = version } @@ -1300,22 +1628,29 @@ constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RuntimeContext = RuntimeContext( - runtime, - version, + checkRequired("runtime", runtime), + checkRequired("version", version), additionalProperties.toImmutable(), ) } @@ -1326,41 +1661,61 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val NODE = Runtime(JsonField.of("node")) + @JvmField val NODE = of("node") - @JvmField val PYTHON = Runtime(JsonField.of("python")) + @JvmField val PYTHON = of("python") @JvmStatic fun of(value: String) = Runtime(JsonField.of(value)) } + /** An enum containing [Runtime]'s known values. */ enum class Known { NODE, PYTHON, } + /** + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Runtime] 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 { NODE, PYTHON, + /** + * An enum member indicating that [Runtime] 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) { NODE -> Value.NODE @@ -1368,6 +1723,15 @@ constructor( 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) { NODE -> Known.NODE @@ -1379,6 +1743,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1405,43 +1781,70 @@ 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 - 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() - companion object { - @JvmField val INLINE = Type(JsonField.of("inline")) + @JvmField val INLINE = of("inline") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { INLINE, } + /** + * 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 { INLINE, + /** + * 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) { INLINE -> Value.INLINE 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) { INLINE -> Known.INLINE @@ -1449,6 +1852,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1456,17 +1871,17 @@ constructor( return true } - return /* spotless:off */ other is Inline && type == other.type && runtimeContext == other.runtimeContext && code == other.code && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, runtimeContext, code, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, runtimeContext, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" + "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } @@ -1476,42 +1891,67 @@ 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 - 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() - companion object { - @JvmField val CODE = Type(JsonField.of("code")) + @JvmField val CODE = of("code") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { CODE, } + /** + * 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 { CODE, + /** + * 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) { CODE -> Value.CODE 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) { CODE -> Known.CODE @@ -1519,6 +1959,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1526,48 +1978,55 @@ constructor( return true } - return /* spotless:off */ other is Code && type == other.type && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, data, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect class Global + @JsonCreator private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - fun name(): String = name.getRequired("name") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Global = apply { - if (!validated) { - type() - name() - validated = true + if (validated) { + return@apply } + + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1577,39 +2036,35 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Global]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(global: Global) = apply { - this.type = global.type - this.name = global.name - additionalProperties(global.additionalProperties) + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1617,10 +2072,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Global = Global( - type, - name, + checkRequired("name", name), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -1631,42 +2094,67 @@ 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 - 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() - companion object { - @JvmField val GLOBAL = Type(JsonField.of("global")) + @JvmField val GLOBAL = of("global") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { GLOBAL, } + /** + * 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 { GLOBAL, + /** + * 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) { GLOBAL -> Value.GLOBAL 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) { GLOBAL -> Known.GLOBAL @@ -1674,6 +2162,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1681,36 +2181,39 @@ constructor( return true } - return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect class NullableVariant + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): NullableVariant = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1720,23 +2223,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [NullableVariant]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) + additionalProperties = nullableVariant.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -1744,6 +2247,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } @@ -1770,11 +2281,11 @@ constructor( return true } - return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, description, functionData, name, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "FunctionUpdateParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 91330774..9345bea8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -7,11 +7,13 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -21,27 +23,40 @@ import java.util.Optional * * Groups can consist of individual users, as well as a set of groups they inherit from */ -@JsonDeserialize(builder = Group.Builder::class) @NoAutoDetect class Group +@JsonCreator private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val deletedAt: JsonField, - private val memberUsers: JsonField>, - private val memberGroups: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") + @ExcludeMissing + private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") + @ExcludeMissing + private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the group */ fun id(): String = id.getRequired("id") + /** Name of the group */ + fun name(): String = name.getRequired("name") + /** * Unique id for the organization that the group belongs under * @@ -49,26 +64,16 @@ private constructor( */ fun orgId(): String = orgId.getRequired("org_id") - /** Identifies the user who created the group */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Date of group creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Name of the group */ - fun name(): String = name.getRequired("name") - - /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - /** Date of group deletion, or null if the group is still active */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = - Optional.ofNullable(memberUsers.getNullable("member_users")) + /** Textual description of the group */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from @@ -79,33 +84,36 @@ private constructor( fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) + /** Ids of users which belong to this group */ + fun memberUsers(): Optional> = + Optional.ofNullable(memberUsers.getNullable("member_users")) + + /** Identifies the user who created the group */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** Unique identifier for the group */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** Name of the group */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Unique id for the organization that the group belongs under * * It is forbidden to change the org after creating a group */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** Identifies the user who created the group */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Date of group creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the group */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of group deletion, or null if the group is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt - /** Ids of users which belong to this group */ - @JsonProperty("member_users") @ExcludeMissing fun _memberUsers() = memberUsers + /** Textual description of the group */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** * Ids of the groups this group inherits from @@ -113,25 +121,39 @@ private constructor( * An inheriting group has all the users contained in its member groups, as well as all of their * inherited users */ - @JsonProperty("member_groups") @ExcludeMissing fun _memberGroups() = memberGroups + @JsonProperty("member_groups") + @ExcludeMissing + fun _memberGroups(): JsonField> = memberGroups + + /** Ids of users which belong to this group */ + @JsonProperty("member_users") + @ExcludeMissing + fun _memberUsers(): JsonField> = memberUsers + + /** Identifies the user who created the group */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Group = apply { - if (!validated) { - id() - orgId() - userId() - created() - name() - description() - deletedAt() - memberUsers() - memberGroups() - validated = true + if (validated) { + return@apply } + + id() + name() + orgId() + created() + deletedAt() + description() + memberGroups() + memberUsers() + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -141,38 +163,45 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Group]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var orgId: JsonField? = null private var created: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() - private var memberUsers: JsonField> = JsonMissing.of() - private var memberGroups: JsonField> = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var memberGroups: JsonField>? = null + private var memberUsers: JsonField>? = null + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(group: Group) = apply { - this.id = group.id - this.orgId = group.orgId - this.userId = group.userId - this.created = group.created - this.name = group.name - this.description = group.description - this.deletedAt = group.deletedAt - this.memberUsers = group.memberUsers - this.memberGroups = group.memberGroups - additionalProperties(group.additionalProperties) + id = group.id + name = group.name + orgId = group.orgId + created = group.created + deletedAt = group.deletedAt + description = group.description + memberGroups = group.memberGroups.map { it.toMutableList() } + memberUsers = group.memberUsers.map { it.toMutableList() } + userId = group.userId + additionalProperties = group.additionalProperties.toMutableMap() } /** Unique identifier for the group */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the group */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } + + /** Name of the group */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the group */ + fun name(name: JsonField) = apply { this.name = name } /** * Unique id for the organization that the group belongs under @@ -186,59 +215,43 @@ private constructor( * * It is forbidden to change the org after creating a group */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - /** Identifies the user who created the group */ - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** Identifies the user who created the group */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + /** Date of group creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of group creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: Optional) = created(created.orElse(null)) /** Date of group creation */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } - /** Name of the group */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the group */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the group */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the group */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + /** Date of group deletion, or null if the group is still active */ + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) /** Date of group deletion, or null if the group is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } - /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List) = memberUsers(JsonField.of(memberUsers)) + /** Textual description of the group */ + fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Ids of users which belong to this group */ - @JsonProperty("member_users") - @ExcludeMissing - fun memberUsers(memberUsers: JsonField>) = apply { - this.memberUsers = memberUsers - } + /** Textual description of the group */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the group */ + fun description(description: JsonField) = apply { this.description = description } + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + fun memberGroups(memberGroups: List?) = + memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from @@ -246,7 +259,8 @@ private constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ - fun memberGroups(memberGroups: List) = memberGroups(JsonField.of(memberGroups)) + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.orElse(null)) /** * Ids of the groups this group inherits from @@ -254,37 +268,93 @@ private constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ - @JsonProperty("member_groups") - @ExcludeMissing fun memberGroups(memberGroups: JsonField>) = apply { - this.memberGroups = memberGroups + this.memberGroups = memberGroups.map { it.toMutableList() } } + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + fun addMemberGroup(memberGroup: String) = apply { + memberGroups = + (memberGroups ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberGroup) + } + } + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.orElse(null)) + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: JsonField>) = apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } + + /** Ids of users which belong to this group */ + fun addMemberUser(memberUser: String) = apply { + memberUsers = + (memberUsers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberUser) + } + } + + /** Identifies the user who created the group */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Identifies the user who created the group */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Identifies the user who created the group */ + fun userId(userId: JsonField) = apply { this.userId = userId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Group = Group( - id, - orgId, - userId, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("orgId", orgId), created, - name, - description, deletedAt, - memberUsers.map { it.toImmutable() }, - memberGroups.map { it.toImmutable() }, + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + userId, additionalProperties.toImmutable(), ) } @@ -294,15 +364,15 @@ private constructor( return true } - return /* spotless:off */ other is Group && id == other.id && orgId == other.orgId && userId == other.userId && created == other.created && name == other.name && description == other.description && deletedAt == other.deletedAt && memberUsers == other.memberUsers && memberGroups == other.memberGroups && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Group && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, orgId, userId, created, name, description, deletedAt, memberUsers, memberGroups, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, orgId, created, deletedAt, description, memberGroups, memberUsers, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Group{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberUsers=$memberUsers, memberGroups=$memberGroups, additionalProperties=$additionalProperties}" + "Group{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index ca5de374..4ecf780d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -3,80 +3,123 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new group. If there is an existing group with the same name as the one specified in the + * request, will return the existing group unmodified + */ class GroupCreateParams -constructor( - private val name: String, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, +private constructor( + private val body: GroupCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun name(): String = name - - fun description(): Optional = Optional.ofNullable(description) - - fun memberGroups(): Optional> = Optional.ofNullable(memberGroups) - - fun memberUsers(): Optional> = Optional.ofNullable(memberUsers) - - fun orgName(): Optional = Optional.ofNullable(orgName) +) : Params { + + /** Name of the group */ + fun name(): String = body.name() + + /** Textual description of the group */ + fun description(): Optional = body.description() + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users + */ + fun memberGroups(): Optional> = body.memberGroups() + + /** Ids of users which belong to this group */ + fun memberUsers(): Optional> = body.memberUsers() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. + */ + fun orgName(): Optional = body.orgName() + + /** Name of the group */ + fun _name(): JsonField = body._name() + + /** Textual description of the group */ + fun _description(): JsonField = body._description() + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users + */ + fun _memberGroups(): JsonField> = body._memberGroups() + + /** Ids of users which belong to this group */ + fun _memberUsers(): JsonField> = body._memberUsers() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): GroupCreateBody { - return GroupCreateBody( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): GroupCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = GroupCreateBody.Builder::class) @NoAutoDetect class GroupCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") + @ExcludeMissing + private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") + @ExcludeMissing + private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the group */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** Textual description of the group */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from @@ -84,22 +127,69 @@ constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ - @JsonProperty("member_groups") fun memberGroups(): List? = memberGroups + fun memberGroups(): Optional> = + Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - @JsonProperty("member_users") fun memberUsers(): List? = memberUsers + fun memberUsers(): Optional> = + Optional.ofNullable(memberUsers.getNullable("member_users")) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the group */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Textual description of the group */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + @JsonProperty("member_groups") + @ExcludeMissing + fun _memberGroups(): JsonField> = memberGroups + + /** Ids of users which belong to this group */ + @JsonProperty("member_users") + @ExcludeMissing + fun _memberUsers(): JsonField> = memberUsers + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupCreateBody = apply { + if (validated) { + return@apply + } + + name() + description() + memberGroups() + memberUsers() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -107,31 +197,60 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [GroupCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var description: String? = null - private var memberGroups: List? = null - private var memberUsers: List? = null - private var orgName: String? = null + private var name: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var memberGroups: JsonField>? = null + private var memberUsers: JsonField>? = null + private var orgName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(groupCreateBody: GroupCreateBody) = apply { - this.name = groupCreateBody.name - this.description = groupCreateBody.description - this.memberGroups = groupCreateBody.memberGroups - this.memberUsers = groupCreateBody.memberUsers - this.orgName = groupCreateBody.orgName - additionalProperties(groupCreateBody.additionalProperties) + name = groupCreateBody.name + description = groupCreateBody.description + memberGroups = groupCreateBody.memberGroups.map { it.toMutableList() } + memberUsers = groupCreateBody.memberUsers.map { it.toMutableList() } + orgName = groupCreateBody.orgName + additionalProperties = groupCreateBody.additionalProperties.toMutableMap() } /** Name of the group */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the group */ + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the group */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the group */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the group */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users + */ + fun memberGroups(memberGroups: List?) = + memberGroups(JsonField.ofNullable(memberGroups)) + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users + */ + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.orElse(null)) /** * Ids of the groups this group inherits from @@ -139,43 +258,102 @@ constructor( * An inheriting group has all the users contained in its member groups, as well as all * of their inherited users */ - @JsonProperty("member_groups") - fun memberGroups(memberGroups: List) = apply { - this.memberGroups = memberGroups + fun memberGroups(memberGroups: JsonField>) = apply { + this.memberGroups = memberGroups.map { it.toMutableList() } } + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users + */ + fun addMemberGroup(memberGroup: String) = apply { + memberGroups = + (memberGroups ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberGroup) + } + } + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: List?) = + memberUsers(JsonField.ofNullable(memberUsers)) + /** Ids of users which belong to this group */ - @JsonProperty("member_users") - fun memberUsers(memberUsers: List) = apply { this.memberUsers = memberUsers } + fun memberUsers(memberUsers: Optional>) = + memberUsers(memberUsers.orElse(null)) + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: JsonField>) = apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } + + /** Ids of users which belong to this group */ + fun addMemberUser(memberUser: String) = apply { + memberUsers = + (memberUsers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberUser) + } + } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): GroupCreateBody = GroupCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), description, - memberGroups?.toImmutable(), - memberUsers?.toImmutable(), + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, orgName, additionalProperties.toImmutable(), ) @@ -206,35 +384,35 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [GroupCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var description: String? = null - private var memberGroups: MutableList = mutableListOf() - private var memberUsers: MutableList = mutableListOf() - private var orgName: String? = null + private var body: GroupCreateBody.Builder = GroupCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(groupCreateParams: GroupCreateParams) = apply { - name = groupCreateParams.name - description = groupCreateParams.description - memberGroups = groupCreateParams.memberGroups?.toMutableList() ?: mutableListOf() - memberUsers = groupCreateParams.memberUsers?.toMutableList() ?: mutableListOf() - orgName = groupCreateParams.orgName + body = groupCreateParams.body.toBuilder() additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = groupCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the group */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the group */ + fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the group */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the group */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the group */ + fun description(description: JsonField) = apply { body.description(description) } /** * Ids of the groups this group inherits from @@ -242,9 +420,25 @@ constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ - fun memberGroups(memberGroups: List) = apply { - this.memberGroups.clear() - this.memberGroups.addAll(memberGroups) + fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.orElse(null)) + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + fun memberGroups(memberGroups: JsonField>) = apply { + body.memberGroups(memberGroups) } /** @@ -253,23 +447,61 @@ constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { this.memberGroups.add(memberGroup) } + fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List) = apply { - this.memberUsers.clear() - this.memberUsers.addAll(memberUsers) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.orElse(null)) + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: JsonField>) = apply { + body.memberUsers(memberUsers) } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { this.memberUsers.add(memberUser) } + fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: String?) = apply { body.orgName(orgName) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -369,38 +601,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): GroupCreateParams = GroupCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - memberGroups.toImmutable().ifEmpty { null }, - memberUsers.toImmutable().ifEmpty { null }, - orgName, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -409,11 +614,11 @@ constructor( return true } - return /* spotless:off */ other is GroupCreateParams && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "GroupCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index a60e1027..85a98d4f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a group object by its id */ class GroupDeleteParams -constructor( +private constructor( private val groupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Group id */ fun groupId(): String = groupId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [GroupDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var groupId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): GroupDeleteParams = GroupDeleteParams( - checkNotNull(groupId) { "`groupId` is required but was not set" }, + checkRequired("groupId", groupId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 05da2456..928ff615 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.GroupService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first + */ class GroupListPage private constructor( private val groupsService: GroupService, @@ -79,16 +84,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -98,11 +102,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,10 +146,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -150,8 +156,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: GroupListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index f9e04f24..8c473bfe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.GroupServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first + */ class GroupListPageAsync private constructor( private val groupsService: GroupServiceAsync, @@ -82,16 +87,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -101,11 +105,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -141,10 +149,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -153,8 +159,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: GroupListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 388cd7fc..0010b69e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first + */ class GroupListParams -constructor( +private constructor( private val endingBefore: String?, private val groupName: String?, private val ids: Ids?, @@ -31,28 +35,48 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** Name of the group to search for */ fun groupName(): Optional = Optional.ofNullable(groupName) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.groupName?.let { queryParams.put("group_name", listOf(it.toString())) } @@ -71,8 +95,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [GroupListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var groupName: String? = null @@ -102,34 +127,62 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** Name of the group to search for */ - fun groupName(groupName: String) = apply { this.groupName = groupName } + fun groupName(groupName: String?) = apply { this.groupName = groupName } + + /** Name of the group to search for */ + fun groupName(groupName: Optional) = groupName(groupName.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long) = limit(limit as Long?) + + /** Limit the number of objects to return */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * Pagination cursor id. @@ -138,7 +191,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -251,6 +314,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -260,8 +327,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -284,15 +349,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -318,18 +374,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -345,7 +411,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 0f9b8053..90421aef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -3,80 +3,123 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create or replace group. If there is an existing group with the same name as the one specified in + * the request, will replace the existing group with the provided fields + */ class GroupReplaceParams -constructor( - private val name: String, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, +private constructor( + private val body: GroupReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun name(): String = name - - fun description(): Optional = Optional.ofNullable(description) - - fun memberGroups(): Optional> = Optional.ofNullable(memberGroups) - - fun memberUsers(): Optional> = Optional.ofNullable(memberUsers) - - fun orgName(): Optional = Optional.ofNullable(orgName) +) : Params { + + /** Name of the group */ + fun name(): String = body.name() + + /** Textual description of the group */ + fun description(): Optional = body.description() + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users + */ + fun memberGroups(): Optional> = body.memberGroups() + + /** Ids of users which belong to this group */ + fun memberUsers(): Optional> = body.memberUsers() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. + */ + fun orgName(): Optional = body.orgName() + + /** Name of the group */ + fun _name(): JsonField = body._name() + + /** Textual description of the group */ + fun _description(): JsonField = body._description() + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users + */ + fun _memberGroups(): JsonField> = body._memberGroups() + + /** Ids of users which belong to this group */ + fun _memberUsers(): JsonField> = body._memberUsers() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): GroupReplaceBody { - return GroupReplaceBody( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): GroupReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = GroupReplaceBody.Builder::class) @NoAutoDetect class GroupReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") + @ExcludeMissing + private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") + @ExcludeMissing + private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the group */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** Textual description of the group */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from @@ -84,22 +127,69 @@ constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ - @JsonProperty("member_groups") fun memberGroups(): List? = memberGroups + fun memberGroups(): Optional> = + Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - @JsonProperty("member_users") fun memberUsers(): List? = memberUsers + fun memberUsers(): Optional> = + Optional.ofNullable(memberUsers.getNullable("member_users")) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the group */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Textual description of the group */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + @JsonProperty("member_groups") + @ExcludeMissing + fun _memberGroups(): JsonField> = memberGroups + + /** Ids of users which belong to this group */ + @JsonProperty("member_users") + @ExcludeMissing + fun _memberUsers(): JsonField> = memberUsers + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupReplaceBody = apply { + if (validated) { + return@apply + } + + name() + description() + memberGroups() + memberUsers() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -107,31 +197,60 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [GroupReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var description: String? = null - private var memberGroups: List? = null - private var memberUsers: List? = null - private var orgName: String? = null + private var name: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var memberGroups: JsonField>? = null + private var memberUsers: JsonField>? = null + private var orgName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(groupReplaceBody: GroupReplaceBody) = apply { - this.name = groupReplaceBody.name - this.description = groupReplaceBody.description - this.memberGroups = groupReplaceBody.memberGroups - this.memberUsers = groupReplaceBody.memberUsers - this.orgName = groupReplaceBody.orgName - additionalProperties(groupReplaceBody.additionalProperties) + name = groupReplaceBody.name + description = groupReplaceBody.description + memberGroups = groupReplaceBody.memberGroups.map { it.toMutableList() } + memberUsers = groupReplaceBody.memberUsers.map { it.toMutableList() } + orgName = groupReplaceBody.orgName + additionalProperties = groupReplaceBody.additionalProperties.toMutableMap() } /** Name of the group */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the group */ + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the group */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the group */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the group */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users + */ + fun memberGroups(memberGroups: List?) = + memberGroups(JsonField.ofNullable(memberGroups)) + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users + */ + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.orElse(null)) /** * Ids of the groups this group inherits from @@ -139,43 +258,102 @@ constructor( * An inheriting group has all the users contained in its member groups, as well as all * of their inherited users */ - @JsonProperty("member_groups") - fun memberGroups(memberGroups: List) = apply { - this.memberGroups = memberGroups + fun memberGroups(memberGroups: JsonField>) = apply { + this.memberGroups = memberGroups.map { it.toMutableList() } } + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users + */ + fun addMemberGroup(memberGroup: String) = apply { + memberGroups = + (memberGroups ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberGroup) + } + } + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: List?) = + memberUsers(JsonField.ofNullable(memberUsers)) + /** Ids of users which belong to this group */ - @JsonProperty("member_users") - fun memberUsers(memberUsers: List) = apply { this.memberUsers = memberUsers } + fun memberUsers(memberUsers: Optional>) = + memberUsers(memberUsers.orElse(null)) + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: JsonField>) = apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } + + /** Ids of users which belong to this group */ + fun addMemberUser(memberUser: String) = apply { + memberUsers = + (memberUsers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberUser) + } + } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): GroupReplaceBody = GroupReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), description, - memberGroups?.toImmutable(), - memberUsers?.toImmutable(), + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, orgName, additionalProperties.toImmutable(), ) @@ -206,35 +384,35 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [GroupReplaceParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var description: String? = null - private var memberGroups: MutableList = mutableListOf() - private var memberUsers: MutableList = mutableListOf() - private var orgName: String? = null + private var body: GroupReplaceBody.Builder = GroupReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(groupReplaceParams: GroupReplaceParams) = apply { - name = groupReplaceParams.name - description = groupReplaceParams.description - memberGroups = groupReplaceParams.memberGroups?.toMutableList() ?: mutableListOf() - memberUsers = groupReplaceParams.memberUsers?.toMutableList() ?: mutableListOf() - orgName = groupReplaceParams.orgName + body = groupReplaceParams.body.toBuilder() additionalHeaders = groupReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = groupReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = groupReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the group */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the group */ + fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the group */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the group */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the group */ + fun description(description: JsonField) = apply { body.description(description) } /** * Ids of the groups this group inherits from @@ -242,9 +420,25 @@ constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ - fun memberGroups(memberGroups: List) = apply { - this.memberGroups.clear() - this.memberGroups.addAll(memberGroups) + fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.orElse(null)) + + /** + * Ids of the groups this group inherits from + * + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users + */ + fun memberGroups(memberGroups: JsonField>) = apply { + body.memberGroups(memberGroups) } /** @@ -253,23 +447,61 @@ constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { this.memberGroups.add(memberGroup) } + fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List) = apply { - this.memberUsers.clear() - this.memberUsers.addAll(memberUsers) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.orElse(null)) + + /** Ids of users which belong to this group */ + fun memberUsers(memberUsers: JsonField>) = apply { + body.memberUsers(memberUsers) } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { this.memberUsers.add(memberUser) } + fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: String?) = apply { body.orgName(orgName) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -369,38 +601,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): GroupReplaceParams = GroupReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - memberGroups.toImmutable().ifEmpty { null }, - memberUsers.toImmutable().ifEmpty { null }, - orgName, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -409,11 +614,11 @@ constructor( return true } - return /* spotless:off */ other is GroupReplaceParams && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberGroups, memberUsers, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "GroupReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index 3a52c1ae..6dd1c211 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a group object by its id */ class GroupRetrieveParams -constructor( +private constructor( private val groupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Group id */ fun groupId(): String = groupId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [GroupRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var groupId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): GroupRetrieveParams = GroupRetrieveParams( - checkNotNull(groupId) { "`groupId` is required but was not set" }, + checkRequired("groupId", groupId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 50ae0659..bdb048a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -3,69 +3,86 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update a group object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. + */ class GroupUpdateParams -constructor( +private constructor( private val groupId: String, - private val addMemberGroups: List?, - private val addMemberUsers: List?, - private val description: String?, - private val name: String?, - private val removeMemberGroups: List?, - private val removeMemberUsers: List?, + private val body: GroupUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Group id */ fun groupId(): String = groupId - fun addMemberGroups(): Optional> = Optional.ofNullable(addMemberGroups) + /** A list of group IDs to add to the group's inheriting-from set */ + fun addMemberGroups(): Optional> = body.addMemberGroups() - fun addMemberUsers(): Optional> = Optional.ofNullable(addMemberUsers) + /** A list of user IDs to add to the group */ + fun addMemberUsers(): Optional> = body.addMemberUsers() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the group */ + fun description(): Optional = body.description() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the group */ + fun name(): Optional = body.name() - fun removeMemberGroups(): Optional> = Optional.ofNullable(removeMemberGroups) + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(): Optional> = body.removeMemberGroups() - fun removeMemberUsers(): Optional> = Optional.ofNullable(removeMemberUsers) + /** A list of user IDs to remove from the group */ + fun removeMemberUsers(): Optional> = body.removeMemberUsers() + + /** A list of group IDs to add to the group's inheriting-from set */ + fun _addMemberGroups(): JsonField> = body._addMemberGroups() + + /** A list of user IDs to add to the group */ + fun _addMemberUsers(): JsonField> = body._addMemberUsers() + + /** Textual description of the group */ + fun _description(): JsonField = body._description() + + /** Name of the group */ + fun _name(): JsonField = body._name() + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun _removeMemberGroups(): JsonField> = body._removeMemberGroups() + + /** A list of user IDs to remove from the group */ + fun _removeMemberUsers(): JsonField> = body._removeMemberUsers() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): GroupUpdateBody { - return GroupUpdateBody( - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): GroupUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -74,43 +91,103 @@ constructor( } } - @JsonDeserialize(builder = GroupUpdateBody.Builder::class) @NoAutoDetect class GroupUpdateBody + @JsonCreator internal constructor( - private val addMemberGroups: List?, - private val addMemberUsers: List?, - private val description: String?, - private val name: String?, - private val removeMemberGroups: List?, - private val removeMemberUsers: List?, - private val additionalProperties: Map, + @JsonProperty("add_member_groups") + @ExcludeMissing + private val addMemberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("add_member_users") + @ExcludeMissing + private val addMemberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("remove_member_groups") + @ExcludeMissing + private val removeMemberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("remove_member_users") + @ExcludeMissing + private val removeMemberUsers: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of group IDs to add to the group's inheriting-from set */ - @JsonProperty("add_member_groups") fun addMemberGroups(): List? = addMemberGroups + fun addMemberGroups(): Optional> = + Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) + + /** A list of user IDs to add to the group */ + fun addMemberUsers(): Optional> = + Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) + + /** Textual description of the group */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the group */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(): Optional> = + Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) + + /** A list of user IDs to remove from the group */ + fun removeMemberUsers(): Optional> = + Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) + + /** A list of group IDs to add to the group's inheriting-from set */ + @JsonProperty("add_member_groups") + @ExcludeMissing + fun _addMemberGroups(): JsonField> = addMemberGroups /** A list of user IDs to add to the group */ - @JsonProperty("add_member_users") fun addMemberUsers(): List? = addMemberUsers + @JsonProperty("add_member_users") + @ExcludeMissing + fun _addMemberUsers(): JsonField> = addMemberUsers /** Textual description of the group */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** Name of the group */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** A list of group IDs to remove from the group's inheriting-from set */ @JsonProperty("remove_member_groups") - fun removeMemberGroups(): List? = removeMemberGroups + @ExcludeMissing + fun _removeMemberGroups(): JsonField> = removeMemberGroups /** A list of user IDs to remove from the group */ @JsonProperty("remove_member_users") - fun removeMemberUsers(): List? = removeMemberUsers + @ExcludeMissing + fun _removeMemberUsers(): JsonField> = removeMemberUsers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupUpdateBody = apply { + if (validated) { + return@apply + } + + addMemberGroups() + addMemberUsers() + description() + name() + removeMemberGroups() + removeMemberUsers() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -118,80 +195,183 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [GroupUpdateBody]. */ + class Builder internal constructor() { - private var addMemberGroups: List? = null - private var addMemberUsers: List? = null - private var description: String? = null - private var name: String? = null - private var removeMemberGroups: List? = null - private var removeMemberUsers: List? = null + private var addMemberGroups: JsonField>? = null + private var addMemberUsers: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var removeMemberGroups: JsonField>? = null + private var removeMemberUsers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(groupUpdateBody: GroupUpdateBody) = apply { - this.addMemberGroups = groupUpdateBody.addMemberGroups - this.addMemberUsers = groupUpdateBody.addMemberUsers - this.description = groupUpdateBody.description - this.name = groupUpdateBody.name - this.removeMemberGroups = groupUpdateBody.removeMemberGroups - this.removeMemberUsers = groupUpdateBody.removeMemberUsers - additionalProperties(groupUpdateBody.additionalProperties) + addMemberGroups = groupUpdateBody.addMemberGroups.map { it.toMutableList() } + addMemberUsers = groupUpdateBody.addMemberUsers.map { it.toMutableList() } + description = groupUpdateBody.description + name = groupUpdateBody.name + removeMemberGroups = groupUpdateBody.removeMemberGroups.map { it.toMutableList() } + removeMemberUsers = groupUpdateBody.removeMemberUsers.map { it.toMutableList() } + additionalProperties = groupUpdateBody.additionalProperties.toMutableMap() } /** A list of group IDs to add to the group's inheriting-from set */ - @JsonProperty("add_member_groups") - fun addMemberGroups(addMemberGroups: List) = apply { - this.addMemberGroups = addMemberGroups + fun addMemberGroups(addMemberGroups: List?) = + addMemberGroups(JsonField.ofNullable(addMemberGroups)) + + /** A list of group IDs to add to the group's inheriting-from set */ + fun addMemberGroups(addMemberGroups: Optional>) = + addMemberGroups(addMemberGroups.orElse(null)) + + /** A list of group IDs to add to the group's inheriting-from set */ + fun addMemberGroups(addMemberGroups: JsonField>) = apply { + this.addMemberGroups = addMemberGroups.map { it.toMutableList() } + } + + /** A list of group IDs to add to the group's inheriting-from set */ + fun addAddMemberGroup(addMemberGroup: String) = apply { + addMemberGroups = + (addMemberGroups ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addMemberGroup) + } + } + + /** A list of user IDs to add to the group */ + fun addMemberUsers(addMemberUsers: List?) = + addMemberUsers(JsonField.ofNullable(addMemberUsers)) + + /** A list of user IDs to add to the group */ + fun addMemberUsers(addMemberUsers: Optional>) = + addMemberUsers(addMemberUsers.orElse(null)) + + /** A list of user IDs to add to the group */ + fun addMemberUsers(addMemberUsers: JsonField>) = apply { + this.addMemberUsers = addMemberUsers.map { it.toMutableList() } } /** A list of user IDs to add to the group */ - @JsonProperty("add_member_users") - fun addMemberUsers(addMemberUsers: List) = apply { - this.addMemberUsers = addMemberUsers + fun addAddMemberUser(addMemberUser: String) = apply { + addMemberUsers = + (addMemberUsers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addMemberUser) + } } /** Textual description of the group */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the group */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the group */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** Name of the group */ + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the group */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the group */ + fun name(name: JsonField) = apply { this.name = name } + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(removeMemberGroups: List?) = + removeMemberGroups(JsonField.ofNullable(removeMemberGroups)) + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(removeMemberGroups: Optional>) = + removeMemberGroups(removeMemberGroups.orElse(null)) + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { + this.removeMemberGroups = removeMemberGroups.map { it.toMutableList() } + } /** A list of group IDs to remove from the group's inheriting-from set */ - @JsonProperty("remove_member_groups") - fun removeMemberGroups(removeMemberGroups: List) = apply { - this.removeMemberGroups = removeMemberGroups + fun addRemoveMemberGroup(removeMemberGroup: String) = apply { + removeMemberGroups = + (removeMemberGroups ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removeMemberGroup) + } } /** A list of user IDs to remove from the group */ - @JsonProperty("remove_member_users") - fun removeMemberUsers(removeMemberUsers: List) = apply { - this.removeMemberUsers = removeMemberUsers + fun removeMemberUsers(removeMemberUsers: List?) = + removeMemberUsers(JsonField.ofNullable(removeMemberUsers)) + + /** A list of user IDs to remove from the group */ + fun removeMemberUsers(removeMemberUsers: Optional>) = + removeMemberUsers(removeMemberUsers.orElse(null)) + + /** A list of user IDs to remove from the group */ + fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { + this.removeMemberUsers = removeMemberUsers.map { it.toMutableList() } + } + + /** A list of user IDs to remove from the group */ + fun addRemoveMemberUser(removeMemberUser: String) = apply { + removeMemberUsers = + (removeMemberUsers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removeMemberUser) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): GroupUpdateBody = GroupUpdateBody( - addMemberGroups?.toImmutable(), - addMemberUsers?.toImmutable(), + (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (addMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, description, name, - removeMemberGroups?.toImmutable(), - removeMemberUsers?.toImmutable(), + (removeMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (removeMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -221,87 +401,135 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [GroupUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var groupId: String? = null - private var addMemberGroups: MutableList = mutableListOf() - private var addMemberUsers: MutableList = mutableListOf() - private var description: String? = null - private var name: String? = null - private var removeMemberGroups: MutableList = mutableListOf() - private var removeMemberUsers: MutableList = mutableListOf() + private var body: GroupUpdateBody.Builder = GroupUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(groupUpdateParams: GroupUpdateParams) = apply { groupId = groupUpdateParams.groupId - addMemberGroups = groupUpdateParams.addMemberGroups?.toMutableList() ?: mutableListOf() - addMemberUsers = groupUpdateParams.addMemberUsers?.toMutableList() ?: mutableListOf() - description = groupUpdateParams.description - name = groupUpdateParams.name - removeMemberGroups = - groupUpdateParams.removeMemberGroups?.toMutableList() ?: mutableListOf() - removeMemberUsers = - groupUpdateParams.removeMemberUsers?.toMutableList() ?: mutableListOf() + body = groupUpdateParams.body.toBuilder() additionalHeaders = groupUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = groupUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = groupUpdateParams.additionalBodyProperties.toMutableMap() } /** Group id */ fun groupId(groupId: String) = apply { this.groupId = groupId } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: List) = apply { - this.addMemberGroups.clear() - this.addMemberGroups.addAll(addMemberGroups) + fun addMemberGroups(addMemberGroups: List?) = apply { + body.addMemberGroups(addMemberGroups) + } + + /** A list of group IDs to add to the group's inheriting-from set */ + fun addMemberGroups(addMemberGroups: Optional>) = + addMemberGroups(addMemberGroups.orElse(null)) + + /** A list of group IDs to add to the group's inheriting-from set */ + fun addMemberGroups(addMemberGroups: JsonField>) = apply { + body.addMemberGroups(addMemberGroups) } /** A list of group IDs to add to the group's inheriting-from set */ fun addAddMemberGroup(addMemberGroup: String) = apply { - this.addMemberGroups.add(addMemberGroup) + body.addAddMemberGroup(addMemberGroup) } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: List) = apply { - this.addMemberUsers.clear() - this.addMemberUsers.addAll(addMemberUsers) + fun addMemberUsers(addMemberUsers: List?) = apply { + body.addMemberUsers(addMemberUsers) } /** A list of user IDs to add to the group */ - fun addAddMemberUser(addMemberUser: String) = apply { - this.addMemberUsers.add(addMemberUser) + fun addMemberUsers(addMemberUsers: Optional>) = + addMemberUsers(addMemberUsers.orElse(null)) + + /** A list of user IDs to add to the group */ + fun addMemberUsers(addMemberUsers: JsonField>) = apply { + body.addMemberUsers(addMemberUsers) } + /** A list of user IDs to add to the group */ + fun addAddMemberUser(addMemberUser: String) = apply { body.addAddMemberUser(addMemberUser) } + + /** Textual description of the group */ + fun description(description: String?) = apply { body.description(description) } + /** Textual description of the group */ - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the group */ + fun description(description: JsonField) = apply { body.description(description) } + + /** Name of the group */ + fun name(name: String?) = apply { body.name(name) } /** Name of the group */ - fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the group */ + fun name(name: JsonField) = apply { body.name(name) } + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(removeMemberGroups: List?) = apply { + body.removeMemberGroups(removeMemberGroups) + } + + /** A list of group IDs to remove from the group's inheriting-from set */ + fun removeMemberGroups(removeMemberGroups: Optional>) = + removeMemberGroups(removeMemberGroups.orElse(null)) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: List) = apply { - this.removeMemberGroups.clear() - this.removeMemberGroups.addAll(removeMemberGroups) + fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { + body.removeMemberGroups(removeMemberGroups) } /** A list of group IDs to remove from the group's inheriting-from set */ fun addRemoveMemberGroup(removeMemberGroup: String) = apply { - this.removeMemberGroups.add(removeMemberGroup) + body.addRemoveMemberGroup(removeMemberGroup) } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: List) = apply { - this.removeMemberUsers.clear() - this.removeMemberUsers.addAll(removeMemberUsers) + fun removeMemberUsers(removeMemberUsers: List?) = apply { + body.removeMemberUsers(removeMemberUsers) + } + + /** A list of user IDs to remove from the group */ + fun removeMemberUsers(removeMemberUsers: Optional>) = + removeMemberUsers(removeMemberUsers.orElse(null)) + + /** A list of user IDs to remove from the group */ + fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { + body.removeMemberUsers(removeMemberUsers) } /** A list of user IDs to remove from the group */ fun addRemoveMemberUser(removeMemberUser: String) = apply { - this.removeMemberUsers.add(removeMemberUser) + body.addRemoveMemberUser(removeMemberUser) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -402,40 +630,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): GroupUpdateParams = GroupUpdateParams( - checkNotNull(groupId) { "`groupId` is required but was not set" }, - addMemberGroups.toImmutable().ifEmpty { null }, - addMemberUsers.toImmutable().ifEmpty { null }, - description, - name, - removeMemberGroups.toImmutable().ifEmpty { null }, - removeMemberUsers.toImmutable().ifEmpty { null }, + checkRequired("groupId", groupId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -444,11 +644,11 @@ constructor( return true } - return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, addMemberGroups, addMemberUsers, description, name, removeMemberGroups, removeMemberUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "GroupUpdateParams{groupId=$groupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index 556406f9..11fc83da 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -7,75 +7,63 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional /** A dataset event */ -@JsonDeserialize(builder = InsertDatasetEvent.Builder::class) @NoAutoDetect class InsertDatasetEvent +@JsonCreator private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val _parentId: JsonField, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val spanParents: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") + @ExcludeMissing + private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") + @ExcludeMissing + private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") + @ExcludeMissing + private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") + @ExcludeMissing + private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) - */ - fun expected(): JsonValue = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate * one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - /** The timestamp the dataset event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - /** * The `_is_merge` field controls how the row is merged with any existing row with the same id * in the DB. By default (or when set to `false`), the existing row is completely replaced by @@ -106,6 +94,13 @@ private constructor( fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the @@ -122,6 +117,27 @@ private constructor( */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + /** The timestamp the dataset event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. * The span_id is a unique identifier describing the row's place in the a trace, and the @@ -138,7 +154,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) + fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -156,7 +172,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) + fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -177,41 +193,14 @@ private constructor( fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate * one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The `_is_merge` field controls how the row is merged with any existing row with the same id @@ -225,7 +214,7 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. @@ -240,7 +229,17 @@ private constructor( * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and * `input.c`. */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + @JsonProperty("_merge_paths") + @ExcludeMissing + fun __mergePaths(): JsonField>> = _mergePaths + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete(): JsonField = _objectDelete /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking @@ -256,7 +255,19 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + + /** The timestamp the dataset event was created */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -274,7 +285,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -292,7 +303,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -310,29 +321,36 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents + @JsonProperty("span_parents") + @ExcludeMissing + fun _spanParents(): JsonField> = spanParents + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InsertDatasetEvent = apply { - if (!validated) { - input() - expected() - metadata().map { it.validate() } - tags() - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - _parentId() - spanId() - rootSpanId() - spanParents() - validated = true + if (validated) { + return@apply } + + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + created() + metadata().ifPresent { it.validate() } + rootSpanId() + spanId() + spanParents() + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -342,119 +360,87 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InsertDatasetEvent]. */ + class Builder internal constructor() { - private var input: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() private var _isMerge: JsonField = JsonMissing.of() - private var _mergePaths: JsonField>> = JsonMissing.of() + private var _mergePaths: JsonField>>? = null + private var _objectDelete: JsonField = JsonMissing.of() private var _parentId: JsonField = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() + private var spanId: JsonField = JsonMissing.of() + private var spanParents: JsonField>? = null + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(insertDatasetEvent: InsertDatasetEvent) = apply { - this.input = insertDatasetEvent.input - this.expected = insertDatasetEvent.expected - this.metadata = insertDatasetEvent.metadata - this.tags = insertDatasetEvent.tags - this.id = insertDatasetEvent.id - this.created = insertDatasetEvent.created - this._objectDelete = insertDatasetEvent._objectDelete - this._isMerge = insertDatasetEvent._isMerge - this._mergePaths = insertDatasetEvent._mergePaths - this._parentId = insertDatasetEvent._parentId - this.spanId = insertDatasetEvent.spanId - this.rootSpanId = insertDatasetEvent.rootSpanId - this.spanParents = insertDatasetEvent.spanParents - additionalProperties(insertDatasetEvent.additionalProperties) + id = insertDatasetEvent.id + _isMerge = insertDatasetEvent._isMerge + _mergePaths = insertDatasetEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertDatasetEvent._objectDelete + _parentId = insertDatasetEvent._parentId + created = insertDatasetEvent.created + expected = insertDatasetEvent.expected + input = insertDatasetEvent.input + metadata = insertDatasetEvent.metadata + rootSpanId = insertDatasetEvent.rootSpanId + spanId = insertDatasetEvent.spanId + spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } + tags = insertDatasetEvent.tags.map { it.toMutableList() } + additionalProperties = insertDatasetEvent.additionalProperties.toMutableMap() } /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun id(id: String?) = id(JsonField.ofNullable(id)) /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will * generate one for you */ - fun id(id: String) = id(JsonField.of(id)) + fun id(id: Optional) = id(id.orElse(null)) /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will * generate one for you */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the dataset event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun id(id: JsonField) = apply { this.id = id } /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** * The `_is_merge` field controls how the row is merged with any existing row with the same @@ -468,7 +454,8 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.orElse(null) as Boolean?) /** * The `_is_merge` field controls how the row is merged with any existing row with the same @@ -482,8 +469,6 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** @@ -499,7 +484,24 @@ private constructor( * case, due to the merge paths, we have replaced `input.a` and `output`, but have still * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = + _mergePaths(JsonField.ofNullable(_mergePaths)) + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: Optional>>) = + _mergePaths(_mergePaths.orElse(null)) /** * The `_merge_paths` field allows controlling the depth of the merge, when @@ -514,10 +516,63 @@ private constructor( * case, due to the merge paths, we have replaced `input.a` and `output`, but have still * deep-merged `input` and `input.c`. */ - @JsonProperty("_merge_paths") - @ExcludeMissing fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths + this._mergePaths = _mergePaths.map { it.toMutableList() } + } + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun addMergePath(mergePath: List) = apply { + _mergePaths = + (_mergePaths ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(mergePath) + } + } + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + fun _objectDelete(_objectDelete: Boolean?) = + _objectDelete(JsonField.ofNullable(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun _objectDelete(_objectDelete: Optional) = + _objectDelete(_objectDelete.orElse(null) as Boolean?) + + /** + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset + */ + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete } /** @@ -534,7 +589,23 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: Optional) = _parentId(_parentId.orElse(null)) /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking @@ -550,10 +621,55 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") - @ExcludeMissing fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + /** The timestamp the dataset event was created */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** The timestamp the dataset event was created */ + fun created(created: Optional) = created(created.orElse(null)) + + /** The timestamp the dataset event was created */ + fun created(created: JsonField) = apply { this.created = created } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) + */ + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + */ + fun input(input: JsonValue) = apply { this.input = input } + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to * \_parent_id. The span_id is a unique identifier describing the row's place in the a @@ -571,7 +687,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -590,9 +706,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.orElse(null)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -611,7 +725,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -630,9 +744,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -651,7 +763,64 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + fun spanId(spanId: Optional) = spanId(spanId.orElse(null)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -670,41 +839,99 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_parents") - @ExcludeMissing fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents + this.spanParents = spanParents.map { it.toMutableList() } + } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(spanParent) + } + } + + /** A list of tags to log */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags to log */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InsertDatasetEvent = InsertDatasetEvent( - input, - expected, - metadata, - tags.map { it.toImmutable() }, id, - created, - _objectDelete, _isMerge, - _mergePaths.map { it.toImmutable() }, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, _parentId, - spanId, + created, + expected, + input, + metadata, rootSpanId, - spanParents.map { it.toImmutable() }, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -716,23 +943,26 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -742,29 +972,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -790,15 +1026,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertDatasetEvent && input == other.input && expected == other.expected && metadata == other.metadata && tags == other.tags && id == other.id && created == other.created && _objectDelete == other._objectDelete && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _parentId == other._parentId && spanId == other.spanId && rootSpanId == other.rootSpanId && spanParents == other.spanParents && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(input, expected, metadata, tags, id, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, created, expected, input, metadata, rootSpanId, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertDatasetEvent{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" + "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 80aa1350..d057d704 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -7,23 +7,25 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects -@JsonDeserialize(builder = InsertEventsResponse.Builder::class) @NoAutoDetect class InsertEventsResponse +@JsonCreator private constructor( - private val rowIds: JsonField>, - private val additionalProperties: Map, + @JsonProperty("row_ids") + @ExcludeMissing + private val rowIds: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ @@ -32,17 +34,21 @@ private constructor( /** * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField> = rowIds @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InsertEventsResponse = apply { - if (!validated) { - rowIds() - validated = true + if (validated) { + return@apply } + + rowIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -52,15 +58,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InsertEventsResponse]. */ + class Builder internal constructor() { - private var rowIds: JsonField> = JsonMissing.of() + private var rowIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(insertEventsResponse: InsertEventsResponse) = apply { - this.rowIds = insertEventsResponse.rowIds - additionalProperties(insertEventsResponse.additionalProperties) + rowIds = insertEventsResponse.rowIds.map { it.toMutableList() } + additionalProperties = insertEventsResponse.additionalProperties.toMutableMap() } /** @@ -73,27 +80,49 @@ private constructor( * The ids of all rows that were inserted, aligning one-to-one with the rows provided as * input */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } + fun rowIds(rowIds: JsonField>) = apply { + this.rowIds = rowIds.map { it.toMutableList() } + } + + /** + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input + */ + fun addRowId(rowId: String) = apply { + rowIds = + (rowIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(rowId) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InsertEventsResponse = InsertEventsResponse( - rowIds.map { it.toImmutable() }, + checkRequired("rowIds", rowIds).map { it.toImmutable() }, additionalProperties.toImmutable() ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 5b406d62..adeac0f2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -7,61 +7,152 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional /** An experiment event */ -@JsonDeserialize(builder = InsertExperimentEvent.Builder::class) @NoAutoDetect class InsertExperimentEvent +@JsonCreator private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val datasetRecordId: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val _parentId: JsonField, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val spanParents: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") + @ExcludeMissing + private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") + @ExcludeMissing + private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") + @ExcludeMissing + private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") + @ExcludeMissing + private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + private val context: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_record_id") + @ExcludeMissing + private val datasetRecordId: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), + @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") + @ExcludeMissing + private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun input(): JsonValue = input + fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. + */ + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show + * up in subsequent fetches for this experiment + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** The timestamp the experiment event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun output(): JsonValue = output + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to @@ -71,21 +162,15 @@ private constructor( * digging into analyses. However, we may later use these values to re-score outputs or * fine-tune your models */ - fun expected(): JsonValue = expected - - /** The error that occurred, if any. */ - fun error(): JsonValue = error + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input /** * A dictionary with additional data about the test example, model outputs, or just about @@ -96,9 +181,6 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** * Metrics are numerical measurements tracking the execution of the code that produced the * experiment event. Use "start" and "end" to track the time span over which the experiment @@ -107,38 +189,92 @@ private constructor( fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. */ - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) - /** The timestamp the experiment event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The `_is_merge` field controls how the row is merged with any existing row with the same id @@ -152,7 +288,7 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. @@ -167,8 +303,17 @@ private constructor( * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and * `input.c`. */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + @JsonProperty("_merge_paths") + @ExcludeMissing + fun __mergePaths(): JsonField>> = _mergePaths + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show + * up in subsequent fetches for this experiment + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete(): JsonField = _objectDelete /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking @@ -184,7 +329,41 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + + /** + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + + /** The timestamp the experiment event was created */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + @JsonProperty("dataset_record_id") + @ExcludeMissing + fun _datasetRecordId(): JsonField = datasetRecordId + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -202,7 +381,23 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments + */ + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes(): JsonField = spanAttributes /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -220,7 +415,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -238,227 +433,41 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("span_parents") + @ExcludeMissing + fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId - - /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete - - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge - - /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. - */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths - - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId - - /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId - - /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InsertExperimentEvent = apply { - if (!validated) { - input() - output() - expected() - error() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - datasetRecordId() - created() - _objectDelete() - _isMerge() - _mergePaths() - _parentId() - spanId() - rootSpanId() - spanParents() - validated = true + if (validated) { + return@apply } + + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + context().ifPresent { it.validate() } + created() + datasetRecordId() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + rootSpanId() + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanId() + spanParents() + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -468,338 +477,534 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InsertExperimentEvent]. */ + class Builder internal constructor() { - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _mergePaths: JsonField>>? = null + private var _objectDelete: JsonField = JsonMissing.of() + private var _parentId: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var datasetRecordId: JsonField = JsonMissing.of() private var error: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var rootSpanId: JsonField = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() private var spanAttributes: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _mergePaths: JsonField>> = JsonMissing.of() - private var _parentId: JsonField = JsonMissing.of() private var spanId: JsonField = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() + private var spanParents: JsonField>? = null + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(insertExperimentEvent: InsertExperimentEvent) = apply { - this.input = insertExperimentEvent.input - this.output = insertExperimentEvent.output - this.expected = insertExperimentEvent.expected - this.error = insertExperimentEvent.error - this.scores = insertExperimentEvent.scores - this.metadata = insertExperimentEvent.metadata - this.tags = insertExperimentEvent.tags - this.metrics = insertExperimentEvent.metrics - this.context = insertExperimentEvent.context - this.spanAttributes = insertExperimentEvent.spanAttributes - this.id = insertExperimentEvent.id - this.datasetRecordId = insertExperimentEvent.datasetRecordId - this.created = insertExperimentEvent.created - this._objectDelete = insertExperimentEvent._objectDelete - this._isMerge = insertExperimentEvent._isMerge - this._mergePaths = insertExperimentEvent._mergePaths - this._parentId = insertExperimentEvent._parentId - this.spanId = insertExperimentEvent.spanId - this.rootSpanId = insertExperimentEvent.rootSpanId - this.spanParents = insertExperimentEvent.spanParents - additionalProperties(insertExperimentEvent.additionalProperties) + id = insertExperimentEvent.id + _isMerge = insertExperimentEvent._isMerge + _mergePaths = insertExperimentEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertExperimentEvent._objectDelete + _parentId = insertExperimentEvent._parentId + context = insertExperimentEvent.context + created = insertExperimentEvent.created + datasetRecordId = insertExperimentEvent.datasetRecordId + error = insertExperimentEvent.error + expected = insertExperimentEvent.expected + input = insertExperimentEvent.input + metadata = insertExperimentEvent.metadata + metrics = insertExperimentEvent.metrics + output = insertExperimentEvent.output + rootSpanId = insertExperimentEvent.rootSpanId + scores = insertExperimentEvent.scores + spanAttributes = insertExperimentEvent.spanAttributes + spanId = insertExperimentEvent.spanId + spanParents = insertExperimentEvent.spanParents.map { it.toMutableList() } + tags = insertExperimentEvent.tags.map { it.toMutableList() } + additionalProperties = insertExperimentEvent.additionalProperties.toMutableMap() } /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun id(id: Optional) = id(id.orElse(null)) /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun id(id: JsonField) = apply { this.id = id } - /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) + fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.orElse(null) as Boolean?) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun _mergePaths(_mergePaths: List>?) = + _mergePaths(JsonField.ofNullable(_mergePaths)) - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: Optional>>) = + _mergePaths(_mergePaths.orElse(null)) - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + fun addMergePath(mergePath: List) = apply { + _mergePaths = + (_mergePaths ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(mergePath) + } + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun _objectDelete(_objectDelete: Boolean?) = + _objectDelete(JsonField.ofNullable(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun _objectDelete(_objectDelete: Optional) = + _objectDelete(_objectDelete.orElse(null) as Boolean?) + + /** + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment + */ + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: Optional) = _parentId(_parentId.orElse(null)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } /** * Context is additional information about the code that produced the experiment event. It * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to * track the location in code which produced the experiment event */ - fun context(context: Context) = context(JsonField.of(context)) + fun context(context: Context?) = context(JsonField.ofNullable(context)) + + /** + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event + */ + fun context(context: Optional) = context(context.orElse(null)) /** * Context is additional information about the code that produced the experiment event. It * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to * track the location in code which produced the experiment event */ - @JsonProperty("context") - @ExcludeMissing fun context(context: JsonField) = apply { this.context = context } - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) + /** The timestamp the experiment event was created */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes + /** The timestamp the experiment event was created */ + fun created(created: Optional) = created(created.orElse(null)) + + /** The timestamp the experiment event was created */ + fun created(created: JsonField) = apply { this.created = created } + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: String?) = + datasetRecordId(JsonField.ofNullable(datasetRecordId)) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: Optional) = + datasetRecordId(datasetRecordId.orElse(null)) + + /** + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to + */ + fun datasetRecordId(datasetRecordId: JsonField) = apply { + this.datasetRecordId = datasetRecordId } + /** The error that occurred, if any. */ + fun error(error: JsonValue) = apply { this.error = error } + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models + */ + fun expected(expected: JsonValue) = apply { this.expected = expected } + + /** + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical + */ + fun input(input: JsonValue) = apply { this.input = input } + /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun id(id: String) = id(JsonField.of(id)) + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - - /** The timestamp the experiment event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) - /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced + */ + fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun output(output: JsonValue) = apply { this.output = output } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.orElse(null)) /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. */ - fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths - } + fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + fun scores(scores: Optional) = scores(scores.orElse(null)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments + */ + fun scores(scores: JsonField) = apply { this.scores = scores } + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes?) = + spanAttributes(JsonField.ofNullable(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: Optional) = + spanAttributes(spanAttributes.orElse(null)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -818,7 +1023,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + fun spanId(spanId: Optional) = spanId(spanId.orElse(null)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -837,8 +1042,6 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") - @ExcludeMissing fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** @@ -858,7 +1061,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -877,9 +1080,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -898,7 +1099,9 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -917,48 +1120,85 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_parents") - @ExcludeMissing - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(spanParent) + } + } + + /** A list of tags to log */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags to log */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InsertExperimentEvent = InsertExperimentEvent( - input, - output, - expected, + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + context, + created, + datasetRecordId, error, - scores, + expected, + input, metadata, - tags.map { it.toImmutable() }, metrics, - context, + output, + rootSpanId, + scores, spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toImmutable() }, - _parentId, spanId, - rootSpanId, - spanParents.map { it.toImmutable() }, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -968,52 +1208,65 @@ private constructor( * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the * location in code which produced the experiment event */ - @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect class Context + @JsonCreator private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Name of the file in code where the experiment event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the experiment event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - /** Line of code where the experiment event was created */ fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + /** Name of the file in code where the experiment event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename(): JsonField = callerFilename + /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + fun _callerFunctionname(): JsonField = callerFunctionname /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonField = callerLineno @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + if (validated) { + return@apply } + + callerFilename() + callerFunctionname() + callerLineno() + validated = true } fun toBuilder() = Builder().from(this) @@ -1023,71 +1276,87 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Context]. */ + class Builder internal constructor() { - private var callerFunctionname: JsonField = JsonMissing.of() private var callerFilename: JsonField = JsonMissing.of() + private var callerFunctionname: JsonField = JsonMissing.of() private var callerLineno: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() } + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: String?) = + callerFilename(JsonField.ofNullable(callerFilename)) + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: Optional) = + callerFilename(callerFilename.orElse(null)) + + /** Name of the file in code where the experiment event was created */ + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } + + /** The function in code which created the experiment event */ + fun callerFunctionname(callerFunctionname: String?) = + callerFunctionname(JsonField.ofNullable(callerFunctionname)) + /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: Optional) = + callerFunctionname(callerFunctionname.orElse(null)) /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing fun callerFunctionname(callerFunctionname: JsonField) = apply { this.callerFunctionname = callerFunctionname } - /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + /** Line of code where the experiment event was created */ + fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + /** Line of code where the experiment event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun callerLineno(callerLineno: Optional) = + callerLineno(callerLineno.orElse(null) as Long?) /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing fun callerLineno(callerLineno: JsonField) = apply { this.callerLineno = callerLineno } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Context = Context( - callerFunctionname, callerFilename, + callerFunctionname, callerLineno, additionalProperties.toImmutable(), ) @@ -1098,17 +1367,17 @@ private constructor( return true } - return /* spotless:off */ other is Context && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(callerFilename, callerFunctionname, callerLineno, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -1118,23 +1387,26 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1144,29 +1416,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -1192,28 +1470,55 @@ private constructor( * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced */ - @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect class Metrics + @JsonCreator private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val callerFunctionname: JsonValue, - private val callerFilename: JsonValue, - private val callerLineno: JsonValue, - private val additionalProperties: Map, + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + private val completionTokens: JsonField = JsonMissing.of(), + @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") + @ExcludeMissing + private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename(): JsonValue = callerFilename + + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname(): JsonValue = callerFunctionname + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** * A unix timestamp recording when the section of code which produced the experiment event @@ -1229,80 +1534,62 @@ private constructor( Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * A unix timestamp recording when the section of code which produced the experiment event + * started */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) /** The total number of tokens in the input and output of the experiment event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - /** This metric is deprecated */ - fun callerFunctionname(): JsonValue = callerFunctionname - - /** This metric is deprecated */ - fun callerFilename(): JsonValue = callerFilename - - /** This metric is deprecated */ - fun callerLineno(): JsonValue = callerLineno - /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField = completionTokens /** * A unix timestamp recording when the section of code which produced the experiment event * finished */ - @JsonProperty("end") @ExcludeMissing fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField = promptTokens /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * A unix timestamp recording when the section of code which produced the experiment event + * started */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** This metric is deprecated */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - callerFunctionname() - callerFilename() - callerLineno() - validated = true + if (validated) { + return@apply } + + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true } fun toBuilder() = Builder().from(this) @@ -1312,143 +1599,195 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metrics]. */ + class Builder internal constructor() { - private var start: JsonField = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() private var end: JsonField = JsonMissing.of() private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() + private var start: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() - private var callerFunctionname: JsonValue = JsonMissing.of() - private var callerFilename: JsonValue = JsonMissing.of() - private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - this.callerFunctionname = metrics.callerFunctionname - this.callerFilename = metrics.callerFilename - this.callerLineno = metrics.callerLineno - additionalProperties(metrics.additionalProperties) + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } + + /** This metric is deprecated */ + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.orElse(null) as Long?) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens } /** * A unix timestamp recording when the section of code which produced the experiment - * event started + * event finished */ - fun start(start: Double) = start(JsonField.of(start)) + fun end(end: Double?) = end(JsonField.ofNullable(end)) /** * A unix timestamp recording when the section of code which produced the experiment - * event started + * event finished */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun end(end: Double) = end(end as Double?) /** * A unix timestamp recording when the section of code which produced the experiment * event finished */ - fun end(end: Double) = end(JsonField.of(end)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun end(end: Optional) = end(end.orElse(null) as Double?) /** * A unix timestamp recording when the section of code which produced the experiment * event finished */ - @JsonProperty("end") - @ExcludeMissing fun end(end: JsonField) = apply { this.end = end } /** * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun promptTokens(promptTokens: Optional) = + promptTokens(promptTokens.orElse(null) as Long?) /** * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) + fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun start(start: Double) = start(start as Double?) - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun start(start: Optional) = start(start.orElse(null) as Double?) + + /** + * A unix timestamp recording when the section of code which produced the experiment + * event started + */ + fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(tokens: Long) = tokens(tokens as Long?) - /** This metric is deprecated */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + /** The total number of tokens in the input and output of the experiment event. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun tokens(tokens: Optional) = tokens(tokens.orElse(null) as Long?) - /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + /** The total number of tokens in the input and output of the experiment event. */ + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metrics = Metrics( - start, + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, end, promptTokens, - completionTokens, + start, tokens, - callerFunctionname, - callerFilename, - callerLineno, additionalProperties.toImmutable(), ) } @@ -1458,17 +1797,17 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && start == other.start && end == other.end && promptTokens == other.promptTokens && completionTokens == other.completionTokens && tokens == other.tokens && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(callerFilename, callerFunctionname, callerLineno, completionTokens, end, promptTokens, start, tokens, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** @@ -1480,23 +1819,26 @@ private constructor( * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect class Scores + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Scores = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1506,29 +1848,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Scores]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) + additionalProperties = scores.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Scores = Scores(additionalProperties.toImmutable()) } @@ -1554,15 +1902,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertExperimentEvent && input == other.input && output == other.output && expected == other.expected && error == other.error && scores == other.scores && metadata == other.metadata && tags == other.tags && metrics == other.metrics && context == other.context && spanAttributes == other.spanAttributes && id == other.id && datasetRecordId == other.datasetRecordId && created == other.created && _objectDelete == other._objectDelete && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _parentId == other._parentId && spanId == other.spanId && rootSpanId == other.rootSpanId && spanParents == other.spanParents && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, datasetRecordId, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, datasetRecordId, error, expected, input, metadata, metrics, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertExperimentEvent{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" + "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index 3a179072..6b33a1a6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -7,126 +7,77 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional /** A project logs event */ -@JsonDeserialize(builder = InsertProjectLogsEvent.Builder::class) @NoAutoDetect class InsertProjectLogsEvent +@JsonCreator private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val _parentId: JsonField, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val spanParents: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") + @ExcludeMissing + private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") + @ExcludeMissing + private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") + @ExcludeMissing + private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") + @ExcludeMissing + private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + private val context: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), + @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") + @ExcludeMissing + private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. - */ - fun expected(): JsonValue = expected - - /** The error that occurred, if any. */ - fun error(): JsonValue = error - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced - */ - fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - - /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event - */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - /** The timestamp the project logs event was created */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs - */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) - /** * The `_is_merge` field controls how the row is merged with any existing row with the same id * in the DB. By default (or when set to `false`), the existing row is completely replaced by @@ -157,6 +108,13 @@ private constructor( fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not + * show up in subsequent fetches for this project logs + */ + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the @@ -173,6 +131,57 @@ private constructor( */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** The timestamp the project logs event was created */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + + /** + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. + */ + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + + /** + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. + */ + @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. * The span_id is a unique identifier describing the row's place in the a trace, and the @@ -189,7 +198,22 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) + fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) + + /** + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -207,7 +231,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) + fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -228,85 +252,14 @@ private constructor( fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs - */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The `_is_merge` field controls how the row is merged with any existing row with the same id @@ -320,7 +273,7 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. @@ -335,7 +288,17 @@ private constructor( * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and * `input.c`. */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + @JsonProperty("_merge_paths") + @ExcludeMissing + fun __mergePaths(): JsonField>> = _mergePaths + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not + * show up in subsequent fetches for this project logs + */ + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete(): JsonField = _objectDelete /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking @@ -351,7 +314,33 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + + /** + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + + /** The timestamp the project logs event was created */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced + */ + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -369,14 +358,30 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. + */ + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes(): JsonField = spanAttributes + + /** + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": @@ -387,7 +392,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. @@ -405,35 +410,40 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents + @JsonProperty("span_parents") + @ExcludeMissing + fun _spanParents(): JsonField> = spanParents + + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): InsertProjectLogsEvent = apply { - if (!validated) { - input() - output() - expected() - error() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanAttributes().map { it.validate() } - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - _parentId() - spanId() - rootSpanId() - spanParents() - validated = true + if (validated) { + return@apply } + + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + context().ifPresent { it.validate() } + created() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + rootSpanId() + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanId() + spanParents() + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -443,70 +453,313 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InsertProjectLogsEvent]. */ + class Builder internal constructor() { - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() + private var id: JsonField = JsonMissing.of() + private var _isMerge: JsonField = JsonMissing.of() + private var _mergePaths: JsonField>>? = null + private var _objectDelete: JsonField = JsonMissing.of() + private var _parentId: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() private var error: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var rootSpanId: JsonField = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() private var spanAttributes: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var _objectDelete: JsonField = JsonMissing.of() - private var _isMerge: JsonField = JsonMissing.of() - private var _mergePaths: JsonField>> = JsonMissing.of() - private var _parentId: JsonField = JsonMissing.of() private var spanId: JsonField = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() + private var spanParents: JsonField>? = null + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(insertProjectLogsEvent: InsertProjectLogsEvent) = apply { - this.input = insertProjectLogsEvent.input - this.output = insertProjectLogsEvent.output - this.expected = insertProjectLogsEvent.expected - this.error = insertProjectLogsEvent.error - this.scores = insertProjectLogsEvent.scores - this.metadata = insertProjectLogsEvent.metadata - this.tags = insertProjectLogsEvent.tags - this.metrics = insertProjectLogsEvent.metrics - this.context = insertProjectLogsEvent.context - this.spanAttributes = insertProjectLogsEvent.spanAttributes - this.id = insertProjectLogsEvent.id - this.created = insertProjectLogsEvent.created - this._objectDelete = insertProjectLogsEvent._objectDelete - this._isMerge = insertProjectLogsEvent._isMerge - this._mergePaths = insertProjectLogsEvent._mergePaths - this._parentId = insertProjectLogsEvent._parentId - this.spanId = insertProjectLogsEvent.spanId - this.rootSpanId = insertProjectLogsEvent.rootSpanId - this.spanParents = insertProjectLogsEvent.spanParents - additionalProperties(insertProjectLogsEvent.additionalProperties) + id = insertProjectLogsEvent.id + _isMerge = insertProjectLogsEvent._isMerge + _mergePaths = insertProjectLogsEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertProjectLogsEvent._objectDelete + _parentId = insertProjectLogsEvent._parentId + context = insertProjectLogsEvent.context + created = insertProjectLogsEvent.created + error = insertProjectLogsEvent.error + expected = insertProjectLogsEvent.expected + input = insertProjectLogsEvent.input + metadata = insertProjectLogsEvent.metadata + metrics = insertProjectLogsEvent.metrics + output = insertProjectLogsEvent.output + rootSpanId = insertProjectLogsEvent.rootSpanId + scores = insertProjectLogsEvent.scores + spanAttributes = insertProjectLogsEvent.spanAttributes + spanId = insertProjectLogsEvent.spanId + spanParents = insertProjectLogsEvent.spanParents.map { it.toMutableList() } + tags = insertProjectLogsEvent.tags.map { it.toMutableList() } + additionalProperties = insertProjectLogsEvent.additionalProperties.toMutableMap() } /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun id(id: Optional) = id(id.orElse(null)) + + /** + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.orElse(null) as Boolean?) + + /** + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * `{"id": "foo", "input": {"b": 11, "c": 20}}` + */ + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: List>?) = + _mergePaths(JsonField.ofNullable(_mergePaths)) + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: Optional>>) = + _mergePaths(_mergePaths.orElse(null)) + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } + + /** + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun addMergePath(mergePath: List) = apply { + _mergePaths = + (_mergePaths ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(mergePath) + } + } + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs + */ + fun _objectDelete(_objectDelete: Boolean?) = + _objectDelete(JsonField.ofNullable(_objectDelete)) + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs + */ + fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun _objectDelete(_objectDelete: Optional) = + _objectDelete(_objectDelete.orElse(null) as Boolean?) + + /** + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs + */ + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: Optional) = _parentId(_parentId.orElse(null)) + + /** + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. + */ + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: Context?) = context(JsonField.ofNullable(context)) + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: Optional) = context(context.orElse(null)) + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: JsonField) = apply { this.context = context } + + /** The timestamp the project logs event was created */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** The timestamp the project logs event was created */ + fun created(created: Optional) = created(created.orElse(null)) + + /** The timestamp the project logs event was created */ + fun created(created: JsonField) = apply { this.created = created } + + /** The error that occurred, if any. */ + fun error(error: JsonValue) = apply { this.error = error } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to @@ -516,38 +769,21 @@ private constructor( * into analyses. However, we may later use these values to re-score outputs or fine-tune * your models. */ - @JsonProperty("expected") - @ExcludeMissing fun expected(expected: JsonValue) = apply { this.expected = expected } - /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) + fun input(input: JsonValue) = apply { this.input = input } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -556,7 +792,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -565,194 +801,159 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - /** * Metrics are numerical measurements tracking the execution of the code that produced the * project logs event. Use "start" and "end" to track the time span over which the project * logs event was produced */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** * Metrics are numerical measurements tracking the execution of the code that produced the * project logs event. Use "start" and "end" to track the time span over which the project * logs event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ - fun context(context: Context) = context(JsonField.of(context)) + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun output(output: JsonValue) = apply { this.output = output } /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. */ - fun id(id: String) = id(JsonField.of(id)) + fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp the project logs event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.orElse(null)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. + * + * If the row is being merged into an existing row, this field will be ignored. */ - fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - @JsonProperty("_object_delete") - @ExcludeMissing - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) + fun scores(scores: Optional) = scores(scores.orElse(null)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun scores(scores: JsonField) = apply { this.scores = scores } - /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ - fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes?) = + spanAttributes(JsonField.ofNullable(spanAttributes)) - /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ - @JsonProperty("_merge_paths") - @ExcludeMissing - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths - } + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: Optional) = + spanAttributes(spanAttributes.orElse(null)) - /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ - fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -771,7 +972,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + fun spanId(spanId: Optional) = spanId(spanId.orElse(null)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -790,8 +991,6 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") - @ExcludeMissing fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** @@ -811,7 +1010,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -830,9 +1029,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -851,7 +1048,9 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -870,47 +1069,84 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_parents") - @ExcludeMissing - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(spanParent) + } + } + + /** A list of tags to log */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags to log */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InsertProjectLogsEvent = InsertProjectLogsEvent( - input, - output, - expected, + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + context, + created, error, - scores, + expected, + input, metadata, - tags.map { it.toImmutable() }, metrics, - context, + output, + rootSpanId, + scores, spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toImmutable() }, - _parentId, spanId, - rootSpanId, - spanParents.map { it.toImmutable() }, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -920,52 +1156,65 @@ private constructor( * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the * location in code which produced the project logs event */ - @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect class Context + @JsonCreator private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Name of the file in code where the project logs event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the project logs event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - /** Line of code where the project logs event was created */ fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + /** Name of the file in code where the project logs event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename(): JsonField = callerFilename + /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + fun _callerFunctionname(): JsonField = callerFunctionname /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonField = callerLineno @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + if (validated) { + return@apply } + + callerFilename() + callerFunctionname() + callerLineno() + validated = true } fun toBuilder() = Builder().from(this) @@ -975,71 +1224,87 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Context]. */ + class Builder internal constructor() { - private var callerFunctionname: JsonField = JsonMissing.of() private var callerFilename: JsonField = JsonMissing.of() + private var callerFunctionname: JsonField = JsonMissing.of() private var callerLineno: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() } + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: String?) = + callerFilename(JsonField.ofNullable(callerFilename)) + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: Optional) = + callerFilename(callerFilename.orElse(null)) + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } + + /** The function in code which created the project logs event */ + fun callerFunctionname(callerFunctionname: String?) = + callerFunctionname(JsonField.ofNullable(callerFunctionname)) + /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: Optional) = + callerFunctionname(callerFunctionname.orElse(null)) /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing fun callerFunctionname(callerFunctionname: JsonField) = apply { this.callerFunctionname = callerFunctionname } - /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + /** Line of code where the project logs event was created */ + fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + /** Line of code where the project logs event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun callerLineno(callerLineno: Optional) = + callerLineno(callerLineno.orElse(null) as Long?) /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing fun callerLineno(callerLineno: JsonField) = apply { this.callerLineno = callerLineno } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Context = Context( - callerFunctionname, callerFilename, + callerFunctionname, callerLineno, additionalProperties.toImmutable(), ) @@ -1050,17 +1315,17 @@ private constructor( return true } - return /* spotless:off */ other is Context && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(callerFilename, callerFunctionname, callerLineno, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -1070,23 +1335,26 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1096,29 +1364,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -1144,28 +1418,55 @@ private constructor( * project logs event. Use "start" and "end" to track the time span over which the project logs * event was produced */ - @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect class Metrics + @JsonCreator private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val callerFunctionname: JsonValue, - private val callerFilename: JsonValue, - private val callerLineno: JsonValue, - private val additionalProperties: Map, + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + private val completionTokens: JsonField = JsonMissing.of(), + @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") + @ExcludeMissing + private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename(): JsonValue = callerFilename + + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname(): JsonValue = callerFunctionname + + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** * A unix timestamp recording when the section of code which produced the project logs event @@ -1181,80 +1482,62 @@ private constructor( Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * A unix timestamp recording when the section of code which produced the project logs event + * started */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) /** The total number of tokens in the input and output of the project logs event. */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - /** This metric is deprecated */ - fun callerFunctionname(): JsonValue = callerFunctionname - - /** This metric is deprecated */ - fun callerFilename(): JsonValue = callerFilename - - /** This metric is deprecated */ - fun callerLineno(): JsonValue = callerLineno - /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("completion_tokens") + @ExcludeMissing + fun _completionTokens(): JsonField = completionTokens /** * A unix timestamp recording when the section of code which produced the project logs event * finished */ - @JsonProperty("end") @ExcludeMissing fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** * The number of tokens in the prompt used to generate the project logs event (only set if * this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens(): JsonField = promptTokens /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * A unix timestamp recording when the section of code which produced the project logs event + * started */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** This metric is deprecated */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - callerFunctionname() - callerFilename() - callerLineno() - validated = true + if (validated) { + return@apply } + + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true } fun toBuilder() = Builder().from(this) @@ -1264,143 +1547,195 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metrics]. */ + class Builder internal constructor() { - private var start: JsonField = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() private var end: JsonField = JsonMissing.of() private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() + private var start: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() - private var callerFunctionname: JsonValue = JsonMissing.of() - private var callerFilename: JsonValue = JsonMissing.of() - private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - this.callerFunctionname = metrics.callerFunctionname - this.callerFilename = metrics.callerFilename - this.callerLineno = metrics.callerLineno - additionalProperties(metrics.additionalProperties) + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } + + /** This metric is deprecated */ + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.orElse(null) as Long?) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens } /** * A unix timestamp recording when the section of code which produced the project logs - * event started + * event finished */ - fun start(start: Double) = start(JsonField.of(start)) + fun end(end: Double?) = end(JsonField.ofNullable(end)) /** * A unix timestamp recording when the section of code which produced the project logs - * event started + * event finished */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun end(end: Double) = end(end as Double?) /** * A unix timestamp recording when the section of code which produced the project logs * event finished */ - fun end(end: Double) = end(JsonField.of(end)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun end(end: Optional) = end(end.orElse(null) as Double?) /** * A unix timestamp recording when the section of code which produced the project logs * event finished */ - @JsonProperty("end") - @ExcludeMissing fun end(end: JsonField) = apply { this.end = end } /** * The number of tokens in the prompt used to generate the project logs event (only set * if this is an LLM span) */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun promptTokens(promptTokens: Optional) = + promptTokens(promptTokens.orElse(null) as Long?) /** * The number of tokens in the prompt used to generate the project logs event (only set * if this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * A unix timestamp recording when the section of code which produced the project logs + * event started */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) + fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * A unix timestamp recording when the section of code which produced the project logs + * event started */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun start(start: Double) = start(start as Double?) - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun start(start: Optional) = start(start.orElse(null) as Double?) + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(tokens: Long) = tokens(tokens as Long?) - /** This metric is deprecated */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + /** The total number of tokens in the input and output of the project logs event. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun tokens(tokens: Optional) = tokens(tokens.orElse(null) as Long?) - /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metrics = Metrics( - start, + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, end, promptTokens, - completionTokens, + start, tokens, - callerFunctionname, - callerFilename, - callerLineno, additionalProperties.toImmutable(), ) } @@ -1410,17 +1745,17 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && start == other.start && end == other.end && promptTokens == other.promptTokens && completionTokens == other.completionTokens && tokens == other.tokens && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(callerFilename, callerFunctionname, callerLineno, completionTokens, end, promptTokens, start, tokens, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** @@ -1432,23 +1767,26 @@ private constructor( * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect class Scores + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Scores = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1458,29 +1796,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Scores]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) + additionalProperties = scores.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Scores = Scores(additionalProperties.toImmutable()) } @@ -1506,15 +1850,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertProjectLogsEvent && input == other.input && output == other.output && expected == other.expected && error == other.error && scores == other.scores && metadata == other.metadata && tags == other.tags && metrics == other.metrics && context == other.context && spanAttributes == other.spanAttributes && id == other.id && created == other.created && _objectDelete == other._objectDelete && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _parentId == other._parentId && spanId == other.spanId && rootSpanId == other.rootSpanId && spanParents == other.spanParents && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(input, output, expected, error, scores, metadata, tags, metrics, context, spanAttributes, id, created, _objectDelete, _isMerge, _mergePaths, _parentId, spanId, rootSpanId, spanParents, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, error, expected, input, metadata, metrics, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertProjectLogsEvent{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _parentId=$_parentId, spanId=$spanId, rootSpanId=$rootSpanId, spanParents=$spanParents, additionalProperties=$additionalProperties}" + "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index cbccf51b..ca31c473 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -7,35 +7,47 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional /** Summary of a metric's performance */ -@JsonDeserialize(builder = MetricSummary.Builder::class) @NoAutoDetect class MetricSummary +@JsonCreator private constructor( - private val name: JsonField, - private val metric: JsonField, - private val unit: JsonField, - private val diff: JsonField, - private val improvements: JsonField, - private val regressions: JsonField, - private val additionalProperties: Map, + @JsonProperty("improvements") + @ExcludeMissing + private val improvements: JsonField = JsonMissing.of(), + @JsonProperty("metric") + @ExcludeMissing + private val metric: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("regressions") + @ExcludeMissing + private val regressions: JsonField = JsonMissing.of(), + @JsonProperty("unit") @ExcludeMissing private val unit: JsonField = JsonMissing.of(), + @JsonProperty("diff") @ExcludeMissing private val diff: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Number of improvements in the metric */ + fun improvements(): Long = improvements.getRequired("improvements") + + /** Average metric across all examples */ + fun metric(): Double = metric.getRequired("metric") /** Name of the metric */ fun name(): String = name.getRequired("name") - /** Average metric across all examples */ - fun metric(): Double = metric.getRequired("metric") + /** Number of regressions in the metric */ + fun regressions(): Long = regressions.getRequired("regressions") /** Unit label for the metric */ fun unit(): String = unit.getRequired("unit") @@ -44,43 +56,43 @@ private constructor( fun diff(): Optional = Optional.ofNullable(diff.getNullable("diff")) /** Number of improvements in the metric */ - fun improvements(): Long = improvements.getRequired("improvements") + @JsonProperty("improvements") + @ExcludeMissing + fun _improvements(): JsonField = improvements - /** Number of regressions in the metric */ - fun regressions(): Long = regressions.getRequired("regressions") + /** Average metric across all examples */ + @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric /** Name of the metric */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Average metric across all examples */ - @JsonProperty("metric") @ExcludeMissing fun _metric() = metric + /** Number of regressions in the metric */ + @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions /** Unit label for the metric */ - @JsonProperty("unit") @ExcludeMissing fun _unit() = unit + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit /** Difference in metric between the current and comparison experiment */ - @JsonProperty("diff") @ExcludeMissing fun _diff() = diff - - /** Number of improvements in the metric */ - @JsonProperty("improvements") @ExcludeMissing fun _improvements() = improvements - - /** Number of regressions in the metric */ - @JsonProperty("regressions") @ExcludeMissing fun _regressions() = regressions + @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): MetricSummary = apply { - if (!validated) { - name() - metric() - unit() - diff() - improvements() - regressions() - validated = true + if (validated) { + return@apply } + + improvements() + metric() + name() + regressions() + unit() + diff() + validated = true } fun toBuilder() = Builder().from(this) @@ -90,97 +102,91 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [MetricSummary]. */ + class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() - private var metric: JsonField = JsonMissing.of() - private var unit: JsonField = JsonMissing.of() + private var improvements: JsonField? = null + private var metric: JsonField? = null + private var name: JsonField? = null + private var regressions: JsonField? = null + private var unit: JsonField? = null private var diff: JsonField = JsonMissing.of() - private var improvements: JsonField = JsonMissing.of() - private var regressions: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metricSummary: MetricSummary) = apply { - this.name = metricSummary.name - this.metric = metricSummary.metric - this.unit = metricSummary.unit - this.diff = metricSummary.diff - this.improvements = metricSummary.improvements - this.regressions = metricSummary.regressions - additionalProperties(metricSummary.additionalProperties) + improvements = metricSummary.improvements + metric = metricSummary.metric + name = metricSummary.name + regressions = metricSummary.regressions + unit = metricSummary.unit + diff = metricSummary.diff + additionalProperties = metricSummary.additionalProperties.toMutableMap() } - /** Name of the metric */ - fun name(name: String) = name(JsonField.of(name)) + /** Number of improvements in the metric */ + fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) - /** Name of the metric */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Number of improvements in the metric */ + fun improvements(improvements: JsonField) = apply { this.improvements = improvements } /** Average metric across all examples */ fun metric(metric: Double) = metric(JsonField.of(metric)) /** Average metric across all examples */ - @JsonProperty("metric") - @ExcludeMissing fun metric(metric: JsonField) = apply { this.metric = metric } + /** Name of the metric */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the metric */ + fun name(name: JsonField) = apply { this.name = name } + + /** Number of regressions in the metric */ + fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) + + /** Number of regressions in the metric */ + fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + /** Unit label for the metric */ fun unit(unit: String) = unit(JsonField.of(unit)) /** Unit label for the metric */ - @JsonProperty("unit") - @ExcludeMissing fun unit(unit: JsonField) = apply { this.unit = unit } /** Difference in metric between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) /** Difference in metric between the current and comparison experiment */ - @JsonProperty("diff") - @ExcludeMissing fun diff(diff: JsonField) = apply { this.diff = diff } - /** Number of improvements in the metric */ - fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) - - /** Number of improvements in the metric */ - @JsonProperty("improvements") - @ExcludeMissing - fun improvements(improvements: JsonField) = apply { this.improvements = improvements } - - /** Number of regressions in the metric */ - fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) - - /** Number of regressions in the metric */ - @JsonProperty("regressions") - @ExcludeMissing - fun regressions(regressions: JsonField) = apply { this.regressions = regressions } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): MetricSummary = MetricSummary( - name, - metric, - unit, + checkRequired("improvements", improvements), + checkRequired("metric", metric), + checkRequired("name", name), + checkRequired("regressions", regressions), + checkRequired("unit", unit), diff, - improvements, - regressions, additionalProperties.toImmutable(), ) } @@ -190,15 +196,15 @@ private constructor( return true } - return /* spotless:off */ other is MetricSummary && name == other.name && metric == other.metric && unit == other.unit && diff == other.diff && improvements == other.improvements && regressions == other.regressions && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MetricSummary && improvements == other.improvements && metric == other.metric && name == other.name && regressions == other.regressions && unit == other.unit && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, metric, unit, diff, improvements, regressions, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(improvements, metric, name, regressions, unit, diff, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "MetricSummary{name=$name, metric=$metric, unit=$unit, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" + "MetricSummary{improvements=$improvements, metric=$metric, name=$name, regressions=$regressions, unit=$unit, diff=$diff, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 8d6da526..7f1799d4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -10,7 +10,9 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -27,19 +29,25 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = OnlineScoreConfig.Builder::class) @NoAutoDetect class OnlineScoreConfig +@JsonCreator private constructor( - private val samplingRate: JsonField, - private val scorers: JsonField>, - private val applyToRootSpan: JsonField, - private val applyToSpanNames: JsonField>, - private val additionalProperties: Map, + @JsonProperty("sampling_rate") + @ExcludeMissing + private val samplingRate: JsonField = JsonMissing.of(), + @JsonProperty("scorers") + @ExcludeMissing + private val scorers: JsonField> = JsonMissing.of(), + @JsonProperty("apply_to_root_span") + @ExcludeMissing + private val applyToRootSpan: JsonField = JsonMissing.of(), + @JsonProperty("apply_to_span_names") + @ExcludeMissing + private val applyToSpanNames: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The sampling rate for online scoring */ fun samplingRate(): Double = samplingRate.getRequired("sampling_rate") @@ -55,29 +63,39 @@ private constructor( Optional.ofNullable(applyToSpanNames.getNullable("apply_to_span_names")) /** The sampling rate for online scoring */ - @JsonProperty("sampling_rate") @ExcludeMissing fun _samplingRate() = samplingRate + @JsonProperty("sampling_rate") + @ExcludeMissing + fun _samplingRate(): JsonField = samplingRate /** The list of scorers to use for online scoring */ - @JsonProperty("scorers") @ExcludeMissing fun _scorers() = scorers + @JsonProperty("scorers") @ExcludeMissing fun _scorers(): JsonField> = scorers /** Whether to trigger online scoring on the root span of each trace */ - @JsonProperty("apply_to_root_span") @ExcludeMissing fun _applyToRootSpan() = applyToRootSpan + @JsonProperty("apply_to_root_span") + @ExcludeMissing + fun _applyToRootSpan(): JsonField = applyToRootSpan /** Trigger online scoring on any spans with a name in this list */ - @JsonProperty("apply_to_span_names") @ExcludeMissing fun _applyToSpanNames() = applyToSpanNames + @JsonProperty("apply_to_span_names") + @ExcludeMissing + fun _applyToSpanNames(): JsonField> = applyToSpanNames @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): OnlineScoreConfig = apply { - if (!validated) { - samplingRate() - scorers() - applyToRootSpan() - applyToSpanNames() - validated = true + if (validated) { + return@apply } + + samplingRate() + scorers().forEach { it.validate() } + applyToRootSpan() + applyToSpanNames() + validated = true } fun toBuilder() = Builder().from(this) @@ -87,29 +105,28 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [OnlineScoreConfig]. */ + class Builder internal constructor() { - private var samplingRate: JsonField = JsonMissing.of() - private var scorers: JsonField> = JsonMissing.of() + private var samplingRate: JsonField? = null + private var scorers: JsonField>? = null private var applyToRootSpan: JsonField = JsonMissing.of() - private var applyToSpanNames: JsonField> = JsonMissing.of() + private var applyToSpanNames: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(onlineScoreConfig: OnlineScoreConfig) = apply { - this.samplingRate = onlineScoreConfig.samplingRate - this.scorers = onlineScoreConfig.scorers - this.applyToRootSpan = onlineScoreConfig.applyToRootSpan - this.applyToSpanNames = onlineScoreConfig.applyToSpanNames - additionalProperties(onlineScoreConfig.additionalProperties) + samplingRate = onlineScoreConfig.samplingRate + scorers = onlineScoreConfig.scorers.map { it.toMutableList() } + applyToRootSpan = onlineScoreConfig.applyToRootSpan + applyToSpanNames = onlineScoreConfig.applyToSpanNames.map { it.toMutableList() } + additionalProperties = onlineScoreConfig.additionalProperties.toMutableMap() } /** The sampling rate for online scoring */ fun samplingRate(samplingRate: Double) = samplingRate(JsonField.of(samplingRate)) /** The sampling rate for online scoring */ - @JsonProperty("sampling_rate") - @ExcludeMissing fun samplingRate(samplingRate: JsonField) = apply { this.samplingRate = samplingRate } @@ -118,52 +135,99 @@ private constructor( fun scorers(scorers: List) = scorers(JsonField.of(scorers)) /** The list of scorers to use for online scoring */ - @JsonProperty("scorers") - @ExcludeMissing - fun scorers(scorers: JsonField>) = apply { this.scorers = scorers } + fun scorers(scorers: JsonField>) = apply { + this.scorers = scorers.map { it.toMutableList() } + } + + /** The list of scorers to use for online scoring */ + fun addScorer(scorer: Scorer) = apply { + scorers = + (scorers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(scorer) + } + } + + /** The list of scorers to use for online scoring */ + fun addScorer(function: Scorer.Function) = addScorer(Scorer.ofFunction(function)) + + /** The list of scorers to use for online scoring */ + fun addScorer(global: Scorer.Global) = addScorer(Scorer.ofGlobal(global)) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: Boolean) = - applyToRootSpan(JsonField.of(applyToRootSpan)) + fun applyToRootSpan(applyToRootSpan: Boolean?) = + applyToRootSpan(JsonField.ofNullable(applyToRootSpan)) + + /** Whether to trigger online scoring on the root span of each trace */ + fun applyToRootSpan(applyToRootSpan: Boolean) = applyToRootSpan(applyToRootSpan as Boolean?) + + /** Whether to trigger online scoring on the root span of each trace */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun applyToRootSpan(applyToRootSpan: Optional) = + applyToRootSpan(applyToRootSpan.orElse(null) as Boolean?) /** Whether to trigger online scoring on the root span of each trace */ - @JsonProperty("apply_to_root_span") - @ExcludeMissing fun applyToRootSpan(applyToRootSpan: JsonField) = apply { this.applyToRootSpan = applyToRootSpan } /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: List) = - applyToSpanNames(JsonField.of(applyToSpanNames)) + fun applyToSpanNames(applyToSpanNames: List?) = + applyToSpanNames(JsonField.ofNullable(applyToSpanNames)) + + /** Trigger online scoring on any spans with a name in this list */ + fun applyToSpanNames(applyToSpanNames: Optional>) = + applyToSpanNames(applyToSpanNames.orElse(null)) /** Trigger online scoring on any spans with a name in this list */ - @JsonProperty("apply_to_span_names") - @ExcludeMissing fun applyToSpanNames(applyToSpanNames: JsonField>) = apply { - this.applyToSpanNames = applyToSpanNames + this.applyToSpanNames = applyToSpanNames.map { it.toMutableList() } + } + + /** Trigger online scoring on any spans with a name in this list */ + fun addApplyToSpanName(applyToSpanName: String) = apply { + applyToSpanNames = + (applyToSpanNames ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(applyToSpanName) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): OnlineScoreConfig = OnlineScoreConfig( - samplingRate, - scorers.map { it.toImmutable() }, + checkRequired("samplingRate", samplingRate), + checkRequired("scorers", scorers).map { it.toImmutable() }, applyToRootSpan, - applyToSpanNames.map { it.toImmutable() }, + (applyToSpanNames ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -177,8 +241,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun function(): Optional = Optional.ofNullable(function) fun global(): Optional = Optional.ofNullable(global) @@ -201,15 +263,25 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): Scorer = apply { - if (!validated) { - if (function == null && global == null) { - throw BraintrustInvalidDataException("Unknown Scorer: $_json") - } - function?.validate() - global?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitFunction(function: Function) { + function.validate() + } + + override fun visitGlobal(global: Global) { + global.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -237,18 +309,29 @@ private constructor( @JvmStatic fun ofGlobal(global: Global) = Scorer(global = global) } + /** An interface that defines how to map each variant of [Scorer] to a value of type [T]. */ interface Visitor { fun visitFunction(function: Function): T fun visitGlobal(global: Global): T + /** + * Maps an unknown variant of [Scorer] to a value of type [T]. + * + * An instance of [Scorer] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Scorer: $json") } } - class Deserializer : BaseDeserializer(Scorer::class) { + internal class Deserializer : BaseDeserializer(Scorer::class) { override fun ObjectCodec.deserialize(node: JsonNode): Scorer { val json = JsonValue.fromJsonNode(node) @@ -266,7 +349,7 @@ private constructor( } } - class Serializer : BaseSerializer(Scorer::class) { + internal class Serializer : BaseSerializer(Scorer::class) { override fun serialize( value: Scorer, @@ -282,35 +365,42 @@ private constructor( } } - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function + @JsonCreator private constructor( - private val type: JsonField, - private val id: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun id(): String = id.getRequired("id") fun type(): Type = type.getRequired("type") - fun id(): String = id.getRequired("id") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - type() - id() - validated = true + if (validated) { + return@apply } + + id() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -320,39 +410,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Function]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.type = function.type - this.id = function.id - additionalProperties(function.additionalProperties) + id = function.id + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -360,10 +446,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Function = Function( - type, - id, + checkRequired("id", id), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -374,42 +468,67 @@ 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 - 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() - companion object { - @JvmField val FUNCTION = Type(JsonField.of("function")) + @JvmField val FUNCTION = of("function") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { FUNCTION, } + /** + * 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 { FUNCTION, + /** + * 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) { 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) { FUNCTION -> Known.FUNCTION @@ -417,6 +536,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -424,48 +555,55 @@ private constructor( return true } - return /* spotless:off */ other is Function && type == other.type && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, id, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" + "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect class Global + @JsonCreator private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - fun name(): String = name.getRequired("name") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Global = apply { - if (!validated) { - type() - name() - validated = true + if (validated) { + return@apply } + + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -475,39 +613,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Global]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(global: Global) = apply { - this.type = global.type - this.name = global.name - additionalProperties(global.additionalProperties) + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -515,10 +649,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Global = Global( - type, - name, + checkRequired("name", name), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -529,42 +671,67 @@ 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 - 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() - companion object { - @JvmField val GLOBAL = Type(JsonField.of("global")) + @JvmField val GLOBAL = of("global") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { GLOBAL, } + /** + * 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 { GLOBAL, + /** + * 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) { GLOBAL -> Value.GLOBAL 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) { GLOBAL -> Known.GLOBAL @@ -572,6 +739,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -579,17 +758,17 @@ private constructor( return true } - return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 7f3fc444..59ea25d6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -7,31 +7,41 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = Organization.Builder::class) @NoAutoDetect class Organization +@JsonCreator private constructor( - private val id: JsonField, - private val name: JsonField, - private val apiUrl: JsonField, - private val isUniversalApi: JsonField, - private val proxyUrl: JsonField, - private val realtimeUrl: JsonField, - private val created: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("api_url") + @ExcludeMissing + private val apiUrl: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("is_universal_api") + @ExcludeMissing + private val isUniversalApi: JsonField = JsonMissing.of(), + @JsonProperty("proxy_url") + @ExcludeMissing + private val proxyUrl: JsonField = JsonMissing.of(), + @JsonProperty("realtime_url") + @ExcludeMissing + private val realtimeUrl: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the organization */ fun id(): String = id.getRequired("id") @@ -40,6 +50,9 @@ private constructor( fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) + /** Date of organization creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) @@ -48,41 +61,46 @@ private constructor( fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) - /** Date of organization creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Unique identifier for the organization */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the organization */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("api_url") @ExcludeMissing fun _apiUrl() = apiUrl + @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl - @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi() = isUniversalApi + /** Date of organization creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl() = proxyUrl + @JsonProperty("is_universal_api") + @ExcludeMissing + fun _isUniversalApi(): JsonField = isUniversalApi - @JsonProperty("realtime_url") @ExcludeMissing fun _realtimeUrl() = realtimeUrl + @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl - /** Date of organization creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("realtime_url") + @ExcludeMissing + fun _realtimeUrl(): JsonField = realtimeUrl @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Organization = apply { - if (!validated) { - id() - name() - apiUrl() - isUniversalApi() - proxyUrl() - realtimeUrl() - created() - validated = true + if (validated) { + return@apply } + + id() + name() + apiUrl() + created() + isUniversalApi() + proxyUrl() + realtimeUrl() + validated = true } fun toBuilder() = Builder().from(this) @@ -92,100 +110,110 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Organization]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var apiUrl: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() private var isUniversalApi: JsonField = JsonMissing.of() private var proxyUrl: JsonField = JsonMissing.of() private var realtimeUrl: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(organization: Organization) = apply { - this.id = organization.id - this.name = organization.name - this.apiUrl = organization.apiUrl - this.isUniversalApi = organization.isUniversalApi - this.proxyUrl = organization.proxyUrl - this.realtimeUrl = organization.realtimeUrl - this.created = organization.created - additionalProperties(organization.additionalProperties) + id = organization.id + name = organization.name + apiUrl = organization.apiUrl + created = organization.created + isUniversalApi = organization.isUniversalApi + proxyUrl = organization.proxyUrl + realtimeUrl = organization.realtimeUrl + additionalProperties = organization.additionalProperties.toMutableMap() } /** Unique identifier for the organization */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the organization */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } /** Name of the organization */ fun name(name: String) = name(JsonField.of(name)) /** Name of the organization */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } - fun apiUrl(apiUrl: String) = apiUrl(JsonField.of(apiUrl)) + fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) + + fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.orElse(null)) - @JsonProperty("api_url") - @ExcludeMissing fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } - fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(JsonField.of(isUniversalApi)) + /** Date of organization creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** Date of organization creation */ + fun created(created: Optional) = created(created.orElse(null)) + + /** Date of organization creation */ + fun created(created: JsonField) = apply { this.created = created } + + fun isUniversalApi(isUniversalApi: Boolean?) = + isUniversalApi(JsonField.ofNullable(isUniversalApi)) + + fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isUniversalApi(isUniversalApi: Optional) = + isUniversalApi(isUniversalApi.orElse(null) as Boolean?) - @JsonProperty("is_universal_api") - @ExcludeMissing fun isUniversalApi(isUniversalApi: JsonField) = apply { this.isUniversalApi = isUniversalApi } - fun proxyUrl(proxyUrl: String) = proxyUrl(JsonField.of(proxyUrl)) + fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) - @JsonProperty("proxy_url") - @ExcludeMissing - fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.orElse(null)) - fun realtimeUrl(realtimeUrl: String) = realtimeUrl(JsonField.of(realtimeUrl)) + fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } - @JsonProperty("realtime_url") - @ExcludeMissing - fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } + fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) - /** Date of organization creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.orElse(null)) - /** Date of organization creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Organization = Organization( - id, - name, + checkRequired("id", id), + checkRequired("name", name), apiUrl, + created, isUniversalApi, proxyUrl, realtimeUrl, - created, additionalProperties.toImmutable(), ) } @@ -195,15 +223,15 @@ private constructor( return true } - return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && created == other.created && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && created == other.created && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, apiUrl, isUniversalApi, proxyUrl, realtimeUrl, created, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, apiUrl, created, isUniversalApi, proxyUrl, realtimeUrl, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Organization{id=$id, name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, created=$created, additionalProperties=$additionalProperties}" + "Organization{id=$id, name=$name, apiUrl=$apiUrl, created=$created, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index ce556db7..f6fa9f62 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete an organization object by its id */ class OrganizationDeleteParams -constructor( +private constructor( private val organizationId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Organization id */ fun organizationId(): String = organizationId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [OrganizationDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var organizationId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -192,7 +195,7 @@ constructor( fun build(): OrganizationDeleteParams = OrganizationDeleteParams( - checkNotNull(organizationId) { "`organizationId` is required but was not set" }, + checkRequired("organizationId", organizationId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index c6411018..f347b31b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.OrganizationService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first + */ class OrganizationListPage private constructor( private val organizationsService: OrganizationService, @@ -89,16 +94,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -108,11 +113,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -148,10 +157,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -160,8 +167,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: OrganizationListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index 309b4c7b..e5ab24f5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.OrganizationServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first + */ class OrganizationListPageAsync private constructor( private val organizationsService: OrganizationServiceAsync, @@ -92,16 +97,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +116,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +160,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +170,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: OrganizationListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index eb3a4fcc..325a6b2b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first + */ class OrganizationListParams -constructor( +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -30,26 +34,45 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.ids?.let { queryParams.put("ids", listOf(it.toString())) } @@ -67,8 +90,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [OrganizationListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var ids: Ids? = null @@ -96,31 +120,65 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long) = limit(limit as Long?) + + /** Limit the number of objects to return */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** Filter search results to within a particular organization */ + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. @@ -129,7 +187,8 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -241,6 +300,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -250,8 +313,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -274,15 +335,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -308,18 +360,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -335,7 +397,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 2a7fd616..911055df 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -3,94 +3,166 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** Modify organization membership */ class OrganizationMemberUpdateParams -constructor( - private val inviteUsers: InviteUsers?, - private val orgId: String?, - private val orgName: String?, - private val removeUsers: RemoveUsers?, +private constructor( + private val body: OrganizationMemberUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun inviteUsers(): Optional = Optional.ofNullable(inviteUsers) + /** Users to invite to the organization */ + fun inviteUsers(): Optional = body.inviteUsers() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the id of the organization. + */ + fun orgId(): Optional = body.orgId() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the name of the organization. + */ + fun orgName(): Optional = body.orgName() - fun orgId(): Optional = Optional.ofNullable(orgId) + /** Users to remove from the organization */ + fun removeUsers(): Optional = body.removeUsers() - fun orgName(): Optional = Optional.ofNullable(orgName) + /** Users to invite to the organization */ + fun _inviteUsers(): JsonField = body._inviteUsers() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the id of the organization. + */ + fun _orgId(): JsonField = body._orgId() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the name of the organization. + */ + fun _orgName(): JsonField = body._orgName() + + /** Users to remove from the organization */ + fun _removeUsers(): JsonField = body._removeUsers() - fun removeUsers(): Optional = Optional.ofNullable(removeUsers) + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): OrganizationMemberUpdateBody { - return OrganizationMemberUpdateBody( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): OrganizationMemberUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = OrganizationMemberUpdateBody.Builder::class) @NoAutoDetect class OrganizationMemberUpdateBody + @JsonCreator internal constructor( - private val inviteUsers: InviteUsers?, - private val orgId: String?, - private val orgName: String?, - private val removeUsers: RemoveUsers?, - private val additionalProperties: Map, + @JsonProperty("invite_users") + @ExcludeMissing + private val inviteUsers: JsonField = JsonMissing.of(), + @JsonProperty("org_id") + @ExcludeMissing + private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("remove_users") + @ExcludeMissing + private val removeUsers: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Users to invite to the organization */ - @JsonProperty("invite_users") fun inviteUsers(): InviteUsers? = inviteUsers + fun inviteUsers(): Optional = + Optional.ofNullable(inviteUsers.getNullable("invite_users")) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. + */ + fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. + */ + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Users to remove from the organization */ + fun removeUsers(): Optional = + Optional.ofNullable(removeUsers.getNullable("remove_users")) + + /** Users to invite to the organization */ + @JsonProperty("invite_users") + @ExcludeMissing + fun _inviteUsers(): JsonField = inviteUsers /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, or in case you want to explicitly assert * the organization you are modifying, you may specify the id of the organization. */ - @JsonProperty("org_id") fun orgId(): String? = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, or in case you want to explicitly assert * the organization you are modifying, you may specify the name of the organization. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName /** Users to remove from the organization */ - @JsonProperty("remove_users") fun removeUsers(): RemoveUsers? = removeUsers + @JsonProperty("remove_users") + @ExcludeMissing + fun _removeUsers(): JsonField = removeUsers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): OrganizationMemberUpdateBody = apply { + if (validated) { + return@apply + } + + inviteUsers().ifPresent { it.validate() } + orgId() + orgName() + removeUsers().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -98,26 +170,37 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [OrganizationMemberUpdateBody]. */ + class Builder internal constructor() { - private var inviteUsers: InviteUsers? = null - private var orgId: String? = null - private var orgName: String? = null - private var removeUsers: RemoveUsers? = null + private var inviteUsers: JsonField = JsonMissing.of() + private var orgId: JsonField = JsonMissing.of() + private var orgName: JsonField = JsonMissing.of() + private var removeUsers: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(organizationMemberUpdateBody: OrganizationMemberUpdateBody) = apply { - this.inviteUsers = organizationMemberUpdateBody.inviteUsers - this.orgId = organizationMemberUpdateBody.orgId - this.orgName = organizationMemberUpdateBody.orgName - this.removeUsers = organizationMemberUpdateBody.removeUsers - additionalProperties(organizationMemberUpdateBody.additionalProperties) + inviteUsers = organizationMemberUpdateBody.inviteUsers + orgId = organizationMemberUpdateBody.orgId + orgName = organizationMemberUpdateBody.orgName + removeUsers = organizationMemberUpdateBody.removeUsers + additionalProperties = + organizationMemberUpdateBody.additionalProperties.toMutableMap() } /** Users to invite to the organization */ - @JsonProperty("invite_users") - fun inviteUsers(inviteUsers: InviteUsers) = apply { this.inviteUsers = inviteUsers } + fun inviteUsers(inviteUsers: InviteUsers?) = + inviteUsers(JsonField.ofNullable(inviteUsers)) + + /** Users to invite to the organization */ + fun inviteUsers(inviteUsers: Optional) = + inviteUsers(inviteUsers.orElse(null)) + + /** Users to invite to the organization */ + fun inviteUsers(inviteUsers: JsonField) = apply { + this.inviteUsers = inviteUsers + } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -125,7 +208,31 @@ constructor( * assert the organization you are modifying, you may specify the id of the * organization. */ - @JsonProperty("org_id") fun orgId(orgId: String) = apply { this.orgId = orgId } + fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the id of the + * organization. + */ + fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the id of the + * organization. + */ + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the name of the + * organization. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -133,27 +240,48 @@ constructor( * assert the organization you are modifying, you may specify the name of the * organization. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the name of the + * organization. + */ + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + /** Users to remove from the organization */ + fun removeUsers(removeUsers: RemoveUsers?) = + removeUsers(JsonField.ofNullable(removeUsers)) /** Users to remove from the organization */ - @JsonProperty("remove_users") - fun removeUsers(removeUsers: RemoveUsers) = apply { this.removeUsers = removeUsers } + fun removeUsers(removeUsers: Optional) = + removeUsers(removeUsers.orElse(null)) + + /** Users to remove from the organization */ + fun removeUsers(removeUsers: JsonField) = apply { + this.removeUsers = removeUsers + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): OrganizationMemberUpdateBody = OrganizationMemberUpdateBody( inviteUsers, @@ -189,48 +317,104 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [OrganizationMemberUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var inviteUsers: InviteUsers? = null - private var orgId: String? = null - private var orgName: String? = null - private var removeUsers: RemoveUsers? = null + private var body: OrganizationMemberUpdateBody.Builder = + OrganizationMemberUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = apply { - inviteUsers = organizationMemberUpdateParams.inviteUsers - orgId = organizationMemberUpdateParams.orgId - orgName = organizationMemberUpdateParams.orgName - removeUsers = organizationMemberUpdateParams.removeUsers + body = organizationMemberUpdateParams.body.toBuilder() additionalHeaders = organizationMemberUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = organizationMemberUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - organizationMemberUpdateParams.additionalBodyProperties.toMutableMap() } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers) = apply { this.inviteUsers = inviteUsers } + fun inviteUsers(inviteUsers: InviteUsers?) = apply { body.inviteUsers(inviteUsers) } + + /** Users to invite to the organization */ + fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.orElse(null)) + + /** Users to invite to the organization */ + fun inviteUsers(inviteUsers: JsonField) = apply { + body.inviteUsers(inviteUsers) + } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. + */ + fun orgId(orgId: String?) = apply { body.orgId(orgId) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, or in case you want to explicitly assert * the organization you are modifying, you may specify the id of the organization. */ - fun orgId(orgId: String) = apply { this.orgId = orgId } + fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. + */ + fun orgId(orgId: JsonField) = apply { body.orgId(orgId) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, or in case you want to explicitly assert * the organization you are modifying, you may specify the name of the organization. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. + */ + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + + /** Users to remove from the organization */ + fun removeUsers(removeUsers: RemoveUsers?) = apply { body.removeUsers(removeUsers) } /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers) = apply { this.removeUsers = removeUsers } + fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.orElse(null)) + + /** Users to remove from the organization */ + fun removeUsers(removeUsers: JsonField) = apply { + body.removeUsers(removeUsers) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -330,80 +514,116 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): OrganizationMemberUpdateParams = OrganizationMemberUpdateParams( - inviteUsers, - orgId, - orgName, - removeUsers, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } /** Users to invite to the organization */ - @JsonDeserialize(builder = InviteUsers.Builder::class) @NoAutoDetect class InviteUsers + @JsonCreator private constructor( - private val ids: List?, - private val emails: List?, - private val sendInviteEmails: Boolean?, - private val groupIds: List?, - private val groupNames: List?, - private val groupId: String?, - private val groupName: String?, - private val additionalProperties: Map, + @JsonProperty("emails") + @ExcludeMissing + private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("group_ids") + @ExcludeMissing + private val groupIds: JsonField> = JsonMissing.of(), + @JsonProperty("group_name") + @ExcludeMissing + private val groupName: JsonField = JsonMissing.of(), + @JsonProperty("group_names") + @ExcludeMissing + private val groupNames: JsonField> = JsonMissing.of(), + @JsonProperty("ids") + @ExcludeMissing + private val ids: JsonField> = JsonMissing.of(), + @JsonProperty("send_invite_emails") + @ExcludeMissing + private val sendInviteEmails: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Ids of existing users to invite */ - @JsonProperty("ids") fun ids(): List? = ids - /** Emails of users to invite */ - @JsonProperty("emails") fun emails(): List? = emails + fun emails(): Optional> = Optional.ofNullable(emails.getNullable("emails")) - /** If true, send invite emails to the users who wore actually added */ - @JsonProperty("send_invite_emails") fun sendInviteEmails(): Boolean? = sendInviteEmails + /** Singular form of group_ids */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) /** Optional list of group ids to add newly-invited users to. */ - @JsonProperty("group_ids") fun groupIds(): List? = groupIds + fun groupIds(): Optional> = + Optional.ofNullable(groupIds.getNullable("group_ids")) + + /** Singular form of group_names */ + fun groupName(): Optional = Optional.ofNullable(groupName.getNullable("group_name")) /** Optional list of group names to add newly-invited users to. */ - @JsonProperty("group_names") fun groupNames(): List? = groupNames + fun groupNames(): Optional> = + Optional.ofNullable(groupNames.getNullable("group_names")) + + /** Ids of existing users to invite */ + fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) + + /** If true, send invite emails to the users who wore actually added */ + fun sendInviteEmails(): Optional = + Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) + + /** Emails of users to invite */ + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails /** Singular form of group_ids */ - @JsonProperty("group_id") fun groupId(): String? = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + + /** Optional list of group ids to add newly-invited users to. */ + @JsonProperty("group_ids") + @ExcludeMissing + fun _groupIds(): JsonField> = groupIds /** Singular form of group_names */ - @JsonProperty("group_name") fun groupName(): String? = groupName + @JsonProperty("group_name") @ExcludeMissing fun _groupName(): JsonField = groupName + + /** Optional list of group names to add newly-invited users to. */ + @JsonProperty("group_names") + @ExcludeMissing + fun _groupNames(): JsonField> = groupNames + + /** Ids of existing users to invite */ + @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids + + /** If true, send invite emails to the users who wore actually added */ + @JsonProperty("send_invite_emails") + @ExcludeMissing + fun _sendInviteEmails(): JsonField = sendInviteEmails @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InviteUsers = apply { + if (validated) { + return@apply + } + + emails() + groupId() + groupIds() + groupName() + groupNames() + ids() + sendInviteEmails() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -411,81 +631,194 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InviteUsers]. */ + class Builder internal constructor() { - private var ids: List? = null - private var emails: List? = null - private var sendInviteEmails: Boolean? = null - private var groupIds: List? = null - private var groupNames: List? = null - private var groupId: String? = null - private var groupName: String? = null + private var emails: JsonField>? = null + private var groupId: JsonField = JsonMissing.of() + private var groupIds: JsonField>? = null + private var groupName: JsonField = JsonMissing.of() + private var groupNames: JsonField>? = null + private var ids: JsonField>? = null + private var sendInviteEmails: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(inviteUsers: InviteUsers) = apply { - this.ids = inviteUsers.ids - this.emails = inviteUsers.emails - this.sendInviteEmails = inviteUsers.sendInviteEmails - this.groupIds = inviteUsers.groupIds - this.groupNames = inviteUsers.groupNames - this.groupId = inviteUsers.groupId - this.groupName = inviteUsers.groupName - additionalProperties(inviteUsers.additionalProperties) + emails = inviteUsers.emails.map { it.toMutableList() } + groupId = inviteUsers.groupId + groupIds = inviteUsers.groupIds.map { it.toMutableList() } + groupName = inviteUsers.groupName + groupNames = inviteUsers.groupNames.map { it.toMutableList() } + ids = inviteUsers.ids.map { it.toMutableList() } + sendInviteEmails = inviteUsers.sendInviteEmails + additionalProperties = inviteUsers.additionalProperties.toMutableMap() } - /** Ids of existing users to invite */ - @JsonProperty("ids") fun ids(ids: List) = apply { this.ids = ids } + /** Emails of users to invite */ + fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) /** Emails of users to invite */ - @JsonProperty("emails") - fun emails(emails: List) = apply { this.emails = emails } + fun emails(emails: Optional>) = emails(emails.orElse(null)) - /** If true, send invite emails to the users who wore actually added */ - @JsonProperty("send_invite_emails") - fun sendInviteEmails(sendInviteEmails: Boolean) = apply { - this.sendInviteEmails = sendInviteEmails + /** Emails of users to invite */ + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } } - /** Optional list of group ids to add newly-invited users to. */ - @JsonProperty("group_ids") - fun groupIds(groupIds: List) = apply { this.groupIds = groupIds } + /** Emails of users to invite */ + fun addEmail(email: String) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(email) + } + } - /** Optional list of group names to add newly-invited users to. */ - @JsonProperty("group_names") - fun groupNames(groupNames: List) = apply { this.groupNames = groupNames } + /** Singular form of group_ids */ + fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) + + /** Singular form of group_ids */ + fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) /** Singular form of group_ids */ - @JsonProperty("group_id") - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** Optional list of group ids to add newly-invited users to. */ + fun groupIds(groupIds: List?) = groupIds(JsonField.ofNullable(groupIds)) + + /** Optional list of group ids to add newly-invited users to. */ + fun groupIds(groupIds: Optional>) = groupIds(groupIds.orElse(null)) + + /** Optional list of group ids to add newly-invited users to. */ + fun groupIds(groupIds: JsonField>) = apply { + this.groupIds = groupIds.map { it.toMutableList() } + } + + /** Optional list of group ids to add newly-invited users to. */ + fun addGroupId(groupId: String) = apply { + groupIds = + (groupIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(groupId) + } + } + + /** Singular form of group_names */ + fun groupName(groupName: String?) = groupName(JsonField.ofNullable(groupName)) /** Singular form of group_names */ - @JsonProperty("group_name") - fun groupName(groupName: String) = apply { this.groupName = groupName } + fun groupName(groupName: Optional) = groupName(groupName.orElse(null)) + + /** Singular form of group_names */ + fun groupName(groupName: JsonField) = apply { this.groupName = groupName } + + /** Optional list of group names to add newly-invited users to. */ + fun groupNames(groupNames: List?) = groupNames(JsonField.ofNullable(groupNames)) + + /** Optional list of group names to add newly-invited users to. */ + fun groupNames(groupNames: Optional>) = groupNames(groupNames.orElse(null)) + + /** Optional list of group names to add newly-invited users to. */ + fun groupNames(groupNames: JsonField>) = apply { + this.groupNames = groupNames.map { it.toMutableList() } + } + + /** Optional list of group names to add newly-invited users to. */ + fun addGroupName(groupName: String) = apply { + groupNames = + (groupNames ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(groupName) + } + } + + /** Ids of existing users to invite */ + fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) + + /** Ids of existing users to invite */ + fun ids(ids: Optional>) = ids(ids.orElse(null)) + + /** Ids of existing users to invite */ + fun ids(ids: JsonField>) = apply { + this.ids = ids.map { it.toMutableList() } + } + + /** Ids of existing users to invite */ + fun addId(id: String) = apply { + ids = + (ids ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(id) + } + } + + /** If true, send invite emails to the users who wore actually added */ + fun sendInviteEmails(sendInviteEmails: Boolean?) = + sendInviteEmails(JsonField.ofNullable(sendInviteEmails)) + + /** If true, send invite emails to the users who wore actually added */ + fun sendInviteEmails(sendInviteEmails: Boolean) = + sendInviteEmails(sendInviteEmails as Boolean?) + + /** If true, send invite emails to the users who wore actually added */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun sendInviteEmails(sendInviteEmails: Optional) = + sendInviteEmails(sendInviteEmails.orElse(null) as Boolean?) + + /** If true, send invite emails to the users who wore actually added */ + fun sendInviteEmails(sendInviteEmails: JsonField) = apply { + this.sendInviteEmails = sendInviteEmails + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): InviteUsers = InviteUsers( - ids?.toImmutable(), - emails?.toImmutable(), - sendInviteEmails, - groupIds?.toImmutable(), - groupNames?.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, groupId, + (groupIds ?: JsonMissing.of()).map { it.toImmutable() }, groupName, + (groupNames ?: JsonMissing.of()).map { it.toImmutable() }, + (ids ?: JsonMissing.of()).map { it.toImmutable() }, + sendInviteEmails, additionalProperties.toImmutable(), ) } @@ -495,39 +828,62 @@ constructor( return true } - return /* spotless:off */ other is InviteUsers && ids == other.ids && emails == other.emails && sendInviteEmails == other.sendInviteEmails && groupIds == other.groupIds && groupNames == other.groupNames && groupId == other.groupId && groupName == other.groupName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InviteUsers && emails == other.emails && groupId == other.groupId && groupIds == other.groupIds && groupName == other.groupName && groupNames == other.groupNames && ids == other.ids && sendInviteEmails == other.sendInviteEmails && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(ids, emails, sendInviteEmails, groupIds, groupNames, groupId, groupName, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(emails, groupId, groupIds, groupName, groupNames, ids, sendInviteEmails, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupIds=$groupIds, groupNames=$groupNames, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" + "InviteUsers{emails=$emails, groupId=$groupId, groupIds=$groupIds, groupName=$groupName, groupNames=$groupNames, ids=$ids, sendInviteEmails=$sendInviteEmails, additionalProperties=$additionalProperties}" } /** Users to remove from the organization */ - @JsonDeserialize(builder = RemoveUsers.Builder::class) @NoAutoDetect class RemoveUsers + @JsonCreator private constructor( - private val ids: List?, - private val emails: List?, - private val additionalProperties: Map, + @JsonProperty("emails") + @ExcludeMissing + private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("ids") + @ExcludeMissing + private val ids: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** Emails of users to remove */ + fun emails(): Optional> = Optional.ofNullable(emails.getNullable("emails")) + /** Ids of users to remove */ - @JsonProperty("ids") fun ids(): List? = ids + fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) /** Emails of users to remove */ - @JsonProperty("emails") fun emails(): List? = emails + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails + + /** Ids of users to remove */ + @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RemoveUsers = apply { + if (validated) { + return@apply + } + + emails() + ids() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -535,44 +891,93 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RemoveUsers]. */ + class Builder internal constructor() { - private var ids: List? = null - private var emails: List? = null + private var emails: JsonField>? = null + private var ids: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(removeUsers: RemoveUsers) = apply { - this.ids = removeUsers.ids - this.emails = removeUsers.emails - additionalProperties(removeUsers.additionalProperties) + emails = removeUsers.emails.map { it.toMutableList() } + ids = removeUsers.ids.map { it.toMutableList() } + additionalProperties = removeUsers.additionalProperties.toMutableMap() } - /** Ids of users to remove */ - @JsonProperty("ids") fun ids(ids: List) = apply { this.ids = ids } + /** Emails of users to remove */ + fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) /** Emails of users to remove */ - @JsonProperty("emails") - fun emails(emails: List) = apply { this.emails = emails } + fun emails(emails: Optional>) = emails(emails.orElse(null)) + + /** Emails of users to remove */ + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } + + /** Emails of users to remove */ + fun addEmail(email: String) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(email) + } + } + + /** Ids of users to remove */ + fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) + + /** Ids of users to remove */ + fun ids(ids: Optional>) = ids(ids.orElse(null)) + + /** Ids of users to remove */ + fun ids(ids: JsonField>) = apply { + this.ids = ids.map { it.toMutableList() } + } + + /** Ids of users to remove */ + fun addId(id: String) = apply { + ids = + (ids ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(id) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RemoveUsers = RemoveUsers( - ids?.toImmutable(), - emails?.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + (ids ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -582,17 +987,17 @@ constructor( return true } - return /* spotless:off */ other is RemoveUsers && ids == other.ids && emails == other.emails && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveUsers && emails == other.emails && ids == other.ids && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(ids, emails, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(emails, ids, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" + "RemoveUsers{emails=$emails, ids=$ids, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -600,11 +1005,11 @@ constructor( return true } - return /* spotless:off */ other is OrganizationMemberUpdateParams && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationMemberUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(inviteUsers, orgId, orgName, removeUsers, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "OrganizationMemberUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 81c6fe94..09c14c35 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get an organization object by its id */ class OrganizationRetrieveParams -constructor( +private constructor( private val organizationId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Organization id */ fun organizationId(): String = organizationId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [OrganizationRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var organizationId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( - checkNotNull(organizationId) { "`organizationId` is required but was not set" }, + checkRequired("organizationId", organizationId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 78deac2d..7e36e178 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -3,65 +3,72 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update an organization object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ class OrganizationUpdateParams -constructor( +private constructor( private val organizationId: String, - private val apiUrl: String?, - private val isUniversalApi: Boolean?, - private val name: String?, - private val proxyUrl: String?, - private val realtimeUrl: String?, + private val body: OrganizationUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Organization id */ fun organizationId(): String = organizationId - fun apiUrl(): Optional = Optional.ofNullable(apiUrl) + fun apiUrl(): Optional = body.apiUrl() - fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi) + fun isUniversalApi(): Optional = body.isUniversalApi() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the organization */ + fun name(): Optional = body.name() - fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl) + fun proxyUrl(): Optional = body.proxyUrl() - fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl) + fun realtimeUrl(): Optional = body.realtimeUrl() + + fun _apiUrl(): JsonField = body._apiUrl() + + fun _isUniversalApi(): JsonField = body._isUniversalApi() + + /** Name of the organization */ + fun _name(): JsonField = body._name() + + fun _proxyUrl(): JsonField = body._proxyUrl() + + fun _realtimeUrl(): JsonField = body._realtimeUrl() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): OrganizationUpdateBody { - return OrganizationUpdateBody( - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): OrganizationUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -70,33 +77,76 @@ constructor( } } - @JsonDeserialize(builder = OrganizationUpdateBody.Builder::class) @NoAutoDetect class OrganizationUpdateBody + @JsonCreator internal constructor( - private val apiUrl: String?, - private val isUniversalApi: Boolean?, - private val name: String?, - private val proxyUrl: String?, - private val realtimeUrl: String?, - private val additionalProperties: Map, + @JsonProperty("api_url") + @ExcludeMissing + private val apiUrl: JsonField = JsonMissing.of(), + @JsonProperty("is_universal_api") + @ExcludeMissing + private val isUniversalApi: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("proxy_url") + @ExcludeMissing + private val proxyUrl: JsonField = JsonMissing.of(), + @JsonProperty("realtime_url") + @ExcludeMissing + private val realtimeUrl: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("api_url") fun apiUrl(): String? = apiUrl + fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) - @JsonProperty("is_universal_api") fun isUniversalApi(): Boolean? = isUniversalApi + fun isUniversalApi(): Optional = + Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) /** Name of the organization */ - @JsonProperty("name") fun name(): String? = name + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) + + fun realtimeUrl(): Optional = + Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) - @JsonProperty("proxy_url") fun proxyUrl(): String? = proxyUrl + @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl - @JsonProperty("realtime_url") fun realtimeUrl(): String? = realtimeUrl + @JsonProperty("is_universal_api") + @ExcludeMissing + fun _isUniversalApi(): JsonField = isUniversalApi + + /** Name of the organization */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl + + @JsonProperty("realtime_url") + @ExcludeMissing + fun _realtimeUrl(): JsonField = realtimeUrl @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): OrganizationUpdateBody = apply { + if (validated) { + return@apply + } + + apiUrl() + isUniversalApi() + name() + proxyUrl() + realtimeUrl() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -104,55 +154,87 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [OrganizationUpdateBody]. */ + class Builder internal constructor() { - private var apiUrl: String? = null - private var isUniversalApi: Boolean? = null - private var name: String? = null - private var proxyUrl: String? = null - private var realtimeUrl: String? = null + private var apiUrl: JsonField = JsonMissing.of() + private var isUniversalApi: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var proxyUrl: JsonField = JsonMissing.of() + private var realtimeUrl: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(organizationUpdateBody: OrganizationUpdateBody) = apply { - this.apiUrl = organizationUpdateBody.apiUrl - this.isUniversalApi = organizationUpdateBody.isUniversalApi - this.name = organizationUpdateBody.name - this.proxyUrl = organizationUpdateBody.proxyUrl - this.realtimeUrl = organizationUpdateBody.realtimeUrl - additionalProperties(organizationUpdateBody.additionalProperties) + apiUrl = organizationUpdateBody.apiUrl + isUniversalApi = organizationUpdateBody.isUniversalApi + name = organizationUpdateBody.name + proxyUrl = organizationUpdateBody.proxyUrl + realtimeUrl = organizationUpdateBody.realtimeUrl + additionalProperties = organizationUpdateBody.additionalProperties.toMutableMap() } - @JsonProperty("api_url") fun apiUrl(apiUrl: String) = apply { this.apiUrl = apiUrl } + fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) + + fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.orElse(null)) + + fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } + + fun isUniversalApi(isUniversalApi: Boolean?) = + isUniversalApi(JsonField.ofNullable(isUniversalApi)) - @JsonProperty("is_universal_api") - fun isUniversalApi(isUniversalApi: Boolean) = apply { + fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isUniversalApi(isUniversalApi: Optional) = + isUniversalApi(isUniversalApi.orElse(null) as Boolean?) + + fun isUniversalApi(isUniversalApi: JsonField) = apply { this.isUniversalApi = isUniversalApi } /** Name of the organization */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) - @JsonProperty("proxy_url") - fun proxyUrl(proxyUrl: String) = apply { this.proxyUrl = proxyUrl } + /** Name of the organization */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the organization */ + fun name(name: JsonField) = apply { this.name = name } - @JsonProperty("realtime_url") - fun realtimeUrl(realtimeUrl: String) = apply { this.realtimeUrl = realtimeUrl } + fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) + + fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.orElse(null)) + + fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } + + fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) + + fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.orElse(null)) + + fun realtimeUrl(realtimeUrl: JsonField) = apply { + this.realtimeUrl = realtimeUrl + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): OrganizationUpdateBody = OrganizationUpdateBody( apiUrl, @@ -189,46 +271,83 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [OrganizationUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var organizationId: String? = null - private var apiUrl: String? = null - private var isUniversalApi: Boolean? = null - private var name: String? = null - private var proxyUrl: String? = null - private var realtimeUrl: String? = null + private var body: OrganizationUpdateBody.Builder = OrganizationUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(organizationUpdateParams: OrganizationUpdateParams) = apply { organizationId = organizationUpdateParams.organizationId - apiUrl = organizationUpdateParams.apiUrl - isUniversalApi = organizationUpdateParams.isUniversalApi - name = organizationUpdateParams.name - proxyUrl = organizationUpdateParams.proxyUrl - realtimeUrl = organizationUpdateParams.realtimeUrl + body = organizationUpdateParams.body.toBuilder() additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - organizationUpdateParams.additionalBodyProperties.toMutableMap() } /** Organization id */ fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } - fun apiUrl(apiUrl: String) = apply { this.apiUrl = apiUrl } + fun apiUrl(apiUrl: String?) = apply { body.apiUrl(apiUrl) } - fun isUniversalApi(isUniversalApi: Boolean) = apply { this.isUniversalApi = isUniversalApi } + fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.orElse(null)) + + fun apiUrl(apiUrl: JsonField) = apply { body.apiUrl(apiUrl) } + + fun isUniversalApi(isUniversalApi: Boolean?) = apply { body.isUniversalApi(isUniversalApi) } + + fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isUniversalApi(isUniversalApi: Optional) = + isUniversalApi(isUniversalApi.orElse(null) as Boolean?) + + fun isUniversalApi(isUniversalApi: JsonField) = apply { + body.isUniversalApi(isUniversalApi) + } /** Name of the organization */ - fun name(name: String) = apply { this.name = name } + fun name(name: String?) = apply { body.name(name) } + + /** Name of the organization */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the organization */ + fun name(name: JsonField) = apply { body.name(name) } + + fun proxyUrl(proxyUrl: String?) = apply { body.proxyUrl(proxyUrl) } - fun proxyUrl(proxyUrl: String) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.orElse(null)) - fun realtimeUrl(realtimeUrl: String) = apply { this.realtimeUrl = realtimeUrl } + fun proxyUrl(proxyUrl: JsonField) = apply { body.proxyUrl(proxyUrl) } + + fun realtimeUrl(realtimeUrl: String?) = apply { body.realtimeUrl(realtimeUrl) } + + fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.orElse(null)) + + fun realtimeUrl(realtimeUrl: JsonField) = apply { body.realtimeUrl(realtimeUrl) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -328,39 +447,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): OrganizationUpdateParams = OrganizationUpdateParams( - checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, + checkRequired("organizationId", organizationId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -369,11 +461,11 @@ constructor( return true } - return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, apiUrl, isUniversalApi, name, proxyUrl, realtimeUrl, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "OrganizationUpdateParams{organizationId=$organizationId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index c20f53c9..0ceee718 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -8,33 +8,36 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = PatchOrganizationMembersOutput.Builder::class) @NoAutoDetect class PatchOrganizationMembersOutput +@JsonCreator private constructor( - private val status: JsonField, - private val orgId: JsonField, - private val sendEmailError: JsonField, - private val additionalProperties: Map, + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("send_email_error") + @ExcludeMissing + private val sendEmailError: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun status(): Status = status.getRequired("status") - /** The id of the org that was modified. */ fun orgId(): String = orgId.getRequired("org_id") + fun status(): Status = status.getRequired("status") + /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here @@ -42,28 +45,34 @@ private constructor( fun sendEmailError(): Optional = Optional.ofNullable(sendEmailError.getNullable("send_email_error")) - @JsonProperty("status") @ExcludeMissing fun _status() = status - /** The id of the org that was modified. */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here */ - @JsonProperty("send_email_error") @ExcludeMissing fun _sendEmailError() = sendEmailError + @JsonProperty("send_email_error") + @ExcludeMissing + fun _sendEmailError(): JsonField = sendEmailError @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): PatchOrganizationMembersOutput = apply { - if (!validated) { - status() - orgId() - sendEmailError() - validated = true + if (validated) { + return@apply } + + orgId() + status() + sendEmailError() + validated = true } fun toBuilder() = Builder().from(this) @@ -73,69 +82,78 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PatchOrganizationMembersOutput]. */ + class Builder internal constructor() { - private var status: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() + private var orgId: JsonField? = null + private var status: JsonField? = null private var sendEmailError: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = apply { - this.status = patchOrganizationMembersOutput.status - this.orgId = patchOrganizationMembersOutput.orgId - this.sendEmailError = patchOrganizationMembersOutput.sendEmailError - additionalProperties(patchOrganizationMembersOutput.additionalProperties) + orgId = patchOrganizationMembersOutput.orgId + status = patchOrganizationMembersOutput.status + sendEmailError = patchOrganizationMembersOutput.sendEmailError + additionalProperties = + patchOrganizationMembersOutput.additionalProperties.toMutableMap() } - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - /** The id of the org that was modified. */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** The id of the org that was modified. */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun status(status: Status) = status(JsonField.of(status)) + + fun status(status: JsonField) = apply { this.status = status } + + /** + * If invite emails failed to send for some reason, the patch operation will still complete, + * but we will return an error message here + */ + fun sendEmailError(sendEmailError: String?) = + sendEmailError(JsonField.ofNullable(sendEmailError)) + /** * If invite emails failed to send for some reason, the patch operation will still complete, * but we will return an error message here */ - fun sendEmailError(sendEmailError: String) = sendEmailError(JsonField.of(sendEmailError)) + fun sendEmailError(sendEmailError: Optional) = + sendEmailError(sendEmailError.orElse(null)) /** * If invite emails failed to send for some reason, the patch operation will still complete, * but we will return an error message here */ - @JsonProperty("send_email_error") - @ExcludeMissing fun sendEmailError(sendEmailError: JsonField) = apply { this.sendEmailError = sendEmailError } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PatchOrganizationMembersOutput = PatchOrganizationMembersOutput( - status, - orgId, + checkRequired("orgId", orgId), + checkRequired("status", status), sendEmailError, additionalProperties.toImmutable(), ) @@ -147,42 +165,65 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val SUCCESS = Status(JsonField.of("success")) + @JvmField val SUCCESS = of("success") @JvmStatic fun of(value: String) = Status(JsonField.of(value)) } + /** An enum containing [Status]'s known values. */ enum class Known { SUCCESS, } + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { SUCCESS, + /** An enum member indicating that [Status] 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) { SUCCESS -> Value.SUCCESS 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) { SUCCESS -> Known.SUCCESS @@ -190,6 +231,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -197,15 +250,15 @@ private constructor( return true } - return /* spotless:off */ other is PatchOrganizationMembersOutput && status == other.status && orgId == other.orgId && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PatchOrganizationMembersOutput && orgId == other.orgId && status == other.status && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(status, orgId, sendEmailError, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(orgId, status, sendEmailError, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PatchOrganizationMembersOutput{status=$status, orgId=$orgId, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + "PatchOrganizationMembersOutput{orgId=$orgId, status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index cc9e6d6d..6f4e6f16 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -7,40 +7,48 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = Project.Builder::class) @NoAutoDetect class Project +@JsonCreator private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val created: JsonField, - private val deletedAt: JsonField, - private val userId: JsonField, - private val settings: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("settings") + @ExcludeMissing + private val settings: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the project */ fun id(): String = id.getRequired("id") - /** Unique id for the organization that the project belongs under */ - fun orgId(): String = orgId.getRequired("org_id") - /** Name of the project */ fun name(): String = name.getRequired("name") + /** Unique id for the organization that the project belongs under */ + fun orgId(): String = orgId.getRequired("org_id") + /** Date of project creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) @@ -48,47 +56,53 @@ private constructor( fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Identifies the user who created the project */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) - /** Unique identifier for the project */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + /** Identifies the user who created the project */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + /** Unique identifier for the project */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Unique id for the organization that the project belongs under */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Date of project creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of project deletion, or null if the project is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt - /** Identifies the user who created the project */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonField = settings - @JsonProperty("settings") @ExcludeMissing fun _settings() = settings + /** Identifies the user who created the project */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Project = apply { - if (!validated) { - id() - orgId() - name() - created() - deletedAt() - userId() - settings().map { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + name() + orgId() + created() + deletedAt() + settings().ifPresent { it.validate() } + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -98,104 +112,109 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Project]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var orgId: JsonField? = null private var created: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() private var settings: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(project: Project) = apply { - this.id = project.id - this.orgId = project.orgId - this.name = project.name - this.created = project.created - this.deletedAt = project.deletedAt - this.userId = project.userId - this.settings = project.settings - additionalProperties(project.additionalProperties) + id = project.id + name = project.name + orgId = project.orgId + created = project.created + deletedAt = project.deletedAt + settings = project.settings + userId = project.userId + additionalProperties = project.additionalProperties.toMutableMap() } /** Unique identifier for the project */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } + + /** Name of the project */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project */ + fun name(name: JsonField) = apply { this.name = name } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - /** Name of the project */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the project */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Date of project creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of project creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: Optional) = created(created.orElse(null)) /** Date of project creation */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } /** Date of project deletion, or null if the project is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) + + /** Date of project deletion, or null if the project is still active */ + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) /** Date of project deletion, or null if the project is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } - /** Identifies the user who created the project */ - fun userId(userId: String) = userId(JsonField.of(userId)) + fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) + + fun settings(settings: Optional) = settings(settings.orElse(null)) + + fun settings(settings: JsonField) = apply { this.settings = settings } /** Identifies the user who created the project */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - fun settings(settings: ProjectSettings) = settings(JsonField.of(settings)) + /** Identifies the user who created the project */ + fun userId(userId: Optional) = userId(userId.orElse(null)) - @JsonProperty("settings") - @ExcludeMissing - fun settings(settings: JsonField) = apply { this.settings = settings } + /** Identifies the user who created the project */ + fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Project = Project( - id, - orgId, - name, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("orgId", orgId), created, deletedAt, - userId, settings, + userId, additionalProperties.toImmutable(), ) } @@ -205,15 +224,15 @@ private constructor( return true } - return /* spotless:off */ other is Project && id == other.id && orgId == other.orgId && name == other.name && created == other.created && deletedAt == other.deletedAt && userId == other.userId && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Project && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && settings == other.settings && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, orgId, name, created, deletedAt, userId, settings, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, orgId, created, deletedAt, settings, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" + "Project{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, settings=$settings, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 062dc275..8f519311 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -3,74 +3,116 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new project. If there is an existing project with the same name as the one specified in + * the request, will return the existing project unmodified + */ class ProjectCreateParams -constructor( - private val name: String, - private val orgName: String?, +private constructor( + private val body: ProjectCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the project */ + fun name(): String = body.name() - fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * project belongs in. + */ + fun orgName(): Optional = body.orgName() + + /** Name of the project */ + fun _name(): JsonField = body._name() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * project belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun _body(): ProjectCreateBody = body - @JvmSynthetic - internal fun getBody(): ProjectCreateBody { - return ProjectCreateBody( - name, - orgName, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = ProjectCreateBody.Builder::class) @NoAutoDetect class ProjectCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val orgName: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the project belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the project */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. + */ + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectCreateBody = apply { + if (validated) { + return@apply + } + + name() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -78,47 +120,69 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var orgName: String? = null + private var name: JsonField? = null + private var orgName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectCreateBody: ProjectCreateBody) = apply { - this.name = projectCreateBody.name - this.orgName = projectCreateBody.orgName - additionalProperties(projectCreateBody.additionalProperties) + name = projectCreateBody.name + orgName = projectCreateBody.orgName + additionalProperties = projectCreateBody.additionalProperties.toMutableMap() } /** Name of the project */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the project belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectCreateBody = ProjectCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), orgName, additionalProperties.toImmutable(), ) @@ -149,33 +213,66 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var orgName: String? = null + private var body: ProjectCreateBody.Builder = ProjectCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectCreateParams: ProjectCreateParams) = apply { - name = projectCreateParams.name - orgName = projectCreateParams.orgName + body = projectCreateParams.body.toBuilder() additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = projectCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the project */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the project */ + fun name(name: JsonField) = apply { body.name(name) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the project belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. + */ + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -275,35 +372,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectCreateParams = ProjectCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -312,11 +385,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectCreateParams && name == other.name && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectCreateParams{name=$name, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 9c24a6f7..c63758e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a project object by its id */ class ProjectDeleteParams -constructor( +private constructor( private val projectId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Project id */ fun projectId(): String = projectId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): ProjectDeleteParams = ProjectDeleteParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkRequired("projectId", projectId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index a19ead47..7ed60f96 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.ProjectService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all projects. The projects are sorted by creation date, with the most recently-created + * projects coming first + */ class ProjectListPage private constructor( private val projectsService: ProjectService, @@ -85,16 +90,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -104,11 +108,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -144,10 +152,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -156,8 +162,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ProjectListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 1a0f4e9c..1fcb984b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.ProjectServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all projects. The projects are sorted by creation date, with the most recently-created + * projects coming first + */ class ProjectListPageAsync private constructor( private val projectsService: ProjectServiceAsync, @@ -92,16 +97,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +115,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +159,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +169,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ProjectListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index ff8c5a39..a3099c06 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all projects. The projects are sorted by creation date, with the most recently-created + * projects coming first + */ class ProjectListParams -constructor( +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -31,28 +35,48 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Name of the project to search for */ fun projectName(): Optional = Optional.ofNullable(projectName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.ids?.let { queryParams.put("ids", listOf(it.toString())) } @@ -71,8 +95,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var ids: Ids? = null @@ -102,34 +127,62 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = apply { this.projectName = projectName } + + /** Name of the project to search for */ + fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) /** * Pagination cursor id. @@ -138,7 +191,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -251,6 +314,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -260,8 +327,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -284,15 +349,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -318,18 +374,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -345,7 +411,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 2bfd74a5..3ed038e0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -3,45 +3,51 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects +/** Log feedback for a set of project logs events */ class ProjectLogFeedbackParams -constructor( +private constructor( private val projectId: String, - private val feedback: List, + private val body: ProjectLogFeedbackBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Project id */ fun projectId(): String = projectId - fun feedback(): List = feedback + /** A list of project logs feedback items */ + fun feedback(): List = body.feedback() + + /** A list of project logs feedback items */ + fun _feedback(): JsonField> = body._feedback() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectLogFeedbackBody { - return ProjectLogFeedbackBody(feedback, additionalBodyProperties) - } + @JvmSynthetic internal fun _body(): ProjectLogFeedbackBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,21 +56,40 @@ constructor( } } - @JsonDeserialize(builder = ProjectLogFeedbackBody.Builder::class) @NoAutoDetect class ProjectLogFeedbackBody + @JsonCreator internal constructor( - private val feedback: List?, - private val additionalProperties: Map, + @JsonProperty("feedback") + @ExcludeMissing + private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of project logs feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + fun feedback(): List = feedback.getRequired("feedback") + + /** A list of project logs feedback items */ + @JsonProperty("feedback") + @ExcludeMissing + fun _feedback(): JsonField> = feedback @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectLogFeedbackBody = apply { + if (validated) { + return@apply + } + + feedback().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,41 +97,62 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectLogFeedbackBody]. */ + class Builder internal constructor() { - private var feedback: List? = null + private var feedback: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogFeedbackBody: ProjectLogFeedbackBody) = apply { - this.feedback = projectLogFeedbackBody.feedback - additionalProperties(projectLogFeedbackBody.additionalProperties) + feedback = projectLogFeedbackBody.feedback.map { it.toMutableList() } + additionalProperties = projectLogFeedbackBody.additionalProperties.toMutableMap() } /** A list of project logs feedback items */ - @JsonProperty("feedback") - fun feedback(feedback: List) = apply { - this.feedback = feedback + fun feedback(feedback: List) = feedback(JsonField.of(feedback)) + + /** A list of project logs feedback items */ + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback.map { it.toMutableList() } + } + + /** A list of project logs feedback items */ + fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { + this.feedback = + (this.feedback ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(feedback) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectLogFeedbackBody = ProjectLogFeedbackBody( - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toImmutable(), + checkRequired("feedback", feedback).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -136,36 +182,55 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectLogFeedbackParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectId: String? = null - private var feedback: MutableList = mutableListOf() + private var body: ProjectLogFeedbackBody.Builder = ProjectLogFeedbackBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = apply { projectId = projectLogFeedbackParams.projectId - feedback = projectLogFeedbackParams.feedback.toMutableList() + body = projectLogFeedbackParams.body.toBuilder() additionalHeaders = projectLogFeedbackParams.additionalHeaders.toBuilder() additionalQueryParams = projectLogFeedbackParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectLogFeedbackParams.additionalBodyProperties.toMutableMap() } /** Project id */ fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs feedback items */ - fun feedback(feedback: List) = apply { - this.feedback.clear() - this.feedback.addAll(feedback) + fun feedback(feedback: List) = apply { body.feedback(feedback) } + + /** A list of project logs feedback items */ + fun feedback(feedback: JsonField>) = apply { + body.feedback(feedback) } /** A list of project logs feedback items */ - fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { body.addFeedback(feedback) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -265,35 +330,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - feedback.toImmutable(), + checkRequired("projectId", projectId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -302,11 +344,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && feedback == other.feedback && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, feedback, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogFeedbackParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 4623fef6..c8eb1de7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -3,14 +3,20 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects import java.util.Optional +/** + * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use the + * `POST /btql` endpoint. + */ class ProjectLogFetchParams -constructor( +private constructor( private val projectId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -18,26 +24,70 @@ constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Project id */ fun projectId(): String = projectId + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ fun limit(): Optional = Optional.ofNullable(limit) + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ fun version(): Optional = Optional.ofNullable(version) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.limit?.let { queryParams.put("limit", listOf(it.toString())) } this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } @@ -61,8 +111,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectLogFetchParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectId: String? = null private var limit: Long? = null @@ -101,7 +152,42 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -115,7 +201,7 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -129,7 +215,44 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: String?) = apply { this.version = version } /** * Retrieve a snapshot of events from a past time @@ -137,7 +260,7 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { this.version = version } + fun version(version: Optional) = version(version.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -239,7 +362,7 @@ constructor( fun build(): ProjectLogFetchParams = ProjectLogFetchParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkRequired("projectId", projectId), limit, maxRootSpanId, maxXactId, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 8a3ef33d..d56ae77a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -3,65 +3,170 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use the + * `POST /btql` endpoint. + */ class ProjectLogFetchPostParams -constructor( +private constructor( private val projectId: String, - private val cursor: String?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, + private val body: ProjectLogFetchPostBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Project id */ fun projectId(): String = projectId - fun cursor(): Optional = Optional.ofNullable(cursor) - - fun limit(): Optional = Optional.ofNullable(limit) - - fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) - - fun maxXactId(): Optional = Optional.ofNullable(maxXactId) - - fun version(): Optional = Optional.ofNullable(version) + /** + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch query + */ + fun cursor(): Optional = body.cursor() + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ + fun limit(): Optional = body.limit() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun maxRootSpanId(): Optional = body.maxRootSpanId() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun maxXactId(): Optional = body.maxXactId() + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(): Optional = body.version() + + /** + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch query + */ + fun _cursor(): JsonField = body._cursor() + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. + */ + fun _limit(): JsonField = body._limit() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun _maxRootSpanId(): JsonField = body._maxRootSpanId() + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. + */ + fun _maxXactId(): JsonField = body._maxXactId() + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun _version(): JsonField = body._version() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectLogFetchPostBody { - return ProjectLogFetchPostBody( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ProjectLogFetchPostBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -70,16 +175,27 @@ constructor( } } - @JsonDeserialize(builder = ProjectLogFetchPostBody.Builder::class) @NoAutoDetect class ProjectLogFetchPostBody + @JsonCreator internal constructor( - private val cursor: String?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") + @ExcludeMissing + private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") + @ExcludeMissing + private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") + @ExcludeMissing + private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -89,7 +205,7 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - @JsonProperty("cursor") fun cursor(): String? = cursor + fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched @@ -106,7 +222,7 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @JsonProperty("limit") fun limit(): Long? = limit + fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -120,7 +236,8 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - @JsonProperty("max_root_span_id") fun maxRootSpanId(): String? = maxRootSpanId + fun maxRootSpanId(): Optional = + Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -134,7 +251,8 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - @JsonProperty("max_xact_id") fun maxXactId(): String? = maxXactId + fun maxXactId(): Optional = + Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time @@ -142,12 +260,91 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") fun version(): String? = version + fun version(): Optional = Optional.ofNullable(version.getNullable("version")) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + @JsonProperty("max_root_span_id") + @ExcludeMissing + fun _maxRootSpanId(): JsonField = maxRootSpanId + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectLogFetchPostBody = apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -155,23 +352,24 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectLogFetchPostBody]. */ + class Builder internal constructor() { - private var cursor: String? = null - private var limit: Long? = null - private var maxRootSpanId: String? = null - private var maxXactId: String? = null - private var version: String? = null + private var cursor: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var maxRootSpanId: JsonField = JsonMissing.of() + private var maxXactId: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogFetchPostBody: ProjectLogFetchPostBody) = apply { - this.cursor = projectLogFetchPostBody.cursor - this.limit = projectLogFetchPostBody.limit - this.maxRootSpanId = projectLogFetchPostBody.maxRootSpanId - this.maxXactId = projectLogFetchPostBody.maxXactId - this.version = projectLogFetchPostBody.version - additionalProperties(projectLogFetchPostBody.additionalProperties) + cursor = projectLogFetchPostBody.cursor + limit = projectLogFetchPostBody.limit + maxRootSpanId = projectLogFetchPostBody.maxRootSpanId + maxXactId = projectLogFetchPostBody.maxXactId + version = projectLogFetchPostBody.version + additionalProperties = projectLogFetchPostBody.additionalProperties.toMutableMap() } /** @@ -181,7 +379,25 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - @JsonProperty("cursor") fun cursor(cursor: String) = apply { this.cursor = cursor } + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } /** * limit the number of traces fetched @@ -198,7 +414,119 @@ constructor( * with more individual rows than the specified limit if you are fetching events * containing traces. */ - @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: String?) = + maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + this.maxRootSpanId = maxRootSpanId + } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -212,8 +540,7 @@ constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - @JsonProperty("max_root_span_id") - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -227,8 +554,25 @@ constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. + */ + fun version(version: String?) = version(JsonField.ofNullable(version)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. + */ + fun version(version: Optional) = version(version.orElse(null)) /** * Retrieve a snapshot of events from a past time @@ -237,22 +581,27 @@ constructor( * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact * fetch. */ - @JsonProperty("version") fun version(version: String) = apply { this.version = version } + fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectLogFetchPostBody = ProjectLogFetchPostBody( cursor, @@ -289,31 +638,21 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectLogFetchPostParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectId: String? = null - private var cursor: String? = null - private var limit: Long? = null - private var maxRootSpanId: String? = null - private var maxXactId: String? = null - private var version: String? = null + private var body: ProjectLogFetchPostBody.Builder = ProjectLogFetchPostBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = apply { projectId = projectLogFetchPostParams.projectId - cursor = projectLogFetchPostParams.cursor - limit = projectLogFetchPostParams.limit - maxRootSpanId = projectLogFetchPostParams.maxRootSpanId - maxXactId = projectLogFetchPostParams.maxXactId - version = projectLogFetchPostParams.version + body = projectLogFetchPostParams.body.toBuilder() additionalHeaders = projectLogFetchPostParams.additionalHeaders.toBuilder() additionalQueryParams = projectLogFetchPostParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectLogFetchPostParams.additionalBodyProperties.toMutableMap() } /** Project id */ @@ -326,7 +665,25 @@ constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: String) = apply { this.cursor = cursor } + fun cursor(cursor: String?) = apply { body.cursor(cursor) } + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + + /** + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. + * + * The string can be obtained directly from the `cursor` property of the previous fetch + * query + */ + fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } /** * limit the number of traces fetched @@ -343,7 +700,59 @@ constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = apply { body.limit(limit) } + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** + * limit the number of traces fetched + * + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. + */ + fun limit(limit: JsonField) = apply { body.limit(limit) } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -357,7 +766,7 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -371,7 +780,74 @@ constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + body.maxRootSpanId(maxRootSpanId) + } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + + /** + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. + * + * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. + */ + fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: String?) = apply { body.version(version) } /** * Retrieve a snapshot of events from a past time @@ -379,7 +855,34 @@ constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String) = apply { this.version = version } + fun version(version: Optional) = version(version.orElse(null)) + + /** + * Retrieve a snapshot of events from a past time + * + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + */ + fun version(version: JsonField) = apply { body.version(version) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -479,39 +982,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectLogFetchPostParams = ProjectLogFetchPostParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - cursor, - limit, - maxRootSpanId, - maxXactId, - version, + checkRequired("projectId", projectId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -520,11 +996,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, cursor, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogFetchPostParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 815ee46e..264010df 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -3,45 +3,51 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects +/** Insert a set of events into the project logs */ class ProjectLogInsertParams -constructor( +private constructor( private val projectId: String, - private val events: List, + private val body: ProjectLogInsertBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Project id */ fun projectId(): String = projectId - fun events(): List = events + /** A list of project logs events to insert */ + fun events(): List = body.events() + + /** A list of project logs events to insert */ + fun _events(): JsonField> = body._events() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectLogInsertBody { - return ProjectLogInsertBody(events, additionalBodyProperties) - } + @JvmSynthetic internal fun _body(): ProjectLogInsertBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,21 +56,40 @@ constructor( } } - @JsonDeserialize(builder = ProjectLogInsertBody.Builder::class) @NoAutoDetect class ProjectLogInsertBody + @JsonCreator internal constructor( - private val events: List?, - private val additionalProperties: Map, + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of project logs events to insert */ - @JsonProperty("events") fun events(): List? = events + fun events(): List = events.getRequired("events") + + /** A list of project logs events to insert */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectLogInsertBody = apply { + if (validated) { + return@apply + } + + events().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,38 +97,62 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectLogInsertBody]. */ + class Builder internal constructor() { - private var events: List? = null + private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogInsertBody: ProjectLogInsertBody) = apply { - this.events = projectLogInsertBody.events - additionalProperties(projectLogInsertBody.additionalProperties) + events = projectLogInsertBody.events.map { it.toMutableList() } + additionalProperties = projectLogInsertBody.additionalProperties.toMutableMap() + } + + /** A list of project logs events to insert */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of project logs events to insert */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } } /** A list of project logs events to insert */ - @JsonProperty("events") - fun events(events: List) = apply { this.events = events } + fun addEvent(event: InsertProjectLogsEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(event) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectLogInsertBody = ProjectLogInsertBody( - checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + checkRequired("events", events).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -133,36 +182,53 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectLogInsertParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectId: String? = null - private var events: MutableList = mutableListOf() + private var body: ProjectLogInsertBody.Builder = ProjectLogInsertBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogInsertParams: ProjectLogInsertParams) = apply { projectId = projectLogInsertParams.projectId - events = projectLogInsertParams.events.toMutableList() + body = projectLogInsertParams.body.toBuilder() additionalHeaders = projectLogInsertParams.additionalHeaders.toBuilder() additionalQueryParams = projectLogInsertParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectLogInsertParams.additionalBodyProperties.toMutableMap() } /** Project id */ fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs events to insert */ - fun events(events: List) = apply { - this.events.clear() - this.events.addAll(events) - } + fun events(events: List) = apply { body.events(events) } /** A list of project logs events to insert */ - fun addEvent(event: InsertProjectLogsEvent) = apply { this.events.add(event) } + fun events(events: JsonField>) = apply { body.events(events) } + + /** A list of project logs events to insert */ + fun addEvent(event: InsertProjectLogsEvent) = apply { body.addEvent(event) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -262,35 +328,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectLogInsertParams = ProjectLogInsertParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - events.toImmutable(), + checkRequired("projectId", projectId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -299,11 +342,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && events == other.events && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, events, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectLogInsertParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 290eb5ed..351a1817 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -8,47 +8,74 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ProjectLogsEvent.Builder::class) @NoAutoDetect class ProjectLogsEvent +@JsonCreator private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val orgId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val isRoot: JsonField, - private val spanAttributes: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + private val context: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), + @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), + @JsonProperty("is_root") + @ExcludeMissing + private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") + @ExcludeMissing + private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you @@ -65,26 +92,34 @@ private constructor( /** The timestamp the project logs event was created */ fun created(): OffsetDateTime = created.getRequired("created") + /** A literal 'g' which identifies the log as a project log */ + fun logId(): LogId = logId.getRequired("log_id") + /** Unique id for the organization that the project belongs under */ fun orgId(): String = orgId.getRequired("org_id") /** Unique identifier for the project */ fun projectId(): String = projectId.getRequired("project_id") - /** A literal 'g' which identifies the log as a project log */ - fun logId(): LogId = logId.getRequired("log_id") + /** A unique identifier for the trace this project logs event belongs to */ + fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - fun input(): JsonValue = input + /** + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing + */ + fun spanId(): String = spanId.getRequired("span_id") /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event */ - fun output(): JsonValue = output + fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + + /** The error that occurred, if any. */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to @@ -94,21 +129,13 @@ private constructor( * analyses. However, we may later use these values to re-score outputs or fine-tune your * models. */ - fun expected(): JsonValue = expected + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected - /** The error that occurred, if any. */ - fun error(): JsonValue = error + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. - */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + /** Whether this span is a root span */ + fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -119,9 +146,6 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** A list of tags to log */ - fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** * Metrics are numerical measurements tracking the execution of the code that produced the * project logs event. Use "start" and "end" to track the time span over which the project logs @@ -129,19 +153,32 @@ private constructor( */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. */ - fun context(): Optional = Optional.ofNullable(context.getNullable("context")) + @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ - fun spanId(): String = spanId.getRequired("span_id") + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** * An array of the parent `span_ids` of this project logs event. This should be empty for the @@ -150,79 +187,53 @@ private constructor( fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** A unique identifier for the trace this project logs event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** Whether this span is a root span */ - fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) - - /** Indicates the event was copied from another object. */ - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** A list of tags to log */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the project logs (see the `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** A literal 'g' which identifies the log as a project log */ + @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Unique identifier for the project */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input() = input + /** A unique identifier for the trace this project logs event belongs to */ + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("output") @ExcludeMissing fun _output() = output + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + /** Whether this span is a root span */ + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** * A dictionary with additional data about the test example, model outputs, or just about @@ -231,79 +242,74 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * Metrics are numerical measurements tracking the execution of the code that produced the * project logs event. Use "start" and "end" to track the time span over which the project logs * event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics - /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + + /** Human-identifying attributes of the span, such as name, type, etc. */ + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes(): JsonField = spanAttributes /** * An array of the parent `span_ids` of this project logs event. This should be empty for the * root span of a trace, and should most often contain just one parent element for subspans */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents - - /** A unique identifier for the trace this project logs event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot() = isRoot - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + @JsonProperty("span_parents") + @ExcludeMissing + fun _spanParents(): JsonField> = spanParents - /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + /** A list of tags to log */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectLogsEvent = apply { - if (!validated) { - id() - _xactId() - created() - orgId() - projectId() - logId() - input() - output() - expected() - error() - scores().map { it.validate() } - metadata().map { it.validate() } - tags() - metrics().map { it.validate() } - context().map { it.validate() } - spanId() - spanParents() - rootSpanId() - isRoot() - spanAttributes().map { it.validate() } - origin().map { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + _xactId() + created() + logId() + orgId() + projectId() + rootSpanId() + spanId() + context().ifPresent { it.validate() } + isRoot() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanParents() + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -313,55 +319,56 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() + /** A builder for [ProjectLogsEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var created: JsonField? = null + private var logId: JsonField? = null + private var orgId: JsonField? = null + private var projectId: JsonField? = null + private var rootSpanId: JsonField? = null + private var spanId: JsonField? = null + private var context: JsonField = JsonMissing.of() private var error: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() + private var expected: JsonValue = JsonMissing.of() + private var input: JsonValue = JsonMissing.of() + private var isRoot: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var isRoot: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() private var origin: JsonField = JsonMissing.of() + private var output: JsonValue = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() + private var spanAttributes: JsonField = JsonMissing.of() + private var spanParents: JsonField>? = null + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectLogsEvent: ProjectLogsEvent) = apply { - this.id = projectLogsEvent.id - this._xactId = projectLogsEvent._xactId - this.created = projectLogsEvent.created - this.orgId = projectLogsEvent.orgId - this.projectId = projectLogsEvent.projectId - this.logId = projectLogsEvent.logId - this.input = projectLogsEvent.input - this.output = projectLogsEvent.output - this.expected = projectLogsEvent.expected - this.error = projectLogsEvent.error - this.scores = projectLogsEvent.scores - this.metadata = projectLogsEvent.metadata - this.tags = projectLogsEvent.tags - this.metrics = projectLogsEvent.metrics - this.context = projectLogsEvent.context - this.spanId = projectLogsEvent.spanId - this.spanParents = projectLogsEvent.spanParents - this.rootSpanId = projectLogsEvent.rootSpanId - this.isRoot = projectLogsEvent.isRoot - this.spanAttributes = projectLogsEvent.spanAttributes - this.origin = projectLogsEvent.origin - additionalProperties(projectLogsEvent.additionalProperties) + id = projectLogsEvent.id + _xactId = projectLogsEvent._xactId + created = projectLogsEvent.created + logId = projectLogsEvent.logId + orgId = projectLogsEvent.orgId + projectId = projectLogsEvent.projectId + rootSpanId = projectLogsEvent.rootSpanId + spanId = projectLogsEvent.spanId + context = projectLogsEvent.context + error = projectLogsEvent.error + expected = projectLogsEvent.expected + input = projectLogsEvent.input + isRoot = projectLogsEvent.isRoot + metadata = projectLogsEvent.metadata + metrics = projectLogsEvent.metrics + origin = projectLogsEvent.origin + output = projectLogsEvent.output + scores = projectLogsEvent.scores + spanAttributes = projectLogsEvent.spanAttributes + spanParents = projectLogsEvent.spanParents.map { it.toMutableList() } + tags = projectLogsEvent.tags.map { it.toMutableList() } + additionalProperties = projectLogsEvent.additionalProperties.toMutableMap() } /** @@ -374,7 +381,7 @@ private constructor( * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } /** * The transaction id of an event is unique to the network operation that processed the @@ -388,59 +395,75 @@ private constructor( * event insertion. Transaction ids are monotonically increasing over time and can be used * to retrieve a versioned snapshot of the project logs (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } + /** A literal 'g' which identifies the log as a project log */ + fun logId(logId: LogId) = logId(JsonField.of(logId)) + + /** A literal 'g' which identifies the log as a project log */ + fun logId(logId: JsonField) = apply { this.logId = logId } + /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project */ - @JsonProperty("project_id") - @ExcludeMissing fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - /** A literal 'g' which identifies the log as a project log */ - fun logId(logId: LogId) = logId(JsonField.of(logId)) + /** A unique identifier for the trace this project logs event belongs to */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") - @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } + /** A unique identifier for the trace this project logs event belongs to */ + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: Context?) = context(JsonField.ofNullable(context)) + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: Optional) = context(context.orElse(null)) + + /** + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event + */ + fun context(context: JsonField) = apply { this.context = context } + + /** The error that occurred, if any. */ + fun error(error: JsonValue) = apply { this.error = error } /** * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to @@ -450,38 +473,34 @@ private constructor( * into analyses. However, we may later use these values to re-score outputs or fine-tune * your models. */ - @JsonProperty("expected") - @ExcludeMissing fun expected(expected: JsonValue) = apply { this.expected = expected } - /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) + fun input(input: JsonValue) = apply { this.input = input } + + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) + + /** Whether this span is a root span */ + fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) + + /** Whether this span is a root span */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isRoot(isRoot: Optional) = isRoot(isRoot.orElse(null) as Boolean?) + + /** Whether this span is a root span */ + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -490,7 +509,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -499,202 +518,271 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - @JsonProperty("metadata") - @ExcludeMissing fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced + */ + fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + /** + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced + */ + fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) /** * Metrics are numerical measurements tracking the execution of the code that produced the * project logs event. Use "start" and "end" to track the time span over which the project * logs event was produced */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + + /** Indicates the event was copied from another object. */ + fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.orElse(null)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. + */ + fun output(output: JsonValue) = apply { this.output = output } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - fun context(context: Context) = context(JsonField.of(context)) + fun scores(scores: Optional) = scores(scores.orElse(null)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } + fun scores(scores: JsonField) = apply { this.scores = scores } - /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing - */ - fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: SpanAttributes?) = + spanAttributes(JsonField.ofNullable(spanAttributes)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: Optional) = + spanAttributes(spanAttributes.orElse(null)) + + /** Human-identifying attributes of the span, such as name, type, etc. */ + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** * An array of the parent `span_ids` of this project logs event. This should be empty for * the root span of a trace, and should most often contain just one parent element for * subspans */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) + fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) /** * An array of the parent `span_ids` of this project logs event. This should be empty for * the root span of a trace, and should most often contain just one parent element for * subspans */ - @JsonProperty("span_parents") - @ExcludeMissing fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents + this.spanParents = spanParents.map { it.toMutableList() } } - /** A unique identifier for the trace this project logs event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - - /** A unique identifier for the trace this project logs event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } - - /** Whether this span is a root span */ - fun isRoot(isRoot: Boolean) = isRoot(JsonField.of(isRoot)) + /** + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans + */ + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(spanParent) + } + } - /** Whether this span is a root span */ - @JsonProperty("is_root") - @ExcludeMissing - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + /** A list of tags to log */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) + /** A list of tags to log */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes + /** A list of tags to log */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } } - /** Indicates the event was copied from another object. */ - fun origin(origin: Origin) = origin(JsonField.of(origin)) - - /** Indicates the event was copied from another object. */ - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } + /** A list of tags to log */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectLogsEvent = ProjectLogsEvent( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("created", created), + checkRequired("logId", logId), + checkRequired("orgId", orgId), + checkRequired("projectId", projectId), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), + context, error, - scores, + expected, + input, + isRoot, metadata, - tags.map { it.toImmutable() }, metrics, - context, - spanId, - spanParents.map { it.toImmutable() }, - rootSpanId, - isRoot, - spanAttributes, origin, + output, + scores, + spanAttributes, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } + /** A literal 'g' which identifies the log as a project log */ class LogId @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val G = LogId(JsonField.of("g")) + @JvmField val G = of("g") @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) } + /** An enum containing [LogId]'s known values. */ enum class Known { G, } + /** + * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [LogId] 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 { G, + /** An enum member indicating that [LogId] 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) { G -> Value.G 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) { G -> Known.G @@ -702,6 +790,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** @@ -709,52 +809,65 @@ private constructor( * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the * location in code which produced the project logs event */ - @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect class Context + @JsonCreator private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Name of the file in code where the project logs event was created */ + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the project logs event */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) - /** Line of code where the project logs event was created */ fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + /** Name of the file in code where the project logs event was created */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename(): JsonField = callerFilename + /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + fun _callerFunctionname(): JsonField = callerFunctionname /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonField = callerLineno @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + if (validated) { + return@apply } + + callerFilename() + callerFunctionname() + callerLineno() + validated = true } fun toBuilder() = Builder().from(this) @@ -764,71 +877,87 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Context]. */ + class Builder internal constructor() { - private var callerFunctionname: JsonField = JsonMissing.of() private var callerFilename: JsonField = JsonMissing.of() + private var callerFunctionname: JsonField = JsonMissing.of() private var callerLineno: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: String?) = + callerFilename(JsonField.ofNullable(callerFilename)) + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: Optional) = + callerFilename(callerFilename.orElse(null)) + + /** Name of the file in code where the project logs event was created */ + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = + callerFunctionname(JsonField.ofNullable(callerFunctionname)) + + /** The function in code which created the project logs event */ + fun callerFunctionname(callerFunctionname: Optional) = + callerFunctionname(callerFunctionname.orElse(null)) /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing fun callerFunctionname(callerFunctionname: JsonField) = apply { this.callerFunctionname = callerFunctionname } - /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + /** Line of code where the project logs event was created */ + fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + /** Line of code where the project logs event was created */ + fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun callerLineno(callerLineno: Optional) = + callerLineno(callerLineno.orElse(null) as Long?) /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing fun callerLineno(callerLineno: JsonField) = apply { this.callerLineno = callerLineno } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Context = Context( - callerFunctionname, callerFilename, + callerFunctionname, callerLineno, additionalProperties.toImmutable(), ) @@ -839,17 +968,17 @@ private constructor( return true } - return /* spotless:off */ other is Context && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(callerFunctionname, callerFilename, callerLineno, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(callerFilename, callerFunctionname, callerLineno, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** @@ -859,23 +988,26 @@ private constructor( * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -885,29 +1017,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -933,41 +1071,48 @@ private constructor( * project logs event. Use "start" and "end" to track the time span over which the project logs * event was produced */ - @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect class Metrics + @JsonCreator private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val callerFunctionname: JsonValue, - private val callerFilename: JsonValue, - private val callerLineno: JsonValue, - private val additionalProperties: Map, + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + private val completionTokens: JsonField = JsonMissing.of(), + @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), + @JsonProperty("prompt_tokens") + @ExcludeMissing + private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") + @ExcludeMissing + private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** - * A unix timestamp recording when the section of code which produced the project logs event - * started - */ - fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + /** This metric is deprecated */ + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename(): JsonValue = callerFilename - /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished - */ - fun end(): Optional = Optional.ofNullable(end.getNullable("end")) + /** This metric is deprecated */ + @JsonProperty("caller_functionname") + @ExcludeMissing + fun _callerFunctionname(): JsonValue = callerFunctionname - /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) - */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + /** This metric is deprecated */ + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno /** * The number of tokens in the completion generated by the model (only set if this is an LLM @@ -976,35 +1121,27 @@ private constructor( fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) - - /** This metric is deprecated */ - fun callerFunctionname(): JsonValue = callerFunctionname - - /** This metric is deprecated */ - fun callerFilename(): JsonValue = callerFilename - - /** This metric is deprecated */ - fun callerLineno(): JsonValue = callerLineno - - /** - * A unix timestamp recording when the section of code which produced the project logs event - * started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - /** * A unix timestamp recording when the section of code which produced the project logs event * finished */ - @JsonProperty("end") @ExcludeMissing fun _end() = end + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** * The number of tokens in the prompt used to generate the project logs event (only set if * this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + + /** + * A unix timestamp recording when the section of code which produced the project logs event + * started + */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** * The number of tokens in the completion generated by the model (only set if this is an LLM @@ -1012,38 +1149,48 @@ private constructor( */ @JsonProperty("completion_tokens") @ExcludeMissing - fun _completionTokens() = completionTokens + fun _completionTokens(): JsonField = completionTokens - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + /** + * A unix timestamp recording when the section of code which produced the project logs event + * finished + */ + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end - /** This metric is deprecated */ - @JsonProperty("caller_functionname") + /** + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) + */ + @JsonProperty("prompt_tokens") @ExcludeMissing - fun _callerFunctionname() = callerFunctionname + fun _promptTokens(): JsonField = promptTokens - /** This metric is deprecated */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + /** + * A unix timestamp recording when the section of code which produced the project logs event + * started + */ + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start - /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + /** The total number of tokens in the input and output of the project logs event. */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - callerFunctionname() - callerFilename() - callerLineno() - validated = true + if (validated) { + return@apply } + + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true } fun toBuilder() = Builder().from(this) @@ -1053,143 +1200,195 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metrics]. */ + class Builder internal constructor() { - private var start: JsonField = JsonMissing.of() + private var callerFilename: JsonValue = JsonMissing.of() + private var callerFunctionname: JsonValue = JsonMissing.of() + private var callerLineno: JsonValue = JsonMissing.of() + private var completionTokens: JsonField = JsonMissing.of() private var end: JsonField = JsonMissing.of() private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() + private var start: JsonField = JsonMissing.of() private var tokens: JsonField = JsonMissing.of() - private var callerFunctionname: JsonValue = JsonMissing.of() - private var callerFilename: JsonValue = JsonMissing.of() - private var callerLineno: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - this.callerFunctionname = metrics.callerFunctionname - this.callerFilename = metrics.callerFilename - this.callerLineno = metrics.callerLineno - additionalProperties(metrics.additionalProperties) + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } + + /** This metric is deprecated */ + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } + + /** This metric is deprecated */ + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } + + /** This metric is deprecated */ + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.orElse(null) as Long?) + + /** + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) + */ + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens } /** * A unix timestamp recording when the section of code which produced the project logs - * event started + * event finished */ - fun start(start: Double) = start(JsonField.of(start)) + fun end(end: Double?) = end(JsonField.ofNullable(end)) /** * A unix timestamp recording when the section of code which produced the project logs - * event started + * event finished */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun end(end: Double) = end(end as Double?) /** * A unix timestamp recording when the section of code which produced the project logs * event finished */ - fun end(end: Double) = end(JsonField.of(end)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun end(end: Optional) = end(end.orElse(null) as Double?) /** * A unix timestamp recording when the section of code which produced the project logs * event finished */ - @JsonProperty("end") - @ExcludeMissing fun end(end: JsonField) = apply { this.end = end } /** * The number of tokens in the prompt used to generate the project logs event (only set * if this is an LLM span) */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) + fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) + + /** + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun promptTokens(promptTokens: Optional) = + promptTokens(promptTokens.orElse(null) as Long?) /** * The number of tokens in the prompt used to generate the project logs event (only set * if this is an LLM span) */ - @JsonProperty("prompt_tokens") - @ExcludeMissing fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * A unix timestamp recording when the section of code which produced the project logs + * event started */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) + fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * A unix timestamp recording when the section of code which produced the project logs + * event started */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun start(start: Double) = start(start as Double?) - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun start(start: Optional) = start(start.orElse(null) as Double?) + + /** + * A unix timestamp recording when the section of code which produced the project logs + * event started + */ + fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) - /** This metric is deprecated */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(tokens: Long) = tokens(tokens as Long?) - /** This metric is deprecated */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + /** The total number of tokens in the input and output of the project logs event. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun tokens(tokens: Optional) = tokens(tokens.orElse(null) as Long?) - /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + /** The total number of tokens in the input and output of the project logs event. */ + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metrics = Metrics( - start, + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, end, promptTokens, - completionTokens, + start, tokens, - callerFunctionname, - callerFilename, - callerLineno, additionalProperties.toImmutable(), ) } @@ -1199,69 +1398,80 @@ private constructor( return true } - return /* spotless:off */ other is Metrics && start == other.start && end == other.end && promptTokens == other.promptTokens && completionTokens == other.completionTokens && tokens == other.tokens && callerFunctionname == other.callerFunctionname && callerFilename == other.callerFilename && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(start, end, promptTokens, completionTokens, tokens, callerFunctionname, callerFilename, callerLineno, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(callerFilename, callerFunctionname, callerLineno, completionTokens, end, promptTokens, start, tokens, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** Indicates the event was copied from another object. */ - @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect class Origin + @JsonCreator private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val id: JsonField, - private val _xactId: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - /** ID of the original event. */ fun id(): String = id.getRequired("id") /** Transaction ID of the original event. */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + fun objectId(): String = objectId.getRequired("object_id") + + /** Type of the object the event is originating from. */ + fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Origin = apply { - if (!validated) { - objectType() - objectId() - id() - _xactId() - validated = true + if (validated) { + return@apply } + + id() + _xactId() + objectId() + objectType() + validated = true } fun toBuilder() = Builder().from(this) @@ -1271,118 +1481,114 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Origin]. */ + class Builder internal constructor() { - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(origin: Origin) = apply { - this.objectType = origin.objectType - this.objectId = origin.objectId - this.id = origin.id - this._xactId = origin._xactId - additionalProperties(origin.additionalProperties) - } - - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() } - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") - @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") - @ExcludeMissing fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + /** ID of the object the event is originating from. */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** ID of the object the event is originating from. */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** Type of the object the event is originating from. */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** Type of the object the event is originating from. */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Origin = Origin( - objectType, - objectId, - id, - _xactId, + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), additionalProperties.toImmutable(), ) } + /** Type of the object the event is originating from. */ 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 - 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() - companion object { - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val FUNCTION = ObjectType(JsonField.of("function")) + @JvmField val FUNCTION = of("function") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val PROJECT_LOGS = ObjectType(JsonField.of("project_logs")) + @JvmField val PROJECT_LOGS = of("project_logs") @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) } + /** An enum containing [ObjectType]'s known values. */ enum class Known { EXPERIMENT, DATASET, @@ -1392,6 +1598,15 @@ private constructor( PROJECT_LOGS, } + /** + * 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 { EXPERIMENT, DATASET, @@ -1399,9 +1614,20 @@ private constructor( FUNCTION, PROMPT_SESSION, PROJECT_LOGS, + /** + * 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) { EXPERIMENT -> Value.EXPERIMENT @@ -1413,6 +1639,15 @@ private constructor( 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) { EXPERIMENT -> Known.EXPERIMENT @@ -1425,6 +1660,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1432,17 +1679,17 @@ private constructor( return true } - return /* spotless:off */ other is Origin && objectType == other.objectType && objectId == other.objectId && id == other.id && _xactId == other._xactId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectType, objectId, id, _xactId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, id=$id, _xactId=$_xactId, additionalProperties=$additionalProperties}" + "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } /** @@ -1454,23 +1701,26 @@ private constructor( * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect class Scores + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Scores = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1480,29 +1730,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Scores]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) + additionalProperties = scores.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Scores = Scores(additionalProperties.toImmutable()) } @@ -1528,15 +1784,15 @@ private constructor( return true } - return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && orgId == other.orgId && projectId == other.projectId && logId == other.logId && input == other.input && output == other.output && expected == other.expected && error == other.error && scores == other.scores && metadata == other.metadata && tags == other.tags && metrics == other.metrics && context == other.context && spanId == other.spanId && spanParents == other.spanParents && rootSpanId == other.rootSpanId && isRoot == other.isRoot && spanAttributes == other.spanAttributes && origin == other.origin && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && logId == other.logId && orgId == other.orgId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, orgId, projectId, logId, input, output, expected, error, scores, metadata, tags, metrics, context, spanId, spanParents, rootSpanId, isRoot, spanAttributes, origin, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, logId, orgId, projectId, rootSpanId, spanId, context, error, expected, input, isRoot, metadata, metrics, origin, output, scores, spanAttributes, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, isRoot=$isRoot, spanAttributes=$spanAttributes, origin=$origin, additionalProperties=$additionalProperties}" + "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, logId=$logId, orgId=$orgId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 824ea72c..51adb840 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a project object by its id */ class ProjectRetrieveParams -constructor( +private constructor( private val projectId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Project id */ fun projectId(): String = projectId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): ProjectRetrieveParams = ProjectRetrieveParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkRequired("projectId", projectId), additionalHeaders.build(), additionalQueryParams.build(), ) 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 28bb4d36..c0fc104b 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 @@ -10,7 +10,9 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -29,101 +31,121 @@ import java.util.Objects import java.util.Optional /** A project score is a user-configured score, which can be manually-labeled through the UI */ -@JsonDeserialize(builder = ProjectScore.Builder::class) @NoAutoDetect class ProjectScore +@JsonCreator private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val scoreType: JsonField, - private val categories: JsonField, - private val config: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") + @ExcludeMissing + private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + private val config: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the project score */ fun id(): String = id.getRequired("id") - /** Unique identifier for the project that the project score belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - fun userId(): String = userId.getRequired("user_id") - - /** Date of project score creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Name of the project score */ fun name(): String = name.getRequired("name") - /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + /** Unique identifier for the project that the project score belongs under */ + fun projectId(): String = projectId.getRequired("project_id") /** The type of the configured score */ fun scoreType(): ScoreType = scoreType.getRequired("score_type") + fun userId(): String = userId.getRequired("user_id") + /** For categorical-type project scores, the list of all categories */ fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) fun config(): Optional = Optional.ofNullable(config.getNullable("config")) + /** Date of project score creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** Textual description of the project score */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ fun position(): Optional = Optional.ofNullable(position.getNullable("position")) /** Unique identifier for the project score */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId - - /** Date of project score creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Textual description of the project score */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + /** Unique identifier for the project that the project score belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** The type of the configured score */ - @JsonProperty("score_type") @ExcludeMissing fun _scoreType() = scoreType + @JsonProperty("score_type") @ExcludeMissing fun _scoreType(): JsonField = scoreType + + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** For categorical-type project scores, the list of all categories */ - @JsonProperty("categories") @ExcludeMissing fun _categories() = categories + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField = categories + + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - @JsonProperty("config") @ExcludeMissing fun _config() = config + /** Date of project score creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** Textual description of the project score */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectScore = apply { - if (!validated) { - id() - projectId() - userId() - created() - name() - description() - scoreType() - categories() - config().map { it.validate() } - position() - validated = true + if (validated) { + return@apply } + + id() + name() + projectId() + scoreType() + userId() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + created() + description() + position() + validated = true } fun toBuilder() = Builder().from(this) @@ -133,176 +155,187 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectScore]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var scoreType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var scoreType: JsonField? = null + private var userId: JsonField? = null private var categories: JsonField = JsonMissing.of() private var config: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScore: ProjectScore) = apply { - this.id = projectScore.id - this.projectId = projectScore.projectId - this.userId = projectScore.userId - this.created = projectScore.created - this.name = projectScore.name - this.description = projectScore.description - this.scoreType = projectScore.scoreType - this.categories = projectScore.categories - this.config = projectScore.config - this.position = projectScore.position - additionalProperties(projectScore.additionalProperties) + id = projectScore.id + name = projectScore.name + projectId = projectScore.projectId + scoreType = projectScore.scoreType + userId = projectScore.userId + categories = projectScore.categories + config = projectScore.config + created = projectScore.created + description = projectScore.description + position = projectScore.position + additionalProperties = projectScore.additionalProperties.toMutableMap() } /** Unique identifier for the project score */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project score */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun userId(userId: String) = userId(JsonField.of(userId)) - - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } - - /** Date of project score creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** Date of project score creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun id(id: JsonField) = apply { this.id = id } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } - /** Textual description of the project score */ - fun description(description: String) = description(JsonField.of(description)) + /** Unique identifier for the project that the project score belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Textual description of the project score */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + /** Unique identifier for the project that the project score belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) /** The type of the configured score */ - @JsonProperty("score_type") - @ExcludeMissing fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun userId(userId: String) = userId(JsonField.of(userId)) + + fun userId(userId: JsonField) = apply { this.userId = userId } + /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - @JsonProperty("categories") - @ExcludeMissing fun categories(categories: JsonField) = apply { this.categories = categories } - fun config(config: ProjectScoreConfig) = config(JsonField.of(config)) + /** For categorical-type project scores, the list of all categories */ + fun categoriesOfCategorical(categorical: List) = + categories(Categories.ofCategorical(categorical)) + + /** For weighted-type project scores, the weights of each score */ + fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) + + /** For minimum-type project scores, the list of included scores */ + fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(nullableVariant: Categories.NullableVariant) = + categories(Categories.ofNullableVariant(nullableVariant)) + + fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) + + fun config(config: Optional) = config(config.orElse(null)) - @JsonProperty("config") - @ExcludeMissing fun config(config: JsonField) = apply { this.config = config } + /** Date of project score creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** Date of project score creation */ + fun created(created: Optional) = created(created.orElse(null)) + + /** Date of project score creation */ + fun created(created: JsonField) = apply { this.created = created } + + /** Textual description of the project score */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the project score */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project score */ + fun description(description: JsonField) = apply { this.description = description } + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - fun position(position: String) = position(JsonField.of(position)) + fun position(position: String?) = position(JsonField.ofNullable(position)) + + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + fun position(position: Optional) = position(position.orElse(null)) /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectScore = ProjectScore( - id, - projectId, - userId, - created, - name, - description, - scoreType, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("scoreType", scoreType), + checkRequired("userId", userId), categories, config, + created, + description, position, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val SLIDER = ScoreType(JsonField.of("slider")) + @JvmField val SLIDER = of("slider") - @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) + @JvmField val CATEGORICAL = of("categorical") - @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) + @JvmField val WEIGHTED = of("weighted") - @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) + @JvmField val MINIMUM = of("minimum") - @JvmField val MAXIMUM = ScoreType(JsonField.of("maximum")) + @JvmField val MAXIMUM = of("maximum") - @JvmField val ONLINE = ScoreType(JsonField.of("online")) + @JvmField val ONLINE = of("online") @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } + /** An enum containing [ScoreType]'s known values. */ enum class Known { SLIDER, CATEGORICAL, @@ -312,6 +345,15 @@ private constructor( ONLINE, } + /** + * 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, @@ -319,9 +361,19 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + /** + * 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 @@ -333,6 +385,15 @@ private constructor( 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 @@ -345,8 +406,21 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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) class Categories @@ -358,12 +432,12 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** For categorical-type project scores, the list of all categories */ fun categorical(): Optional> = Optional.ofNullable(categorical) + /** For weighted-type project scores, the weights of each score */ fun weighted(): Optional = Optional.ofNullable(weighted) + /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) @@ -377,10 +451,13 @@ private constructor( fun isNullableVariant(): Boolean = nullableVariant != null + /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") + /** For weighted-type project scores, the weights of each score */ fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") @@ -397,21 +474,31 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): Categories = apply { - if (!validated) { - if ( - categorical == null && - weighted == null && - minimum == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - categorical?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitCategorical(categorical: List) { + categorical.forEach { it.validate() } + } + + override fun visitWeighted(weighted: Weighted) { + weighted.validate() + } + + override fun visitMinimum(minimum: List) {} + + override fun visitNullableVariant(nullableVariant: NullableVariant) { + nullableVariant.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -436,12 +523,15 @@ private constructor( companion object { + /** For categorical-type project scores, the list of all categories */ @JvmStatic fun ofCategorical(categorical: List) = Categories(categorical = categorical) + /** For weighted-type project scores, the weights of each score */ @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic @@ -449,22 +539,38 @@ private constructor( Categories(nullableVariant = nullableVariant) } + /** + * An interface that defines how to map each variant of [Categories] to a value of type [T]. + */ interface Visitor { + /** For categorical-type project scores, the list of all categories */ fun visitCategorical(categorical: List): T + /** For weighted-type project scores, the weights of each score */ fun visitWeighted(weighted: Weighted): T + /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T fun visitNullableVariant(nullableVariant: NullableVariant): T + /** + * Maps an unknown variant of [Categories] to a value of type [T]. + * + * An instance of [Categories] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Categories: $json") } } - class Deserializer : BaseDeserializer(Categories::class) { + internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { val json = JsonValue.fromJsonNode(node) @@ -491,7 +597,7 @@ private constructor( } } - class Serializer : BaseSerializer(Categories::class) { + internal class Serializer : BaseSerializer(Categories::class) { override fun serialize( value: Categories, @@ -510,23 +616,26 @@ private constructor( } /** For weighted-type project scores, the weights of each score */ - @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect class Weighted + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Weighted = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -536,23 +645,23 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Weighted]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(weighted: Weighted) = apply { - additionalProperties(weighted.additionalProperties) + additionalProperties = weighted.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -560,6 +669,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } @@ -580,23 +697,26 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect class NullableVariant + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): NullableVariant = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -606,23 +726,23 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [NullableVariant]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) + additionalProperties = nullableVariant.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -630,6 +750,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } @@ -656,15 +784,15 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScore && id == other.id && projectId == other.projectId && userId == other.userId && created == other.created && name == other.name && description == other.description && scoreType == other.scoreType && categories == other.categories && config == other.config && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScore && id == other.id && name == other.name && projectId == other.projectId && scoreType == other.scoreType && userId == other.userId && categories == other.categories && config == other.config && created == other.created && description == other.description && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, userId, created, name, description, scoreType, categories, config, position, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, projectId, scoreType, userId, categories, config, created, description, position, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectScore{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, scoreType=$scoreType, categories=$categories, config=$config, position=$position, additionalProperties=$additionalProperties}" + "ProjectScore{id=$id, name=$name, projectId=$projectId, scoreType=$scoreType, userId=$userId, categories=$categories, config=$config, created=$created, description=$description, position=$position, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index 99a37566..758c27a2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -7,25 +7,25 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects /** For categorical-type project scores, defines a single category */ -@JsonDeserialize(builder = ProjectScoreCategory.Builder::class) @NoAutoDetect class ProjectScoreCategory +@JsonCreator private constructor( - private val name: JsonField, - private val value: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Name of the category */ fun name(): String = name.getRequired("name") @@ -33,21 +33,25 @@ private constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectScoreCategory = apply { - if (!validated) { - name() - value() - validated = true + if (validated) { + return@apply } + + name() + value() + validated = true } fun toBuilder() = Builder().from(this) @@ -57,53 +61,55 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectScoreCategory]. */ + class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var name: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreCategory: ProjectScoreCategory) = apply { - this.name = projectScoreCategory.name - this.value = projectScoreCategory.value - additionalProperties(projectScoreCategory.additionalProperties) + name = projectScoreCategory.name + value = projectScoreCategory.value + additionalProperties = projectScoreCategory.additionalProperties.toMutableMap() } /** Name of the category */ fun name(name: String) = name(JsonField.of(name)) /** Name of the category */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") - @ExcludeMissing fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectScoreCategory = ProjectScoreCategory( - name, - value, + checkRequired("name", name), + checkRequired("value", value), additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index e1641f66..ecdf62c2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -8,53 +8,65 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ProjectScoreConfig.Builder::class) @NoAutoDetect class ProjectScoreConfig +@JsonCreator private constructor( - private val multiSelect: JsonField, - private val destination: JsonField, - private val online: JsonField, - private val additionalProperties: Map, + @JsonProperty("destination") + @ExcludeMissing + private val destination: JsonField = JsonMissing.of(), + @JsonProperty("multi_select") + @ExcludeMissing + private val multiSelect: JsonField = JsonMissing.of(), + @JsonProperty("online") + @ExcludeMissing + private val online: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun destination(): Optional = + Optional.ofNullable(destination.getNullable("destination")) fun multiSelect(): Optional = Optional.ofNullable(multiSelect.getNullable("multi_select")) - fun destination(): Optional = - Optional.ofNullable(destination.getNullable("destination")) - fun online(): Optional = Optional.ofNullable(online.getNullable("online")) - @JsonProperty("multi_select") @ExcludeMissing fun _multiSelect() = multiSelect + @JsonProperty("destination") + @ExcludeMissing + fun _destination(): JsonField = destination - @JsonProperty("destination") @ExcludeMissing fun _destination() = destination + @JsonProperty("multi_select") + @ExcludeMissing + fun _multiSelect(): JsonField = multiSelect - @JsonProperty("online") @ExcludeMissing fun _online() = online + @JsonProperty("online") @ExcludeMissing fun _online(): JsonField = online @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectScoreConfig = apply { - if (!validated) { - multiSelect() - destination() - online().map { it.validate() } - validated = true + if (validated) { + return@apply } + + destination() + multiSelect() + online().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -64,59 +76,69 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectScoreConfig]. */ + class Builder internal constructor() { - private var multiSelect: JsonField = JsonMissing.of() private var destination: JsonField = JsonMissing.of() + private var multiSelect: JsonField = JsonMissing.of() private var online: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreConfig: ProjectScoreConfig) = apply { - this.multiSelect = projectScoreConfig.multiSelect - this.destination = projectScoreConfig.destination - this.online = projectScoreConfig.online - additionalProperties(projectScoreConfig.additionalProperties) + destination = projectScoreConfig.destination + multiSelect = projectScoreConfig.multiSelect + online = projectScoreConfig.online + additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() } - fun multiSelect(multiSelect: Boolean) = multiSelect(JsonField.of(multiSelect)) - - @JsonProperty("multi_select") - @ExcludeMissing - fun multiSelect(multiSelect: JsonField) = apply { this.multiSelect = multiSelect } + fun destination(destination: Destination?) = destination(JsonField.ofNullable(destination)) - fun destination(destination: Destination) = destination(JsonField.of(destination)) + fun destination(destination: Optional) = destination(destination.orElse(null)) - @JsonProperty("destination") - @ExcludeMissing fun destination(destination: JsonField) = apply { this.destination = destination } - fun online(online: OnlineScoreConfig) = online(JsonField.of(online)) + fun multiSelect(multiSelect: Boolean?) = multiSelect(JsonField.ofNullable(multiSelect)) + + fun multiSelect(multiSelect: Boolean) = multiSelect(multiSelect as Boolean?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun multiSelect(multiSelect: Optional) = + multiSelect(multiSelect.orElse(null) as Boolean?) + + fun multiSelect(multiSelect: JsonField) = apply { this.multiSelect = multiSelect } + + fun online(online: OnlineScoreConfig?) = online(JsonField.ofNullable(online)) + + fun online(online: Optional) = online(online.orElse(null)) - @JsonProperty("online") - @ExcludeMissing fun online(online: JsonField) = apply { this.online = online } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectScoreConfig = ProjectScoreConfig( - multiSelect, destination, + multiSelect, online, additionalProperties.toImmutable(), ) @@ -128,42 +150,67 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val EXPECTED = Destination(JsonField.of("expected")) + @JvmField val EXPECTED = of("expected") @JvmStatic fun of(value: String) = Destination(JsonField.of(value)) } + /** An enum containing [Destination]'s known values. */ enum class Known { EXPECTED, } + /** + * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Destination] 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 { EXPECTED, + /** + * An enum member indicating that [Destination] 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) { EXPECTED -> Value.EXPECTED 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) { EXPECTED -> Known.EXPECTED @@ -171,6 +218,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -178,15 +237,15 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScoreConfig && multiSelect == other.multiSelect && destination == other.destination && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreConfig && destination == other.destination && multiSelect == other.multiSelect && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(multiSelect, destination, online, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(destination, multiSelect, online, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectScoreConfig{multiSelect=$multiSelect, destination=$destination, online=$online, additionalProperties=$additionalProperties}" + "ProjectScoreConfig{destination=$destination, multiSelect=$multiSelect, online=$online, additionalProperties=$additionalProperties}" } 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 85482c3f..f2a700a4 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 @@ -7,11 +7,15 @@ 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 import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow 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 @@ -28,89 +32,155 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * Create a new project_score. If there is an existing project_score in the project with the same + * name as the one specified in the request, will return the existing project_score unmodified + */ class ProjectScoreCreateParams -constructor( - private val name: String, - private val projectId: String, - private val scoreType: ScoreType, - private val categories: Categories?, - private val config: ProjectScoreConfig?, - private val description: String?, +private constructor( + private val body: ProjectScoreCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the project score */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the project score belongs under */ + fun projectId(): String = body.projectId() - fun scoreType(): ScoreType = scoreType + /** The type of the configured score */ + fun scoreType(): ScoreType = body.scoreType() - fun categories(): Optional = Optional.ofNullable(categories) + /** For categorical-type project scores, the list of all categories */ + fun categories(): Optional = body.categories() - fun config(): Optional = Optional.ofNullable(config) + fun config(): Optional = body.config() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the project score */ + fun description(): Optional = body.description() + + /** Name of the project score */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the project score belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** The type of the configured score */ + fun _scoreType(): JsonField = body._scoreType() + + /** For categorical-type project scores, the list of all categories */ + fun _categories(): JsonField = body._categories() + + fun _config(): JsonField = body._config() + + /** Textual description of the project score */ + fun _description(): JsonField = body._description() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectScoreCreateBody { - return ProjectScoreCreateBody( - name, - projectId, - scoreType, - categories, - config, - description, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ProjectScoreCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams /** A project score is a user-configured score, which can be manually-labeled through the UI */ - @JsonDeserialize(builder = ProjectScoreCreateBody.Builder::class) @NoAutoDetect class ProjectScoreCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val config: ProjectScoreConfig?, - private val description: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") + @ExcludeMissing + private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project score */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** Unique identifier for the project that the project score belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** The type of the configured score */ + fun scoreType(): ScoreType = scoreType.getRequired("score_type") + + /** For categorical-type project scores, the list of all categories */ + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) + + fun config(): Optional = + Optional.ofNullable(config.getNullable("config")) + + /** Textual description of the project score */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the project score */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") + @ExcludeMissing + fun _scoreType(): JsonField = scoreType /** For categorical-type project scores, the list of all categories */ - @JsonProperty("categories") fun categories(): Categories? = categories + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField = categories - @JsonProperty("config") fun config(): ProjectScoreConfig? = config + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField = config /** Textual description of the project score */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectScoreCreateBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + scoreType() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -118,68 +188,111 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectScoreCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var scoreType: ScoreType? = null - private var categories: Categories? = null - private var config: ProjectScoreConfig? = null - private var description: String? = null + private var name: JsonField? = null + private var projectId: 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() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreCreateBody: ProjectScoreCreateBody) = apply { - this.name = projectScoreCreateBody.name - this.projectId = projectScoreCreateBody.projectId - this.scoreType = projectScoreCreateBody.scoreType - this.categories = projectScoreCreateBody.categories - this.config = projectScoreCreateBody.config - this.description = projectScoreCreateBody.description - additionalProperties(projectScoreCreateBody.additionalProperties) + name = projectScoreCreateBody.name + projectId = projectScoreCreateBody.projectId + scoreType = projectScoreCreateBody.scoreType + categories = projectScoreCreateBody.categories + config = projectScoreCreateBody.config + description = projectScoreCreateBody.description + additionalProperties = projectScoreCreateBody.additionalProperties.toMutableMap() } /** Name of the project score */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project score */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the project score belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ - @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) + + /** The type of the configured score */ + fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ - @JsonProperty("categories") - fun categories(categories: Categories) = apply { this.categories = categories } + fun categories(categories: Categories) = categories(JsonField.of(categories)) - @JsonProperty("config") - fun config(config: ProjectScoreConfig) = apply { this.config = config } + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: JsonField) = apply { + this.categories = categories + } + + /** For categorical-type project scores, the list of all categories */ + fun categoriesOfCategorical(categorical: List) = + categories(Categories.ofCategorical(categorical)) + + /** For weighted-type project scores, the weights of each score */ + fun categories(weighted: Categories.Weighted) = + categories(Categories.ofWeighted(weighted)) + + /** For minimum-type project scores, the list of included scores */ + fun categoriesOfMinimum(minimum: List) = + categories(Categories.ofMinimum(minimum)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(nullableVariant: Categories.NullableVariant) = + categories(Categories.ofNullableVariant(nullableVariant)) + + fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) + + fun config(config: Optional) = config(config.orElse(null)) + + fun config(config: JsonField) = apply { this.config = config } + + /** Textual description of the project score */ + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project score */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project score */ + fun description(description: JsonField) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectScoreCreateBody = ProjectScoreCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(scoreType) { "`scoreType` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("scoreType", scoreType), categories, config, description, @@ -212,69 +325,94 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectScoreCreateParams]. */ @NoAutoDetect - class Builder { - - private var name: String? = null - private var projectId: String? = null - private var scoreType: ScoreType? = null - private var categories: Categories? = null - private var config: ProjectScoreConfig? = null - private var description: String? = null + class Builder internal constructor() { + + private var body: ProjectScoreCreateBody.Builder = ProjectScoreCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreCreateParams: ProjectScoreCreateParams) = apply { - name = projectScoreCreateParams.name - projectId = projectScoreCreateParams.projectId - scoreType = projectScoreCreateParams.scoreType - categories = projectScoreCreateParams.categories - config = projectScoreCreateParams.config - description = projectScoreCreateParams.description + body = projectScoreCreateParams.body.toBuilder() additionalHeaders = projectScoreCreateParams.additionalHeaders.toBuilder() additionalQueryParams = projectScoreCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectScoreCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the project score */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the project score */ + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { body.projectId(projectId) } + + /** Unique identifier for the project that the project score belongs under */ + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { body.scoreType(scoreType) } - /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { this.categories = categories } + /** The type of the configured score */ + fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - this.categories = Categories.ofCategorical(categorical) - } + fun categories(categories: Categories) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categories(weighted: Categories.Weighted) = apply { - this.categories = Categories.ofWeighted(weighted) - } + fun categories(categories: JsonField) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfMinimum(minimum: List) = apply { - this.categories = Categories.ofMinimum(minimum) + fun categoriesOfCategorical(categorical: List) = apply { + body.categoriesOfCategorical(categorical) } + /** For weighted-type project scores, the weights of each score */ + fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + + /** For minimum-type project scores, the list of included scores */ + fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } + /** For categorical-type project scores, the list of all categories */ fun categories(nullableVariant: Categories.NullableVariant) = apply { - this.categories = Categories.ofNullableVariant(nullableVariant) + body.categories(nullableVariant) } - fun config(config: ProjectScoreConfig) = apply { this.config = config } + fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + + fun config(config: Optional) = config(config.orElse(null)) + + fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the project score */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project score */ + fun description(description: JsonField) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -374,79 +512,49 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectScoreCreateParams = ProjectScoreCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(scoreType) { "`scoreType` is required but was not set" }, - categories, - config, - description, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val SLIDER = ScoreType(JsonField.of("slider")) + @JvmField val SLIDER = of("slider") - @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) + @JvmField val CATEGORICAL = of("categorical") - @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) + @JvmField val WEIGHTED = of("weighted") - @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) + @JvmField val MINIMUM = of("minimum") - @JvmField val MAXIMUM = ScoreType(JsonField.of("maximum")) + @JvmField val MAXIMUM = of("maximum") - @JvmField val ONLINE = ScoreType(JsonField.of("online")) + @JvmField val ONLINE = of("online") @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } + /** An enum containing [ScoreType]'s known values. */ enum class Known { SLIDER, CATEGORICAL, @@ -456,6 +564,15 @@ constructor( ONLINE, } + /** + * 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, @@ -463,9 +580,19 @@ constructor( MINIMUM, MAXIMUM, ONLINE, + /** + * 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 @@ -477,6 +604,15 @@ constructor( 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 @@ -489,8 +625,21 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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) class Categories @@ -502,12 +651,12 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** For categorical-type project scores, the list of all categories */ fun categorical(): Optional> = Optional.ofNullable(categorical) + /** For weighted-type project scores, the weights of each score */ fun weighted(): Optional = Optional.ofNullable(weighted) + /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) @@ -521,10 +670,13 @@ constructor( fun isNullableVariant(): Boolean = nullableVariant != null + /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") + /** For weighted-type project scores, the weights of each score */ fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") @@ -541,21 +693,31 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Categories = apply { - if (!validated) { - if ( - categorical == null && - weighted == null && - minimum == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - categorical?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitCategorical(categorical: List) { + categorical.forEach { it.validate() } + } + + override fun visitWeighted(weighted: Weighted) { + weighted.validate() + } + + override fun visitMinimum(minimum: List) {} + + override fun visitNullableVariant(nullableVariant: NullableVariant) { + nullableVariant.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -580,12 +742,15 @@ constructor( companion object { + /** For categorical-type project scores, the list of all categories */ @JvmStatic fun ofCategorical(categorical: List) = Categories(categorical = categorical) + /** For weighted-type project scores, the weights of each score */ @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic @@ -593,22 +758,38 @@ constructor( Categories(nullableVariant = nullableVariant) } + /** + * An interface that defines how to map each variant of [Categories] to a value of type [T]. + */ interface Visitor { + /** For categorical-type project scores, the list of all categories */ fun visitCategorical(categorical: List): T + /** For weighted-type project scores, the weights of each score */ fun visitWeighted(weighted: Weighted): T + /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T fun visitNullableVariant(nullableVariant: NullableVariant): T + /** + * Maps an unknown variant of [Categories] to a value of type [T]. + * + * An instance of [Categories] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Categories: $json") } } - class Deserializer : BaseDeserializer(Categories::class) { + internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { val json = JsonValue.fromJsonNode(node) @@ -635,7 +816,7 @@ constructor( } } - class Serializer : BaseSerializer(Categories::class) { + internal class Serializer : BaseSerializer(Categories::class) { override fun serialize( value: Categories, @@ -654,23 +835,26 @@ constructor( } /** For weighted-type project scores, the weights of each score */ - @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect class Weighted + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Weighted = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -680,23 +864,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Weighted]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(weighted: Weighted) = apply { - additionalProperties(weighted.additionalProperties) + additionalProperties = weighted.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -704,6 +888,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } @@ -724,23 +916,26 @@ constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect class NullableVariant + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): NullableVariant = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -750,23 +945,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [NullableVariant]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) + additionalProperties = nullableVariant.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -774,6 +969,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } @@ -800,11 +1003,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreCreateParams && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectScoreCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 0d76b5fc..de63fd45 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a project_score object by its id */ class ProjectScoreDeleteParams -constructor( +private constructor( private val projectScoreId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** ProjectScore id */ fun projectScoreId(): String = projectScoreId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectScoreDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectScoreId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -192,7 +195,7 @@ constructor( fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( - checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, + checkRequired("projectScoreId", projectScoreId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index 2f728a79..10e8bdea 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.ProjectScoreService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first + */ class ProjectScoreListPage private constructor( private val projectScoresService: ProjectScoreService, @@ -89,16 +94,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -108,11 +113,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -148,10 +157,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -160,8 +167,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ProjectScoreListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index 5c68f620..8f2d5398 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.ProjectScoreServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first + */ class ProjectScoreListPageAsync private constructor( private val projectScoresService: ProjectScoreServiceAsync, @@ -92,16 +97,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +116,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +160,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +170,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ProjectScoreListPageAsync, ) { 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 5b669e67..2ad5f16c 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 @@ -8,11 +8,11 @@ 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 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.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -24,8 +24,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first + */ class ProjectScoreListParams -constructor( +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -37,34 +41,57 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Project id */ fun projectId(): Optional = Optional.ofNullable(projectId) + /** Name of the project to search for */ fun projectName(): Optional = Optional.ofNullable(projectName) + /** Name of the project_score to search for */ fun projectScoreName(): Optional = Optional.ofNullable(projectScoreName) + /** The type of the configured score */ fun scoreType(): Optional = Optional.ofNullable(scoreType) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.ids?.let { queryParams.put("ids", listOf(it.toString())) } @@ -86,8 +113,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectScoreListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var ids: Ids? = null @@ -123,55 +151,99 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long) = limit(limit as Long?) + + /** Limit the number of objects to return */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** Filter search results to within a particular organization */ + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** Project id */ + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = apply { this.projectName = projectName } + + /** Name of the project to search for */ + fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) /** Name of the project_score to search for */ - fun projectScoreName(projectScoreName: String) = apply { + fun projectScoreName(projectScoreName: String?) = apply { this.projectScoreName = projectScoreName } + /** Name of the project_score to search for */ + fun projectScoreName(projectScoreName: Optional) = + projectScoreName(projectScoreName.orElse(null)) + /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType?) = apply { this.scoreType = scoreType } /** The type of the configured score */ - fun scoreType(projectScoreType: ScoreType.ProjectScoreType) = apply { - this.scoreType = ScoreType.ofProjectScoreType(projectScoreType) - } + fun scoreType(scoreType: Optional) = scoreType(scoreType.orElse(null)) /** The type of the configured score */ - fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = apply { - this.scoreType = ScoreType.ofProjectScoreTypes(projectScoreTypes) - } + fun scoreType(project: ScoreType.ProjectScoreType) = scoreType(ScoreType.ofProject(project)) + + /** The type of the configured score */ + fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = + scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. @@ -180,7 +252,8 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -296,6 +369,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -305,8 +382,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -329,15 +404,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -363,18 +429,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -390,7 +466,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, @@ -407,29 +483,31 @@ constructor( } } + /** The type of the configured score */ @JsonDeserialize(using = ScoreType.Deserializer::class) @JsonSerialize(using = ScoreType.Serializer::class) class ScoreType private constructor( - private val projectScoreType: ProjectScoreType? = null, + private val project: ProjectScoreType? = null, private val projectScoreTypes: List? = null, private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** The type of the configured score */ - fun projectScoreType(): Optional = Optional.ofNullable(projectScoreType) + fun project(): Optional = Optional.ofNullable(project) + /** The type of the configured score */ fun projectScoreTypes(): Optional> = Optional.ofNullable(projectScoreTypes) - fun isProjectScoreType(): Boolean = projectScoreType != null + fun isProject(): Boolean = project != null fun isProjectScoreTypes(): Boolean = projectScoreTypes != null - fun asProjectScoreType(): ProjectScoreType = projectScoreType.getOrThrow("projectScoreType") + /** The type of the configured score */ + fun asProject(): ProjectScoreType = project.getOrThrow("project") + /** The type of the configured score */ fun asProjectScoreTypes(): List = projectScoreTypes.getOrThrow("projectScoreTypes") @@ -437,34 +515,25 @@ constructor( fun accept(visitor: Visitor): T { return when { - projectScoreType != null -> visitor.visitProjectScoreType(projectScoreType) + project != null -> visitor.visitProject(project) projectScoreTypes != null -> visitor.visitProjectScoreTypes(projectScoreTypes) else -> visitor.unknown(_json) } } - fun validate(): ScoreType = apply { - if (!validated) { - if (projectScoreType == null && projectScoreTypes == null) { - throw BraintrustInvalidDataException("Unknown ScoreType: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ScoreType && projectScoreType == other.projectScoreType && projectScoreTypes == other.projectScoreTypes /* spotless:on */ + return /* spotless:off */ other is ScoreType && project == other.project && projectScoreTypes == other.projectScoreTypes /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreType, projectScoreTypes) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(project, projectScoreTypes) /* spotless:on */ override fun toString(): String = when { - projectScoreType != null -> "ScoreType{projectScoreType=$projectScoreType}" + project != null -> "ScoreType{project=$project}" projectScoreTypes != null -> "ScoreType{projectScoreTypes=$projectScoreTypes}" _json != null -> "ScoreType{_unknown=$_json}" else -> throw IllegalStateException("Invalid ScoreType") @@ -472,33 +541,48 @@ constructor( companion object { - @JvmStatic - fun ofProjectScoreType(projectScoreType: ProjectScoreType) = - ScoreType(projectScoreType = projectScoreType) + /** The type of the configured score */ + @JvmStatic fun ofProject(project: ProjectScoreType) = ScoreType(project = project) + /** The type of the configured score */ @JvmStatic fun ofProjectScoreTypes(projectScoreTypes: List) = ScoreType(projectScoreTypes = projectScoreTypes) } + /** + * An interface that defines how to map each variant of [ScoreType] to a value of type [T]. + */ interface Visitor { - fun visitProjectScoreType(projectScoreType: ProjectScoreType): T + /** The type of the configured score */ + fun visitProject(project: ProjectScoreType): T + /** The type of the configured score */ fun visitProjectScoreTypes(projectScoreTypes: List): T + /** + * Maps an unknown variant of [ScoreType] to a value of type [T]. + * + * An instance of [ScoreType] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown ScoreType: $json") } } - class Deserializer : BaseDeserializer(ScoreType::class) { + internal class Deserializer : BaseDeserializer(ScoreType::class) { override fun ObjectCodec.deserialize(node: JsonNode): ScoreType { val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef())?.let { - return ScoreType(projectScoreType = it, _json = json) + return ScoreType(project = it, _json = json) } tryDeserialize(node, jacksonTypeRef>())?.let { return ScoreType(projectScoreTypes = it, _json = json) @@ -508,7 +592,7 @@ constructor( } } - class Serializer : BaseSerializer(ScoreType::class) { + internal class Serializer : BaseSerializer(ScoreType::class) { override fun serialize( value: ScoreType, @@ -516,7 +600,7 @@ constructor( provider: SerializerProvider ) { when { - value.projectScoreType != null -> generator.writeObject(value.projectScoreType) + value.project != null -> generator.writeObject(value.project) value.projectScoreTypes != null -> generator.writeObject(value.projectScoreTypes) value._json != null -> generator.writeObject(value._json) @@ -525,43 +609,41 @@ 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 - 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() - companion object { - @JvmField val SLIDER = ProjectScoreType(JsonField.of("slider")) + @JvmField val SLIDER = of("slider") - @JvmField val CATEGORICAL = ProjectScoreType(JsonField.of("categorical")) + @JvmField val CATEGORICAL = of("categorical") - @JvmField val WEIGHTED = ProjectScoreType(JsonField.of("weighted")) + @JvmField val WEIGHTED = of("weighted") - @JvmField val MINIMUM = ProjectScoreType(JsonField.of("minimum")) + @JvmField val MINIMUM = of("minimum") - @JvmField val MAXIMUM = ProjectScoreType(JsonField.of("maximum")) + @JvmField val MAXIMUM = of("maximum") - @JvmField val ONLINE = ProjectScoreType(JsonField.of("online")) + @JvmField val ONLINE = of("online") @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) } + /** An enum containing [ProjectScoreType]'s known values. */ enum class Known { SLIDER, CATEGORICAL, @@ -571,6 +653,16 @@ constructor( ONLINE, } + /** + * 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, @@ -578,9 +670,20 @@ constructor( MINIMUM, MAXIMUM, ONLINE, + /** + * 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 @@ -592,6 +695,15 @@ constructor( 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 @@ -604,15 +716,6 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class ProjectScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { @@ -625,24 +728,43 @@ constructor( 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 = ProjectScoreType(JsonField.of("slider")) + @JvmField val SLIDER = of("slider") - @JvmField val CATEGORICAL = ProjectScoreType(JsonField.of("categorical")) + @JvmField val CATEGORICAL = of("categorical") - @JvmField val WEIGHTED = ProjectScoreType(JsonField.of("weighted")) + @JvmField val WEIGHTED = of("weighted") - @JvmField val MINIMUM = ProjectScoreType(JsonField.of("minimum")) + @JvmField val MINIMUM = of("minimum") - @JvmField val MAXIMUM = ProjectScoreType(JsonField.of("maximum")) + @JvmField val MAXIMUM = of("maximum") - @JvmField val ONLINE = ProjectScoreType(JsonField.of("online")) + @JvmField val ONLINE = of("online") @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) } + /** An enum containing [ProjectScoreType]'s known values. */ enum class Known { SLIDER, CATEGORICAL, @@ -652,6 +774,16 @@ constructor( ONLINE, } + /** + * 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, @@ -659,9 +791,20 @@ constructor( MINIMUM, MAXIMUM, ONLINE, + /** + * 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 @@ -673,6 +816,15 @@ constructor( 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 @@ -685,6 +837,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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/ProjectScoreReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt index 05cbad15..5439a1c4 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 @@ -7,11 +7,15 @@ 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 import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow 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 @@ -28,89 +32,156 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * Create or replace project_score. If there is an existing project_score in the project with the + * same name as the one specified in the request, will replace the existing project_score with the + * provided fields + */ class ProjectScoreReplaceParams -constructor( - private val name: String, - private val projectId: String, - private val scoreType: ScoreType, - private val categories: Categories?, - private val config: ProjectScoreConfig?, - private val description: String?, +private constructor( + private val body: ProjectScoreReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the project score */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the project score belongs under */ + fun projectId(): String = body.projectId() - fun scoreType(): ScoreType = scoreType + /** The type of the configured score */ + fun scoreType(): ScoreType = body.scoreType() - fun categories(): Optional = Optional.ofNullable(categories) + /** For categorical-type project scores, the list of all categories */ + fun categories(): Optional = body.categories() - fun config(): Optional = Optional.ofNullable(config) + fun config(): Optional = body.config() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the project score */ + fun description(): Optional = body.description() + + /** Name of the project score */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the project score belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** The type of the configured score */ + fun _scoreType(): JsonField = body._scoreType() + + /** For categorical-type project scores, the list of all categories */ + fun _categories(): JsonField = body._categories() + + fun _config(): JsonField = body._config() + + /** Textual description of the project score */ + fun _description(): JsonField = body._description() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectScoreReplaceBody { - return ProjectScoreReplaceBody( - name, - projectId, - scoreType, - categories, - config, - description, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ProjectScoreReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams /** A project score is a user-configured score, which can be manually-labeled through the UI */ - @JsonDeserialize(builder = ProjectScoreReplaceBody.Builder::class) @NoAutoDetect class ProjectScoreReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val config: ProjectScoreConfig?, - private val description: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") + @ExcludeMissing + private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project score */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** Unique identifier for the project that the project score belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** The type of the configured score */ + fun scoreType(): ScoreType = scoreType.getRequired("score_type") + + /** For categorical-type project scores, the list of all categories */ + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) + + fun config(): Optional = + Optional.ofNullable(config.getNullable("config")) + + /** Textual description of the project score */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the project score */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") + @ExcludeMissing + fun _scoreType(): JsonField = scoreType /** For categorical-type project scores, the list of all categories */ - @JsonProperty("categories") fun categories(): Categories? = categories + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField = categories - @JsonProperty("config") fun config(): ProjectScoreConfig? = config + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField = config /** Textual description of the project score */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectScoreReplaceBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + scoreType() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -118,68 +189,111 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectScoreReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var scoreType: ScoreType? = null - private var categories: Categories? = null - private var config: ProjectScoreConfig? = null - private var description: String? = null + private var name: JsonField? = null + private var projectId: 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() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreReplaceBody: ProjectScoreReplaceBody) = apply { - this.name = projectScoreReplaceBody.name - this.projectId = projectScoreReplaceBody.projectId - this.scoreType = projectScoreReplaceBody.scoreType - this.categories = projectScoreReplaceBody.categories - this.config = projectScoreReplaceBody.config - this.description = projectScoreReplaceBody.description - additionalProperties(projectScoreReplaceBody.additionalProperties) + name = projectScoreReplaceBody.name + projectId = projectScoreReplaceBody.projectId + scoreType = projectScoreReplaceBody.scoreType + categories = projectScoreReplaceBody.categories + config = projectScoreReplaceBody.config + description = projectScoreReplaceBody.description + additionalProperties = projectScoreReplaceBody.additionalProperties.toMutableMap() } /** Name of the project score */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project score */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the project score belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ - @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) + + /** The type of the configured score */ + fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ - @JsonProperty("categories") - fun categories(categories: Categories) = apply { this.categories = categories } + fun categories(categories: Categories) = categories(JsonField.of(categories)) - @JsonProperty("config") - fun config(config: ProjectScoreConfig) = apply { this.config = config } + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: JsonField) = apply { + this.categories = categories + } + + /** For categorical-type project scores, the list of all categories */ + fun categoriesOfCategorical(categorical: List) = + categories(Categories.ofCategorical(categorical)) + + /** For weighted-type project scores, the weights of each score */ + fun categories(weighted: Categories.Weighted) = + categories(Categories.ofWeighted(weighted)) + + /** For minimum-type project scores, the list of included scores */ + fun categoriesOfMinimum(minimum: List) = + categories(Categories.ofMinimum(minimum)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(nullableVariant: Categories.NullableVariant) = + categories(Categories.ofNullableVariant(nullableVariant)) + + fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) + + fun config(config: Optional) = config(config.orElse(null)) + + fun config(config: JsonField) = apply { this.config = config } + + /** Textual description of the project score */ + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project score */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project score */ + fun description(description: JsonField) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectScoreReplaceBody = ProjectScoreReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(scoreType) { "`scoreType` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("scoreType", scoreType), categories, config, description, @@ -212,69 +326,94 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectScoreReplaceParams]. */ @NoAutoDetect - class Builder { - - private var name: String? = null - private var projectId: String? = null - private var scoreType: ScoreType? = null - private var categories: Categories? = null - private var config: ProjectScoreConfig? = null - private var description: String? = null + class Builder internal constructor() { + + private var body: ProjectScoreReplaceBody.Builder = ProjectScoreReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreReplaceParams: ProjectScoreReplaceParams) = apply { - name = projectScoreReplaceParams.name - projectId = projectScoreReplaceParams.projectId - scoreType = projectScoreReplaceParams.scoreType - categories = projectScoreReplaceParams.categories - config = projectScoreReplaceParams.config - description = projectScoreReplaceParams.description + body = projectScoreReplaceParams.body.toBuilder() additionalHeaders = projectScoreReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = projectScoreReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectScoreReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the project score */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the project score */ + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { body.projectId(projectId) } + + /** Unique identifier for the project that the project score belongs under */ + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { body.scoreType(scoreType) } - /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { this.categories = categories } + /** The type of the configured score */ + fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - this.categories = Categories.ofCategorical(categorical) - } + fun categories(categories: Categories) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categories(weighted: Categories.Weighted) = apply { - this.categories = Categories.ofWeighted(weighted) - } + fun categories(categories: JsonField) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfMinimum(minimum: List) = apply { - this.categories = Categories.ofMinimum(minimum) + fun categoriesOfCategorical(categorical: List) = apply { + body.categoriesOfCategorical(categorical) } + /** For weighted-type project scores, the weights of each score */ + fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + + /** For minimum-type project scores, the list of included scores */ + fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } + /** For categorical-type project scores, the list of all categories */ fun categories(nullableVariant: Categories.NullableVariant) = apply { - this.categories = Categories.ofNullableVariant(nullableVariant) + body.categories(nullableVariant) } - fun config(config: ProjectScoreConfig) = apply { this.config = config } + fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + + fun config(config: Optional) = config(config.orElse(null)) + + fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the project score */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project score */ + fun description(description: JsonField) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -374,79 +513,49 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectScoreReplaceParams = ProjectScoreReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(scoreType) { "`scoreType` is required but was not set" }, - categories, - config, - description, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val SLIDER = ScoreType(JsonField.of("slider")) + @JvmField val SLIDER = of("slider") - @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) + @JvmField val CATEGORICAL = of("categorical") - @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) + @JvmField val WEIGHTED = of("weighted") - @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) + @JvmField val MINIMUM = of("minimum") - @JvmField val MAXIMUM = ScoreType(JsonField.of("maximum")) + @JvmField val MAXIMUM = of("maximum") - @JvmField val ONLINE = ScoreType(JsonField.of("online")) + @JvmField val ONLINE = of("online") @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } + /** An enum containing [ScoreType]'s known values. */ enum class Known { SLIDER, CATEGORICAL, @@ -456,6 +565,15 @@ constructor( ONLINE, } + /** + * 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, @@ -463,9 +581,19 @@ constructor( MINIMUM, MAXIMUM, ONLINE, + /** + * 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 @@ -477,6 +605,15 @@ constructor( 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 @@ -489,8 +626,21 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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) class Categories @@ -502,12 +652,12 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** For categorical-type project scores, the list of all categories */ fun categorical(): Optional> = Optional.ofNullable(categorical) + /** For weighted-type project scores, the weights of each score */ fun weighted(): Optional = Optional.ofNullable(weighted) + /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) @@ -521,10 +671,13 @@ constructor( fun isNullableVariant(): Boolean = nullableVariant != null + /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") + /** For weighted-type project scores, the weights of each score */ fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") @@ -541,21 +694,31 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Categories = apply { - if (!validated) { - if ( - categorical == null && - weighted == null && - minimum == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - categorical?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitCategorical(categorical: List) { + categorical.forEach { it.validate() } + } + + override fun visitWeighted(weighted: Weighted) { + weighted.validate() + } + + override fun visitMinimum(minimum: List) {} + + override fun visitNullableVariant(nullableVariant: NullableVariant) { + nullableVariant.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -580,12 +743,15 @@ constructor( companion object { + /** For categorical-type project scores, the list of all categories */ @JvmStatic fun ofCategorical(categorical: List) = Categories(categorical = categorical) + /** For weighted-type project scores, the weights of each score */ @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic @@ -593,22 +759,38 @@ constructor( Categories(nullableVariant = nullableVariant) } + /** + * An interface that defines how to map each variant of [Categories] to a value of type [T]. + */ interface Visitor { + /** For categorical-type project scores, the list of all categories */ fun visitCategorical(categorical: List): T + /** For weighted-type project scores, the weights of each score */ fun visitWeighted(weighted: Weighted): T + /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T fun visitNullableVariant(nullableVariant: NullableVariant): T + /** + * Maps an unknown variant of [Categories] to a value of type [T]. + * + * An instance of [Categories] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Categories: $json") } } - class Deserializer : BaseDeserializer(Categories::class) { + internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { val json = JsonValue.fromJsonNode(node) @@ -635,7 +817,7 @@ constructor( } } - class Serializer : BaseSerializer(Categories::class) { + internal class Serializer : BaseSerializer(Categories::class) { override fun serialize( value: Categories, @@ -654,23 +836,26 @@ constructor( } /** For weighted-type project scores, the weights of each score */ - @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect class Weighted + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Weighted = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -680,23 +865,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Weighted]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(weighted: Weighted) = apply { - additionalProperties(weighted.additionalProperties) + additionalProperties = weighted.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -704,6 +889,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } @@ -724,23 +917,26 @@ constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect class NullableVariant + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): NullableVariant = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -750,23 +946,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [NullableVariant]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) + additionalProperties = nullableVariant.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -774,6 +970,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } @@ -800,11 +1004,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreReplaceParams && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, scoreType, categories, config, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectScoreReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 0cf1948a..32de5bac 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a project_score object by its id */ class ProjectScoreRetrieveParams -constructor( +private constructor( private val projectScoreId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** ProjectScore id */ fun projectScoreId(): String = projectScoreId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectScoreRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectScoreId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( - checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, + checkRequired("projectScoreId", projectScoreId), additionalHeaders.build(), additionalQueryParams.build(), ) 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 5c6e0a37..73dd76e3 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 @@ -7,11 +7,15 @@ 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 import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow 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 @@ -28,52 +32,61 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * Partially update a project_score object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ class ProjectScoreUpdateParams -constructor( +private constructor( private val projectScoreId: String, - private val categories: Categories?, - private val config: ProjectScoreConfig?, - private val description: String?, - private val name: String?, - private val scoreType: ScoreType?, + private val body: ProjectScoreUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** ProjectScore id */ fun projectScoreId(): String = projectScoreId - fun categories(): Optional = Optional.ofNullable(categories) + /** For categorical-type project scores, the list of all categories */ + fun categories(): Optional = body.categories() - fun config(): Optional = Optional.ofNullable(config) + fun config(): Optional = body.config() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the project score */ + fun description(): Optional = body.description() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the project score */ + fun name(): Optional = body.name() - fun scoreType(): Optional = Optional.ofNullable(scoreType) + /** The type of the configured score */ + fun scoreType(): Optional = body.scoreType() + + /** For categorical-type project scores, the list of all categories */ + fun _categories(): JsonField = body._categories() + + fun _config(): JsonField = body._config() + + /** Textual description of the project score */ + fun _description(): JsonField = body._description() + + /** Name of the project score */ + fun _name(): JsonField = body._name() + + /** The type of the configured score */ + fun _scoreType(): JsonField = body._scoreType() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectScoreUpdateBody { - return ProjectScoreUpdateBody( - categories, - config, - description, - name, - scoreType, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ProjectScoreUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -83,36 +96,88 @@ constructor( } /** A project score is a user-configured score, which can be manually-labeled through the UI */ - @JsonDeserialize(builder = ProjectScoreUpdateBody.Builder::class) @NoAutoDetect class ProjectScoreUpdateBody + @JsonCreator internal constructor( - private val categories: Categories?, - private val config: ProjectScoreConfig?, - private val description: String?, - private val name: String?, - private val scoreType: ScoreType?, - private val additionalProperties: Map, + @JsonProperty("categories") + @ExcludeMissing + private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("score_type") + @ExcludeMissing + private val scoreType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** For categorical-type project scores, the list of all categories */ - @JsonProperty("categories") fun categories(): Categories? = categories + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) - @JsonProperty("config") fun config(): ProjectScoreConfig? = config + fun config(): Optional = + Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ - @JsonProperty("name") fun name(): String? = name + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + fun scoreType(): Optional = + Optional.ofNullable(scoreType.getNullable("score_type")) + + /** For categorical-type project scores, the list of all categories */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField = categories + + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField = config + + /** Textual description of the project score */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** Name of the project score */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The type of the configured score */ + @JsonProperty("score_type") + @ExcludeMissing + fun _scoreType(): JsonField = scoreType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectScoreUpdateBody = apply { + if (validated) { + return@apply + } + + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + name() + scoreType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -120,57 +185,104 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectScoreUpdateBody]. */ + class Builder internal constructor() { - private var categories: Categories? = null - private var config: ProjectScoreConfig? = null - private var description: String? = null - private var name: String? = null - private var scoreType: ScoreType? = null + private var categories: JsonField = JsonMissing.of() + 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 additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreUpdateBody: ProjectScoreUpdateBody) = apply { - this.categories = projectScoreUpdateBody.categories - this.config = projectScoreUpdateBody.config - this.description = projectScoreUpdateBody.description - this.name = projectScoreUpdateBody.name - this.scoreType = projectScoreUpdateBody.scoreType - additionalProperties(projectScoreUpdateBody.additionalProperties) + categories = projectScoreUpdateBody.categories + config = projectScoreUpdateBody.config + description = projectScoreUpdateBody.description + name = projectScoreUpdateBody.name + scoreType = projectScoreUpdateBody.scoreType + additionalProperties = projectScoreUpdateBody.additionalProperties.toMutableMap() + } + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Categories) = categories(JsonField.of(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: JsonField) = apply { + this.categories = categories } /** For categorical-type project scores, the list of all categories */ - @JsonProperty("categories") - fun categories(categories: Categories) = apply { this.categories = categories } + fun categoriesOfCategorical(categorical: List) = + categories(Categories.ofCategorical(categorical)) + + /** For weighted-type project scores, the weights of each score */ + fun categories(weighted: Categories.Weighted) = + categories(Categories.ofWeighted(weighted)) + + /** For minimum-type project scores, the list of included scores */ + fun categoriesOfMinimum(minimum: List) = + categories(Categories.ofMinimum(minimum)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(nullableVariant: Categories.NullableVariant) = + categories(Categories.ofNullableVariant(nullableVariant)) + + fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) + + fun config(config: Optional) = config(config.orElse(null)) + + fun config(config: JsonField) = apply { this.config = config } + + /** Textual description of the project score */ + fun description(description: String?) = description(JsonField.ofNullable(description)) - @JsonProperty("config") - fun config(config: ProjectScoreConfig) = apply { this.config = config } + /** Textual description of the project score */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the project score */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } + + /** Name of the project score */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the project score */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the project score */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + /** The type of the configured score */ + fun scoreType(scoreType: ScoreType?) = scoreType(JsonField.ofNullable(scoreType)) /** The type of the configured score */ - @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: Optional) = scoreType(scoreType.orElse(null)) + + /** The type of the configured score */ + fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectScoreUpdateBody = ProjectScoreUpdateBody( categories, @@ -207,69 +319,99 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectScoreUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectScoreId: String? = null - private var categories: Categories? = null - private var config: ProjectScoreConfig? = null - private var description: String? = null - private var name: String? = null - private var scoreType: ScoreType? = null + private var body: ProjectScoreUpdateBody.Builder = ProjectScoreUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectScoreUpdateParams: ProjectScoreUpdateParams) = apply { projectScoreId = projectScoreUpdateParams.projectScoreId - categories = projectScoreUpdateParams.categories - config = projectScoreUpdateParams.config - description = projectScoreUpdateParams.description - name = projectScoreUpdateParams.name - scoreType = projectScoreUpdateParams.scoreType + body = projectScoreUpdateParams.body.toBuilder() additionalHeaders = projectScoreUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = projectScoreUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectScoreUpdateParams.additionalBodyProperties.toMutableMap() } /** ProjectScore id */ fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { this.categories = categories } + fun categories(categories: Categories) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - this.categories = Categories.ofCategorical(categorical) - } + fun categories(categories: JsonField) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categories(weighted: Categories.Weighted) = apply { - this.categories = Categories.ofWeighted(weighted) + fun categoriesOfCategorical(categorical: List) = apply { + body.categoriesOfCategorical(categorical) } - /** For categorical-type project scores, the list of all categories */ - fun categoriesOfMinimum(minimum: List) = apply { - this.categories = Categories.ofMinimum(minimum) - } + /** For weighted-type project scores, the weights of each score */ + fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + + /** For minimum-type project scores, the list of included scores */ + fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } /** For categorical-type project scores, the list of all categories */ fun categories(nullableVariant: Categories.NullableVariant) = apply { - this.categories = Categories.ofNullableVariant(nullableVariant) + body.categories(nullableVariant) } - fun config(config: ProjectScoreConfig) = apply { this.config = config } + fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + + fun config(config: Optional) = config(config.orElse(null)) + + fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the project score */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project score */ + fun description(description: JsonField) = apply { body.description(description) } + + /** Name of the project score */ + fun name(name: String?) = apply { body.name(name) } + + /** Name of the project score */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the project score */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { body.name(name) } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType?) = apply { body.scoreType(scoreType) } + + /** The type of the configured score */ + fun scoreType(scoreType: Optional) = scoreType(scoreType.orElse(null)) + + /** The type of the configured score */ + fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -369,42 +511,16 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectScoreUpdateParams = ProjectScoreUpdateParams( - checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - categories, - config, - description, - name, - scoreType, + checkRequired("projectScoreId", projectScoreId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) class Categories @@ -416,12 +532,12 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** For categorical-type project scores, the list of all categories */ fun categorical(): Optional> = Optional.ofNullable(categorical) + /** For weighted-type project scores, the weights of each score */ fun weighted(): Optional = Optional.ofNullable(weighted) + /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) @@ -435,10 +551,13 @@ constructor( fun isNullableVariant(): Boolean = nullableVariant != null + /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") + /** For weighted-type project scores, the weights of each score */ fun asWeighted(): Weighted = weighted.getOrThrow("weighted") + /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") @@ -455,21 +574,31 @@ constructor( } } + private var validated: Boolean = false + fun validate(): Categories = apply { - if (!validated) { - if ( - categorical == null && - weighted == null && - minimum == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - categorical?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitCategorical(categorical: List) { + categorical.forEach { it.validate() } + } + + override fun visitWeighted(weighted: Weighted) { + weighted.validate() + } + + override fun visitMinimum(minimum: List) {} + + override fun visitNullableVariant(nullableVariant: NullableVariant) { + nullableVariant.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -494,12 +623,15 @@ constructor( companion object { + /** For categorical-type project scores, the list of all categories */ @JvmStatic fun ofCategorical(categorical: List) = Categories(categorical = categorical) + /** For weighted-type project scores, the weights of each score */ @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic @@ -507,22 +639,38 @@ constructor( Categories(nullableVariant = nullableVariant) } + /** + * An interface that defines how to map each variant of [Categories] to a value of type [T]. + */ interface Visitor { + /** For categorical-type project scores, the list of all categories */ fun visitCategorical(categorical: List): T + /** For weighted-type project scores, the weights of each score */ fun visitWeighted(weighted: Weighted): T + /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T fun visitNullableVariant(nullableVariant: NullableVariant): T + /** + * Maps an unknown variant of [Categories] to a value of type [T]. + * + * An instance of [Categories] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Categories: $json") } } - class Deserializer : BaseDeserializer(Categories::class) { + internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { val json = JsonValue.fromJsonNode(node) @@ -549,7 +697,7 @@ constructor( } } - class Serializer : BaseSerializer(Categories::class) { + internal class Serializer : BaseSerializer(Categories::class) { override fun serialize( value: Categories, @@ -568,23 +716,26 @@ constructor( } /** For weighted-type project scores, the weights of each score */ - @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect class Weighted + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Weighted = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -594,23 +745,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Weighted]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(weighted: Weighted) = apply { - additionalProperties(weighted.additionalProperties) + additionalProperties = weighted.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -618,6 +769,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } @@ -638,23 +797,26 @@ constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect class NullableVariant + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): NullableVariant = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -664,23 +826,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [NullableVariant]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) + additionalProperties = nullableVariant.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -688,6 +850,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } @@ -709,43 +879,41 @@ 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 - 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() - companion object { - @JvmField val SLIDER = ScoreType(JsonField.of("slider")) + @JvmField val SLIDER = of("slider") - @JvmField val CATEGORICAL = ScoreType(JsonField.of("categorical")) + @JvmField val CATEGORICAL = of("categorical") - @JvmField val WEIGHTED = ScoreType(JsonField.of("weighted")) + @JvmField val WEIGHTED = of("weighted") - @JvmField val MINIMUM = ScoreType(JsonField.of("minimum")) + @JvmField val MINIMUM = of("minimum") - @JvmField val MAXIMUM = ScoreType(JsonField.of("maximum")) + @JvmField val MAXIMUM = of("maximum") - @JvmField val ONLINE = ScoreType(JsonField.of("online")) + @JvmField val ONLINE = of("online") @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } + /** An enum containing [ScoreType]'s known values. */ enum class Known { SLIDER, CATEGORICAL, @@ -755,6 +923,15 @@ constructor( ONLINE, } + /** + * 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, @@ -762,9 +939,19 @@ constructor( MINIMUM, MAXIMUM, ONLINE, + /** + * 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 @@ -776,6 +963,15 @@ constructor( 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 @@ -788,6 +984,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -795,11 +1003,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, categories, config, description, name, scoreType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index 63d9c02a..949f7a97 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -7,40 +7,47 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ProjectSettings.Builder::class) @NoAutoDetect class ProjectSettings +@JsonCreator private constructor( - private val comparisonKey: JsonField, - private val additionalProperties: Map, + @JsonProperty("comparison_key") + @ExcludeMissing + private val comparisonKey: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** The key used to join two experiments (defaults to `input`). */ fun comparisonKey(): Optional = Optional.ofNullable(comparisonKey.getNullable("comparison_key")) /** The key used to join two experiments (defaults to `input`). */ - @JsonProperty("comparison_key") @ExcludeMissing fun _comparisonKey() = comparisonKey + @JsonProperty("comparison_key") + @ExcludeMissing + fun _comparisonKey(): JsonField = comparisonKey @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectSettings = apply { - if (!validated) { - comparisonKey() - validated = true + if (validated) { + return@apply } + + comparisonKey() + validated = true } fun toBuilder() = Builder().from(this) @@ -50,41 +57,50 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectSettings]. */ + class Builder internal constructor() { private var comparisonKey: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectSettings: ProjectSettings) = apply { - this.comparisonKey = projectSettings.comparisonKey - additionalProperties(projectSettings.additionalProperties) + comparisonKey = projectSettings.comparisonKey + additionalProperties = projectSettings.additionalProperties.toMutableMap() } /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: String) = comparisonKey(JsonField.of(comparisonKey)) + fun comparisonKey(comparisonKey: String?) = + comparisonKey(JsonField.ofNullable(comparisonKey)) + + /** The key used to join two experiments (defaults to `input`). */ + fun comparisonKey(comparisonKey: Optional) = + comparisonKey(comparisonKey.orElse(null)) /** The key used to join two experiments (defaults to `input`). */ - @JsonProperty("comparison_key") - @ExcludeMissing fun comparisonKey(comparisonKey: JsonField) = apply { this.comparisonKey = comparisonKey } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectSettings = ProjectSettings(comparisonKey, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 257b71ec..687292bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -7,11 +7,13 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -20,78 +22,88 @@ import java.util.Optional * A project tag is a user-configured tag for tracking and filtering your experiments, logs, and * other data */ -@JsonDeserialize(builder = ProjectTag.Builder::class) @NoAutoDetect class ProjectTag +@JsonCreator private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val color: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the project tag */ fun id(): String = id.getRequired("id") + /** Name of the project tag */ + fun name(): String = name.getRequired("name") + /** Unique identifier for the project that the project tag belongs under */ fun projectId(): String = projectId.getRequired("project_id") fun userId(): String = userId.getRequired("user_id") + /** Color of the tag for the UI */ + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) + /** Date of project tag creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Name of the project tag */ - fun name(): String = name.getRequired("name") - /** Textual description of the project tag */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Color of the tag for the UI */ - fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - /** Unique identifier for the project tag */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** Name of the project tag */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - /** Date of project tag creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + /** Color of the tag for the UI */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + /** Date of project tag creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Textual description of the project tag */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color() = color + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ProjectTag = apply { - if (!validated) { - id() - projectId() - userId() - created() - name() - description() - color() - validated = true + if (validated) { + return@apply } + + id() + name() + projectId() + userId() + color() + created() + description() + validated = true } fun toBuilder() = Builder().from(this) @@ -101,104 +113,107 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectTag]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var userId: JsonField? = null + private var color: JsonField = JsonMissing.of() private var created: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var color: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectTag: ProjectTag) = apply { - this.id = projectTag.id - this.projectId = projectTag.projectId - this.userId = projectTag.userId - this.created = projectTag.created - this.name = projectTag.name - this.description = projectTag.description - this.color = projectTag.color - additionalProperties(projectTag.additionalProperties) + id = projectTag.id + name = projectTag.name + projectId = projectTag.projectId + userId = projectTag.userId + color = projectTag.color + created = projectTag.created + description = projectTag.description + additionalProperties = projectTag.additionalProperties.toMutableMap() } /** Unique identifier for the project tag */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project tag */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } + + /** Name of the project tag */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project tag */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - @ExcludeMissing fun projectId(projectId: JsonField) = apply { this.projectId = projectId } fun userId(userId: String) = userId(JsonField.of(userId)) - @JsonProperty("user_id") - @ExcludeMissing fun userId(userId: JsonField) = apply { this.userId = userId } + /** Color of the tag for the UI */ + fun color(color: String?) = color(JsonField.ofNullable(color)) + + /** Color of the tag for the UI */ + fun color(color: Optional) = color(color.orElse(null)) + + /** Color of the tag for the UI */ + fun color(color: JsonField) = apply { this.color = color } + /** Date of project tag creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of project tag creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: Optional) = created(created.orElse(null)) - /** Name of the project tag */ - fun name(name: String) = name(JsonField.of(name)) + /** Date of project tag creation */ + fun created(created: JsonField) = apply { this.created = created } - /** Name of the project tag */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Textual description of the project tag */ + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project tag */ - fun description(description: String) = description(JsonField.of(description)) + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the project tag */ - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } - /** Color of the tag for the UI */ - fun color(color: String) = color(JsonField.of(color)) - - /** Color of the tag for the UI */ - @JsonProperty("color") - @ExcludeMissing - fun color(color: JsonField) = apply { this.color = color } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectTag = ProjectTag( - id, - projectId, - userId, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("userId", userId), + color, created, - name, description, - color, additionalProperties.toImmutable(), ) } @@ -208,15 +223,15 @@ private constructor( return true } - return /* spotless:off */ other is ProjectTag && id == other.id && projectId == other.projectId && userId == other.userId && created == other.created && name == other.name && description == other.description && color == other.color && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTag && id == other.id && name == other.name && projectId == other.projectId && userId == other.userId && color == other.color && created == other.created && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, userId, created, name, description, color, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, projectId, userId, color, created, description, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectTag{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" + "ProjectTag{id=$id, name=$name, projectId=$projectId, userId=$userId, color=$color, created=$created, description=$description, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index a73ba12f..d61f3934 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -3,86 +3,135 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new project_tag. If there is an existing project_tag in the project with the same name + * as the one specified in the request, will return the existing project_tag unmodified + */ class ProjectTagCreateParams -constructor( - private val name: String, - private val projectId: String, - private val color: String?, - private val description: String?, +private constructor( + private val body: ProjectTagCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the project tag */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the project tag belongs under */ + fun projectId(): String = body.projectId() - fun color(): Optional = Optional.ofNullable(color) + /** Color of the tag for the UI */ + fun color(): Optional = body.color() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the project tag */ + fun description(): Optional = body.description() + + /** Name of the project tag */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the project tag belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** Color of the tag for the UI */ + fun _color(): JsonField = body._color() + + /** Textual description of the project tag */ + fun _description(): JsonField = body._description() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectTagCreateBody { - return ProjectTagCreateBody( - name, - projectId, - color, - description, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ProjectTagCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = ProjectTagCreateBody.Builder::class) @NoAutoDetect class ProjectTagCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val color: String?, - private val description: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project tag */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + fun projectId(): String = projectId.getRequired("project_id") /** Color of the tag for the UI */ - @JsonProperty("color") fun color(): String? = color + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the project tag */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Unique identifier for the project that the project tag belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** Color of the tag for the UI */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** Textual description of the project tag */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectTagCreateBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + color() + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -90,55 +139,79 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectTagCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var color: String? = null - private var description: String? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectTagCreateBody: ProjectTagCreateBody) = apply { - this.name = projectTagCreateBody.name - this.projectId = projectTagCreateBody.projectId - this.color = projectTagCreateBody.color - this.description = projectTagCreateBody.description - additionalProperties(projectTagCreateBody.additionalProperties) + name = projectTagCreateBody.name + projectId = projectTagCreateBody.projectId + color = projectTagCreateBody.color + description = projectTagCreateBody.description + additionalProperties = projectTagCreateBody.additionalProperties.toMutableMap() } /** Name of the project tag */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project tag */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the project tag belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Color of the tag for the UI */ + fun color(color: String?) = color(JsonField.ofNullable(color)) + + /** Color of the tag for the UI */ + fun color(color: Optional) = color(color.orElse(null)) /** Color of the tag for the UI */ - @JsonProperty("color") fun color(color: String) = apply { this.color = color } + fun color(color: JsonField) = apply { this.color = color } + + /** Textual description of the project tag */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the project tag */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the project tag */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectTagCreateBody = ProjectTagCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), color, description, additionalProperties.toImmutable(), @@ -170,40 +243,69 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectTagCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var color: String? = null - private var description: String? = null + private var body: ProjectTagCreateBody.Builder = ProjectTagCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectTagCreateParams: ProjectTagCreateParams) = apply { - name = projectTagCreateParams.name - projectId = projectTagCreateParams.projectId - color = projectTagCreateParams.color - description = projectTagCreateParams.description + body = projectTagCreateParams.body.toBuilder() additionalHeaders = projectTagCreateParams.additionalHeaders.toBuilder() additionalQueryParams = projectTagCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectTagCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the project tag */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the project tag */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the project tag belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + + /** Color of the tag for the UI */ + fun color(color: String?) = apply { body.color(color) } /** Color of the tag for the UI */ - fun color(color: String) = apply { this.color = color } + fun color(color: Optional) = color(color.orElse(null)) + + /** Color of the tag for the UI */ + fun color(color: JsonField) = apply { body.color(color) } /** Textual description of the project tag */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the project tag */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project tag */ + fun description(description: JsonField) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -303,37 +405,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectTagCreateParams = ProjectTagCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - color, - description, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -342,11 +418,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagCreateParams && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectTagCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 8cc4cbd5..b9463ba3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a project_tag object by its id */ class ProjectTagDeleteParams -constructor( +private constructor( private val projectTagId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** ProjectTag id */ fun projectTagId(): String = projectTagId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectTagDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectTagId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -192,7 +195,7 @@ constructor( fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( - checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, + checkRequired("projectTagId", projectTagId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index e32a9436..29cc199a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.ProjectTagService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first + */ class ProjectTagListPage private constructor( private val projectTagsService: ProjectTagService, @@ -89,16 +94,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -108,11 +113,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -148,10 +157,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -160,8 +167,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ProjectTagListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 822a3261..3cb31a0b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.ProjectTagServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first + */ class ProjectTagListPageAsync private constructor( private val projectTagsService: ProjectTagServiceAsync, @@ -92,16 +97,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +116,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +160,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +170,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ProjectTagListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index b5f6307e..872ca35b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first + */ class ProjectTagListParams -constructor( +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -33,32 +37,54 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Project id */ fun projectId(): Optional = Optional.ofNullable(projectId) + /** Name of the project to search for */ fun projectName(): Optional = Optional.ofNullable(projectName) + /** Name of the project_tag to search for */ fun projectTagName(): Optional = Optional.ofNullable(projectTagName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.ids?.let { queryParams.put("ids", listOf(it.toString())) } @@ -79,8 +105,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectTagListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var ids: Ids? = null @@ -114,40 +141,75 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = ids(Ids.ofString(string)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + + /** Filter search results to within a particular organization */ + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = apply { this.projectId = projectId } + + /** Project id */ + fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = apply { this.projectName = projectName } + + /** Name of the project to search for */ + fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + + /** Name of the project_tag to search for */ + fun projectTagName(projectTagName: String?) = apply { this.projectTagName = projectTagName } /** Name of the project_tag to search for */ - fun projectTagName(projectTagName: String) = apply { this.projectTagName = projectTagName } + fun projectTagName(projectTagName: Optional) = + projectTagName(projectTagName.orElse(null)) /** * Pagination cursor id. @@ -156,7 +218,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -271,6 +343,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -280,8 +356,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -304,15 +378,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -338,18 +403,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -365,7 +440,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index e8744dfe..13336fc8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -3,86 +3,136 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create or replace project_tag. If there is an existing project_tag in the project with the same + * name as the one specified in the request, will replace the existing project_tag with the provided + * fields + */ class ProjectTagReplaceParams -constructor( - private val name: String, - private val projectId: String, - private val color: String?, - private val description: String?, +private constructor( + private val body: ProjectTagReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the project tag */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the project tag belongs under */ + fun projectId(): String = body.projectId() - fun color(): Optional = Optional.ofNullable(color) + /** Color of the tag for the UI */ + fun color(): Optional = body.color() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the project tag */ + fun description(): Optional = body.description() + + /** Name of the project tag */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the project tag belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** Color of the tag for the UI */ + fun _color(): JsonField = body._color() + + /** Textual description of the project tag */ + fun _description(): JsonField = body._description() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectTagReplaceBody { - return ProjectTagReplaceBody( - name, - projectId, - color, - description, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ProjectTagReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = ProjectTagReplaceBody.Builder::class) @NoAutoDetect class ProjectTagReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val color: String?, - private val description: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project tag */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + fun projectId(): String = projectId.getRequired("project_id") /** Color of the tag for the UI */ - @JsonProperty("color") fun color(): String? = color + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the project tag */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Unique identifier for the project that the project tag belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** Color of the tag for the UI */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** Textual description of the project tag */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectTagReplaceBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + color() + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -90,55 +140,79 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectTagReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var color: String? = null - private var description: String? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectTagReplaceBody: ProjectTagReplaceBody) = apply { - this.name = projectTagReplaceBody.name - this.projectId = projectTagReplaceBody.projectId - this.color = projectTagReplaceBody.color - this.description = projectTagReplaceBody.description - additionalProperties(projectTagReplaceBody.additionalProperties) + name = projectTagReplaceBody.name + projectId = projectTagReplaceBody.projectId + color = projectTagReplaceBody.color + description = projectTagReplaceBody.description + additionalProperties = projectTagReplaceBody.additionalProperties.toMutableMap() } /** Name of the project tag */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the project tag */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the project tag belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Color of the tag for the UI */ + fun color(color: String?) = color(JsonField.ofNullable(color)) + + /** Color of the tag for the UI */ + fun color(color: Optional) = color(color.orElse(null)) /** Color of the tag for the UI */ - @JsonProperty("color") fun color(color: String) = apply { this.color = color } + fun color(color: JsonField) = apply { this.color = color } + + /** Textual description of the project tag */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the project tag */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the project tag */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectTagReplaceBody = ProjectTagReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), color, description, additionalProperties.toImmutable(), @@ -170,40 +244,69 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectTagReplaceParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var color: String? = null - private var description: String? = null + private var body: ProjectTagReplaceBody.Builder = ProjectTagReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectTagReplaceParams: ProjectTagReplaceParams) = apply { - name = projectTagReplaceParams.name - projectId = projectTagReplaceParams.projectId - color = projectTagReplaceParams.color - description = projectTagReplaceParams.description + body = projectTagReplaceParams.body.toBuilder() additionalHeaders = projectTagReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = projectTagReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectTagReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the project tag */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the project tag */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the project tag belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + + /** Color of the tag for the UI */ + fun color(color: String?) = apply { body.color(color) } /** Color of the tag for the UI */ - fun color(color: String) = apply { this.color = color } + fun color(color: Optional) = color(color.orElse(null)) + + /** Color of the tag for the UI */ + fun color(color: JsonField) = apply { body.color(color) } /** Textual description of the project tag */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the project tag */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project tag */ + fun description(description: JsonField) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -303,37 +406,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectTagReplaceParams = ProjectTagReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - color, - description, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -342,11 +419,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagReplaceParams && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, color, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectTagReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 4bdda4c7..55c68bdd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a project_tag object by its id */ class ProjectTagRetrieveParams -constructor( +private constructor( private val projectTagId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** ProjectTag id */ fun projectTagId(): String = projectTagId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectTagRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectTagId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( - checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, + checkRequired("projectTagId", projectTagId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 821a2c38..99621883 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -3,57 +3,68 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update a project_tag object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ class ProjectTagUpdateParams -constructor( +private constructor( private val projectTagId: String, - private val color: String?, - private val description: String?, - private val name: String?, + private val body: ProjectTagUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** ProjectTag id */ fun projectTagId(): String = projectTagId - fun color(): Optional = Optional.ofNullable(color) + /** Color of the tag for the UI */ + fun color(): Optional = body.color() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the project tag */ + fun description(): Optional = body.description() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the project tag */ + fun name(): Optional = body.name() + + /** Color of the tag for the UI */ + fun _color(): JsonField = body._color() + + /** Textual description of the project tag */ + fun _description(): JsonField = body._description() + + /** Name of the project tag */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectTagUpdateBody { - return ProjectTagUpdateBody( - color, - description, - name, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ProjectTagUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -62,29 +73,61 @@ constructor( } } - @JsonDeserialize(builder = ProjectTagUpdateBody.Builder::class) @NoAutoDetect class ProjectTagUpdateBody + @JsonCreator internal constructor( - private val color: String?, - private val description: String?, - private val name: String?, - private val additionalProperties: Map, + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Color of the tag for the UI */ - @JsonProperty("color") fun color(): String? = color + fun color(): Optional = Optional.ofNullable(color.getNullable("color")) + + /** Textual description of the project tag */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the project tag */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Color of the tag for the UI */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color /** Textual description of the project tag */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** Name of the project tag */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectTagUpdateBody = apply { + if (validated) { + return@apply + } + + color() + description() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -92,45 +135,70 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectTagUpdateBody]. */ + class Builder internal constructor() { - private var color: String? = null - private var description: String? = null - private var name: String? = null + private var color: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectTagUpdateBody: ProjectTagUpdateBody) = apply { - this.color = projectTagUpdateBody.color - this.description = projectTagUpdateBody.description - this.name = projectTagUpdateBody.name - additionalProperties(projectTagUpdateBody.additionalProperties) + color = projectTagUpdateBody.color + description = projectTagUpdateBody.description + name = projectTagUpdateBody.name + additionalProperties = projectTagUpdateBody.additionalProperties.toMutableMap() } /** Color of the tag for the UI */ - @JsonProperty("color") fun color(color: String) = apply { this.color = color } + fun color(color: String?) = color(JsonField.ofNullable(color)) + + /** Color of the tag for the UI */ + fun color(color: Optional) = color(color.orElse(null)) + + /** Color of the tag for the UI */ + fun color(color: JsonField) = apply { this.color = color } /** Textual description of the project tag */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the project tag */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the project tag */ + fun description(description: JsonField) = apply { + this.description = description + } /** Name of the project tag */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the project tag */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the project tag */ + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectTagUpdateBody = ProjectTagUpdateBody( color, @@ -165,40 +233,71 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectTagUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectTagId: String? = null - private var color: String? = null - private var description: String? = null - private var name: String? = null + private var body: ProjectTagUpdateBody.Builder = ProjectTagUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectTagUpdateParams: ProjectTagUpdateParams) = apply { projectTagId = projectTagUpdateParams.projectTagId - color = projectTagUpdateParams.color - description = projectTagUpdateParams.description - name = projectTagUpdateParams.name + body = projectTagUpdateParams.body.toBuilder() additionalHeaders = projectTagUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = projectTagUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectTagUpdateParams.additionalBodyProperties.toMutableMap() } /** ProjectTag id */ fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } /** Color of the tag for the UI */ - fun color(color: String) = apply { this.color = color } + fun color(color: String?) = apply { body.color(color) } + + /** Color of the tag for the UI */ + fun color(color: Optional) = color(color.orElse(null)) + + /** Color of the tag for the UI */ + fun color(color: JsonField) = apply { body.color(color) } + + /** Textual description of the project tag */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the project tag */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the project tag */ - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { body.description(description) } + + /** Name of the project tag */ + fun name(name: String?) = apply { body.name(name) } + + /** Name of the project tag */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the project tag */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -298,37 +397,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectTagUpdateParams = ProjectTagUpdateParams( - checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - color, - description, - name, + checkRequired("projectTagId", projectTagId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -337,11 +411,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && color == other.color && description == other.description && name == other.name && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, color, description, name, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectTagUpdateParams{projectTagId=$projectTagId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index b4d4b463..0114bd24 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -3,53 +3,68 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update a project object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. + */ class ProjectUpdateParams -constructor( +private constructor( private val projectId: String, - private val name: String?, - private val settings: ProjectSettings?, + private val body: ProjectUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Project id */ fun projectId(): String = projectId - fun name(): Optional = Optional.ofNullable(name) + /** Name of the project */ + fun name(): Optional = body.name() - fun settings(): Optional = Optional.ofNullable(settings) + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + fun settings(): Optional = body.settings() + + /** Name of the project */ + fun _name(): JsonField = body._name() + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + fun _settings(): JsonField = body._settings() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun _body(): ProjectUpdateBody = body - @JvmSynthetic - internal fun getBody(): ProjectUpdateBody { - return ProjectUpdateBody( - name, - settings, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -58,28 +73,57 @@ constructor( } } - @JsonDeserialize(builder = ProjectUpdateBody.Builder::class) @NoAutoDetect class ProjectUpdateBody + @JsonCreator internal constructor( - private val name: String?, - private val settings: ProjectSettings?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("settings") + @ExcludeMissing + private val settings: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project */ - @JsonProperty("name") fun name(): String? = name + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** * Project settings. Patch operations replace all settings, so make sure you include all * settings you want to keep. */ - @JsonProperty("settings") fun settings(): ProjectSettings? = settings + fun settings(): Optional = + Optional.ofNullable(settings.getNullable("settings")) + + /** Name of the project */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + @JsonProperty("settings") + @ExcludeMissing + fun _settings(): JsonField = settings @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ProjectUpdateBody = apply { + if (validated) { + return@apply + } + + name() + settings().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -87,43 +131,66 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ProjectUpdateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var settings: ProjectSettings? = null + private var name: JsonField = JsonMissing.of() + private var settings: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectUpdateBody: ProjectUpdateBody) = apply { - this.name = projectUpdateBody.name - this.settings = projectUpdateBody.settings - additionalProperties(projectUpdateBody.additionalProperties) + name = projectUpdateBody.name + settings = projectUpdateBody.settings + additionalProperties = projectUpdateBody.additionalProperties.toMutableMap() } /** Name of the project */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the project */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the project */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + fun settings(settings: Optional) = settings(settings.orElse(null)) /** * Project settings. Patch operations replace all settings, so make sure you include all * settings you want to keep. */ - @JsonProperty("settings") - fun settings(settings: ProjectSettings) = apply { this.settings = settings } + fun settings(settings: JsonField) = apply { this.settings = settings } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ProjectUpdateBody = ProjectUpdateBody( name, @@ -157,37 +224,71 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProjectUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var projectId: String? = null - private var name: String? = null - private var settings: ProjectSettings? = null + private var body: ProjectUpdateBody.Builder = ProjectUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectUpdateParams: ProjectUpdateParams) = apply { projectId = projectUpdateParams.projectId - name = projectUpdateParams.name - settings = projectUpdateParams.settings + body = projectUpdateParams.body.toBuilder() additionalHeaders = projectUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = projectUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = projectUpdateParams.additionalBodyProperties.toMutableMap() } /** Project id */ fun projectId(projectId: String) = apply { this.projectId = projectId } /** Name of the project */ - fun name(name: String) = apply { this.name = name } + fun name(name: String?) = apply { body.name(name) } + + /** Name of the project */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the project */ + fun name(name: JsonField) = apply { body.name(name) } + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + fun settings(settings: ProjectSettings?) = apply { body.settings(settings) } + + /** + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. + */ + fun settings(settings: Optional) = settings(settings.orElse(null)) /** * Project settings. Patch operations replace all settings, so make sure you include all * settings you want to keep. */ - fun settings(settings: ProjectSettings) = apply { this.settings = settings } + fun settings(settings: JsonField) = apply { body.settings(settings) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -287,36 +388,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ProjectUpdateParams = ProjectUpdateParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - name, - settings, + checkRequired("projectId", projectId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -325,11 +402,11 @@ constructor( return true } - return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && name == other.name && settings == other.settings && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, name, settings, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ProjectUpdateParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 6f591005..55622506 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -8,39 +8,54 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect class Prompt +@JsonCreator private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val functionType: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") @@ -51,27 +66,33 @@ private constructor( */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - /** A literal 'p' which identifies the object as a project prompt */ fun logId(): LogId = logId.getRequired("log_id") + /** Name of the prompt */ + fun name(): String = name.getRequired("name") + /** Unique identifier for the organization */ fun orgId(): String = orgId.getRequired("org_id") - /** Name of the prompt */ - fun name(): String = name.getRequired("name") + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = projectId.getRequired("project_id") /** Unique identifier for the prompt */ fun slug(): String = slug.getRequired("slug") + /** Date of prompt creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** Textual description of the prompt */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Date of prompt creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) + + /** User-controlled metadata about the prompt */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The prompt, model, and its parameters */ fun promptData(): Optional = @@ -80,75 +101,77 @@ private constructor( /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** User-controlled metadata about the prompt */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) - /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the prompt (see the `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId + + /** Name of the prompt */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + /** Unique identifier for the project that the prompt belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData + /** Textual description of the prompt */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("function_type") + @ExcludeMissing + fun _functionType(): JsonField = functionType /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("function_type") @ExcludeMissing fun _functionType() = functionType + /** The prompt, model, and its parameters */ + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData(): JsonField = promptData + + /** A list of tags for the prompt */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Prompt = apply { - if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData().map { it.validate() } - tags() - metadata().map { it.validate() } - functionType() - validated = true + if (validated) { + return@apply } + + id() + _xactId() + logId() + name() + orgId() + projectId() + slug() + created() + description() + functionType() + metadata().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true } fun toBuilder() = Builder().from(this) @@ -158,46 +181,47 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Prompt]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var logId: JsonField? = null + private var name: JsonField? = null + private var orgId: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null private var created: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() private var functionType: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(prompt: Prompt) = apply { - this.id = prompt.id - this._xactId = prompt._xactId - this.projectId = prompt.projectId - this.logId = prompt.logId - this.orgId = prompt.orgId - this.name = prompt.name - this.slug = prompt.slug - this.description = prompt.description - this.created = prompt.created - this.promptData = prompt.promptData - this.tags = prompt.tags - this.metadata = prompt.metadata - this.functionType = prompt.functionType - additionalProperties(prompt.additionalProperties) + id = prompt.id + _xactId = prompt._xactId + logId = prompt.logId + name = prompt.name + orgId = prompt.orgId + projectId = prompt.projectId + slug = prompt.slug + created = prompt.created + description = prompt.description + functionType = prompt.functionType + metadata = prompt.metadata + promptData = prompt.promptData + tags = prompt.tags.map { it.toMutableList() } + additionalProperties = prompt.additionalProperties.toMutableMap() } /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } /** * The transaction id of an event is unique to the network operation that processed the @@ -211,173 +235,213 @@ private constructor( * event insertion. Transaction ids are monotonically increasing over time and can be used * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing fun logId(logId: JsonField) = apply { this.logId = logId } + /** Name of the prompt */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the prompt */ + fun name(name: JsonField) = apply { this.name = name } + /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing fun slug(slug: JsonField) = apply { this.slug = slug } + /** Date of prompt creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** Date of prompt creation */ + fun created(created: Optional) = created(created.orElse(null)) + + /** Date of prompt creation */ + fun created(created: JsonField) = apply { this.created = created } + /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } - /** Date of prompt creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) + + fun functionType(functionType: JsonField) = apply { + this.functionType = functionType + } + + /** User-controlled metadata about the prompt */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** User-controlled metadata about the prompt */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + + /** User-controlled metadata about the prompt */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) + fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing fun promptData(promptData: JsonField) = apply { this.promptData = promptData } /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: Optional>) = tags(tags.orElse(null)) - /** User-controlled metadata about the prompt */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun functionType(functionType: FunctionType) = functionType(JsonField.of(functionType)) + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } - @JsonProperty("function_type") - @ExcludeMissing - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType + /** A list of tags for the prompt */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Prompt = Prompt( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("logId", logId), + checkRequired("name", name), + checkRequired("orgId", orgId), + checkRequired("projectId", projectId), + checkRequired("slug", slug), created, - promptData, - tags.map { it.toImmutable() }, - metadata, + description, functionType, + metadata, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } + /** A literal 'p' which identifies the object as a project prompt */ class LogId @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val P = LogId(JsonField.of("p")) + @JvmField val P = of("p") @JvmStatic fun of(value: String) = LogId(JsonField.of(value)) } + /** An enum containing [LogId]'s known values. */ enum class Known { P, } + /** + * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [LogId] 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 { P, + /** An enum member indicating that [LogId] 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) { P -> Value.P 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) { P -> Known.P @@ -385,41 +449,50 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() override fun toString() = value.toString() + } + + class FunctionType + @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 = FunctionType(JsonField.of("llm")) + @JvmField val LLM = of("llm") - @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val SCORER = of("scorer") - @JvmField val TASK = FunctionType(JsonField.of("task")) + @JvmField val TASK = of("task") - @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmField val TOOL = of("tool") @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } + /** An enum containing [FunctionType]'s known values. */ enum class Known { LLM, SCORER, @@ -427,14 +500,33 @@ private constructor( TOOL, } + /** + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FunctionType] 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, SCORER, TASK, TOOL, + /** + * An enum member indicating that [FunctionType] 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 @@ -444,6 +536,15 @@ private constructor( 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 @@ -454,26 +555,41 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** User-controlled metadata about the prompt */ - @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect class Metadata + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metadata = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -483,29 +599,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metadata]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -531,15 +653,15 @@ private constructor( return true } - return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && projectId == other.projectId && logId == other.logId && orgId == other.orgId && name == other.name && slug == other.slug && description == other.description && created == other.created && promptData == other.promptData && tags == other.tags && metadata == other.metadata && functionType == other.functionType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionType == other.functionType && metadata == other.metadata && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, projectId, logId, orgId, name, slug, description, created, promptData, tags, metadata, functionType, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, logId, name, orgId, projectId, slug, created, description, functionType, metadata, promptData, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, additionalProperties=$additionalProperties}" + "Prompt{id=$id, _xactId=$_xactId, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionType=$functionType, metadata=$metadata, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 8a2884de..4a7efdcb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -5,111 +5,185 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new prompt. If there is an existing prompt in the project with the same slug as the one + * specified in the request, will return the existing prompt unmodified + */ class PromptCreateParams -constructor( - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val functionType: FunctionType?, - private val promptData: PromptData?, - private val tags: List?, +private constructor( + private val body: PromptCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the prompt */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = body.projectId() - fun slug(): String = slug + /** Unique identifier for the prompt */ + fun slug(): String = body.slug() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the prompt */ + fun description(): Optional = body.description() - fun functionType(): Optional = Optional.ofNullable(functionType) + fun functionType(): Optional = body.functionType() - fun promptData(): Optional = Optional.ofNullable(promptData) + /** The prompt, model, and its parameters */ + fun promptData(): Optional = body.promptData() - fun tags(): Optional> = Optional.ofNullable(tags) + /** A list of tags for the prompt */ + fun tags(): Optional> = body.tags() + + /** Name of the prompt */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the prompt belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** Unique identifier for the prompt */ + fun _slug(): JsonField = body._slug() + + /** Textual description of the prompt */ + fun _description(): JsonField = body._description() + + fun _functionType(): JsonField = body._functionType() + + /** The prompt, model, and its parameters */ + fun _promptData(): JsonField = body._promptData() + + /** A list of tags for the prompt */ + fun _tags(): JsonField> = body._tags() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): PromptCreateBody { - return PromptCreateBody( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): PromptCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = PromptCreateBody.Builder::class) @NoAutoDetect class PromptCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val functionType: FunctionType?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Unique identifier for the prompt */ + fun slug(): String = slug.getRequired("slug") + + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** Name of the prompt */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("function_type") fun functionType(): FunctionType? = functionType + @JsonProperty("function_type") + @ExcludeMissing + fun _functionType(): JsonField = functionType /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PromptCreateBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + slug() + description() + functionType() + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -117,78 +191,133 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PromptCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var slug: String? = null - private var description: String? = null - private var functionType: FunctionType? = null - private var promptData: PromptData? = null - private var tags: List? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var functionType: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptCreateBody: PromptCreateBody) = apply { - this.name = promptCreateBody.name - this.projectId = promptCreateBody.projectId - this.slug = promptCreateBody.slug - this.description = promptCreateBody.description - this.functionType = promptCreateBody.functionType - this.promptData = promptCreateBody.promptData - this.tags = promptCreateBody.tags - additionalProperties(promptCreateBody.additionalProperties) + name = promptCreateBody.name + projectId = promptCreateBody.projectId + slug = promptCreateBody.slug + description = promptCreateBody.description + functionType = promptCreateBody.functionType + promptData = promptCreateBody.promptData + tags = promptCreateBody.tags.map { it.toMutableList() } + additionalProperties = promptCreateBody.additionalProperties.toMutableMap() } /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the prompt */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: JsonField) = apply { this.slug = slug } + + /** Textual description of the prompt */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the prompt */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } + + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - @JsonProperty("function_type") - fun functionType(functionType: FunctionType) = apply { + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) + + fun functionType(functionType: JsonField) = apply { this.functionType = functionType } /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } + + /** A list of tags for the prompt */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PromptCreateBody = PromptCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("slug", slug), description, functionType, promptData, - tags?.toImmutable(), + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -218,59 +347,96 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [PromptCreateParams]. */ @NoAutoDetect - class Builder { - - private var name: String? = null - private var projectId: String? = null - private var slug: String? = null - private var description: String? = null - private var functionType: FunctionType? = null - private var promptData: PromptData? = null - private var tags: MutableList = mutableListOf() + class Builder internal constructor() { + + private var body: PromptCreateBody.Builder = PromptCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptCreateParams: PromptCreateParams) = apply { - name = promptCreateParams.name - projectId = promptCreateParams.projectId - slug = promptCreateParams.slug - description = promptCreateParams.description - functionType = promptCreateParams.functionType - promptData = promptCreateParams.promptData - tags = promptCreateParams.tags?.toMutableList() ?: mutableListOf() + body = promptCreateParams.body.toBuilder() additionalHeaders = promptCreateParams.additionalHeaders.toBuilder() additionalQueryParams = promptCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = promptCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the prompt */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: JsonField) = apply { body.slug(slug) } + + /** Textual description of the prompt */ + fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the prompt */ + fun description(description: JsonField) = apply { body.description(description) } + + fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) - fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } + fun functionType(functionType: JsonField) = apply { + body.functionType(functionType) + } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List) = apply { - this.tags.clear() - this.tags.addAll(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -370,40 +536,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): PromptCreateParams = PromptCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - promptData, - tags.toImmutable().ifEmpty { null }, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -413,33 +550,30 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val LLM = FunctionType(JsonField.of("llm")) + @JvmField val LLM = of("llm") - @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val SCORER = of("scorer") - @JvmField val TASK = FunctionType(JsonField.of("task")) + @JvmField val TASK = of("task") - @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmField val TOOL = of("tool") @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } + /** An enum containing [FunctionType]'s known values. */ enum class Known { LLM, SCORER, @@ -447,14 +581,33 @@ constructor( TOOL, } + /** + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FunctionType] 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, SCORER, TASK, TOOL, + /** + * An enum member indicating that [FunctionType] 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 @@ -464,6 +617,15 @@ constructor( 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 @@ -474,6 +636,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -481,11 +655,11 @@ constructor( return true } - return /* spotless:off */ other is PromptCreateParams && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "PromptCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 942ab249..6ae99c99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -10,7 +10,9 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -28,54 +30,68 @@ import java.util.Objects import java.util.Optional /** The prompt, model, and its parameters */ -@JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect class PromptData +@JsonCreator private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val parser: JsonField, - private val toolFunctions: JsonField>, - private val origin: JsonField, - private val additionalProperties: Map, + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("parser") + @ExcludeMissing + private val parser: JsonField = JsonMissing.of(), + @JsonProperty("prompt") + @ExcludeMissing + private val prompt: JsonField = JsonMissing.of(), + @JsonProperty("tool_functions") + @ExcludeMissing + private val toolFunctions: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - fun options(): Optional = Optional.ofNullable(options.getNullable("options")) + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + fun parser(): Optional = Optional.ofNullable(parser.getNullable("parser")) + fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) + fun toolFunctions(): Optional> = Optional.ofNullable(toolFunctions.getNullable("tool_functions")) - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - - @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options - @JsonProperty("options") @ExcludeMissing fun _options() = options + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin - @JsonProperty("parser") @ExcludeMissing fun _parser() = parser + @JsonProperty("parser") @ExcludeMissing fun _parser(): JsonField = parser - @JsonProperty("tool_functions") @ExcludeMissing fun _toolFunctions() = toolFunctions + @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField = prompt - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + @JsonProperty("tool_functions") + @ExcludeMissing + fun _toolFunctions(): JsonField> = toolFunctions @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): PromptData = apply { - if (!validated) { - prompt() - options().map { it.validate() } - parser().map { it.validate() } - toolFunctions() - origin().map { it.validate() } - validated = true + if (validated) { + return@apply } + + options().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + parser().ifPresent { it.validate() } + prompt().ifPresent { it.validate() } + toolFunctions().ifPresent { it.forEach { it.validate() } } + validated = true } fun toBuilder() = Builder().from(this) @@ -85,119 +101,161 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PromptData]. */ + class Builder internal constructor() { - private var prompt: JsonField = JsonMissing.of() private var options: JsonField = JsonMissing.of() - private var parser: JsonField = JsonMissing.of() - private var toolFunctions: JsonField> = JsonMissing.of() private var origin: JsonField = JsonMissing.of() + private var parser: JsonField = JsonMissing.of() + private var prompt: JsonField = JsonMissing.of() + private var toolFunctions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptData: PromptData) = apply { - this.prompt = promptData.prompt - this.options = promptData.options - this.parser = promptData.parser - this.toolFunctions = promptData.toolFunctions - this.origin = promptData.origin - additionalProperties(promptData.additionalProperties) + options = promptData.options + origin = promptData.origin + parser = promptData.parser + prompt = promptData.prompt + toolFunctions = promptData.toolFunctions.map { it.toMutableList() } + additionalProperties = promptData.additionalProperties.toMutableMap() } + fun options(options: PromptOptions?) = options(JsonField.ofNullable(options)) + + fun options(options: Optional) = options(options.orElse(null)) + + fun options(options: JsonField) = apply { this.options = options } + + fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + + fun origin(origin: Optional) = origin(origin.orElse(null)) + + fun origin(origin: JsonField) = apply { this.origin = origin } + + fun parser(parser: Parser?) = parser(JsonField.ofNullable(parser)) + + fun parser(parser: Optional) = parser(parser.orElse(null)) + + fun parser(parser: JsonField) = apply { this.parser = parser } + fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - @JsonProperty("prompt") - @ExcludeMissing fun prompt(prompt: JsonField) = apply { this.prompt = prompt } - fun options(options: PromptOptions) = options(JsonField.of(options)) + fun prompt(completion: Prompt.Completion) = prompt(Prompt.ofCompletion(completion)) - @JsonProperty("options") - @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } + fun prompt(chat: Prompt.Chat) = prompt(Prompt.ofChat(chat)) - fun parser(parser: Parser) = parser(JsonField.of(parser)) + fun prompt(nullableVariant: Prompt.NullableVariant) = + prompt(Prompt.ofNullableVariant(nullableVariant)) - @JsonProperty("parser") - @ExcludeMissing - fun parser(parser: JsonField) = apply { this.parser = parser } + fun toolFunctions(toolFunctions: List?) = + toolFunctions(JsonField.ofNullable(toolFunctions)) - fun toolFunctions(toolFunctions: List) = - toolFunctions(JsonField.of(toolFunctions)) + fun toolFunctions(toolFunctions: Optional>) = + toolFunctions(toolFunctions.orElse(null)) - @JsonProperty("tool_functions") - @ExcludeMissing fun toolFunctions(toolFunctions: JsonField>) = apply { - this.toolFunctions = toolFunctions + this.toolFunctions = toolFunctions.map { it.toMutableList() } + } + + fun addToolFunction(toolFunction: ToolFunction) = apply { + toolFunctions = + (toolFunctions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(toolFunction) + } } - fun origin(origin: Origin) = origin(JsonField.of(origin)) + fun addToolFunction(function: ToolFunction.Function) = + addToolFunction(ToolFunction.ofFunction(function)) - @JsonProperty("origin") - @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } + fun addToolFunction(global: ToolFunction.Global) = + addToolFunction(ToolFunction.ofGlobal(global)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PromptData = PromptData( - prompt, options, - parser, - toolFunctions.map { it.toImmutable() }, origin, + parser, + prompt, + (toolFunctions ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect class Origin + @JsonCreator private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_id") + @ExcludeMissing + private val promptId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_version") + @ExcludeMissing + private val promptVersion: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) fun promptId(): Optional = Optional.ofNullable(promptId.getNullable("prompt_id")) - fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) - fun promptVersion(): Optional = Optional.ofNullable(promptVersion.getNullable("prompt_version")) - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("prompt_id") @ExcludeMissing fun _promptId(): JsonField = promptId - @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion + @JsonProperty("prompt_version") + @ExcludeMissing + fun _promptVersion(): JsonField = promptVersion @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Origin = apply { - if (!validated) { - promptId() - projectId() - promptVersion() - validated = true + if (validated) { + return@apply } + + projectId() + promptId() + promptVersion() + validated = true } fun toBuilder() = Builder().from(this) @@ -207,59 +265,59 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Origin]. */ + class Builder internal constructor() { - private var promptId: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var promptId: JsonField = JsonMissing.of() private var promptVersion: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(origin: Origin) = apply { - this.promptId = origin.promptId - this.projectId = origin.projectId - this.promptVersion = origin.promptVersion - additionalProperties(origin.additionalProperties) + projectId = origin.projectId + promptId = origin.promptId + promptVersion = origin.promptVersion + additionalProperties = origin.additionalProperties.toMutableMap() } - fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - - @JsonProperty("prompt_id") - @ExcludeMissing - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - @JsonProperty("project_id") - @ExcludeMissing fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun promptId(promptId: String) = promptId(JsonField.of(promptId)) + + fun promptId(promptId: JsonField) = apply { this.promptId = promptId } + fun promptVersion(promptVersion: String) = promptVersion(JsonField.of(promptVersion)) - @JsonProperty("prompt_version") - @ExcludeMissing fun promptVersion(promptVersion: JsonField) = apply { this.promptVersion = promptVersion } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Origin = Origin( - promptId, projectId, + promptId, promptVersion, additionalProperties.toImmutable(), ) @@ -270,54 +328,63 @@ private constructor( return true } - return /* spotless:off */ other is Origin && promptId == other.promptId && projectId == other.projectId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && projectId == other.projectId && promptId == other.promptId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(promptId, projectId, promptVersion, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(projectId, promptId, promptVersion, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + "Origin{projectId=$projectId, promptId=$promptId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Parser.Builder::class) @NoAutoDetect class Parser + @JsonCreator private constructor( - private val type: JsonField, - private val useCot: JsonField, - private val choiceScores: JsonField, - private val additionalProperties: Map, + @JsonProperty("choice_scores") + @ExcludeMissing + private val choiceScores: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("use_cot") + @ExcludeMissing + private val useCot: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun choiceScores(): ChoiceScores = choiceScores.getRequired("choice_scores") fun type(): Type = type.getRequired("type") fun useCot(): Boolean = useCot.getRequired("use_cot") - fun choiceScores(): ChoiceScores = choiceScores.getRequired("choice_scores") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("choice_scores") + @ExcludeMissing + fun _choiceScores(): JsonField = choiceScores - @JsonProperty("use_cot") @ExcludeMissing fun _useCot() = useCot + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("choice_scores") @ExcludeMissing fun _choiceScores() = choiceScores + @JsonProperty("use_cot") @ExcludeMissing fun _useCot(): JsonField = useCot @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Parser = apply { - if (!validated) { - type() - useCot() - choiceScores().validate() - validated = true + if (validated) { + return@apply } + + choiceScores().validate() + type() + useCot() + validated = true } fun toBuilder() = Builder().from(this) @@ -327,81 +394,84 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Parser]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var useCot: JsonField = JsonMissing.of() - private var choiceScores: JsonField = JsonMissing.of() + private var choiceScores: JsonField? = null + private var type: JsonField? = null + private var useCot: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(parser: Parser) = apply { - this.type = parser.type - this.useCot = parser.useCot - this.choiceScores = parser.choiceScores - additionalProperties(parser.additionalProperties) + choiceScores = parser.choiceScores + type = parser.type + useCot = parser.useCot + additionalProperties = parser.additionalProperties.toMutableMap() + } + + fun choiceScores(choiceScores: ChoiceScores) = choiceScores(JsonField.of(choiceScores)) + + fun choiceScores(choiceScores: JsonField) = apply { + this.choiceScores = choiceScores } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun useCot(useCot: Boolean) = useCot(JsonField.of(useCot)) - @JsonProperty("use_cot") - @ExcludeMissing fun useCot(useCot: JsonField) = apply { this.useCot = useCot } - fun choiceScores(choiceScores: ChoiceScores) = choiceScores(JsonField.of(choiceScores)) - - @JsonProperty("choice_scores") - @ExcludeMissing - fun choiceScores(choiceScores: JsonField) = apply { - this.choiceScores = choiceScores - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Parser = Parser( - type, - useCot, - choiceScores, + checkRequired("choiceScores", choiceScores), + checkRequired("type", type), + checkRequired("useCot", useCot), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = ChoiceScores.Builder::class) @NoAutoDetect class ChoiceScores + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ChoiceScores = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -411,23 +481,23 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ChoiceScores]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(choiceScores: ChoiceScores) = apply { - additionalProperties(choiceScores.additionalProperties) + additionalProperties = choiceScores.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -435,6 +505,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ChoiceScores = ChoiceScores(additionalProperties.toImmutable()) } @@ -461,42 +539,65 @@ 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 - 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() - companion object { - @JvmField val LLM_CLASSIFIER = Type(JsonField.of("llm_classifier")) + @JvmField val LLM_CLASSIFIER = of("llm_classifier") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { LLM_CLASSIFIER, } + /** + * 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_CLASSIFIER, + /** 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_CLASSIFIER -> Value.LLM_CLASSIFIER 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_CLASSIFIER -> Known.LLM_CLASSIFIER @@ -504,6 +605,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -511,17 +624,17 @@ private constructor( return true } - return /* spotless:off */ other is Parser && type == other.type && useCot == other.useCot && choiceScores == other.choiceScores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Parser && choiceScores == other.choiceScores && type == other.type && useCot == other.useCot && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, useCot, choiceScores, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(choiceScores, type, useCot, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Parser{type=$type, useCot=$useCot, choiceScores=$choiceScores, additionalProperties=$additionalProperties}" + "Parser{choiceScores=$choiceScores, type=$type, useCot=$useCot, additionalProperties=$additionalProperties}" } @JsonDeserialize(using = Prompt.Deserializer::class) @@ -534,8 +647,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun completion(): Optional = Optional.ofNullable(completion) fun chat(): Optional = Optional.ofNullable(chat) @@ -565,16 +676,29 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): Prompt = apply { - if (!validated) { - if (completion == null && chat == null && nullableVariant == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - completion?.validate() - chat?.validate() - nullableVariant?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitCompletion(completion: Completion) { + completion.validate() + } + + override fun visitChat(chat: Chat) { + chat.validate() + } + + override fun visitNullableVariant(nullableVariant: NullableVariant) { + nullableVariant.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -607,6 +731,7 @@ private constructor( Prompt(nullableVariant = nullableVariant) } + /** An interface that defines how to map each variant of [Prompt] to a value of type [T]. */ interface Visitor { fun visitCompletion(completion: Completion): T @@ -615,12 +740,22 @@ private constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T + /** + * Maps an unknown variant of [Prompt] to a value of type [T]. + * + * An instance of [Prompt] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Prompt: $json") } } - class Deserializer : BaseDeserializer(Prompt::class) { + internal class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { val json = JsonValue.fromJsonNode(node) @@ -642,7 +777,7 @@ private constructor( } } - class Serializer : BaseSerializer(Prompt::class) { + internal class Serializer : BaseSerializer(Prompt::class) { override fun serialize( value: Prompt, @@ -659,35 +794,42 @@ private constructor( } } - @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect class Completion + @JsonCreator private constructor( - private val type: JsonField, - private val content: JsonField, - private val additionalProperties: Map, + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun content(): String = content.getRequired("content") fun type(): Type = type.getRequired("type") - fun content(): String = content.getRequired("content") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Completion = apply { - if (!validated) { - type() - content() - validated = true + if (validated) { + return@apply } + + content() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -697,39 +839,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Completion]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() + private var content: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(completion: Completion) = apply { - this.type = completion.type - this.content = completion.content - additionalProperties(completion.additionalProperties) + content = completion.content + type = completion.type + additionalProperties = completion.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun content(content: String) = content(JsonField.of(content)) - @JsonProperty("content") - @ExcludeMissing fun content(content: JsonField) = apply { this.content = content } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -737,10 +875,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Completion = Completion( - type, - content, + checkRequired("content", content), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -751,42 +897,67 @@ 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 - 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() - companion object { - @JvmField val COMPLETION = Type(JsonField.of("completion")) + @JvmField val COMPLETION = of("completion") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { COMPLETION, } + /** + * 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 { COMPLETION, + /** + * 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) { COMPLETION -> Value.COMPLETION 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) { COMPLETION -> Known.COMPLETION @@ -794,6 +965,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -801,54 +984,65 @@ private constructor( return true } - return /* spotless:off */ other is Completion && type == other.type && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Completion && content == other.content && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, content, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(content, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" + "Completion{content=$content, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect class Chat + @JsonCreator private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, + @JsonProperty("messages") + @ExcludeMissing + private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonProperty("tools") + @ExcludeMissing + private val tools: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun messages(): List = messages.getRequired("messages") fun type(): Type = type.getRequired("type") - fun messages(): List = messages.getRequired("messages") - fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("messages") + @ExcludeMissing + fun _messages(): JsonField> = messages - @JsonProperty("messages") @ExcludeMissing fun _messages() = messages + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("tools") @ExcludeMissing fun _tools() = tools + @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField = tools @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Chat = apply { - if (!validated) { - type() - messages() - tools() - validated = true + if (validated) { + return@apply } + + messages().forEach { it.validate() } + type() + tools() + validated = true } fun toBuilder() = Builder().from(this) @@ -858,49 +1052,71 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Chat]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var messages: JsonField> = JsonMissing.of() + private var messages: JsonField>? = null + private var type: JsonField? = null private var tools: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(chat: Chat) = apply { - this.type = chat.type - this.messages = chat.messages - this.tools = chat.tools - additionalProperties(chat.additionalProperties) + messages = chat.messages.map { it.toMutableList() } + type = chat.type + tools = chat.tools + additionalProperties = chat.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun messages(messages: List) = messages(JsonField.of(messages)) - @JsonProperty("messages") - @ExcludeMissing fun messages(messages: JsonField>) = apply { - this.messages = messages + this.messages = messages.map { it.toMutableList() } + } + + fun addMessage(message: Message) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(message) + } } + fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) + + fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) + + fun addMessage(assistant: Message.Assistant) = + addMessage(Message.ofAssistant(assistant)) + + fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) + + fun addMessage(function: Message.Function) = + addMessage(Message.ofFunction(function)) + + fun addMessage(fallback: Message.Fallback) = + addMessage(Message.ofFallback(fallback)) + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun tools(tools: String) = tools(JsonField.of(tools)) - @JsonProperty("tools") - @ExcludeMissing fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -908,10 +1124,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Chat = Chat( - type, - messages.map { it.toImmutable() }, + checkRequired("messages", messages).map { it.toImmutable() }, + checkRequired("type", type), tools, additionalProperties.toImmutable(), ) @@ -930,8 +1154,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun system(): Optional = Optional.ofNullable(system) fun user(): Optional = Optional.ofNullable(user) @@ -982,26 +1204,41 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): Message = apply { - if (!validated) { - if ( - system == null && - user == null && - assistant == null && - tool == null && - function == null && - fallback == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - system?.validate() - user?.validate() - assistant?.validate() - tool?.validate() - function?.validate() - fallback?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitSystem(system: System) { + system.validate() + } + + override fun visitUser(user: User) { + user.validate() + } + + override fun visitAssistant(assistant: Assistant) { + assistant.validate() + } + + override fun visitTool(tool: Tool) { + tool.validate() + } + + override fun visitFunction(function: Function) { + function.validate() + } + + override fun visitFallback(fallback: Fallback) { + fallback.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -1042,6 +1279,10 @@ private constructor( @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } + /** + * An interface that defines how to map each variant of [Message] to a value of type + * [T]. + */ interface Visitor { fun visitSystem(system: System): T @@ -1056,12 +1297,22 @@ private constructor( fun visitFallback(fallback: Fallback): T + /** + * Maps an unknown variant of [Message] to a value of type [T]. + * + * An instance of [Message] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Message: $json") } } - class Deserializer : BaseDeserializer(Message::class) { + internal class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { val json = JsonValue.fromJsonNode(node) @@ -1095,7 +1346,7 @@ private constructor( } } - class Serializer : BaseSerializer(Message::class) { + internal class Serializer : BaseSerializer(Message::class) { override fun serialize( value: Message, @@ -1115,42 +1366,53 @@ private constructor( } } - @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect class System + @JsonCreator private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun role(): Role = role.getRequired("role") - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): System = apply { - if (!validated) { - content() - role() - name() - validated = true + if (validated) { + return@apply } + + role() + content() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1160,59 +1422,61 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [System]. */ + class Builder internal constructor() { + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(system: System) = apply { - this.content = system.content - this.role = system.role - this.name = system.name - additionalProperties(system.additionalProperties) + role = system.role + content = system.content + name = system.name + additionalProperties = system.additionalProperties.toMutableMap() } - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } + fun content(content: String) = content(JsonField.of(content)) + + fun content(content: JsonField) = apply { this.content = content } + fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): System = System( + checkRequired("role", role), content, - role, name, additionalProperties.toImmutable(), ) @@ -1224,43 +1488,70 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val SYSTEM = Role(JsonField.of("system")) + @JvmField val SYSTEM = of("system") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { SYSTEM, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Role] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { SYSTEM, + /** + * An enum member indicating that [Role] was instantiated with an + * unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ fun value(): Value = when (this) { SYSTEM -> Value.SYSTEM 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) { SYSTEM -> Known.SYSTEM @@ -1268,6 +1559,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1275,55 +1578,66 @@ private constructor( return true } - return /* spotless:off */ other is System && content == other.content && role == other.role && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(content, role, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(role, content, name, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect class User + @JsonCreator private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun role(): Role = role.getRequired("role") - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): User = apply { - if (!validated) { - content() - role() - name() - validated = true + if (validated) { + return@apply } + + role() + content().ifPresent { it.validate() } + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1333,59 +1647,66 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [User]. */ + class Builder internal constructor() { + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(user: User) = apply { - this.content = user.content - this.role = user.role - this.name = user.name - additionalProperties(user.additionalProperties) + role = user.role + content = user.content + name = user.name + additionalProperties = user.additionalProperties.toMutableMap() } + fun role(role: Role) = role(JsonField.of(role)) + + fun role(role: JsonField) = apply { this.role = role } + fun content(content: Content) = content(JsonField.of(content)) - @JsonProperty("content") - @ExcludeMissing fun content(content: JsonField) = apply { this.content = content } - fun role(role: Role) = role(JsonField.of(role)) + fun content(text: String) = content(Content.ofText(text)) - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } + fun contentOfArray(array: List) = + content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): User = User( + checkRequired("role", role), content, - role, name, additionalProperties.toImmutable(), ) @@ -1397,43 +1718,70 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val USER = Role(JsonField.of("user")) + @JvmField val USER = of("user") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { USER, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Role] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { USER, + /** + * An enum member indicating that [Role] was instantiated with an + * unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ fun value(): Value = when (this) { USER -> Value.USER 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) { USER -> Known.USER @@ -1441,6 +1789,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } @JsonDeserialize(using = Content.Deserializer::class) @@ -1452,8 +1812,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun text(): Optional = Optional.ofNullable(text) fun array(): Optional> = @@ -1477,13 +1835,25 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): Content = apply { - if (!validated) { - if (text == null && array == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitText(text: String) {} + + override fun visitArray( + array: List + ) { + array.forEach { it.validate() } + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -1513,18 +1883,32 @@ private constructor( Content(array = array) } + /** + * An interface that defines how to map each variant of [Content] to a value + * of type [T]. + */ interface Visitor { fun visitText(text: String): T fun visitArray(array: List): T + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Content: $json") } } - class Deserializer : BaseDeserializer(Content::class) { + internal class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { val json = JsonValue.fromJsonNode(node) @@ -1535,7 +1919,9 @@ private constructor( tryDeserialize( node, jacksonTypeRef>() - ) + ) { + it.forEach { it.validate() } + } ?.let { return Content(array = it, _json = json) } @@ -1544,7 +1930,7 @@ private constructor( } } - class Serializer : BaseSerializer(Content::class) { + internal class Serializer : BaseSerializer(Content::class) { override fun serialize( value: Content, @@ -1564,71 +1950,59 @@ private constructor( @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) class ChatCompletionContentPart private constructor( - private val chatCompletionContentPartText: - ChatCompletionContentPartText? = - null, - private val chatCompletionContentPartImage: - ChatCompletionContentPartImage? = - null, + private val text: ChatCompletionContentPartText? = null, + private val image: ChatCompletionContentPartImage? = null, private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - - fun chatCompletionContentPartText(): - Optional = - Optional.ofNullable(chatCompletionContentPartText) + fun text(): Optional = + Optional.ofNullable(text) - fun chatCompletionContentPartImage(): - Optional = - Optional.ofNullable(chatCompletionContentPartImage) + fun image(): Optional = + Optional.ofNullable(image) - fun isChatCompletionContentPartText(): Boolean = - chatCompletionContentPartText != null + fun isText(): Boolean = text != null - fun isChatCompletionContentPartImage(): Boolean = - chatCompletionContentPartImage != null + fun isImage(): Boolean = image != null - fun asChatCompletionContentPartText(): ChatCompletionContentPartText = - chatCompletionContentPartText.getOrThrow( - "chatCompletionContentPartText" - ) + fun asText(): ChatCompletionContentPartText = text.getOrThrow("text") - fun asChatCompletionContentPartImage(): ChatCompletionContentPartImage = - chatCompletionContentPartImage.getOrThrow( - "chatCompletionContentPartImage" - ) + fun asImage(): ChatCompletionContentPartImage = + image.getOrThrow("image") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - chatCompletionContentPartText != null -> - visitor.visitChatCompletionContentPartText( - chatCompletionContentPartText - ) - chatCompletionContentPartImage != null -> - visitor.visitChatCompletionContentPartImage( - chatCompletionContentPartImage - ) + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) else -> visitor.unknown(_json) } } + private var validated: Boolean = false + fun validate(): ChatCompletionContentPart = apply { - if (!validated) { - if ( - chatCompletionContentPartText == null && - chatCompletionContentPartImage == null - ) { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $_json" - ) - } - chatCompletionContentPartText?.validate() - chatCompletionContentPartImage?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitText( + text: ChatCompletionContentPartText + ) { + text.validate() + } + + override fun visitImage( + image: ChatCompletionContentPartImage + ) { + image.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -1636,17 +2010,15 @@ private constructor( return true } - return /* spotless:off */ other is ChatCompletionContentPart && chatCompletionContentPartText == other.chatCompletionContentPartText && chatCompletionContentPartImage == other.chatCompletionContentPartImage /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(chatCompletionContentPartText, chatCompletionContentPartImage) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, image) /* spotless:on */ override fun toString(): String = when { - chatCompletionContentPartText != null -> - "ChatCompletionContentPart{chatCompletionContentPartText=$chatCompletionContentPartText}" - chatCompletionContentPartImage != null -> - "ChatCompletionContentPart{chatCompletionContentPartImage=$chatCompletionContentPartImage}" + text != null -> "ChatCompletionContentPart{text=$text}" + image != null -> "ChatCompletionContentPart{image=$image}" _json != null -> "ChatCompletionContentPart{_unknown=$_json}" else -> throw IllegalStateException( @@ -1657,34 +2029,37 @@ private constructor( companion object { @JvmStatic - fun ofChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ) = - ChatCompletionContentPart( - chatCompletionContentPartText = - chatCompletionContentPartText - ) + fun ofText(text: ChatCompletionContentPartText) = + ChatCompletionContentPart(text = text) @JvmStatic - fun ofChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ) = - ChatCompletionContentPart( - chatCompletionContentPartImage = - chatCompletionContentPartImage - ) + fun ofImage(image: ChatCompletionContentPartImage) = + ChatCompletionContentPart(image = image) } + /** + * An interface that defines how to map each variant of + * [ChatCompletionContentPart] to a value of type [T]. + */ interface Visitor { - fun visitChatCompletionContentPartText( - chatCompletionContentPartText: ChatCompletionContentPartText - ): T - - fun visitChatCompletionContentPartImage( - chatCompletionContentPartImage: ChatCompletionContentPartImage - ): T - + fun visitText(text: ChatCompletionContentPartText): T + + fun visitImage(image: ChatCompletionContentPartImage): T + + /** + * Maps an unknown variant of [ChatCompletionContentPart] to a value + * of type [T]. + * + * An instance of [ChatCompletionContentPart] can contain an unknown + * variant if it was deserialized from data that doesn't match any + * known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default + * implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException( "Unknown ChatCompletionContentPart: $json" @@ -1692,7 +2067,7 @@ private constructor( } } - class Deserializer : + internal class Deserializer : BaseDeserializer( ChatCompletionContentPart::class ) { @@ -1710,7 +2085,7 @@ private constructor( } ?.let { return ChatCompletionContentPart( - chatCompletionContentPartText = it, + text = it, _json = json ) } @@ -1722,7 +2097,7 @@ private constructor( } ?.let { return ChatCompletionContentPart( - chatCompletionContentPartImage = it, + image = it, _json = json ) } @@ -1731,7 +2106,7 @@ private constructor( } } - class Serializer : + internal class Serializer : BaseSerializer( ChatCompletionContentPart::class ) { @@ -1742,14 +2117,8 @@ private constructor( provider: SerializerProvider ) { when { - value.chatCompletionContentPartText != null -> - generator.writeObject( - value.chatCompletionContentPartText - ) - value.chatCompletionContentPartImage != null -> - generator.writeObject( - value.chatCompletionContentPartImage - ) + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( @@ -1766,33 +2135,43 @@ private constructor( return true } - return /* spotless:off */ other is User && content == other.content && role == other.role && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(content, role, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(role, content, name, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect class Assistant + @JsonCreator private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tool_calls") + @ExcludeMissing + private val toolCalls: JsonField> = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun role(): Role = role.getRequired("role") fun content(): Optional = @@ -1806,31 +2185,39 @@ private constructor( fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonProperty("function_call") @ExcludeMissing - fun _functionCall() = functionCall + fun _functionCall(): JsonField = functionCall - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") + @ExcludeMissing + fun _toolCalls(): JsonField> = toolCalls @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Assistant = apply { - if (!validated) { - role() - content() - functionCall().map { it.validate() } - name() - toolCalls().map { it.forEach { it.validate() } } - validated = true + if (validated) { + return@apply } + + role() + content() + functionCall().ifPresent { it.validate() } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true } fun toBuilder() = Builder().from(this) @@ -1840,86 +2227,108 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Assistant]. */ + class Builder internal constructor() { - private var role: JsonField = JsonMissing.of() + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField> = - JsonMissing.of() + private var toolCalls: + JsonField>? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(assistant: Assistant) = apply { - this.role = assistant.role - this.content = assistant.content - this.functionCall = assistant.functionCall - this.name = assistant.name - this.toolCalls = assistant.toolCalls - additionalProperties(assistant.additionalProperties) + role = assistant.role + content = assistant.content + functionCall = assistant.functionCall + name = assistant.name + toolCalls = assistant.toolCalls.map { it.toMutableList() } + additionalProperties = assistant.additionalProperties.toMutableMap() } fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } - fun content(content: String) = content(JsonField.of(content)) + fun content(content: String?) = content(JsonField.ofNullable(content)) + + fun content(content: Optional) = content(content.orElse(null)) - @JsonProperty("content") - @ExcludeMissing fun content(content: JsonField) = apply { this.content = content } - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall?) = + functionCall(JsonField.ofNullable(functionCall)) + + fun functionCall(functionCall: Optional) = + functionCall(functionCall.orElse(null)) - @JsonProperty("function_call") - @ExcludeMissing fun functionCall(functionCall: JsonField) = apply { this.functionCall = functionCall } - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List?) = + toolCalls(JsonField.ofNullable(toolCalls)) + + fun toolCalls(toolCalls: Optional>) = + toolCalls(toolCalls.orElse(null)) - @JsonProperty("tool_calls") - @ExcludeMissing fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls + this.toolCalls = toolCalls.map { it.toMutableList() } } + fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { + toolCalls = + (toolCalls ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(toolCall) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Assistant = Assistant( - role, + checkRequired("role", role), content, functionCall, name, - toolCalls.map { it.toImmutable() }, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -1930,43 +2339,70 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val ASSISTANT = Role(JsonField.of("assistant")) + @JvmField val ASSISTANT = of("assistant") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { ASSISTANT, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Role] 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 { ASSISTANT, + /** + * An enum member indicating that [Role] 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) { ASSISTANT -> Value.ASSISTANT 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) { ASSISTANT -> Known.ASSISTANT @@ -1974,37 +2410,59 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect class FunctionCall + @JsonCreator private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("arguments") + @ExcludeMissing + private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): FunctionCall = apply { - if (!validated) { - arguments() - name() - validated = true + if (validated) { + return@apply } + + arguments() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -2014,53 +2472,58 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FunctionCall]. */ + class Builder internal constructor() { - private var arguments: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var arguments: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(functionCall: FunctionCall) = apply { - this.arguments = functionCall.arguments - this.name = functionCall.name - additionalProperties(functionCall.additionalProperties) + arguments = functionCall.arguments + name = functionCall.name + additionalProperties = + functionCall.additionalProperties.toMutableMap() } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - @JsonProperty("arguments") - @ExcludeMissing fun arguments(arguments: JsonField) = apply { this.arguments = arguments } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): FunctionCall = FunctionCall( - arguments, - name, + checkRequired("arguments", arguments), + checkRequired("name", name), additionalProperties.toImmutable(), ) } @@ -2101,43 +2564,56 @@ private constructor( "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect class Tool + @JsonCreator private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + private val toolCallId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun role(): Role = role.getRequired("role") - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId(): JsonField = toolCallId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Tool = apply { - if (!validated) { - content() - role() - toolCallId() - validated = true + if (validated) { + return@apply } + + role() + content() + toolCallId() + validated = true } fun toBuilder() = Builder().from(this) @@ -2147,38 +2623,33 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Tool]. */ + class Builder internal constructor() { + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tool: Tool) = apply { - this.content = tool.content - this.role = tool.role - this.toolCallId = tool.toolCallId - additionalProperties(tool.additionalProperties) + role = tool.role + content = tool.content + toolCallId = tool.toolCallId + additionalProperties = tool.additionalProperties.toMutableMap() } - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } + fun content(content: String) = content(JsonField.of(content)) + + fun content(content: JsonField) = apply { this.content = content } + fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - @JsonProperty("tool_call_id") - @ExcludeMissing fun toolCallId(toolCallId: JsonField) = apply { this.toolCallId = toolCallId } @@ -2186,22 +2657,29 @@ private constructor( fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Tool = Tool( + checkRequired("role", role), content, - role, toolCallId, additionalProperties.toImmutable(), ) @@ -2213,43 +2691,70 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val TOOL = Role(JsonField.of("tool")) + @JvmField val TOOL = of("tool") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { TOOL, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Role] 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 { TOOL, + /** + * An enum member indicating that [Role] 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) { 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) { TOOL -> Known.TOOL @@ -2257,6 +2762,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2264,55 +2781,66 @@ private constructor( return true } - return /* spotless:off */ other is Tool && content == other.content && role == other.role && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(content, role, toolCallId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(role, content, toolCallId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function + @JsonCreator private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - @JsonProperty("content") @ExcludeMissing fun _content() = content + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - content() - name() - role() - validated = true + if (validated) { + return@apply } + + name() + role() + content() + validated = true } fun toBuilder() = Builder().from(this) @@ -2322,60 +2850,62 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Function]. */ + class Builder internal constructor() { + private var name: JsonField? = null + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var role: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.content = function.content - this.name = function.name - this.role = function.role - additionalProperties(function.additionalProperties) + name = function.name + role = function.role + content = function.content + additionalProperties = function.additionalProperties.toMutableMap() } - fun content(content: String) = content(JsonField.of(content)) - - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } + fun content(content: String) = content(JsonField.of(content)) + + fun content(content: JsonField) = apply { this.content = content } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Function = Function( + checkRequired("name", name), + checkRequired("role", role), content, - name, - role, additionalProperties.toImmutable(), ) } @@ -2386,43 +2916,70 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val FUNCTION = Role(JsonField.of("function")) + @JvmField val FUNCTION = of("function") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { FUNCTION, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Role] 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 { FUNCTION, + /** + * An enum member indicating that [Role] 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) { 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) { FUNCTION -> Known.FUNCTION @@ -2430,6 +2987,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2437,49 +3006,58 @@ private constructor( return true } - return /* spotless:off */ other is Function && content == other.content && name == other.name && role == other.role && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(content, name, role, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, role, content, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect class Fallback + @JsonCreator private constructor( - private val role: JsonField, - private val content: JsonField, - private val additionalProperties: Map, + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Fallback = apply { - if (!validated) { - role() - content() - validated = true + if (validated) { + return@apply } + + role() + content() + validated = true } fun toBuilder() = Builder().from(this) @@ -2489,50 +3067,56 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Fallback]. */ + class Builder internal constructor() { - private var role: JsonField = JsonMissing.of() + private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(fallback: Fallback) = apply { - this.role = fallback.role - this.content = fallback.content - additionalProperties(fallback.additionalProperties) + role = fallback.role + content = fallback.content + additionalProperties = fallback.additionalProperties.toMutableMap() } fun role(role: Role) = role(JsonField.of(role)) - @JsonProperty("role") - @ExcludeMissing fun role(role: JsonField) = apply { this.role = role } - fun content(content: String) = content(JsonField.of(content)) + fun content(content: String?) = content(JsonField.ofNullable(content)) + + fun content(content: Optional) = content(content.orElse(null)) - @JsonProperty("content") - @ExcludeMissing fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Fallback = Fallback( - role, + checkRequired("role", role), content, additionalProperties.toImmutable(), ) @@ -2544,43 +3128,70 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val MODEL = Role(JsonField.of("model")) + @JvmField val MODEL = of("model") @JvmStatic fun of(value: String) = Role(JsonField.of(value)) } + /** An enum containing [Role]'s known values. */ enum class Known { MODEL, } + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Role] 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 { MODEL, + /** + * An enum member indicating that [Role] 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) { MODEL -> Value.MODEL 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) { MODEL -> Known.MODEL @@ -2588,6 +3199,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2615,42 +3238,67 @@ 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 - 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() - companion object { - @JvmField val CHAT = Type(JsonField.of("chat")) + @JvmField val CHAT = of("chat") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { CHAT, } + /** + * 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 { CHAT, + /** + * 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) { CHAT -> Value.CHAT 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) { CHAT -> Known.CHAT @@ -2658,6 +3306,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -2665,36 +3325,39 @@ private constructor( return true } - return /* spotless:off */ other is Chat && type == other.type && messages == other.messages && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Chat && messages == other.messages && type == other.type && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, messages, tools, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(messages, type, tools, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect class NullableVariant + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): NullableVariant = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -2704,23 +3367,23 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [NullableVariant]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) + additionalProperties = nullableVariant.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2728,6 +3391,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } @@ -2758,8 +3429,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun function(): Optional = Optional.ofNullable(function) fun global(): Optional = Optional.ofNullable(global) @@ -2782,15 +3451,25 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): ToolFunction = apply { - if (!validated) { - if (function == null && global == null) { - throw BraintrustInvalidDataException("Unknown ToolFunction: $_json") - } - function?.validate() - global?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitFunction(function: Function) { + function.validate() + } + + override fun visitGlobal(global: Global) { + global.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -2818,18 +3497,32 @@ private constructor( @JvmStatic fun ofGlobal(global: Global) = ToolFunction(global = global) } + /** + * An interface that defines how to map each variant of [ToolFunction] to a value of type + * [T]. + */ interface Visitor { fun visitFunction(function: Function): T fun visitGlobal(global: Global): T + /** + * Maps an unknown variant of [ToolFunction] to a value of type [T]. + * + * An instance of [ToolFunction] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown ToolFunction: $json") } } - class Deserializer : BaseDeserializer(ToolFunction::class) { + internal class Deserializer : BaseDeserializer(ToolFunction::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolFunction { val json = JsonValue.fromJsonNode(node) @@ -2847,7 +3540,7 @@ private constructor( } } - class Serializer : BaseSerializer(ToolFunction::class) { + internal class Serializer : BaseSerializer(ToolFunction::class) { override fun serialize( value: ToolFunction, @@ -2863,35 +3556,42 @@ private constructor( } } - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function + @JsonCreator private constructor( - private val type: JsonField, - private val id: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun id(): String = id.getRequired("id") fun type(): Type = type.getRequired("type") - fun id(): String = id.getRequired("id") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - type() - id() - validated = true + if (validated) { + return@apply } + + id() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -2901,39 +3601,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Function]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.type = function.type - this.id = function.id - additionalProperties(function.additionalProperties) + id = function.id + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun id(id: String) = id(JsonField.of(id)) - @JsonProperty("id") - @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2941,10 +3637,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Function = Function( - type, - id, + checkRequired("id", id), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -2955,42 +3659,67 @@ 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 - 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() - companion object { - @JvmField val FUNCTION = Type(JsonField.of("function")) + @JvmField val FUNCTION = of("function") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { FUNCTION, } + /** + * 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 { FUNCTION, + /** + * 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) { 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) { FUNCTION -> Known.FUNCTION @@ -2998,6 +3727,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -3005,48 +3746,55 @@ private constructor( return true } - return /* spotless:off */ other is Function && type == other.type && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, id, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" + "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect class Global + @JsonCreator private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - fun name(): String = name.getRequired("name") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Global = apply { - if (!validated) { - type() - name() - validated = true + if (validated) { + return@apply } + + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -3056,39 +3804,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Global]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(global: Global) = apply { - this.type = global.type - this.name = global.name - additionalProperties(global.additionalProperties) + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -3096,10 +3840,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Global = Global( - type, - name, + checkRequired("name", name), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -3110,42 +3862,67 @@ 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 - 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() - companion object { - @JvmField val GLOBAL = Type(JsonField.of("global")) + @JvmField val GLOBAL = of("global") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { GLOBAL, } + /** + * 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 { GLOBAL, + /** + * 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) { GLOBAL -> Value.GLOBAL 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) { GLOBAL -> Known.GLOBAL @@ -3153,6 +3930,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -3160,17 +3949,17 @@ private constructor( return true } - return /* spotless:off */ other is Global && type == other.type && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } @@ -3179,15 +3968,15 @@ private constructor( return true } - return /* spotless:off */ other is PromptData && prompt == other.prompt && options == other.options && parser == other.parser && toolFunctions == other.toolFunctions && origin == other.origin && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptData && options == other.options && origin == other.origin && parser == other.parser && prompt == other.prompt && toolFunctions == other.toolFunctions && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(prompt, options, parser, toolFunctions, origin, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(options, origin, parser, prompt, toolFunctions, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PromptData{prompt=$prompt, options=$options, parser=$parser, toolFunctions=$toolFunctions, origin=$origin, additionalProperties=$additionalProperties}" + "PromptData{options=$options, origin=$origin, parser=$parser, prompt=$prompt, toolFunctions=$toolFunctions, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index c4e173e1..9d99c9b8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a prompt object by its id */ class PromptDeleteParams -constructor( +private constructor( private val promptId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Prompt id */ fun promptId(): String = promptId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [PromptDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var promptId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): PromptDeleteParams = PromptDeleteParams( - checkNotNull(promptId) { "`promptId` is required but was not set" }, + checkRequired("promptId", promptId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index c692f4f7..0901fd57 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.PromptService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first + */ class PromptListPage private constructor( private val promptsService: PromptService, @@ -79,16 +84,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -98,11 +102,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,10 +146,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -150,8 +156,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: PromptListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index 9d1786e3..88ccf7c7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.PromptServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first + */ class PromptListPageAsync private constructor( private val promptsService: PromptServiceAsync, @@ -82,16 +87,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -101,11 +105,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -141,10 +149,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -153,8 +159,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: PromptListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index ec56d5cf..d24b3f68 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first + */ class PromptListParams -constructor( +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -35,36 +39,65 @@ constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Project id */ fun projectId(): Optional = Optional.ofNullable(projectId) + /** Name of the project to search for */ fun projectName(): Optional = Optional.ofNullable(projectName) + /** Name of the prompt to search for */ fun promptName(): Optional = Optional.ofNullable(promptName) + /** Retrieve prompt with a specific slug */ fun slug(): Optional = Optional.ofNullable(slug) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + /** + * Retrieve prompt at a specific version. + * + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). + */ fun version(): Optional = Optional.ofNullable(version) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.ids?.let { queryParams.put("ids", listOf(it.toString())) } @@ -87,8 +120,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [PromptListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var ids: Ids? = null @@ -126,43 +160,89 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = ids(Ids.ofString(string)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** Project id */ + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + + /** Name of the project to search for */ + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) /** Name of the prompt to search for */ - fun promptName(promptName: String) = apply { this.promptName = promptName } + fun promptName(promptName: String?) = apply { this.promptName = promptName } + + /** Name of the prompt to search for */ + fun promptName(promptName: Optional) = promptName(promptName.orElse(null)) + + /** Retrieve prompt with a specific slug */ + fun slug(slug: String?) = apply { this.slug = slug } /** Retrieve prompt with a specific slug */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: Optional) = slug(slug.orElse(null)) + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. @@ -171,7 +251,8 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) /** * Retrieve prompt at a specific version. @@ -179,7 +260,15 @@ constructor( * The version id can either be a transaction id (e.g. '1000192656880881099') or a version * identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String) = apply { this.version = version } + fun version(version: String?) = apply { this.version = version } + + /** + * Retrieve prompt at a specific version. + * + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). + */ + fun version(version: Optional) = version(version.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -296,6 +385,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -305,8 +398,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -329,15 +420,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -363,18 +445,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -390,7 +482,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 2db2169f..1191f0f3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -10,7 +10,9 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -27,41 +29,47 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = PromptOptions.Builder::class) @NoAutoDetect class PromptOptions +@JsonCreator private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + @JsonProperty("model") @ExcludeMissing private val model: JsonField = JsonMissing.of(), + @JsonProperty("params") + @ExcludeMissing + private val params: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun model(): Optional = Optional.ofNullable(model.getNullable("model")) fun params(): Optional = Optional.ofNullable(params.getNullable("params")) fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - @JsonProperty("model") @ExcludeMissing fun _model() = model + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model - @JsonProperty("params") @ExcludeMissing fun _params() = params + @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): PromptOptions = apply { - if (!validated) { - model() - params() - position() - validated = true + if (validated) { + return@apply } + + model() + params().ifPresent { it.validate() } + position() + validated = true } fun toBuilder() = Builder().from(this) @@ -71,7 +79,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PromptOptions]. */ + class Builder internal constructor() { private var model: JsonField = JsonMissing.of() private var params: JsonField = JsonMissing.of() @@ -80,44 +89,58 @@ private constructor( @JvmSynthetic internal fun from(promptOptions: PromptOptions) = apply { - this.model = promptOptions.model - this.params = promptOptions.params - this.position = promptOptions.position - additionalProperties(promptOptions.additionalProperties) + model = promptOptions.model + params = promptOptions.params + position = promptOptions.position + additionalProperties = promptOptions.additionalProperties.toMutableMap() } fun model(model: String) = model(JsonField.of(model)) - @JsonProperty("model") - @ExcludeMissing fun model(model: JsonField) = apply { this.model = model } fun params(params: Params) = params(JsonField.of(params)) - @JsonProperty("params") - @ExcludeMissing fun params(params: JsonField) = apply { this.params = params } + fun params(openaiModel: Params.OpenAIModelParams) = + params(Params.ofOpenAIModel(openaiModel)) + + fun params(anthropicModel: Params.AnthropicModelParams) = + params(Params.ofAnthropicModel(anthropicModel)) + + fun params(googleModel: Params.GoogleModelParams) = + params(Params.ofGoogleModel(googleModel)) + + fun params(windowAiModel: Params.WindowAiModelParams) = + params(Params.ofWindowAiModel(windowAiModel)) + + fun params(jsCompletion: Params.JsCompletionParams) = + params(Params.ofJsCompletion(jsCompletion)) + fun position(position: String) = position(JsonField.of(position)) - @JsonProperty("position") - @ExcludeMissing fun position(position: JsonField) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PromptOptions = PromptOptions( model, @@ -131,88 +154,88 @@ private constructor( @JsonSerialize(using = Params.Serializer::class) class Params private constructor( - private val openaiModelParams: OpenAIModelParams? = null, - private val anthropicModelParams: AnthropicModelParams? = null, - private val googleModelParams: GoogleModelParams? = null, - private val windowAiModelParams: WindowAiModelParams? = null, - private val jsCompletionParams: JsCompletionParams? = null, + private val openaiModel: OpenAIModelParams? = null, + private val anthropicModel: AnthropicModelParams? = null, + private val googleModel: GoogleModelParams? = null, + private val windowAiModel: WindowAiModelParams? = null, + private val jsCompletion: JsCompletionParams? = null, private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - - fun openaiModelParams(): Optional = - Optional.ofNullable(openaiModelParams) + fun openaiModel(): Optional = Optional.ofNullable(openaiModel) - fun anthropicModelParams(): Optional = - Optional.ofNullable(anthropicModelParams) + fun anthropicModel(): Optional = Optional.ofNullable(anthropicModel) - fun googleModelParams(): Optional = - Optional.ofNullable(googleModelParams) + fun googleModel(): Optional = Optional.ofNullable(googleModel) - fun windowAiModelParams(): Optional = - Optional.ofNullable(windowAiModelParams) + fun windowAiModel(): Optional = Optional.ofNullable(windowAiModel) - fun jsCompletionParams(): Optional = - Optional.ofNullable(jsCompletionParams) + fun jsCompletion(): Optional = Optional.ofNullable(jsCompletion) - fun isOpenAIModelParams(): Boolean = openaiModelParams != null + fun isOpenAIModel(): Boolean = openaiModel != null - fun isAnthropicModelParams(): Boolean = anthropicModelParams != null + fun isAnthropicModel(): Boolean = anthropicModel != null - fun isGoogleModelParams(): Boolean = googleModelParams != null + fun isGoogleModel(): Boolean = googleModel != null - fun isWindowAiModelParams(): Boolean = windowAiModelParams != null + fun isWindowAiModel(): Boolean = windowAiModel != null - fun isJsCompletionParams(): Boolean = jsCompletionParams != null + fun isJsCompletion(): Boolean = jsCompletion != null - fun asOpenAIModelParams(): OpenAIModelParams = - openaiModelParams.getOrThrow("openaiModelParams") + fun asOpenAIModel(): OpenAIModelParams = openaiModel.getOrThrow("openaiModel") - fun asAnthropicModelParams(): AnthropicModelParams = - anthropicModelParams.getOrThrow("anthropicModelParams") + fun asAnthropicModel(): AnthropicModelParams = anthropicModel.getOrThrow("anthropicModel") - fun asGoogleModelParams(): GoogleModelParams = - googleModelParams.getOrThrow("googleModelParams") + fun asGoogleModel(): GoogleModelParams = googleModel.getOrThrow("googleModel") - fun asWindowAiModelParams(): WindowAiModelParams = - windowAiModelParams.getOrThrow("windowAiModelParams") + fun asWindowAiModel(): WindowAiModelParams = windowAiModel.getOrThrow("windowAiModel") - fun asJsCompletionParams(): JsCompletionParams = - jsCompletionParams.getOrThrow("jsCompletionParams") + fun asJsCompletion(): JsCompletionParams = jsCompletion.getOrThrow("jsCompletion") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - openaiModelParams != null -> visitor.visitOpenAIModelParams(openaiModelParams) - anthropicModelParams != null -> - visitor.visitAnthropicModelParams(anthropicModelParams) - googleModelParams != null -> visitor.visitGoogleModelParams(googleModelParams) - windowAiModelParams != null -> visitor.visitWindowAiModelParams(windowAiModelParams) - jsCompletionParams != null -> visitor.visitJsCompletionParams(jsCompletionParams) + openaiModel != null -> visitor.visitOpenAIModel(openaiModel) + anthropicModel != null -> visitor.visitAnthropicModel(anthropicModel) + googleModel != null -> visitor.visitGoogleModel(googleModel) + windowAiModel != null -> visitor.visitWindowAiModel(windowAiModel) + jsCompletion != null -> visitor.visitJsCompletion(jsCompletion) else -> visitor.unknown(_json) } } + private var validated: Boolean = false + fun validate(): Params = apply { - if (!validated) { - if ( - openaiModelParams == null && - anthropicModelParams == null && - googleModelParams == null && - windowAiModelParams == null && - jsCompletionParams == null - ) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - openaiModelParams?.validate() - anthropicModelParams?.validate() - googleModelParams?.validate() - windowAiModelParams?.validate() - jsCompletionParams?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitOpenAIModel(openaiModel: OpenAIModelParams) { + openaiModel.validate() + } + + override fun visitAnthropicModel(anthropicModel: AnthropicModelParams) { + anthropicModel.validate() + } + + override fun visitGoogleModel(googleModel: GoogleModelParams) { + googleModel.validate() + } + + override fun visitWindowAiModel(windowAiModel: WindowAiModelParams) { + windowAiModel.validate() + } + + override fun visitJsCompletion(jsCompletion: JsCompletionParams) { + jsCompletion.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -220,18 +243,18 @@ private constructor( return true } - return /* spotless:off */ other is Params && openaiModelParams == other.openaiModelParams && anthropicModelParams == other.anthropicModelParams && googleModelParams == other.googleModelParams && windowAiModelParams == other.windowAiModelParams && jsCompletionParams == other.jsCompletionParams /* spotless:on */ + return /* spotless:off */ other is Params && openaiModel == other.openaiModel && anthropicModel == other.anthropicModel && googleModel == other.googleModel && windowAiModel == other.windowAiModel && jsCompletion == other.jsCompletion /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(openaiModelParams, anthropicModelParams, googleModelParams, windowAiModelParams, jsCompletionParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(openaiModel, anthropicModel, googleModel, windowAiModel, jsCompletion) /* spotless:on */ override fun toString(): String = when { - openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" - anthropicModelParams != null -> "Params{anthropicModelParams=$anthropicModelParams}" - googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" - windowAiModelParams != null -> "Params{windowAiModelParams=$windowAiModelParams}" - jsCompletionParams != null -> "Params{jsCompletionParams=$jsCompletionParams}" + openaiModel != null -> "Params{openaiModel=$openaiModel}" + anthropicModel != null -> "Params{anthropicModel=$anthropicModel}" + googleModel != null -> "Params{googleModel=$googleModel}" + windowAiModel != null -> "Params{windowAiModel=$windowAiModel}" + jsCompletion != null -> "Params{jsCompletion=$jsCompletion}" _json != null -> "Params{_unknown=$_json}" else -> throw IllegalStateException("Invalid Params") } @@ -239,74 +262,83 @@ private constructor( companion object { @JvmStatic - fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = - Params(openaiModelParams = openaiModelParams) + fun ofOpenAIModel(openaiModel: OpenAIModelParams) = Params(openaiModel = openaiModel) @JvmStatic - fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = - Params(anthropicModelParams = anthropicModelParams) + fun ofAnthropicModel(anthropicModel: AnthropicModelParams) = + Params(anthropicModel = anthropicModel) @JvmStatic - fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = - Params(googleModelParams = googleModelParams) + fun ofGoogleModel(googleModel: GoogleModelParams) = Params(googleModel = googleModel) @JvmStatic - fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = - Params(windowAiModelParams = windowAiModelParams) + fun ofWindowAiModel(windowAiModel: WindowAiModelParams) = + Params(windowAiModel = windowAiModel) @JvmStatic - fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = - Params(jsCompletionParams = jsCompletionParams) + fun ofJsCompletion(jsCompletion: JsCompletionParams) = + Params(jsCompletion = jsCompletion) } + /** An interface that defines how to map each variant of [Params] to a value of type [T]. */ interface Visitor { - fun visitOpenAIModelParams(openaiModelParams: OpenAIModelParams): T + fun visitOpenAIModel(openaiModel: OpenAIModelParams): T - fun visitAnthropicModelParams(anthropicModelParams: AnthropicModelParams): T + fun visitAnthropicModel(anthropicModel: AnthropicModelParams): T - fun visitGoogleModelParams(googleModelParams: GoogleModelParams): T + fun visitGoogleModel(googleModel: GoogleModelParams): T - fun visitWindowAiModelParams(windowAiModelParams: WindowAiModelParams): T + fun visitWindowAiModel(windowAiModel: WindowAiModelParams): T - fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T + fun visitJsCompletion(jsCompletion: JsCompletionParams): T + /** + * Maps an unknown variant of [Params] to a value of type [T]. + * + * An instance of [Params] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Params: $json") } } - class Deserializer : BaseDeserializer(Params::class) { + internal class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { val json = JsonValue.fromJsonNode(node) tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Params(openaiModelParams = it, _json = json) + return Params(openaiModel = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Params(anthropicModelParams = it, _json = json) + return Params(anthropicModel = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Params(googleModelParams = it, _json = json) + return Params(googleModel = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Params(windowAiModelParams = it, _json = json) + return Params(windowAiModel = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Params(jsCompletionParams = it, _json = json) + return Params(jsCompletion = it, _json = json) } return Params(_json = json) } } - class Serializer : BaseSerializer(Params::class) { + internal class Serializer : BaseSerializer(Params::class) { override fun serialize( value: Params, @@ -314,55 +346,66 @@ private constructor( provider: SerializerProvider ) { when { - value.openaiModelParams != null -> - generator.writeObject(value.openaiModelParams) - value.anthropicModelParams != null -> - generator.writeObject(value.anthropicModelParams) - value.googleModelParams != null -> - generator.writeObject(value.googleModelParams) - value.windowAiModelParams != null -> - generator.writeObject(value.windowAiModelParams) - value.jsCompletionParams != null -> - generator.writeObject(value.jsCompletionParams) + value.openaiModel != null -> generator.writeObject(value.openaiModel) + value.anthropicModel != null -> generator.writeObject(value.anthropicModel) + value.googleModel != null -> generator.writeObject(value.googleModel) + value.windowAiModel != null -> generator.writeObject(value.windowAiModel) + value.jsCompletion != null -> generator.writeObject(value.jsCompletion) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Params") } } } - @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect class OpenAIModelParams + @JsonCreator private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, + @JsonProperty("frequency_penalty") + @ExcludeMissing + private val frequencyPenalty: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens") + @ExcludeMissing + private val maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("n") @ExcludeMissing private val n: JsonField = JsonMissing.of(), + @JsonProperty("presence_penalty") + @ExcludeMissing + private val presencePenalty: JsonField = JsonMissing.of(), + @JsonProperty("response_format") + @ExcludeMissing + private val responseFormat: JsonField = JsonMissing.of(), + @JsonProperty("stop") + @ExcludeMissing + private val stop: JsonField> = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("tool_choice") + @ExcludeMissing + private val toolChoice: JsonField = JsonMissing.of(), + @JsonProperty("top_p") + @ExcludeMissing + private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun n(): Optional = Optional.ofNullable(n.getNullable("n")) fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) @@ -370,61 +413,80 @@ private constructor( fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) + fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) - - fun n(): Optional = Optional.ofNullable(n.getNullable("n")) + fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + @JsonProperty("frequency_penalty") + @ExcludeMissing + fun _frequencyPenalty(): JsonField = frequencyPenalty - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + @JsonProperty("function_call") + @ExcludeMissing + fun _functionCall(): JsonField = functionCall - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP + @JsonProperty("max_tokens") + @ExcludeMissing + fun _maxTokens(): JsonField = maxTokens - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens + @JsonProperty("n") @ExcludeMissing fun _n(): JsonField = n - @JsonProperty("frequency_penalty") + @JsonProperty("presence_penalty") @ExcludeMissing - fun _frequencyPenalty() = frequencyPenalty + fun _presencePenalty(): JsonField = presencePenalty - @JsonProperty("presence_penalty") + @JsonProperty("response_format") @ExcludeMissing - fun _presencePenalty() = presencePenalty + fun _responseFormat(): JsonField = responseFormat - @JsonProperty("response_format") @ExcludeMissing fun _responseFormat() = responseFormat + @JsonProperty("stop") @ExcludeMissing fun _stop(): JsonField> = stop - @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature(): JsonField = temperature - @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall + @JsonProperty("tool_choice") + @ExcludeMissing + fun _toolChoice(): JsonField = toolChoice - @JsonProperty("n") @ExcludeMissing fun _n() = n + @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP - @JsonProperty("stop") @ExcludeMissing fun _stop() = stop + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache(): JsonField = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): OpenAIModelParams = apply { - if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat() - toolChoice() - functionCall() - n() - stop() - validated = true - } + if (validated) { + return@apply + } + + frequencyPenalty() + functionCall().ifPresent { it.validate() } + maxTokens() + n() + presencePenalty() + responseFormat().ifPresent { it.validate() } + stop() + temperature() + toolChoice().ifPresent { it.validate() } + topP() + useCache() + validated = true } fun toBuilder() = Builder().from(this) @@ -434,77 +496,69 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [OpenAIModelParams]. */ + class Builder internal constructor() { - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() private var frequencyPenalty: JsonField = JsonMissing.of() + private var functionCall: JsonField = JsonMissing.of() + private var maxTokens: JsonField = JsonMissing.of() + private var n: JsonField = JsonMissing.of() private var presencePenalty: JsonField = JsonMissing.of() private var responseFormat: JsonField = JsonMissing.of() + private var stop: JsonField>? = null + private var temperature: JsonField = JsonMissing.of() private var toolChoice: JsonField = JsonMissing.of() - private var functionCall: JsonField = JsonMissing.of() - private var n: JsonField = JsonMissing.of() - private var stop: JsonField> = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var useCache: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(openaiModelParams: OpenAIModelParams) = apply { - this.useCache = openaiModelParams.useCache - this.temperature = openaiModelParams.temperature - this.topP = openaiModelParams.topP - this.maxTokens = openaiModelParams.maxTokens - this.frequencyPenalty = openaiModelParams.frequencyPenalty - this.presencePenalty = openaiModelParams.presencePenalty - this.responseFormat = openaiModelParams.responseFormat - this.toolChoice = openaiModelParams.toolChoice - this.functionCall = openaiModelParams.functionCall - this.n = openaiModelParams.n - this.stop = openaiModelParams.stop - additionalProperties(openaiModelParams.additionalProperties) + frequencyPenalty = openaiModelParams.frequencyPenalty + functionCall = openaiModelParams.functionCall + maxTokens = openaiModelParams.maxTokens + n = openaiModelParams.n + presencePenalty = openaiModelParams.presencePenalty + responseFormat = openaiModelParams.responseFormat + stop = openaiModelParams.stop.map { it.toMutableList() } + temperature = openaiModelParams.temperature + toolChoice = openaiModelParams.toolChoice + topP = openaiModelParams.topP + useCache = openaiModelParams.useCache + additionalProperties = openaiModelParams.additionalProperties.toMutableMap() } - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun frequencyPenalty(frequencyPenalty: JsonField) = apply { + this.frequencyPenalty = frequencyPenalty + } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) - @JsonProperty("temperature") - @ExcludeMissing - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall } - fun topP(topP: Double) = topP(JsonField.of(topP)) + fun functionCall(unionMember0: FunctionCall.UnionMember0) = + functionCall(FunctionCall.ofUnionMember0(unionMember0)) - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } + fun functionCall(function: FunctionCall.Function) = + functionCall(FunctionCall.ofFunction(function)) fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - @JsonProperty("max_tokens") - @ExcludeMissing fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) + fun n(n: Double) = n(JsonField.of(n)) - @JsonProperty("frequency_penalty") - @ExcludeMissing - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } + fun n(n: JsonField) = apply { this.n = n } fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) - @JsonProperty("presence_penalty") - @ExcludeMissing fun presencePenalty(presencePenalty: JsonField) = apply { this.presencePenalty = presencePenalty } @@ -512,49 +566,74 @@ private constructor( fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) - @JsonProperty("response_format") - @ExcludeMissing fun responseFormat(responseFormat: JsonField) = apply { this.responseFormat = responseFormat } + fun responseFormat(jsonObject: ResponseFormat.JsonObject) = + responseFormat(ResponseFormat.ofJsonObject(jsonObject)) + + fun responseFormat(jsonSchema: ResponseFormat.JsonSchema) = + responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) + + fun responseFormat(text: ResponseFormat.Text) = + responseFormat(ResponseFormat.ofText(text)) + + fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = + responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) + + fun stop(stop: List) = stop(JsonField.of(stop)) + + fun stop(stop: JsonField>) = apply { + this.stop = stop.map { it.toMutableList() } + } + + fun addStop(stop: String) = apply { + this.stop = + (this.stop ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stop) + } + } + + fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } + fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) - @JsonProperty("tool_choice") - @ExcludeMissing fun toolChoice(toolChoice: JsonField) = apply { this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) + fun toolChoice(unionMember0: ToolChoice.UnionMember0) = + toolChoice(ToolChoice.ofUnionMember0(unionMember0)) - @JsonProperty("function_call") - @ExcludeMissing - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } + fun toolChoice(function: ToolChoice.Function) = + toolChoice(ToolChoice.ofFunction(function)) - fun n(n: Double) = n(JsonField.of(n)) + fun topP(topP: Double) = topP(JsonField.of(topP)) - @JsonProperty("n") - @ExcludeMissing - fun n(n: JsonField) = apply { this.n = n } + fun topP(topP: JsonField) = apply { this.topP = topP } - fun stop(stop: List) = stop(JsonField.of(stop)) + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - @JsonProperty("stop") - @ExcludeMissing - fun stop(stop: JsonField>) = apply { this.stop = stop } + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -562,19 +641,27 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): OpenAIModelParams = OpenAIModelParams( - useCache, - temperature, - topP, - maxTokens, frequencyPenalty, + functionCall, + maxTokens, + n, presencePenalty, responseFormat, + (stop ?: JsonMissing.of()).map { it.toImmutable() }, + temperature, toolChoice, - functionCall, - n, - stop.map { it.toImmutable() }, + topP, + useCache, additionalProperties.toImmutable(), ) } @@ -583,29 +670,20 @@ private constructor( @JsonSerialize(using = FunctionCall.Serializer::class) class FunctionCall private constructor( - private val auto: Auto? = null, - private val none: None? = null, + private val unionMember0: UnionMember0? = null, private val function: Function? = null, private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - - fun auto(): Optional = Optional.ofNullable(auto) - - fun none(): Optional = Optional.ofNullable(none) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun function(): Optional = Optional.ofNullable(function) - fun isAuto(): Boolean = auto != null - - fun isNone(): Boolean = none != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isFunction(): Boolean = function != null - fun asAuto(): Auto = auto.getOrThrow("auto") - - fun asNone(): None = none.getOrThrow("none") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asFunction(): Function = function.getOrThrow("function") @@ -613,21 +691,29 @@ private constructor( fun accept(visitor: Visitor): T { return when { - auto != null -> visitor.visitAuto(auto) - none != null -> visitor.visitNone(none) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) function != null -> visitor.visitFunction(function) else -> visitor.unknown(_json) } } + private var validated: Boolean = false + fun validate(): FunctionCall = apply { - if (!validated) { - if (auto == null && none == null && function == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - function?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) {} + + override fun visitFunction(function: Function) { + function.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -635,15 +721,14 @@ private constructor( return true } - return /* spotless:off */ other is FunctionCall && auto == other.auto && none == other.none && function == other.function /* spotless:on */ + return /* spotless:off */ other is FunctionCall && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, none, function) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, function) /* spotless:on */ override fun toString(): String = when { - auto != null -> "FunctionCall{auto=$auto}" - none != null -> "FunctionCall{none=$none}" + unionMember0 != null -> "FunctionCall{unionMember0=$unionMember0}" function != null -> "FunctionCall{function=$function}" _json != null -> "FunctionCall{_unknown=$_json}" else -> throw IllegalStateException("Invalid FunctionCall") @@ -651,37 +736,46 @@ private constructor( companion object { - @JvmStatic fun ofAuto(auto: Auto) = FunctionCall(auto = auto) - - @JvmStatic fun ofNone(none: None) = FunctionCall(none = none) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + FunctionCall(unionMember0 = unionMember0) @JvmStatic fun ofFunction(function: Function) = FunctionCall(function = function) } + /** + * An interface that defines how to map each variant of [FunctionCall] to a value of + * type [T]. + */ interface Visitor { - fun visitAuto(auto: Auto): T - - fun visitNone(none: None): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitFunction(function: Function): T + /** + * Maps an unknown variant of [FunctionCall] to a value of type [T]. + * + * An instance of [FunctionCall] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } - class Deserializer : BaseDeserializer(FunctionCall::class) { + internal class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(auto = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(none = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(unionMember0 = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -692,7 +786,7 @@ private constructor( } } - class Serializer : BaseSerializer(FunctionCall::class) { + internal class Serializer : BaseSerializer(FunctionCall::class) { override fun serialize( value: FunctionCall, @@ -700,8 +794,7 @@ private constructor( provider: SerializerProvider ) { when { - value.auto != null -> generator.writeObject(value.auto) - value.none != null -> generator.writeObject(value.none) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) value.function != null -> generator.writeObject(value.function) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid FunctionCall") @@ -709,133 +802,133 @@ private constructor( } } - class Auto + class UnionMember0 @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Auto && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val AUTO = Auto(JsonField.of("auto")) + @JvmField val AUTO = of("auto") + + @JvmField val NONE = of("none") - @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) + @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) } + /** An enum containing [UnionMember0]'s known values. */ enum class Known { AUTO, + NONE, } + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [UnionMember0] 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 { AUTO, + NONE, + /** + * An enum member indicating that [UnionMember0] 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) { AUTO -> Value.AUTO + NONE -> Value.NONE 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) { AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown Auto: $value") + NONE -> Known.NONE + else -> + throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } fun asString(): String = _value().asStringOrThrow() - } - - class None - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is None && value == other.value /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = None(JsonField.of("none")) - - @JvmStatic fun of(value: String) = None(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown None: $value") - } - - fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function + @JsonCreator private constructor( - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun name(): String = name.getRequired("name") - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -845,40 +938,50 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Function]. */ + class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) + name = function.name + additionalProperties = function.additionalProperties.toMutableMap() } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = Function(name, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Function = + Function( + checkRequired("name", name), + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -911,8 +1014,6 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun jsonObject(): Optional = Optional.ofNullable(jsonObject) fun jsonSchema(): Optional = Optional.ofNullable(jsonSchema) @@ -951,22 +1052,33 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): ResponseFormat = apply { - if (!validated) { - if ( - jsonObject == null && - jsonSchema == null && - text == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown ResponseFormat: $_json") - } - jsonObject?.validate() - jsonSchema?.validate() - text?.validate() - nullableVariant?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitJsonObject(jsonObject: JsonObject) { + jsonObject.validate() + } + + override fun visitJsonSchema(jsonSchema: JsonSchema) { + jsonSchema.validate() + } + + override fun visitText(text: Text) { + text.validate() + } + + override fun visitNullableVariant(nullableVariant: NullableVariant) { + nullableVariant.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -1007,6 +1119,10 @@ private constructor( ResponseFormat(nullableVariant = nullableVariant) } + /** + * An interface that defines how to map each variant of [ResponseFormat] to a value + * of type [T]. + */ interface Visitor { fun visitJsonObject(jsonObject: JsonObject): T @@ -1017,12 +1133,23 @@ private constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T + /** + * Maps an unknown variant of [ResponseFormat] to a value of type [T]. + * + * An instance of [ResponseFormat] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") } } - class Deserializer : BaseDeserializer(ResponseFormat::class) { + internal class Deserializer : + BaseDeserializer(ResponseFormat::class) { override fun ObjectCodec.deserialize(node: JsonNode): ResponseFormat { val json = JsonValue.fromJsonNode(node) @@ -1048,7 +1175,7 @@ private constructor( } } - class Serializer : BaseSerializer(ResponseFormat::class) { + internal class Serializer : BaseSerializer(ResponseFormat::class) { override fun serialize( value: ResponseFormat, @@ -1067,29 +1194,34 @@ private constructor( } } - @JsonDeserialize(builder = JsonObject.Builder::class) @NoAutoDetect class JsonObject + @JsonCreator private constructor( - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): JsonObject = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1099,41 +1231,50 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [JsonObject]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(jsonObject: JsonObject) = apply { - this.type = jsonObject.type - additionalProperties(jsonObject.additionalProperties) + type = jsonObject.type + additionalProperties = jsonObject.additionalProperties.toMutableMap() } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): JsonObject = - JsonObject(type, additionalProperties.toImmutable()) + JsonObject( + checkRequired("type", type), + additionalProperties.toImmutable() + ) } class Type @@ -1142,43 +1283,70 @@ 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 - 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() - companion object { - @JvmField val JSON_OBJECT = Type(JsonField.of("json_object")) + @JvmField val JSON_OBJECT = of("json_object") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { JSON_OBJECT, } + /** + * 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 { JSON_OBJECT, + /** + * 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) { JSON_OBJECT -> Value.JSON_OBJECT 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) { JSON_OBJECT -> Known.JSON_OBJECT @@ -1186,6 +1354,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1206,35 +1386,44 @@ private constructor( "JsonObject{type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = JsonSchema.Builder::class) @NoAutoDetect class JsonSchema + @JsonCreator private constructor( - private val type: JsonField, - private val jsonSchema: JsonField, - private val additionalProperties: Map, + @JsonProperty("json_schema") + @ExcludeMissing + private val jsonSchema: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun jsonSchema(): InnerJsonSchema = jsonSchema.getRequired("json_schema") fun type(): Type = type.getRequired("type") - fun jsonSchema(): JsonSchema = jsonSchema.getRequired("json_schema") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("json_schema") + @ExcludeMissing + fun _jsonSchema(): JsonField = jsonSchema - @JsonProperty("json_schema") @ExcludeMissing fun _jsonSchema() = jsonSchema + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): JsonSchema = apply { - if (!validated) { - type() - jsonSchema().validate() - validated = true + if (validated) { + return@apply } + + jsonSchema().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1244,71 +1433,83 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [JsonSchema]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var jsonSchema: JsonField = JsonMissing.of() + private var jsonSchema: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(jsonSchema: JsonSchema) = apply { - this.type = jsonSchema.type this.jsonSchema = jsonSchema.jsonSchema - additionalProperties(jsonSchema.additionalProperties) + type = jsonSchema.type + additionalProperties = jsonSchema.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun jsonSchema(jsonSchema: JsonSchema) = + fun jsonSchema(jsonSchema: InnerJsonSchema) = jsonSchema(JsonField.of(jsonSchema)) - @JsonProperty("json_schema") - @ExcludeMissing - fun jsonSchema(jsonSchema: JsonField) = apply { + fun jsonSchema(jsonSchema: JsonField) = apply { this.jsonSchema = jsonSchema } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): JsonSchema = JsonSchema( - type, - jsonSchema, + checkRequired("jsonSchema", jsonSchema), + checkRequired("type", type), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = JsonSchema.Builder::class) @NoAutoDetect - class JsonSchema + class InnerJsonSchema + @JsonCreator private constructor( - private val name: JsonField, - private val description: JsonField, - private val schema: JsonField, - private val strict: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("schema") + @ExcludeMissing + private val schema: JsonField = JsonMissing.of(), + @JsonProperty("strict") + @ExcludeMissing + private val strict: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun name(): String = name.getRequired("name") fun description(): Optional = @@ -1320,28 +1521,36 @@ private constructor( fun strict(): Optional = Optional.ofNullable(strict.getNullable("strict")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("description") @ExcludeMissing - fun _description() = description + fun _description(): JsonField = description - @JsonProperty("schema") @ExcludeMissing fun _schema() = schema + @JsonProperty("schema") + @ExcludeMissing + fun _schema(): JsonField = schema - @JsonProperty("strict") @ExcludeMissing fun _strict() = strict + @JsonProperty("strict") + @ExcludeMissing + fun _strict(): JsonField = strict @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): JsonSchema = apply { - if (!validated) { - name() - description() - schema().map { it.validate() } - strict() - validated = true + private var validated: Boolean = false + + fun validate(): InnerJsonSchema = apply { + if (validated) { + return@apply } + + name() + description() + schema().ifPresent { it.validate() } + strict() + validated = true } fun toBuilder() = Builder().from(this) @@ -1351,9 +1560,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InnerJsonSchema]. */ + class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null private var description: JsonField = JsonMissing.of() private var schema: JsonField = JsonMissing.of() private var strict: JsonField = JsonMissing.of() @@ -1361,59 +1571,67 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(jsonSchema: JsonSchema) = apply { - this.name = jsonSchema.name - this.description = jsonSchema.description - this.schema = jsonSchema.schema - this.strict = jsonSchema.strict - additionalProperties(jsonSchema.additionalProperties) + internal fun from(innerJsonSchema: InnerJsonSchema) = apply { + name = innerJsonSchema.name + description = innerJsonSchema.description + schema = innerJsonSchema.schema + strict = innerJsonSchema.strict + additionalProperties = + innerJsonSchema.additionalProperties.toMutableMap() } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun description(description: String) = description(JsonField.of(description)) - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } fun schema(schema: Schema) = schema(JsonField.of(schema)) - @JsonProperty("schema") - @ExcludeMissing fun schema(schema: JsonField) = apply { this.schema = schema } - fun strict(strict: Boolean) = strict(JsonField.of(strict)) + fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict)) + + fun strict(strict: Boolean) = strict(strict as Boolean?) + + @Suppress( + "USELESS_CAST" + ) // See https://youtrack.jetbrains.com/issue/KT-74228 + fun strict(strict: Optional) = + strict(strict.orElse(null) as Boolean?) - @JsonProperty("strict") - @ExcludeMissing fun strict(strict: JsonField) = apply { this.strict = strict } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): JsonSchema = - JsonSchema( - name, + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): InnerJsonSchema = + InnerJsonSchema( + checkRequired("name", name), description, schema, strict, @@ -1421,24 +1639,28 @@ private constructor( ) } - @JsonDeserialize(builder = Schema.Builder::class) @NoAutoDetect class Schema + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Schema = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1448,32 +1670,41 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Schema]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(schema: Schema) = apply { - additionalProperties(schema.additionalProperties) + additionalProperties = + schema.additionalProperties.toMutableMap() } fun additionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Schema = Schema(additionalProperties.toImmutable()) } @@ -1500,7 +1731,7 @@ private constructor( return true } - return /* spotless:off */ other is JsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InnerJsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1510,7 +1741,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "JsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" + "InnerJsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" } class Type @@ -1519,43 +1750,70 @@ 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 - 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() - companion object { - @JvmField val JSON_SCHEMA = Type(JsonField.of("json_schema")) + @JvmField val JSON_SCHEMA = of("json_schema") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { JSON_SCHEMA, } + /** + * 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 { JSON_SCHEMA, + /** + * 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) { JSON_SCHEMA -> Value.JSON_SCHEMA 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) { JSON_SCHEMA -> Known.JSON_SCHEMA @@ -1563,6 +1821,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1570,42 +1840,47 @@ private constructor( return true } - return /* spotless:off */ other is JsonSchema && type == other.type && jsonSchema == other.jsonSchema && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonSchema && jsonSchema == other.jsonSchema && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, jsonSchema, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(jsonSchema, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "JsonSchema{type=$type, jsonSchema=$jsonSchema, additionalProperties=$additionalProperties}" + "JsonSchema{jsonSchema=$jsonSchema, type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect class Text + @JsonCreator private constructor( - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Text = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1615,40 +1890,47 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Text]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(text: Text) = apply { - this.type = text.type - additionalProperties(text.additionalProperties) + type = text.type + additionalProperties = text.additionalProperties.toMutableMap() } fun type(type: Type) = type(JsonField.of(type)) - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Text = Text(type, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Text = + Text(checkRequired("type", type), additionalProperties.toImmutable()) } class Type @@ -1657,43 +1939,70 @@ 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 - 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() - companion object { - @JvmField val TEXT = Type(JsonField.of("text")) + @JvmField val TEXT = of("text") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { TEXT, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { TEXT, + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ fun value(): Value = when (this) { TEXT -> Value.TEXT else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. + */ fun known(): Known = when (this) { TEXT -> Known.TEXT @@ -1701,6 +2010,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1721,23 +2042,26 @@ private constructor( "Text{type=$type, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect class NullableVariant + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): NullableVariant = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -1747,31 +2071,40 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [NullableVariant]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) + additionalProperties = + nullableVariant.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } @@ -1799,36 +2132,20 @@ private constructor( @JsonSerialize(using = ToolChoice.Serializer::class) class ToolChoice private constructor( - private val auto: Auto? = null, - private val none: None? = null, - private val required: Required? = null, + private val unionMember0: UnionMember0? = null, private val function: Function? = null, private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - - fun auto(): Optional = Optional.ofNullable(auto) - - fun none(): Optional = Optional.ofNullable(none) - - fun required(): Optional = Optional.ofNullable(required) + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) fun function(): Optional = Optional.ofNullable(function) - fun isAuto(): Boolean = auto != null - - fun isNone(): Boolean = none != null - - fun isRequired(): Boolean = required != null + fun isUnionMember0(): Boolean = unionMember0 != null fun isFunction(): Boolean = function != null - fun asAuto(): Auto = auto.getOrThrow("auto") - - fun asNone(): None = none.getOrThrow("none") - - fun asRequired(): Required = required.getOrThrow("required") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") fun asFunction(): Function = function.getOrThrow("function") @@ -1836,22 +2153,29 @@ private constructor( fun accept(visitor: Visitor): T { return when { - auto != null -> visitor.visitAuto(auto) - none != null -> visitor.visitNone(none) - required != null -> visitor.visitRequired(required) + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) function != null -> visitor.visitFunction(function) else -> visitor.unknown(_json) } } + private var validated: Boolean = false + fun validate(): ToolChoice = apply { - if (!validated) { - if (auto == null && none == null && required == null && function == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - function?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) {} + + override fun visitFunction(function: Function) { + function.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -1859,16 +2183,14 @@ private constructor( return true } - return /* spotless:off */ other is ToolChoice && auto == other.auto && none == other.none && required == other.required && function == other.function /* spotless:on */ + return /* spotless:off */ other is ToolChoice && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(auto, none, required, function) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, function) /* spotless:on */ override fun toString(): String = when { - auto != null -> "ToolChoice{auto=$auto}" - none != null -> "ToolChoice{none=$none}" - required != null -> "ToolChoice{required=$required}" + unionMember0 != null -> "ToolChoice{unionMember0=$unionMember0}" function != null -> "ToolChoice{function=$function}" _json != null -> "ToolChoice{_unknown=$_json}" else -> throw IllegalStateException("Invalid ToolChoice") @@ -1876,43 +2198,45 @@ private constructor( companion object { - @JvmStatic fun ofAuto(auto: Auto) = ToolChoice(auto = auto) - - @JvmStatic fun ofNone(none: None) = ToolChoice(none = none) - - @JvmStatic fun ofRequired(required: Required) = ToolChoice(required = required) + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + ToolChoice(unionMember0 = unionMember0) @JvmStatic fun ofFunction(function: Function) = ToolChoice(function = function) } + /** + * An interface that defines how to map each variant of [ToolChoice] to a value of + * type [T]. + */ interface Visitor { - fun visitAuto(auto: Auto): T - - fun visitNone(none: None): T - - fun visitRequired(required: Required): T + fun visitUnionMember0(unionMember0: UnionMember0): T fun visitFunction(function: Function): T + /** + * Maps an unknown variant of [ToolChoice] to a value of type [T]. + * + * An instance of [ToolChoice] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } - class Deserializer : BaseDeserializer(ToolChoice::class) { + internal class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(auto = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(none = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(required = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(unionMember0 = it, _json = json) } tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { @@ -1923,7 +2247,7 @@ private constructor( } } - class Serializer : BaseSerializer(ToolChoice::class) { + internal class Serializer : BaseSerializer(ToolChoice::class) { override fun serialize( value: ToolChoice, @@ -1931,9 +2255,7 @@ private constructor( provider: SerializerProvider ) { when { - value.auto != null -> generator.writeObject(value.auto) - value.none != null -> generator.writeObject(value.none) - value.required != null -> generator.writeObject(value.required) + value.unionMember0 != null -> generator.writeObject(value.unionMember0) value.function != null -> generator.writeObject(value.function) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ToolChoice") @@ -1941,191 +2263,149 @@ private constructor( } } - class Auto + class UnionMember0 @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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Auto && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() + companion object { - override fun toString() = value.toString() + @JvmField val AUTO = of("auto") - companion object { + @JvmField val NONE = of("none") - @JvmField val AUTO = Auto(JsonField.of("auto")) + @JvmField val REQUIRED = of("required") - @JvmStatic fun of(value: String) = Auto(JsonField.of(value)) + @JvmStatic fun of(value: String) = UnionMember0(JsonField.of(value)) } + /** An enum containing [UnionMember0]'s known values. */ enum class Known { AUTO, + NONE, + REQUIRED, } + /** + * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [UnionMember0] 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 { AUTO, + NONE, + REQUIRED, + /** + * An enum member indicating that [UnionMember0] 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) { AUTO -> Value.AUTO + NONE -> Value.NONE + REQUIRED -> Value.REQUIRED 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) { AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown Auto: $value") + NONE -> Known.NONE + REQUIRED -> Known.REQUIRED + else -> + throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } fun asString(): String = _value().asStringOrThrow() - } - - class None - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is None && value == other.value /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() override fun toString() = value.toString() - - companion object { - - @JvmField val NONE = None(JsonField.of("none")) - - @JvmStatic fun of(value: String) = None(JsonField.of(value)) - } - - enum class Known { - NONE, - } - - enum class Value { - NONE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown None: $value") - } - - fun asString(): String = _value().asStringOrThrow() } - class Required - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Required && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - @JvmField val REQUIRED = Required(JsonField.of("required")) - - @JvmStatic fun of(value: String) = Required(JsonField.of(value)) - } - - enum class Known { - REQUIRED, - } - - enum class Value { - REQUIRED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - REQUIRED -> Value.REQUIRED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - REQUIRED -> Known.REQUIRED - else -> throw BraintrustInvalidDataException("Unknown Required: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect class Function + @JsonCreator private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, + @JsonProperty("function") + @ExcludeMissing + private val function: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + fun function(): InnerFunction = function.getRequired("function") fun type(): Type = type.getRequired("type") - fun function(): Function = function.getRequired("function") - - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("function") + @ExcludeMissing + fun _function(): JsonField = function - @JsonProperty("function") @ExcludeMissing fun _function() = function + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Function = apply { - if (!validated) { - type() - function().validate() - validated = true + if (validated) { + return@apply } + + function().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -2135,80 +2415,90 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Function]. */ + class Builder internal constructor() { - private var type: JsonField = JsonMissing.of() - private var function: JsonField = JsonMissing.of() + private var function: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(function: Function) = apply { - this.type = function.type this.function = function.function - additionalProperties(function.additionalProperties) + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() } - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun function(function: Function) = function(JsonField.of(function)) + fun function(function: InnerFunction) = function(JsonField.of(function)) - @JsonProperty("function") - @ExcludeMissing - fun function(function: JsonField) = apply { + fun function(function: JsonField) = apply { this.function = function } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Function = Function( - type, - function, + checkRequired("function", function), + checkRequired("type", type), additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function + class InnerFunction + @JsonCreator private constructor( - private val name: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { - private var validated: Boolean = false - fun name(): String = name.getRequired("name") - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): Function = apply { - if (!validated) { - name() - validated = true + private var validated: Boolean = false + + fun validate(): InnerFunction = apply { + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -2218,41 +2508,51 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [InnerFunction]. */ + class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - this.name = function.name - additionalProperties(function.additionalProperties) + internal fun from(innerFunction: InnerFunction) = apply { + name = innerFunction.name + additionalProperties = + innerFunction.additionalProperties.toMutableMap() } fun name(name: String) = name(JsonField.of(name)) - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties( additionalProperties: Map ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = - Function(name, additionalProperties.toImmutable()) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): InnerFunction = + InnerFunction( + checkRequired("name", name), + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -2260,7 +2560,7 @@ private constructor( return true } - return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InnerFunction && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2270,7 +2570,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" + "InnerFunction{name=$name, additionalProperties=$additionalProperties}" } class Type @@ -2279,43 +2579,70 @@ 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 - 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() - companion object { - @JvmField val FUNCTION = Type(JsonField.of("function")) + @JvmField val FUNCTION = of("function") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { FUNCTION, } + /** + * 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 { FUNCTION, + /** + * 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) { 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) { FUNCTION -> Known.FUNCTION @@ -2323,6 +2650,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -2330,17 +2669,17 @@ private constructor( return true } - return /* spotless:off */ other is Function && type == other.type && function == other.function && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, function, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(function, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" + "Function{function=$function, type=$type, additionalProperties=$additionalProperties}" } } @@ -2349,85 +2688,110 @@ private constructor( return true } - return /* spotless:off */ other is OpenAIModelParams && useCache == other.useCache && temperature == other.temperature && topP == other.topP && maxTokens == other.maxTokens && frequencyPenalty == other.frequencyPenalty && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && toolChoice == other.toolChoice && functionCall == other.functionCall && n == other.n && stop == other.stop && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(useCache, temperature, topP, maxTokens, frequencyPenalty, presencePenalty, responseFormat, toolChoice, functionCall, n, stop, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(frequencyPenalty, functionCall, maxTokens, n, presencePenalty, responseFormat, stop, temperature, toolChoice, topP, useCache, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect class AnthropicModelParams + @JsonCreator private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, + @JsonProperty("max_tokens") + @ExcludeMissing + private val maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens_to_sample") + @ExcludeMissing + private val maxTokensToSample: JsonField = JsonMissing.of(), + @JsonProperty("stop_sequences") + @ExcludeMissing + private val stopSequences: JsonField> = JsonMissing.of(), + @JsonProperty("top_k") + @ExcludeMissing + private val topK: JsonField = JsonMissing.of(), + @JsonProperty("top_p") + @ExcludeMissing + private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - fun maxTokens(): Double = maxTokens.getRequired("max_tokens") fun temperature(): Double = temperature.getRequired("temperature") - fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - - fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) - /** This is a legacy parameter that should not be used. */ fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens + fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK + @JsonProperty("max_tokens") + @ExcludeMissing + fun _maxTokens(): JsonField = maxTokens - @JsonProperty("stop_sequences") @ExcludeMissing fun _stopSequences() = stopSequences + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature(): JsonField = temperature /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @ExcludeMissing - fun _maxTokensToSample() = maxTokensToSample + fun _maxTokensToSample(): JsonField = maxTokensToSample + + @JsonProperty("stop_sequences") + @ExcludeMissing + fun _stopSequences(): JsonField> = stopSequences + + @JsonProperty("top_k") @ExcludeMissing fun _topK(): JsonField = topK + + @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache(): JsonField = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): AnthropicModelParams = apply { - if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + if (validated) { + return@apply } + + maxTokens() + temperature() + maxTokensToSample() + stopSequences() + topK() + topP() + useCache() + validated = true } fun toBuilder() = Builder().from(this) @@ -2437,89 +2801,88 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AnthropicModelParams]. */ + class Builder internal constructor() { - private var useCache: JsonField = JsonMissing.of() - private var maxTokens: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() - private var topK: JsonField = JsonMissing.of() - private var stopSequences: JsonField> = JsonMissing.of() + private var maxTokens: JsonField? = null + private var temperature: JsonField? = null private var maxTokensToSample: JsonField = JsonMissing.of() + private var stopSequences: JsonField>? = null + private var topK: JsonField = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var useCache: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(anthropicModelParams: AnthropicModelParams) = apply { - this.useCache = anthropicModelParams.useCache - this.maxTokens = anthropicModelParams.maxTokens - this.temperature = anthropicModelParams.temperature - this.topP = anthropicModelParams.topP - this.topK = anthropicModelParams.topK - this.stopSequences = anthropicModelParams.stopSequences - this.maxTokensToSample = anthropicModelParams.maxTokensToSample - additionalProperties(anthropicModelParams.additionalProperties) + maxTokens = anthropicModelParams.maxTokens + temperature = anthropicModelParams.temperature + maxTokensToSample = anthropicModelParams.maxTokensToSample + stopSequences = anthropicModelParams.stopSequences.map { it.toMutableList() } + topK = anthropicModelParams.topK + topP = anthropicModelParams.topP + useCache = anthropicModelParams.useCache + additionalProperties = anthropicModelParams.additionalProperties.toMutableMap() } - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - @JsonProperty("max_tokens") - @ExcludeMissing fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - @JsonProperty("temperature") - @ExcludeMissing fun temperature(temperature: JsonField) = apply { this.temperature = temperature } - fun topP(topP: Double) = topP(JsonField.of(topP)) - - @JsonProperty("top_p") - @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } - - fun topK(topK: Double) = topK(JsonField.of(topK)) + /** This is a legacy parameter that should not be used. */ + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) - @JsonProperty("top_k") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } + /** This is a legacy parameter that should not be used. */ + fun maxTokensToSample(maxTokensToSample: JsonField) = apply { + this.maxTokensToSample = maxTokensToSample + } fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) - @JsonProperty("stop_sequences") - @ExcludeMissing fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences + this.stopSequences = stopSequences.map { it.toMutableList() } } - /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) - - /** This is a legacy parameter that should not be used. */ - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample + fun addStopSequence(stopSequence: String) = apply { + stopSequences = + (stopSequences ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(stopSequence) + } } + fun topK(topK: Double) = topK(JsonField.of(topK)) + + fun topK(topK: JsonField) = apply { this.topK = topK } + + fun topP(topP: Double) = topP(JsonField.of(topP)) + + fun topP(topP: JsonField) = apply { this.topP = topP } + + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2527,15 +2890,23 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AnthropicModelParams = AnthropicModelParams( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toImmutable() }, + checkRequired("maxTokens", maxTokens), + checkRequired("temperature", temperature), maxTokensToSample, + (stopSequences ?: JsonMissing.of()).map { it.toImmutable() }, + topK, + topP, + useCache, additionalProperties.toImmutable(), ) } @@ -2545,71 +2916,88 @@ private constructor( return true } - return /* spotless:off */ other is AnthropicModelParams && useCache == other.useCache && maxTokens == other.maxTokens && temperature == other.temperature && topP == other.topP && topK == other.topK && stopSequences == other.stopSequences && maxTokensToSample == other.maxTokensToSample && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AnthropicModelParams && maxTokens == other.maxTokens && temperature == other.temperature && maxTokensToSample == other.maxTokensToSample && stopSequences == other.stopSequences && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(useCache, maxTokens, temperature, topP, topK, stopSequences, maxTokensToSample, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(maxTokens, temperature, maxTokensToSample, stopSequences, topK, topP, useCache, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + "AnthropicModelParams{maxTokens=$maxTokens, temperature=$temperature, maxTokensToSample=$maxTokensToSample, stopSequences=$stopSequences, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect class GoogleModelParams + @JsonCreator private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, + @JsonProperty("maxOutputTokens") + @ExcludeMissing + private val maxOutputTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("topK") + @ExcludeMissing + private val topK: JsonField = JsonMissing.of(), + @JsonProperty("topP") + @ExcludeMissing + private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("maxOutputTokens") @ExcludeMissing - fun _maxOutputTokens() = maxOutputTokens + fun _maxOutputTokens(): JsonField = maxOutputTokens + + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature(): JsonField = temperature - @JsonProperty("topP") @ExcludeMissing fun _topP() = topP + @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK + @JsonProperty("topP") @ExcludeMissing fun _topP(): JsonField = topP + + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache(): JsonField = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): GoogleModelParams = apply { - if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + if (validated) { + return@apply } + + maxOutputTokens() + temperature() + topK() + topP() + useCache() + validated = true } fun toBuilder() = Builder().from(this) @@ -2619,68 +3007,58 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [GoogleModelParams]. */ + class Builder internal constructor() { - private var useCache: JsonField = JsonMissing.of() - private var temperature: JsonField = JsonMissing.of() private var maxOutputTokens: JsonField = JsonMissing.of() - private var topP: JsonField = JsonMissing.of() + private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() + private var topP: JsonField = JsonMissing.of() + private var useCache: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(googleModelParams: GoogleModelParams) = apply { - this.useCache = googleModelParams.useCache - this.temperature = googleModelParams.temperature - this.maxOutputTokens = googleModelParams.maxOutputTokens - this.topP = googleModelParams.topP - this.topK = googleModelParams.topK - additionalProperties(googleModelParams.additionalProperties) + maxOutputTokens = googleModelParams.maxOutputTokens + temperature = googleModelParams.temperature + topK = googleModelParams.topK + topP = googleModelParams.topP + useCache = googleModelParams.useCache + additionalProperties = googleModelParams.additionalProperties.toMutableMap() } - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun maxOutputTokens(maxOutputTokens: JsonField) = apply { + this.maxOutputTokens = maxOutputTokens + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - @JsonProperty("temperature") - @ExcludeMissing fun temperature(temperature: JsonField) = apply { this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) + fun topK(topK: Double) = topK(JsonField.of(topK)) - @JsonProperty("maxOutputTokens") - @ExcludeMissing - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } + fun topK(topK: JsonField) = apply { this.topK = topK } fun topP(topP: Double) = topP(JsonField.of(topP)) - @JsonProperty("topP") - @ExcludeMissing fun topP(topP: JsonField) = apply { this.topP = topP } - fun topK(topK: Double) = topK(JsonField.of(topK)) + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - @JsonProperty("topK") - @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2688,13 +3066,21 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): GoogleModelParams = GoogleModelParams( - useCache, - temperature, maxOutputTokens, - topP, + temperature, topK, + topP, + useCache, additionalProperties.toImmutable(), ) } @@ -2704,56 +3090,69 @@ private constructor( return true } - return /* spotless:off */ other is GoogleModelParams && useCache == other.useCache && temperature == other.temperature && maxOutputTokens == other.maxOutputTokens && topP == other.topP && topK == other.topK && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GoogleModelParams && maxOutputTokens == other.maxOutputTokens && temperature == other.temperature && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(useCache, temperature, maxOutputTokens, topP, topK, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(maxOutputTokens, temperature, topK, topP, useCache, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + "GoogleModelParams{maxOutputTokens=$maxOutputTokens, temperature=$temperature, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect class WindowAiModelParams + @JsonCreator private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, + @JsonProperty("temperature") + @ExcludeMissing + private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("topK") + @ExcludeMissing + private val topK: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature(): JsonField = temperature - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK + @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK + + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache(): JsonField = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): WindowAiModelParams = apply { - if (!validated) { - useCache() - temperature() - topK() - validated = true + if (validated) { + return@apply } + + temperature() + topK() + useCache() + validated = true } fun toBuilder() = Builder().from(this) @@ -2763,49 +3162,43 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [WindowAiModelParams]. */ + class Builder internal constructor() { - private var useCache: JsonField = JsonMissing.of() private var temperature: JsonField = JsonMissing.of() private var topK: JsonField = JsonMissing.of() + private var useCache: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(windowAiModelParams: WindowAiModelParams) = apply { - this.useCache = windowAiModelParams.useCache - this.temperature = windowAiModelParams.temperature - this.topK = windowAiModelParams.topK - additionalProperties(windowAiModelParams.additionalProperties) + temperature = windowAiModelParams.temperature + topK = windowAiModelParams.topK + useCache = windowAiModelParams.useCache + additionalProperties = windowAiModelParams.additionalProperties.toMutableMap() } - fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - - @JsonProperty("use_cache") - @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - @JsonProperty("temperature") - @ExcludeMissing fun temperature(temperature: JsonField) = apply { this.temperature = temperature } fun topK(topK: Double) = topK(JsonField.of(topK)) - @JsonProperty("topK") - @ExcludeMissing fun topK(topK: JsonField) = apply { this.topK = topK } + fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2813,11 +3206,19 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): WindowAiModelParams = WindowAiModelParams( - useCache, temperature, topK, + useCache, additionalProperties.toImmutable(), ) } @@ -2827,43 +3228,50 @@ private constructor( return true } - return /* spotless:off */ other is WindowAiModelParams && useCache == other.useCache && temperature == other.temperature && topK == other.topK && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is WindowAiModelParams && temperature == other.temperature && topK == other.topK && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(useCache, temperature, topK, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(temperature, topK, useCache, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + "WindowAiModelParams{temperature=$temperature, topK=$topK, useCache=$useCache, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect class JsCompletionParams + @JsonCreator private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache(): JsonField = useCache @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): JsCompletionParams = apply { - if (!validated) { - useCache() - validated = true + if (validated) { + return@apply } + + useCache() + validated = true } fun toBuilder() = Builder().from(this) @@ -2873,31 +3281,29 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [JsCompletionParams]. */ + class Builder internal constructor() { private var useCache: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(jsCompletionParams: JsCompletionParams) = apply { - this.useCache = jsCompletionParams.useCache - additionalProperties(jsCompletionParams.additionalProperties) + useCache = jsCompletionParams.useCache + additionalProperties = jsCompletionParams.additionalProperties.toMutableMap() } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - @JsonProperty("use_cache") - @ExcludeMissing fun useCache(useCache: JsonField) = apply { this.useCache = useCache } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -2905,6 +3311,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): JsCompletionParams = JsCompletionParams(useCache, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 262ddfc9..8ea32140 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -5,111 +5,185 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create or replace prompt. If there is an existing prompt in the project with the same slug as the + * one specified in the request, will replace the existing prompt with the provided fields + */ class PromptReplaceParams -constructor( - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val functionType: FunctionType?, - private val promptData: PromptData?, - private val tags: List?, +private constructor( + private val body: PromptReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the prompt */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = body.projectId() - fun slug(): String = slug + /** Unique identifier for the prompt */ + fun slug(): String = body.slug() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the prompt */ + fun description(): Optional = body.description() - fun functionType(): Optional = Optional.ofNullable(functionType) + fun functionType(): Optional = body.functionType() - fun promptData(): Optional = Optional.ofNullable(promptData) + /** The prompt, model, and its parameters */ + fun promptData(): Optional = body.promptData() - fun tags(): Optional> = Optional.ofNullable(tags) + /** A list of tags for the prompt */ + fun tags(): Optional> = body.tags() + + /** Name of the prompt */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the prompt belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** Unique identifier for the prompt */ + fun _slug(): JsonField = body._slug() + + /** Textual description of the prompt */ + fun _description(): JsonField = body._description() + + fun _functionType(): JsonField = body._functionType() + + /** The prompt, model, and its parameters */ + fun _promptData(): JsonField = body._promptData() + + /** A list of tags for the prompt */ + fun _tags(): JsonField> = body._tags() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): PromptReplaceBody { - return PromptReplaceBody( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): PromptReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = PromptReplaceBody.Builder::class) @NoAutoDetect class PromptReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val functionType: FunctionType?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(): String = projectId.getRequired("project_id") + + /** Unique identifier for the prompt */ + fun slug(): String = slug.getRequired("slug") + + /** Textual description of the prompt */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** Name of the prompt */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("function_type") fun functionType(): FunctionType? = functionType + @JsonProperty("function_type") + @ExcludeMissing + fun _functionType(): JsonField = functionType /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PromptReplaceBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + slug() + description() + functionType() + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -117,78 +191,133 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PromptReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var slug: String? = null - private var description: String? = null - private var functionType: FunctionType? = null - private var promptData: PromptData? = null - private var tags: List? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var functionType: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptReplaceBody: PromptReplaceBody) = apply { - this.name = promptReplaceBody.name - this.projectId = promptReplaceBody.projectId - this.slug = promptReplaceBody.slug - this.description = promptReplaceBody.description - this.functionType = promptReplaceBody.functionType - this.promptData = promptReplaceBody.promptData - this.tags = promptReplaceBody.tags - additionalProperties(promptReplaceBody.additionalProperties) + name = promptReplaceBody.name + projectId = promptReplaceBody.projectId + slug = promptReplaceBody.slug + description = promptReplaceBody.description + functionType = promptReplaceBody.functionType + promptData = promptReplaceBody.promptData + tags = promptReplaceBody.tags.map { it.toMutableList() } + additionalProperties = promptReplaceBody.additionalProperties.toMutableMap() } /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the prompt */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: JsonField) = apply { this.slug = slug } + + /** Textual description of the prompt */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the prompt */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } + + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - @JsonProperty("function_type") - fun functionType(functionType: FunctionType) = apply { + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) + + fun functionType(functionType: JsonField) = apply { this.functionType = functionType } /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } + + /** A list of tags for the prompt */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PromptReplaceBody = PromptReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("slug", slug), description, functionType, promptData, - tags?.toImmutable(), + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -218,59 +347,96 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [PromptReplaceParams]. */ @NoAutoDetect - class Builder { - - private var name: String? = null - private var projectId: String? = null - private var slug: String? = null - private var description: String? = null - private var functionType: FunctionType? = null - private var promptData: PromptData? = null - private var tags: MutableList = mutableListOf() + class Builder internal constructor() { + + private var body: PromptReplaceBody.Builder = PromptReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptReplaceParams: PromptReplaceParams) = apply { - name = promptReplaceParams.name - projectId = promptReplaceParams.projectId - slug = promptReplaceParams.slug - description = promptReplaceParams.description - functionType = promptReplaceParams.functionType - promptData = promptReplaceParams.promptData - tags = promptReplaceParams.tags?.toMutableList() ?: mutableListOf() + body = promptReplaceParams.body.toBuilder() additionalHeaders = promptReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = promptReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = promptReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the prompt */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the prompt belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + + /** Unique identifier for the prompt */ + fun slug(slug: String) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: JsonField) = apply { body.slug(slug) } + + /** Textual description of the prompt */ + fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the prompt */ + fun description(description: JsonField) = apply { body.description(description) } + + fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + + fun functionType(functionType: Optional) = + functionType(functionType.orElse(null)) - fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } + fun functionType(functionType: JsonField) = apply { + body.functionType(functionType) + } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List) = apply { - this.tags.clear() - this.tags.addAll(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -370,40 +536,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): PromptReplaceParams = PromptReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - promptData, - tags.toImmutable().ifEmpty { null }, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -413,33 +550,30 @@ 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 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val LLM = FunctionType(JsonField.of("llm")) + @JvmField val LLM = of("llm") - @JvmField val SCORER = FunctionType(JsonField.of("scorer")) + @JvmField val SCORER = of("scorer") - @JvmField val TASK = FunctionType(JsonField.of("task")) + @JvmField val TASK = of("task") - @JvmField val TOOL = FunctionType(JsonField.of("tool")) + @JvmField val TOOL = of("tool") @JvmStatic fun of(value: String) = FunctionType(JsonField.of(value)) } + /** An enum containing [FunctionType]'s known values. */ enum class Known { LLM, SCORER, @@ -447,14 +581,33 @@ constructor( TOOL, } + /** + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FunctionType] 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, SCORER, TASK, TOOL, + /** + * An enum member indicating that [FunctionType] 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 @@ -464,6 +617,15 @@ constructor( 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 @@ -474,6 +636,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -481,11 +655,11 @@ constructor( return true } - return /* spotless:off */ other is PromptReplaceParams && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, slug, description, functionType, promptData, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "PromptReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 0feb8a9e..9aac0566 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a prompt object by its id */ class PromptRetrieveParams -constructor( +private constructor( private val promptId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Prompt id */ fun promptId(): String = promptId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [PromptRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var promptId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): PromptRetrieveParams = PromptRetrieveParams( - checkNotNull(promptId) { "`promptId` is required but was not set" }, + checkRequired("promptId", promptId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index e75d265a..16359960 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -3,65 +3,80 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update a prompt object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. + */ class PromptUpdateParams -constructor( +private constructor( private val promptId: String, - private val description: String?, - private val name: String?, - private val promptData: PromptData?, - private val slug: String?, - private val tags: List?, + private val body: PromptUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Prompt id */ fun promptId(): String = promptId - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the prompt */ + fun description(): Optional = body.description() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the prompt */ + fun name(): Optional = body.name() - fun promptData(): Optional = Optional.ofNullable(promptData) + /** The prompt, model, and its parameters */ + fun promptData(): Optional = body.promptData() - fun slug(): Optional = Optional.ofNullable(slug) + /** Unique identifier for the prompt */ + fun slug(): Optional = body.slug() - fun tags(): Optional> = Optional.ofNullable(tags) + /** A list of tags for the prompt */ + fun tags(): Optional> = body.tags() + + /** Textual description of the prompt */ + fun _description(): JsonField = body._description() + + /** Name of the prompt */ + fun _name(): JsonField = body._name() + + /** The prompt, model, and its parameters */ + fun _promptData(): JsonField = body._promptData() + + /** Unique identifier for the prompt */ + fun _slug(): JsonField = body._slug() + + /** A list of tags for the prompt */ + fun _tags(): JsonField> = body._tags() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): PromptUpdateBody { - return PromptUpdateBody( - description, - name, - promptData, - slug, - tags, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): PromptUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -70,37 +85,84 @@ constructor( } } - @JsonDeserialize(builder = PromptUpdateBody.Builder::class) @NoAutoDetect class PromptUpdateBody + @JsonCreator internal constructor( - private val description: String?, - private val name: String?, - private val promptData: PromptData?, - private val slug: String?, - private val tags: List?, - private val additionalProperties: Map, + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the prompt */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** The prompt, model, and its parameters */ + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) + + /** Unique identifier for the prompt */ + fun slug(): Optional = Optional.ofNullable(slug.getNullable("slug")) + + /** A list of tags for the prompt */ + fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + + /** Textual description of the prompt */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData(): JsonField = promptData /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PromptUpdateBody = apply { + if (validated) { + return@apply + } + + description() + name() + promptData().ifPresent { it.validate() } + slug() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -108,63 +170,117 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PromptUpdateBody]. */ + class Builder internal constructor() { - private var description: String? = null - private var name: String? = null - private var promptData: PromptData? = null - private var slug: String? = null - private var tags: List? = null + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var promptData: JsonField = JsonMissing.of() + private var slug: JsonField = JsonMissing.of() + private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptUpdateBody: PromptUpdateBody) = apply { - this.description = promptUpdateBody.description - this.name = promptUpdateBody.name - this.promptData = promptUpdateBody.promptData - this.slug = promptUpdateBody.slug - this.tags = promptUpdateBody.tags - additionalProperties(promptUpdateBody.additionalProperties) + description = promptUpdateBody.description + name = promptUpdateBody.name + promptData = promptUpdateBody.promptData + slug = promptUpdateBody.slug + tags = promptUpdateBody.tags.map { it.toMutableList() } + additionalProperties = promptUpdateBody.additionalProperties.toMutableMap() } /** Textual description of the prompt */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the prompt */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** Name of the prompt */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the prompt */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } + + /** Unique identifier for the prompt */ + fun slug(slug: String?) = slug(JsonField.ofNullable(slug)) /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: Optional) = slug(slug.orElse(null)) + + /** Unique identifier for the prompt */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + /** A list of tags for the prompt */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** A list of tags for the prompt */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): PromptUpdateBody = PromptUpdateBody( description, name, promptData, slug, - tags?.toImmutable(), + (tags ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -194,55 +310,92 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [PromptUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var promptId: String? = null - private var description: String? = null - private var name: String? = null - private var promptData: PromptData? = null - private var slug: String? = null - private var tags: MutableList = mutableListOf() + private var body: PromptUpdateBody.Builder = PromptUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(promptUpdateParams: PromptUpdateParams) = apply { promptId = promptUpdateParams.promptId - description = promptUpdateParams.description - name = promptUpdateParams.name - promptData = promptUpdateParams.promptData - slug = promptUpdateParams.slug - tags = promptUpdateParams.tags?.toMutableList() ?: mutableListOf() + body = promptUpdateParams.body.toBuilder() additionalHeaders = promptUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = promptUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = promptUpdateParams.additionalBodyProperties.toMutableMap() } /** Prompt id */ fun promptId(promptId: String) = apply { this.promptId = promptId } /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the prompt */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the prompt */ + fun description(description: JsonField) = apply { body.description(description) } + + /** Name of the prompt */ + fun name(name: String?) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the prompt */ + fun name(name: JsonField) = apply { body.name(name) } + + /** The prompt, model, and its parameters */ + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + + /** The prompt, model, and its parameters */ + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + + /** Unique identifier for the prompt */ + fun slug(slug: String?) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: Optional) = slug(slug.orElse(null)) + + /** Unique identifier for the prompt */ + fun slug(slug: JsonField) = apply { body.slug(slug) } /** A list of tags for the prompt */ - fun tags(tags: List) = apply { - this.tags.clear() - this.tags.addAll(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun tags(tags: Optional>) = tags(tags.orElse(null)) + + /** A list of tags for the prompt */ + fun tags(tags: JsonField>) = apply { body.tags(tags) } + + /** A list of tags for the prompt */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -342,39 +495,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): PromptUpdateParams = PromptUpdateParams( - checkNotNull(promptId) { "`promptId` is required but was not set" }, - description, - name, - promptData, - slug, - tags.toImmutable().ifEmpty { null }, + checkRequired("promptId", promptId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -383,11 +509,11 @@ constructor( return true } - return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, description, name, promptData, slug, tags, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "PromptUpdateParams{promptId=$promptId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index c17cecde..e39fcb69 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -7,51 +7,58 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional /** Metadata about the state of the repo when the experiment was created */ -@JsonDeserialize(builder = RepoInfo.Builder::class) @NoAutoDetect class RepoInfo +@JsonCreator private constructor( - private val commit: JsonField, - private val branch: JsonField, - private val tag: JsonField, - private val dirty: JsonField, - private val authorName: JsonField, - private val authorEmail: JsonField, - private val commitMessage: JsonField, - private val commitTime: JsonField, - private val gitDiff: JsonField, - private val additionalProperties: Map, + @JsonProperty("author_email") + @ExcludeMissing + private val authorEmail: JsonField = JsonMissing.of(), + @JsonProperty("author_name") + @ExcludeMissing + private val authorName: JsonField = JsonMissing.of(), + @JsonProperty("branch") + @ExcludeMissing + private val branch: JsonField = JsonMissing.of(), + @JsonProperty("commit") + @ExcludeMissing + private val commit: JsonField = JsonMissing.of(), + @JsonProperty("commit_message") + @ExcludeMissing + private val commitMessage: JsonField = JsonMissing.of(), + @JsonProperty("commit_time") + @ExcludeMissing + private val commitTime: JsonField = JsonMissing.of(), + @JsonProperty("dirty") @ExcludeMissing private val dirty: JsonField = JsonMissing.of(), + @JsonProperty("git_diff") + @ExcludeMissing + private val gitDiff: JsonField = JsonMissing.of(), + @JsonProperty("tag") @ExcludeMissing private val tag: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Email of the author of the most recent commit */ + fun authorEmail(): Optional = + Optional.ofNullable(authorEmail.getNullable("author_email")) - /** SHA of most recent commit */ - fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) + /** Name of the author of the most recent commit */ + fun authorName(): Optional = Optional.ofNullable(authorName.getNullable("author_name")) /** Name of the branch the most recent commit belongs to */ fun branch(): Optional = Optional.ofNullable(branch.getNullable("branch")) - /** Name of the tag on the most recent commit */ - fun tag(): Optional = Optional.ofNullable(tag.getNullable("tag")) - - /** Whether or not the repo had uncommitted changes when snapshotted */ - fun dirty(): Optional = Optional.ofNullable(dirty.getNullable("dirty")) - - /** Name of the author of the most recent commit */ - fun authorName(): Optional = Optional.ofNullable(authorName.getNullable("author_name")) - - /** Email of the author of the most recent commit */ - fun authorEmail(): Optional = - Optional.ofNullable(authorEmail.getNullable("author_email")) + /** SHA of most recent commit */ + fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) /** Most recent commit message */ fun commitMessage(): Optional = @@ -60,59 +67,73 @@ private constructor( /** Time of the most recent commit */ fun commitTime(): Optional = Optional.ofNullable(commitTime.getNullable("commit_time")) + /** Whether or not the repo had uncommitted changes when snapshotted */ + fun dirty(): Optional = Optional.ofNullable(dirty.getNullable("dirty")) + /** * If the repo was dirty when run, this includes the diff between the current state of the repo * and the most recent commit. */ fun gitDiff(): Optional = Optional.ofNullable(gitDiff.getNullable("git_diff")) - /** SHA of most recent commit */ - @JsonProperty("commit") @ExcludeMissing fun _commit() = commit - - /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") @ExcludeMissing fun _branch() = branch - /** Name of the tag on the most recent commit */ - @JsonProperty("tag") @ExcludeMissing fun _tag() = tag + fun tag(): Optional = Optional.ofNullable(tag.getNullable("tag")) - /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") @ExcludeMissing fun _dirty() = dirty + /** Email of the author of the most recent commit */ + @JsonProperty("author_email") + @ExcludeMissing + fun _authorEmail(): JsonField = authorEmail /** Name of the author of the most recent commit */ - @JsonProperty("author_name") @ExcludeMissing fun _authorName() = authorName + @JsonProperty("author_name") @ExcludeMissing fun _authorName(): JsonField = authorName - /** Email of the author of the most recent commit */ - @JsonProperty("author_email") @ExcludeMissing fun _authorEmail() = authorEmail + /** Name of the branch the most recent commit belongs to */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** SHA of most recent commit */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit /** Most recent commit message */ - @JsonProperty("commit_message") @ExcludeMissing fun _commitMessage() = commitMessage + @JsonProperty("commit_message") + @ExcludeMissing + fun _commitMessage(): JsonField = commitMessage /** Time of the most recent commit */ - @JsonProperty("commit_time") @ExcludeMissing fun _commitTime() = commitTime + @JsonProperty("commit_time") @ExcludeMissing fun _commitTime(): JsonField = commitTime + + /** Whether or not the repo had uncommitted changes when snapshotted */ + @JsonProperty("dirty") @ExcludeMissing fun _dirty(): JsonField = dirty /** * If the repo was dirty when run, this includes the diff between the current state of the repo * and the most recent commit. */ - @JsonProperty("git_diff") @ExcludeMissing fun _gitDiff() = gitDiff + @JsonProperty("git_diff") @ExcludeMissing fun _gitDiff(): JsonField = gitDiff + + /** Name of the tag on the most recent commit */ + @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField = tag @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): RepoInfo = apply { - if (!validated) { - commit() - branch() - tag() - dirty() - authorName() - authorEmail() - commitMessage() - commitTime() - gitDiff() - validated = true + if (validated) { + return@apply } + + authorEmail() + authorName() + branch() + commit() + commitMessage() + commitTime() + dirty() + gitDiff() + tag() + validated = true } fun toBuilder() = Builder().from(this) @@ -122,138 +143,162 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RepoInfo]. */ + class Builder internal constructor() { - private var commit: JsonField = JsonMissing.of() - private var branch: JsonField = JsonMissing.of() - private var tag: JsonField = JsonMissing.of() - private var dirty: JsonField = JsonMissing.of() - private var authorName: JsonField = JsonMissing.of() private var authorEmail: JsonField = JsonMissing.of() + private var authorName: JsonField = JsonMissing.of() + private var branch: JsonField = JsonMissing.of() + private var commit: JsonField = JsonMissing.of() private var commitMessage: JsonField = JsonMissing.of() private var commitTime: JsonField = JsonMissing.of() + private var dirty: JsonField = JsonMissing.of() private var gitDiff: JsonField = JsonMissing.of() + private var tag: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(repoInfo: RepoInfo) = apply { - this.commit = repoInfo.commit - this.branch = repoInfo.branch - this.tag = repoInfo.tag - this.dirty = repoInfo.dirty - this.authorName = repoInfo.authorName - this.authorEmail = repoInfo.authorEmail - this.commitMessage = repoInfo.commitMessage - this.commitTime = repoInfo.commitTime - this.gitDiff = repoInfo.gitDiff - additionalProperties(repoInfo.additionalProperties) + authorEmail = repoInfo.authorEmail + authorName = repoInfo.authorName + branch = repoInfo.branch + commit = repoInfo.commit + commitMessage = repoInfo.commitMessage + commitTime = repoInfo.commitTime + dirty = repoInfo.dirty + gitDiff = repoInfo.gitDiff + tag = repoInfo.tag + additionalProperties = repoInfo.additionalProperties.toMutableMap() } - /** SHA of most recent commit */ - fun commit(commit: String) = commit(JsonField.of(commit)) + /** Email of the author of the most recent commit */ + fun authorEmail(authorEmail: String?) = authorEmail(JsonField.ofNullable(authorEmail)) - /** SHA of most recent commit */ - @JsonProperty("commit") - @ExcludeMissing - fun commit(commit: JsonField) = apply { this.commit = commit } + /** Email of the author of the most recent commit */ + fun authorEmail(authorEmail: Optional) = authorEmail(authorEmail.orElse(null)) - /** Name of the branch the most recent commit belongs to */ - fun branch(branch: String) = branch(JsonField.of(branch)) + /** Email of the author of the most recent commit */ + fun authorEmail(authorEmail: JsonField) = apply { this.authorEmail = authorEmail } - /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") - @ExcludeMissing - fun branch(branch: JsonField) = apply { this.branch = branch } + /** Name of the author of the most recent commit */ + fun authorName(authorName: String?) = authorName(JsonField.ofNullable(authorName)) - /** Name of the tag on the most recent commit */ - fun tag(tag: String) = tag(JsonField.of(tag)) + /** Name of the author of the most recent commit */ + fun authorName(authorName: Optional) = authorName(authorName.orElse(null)) - /** Name of the tag on the most recent commit */ - @JsonProperty("tag") - @ExcludeMissing - fun tag(tag: JsonField) = apply { this.tag = tag } + /** Name of the author of the most recent commit */ + fun authorName(authorName: JsonField) = apply { this.authorName = authorName } - /** Whether or not the repo had uncommitted changes when snapshotted */ - fun dirty(dirty: Boolean) = dirty(JsonField.of(dirty)) + /** Name of the branch the most recent commit belongs to */ + fun branch(branch: String?) = branch(JsonField.ofNullable(branch)) - /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") - @ExcludeMissing - fun dirty(dirty: JsonField) = apply { this.dirty = dirty } + /** Name of the branch the most recent commit belongs to */ + fun branch(branch: Optional) = branch(branch.orElse(null)) - /** Name of the author of the most recent commit */ - fun authorName(authorName: String) = authorName(JsonField.of(authorName)) + /** Name of the branch the most recent commit belongs to */ + fun branch(branch: JsonField) = apply { this.branch = branch } - /** Name of the author of the most recent commit */ - @JsonProperty("author_name") - @ExcludeMissing - fun authorName(authorName: JsonField) = apply { this.authorName = authorName } + /** SHA of most recent commit */ + fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) - /** Email of the author of the most recent commit */ - fun authorEmail(authorEmail: String) = authorEmail(JsonField.of(authorEmail)) + /** SHA of most recent commit */ + fun commit(commit: Optional) = commit(commit.orElse(null)) - /** Email of the author of the most recent commit */ - @JsonProperty("author_email") - @ExcludeMissing - fun authorEmail(authorEmail: JsonField) = apply { this.authorEmail = authorEmail } + /** SHA of most recent commit */ + fun commit(commit: JsonField) = apply { this.commit = commit } + + /** Most recent commit message */ + fun commitMessage(commitMessage: String?) = + commitMessage(JsonField.ofNullable(commitMessage)) /** Most recent commit message */ - fun commitMessage(commitMessage: String) = commitMessage(JsonField.of(commitMessage)) + fun commitMessage(commitMessage: Optional) = + commitMessage(commitMessage.orElse(null)) /** Most recent commit message */ - @JsonProperty("commit_message") - @ExcludeMissing fun commitMessage(commitMessage: JsonField) = apply { this.commitMessage = commitMessage } /** Time of the most recent commit */ - fun commitTime(commitTime: String) = commitTime(JsonField.of(commitTime)) + fun commitTime(commitTime: String?) = commitTime(JsonField.ofNullable(commitTime)) + + /** Time of the most recent commit */ + fun commitTime(commitTime: Optional) = commitTime(commitTime.orElse(null)) /** Time of the most recent commit */ - @JsonProperty("commit_time") - @ExcludeMissing fun commitTime(commitTime: JsonField) = apply { this.commitTime = commitTime } + /** Whether or not the repo had uncommitted changes when snapshotted */ + fun dirty(dirty: Boolean?) = dirty(JsonField.ofNullable(dirty)) + + /** Whether or not the repo had uncommitted changes when snapshotted */ + fun dirty(dirty: Boolean) = dirty(dirty as Boolean?) + + /** Whether or not the repo had uncommitted changes when snapshotted */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun dirty(dirty: Optional) = dirty(dirty.orElse(null) as Boolean?) + + /** Whether or not the repo had uncommitted changes when snapshotted */ + fun dirty(dirty: JsonField) = apply { this.dirty = dirty } + /** * If the repo was dirty when run, this includes the diff between the current state of the * repo and the most recent commit. */ - fun gitDiff(gitDiff: String) = gitDiff(JsonField.of(gitDiff)) + fun gitDiff(gitDiff: String?) = gitDiff(JsonField.ofNullable(gitDiff)) + + /** + * If the repo was dirty when run, this includes the diff between the current state of the + * repo and the most recent commit. + */ + fun gitDiff(gitDiff: Optional) = gitDiff(gitDiff.orElse(null)) /** * If the repo was dirty when run, this includes the diff between the current state of the * repo and the most recent commit. */ - @JsonProperty("git_diff") - @ExcludeMissing fun gitDiff(gitDiff: JsonField) = apply { this.gitDiff = gitDiff } + /** Name of the tag on the most recent commit */ + fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) + + /** Name of the tag on the most recent commit */ + fun tag(tag: Optional) = tag(tag.orElse(null)) + + /** Name of the tag on the most recent commit */ + fun tag(tag: JsonField) = apply { this.tag = tag } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RepoInfo = RepoInfo( - commit, - branch, - tag, - dirty, - authorName, authorEmail, + authorName, + branch, + commit, commitMessage, commitTime, + dirty, gitDiff, + tag, additionalProperties.toImmutable(), ) } @@ -263,15 +308,15 @@ private constructor( return true } - return /* spotless:off */ other is RepoInfo && commit == other.commit && branch == other.branch && tag == other.tag && dirty == other.dirty && authorName == other.authorName && authorEmail == other.authorEmail && commitMessage == other.commitMessage && commitTime == other.commitTime && gitDiff == other.gitDiff && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RepoInfo && authorEmail == other.authorEmail && authorName == other.authorName && branch == other.branch && commit == other.commit && commitMessage == other.commitMessage && commitTime == other.commitTime && dirty == other.dirty && gitDiff == other.gitDiff && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(commit, branch, tag, dirty, authorName, authorEmail, commitMessage, commitTime, gitDiff, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(authorEmail, authorName, branch, commit, commitMessage, commitTime, dirty, gitDiff, tag, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" + "RepoInfo{authorEmail=$authorEmail, authorName=$authorName, branch=$branch, commit=$commit, commitMessage=$commitMessage, commitTime=$commitTime, dirty=$dirty, gitDiff=$gitDiff, tag=$tag, additionalProperties=$additionalProperties}" } 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 8fb5572a..a95ec69b 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 @@ -8,13 +8,14 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -24,54 +25,51 @@ import java.util.Optional * * Roles can consist of individual permissions, as well as a set of roles they inherit from */ -@JsonDeserialize(builder = Role.Builder::class) @NoAutoDetect class Role +@JsonCreator private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val deletedAt: JsonField, - private val memberPermissions: JsonField>, - private val memberRoles: JsonField>, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") + @ExcludeMissing + private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") + @ExcludeMissing + private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the role */ fun id(): String = id.getRequired("id") - /** - * Unique id for the organization that the role belongs under - * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by any - * other role, but cannot be edited. - * - * It is forbidden to change the org after creating a role - */ - fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) - - /** Identifies the user who created the role */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** Name of the role */ + fun name(): String = name.getRequired("name") /** Date of role creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Name of the role */ - fun name(): String = name.getRequired("name") + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the role */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) @@ -85,9 +83,6 @@ private constructor( fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) - /** Unique identifier for the role */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - /** * Unique id for the organization that the role belongs under * @@ -96,25 +91,32 @@ private constructor( * * It is forbidden to change the org after creating a role */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) /** Identifies the user who created the role */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Date of role creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + /** Unique identifier for the role */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Textual description of the role */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + /** Date of role creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt + + /** Textual description of the role */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** (permission, restrict_object_type) tuples which belong to this role */ - @JsonProperty("member_permissions") @ExcludeMissing fun _memberPermissions() = memberPermissions + @JsonProperty("member_permissions") + @ExcludeMissing + fun _memberPermissions(): JsonField> = memberPermissions /** * Ids of the roles this role inherits from @@ -122,25 +124,44 @@ private constructor( * An inheriting role has all the permissions contained in its member roles, as well as all of * their inherited permissions */ - @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles() = memberRoles + @JsonProperty("member_roles") + @ExcludeMissing + fun _memberRoles(): JsonField> = memberRoles + + /** + * Unique id for the organization that the role belongs under + * + * A null org_id indicates a system role, which may be assigned to anybody and inherited by any + * other role, but cannot be edited. + * + * It is forbidden to change the org after creating a role + */ + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + + /** Identifies the user who created the role */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Role = apply { - if (!validated) { - id() - orgId() - userId() - created() - name() - description() - deletedAt() - memberPermissions().map { it.forEach { it.validate() } } - memberRoles() - validated = true + if (validated) { + return@apply } + + id() + name() + created() + deletedAt() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgId() + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -150,110 +171,98 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Role]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var created: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() - private var memberPermissions: JsonField> = JsonMissing.of() - private var memberRoles: JsonField> = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var memberPermissions: JsonField>? = null + private var memberRoles: JsonField>? = null + private var orgId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(role: Role) = apply { - this.id = role.id - this.orgId = role.orgId - this.userId = role.userId - this.created = role.created - this.name = role.name - this.description = role.description - this.deletedAt = role.deletedAt - this.memberPermissions = role.memberPermissions - this.memberRoles = role.memberRoles - additionalProperties(role.additionalProperties) + id = role.id + name = role.name + created = role.created + deletedAt = role.deletedAt + description = role.description + memberPermissions = role.memberPermissions.map { it.toMutableList() } + memberRoles = role.memberRoles.map { it.toMutableList() } + orgId = role.orgId + userId = role.userId + additionalProperties = role.additionalProperties.toMutableMap() } /** Unique identifier for the role */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the role */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** - * Unique id for the organization that the role belongs under - * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. - * - * It is forbidden to change the org after creating a role - */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** - * Unique id for the organization that the role belongs under - * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. - * - * It is forbidden to change the org after creating a role - */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + /** Name of the role */ + fun name(name: String) = name(JsonField.of(name)) - /** Identifies the user who created the role */ - fun userId(userId: String) = userId(JsonField.of(userId)) + /** Name of the role */ + fun name(name: JsonField) = apply { this.name = name } - /** Identifies the user who created the role */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + /** Date of role creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of role creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: Optional) = created(created.orElse(null)) /** Date of role creation */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } - /** Name of the role */ - fun name(name: String) = name(JsonField.of(name)) + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Name of the role */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the role */ - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the role */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) - /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + /** Textual description of the role */ + fun description(description: JsonField) = apply { this.description = description } - /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: List?) = + memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List) = - memberPermissions(JsonField.of(memberPermissions)) + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.orElse(null)) /** (permission, restrict_object_type) tuples which belong to this role */ - @JsonProperty("member_permissions") - @ExcludeMissing fun memberPermissions(memberPermissions: JsonField>) = apply { - this.memberPermissions = memberPermissions + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun addMemberPermission(memberPermission: MemberPermission) = apply { + memberPermissions = + (memberPermissions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberPermission) + } } /** @@ -262,7 +271,15 @@ private constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - fun memberRoles(memberRoles: List) = memberRoles(JsonField.of(memberRoles)) + fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.orElse(null)) /** * Ids of the roles this role inherits from @@ -270,52 +287,116 @@ private constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - @JsonProperty("member_roles") - @ExcludeMissing fun memberRoles(memberRoles: JsonField>) = apply { - this.memberRoles = memberRoles + this.memberRoles = memberRoles.map { it.toMutableList() } } + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun addMemberRole(memberRole: String) = apply { + memberRoles = + (memberRoles ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberRole) + } + } + + /** + * Unique id for the organization that the role belongs under + * + * A null org_id indicates a system role, which may be assigned to anybody and inherited by + * any other role, but cannot be edited. + * + * It is forbidden to change the org after creating a role + */ + fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) + + /** + * Unique id for the organization that the role belongs under + * + * A null org_id indicates a system role, which may be assigned to anybody and inherited by + * any other role, but cannot be edited. + * + * It is forbidden to change the org after creating a role + */ + fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) + + /** + * Unique id for the organization that the role belongs under + * + * A null org_id indicates a system role, which may be assigned to anybody and inherited by + * any other role, but cannot be edited. + * + * It is forbidden to change the org after creating a role + */ + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + + /** Identifies the user who created the role */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Identifies the user who created the role */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Identifies the user who created the role */ + fun userId(userId: JsonField) = apply { this.userId = userId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Role = Role( - id, - orgId, - userId, + checkRequired("id", id), + checkRequired("name", name), created, - name, - description, deletedAt, - memberPermissions.map { it.toImmutable() }, - memberRoles.map { it.toImmutable() }, + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgId, + userId, additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect class MemberPermission + @JsonCreator private constructor( - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val additionalProperties: Map, + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** * Each permission permits a certain type of operation on an object in the system * @@ -332,23 +413,29 @@ private constructor( * * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") @ExcludeMissing fun _permission() = permission + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @ExcludeMissing - fun _restrictObjectType() = restrictObjectType + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): MemberPermission = apply { - if (!validated) { - permission() - restrictObjectType() - validated = true + if (validated) { + return@apply } + + permission() + restrictObjectType() + validated = true } fun toBuilder() = Builder().from(this) @@ -358,17 +445,18 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [MemberPermission]. */ + class Builder internal constructor() { - private var permission: JsonField = JsonMissing.of() + private var permission: JsonField? = null private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(memberPermission: MemberPermission) = apply { - this.permission = memberPermission.permission - this.restrictObjectType = memberPermission.restrictObjectType - additionalProperties(memberPermission.additionalProperties) + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() } /** @@ -385,86 +473,93 @@ private constructor( * Permissions can be assigned to to objects on an individual basis, or grouped into * roles */ - @JsonProperty("permission") - @ExcludeMissing fun permission(permission: JsonField) = apply { this.permission = permission } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = - restrictObjectType(JsonField.of(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.orElse(null)) /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - @ExcludeMissing fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): MemberPermission = MemberPermission( - permission, + checkRequired("permission", permission), restrictObjectType, additionalProperties.toImmutable(), ) } + /** + * 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 - 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() - companion object { - @JvmField val CREATE = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -476,6 +571,15 @@ private constructor( 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, @@ -485,9 +589,20 @@ private constructor( 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 @@ -501,6 +616,15 @@ private constructor( 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 @@ -515,55 +639,65 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -578,6 +712,17 @@ private constructor( 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, @@ -590,9 +735,20 @@ private constructor( 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 @@ -609,6 +765,15 @@ private constructor( 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 @@ -627,6 +792,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -652,15 +829,15 @@ private constructor( return true } - return /* spotless:off */ other is Role && id == other.id && orgId == other.orgId && userId == other.userId && created == other.created && name == other.name && description == other.description && deletedAt == other.deletedAt && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Role && id == other.id && name == other.name && created == other.created && deletedAt == other.deletedAt && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, orgId, userId, created, name, description, deletedAt, memberPermissions, memberRoles, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, created, deletedAt, description, memberPermissions, memberRoles, orgId, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Role{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberPermissions=$memberPermissions, memberRoles=$memberRoles, additionalProperties=$additionalProperties}" + "Role{id=$id, name=$name, created=$created, deletedAt=$deletedAt, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } 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 04e373f2..1b1265bc 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 @@ -5,87 +5,156 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new role. If there is an existing role with the same name as the one specified in the + * request, will return the existing role unmodified + */ class RoleCreateParams -constructor( - private val name: String, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, +private constructor( + private val body: RoleCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun name(): String = name - - fun description(): Optional = Optional.ofNullable(description) - - fun memberPermissions(): Optional> = - Optional.ofNullable(memberPermissions) - - fun memberRoles(): Optional> = Optional.ofNullable(memberRoles) - - fun orgName(): Optional = Optional.ofNullable(orgName) +) : Params { + + /** Name of the role */ + fun name(): String = body.name() + + /** Textual description of the role */ + fun description(): Optional = body.description() + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(): Optional> = body.memberPermissions() + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions + */ + fun memberRoles(): Optional> = body.memberRoles() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. + */ + fun orgName(): Optional = body.orgName() + + /** Name of the role */ + fun _name(): JsonField = body._name() + + /** Textual description of the role */ + fun _description(): JsonField = body._description() + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun _memberPermissions(): JsonField> = body._memberPermissions() + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions + */ + fun _memberRoles(): JsonField> = body._memberRoles() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): RoleCreateBody { - return RoleCreateBody( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): RoleCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = RoleCreateBody.Builder::class) @NoAutoDetect class RoleCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") + @ExcludeMissing + private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") + @ExcludeMissing + private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the role */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** Textual description of the role */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun memberRoles(): Optional> = + Optional.ofNullable(memberRoles.getNullable("member_roles")) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the role */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Textual description of the role */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") - fun memberPermissions(): List? = memberPermissions + @ExcludeMissing + fun _memberPermissions(): JsonField> = memberPermissions /** * Ids of the roles this role inherits from @@ -93,19 +162,36 @@ constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - @JsonProperty("member_roles") fun memberRoles(): List? = memberRoles + @JsonProperty("member_roles") + @ExcludeMissing + fun _memberRoles(): JsonField> = memberRoles /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RoleCreateBody = apply { + if (validated) { + return@apply + } + + name() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -113,36 +199,96 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RoleCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var description: String? = null - private var memberPermissions: List? = null - private var memberRoles: List? = null - private var orgName: String? = null + private var name: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var memberPermissions: JsonField>? = null + private var memberRoles: JsonField>? = null + private var orgName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(roleCreateBody: RoleCreateBody) = apply { - this.name = roleCreateBody.name - this.description = roleCreateBody.description - this.memberPermissions = roleCreateBody.memberPermissions - this.memberRoles = roleCreateBody.memberRoles - this.orgName = roleCreateBody.orgName - additionalProperties(roleCreateBody.additionalProperties) + name = roleCreateBody.name + description = roleCreateBody.description + memberPermissions = roleCreateBody.memberPermissions.map { it.toMutableList() } + memberRoles = roleCreateBody.memberRoles.map { it.toMutableList() } + orgName = roleCreateBody.orgName + additionalProperties = roleCreateBody.additionalProperties.toMutableMap() } /** Name of the role */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the role */ + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the role */ + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the role */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the role */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: List?) = + memberPermissions(JsonField.ofNullable(memberPermissions)) + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.orElse(null)) /** (permission, restrict_object_type) tuples which belong to this role */ - @JsonProperty("member_permissions") - fun memberPermissions(memberPermissions: List) = apply { - this.memberPermissions = memberPermissions + fun memberPermissions(memberPermissions: JsonField>) = apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun addMemberPermission(memberPermission: MemberPermission) = apply { + memberPermissions = + (memberPermissions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberPermission) + } + } + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions + */ + fun memberRoles(memberRoles: List?) = + memberRoles(JsonField.ofNullable(memberRoles)) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions + */ + fun memberRoles(memberRoles: Optional>) = + memberRoles(memberRoles.orElse(null)) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions + */ + fun memberRoles(memberRoles: JsonField>) = apply { + this.memberRoles = memberRoles.map { it.toMutableList() } } /** @@ -151,37 +297,65 @@ constructor( * An inheriting role has all the permissions contained in its member roles, as well as * all of their inherited permissions */ - @JsonProperty("member_roles") - fun memberRoles(memberRoles: List) = apply { this.memberRoles = memberRoles } + fun addMemberRole(memberRole: String) = apply { + memberRoles = + (memberRoles ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberRole) + } + } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RoleCreateBody = RoleCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), description, - memberPermissions?.toImmutable(), - memberRoles?.toImmutable(), + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, orgName, additionalProperties.toImmutable(), ) @@ -212,46 +386,53 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RoleCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var description: String? = null - private var memberPermissions: MutableList = mutableListOf() - private var memberRoles: MutableList = mutableListOf() - private var orgName: String? = null + private var body: RoleCreateBody.Builder = RoleCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(roleCreateParams: RoleCreateParams) = apply { - name = roleCreateParams.name - description = roleCreateParams.description - memberPermissions = - roleCreateParams.memberPermissions?.toMutableList() ?: mutableListOf() - memberRoles = roleCreateParams.memberRoles?.toMutableList() ?: mutableListOf() - orgName = roleCreateParams.orgName + body = roleCreateParams.body.toBuilder() additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = roleCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the role */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the role */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Textual description of the role */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the role */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the role */ - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { body.description(description) } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List) = apply { - this.memberPermissions.clear() - this.memberPermissions.addAll(memberPermissions) + fun memberPermissions(memberPermissions: List?) = apply { + body.memberPermissions(memberPermissions) + } + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.orElse(null)) + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: JsonField>) = apply { + body.memberPermissions(memberPermissions) } /** (permission, restrict_object_type) tuples which belong to this role */ fun addMemberPermission(memberPermission: MemberPermission) = apply { - this.memberPermissions.add(memberPermission) + body.addMemberPermission(memberPermission) } /** @@ -260,9 +441,24 @@ constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - fun memberRoles(memberRoles: List) = apply { - this.memberRoles.clear() - this.memberRoles.addAll(memberRoles) + fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.orElse(null)) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun memberRoles(memberRoles: JsonField>) = apply { + body.memberRoles(memberRoles) } /** @@ -271,14 +467,47 @@ constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { this.memberRoles.add(memberRole) } + fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -378,48 +607,26 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): RoleCreateParams = RoleCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - memberPermissions.toImmutable().ifEmpty { null }, - memberRoles.toImmutable().ifEmpty { null }, - orgName, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect class MemberPermission + @JsonCreator private constructor( - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val additionalProperties: Map, + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -427,16 +634,42 @@ constructor( * * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") fun permission(): Permission? = permission + fun permission(): Permission = permission.getRequired("permission") + + /** The object type that the ACL applies to */ + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * 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 + */ + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType + @ExcludeMissing + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MemberPermission = apply { + if (validated) { + return@apply + } + + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -444,17 +677,18 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [MemberPermission]. */ + class Builder internal constructor() { - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null + private var permission: JsonField? = null + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(memberPermission: MemberPermission) = apply { - this.permission = memberPermission.permission - this.restrictObjectType = memberPermission.restrictObjectType - additionalProperties(memberPermission.additionalProperties) + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() } /** @@ -463,78 +697,101 @@ constructor( * Permissions can be assigned to to objects on an individual basis, or grouped into * roles */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** + * 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 + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.orElse(null)) + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): MemberPermission = MemberPermission( - checkNotNull(permission) { "`permission` is required but was not set" }, + checkRequired("permission", permission), restrictObjectType, additionalProperties.toImmutable(), ) } + /** + * 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 - 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() - companion object { - @JvmField val CREATE = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -546,6 +803,15 @@ constructor( 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, @@ -555,9 +821,20 @@ constructor( 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 @@ -571,6 +848,15 @@ constructor( 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 @@ -585,55 +871,65 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -648,6 +944,17 @@ constructor( 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, @@ -660,9 +967,20 @@ constructor( 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 @@ -679,6 +997,15 @@ constructor( 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 @@ -697,6 +1024,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -722,11 +1061,11 @@ constructor( return true } - return /* spotless:off */ other is RoleCreateParams && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "RoleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 2722412a..078b4fca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a role object by its id */ class RoleDeleteParams -constructor( +private constructor( private val roleId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** Role id */ fun roleId(): String = roleId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RoleDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var roleId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -191,7 +194,7 @@ constructor( fun build(): RoleDeleteParams = RoleDeleteParams( - checkNotNull(roleId) { "`roleId` is required but was not set" }, + checkRequired("roleId", roleId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index 1debe4a4..2f6e3ecf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.RoleService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all roles. The roles are sorted by creation date, with the most recently-created roles + * coming first + */ class RoleListPage private constructor( private val rolesService: RoleService, @@ -79,16 +84,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -98,11 +102,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,10 +146,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -150,8 +156,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: RoleListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index 1874ecb6..6b505c7c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.RoleServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all roles. The roles are sorted by creation date, with the most recently-created roles + * coming first + */ class RoleListPageAsync private constructor( private val rolesService: RoleServiceAsync, @@ -82,16 +87,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -101,11 +105,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -141,10 +149,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -153,8 +159,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: RoleListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 1ab7b664..9a1cb2ad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all roles. The roles are sorted by creation date, with the most recently-created roles + * coming first + */ class RoleListParams -constructor( +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -31,28 +35,48 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Name of the role to search for */ fun roleName(): Optional = Optional.ofNullable(roleName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.ids?.let { queryParams.put("ids", listOf(it.toString())) } @@ -71,8 +95,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RoleListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var ids: Ids? = null @@ -102,34 +127,62 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** Name of the role to search for */ - fun roleName(roleName: String) = apply { this.roleName = roleName } + fun roleName(roleName: String?) = apply { this.roleName = roleName } + + /** Name of the role to search for */ + fun roleName(roleName: Optional) = roleName(roleName.orElse(null)) /** * Pagination cursor id. @@ -138,7 +191,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -251,6 +314,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -260,8 +327,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -284,15 +349,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -318,18 +374,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -345,7 +411,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, 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 0c08fdc9..44df148c 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 @@ -5,87 +5,156 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create or replace role. If there is an existing role with the same name as the one specified in + * the request, will replace the existing role with the provided fields + */ class RoleReplaceParams -constructor( - private val name: String, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, +private constructor( + private val body: RoleReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun name(): String = name - - fun description(): Optional = Optional.ofNullable(description) - - fun memberPermissions(): Optional> = - Optional.ofNullable(memberPermissions) - - fun memberRoles(): Optional> = Optional.ofNullable(memberRoles) - - fun orgName(): Optional = Optional.ofNullable(orgName) +) : Params { + + /** Name of the role */ + fun name(): String = body.name() + + /** Textual description of the role */ + fun description(): Optional = body.description() + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(): Optional> = body.memberPermissions() + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions + */ + fun memberRoles(): Optional> = body.memberRoles() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. + */ + fun orgName(): Optional = body.orgName() + + /** Name of the role */ + fun _name(): JsonField = body._name() + + /** Textual description of the role */ + fun _description(): JsonField = body._description() + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun _memberPermissions(): JsonField> = body._memberPermissions() + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions + */ + fun _memberRoles(): JsonField> = body._memberRoles() + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. + */ + fun _orgName(): JsonField = body._orgName() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): RoleReplaceBody { - return RoleReplaceBody( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): RoleReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = RoleReplaceBody.Builder::class) @NoAutoDetect class RoleReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") + @ExcludeMissing + private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") + @ExcludeMissing + private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the role */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** Textual description of the role */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun memberRoles(): Optional> = + Optional.ofNullable(memberRoles.getNullable("member_roles")) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) + + /** Name of the role */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Textual description of the role */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") - fun memberPermissions(): List? = memberPermissions + @ExcludeMissing + fun _memberPermissions(): JsonField> = memberPermissions /** * Ids of the roles this role inherits from @@ -93,19 +162,36 @@ constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - @JsonProperty("member_roles") fun memberRoles(): List? = memberRoles + @JsonProperty("member_roles") + @ExcludeMissing + fun _memberRoles(): JsonField> = memberRoles /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RoleReplaceBody = apply { + if (validated) { + return@apply + } + + name() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -113,36 +199,96 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RoleReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var description: String? = null - private var memberPermissions: List? = null - private var memberRoles: List? = null - private var orgName: String? = null + private var name: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var memberPermissions: JsonField>? = null + private var memberRoles: JsonField>? = null + private var orgName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(roleReplaceBody: RoleReplaceBody) = apply { - this.name = roleReplaceBody.name - this.description = roleReplaceBody.description - this.memberPermissions = roleReplaceBody.memberPermissions - this.memberRoles = roleReplaceBody.memberRoles - this.orgName = roleReplaceBody.orgName - additionalProperties(roleReplaceBody.additionalProperties) + name = roleReplaceBody.name + description = roleReplaceBody.description + memberPermissions = roleReplaceBody.memberPermissions.map { it.toMutableList() } + memberRoles = roleReplaceBody.memberRoles.map { it.toMutableList() } + orgName = roleReplaceBody.orgName + additionalProperties = roleReplaceBody.additionalProperties.toMutableMap() } /** Name of the role */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the role */ + fun name(name: JsonField) = apply { this.name = name } + + /** Textual description of the role */ + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the role */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the role */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: List?) = + memberPermissions(JsonField.ofNullable(memberPermissions)) + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.orElse(null)) /** (permission, restrict_object_type) tuples which belong to this role */ - @JsonProperty("member_permissions") - fun memberPermissions(memberPermissions: List) = apply { - this.memberPermissions = memberPermissions + fun memberPermissions(memberPermissions: JsonField>) = apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun addMemberPermission(memberPermission: MemberPermission) = apply { + memberPermissions = + (memberPermissions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberPermission) + } + } + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions + */ + fun memberRoles(memberRoles: List?) = + memberRoles(JsonField.ofNullable(memberRoles)) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions + */ + fun memberRoles(memberRoles: Optional>) = + memberRoles(memberRoles.orElse(null)) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions + */ + fun memberRoles(memberRoles: JsonField>) = apply { + this.memberRoles = memberRoles.map { it.toMutableList() } } /** @@ -151,37 +297,65 @@ constructor( * An inheriting role has all the permissions contained in its member roles, as well as * all of their inherited permissions */ - @JsonProperty("member_roles") - fun memberRoles(memberRoles: List) = apply { this.memberRoles = memberRoles } + fun addMemberRole(memberRole: String) = apply { + memberRoles = + (memberRoles ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(memberRole) + } + } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RoleReplaceBody = RoleReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, + checkRequired("name", name), description, - memberPermissions?.toImmutable(), - memberRoles?.toImmutable(), + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, orgName, additionalProperties.toImmutable(), ) @@ -212,46 +386,53 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RoleReplaceParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var description: String? = null - private var memberPermissions: MutableList = mutableListOf() - private var memberRoles: MutableList = mutableListOf() - private var orgName: String? = null + private var body: RoleReplaceBody.Builder = RoleReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(roleReplaceParams: RoleReplaceParams) = apply { - name = roleReplaceParams.name - description = roleReplaceParams.description - memberPermissions = - roleReplaceParams.memberPermissions?.toMutableList() ?: mutableListOf() - memberRoles = roleReplaceParams.memberRoles?.toMutableList() ?: mutableListOf() - orgName = roleReplaceParams.orgName + body = roleReplaceParams.body.toBuilder() additionalHeaders = roleReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = roleReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = roleReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the role */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the role */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Textual description of the role */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the role */ + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the role */ - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { body.description(description) } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List) = apply { - this.memberPermissions.clear() - this.memberPermissions.addAll(memberPermissions) + fun memberPermissions(memberPermissions: List?) = apply { + body.memberPermissions(memberPermissions) + } + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.orElse(null)) + + /** (permission, restrict_object_type) tuples which belong to this role */ + fun memberPermissions(memberPermissions: JsonField>) = apply { + body.memberPermissions(memberPermissions) } /** (permission, restrict_object_type) tuples which belong to this role */ fun addMemberPermission(memberPermission: MemberPermission) = apply { - this.memberPermissions.add(memberPermission) + body.addMemberPermission(memberPermission) } /** @@ -260,9 +441,24 @@ constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - fun memberRoles(memberRoles: List) = apply { - this.memberRoles.clear() - this.memberRoles.addAll(memberRoles) + fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.orElse(null)) + + /** + * Ids of the roles this role inherits from + * + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions + */ + fun memberRoles(memberRoles: JsonField>) = apply { + body.memberRoles(memberRoles) } /** @@ -271,14 +467,47 @@ constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { this.memberRoles.add(memberRole) } + fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + + /** + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. + */ + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -378,48 +607,26 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): RoleReplaceParams = RoleReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - memberPermissions.toImmutable().ifEmpty { null }, - memberRoles.toImmutable().ifEmpty { null }, - orgName, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect class MemberPermission + @JsonCreator private constructor( - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val additionalProperties: Map, + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -427,16 +634,42 @@ constructor( * * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") fun permission(): Permission? = permission + fun permission(): Permission = permission.getRequired("permission") + + /** The object type that the ACL applies to */ + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * 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 + */ + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType + @ExcludeMissing + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MemberPermission = apply { + if (validated) { + return@apply + } + + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -444,17 +677,18 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [MemberPermission]. */ + class Builder internal constructor() { - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null + private var permission: JsonField? = null + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(memberPermission: MemberPermission) = apply { - this.permission = memberPermission.permission - this.restrictObjectType = memberPermission.restrictObjectType - additionalProperties(memberPermission.additionalProperties) + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() } /** @@ -463,78 +697,101 @@ constructor( * Permissions can be assigned to to objects on an individual basis, or grouped into * roles */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** + * 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 + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.orElse(null)) + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): MemberPermission = MemberPermission( - checkNotNull(permission) { "`permission` is required but was not set" }, + checkRequired("permission", permission), restrictObjectType, additionalProperties.toImmutable(), ) } + /** + * 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 - 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() - companion object { - @JvmField val CREATE = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -546,6 +803,15 @@ constructor( 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, @@ -555,9 +821,20 @@ constructor( 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 @@ -571,6 +848,15 @@ constructor( 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 @@ -585,55 +871,65 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -648,6 +944,17 @@ constructor( 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, @@ -660,9 +967,20 @@ constructor( 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 @@ -679,6 +997,15 @@ constructor( 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 @@ -697,6 +1024,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -722,11 +1061,11 @@ constructor( return true } - return /* spotless:off */ other is RoleReplaceParams && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, description, memberPermissions, memberRoles, orgName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "RoleReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 6731b49d..350fabb7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a role object by its id */ class RoleRetrieveParams -constructor( +private constructor( private val roleId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Role id */ fun roleId(): String = roleId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RoleRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var roleId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): RoleRetrieveParams = RoleRetrieveParams( - checkNotNull(roleId) { "`roleId` is required but was not set" }, + checkRequired("roleId", roleId), additionalHeaders.build(), additionalQueryParams.build(), ) 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 114321ff..760264f4 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 @@ -5,73 +5,88 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update a role object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. + */ class RoleUpdateParams -constructor( +private constructor( private val roleId: String, - private val addMemberPermissions: List?, - private val addMemberRoles: List?, - private val description: String?, - private val name: String?, - private val removeMemberPermissions: List?, - private val removeMemberRoles: List?, + private val body: RoleUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** Role id */ fun roleId(): String = roleId - fun addMemberPermissions(): Optional> = - Optional.ofNullable(addMemberPermissions) + /** A list of permissions to add to the role */ + fun addMemberPermissions(): Optional> = body.addMemberPermissions() - fun addMemberRoles(): Optional> = Optional.ofNullable(addMemberRoles) + /** A list of role IDs to add to the role's inheriting-from set */ + fun addMemberRoles(): Optional> = body.addMemberRoles() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the role */ + fun description(): Optional = body.description() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the role */ + fun name(): Optional = body.name() + /** A list of permissions to remove from the role */ fun removeMemberPermissions(): Optional> = - Optional.ofNullable(removeMemberPermissions) + body.removeMemberPermissions() - fun removeMemberRoles(): Optional> = Optional.ofNullable(removeMemberRoles) + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(): Optional> = body.removeMemberRoles() + + /** A list of permissions to add to the role */ + fun _addMemberPermissions(): JsonField> = body._addMemberPermissions() + + /** A list of role IDs to add to the role's inheriting-from set */ + fun _addMemberRoles(): JsonField> = body._addMemberRoles() + + /** Textual description of the role */ + fun _description(): JsonField = body._description() + + /** Name of the role */ + fun _name(): JsonField = body._name() + + /** A list of permissions to remove from the role */ + fun _removeMemberPermissions(): JsonField> = + body._removeMemberPermissions() + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun _removeMemberRoles(): JsonField> = body._removeMemberRoles() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): RoleUpdateBody { - return RoleUpdateBody( - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): RoleUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -80,44 +95,105 @@ constructor( } } - @JsonDeserialize(builder = RoleUpdateBody.Builder::class) @NoAutoDetect class RoleUpdateBody + @JsonCreator internal constructor( - private val addMemberPermissions: List?, - private val addMemberRoles: List?, - private val description: String?, - private val name: String?, - private val removeMemberPermissions: List?, - private val removeMemberRoles: List?, - private val additionalProperties: Map, + @JsonProperty("add_member_permissions") + @ExcludeMissing + private val addMemberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("add_member_roles") + @ExcludeMissing + private val addMemberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("remove_member_permissions") + @ExcludeMissing + private val removeMemberPermissions: JsonField> = + JsonMissing.of(), + @JsonProperty("remove_member_roles") + @ExcludeMissing + private val removeMemberRoles: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** A list of permissions to add to the role */ + fun addMemberPermissions(): Optional> = + Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) + + /** A list of role IDs to add to the role's inheriting-from set */ + fun addMemberRoles(): Optional> = + Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) + + /** Textual description of the role */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** Name of the role */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** A list of permissions to remove from the role */ + fun removeMemberPermissions(): Optional> = + Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(): Optional> = + Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) + /** A list of permissions to add to the role */ @JsonProperty("add_member_permissions") - fun addMemberPermissions(): List? = addMemberPermissions + @ExcludeMissing + fun _addMemberPermissions(): JsonField> = addMemberPermissions /** A list of role IDs to add to the role's inheriting-from set */ - @JsonProperty("add_member_roles") fun addMemberRoles(): List? = addMemberRoles + @JsonProperty("add_member_roles") + @ExcludeMissing + fun _addMemberRoles(): JsonField> = addMemberRoles /** Textual description of the role */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** Name of the role */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** A list of permissions to remove from the role */ @JsonProperty("remove_member_permissions") - fun removeMemberPermissions(): List? = removeMemberPermissions + @ExcludeMissing + fun _removeMemberPermissions(): JsonField> = + removeMemberPermissions /** A list of role IDs to remove from the role's inheriting-from set */ @JsonProperty("remove_member_roles") - fun removeMemberRoles(): List? = removeMemberRoles + @ExcludeMissing + fun _removeMemberRoles(): JsonField> = removeMemberRoles @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RoleUpdateBody = apply { + if (validated) { + return@apply + } + + addMemberPermissions().ifPresent { it.forEach { it.validate() } } + addMemberRoles() + description() + name() + removeMemberPermissions().ifPresent { it.forEach { it.validate() } } + removeMemberRoles() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -125,81 +201,190 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RoleUpdateBody]. */ + class Builder internal constructor() { - private var addMemberPermissions: List? = null - private var addMemberRoles: List? = null - private var description: String? = null - private var name: String? = null - private var removeMemberPermissions: List? = null - private var removeMemberRoles: List? = null + private var addMemberPermissions: JsonField>? = null + private var addMemberRoles: JsonField>? = null + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var removeMemberPermissions: JsonField>? = + null + private var removeMemberRoles: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(roleUpdateBody: RoleUpdateBody) = apply { - this.addMemberPermissions = roleUpdateBody.addMemberPermissions - this.addMemberRoles = roleUpdateBody.addMemberRoles - this.description = roleUpdateBody.description - this.name = roleUpdateBody.name - this.removeMemberPermissions = roleUpdateBody.removeMemberPermissions - this.removeMemberRoles = roleUpdateBody.removeMemberRoles - additionalProperties(roleUpdateBody.additionalProperties) + addMemberPermissions = + roleUpdateBody.addMemberPermissions.map { it.toMutableList() } + addMemberRoles = roleUpdateBody.addMemberRoles.map { it.toMutableList() } + description = roleUpdateBody.description + name = roleUpdateBody.name + removeMemberPermissions = + roleUpdateBody.removeMemberPermissions.map { it.toMutableList() } + removeMemberRoles = roleUpdateBody.removeMemberRoles.map { it.toMutableList() } + additionalProperties = roleUpdateBody.additionalProperties.toMutableMap() } /** A list of permissions to add to the role */ - @JsonProperty("add_member_permissions") - fun addMemberPermissions(addMemberPermissions: List) = apply { - this.addMemberPermissions = addMemberPermissions + fun addMemberPermissions(addMemberPermissions: List?) = + addMemberPermissions(JsonField.ofNullable(addMemberPermissions)) + + /** A list of permissions to add to the role */ + fun addMemberPermissions(addMemberPermissions: Optional>) = + addMemberPermissions(addMemberPermissions.orElse(null)) + + /** A list of permissions to add to the role */ + fun addMemberPermissions(addMemberPermissions: JsonField>) = + apply { + this.addMemberPermissions = addMemberPermissions.map { it.toMutableList() } + } + + /** A list of permissions to add to the role */ + fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { + addMemberPermissions = + (addMemberPermissions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addMemberPermission) + } + } + + /** A list of role IDs to add to the role's inheriting-from set */ + fun addMemberRoles(addMemberRoles: List?) = + addMemberRoles(JsonField.ofNullable(addMemberRoles)) + + /** A list of role IDs to add to the role's inheriting-from set */ + fun addMemberRoles(addMemberRoles: Optional>) = + addMemberRoles(addMemberRoles.orElse(null)) + + /** A list of role IDs to add to the role's inheriting-from set */ + fun addMemberRoles(addMemberRoles: JsonField>) = apply { + this.addMemberRoles = addMemberRoles.map { it.toMutableList() } } /** A list of role IDs to add to the role's inheriting-from set */ - @JsonProperty("add_member_roles") - fun addMemberRoles(addMemberRoles: List) = apply { - this.addMemberRoles = addMemberRoles + fun addAddMemberRole(addMemberRole: String) = apply { + addMemberRoles = + (addMemberRoles ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addMemberRole) + } } /** Textual description of the role */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the role */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the role */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** Name of the role */ + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the role */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the role */ + fun name(name: JsonField) = apply { this.name = name } /** A list of permissions to remove from the role */ - @JsonProperty("remove_member_permissions") - fun removeMemberPermissions(removeMemberPermissions: List) = - apply { - this.removeMemberPermissions = removeMemberPermissions - } + fun removeMemberPermissions(removeMemberPermissions: List?) = + removeMemberPermissions(JsonField.ofNullable(removeMemberPermissions)) + + /** A list of permissions to remove from the role */ + fun removeMemberPermissions( + removeMemberPermissions: Optional> + ) = removeMemberPermissions(removeMemberPermissions.orElse(null)) + + /** A list of permissions to remove from the role */ + fun removeMemberPermissions( + removeMemberPermissions: JsonField> + ) = apply { + this.removeMemberPermissions = removeMemberPermissions.map { it.toMutableList() } + } + + /** A list of permissions to remove from the role */ + fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { + removeMemberPermissions = + (removeMemberPermissions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removeMemberPermission) + } + } + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(removeMemberRoles: List?) = + removeMemberRoles(JsonField.ofNullable(removeMemberRoles)) + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(removeMemberRoles: Optional>) = + removeMemberRoles(removeMemberRoles.orElse(null)) + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { + this.removeMemberRoles = removeMemberRoles.map { it.toMutableList() } + } /** A list of role IDs to remove from the role's inheriting-from set */ - @JsonProperty("remove_member_roles") - fun removeMemberRoles(removeMemberRoles: List) = apply { - this.removeMemberRoles = removeMemberRoles + fun addRemoveMemberRole(removeMemberRole: String) = apply { + removeMemberRoles = + (removeMemberRoles ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removeMemberRole) + } } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RoleUpdateBody = RoleUpdateBody( - addMemberPermissions?.toImmutable(), - addMemberRoles?.toImmutable(), + (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (addMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, description, name, - removeMemberPermissions?.toImmutable(), - removeMemberRoles?.toImmutable(), + (removeMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (removeMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -229,88 +414,138 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RoleUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var roleId: String? = null - private var addMemberPermissions: MutableList = mutableListOf() - private var addMemberRoles: MutableList = mutableListOf() - private var description: String? = null - private var name: String? = null - private var removeMemberPermissions: MutableList = mutableListOf() - private var removeMemberRoles: MutableList = mutableListOf() + private var body: RoleUpdateBody.Builder = RoleUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(roleUpdateParams: RoleUpdateParams) = apply { roleId = roleUpdateParams.roleId - addMemberPermissions = - roleUpdateParams.addMemberPermissions?.toMutableList() ?: mutableListOf() - addMemberRoles = roleUpdateParams.addMemberRoles?.toMutableList() ?: mutableListOf() - description = roleUpdateParams.description - name = roleUpdateParams.name - removeMemberPermissions = - roleUpdateParams.removeMemberPermissions?.toMutableList() ?: mutableListOf() - removeMemberRoles = - roleUpdateParams.removeMemberRoles?.toMutableList() ?: mutableListOf() + body = roleUpdateParams.body.toBuilder() additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = roleUpdateParams.additionalBodyProperties.toMutableMap() } /** Role id */ fun roleId(roleId: String) = apply { this.roleId = roleId } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: List) = apply { - this.addMemberPermissions.clear() - this.addMemberPermissions.addAll(addMemberPermissions) + fun addMemberPermissions(addMemberPermissions: List?) = apply { + body.addMemberPermissions(addMemberPermissions) } + /** A list of permissions to add to the role */ + fun addMemberPermissions(addMemberPermissions: Optional>) = + addMemberPermissions(addMemberPermissions.orElse(null)) + + /** A list of permissions to add to the role */ + fun addMemberPermissions(addMemberPermissions: JsonField>) = + apply { + body.addMemberPermissions(addMemberPermissions) + } + /** A list of permissions to add to the role */ fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { - this.addMemberPermissions.add(addMemberPermission) + body.addAddMemberPermission(addMemberPermission) } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: List) = apply { - this.addMemberRoles.clear() - this.addMemberRoles.addAll(addMemberRoles) + fun addMemberRoles(addMemberRoles: List?) = apply { + body.addMemberRoles(addMemberRoles) } /** A list of role IDs to add to the role's inheriting-from set */ - fun addAddMemberRole(addMemberRole: String) = apply { - this.addMemberRoles.add(addMemberRole) + fun addMemberRoles(addMemberRoles: Optional>) = + addMemberRoles(addMemberRoles.orElse(null)) + + /** A list of role IDs to add to the role's inheriting-from set */ + fun addMemberRoles(addMemberRoles: JsonField>) = apply { + body.addMemberRoles(addMemberRoles) } + /** A list of role IDs to add to the role's inheriting-from set */ + fun addAddMemberRole(addMemberRole: String) = apply { body.addAddMemberRole(addMemberRole) } + + /** Textual description of the role */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the role */ + fun description(description: Optional) = description(description.orElse(null)) + /** Textual description of the role */ - fun description(description: String) = apply { this.description = description } + fun description(description: JsonField) = apply { body.description(description) } + + /** Name of the role */ + fun name(name: String?) = apply { body.name(name) } /** Name of the role */ - fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the role */ + fun name(name: JsonField) = apply { body.name(name) } /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: List) = apply { - this.removeMemberPermissions.clear() - this.removeMemberPermissions.addAll(removeMemberPermissions) - } + fun removeMemberPermissions(removeMemberPermissions: List?) = + apply { + body.removeMemberPermissions(removeMemberPermissions) + } + + /** A list of permissions to remove from the role */ + fun removeMemberPermissions( + removeMemberPermissions: Optional> + ) = removeMemberPermissions(removeMemberPermissions.orElse(null)) + + /** A list of permissions to remove from the role */ + fun removeMemberPermissions( + removeMemberPermissions: JsonField> + ) = apply { body.removeMemberPermissions(removeMemberPermissions) } /** A list of permissions to remove from the role */ fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { - this.removeMemberPermissions.add(removeMemberPermission) + body.addRemoveMemberPermission(removeMemberPermission) } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: List) = apply { - this.removeMemberRoles.clear() - this.removeMemberRoles.addAll(removeMemberRoles) + fun removeMemberRoles(removeMemberRoles: List?) = apply { + body.removeMemberRoles(removeMemberRoles) + } + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(removeMemberRoles: Optional>) = + removeMemberRoles(removeMemberRoles.orElse(null)) + + /** A list of role IDs to remove from the role's inheriting-from set */ + fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { + body.removeMemberRoles(removeMemberRoles) } /** A list of role IDs to remove from the role's inheriting-from set */ fun addRemoveMemberRole(removeMemberRole: String) = apply { - this.removeMemberRoles.add(removeMemberRole) + body.addRemoveMemberRole(removeMemberRole) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -411,50 +646,27 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): RoleUpdateParams = RoleUpdateParams( - checkNotNull(roleId) { "`roleId` is required but was not set" }, - addMemberPermissions.toImmutable().ifEmpty { null }, - addMemberRoles.toImmutable().ifEmpty { null }, - description, - name, - removeMemberPermissions.toImmutable().ifEmpty { null }, - removeMemberRoles.toImmutable().ifEmpty { null }, + checkRequired("roleId", roleId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - @JsonDeserialize(builder = AddMemberPermission.Builder::class) @NoAutoDetect class AddMemberPermission + @JsonCreator private constructor( - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val additionalProperties: Map, + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -462,16 +674,42 @@ constructor( * * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") fun permission(): Permission? = permission + fun permission(): Permission = permission.getRequired("permission") + + /** The object type that the ACL applies to */ + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * 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 + */ + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType + @ExcludeMissing + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddMemberPermission = apply { + if (validated) { + return@apply + } + + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -479,17 +717,18 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AddMemberPermission]. */ + class Builder internal constructor() { - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null + private var permission: JsonField? = null + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(addMemberPermission: AddMemberPermission) = apply { - this.permission = addMemberPermission.permission - this.restrictObjectType = addMemberPermission.restrictObjectType - additionalProperties(addMemberPermission.additionalProperties) + permission = addMemberPermission.permission + restrictObjectType = addMemberPermission.restrictObjectType + additionalProperties = addMemberPermission.additionalProperties.toMutableMap() } /** @@ -498,78 +737,101 @@ constructor( * Permissions can be assigned to to objects on an individual basis, or grouped into * roles */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** + * 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 + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.orElse(null)) + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): AddMemberPermission = AddMemberPermission( - checkNotNull(permission) { "`permission` is required but was not set" }, + checkRequired("permission", permission), restrictObjectType, additionalProperties.toImmutable(), ) } + /** + * 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 - 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() - companion object { - @JvmField val CREATE = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -581,6 +843,15 @@ constructor( 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, @@ -590,9 +861,20 @@ constructor( 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 @@ -606,6 +888,15 @@ constructor( 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 @@ -620,55 +911,65 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -683,6 +984,17 @@ constructor( 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, @@ -695,9 +1007,20 @@ constructor( 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 @@ -714,6 +1037,15 @@ constructor( 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 @@ -732,6 +1064,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -752,13 +1096,18 @@ constructor( "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = RemoveMemberPermission.Builder::class) @NoAutoDetect class RemoveMemberPermission + @JsonCreator private constructor( - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val additionalProperties: Map, + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -766,16 +1115,42 @@ constructor( * * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ - @JsonProperty("permission") fun permission(): Permission? = permission + fun permission(): Permission = permission.getRequired("permission") + + /** The object type that the ACL applies to */ + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * 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 + */ + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") - fun restrictObjectType(): RestrictObjectType? = restrictObjectType + @ExcludeMissing + fun _restrictObjectType(): JsonField = restrictObjectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RemoveMemberPermission = apply { + if (validated) { + return@apply + } + + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -783,17 +1158,18 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RemoveMemberPermission]. */ + class Builder internal constructor() { - private var permission: Permission? = null - private var restrictObjectType: RestrictObjectType? = null + private var permission: JsonField? = null + private var restrictObjectType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(removeMemberPermission: RemoveMemberPermission) = apply { - this.permission = removeMemberPermission.permission - this.restrictObjectType = removeMemberPermission.restrictObjectType - additionalProperties(removeMemberPermission.additionalProperties) + permission = removeMemberPermission.permission + restrictObjectType = removeMemberPermission.restrictObjectType + additionalProperties = removeMemberPermission.additionalProperties.toMutableMap() } /** @@ -802,78 +1178,101 @@ constructor( * Permissions can be assigned to to objects on an individual basis, or grouped into * roles */ - @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = permission(JsonField.of(permission)) + + /** + * 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 + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.orElse(null)) + + /** The object type that the ACL applies to */ + fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): RemoveMemberPermission = RemoveMemberPermission( - checkNotNull(permission) { "`permission` is required but was not set" }, + checkRequired("permission", permission), restrictObjectType, additionalProperties.toImmutable(), ) } + /** + * 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 - 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() - companion object { - @JvmField val CREATE = Permission(JsonField.of("create")) + @JvmField val CREATE = of("create") - @JvmField val READ = Permission(JsonField.of("read")) + @JvmField val READ = of("read") - @JvmField val UPDATE = Permission(JsonField.of("update")) + @JvmField val UPDATE = of("update") - @JvmField val DELETE = Permission(JsonField.of("delete")) + @JvmField val DELETE = of("delete") - @JvmField val CREATE_ACLS = Permission(JsonField.of("create_acls")) + @JvmField val CREATE_ACLS = of("create_acls") - @JvmField val READ_ACLS = Permission(JsonField.of("read_acls")) + @JvmField val READ_ACLS = of("read_acls") - @JvmField val UPDATE_ACLS = Permission(JsonField.of("update_acls")) + @JvmField val UPDATE_ACLS = of("update_acls") - @JvmField val DELETE_ACLS = Permission(JsonField.of("delete_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, @@ -885,6 +1284,15 @@ constructor( 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, @@ -894,9 +1302,20 @@ constructor( 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 @@ -910,6 +1329,15 @@ constructor( 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 @@ -924,55 +1352,65 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + 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 = RestrictObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = RestrictObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = RestrictObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = RestrictObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = RestrictObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = RestrictObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) + @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, @@ -987,6 +1425,17 @@ constructor( 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, @@ -999,9 +1448,20 @@ constructor( 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 @@ -1018,6 +1478,15 @@ constructor( 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 @@ -1036,6 +1505,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -1061,11 +1542,11 @@ constructor( return true } - return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, addMemberPermissions, addMemberRoles, description, name, removeMemberPermissions, removeMemberRoles, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "RoleUpdateParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index e7f5ddee..3f942703 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -7,32 +7,42 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional /** Summary of a score's performance */ -@JsonDeserialize(builder = ScoreSummary.Builder::class) @NoAutoDetect class ScoreSummary +@JsonCreator private constructor( - private val name: JsonField, - private val score: JsonField, - private val diff: JsonField, - private val improvements: JsonField, - private val regressions: JsonField, - private val additionalProperties: Map, + @JsonProperty("improvements") + @ExcludeMissing + private val improvements: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("regressions") + @ExcludeMissing + private val regressions: JsonField = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing private val score: JsonField = JsonMissing.of(), + @JsonProperty("diff") @ExcludeMissing private val diff: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Number of improvements in the score */ + fun improvements(): Long = improvements.getRequired("improvements") /** Name of the score */ fun name(): String = name.getRequired("name") + /** Number of regressions in the score */ + fun regressions(): Long = regressions.getRequired("regressions") + /** Average score across all examples */ fun score(): Double = score.getRequired("score") @@ -40,39 +50,39 @@ private constructor( fun diff(): Optional = Optional.ofNullable(diff.getNullable("diff")) /** Number of improvements in the score */ - fun improvements(): Long = improvements.getRequired("improvements") - - /** Number of regressions in the score */ - fun regressions(): Long = regressions.getRequired("regressions") + @JsonProperty("improvements") + @ExcludeMissing + fun _improvements(): JsonField = improvements /** Name of the score */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Number of regressions in the score */ + @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions /** Average score across all examples */ - @JsonProperty("score") @ExcludeMissing fun _score() = score + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField = score /** Difference in score between the current and comparison experiment */ - @JsonProperty("diff") @ExcludeMissing fun _diff() = diff - - /** Number of improvements in the score */ - @JsonProperty("improvements") @ExcludeMissing fun _improvements() = improvements - - /** Number of regressions in the score */ - @JsonProperty("regressions") @ExcludeMissing fun _regressions() = regressions + @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ScoreSummary = apply { - if (!validated) { - name() - score() - diff() - improvements() - regressions() - validated = true + if (validated) { + return@apply } + + improvements() + name() + regressions() + score() + diff() + validated = true } fun toBuilder() = Builder().from(this) @@ -82,86 +92,82 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ScoreSummary]. */ + class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() - private var score: JsonField = JsonMissing.of() + private var improvements: JsonField? = null + private var name: JsonField? = null + private var regressions: JsonField? = null + private var score: JsonField? = null private var diff: JsonField = JsonMissing.of() - private var improvements: JsonField = JsonMissing.of() - private var regressions: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scoreSummary: ScoreSummary) = apply { - this.name = scoreSummary.name - this.score = scoreSummary.score - this.diff = scoreSummary.diff - this.improvements = scoreSummary.improvements - this.regressions = scoreSummary.regressions - additionalProperties(scoreSummary.additionalProperties) + improvements = scoreSummary.improvements + name = scoreSummary.name + regressions = scoreSummary.regressions + score = scoreSummary.score + diff = scoreSummary.diff + additionalProperties = scoreSummary.additionalProperties.toMutableMap() } + /** Number of improvements in the score */ + fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) + + /** Number of improvements in the score */ + fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + /** Name of the score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the score */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } + /** Number of regressions in the score */ + fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) + + /** Number of regressions in the score */ + fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + /** Average score across all examples */ fun score(score: Double) = score(JsonField.of(score)) /** Average score across all examples */ - @JsonProperty("score") - @ExcludeMissing fun score(score: JsonField) = apply { this.score = score } /** Difference in score between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) /** Difference in score between the current and comparison experiment */ - @JsonProperty("diff") - @ExcludeMissing fun diff(diff: JsonField) = apply { this.diff = diff } - /** Number of improvements in the score */ - fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) - - /** Number of improvements in the score */ - @JsonProperty("improvements") - @ExcludeMissing - fun improvements(improvements: JsonField) = apply { this.improvements = improvements } - - /** Number of regressions in the score */ - fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) - - /** Number of regressions in the score */ - @JsonProperty("regressions") - @ExcludeMissing - fun regressions(regressions: JsonField) = apply { this.regressions = regressions } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ScoreSummary = ScoreSummary( - name, - score, + checkRequired("improvements", improvements), + checkRequired("name", name), + checkRequired("regressions", regressions), + checkRequired("score", score), diff, - improvements, - regressions, additionalProperties.toImmutable(), ) } @@ -171,15 +177,15 @@ private constructor( return true } - return /* spotless:off */ other is ScoreSummary && name == other.name && score == other.score && diff == other.diff && improvements == other.improvements && regressions == other.regressions && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScoreSummary && improvements == other.improvements && name == other.name && regressions == other.regressions && score == other.score && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, score, diff, improvements, regressions, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(improvements, name, regressions, score, diff, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ScoreSummary{name=$name, score=$score, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" + "ScoreSummary{improvements=$improvements, name=$name, regressions=$regressions, score=$score, diff=$diff, additionalProperties=$additionalProperties}" } 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 4f500d7d..b32a7b0d 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 @@ -8,28 +8,26 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional /** Human-identifying attributes of the span, such as name, type, etc. */ -@JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect class SpanAttributes +@JsonCreator private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Name of the span, for display purposes only */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -37,21 +35,25 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true + if (validated) { + return@apply } + + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -61,7 +63,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SpanAttributes]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -69,41 +72,48 @@ private constructor( @JvmSynthetic internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) + name = spanAttributes.name + type = spanAttributes.type + additionalProperties = spanAttributes.additionalProperties.toMutableMap() } /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the span, for display purposes only */ + fun name(name: Optional) = name(name.orElse(null)) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Type of the span, for display purposes only */ + fun type(type: Optional) = type(type.orElse(null)) /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): SpanAttributes = SpanAttributes( name, @@ -112,43 +122,41 @@ private constructor( ) } + /** 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 - 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() - companion object { - @JvmField val LLM = Type(JsonField.of("llm")) + @JvmField val LLM = of("llm") - @JvmField val SCORE = Type(JsonField.of("score")) + @JvmField val SCORE = of("score") - @JvmField val FUNCTION = Type(JsonField.of("function")) + @JvmField val FUNCTION = of("function") - @JvmField val EVAL = Type(JsonField.of("eval")) + @JvmField val EVAL = of("eval") - @JvmField val TASK = Type(JsonField.of("task")) + @JvmField val TASK = of("task") - @JvmField val TOOL = Type(JsonField.of("tool")) + @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, @@ -158,6 +166,15 @@ private constructor( 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, @@ -165,9 +182,17 @@ private constructor( 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 @@ -179,6 +204,15 @@ private constructor( 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 @@ -191,6 +225,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index c99c13e3..6bdb2fa0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -7,41 +7,56 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = SpanIFrame.Builder::class) @NoAutoDetect class SpanIFrame +@JsonCreator private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val deletedAt: JsonField, - private val name: JsonField, - private val description: JsonField, - private val url: JsonField, - private val postMessage: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") + @ExcludeMissing + private val postMessage: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the span iframe */ fun id(): String = id.getRequired("id") + /** Name of the span iframe */ + fun name(): String = name.getRequired("name") + /** Unique identifier for the project that the span iframe belongs under */ fun projectId(): String = projectId.getRequired("project_id") - /** Identifies the user who created the span iframe */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** URL to embed the project viewer in an iframe */ + fun url(): String = url.getRequired("url") /** Date of span iframe creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) @@ -50,16 +65,10 @@ private constructor( fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Name of the span iframe */ - fun name(): String = name.getRequired("name") - /** Textual description of the span iframe */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** URL to embed the project viewer in an iframe */ - fun url(): String = url.getRequired("url") - /** * Whether to post messages to the iframe containing the span's data. This is useful when you * want to render more data than fits in the URL. @@ -67,53 +76,64 @@ private constructor( fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) + /** Identifies the user who created the span iframe */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + /** Unique identifier for the span iframe */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** Name of the span iframe */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Identifies the user who created the span iframe */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url /** Date of span iframe creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of span iframe deletion, or null if the span iframe is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt - - /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt /** Textual description of the span iframe */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** * Whether to post messages to the iframe containing the span's data. This is useful when you * want to render more data than fits in the URL. */ - @JsonProperty("post_message") @ExcludeMissing fun _postMessage() = postMessage + @JsonProperty("post_message") + @ExcludeMissing + fun _postMessage(): JsonField = postMessage + + /** Identifies the user who created the span iframe */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): SpanIFrame = apply { - if (!validated) { - id() - projectId() - userId() - created() - deletedAt() - name() - description() - url() - postMessage() - validated = true + if (validated) { + return@apply } + + id() + name() + projectId() + url() + created() + deletedAt() + description() + postMessage() + userId() + validated = true } fun toBuilder() = Builder().from(this) @@ -123,134 +143,150 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SpanIFrame]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var url: JsonField? = null private var created: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() private var postMessage: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(spanIFrame: SpanIFrame) = apply { - this.id = spanIFrame.id - this.projectId = spanIFrame.projectId - this.userId = spanIFrame.userId - this.created = spanIFrame.created - this.deletedAt = spanIFrame.deletedAt - this.name = spanIFrame.name - this.description = spanIFrame.description - this.url = spanIFrame.url - this.postMessage = spanIFrame.postMessage - additionalProperties(spanIFrame.additionalProperties) + id = spanIFrame.id + name = spanIFrame.name + projectId = spanIFrame.projectId + url = spanIFrame.url + created = spanIFrame.created + deletedAt = spanIFrame.deletedAt + description = spanIFrame.description + postMessage = spanIFrame.postMessage + userId = spanIFrame.userId + additionalProperties = spanIFrame.additionalProperties.toMutableMap() } /** Unique identifier for the span iframe */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the span iframe */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } + + /** Name of the span iframe */ + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span iframe */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") - @ExcludeMissing fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - /** Identifies the user who created the span iframe */ - fun userId(userId: String) = userId(JsonField.of(userId)) + /** URL to embed the project viewer in an iframe */ + fun url(url: String) = url(JsonField.of(url)) - /** Identifies the user who created the span iframe */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + /** URL to embed the project viewer in an iframe */ + fun url(url: JsonField) = apply { this.url = url } + + /** Date of span iframe creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of span iframe creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: Optional) = created(created.orElse(null)) /** Date of span iframe creation */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } /** Date of span iframe deletion, or null if the span iframe is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of span iframe deletion, or null if the span iframe is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) - /** Name of the span iframe */ - fun name(name: String) = name(JsonField.of(name)) + /** Date of span iframe deletion, or null if the span iframe is still active */ + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } - /** Name of the span iframe */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Textual description of the span iframe */ + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the span iframe */ - fun description(description: String) = description(JsonField.of(description)) + fun description(description: Optional) = description(description.orElse(null)) /** Textual description of the span iframe */ - @JsonProperty("description") - @ExcludeMissing fun description(description: JsonField) = apply { this.description = description } - /** URL to embed the project viewer in an iframe */ - fun url(url: String) = url(JsonField.of(url)) + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) - /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean) = postMessage(JsonField.of(postMessage)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun postMessage(postMessage: Optional) = + postMessage(postMessage.orElse(null) as Boolean?) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - @JsonProperty("post_message") - @ExcludeMissing fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage } + /** Identifies the user who created the span iframe */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Identifies the user who created the span iframe */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Identifies the user who created the span iframe */ + fun userId(userId: JsonField) = apply { this.userId = userId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): SpanIFrame = SpanIFrame( - id, - projectId, - userId, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("url", url), created, deletedAt, - name, description, - url, postMessage, + userId, additionalProperties.toImmutable(), ) } @@ -260,15 +296,15 @@ private constructor( return true } - return /* spotless:off */ other is SpanIFrame && id == other.id && projectId == other.projectId && userId == other.userId && created == other.created && deletedAt == other.deletedAt && name == other.name && description == other.description && url == other.url && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanIFrame && id == other.id && name == other.name && projectId == other.projectId && url == other.url && created == other.created && deletedAt == other.deletedAt && description == other.description && postMessage == other.postMessage && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, userId, created, deletedAt, name, description, url, postMessage, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, projectId, url, created, deletedAt, description, postMessage, userId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SpanIFrame{id=$id, projectId=$projectId, userId=$userId, created=$created, deletedAt=$deletedAt, name=$name, description=$description, url=$url, postMessage=$postMessage, additionalProperties=$additionalProperties}" + "SpanIFrame{id=$id, name=$name, projectId=$projectId, url=$url, created=$created, deletedAt=$deletedAt, description=$description, postMessage=$postMessage, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index abc43e69..280fdb69 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -3,97 +3,164 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create a new span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will return the existing span_iframe unmodified + */ class SpanIframeCreateParams -constructor( - private val name: String, - private val projectId: String, - private val url: String, - private val description: String?, - private val postMessage: Boolean?, +private constructor( + private val body: SpanIframeCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the span iframe */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(): String = body.projectId() - fun url(): String = url + /** URL to embed the project viewer in an iframe */ + fun url(): String = body.url() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the span iframe */ + fun description(): Optional = body.description() - fun postMessage(): Optional = Optional.ofNullable(postMessage) + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. + */ + fun postMessage(): Optional = body.postMessage() + + /** Name of the span iframe */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the span iframe belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** URL to embed the project viewer in an iframe */ + fun _url(): JsonField = body._url() + + /** Textual description of the span iframe */ + fun _description(): JsonField = body._description() + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. + */ + fun _postMessage(): JsonField = body._postMessage() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): SpanIframeCreateBody { - return SpanIframeCreateBody( - name, - projectId, - url, - description, - postMessage, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): SpanIframeCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = SpanIframeCreateBody.Builder::class) @NoAutoDetect class SpanIframeCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val url: String?, - private val description: String?, - private val postMessage: Boolean?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") + @ExcludeMissing + private val postMessage: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the span iframe */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + fun projectId(): String = projectId.getRequired("project_id") /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") fun url(): String? = url + fun url(): String = url.getRequired("url") /** Textual description of the span iframe */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - @JsonProperty("post_message") fun postMessage(): Boolean? = postMessage + fun postMessage(): Optional = + Optional.ofNullable(postMessage.getNullable("post_message")) + + /** Name of the span iframe */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Unique identifier for the project that the span iframe belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** Textual description of the span iframe */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") + @ExcludeMissing + fun _postMessage(): JsonField = postMessage @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SpanIframeCreateBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + url() + description() + postMessage() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -101,65 +168,107 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SpanIframeCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var url: String? = null - private var description: String? = null - private var postMessage: Boolean? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var url: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var postMessage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(spanIframeCreateBody: SpanIframeCreateBody) = apply { - this.name = spanIframeCreateBody.name - this.projectId = spanIframeCreateBody.projectId - this.url = spanIframeCreateBody.url - this.description = spanIframeCreateBody.description - this.postMessage = spanIframeCreateBody.postMessage - additionalProperties(spanIframeCreateBody.additionalProperties) + name = spanIframeCreateBody.name + projectId = spanIframeCreateBody.projectId + url = spanIframeCreateBody.url + description = spanIframeCreateBody.description + postMessage = spanIframeCreateBody.postMessage + additionalProperties = spanIframeCreateBody.additionalProperties.toMutableMap() } /** Name of the span iframe */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span iframe */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** URL to embed the project viewer in an iframe */ + fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") fun url(url: String) = apply { this.url = url } + fun url(url: JsonField) = apply { this.url = url } /** Textual description of the span iframe */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the span iframe */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the span iframe */ + fun description(description: JsonField) = apply { + this.description = description + } /** * Whether to post messages to the iframe containing the span's data. This is useful * when you want to render more data than fits in the URL. */ - @JsonProperty("post_message") - fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun postMessage(postMessage: Optional) = + postMessage(postMessage.orElse(null) as Boolean?) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: JsonField) = apply { + this.postMessage = postMessage + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): SpanIframeCreateBody = SpanIframeCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(url) { "`url` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("url", url), description, postMessage, additionalProperties.toImmutable(), @@ -191,48 +300,92 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SpanIframeCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var url: String? = null - private var description: String? = null - private var postMessage: Boolean? = null + private var body: SpanIframeCreateBody.Builder = SpanIframeCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = apply { - name = spanIframeCreateParams.name - projectId = spanIframeCreateParams.projectId - url = spanIframeCreateParams.url - description = spanIframeCreateParams.description - postMessage = spanIframeCreateParams.postMessage + body = spanIframeCreateParams.body.toBuilder() additionalHeaders = spanIframeCreateParams.additionalHeaders.toBuilder() additionalQueryParams = spanIframeCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - spanIframeCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the span iframe */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the span iframe */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = apply { this.url = url } + fun url(url: String) = apply { body.url(url) } + + /** URL to embed the project viewer in an iframe */ + fun url(url: JsonField) = apply { body.url(url) } + + /** Textual description of the span iframe */ + fun description(description: String?) = apply { body.description(description) } /** Textual description of the span iframe */ - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the span iframe */ + fun description(description: JsonField) = apply { body.description(description) } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun postMessage(postMessage: Optional) = + postMessage(postMessage.orElse(null) as Boolean?) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -332,38 +485,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): SpanIframeCreateParams = SpanIframeCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(url) { "`url` is required but was not set" }, - description, - postMessage, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -372,11 +498,11 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeCreateParams && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "SpanIframeCreateParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "SpanIframeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt index 8b118418..101841eb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -4,21 +4,24 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue 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.core.toImmutable -import com.braintrustdata.api.models.* import java.util.Objects import java.util.Optional +/** Delete a span_iframe object by its id */ class SpanIframeDeleteParams -constructor( +private constructor( private val spanIframeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** SpanIframe id */ fun spanIframeId(): String = spanIframeId fun _additionalHeaders(): Headers = additionalHeaders @@ -28,13 +31,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -50,8 +52,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SpanIframeDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var spanIframeId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -192,7 +195,7 @@ constructor( fun build(): SpanIframeDeleteParams = SpanIframeDeleteParams( - checkNotNull(spanIframeId) { "`spanIframeId` is required but was not set" }, + checkRequired("spanIframeId", spanIframeId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index 7d5d0009..e91debd9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.SpanIframeService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ class SpanIframeListPage private constructor( private val spanIframesService: SpanIframeService, @@ -89,16 +94,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -108,11 +113,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -148,10 +157,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -160,8 +167,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: SpanIframeListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt index d4edf97f..90b8949e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.SpanIframeServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ class SpanIframeListPageAsync private constructor( private val spanIframesService: SpanIframeServiceAsync, @@ -92,16 +97,16 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -111,11 +116,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,10 +160,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -163,8 +170,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: SpanIframeListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index b17e23af..632ac128 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ class SpanIframeListParams -constructor( +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -31,28 +35,48 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { - +) : Params { + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** Name of the span_iframe to search for */ fun spanIframeName(): Optional = Optional.ofNullable(spanIframeName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } this.ids?.let { queryParams.put("ids", listOf(it.toString())) } @@ -71,8 +95,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SpanIframeListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endingBefore: String? = null private var ids: Ids? = null @@ -102,34 +127,63 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** Name of the span_iframe to search for */ - fun spanIframeName(spanIframeName: String) = apply { this.spanIframeName = spanIframeName } + fun spanIframeName(spanIframeName: String?) = apply { this.spanIframeName = spanIframeName } + + /** Name of the span_iframe to search for */ + fun spanIframeName(spanIframeName: Optional) = + spanIframeName(spanIframeName.orElse(null)) /** * Pagination cursor id. @@ -138,7 +192,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -251,6 +315,10 @@ constructor( ) } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -260,8 +328,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -284,15 +350,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -318,18 +375,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -345,7 +412,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index 2c6f3ebf..97a2fe65 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -3,97 +3,164 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Create or replace span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will replace the existing span_iframe with the provided fields + */ class SpanIframeReplaceParams -constructor( - private val name: String, - private val projectId: String, - private val url: String, - private val description: String?, - private val postMessage: Boolean?, +private constructor( + private val body: SpanIframeReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the span iframe */ + fun name(): String = body.name() - fun projectId(): String = projectId + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(): String = body.projectId() - fun url(): String = url + /** URL to embed the project viewer in an iframe */ + fun url(): String = body.url() - fun description(): Optional = Optional.ofNullable(description) + /** Textual description of the span iframe */ + fun description(): Optional = body.description() - fun postMessage(): Optional = Optional.ofNullable(postMessage) + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. + */ + fun postMessage(): Optional = body.postMessage() + + /** Name of the span iframe */ + fun _name(): JsonField = body._name() + + /** Unique identifier for the project that the span iframe belongs under */ + fun _projectId(): JsonField = body._projectId() + + /** URL to embed the project viewer in an iframe */ + fun _url(): JsonField = body._url() + + /** Textual description of the span iframe */ + fun _description(): JsonField = body._description() + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. + */ + fun _postMessage(): JsonField = body._postMessage() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): SpanIframeReplaceBody { - return SpanIframeReplaceBody( - name, - projectId, - url, - description, - postMessage, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): SpanIframeReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = SpanIframeReplaceBody.Builder::class) @NoAutoDetect class SpanIframeReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val projectId: String?, - private val url: String?, - private val description: String?, - private val postMessage: Boolean?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") + @ExcludeMissing + private val postMessage: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the span iframe */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + fun projectId(): String = projectId.getRequired("project_id") /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") fun url(): String? = url + fun url(): String = url.getRequired("url") /** Textual description of the span iframe */ - @JsonProperty("description") fun description(): String? = description + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - @JsonProperty("post_message") fun postMessage(): Boolean? = postMessage + fun postMessage(): Optional = + Optional.ofNullable(postMessage.getNullable("post_message")) + + /** Name of the span iframe */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Unique identifier for the project that the span iframe belongs under */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** URL to embed the project viewer in an iframe */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** Textual description of the span iframe */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + @JsonProperty("post_message") + @ExcludeMissing + fun _postMessage(): JsonField = postMessage @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SpanIframeReplaceBody = apply { + if (validated) { + return@apply + } + + name() + projectId() + url() + description() + postMessage() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -101,65 +168,107 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SpanIframeReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var url: String? = null - private var description: String? = null - private var postMessage: Boolean? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var url: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var postMessage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(spanIframeReplaceBody: SpanIframeReplaceBody) = apply { - this.name = spanIframeReplaceBody.name - this.projectId = spanIframeReplaceBody.projectId - this.url = spanIframeReplaceBody.url - this.description = spanIframeReplaceBody.description - this.postMessage = spanIframeReplaceBody.postMessage - additionalProperties(spanIframeReplaceBody.additionalProperties) + name = spanIframeReplaceBody.name + projectId = spanIframeReplaceBody.projectId + url = spanIframeReplaceBody.url + description = spanIframeReplaceBody.description + postMessage = spanIframeReplaceBody.postMessage + additionalProperties = spanIframeReplaceBody.additionalProperties.toMutableMap() } /** Name of the span iframe */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the span iframe */ + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** URL to embed the project viewer in an iframe */ + fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") fun url(url: String) = apply { this.url = url } + fun url(url: JsonField) = apply { this.url = url } /** Textual description of the span iframe */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the span iframe */ + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the span iframe */ + fun description(description: JsonField) = apply { + this.description = description + } /** * Whether to post messages to the iframe containing the span's data. This is useful * when you want to render more data than fits in the URL. */ - @JsonProperty("post_message") - fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun postMessage(postMessage: Optional) = + postMessage(postMessage.orElse(null) as Boolean?) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: JsonField) = apply { + this.postMessage = postMessage + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): SpanIframeReplaceBody = SpanIframeReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(url) { "`url` is required but was not set" }, + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("url", url), description, postMessage, additionalProperties.toImmutable(), @@ -191,48 +300,92 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SpanIframeReplaceParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { - private var name: String? = null - private var projectId: String? = null - private var url: String? = null - private var description: String? = null - private var postMessage: Boolean? = null + private var body: SpanIframeReplaceBody.Builder = SpanIframeReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = apply { - name = spanIframeReplaceParams.name - projectId = spanIframeReplaceParams.projectId - url = spanIframeReplaceParams.url - description = spanIframeReplaceParams.description - postMessage = spanIframeReplaceParams.postMessage + body = spanIframeReplaceParams.body.toBuilder() additionalHeaders = spanIframeReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = spanIframeReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - spanIframeReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the span iframe */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the span iframe */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Unique identifier for the project that the span iframe belongs under */ + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = apply { this.url = url } + fun url(url: String) = apply { body.url(url) } + + /** URL to embed the project viewer in an iframe */ + fun url(url: JsonField) = apply { body.url(url) } + + /** Textual description of the span iframe */ + fun description(description: String?) = apply { body.description(description) } /** Textual description of the span iframe */ - fun description(description: String) = apply { this.description = description } + fun description(description: Optional) = description(description.orElse(null)) + + /** Textual description of the span iframe */ + fun description(description: JsonField) = apply { body.description(description) } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun postMessage(postMessage: Optional) = + postMessage(postMessage.orElse(null) as Boolean?) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -332,38 +485,11 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): SpanIframeReplaceParams = SpanIframeReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(url) { "`url` is required but was not set" }, - description, - postMessage, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -372,11 +498,11 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeReplaceParams && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, projectId, url, description, postMessage, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "SpanIframeReplaceParams{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "SpanIframeReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt index 9878d60a..14f9bad5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a span_iframe object by its id */ class SpanIframeRetrieveParams -constructor( +private constructor( private val spanIframeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** SpanIframe id */ fun spanIframeId(): String = spanIframeId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SpanIframeRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var spanIframeId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): SpanIframeRetrieveParams = SpanIframeRetrieveParams( - checkNotNull(spanIframeId) { "`spanIframeId` is required but was not set" }, + checkRequired("spanIframeId", spanIframeId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 57143fee..8fb1ce65 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -3,57 +3,74 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update a span_iframe object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. + */ class SpanIframeUpdateParams -constructor( +private constructor( private val spanIframeId: String, - private val name: String?, - private val postMessage: Boolean?, - private val url: String?, + private val body: SpanIframeUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** SpanIframe id */ fun spanIframeId(): String = spanIframeId - fun name(): Optional = Optional.ofNullable(name) + /** Name of the span iframe */ + fun name(): Optional = body.name() - fun postMessage(): Optional = Optional.ofNullable(postMessage) + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. + */ + fun postMessage(): Optional = body.postMessage() - fun url(): Optional = Optional.ofNullable(url) + /** URL to embed the project viewer in an iframe */ + fun url(): Optional = body.url() + + /** Name of the span iframe */ + fun _name(): JsonField = body._name() + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. + */ + fun _postMessage(): JsonField = body._postMessage() + + /** URL to embed the project viewer in an iframe */ + fun _url(): JsonField = body._url() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun _body(): SpanIframeUpdateBody = body - @JvmSynthetic - internal fun getBody(): SpanIframeUpdateBody { - return SpanIframeUpdateBody( - name, - postMessage, - url, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -62,32 +79,65 @@ constructor( } } - @JsonDeserialize(builder = SpanIframeUpdateBody.Builder::class) @NoAutoDetect class SpanIframeUpdateBody + @JsonCreator internal constructor( - private val name: String?, - private val postMessage: Boolean?, - private val url: String?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("post_message") + @ExcludeMissing + private val postMessage: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the span iframe */ - @JsonProperty("name") fun name(): String? = name + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(): Optional = + Optional.ofNullable(postMessage.getNullable("post_message")) + + /** URL to embed the project viewer in an iframe */ + fun url(): Optional = Optional.ofNullable(url.getNullable("url")) + + /** Name of the span iframe */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - @JsonProperty("post_message") fun postMessage(): Boolean? = postMessage + @JsonProperty("post_message") + @ExcludeMissing + fun _postMessage(): JsonField = postMessage /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") fun url(): String? = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SpanIframeUpdateBody = apply { + if (validated) { + return@apply + } + + name() + postMessage() + url() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -95,48 +145,87 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SpanIframeUpdateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var postMessage: Boolean? = null - private var url: String? = null + private var name: JsonField = JsonMissing.of() + private var postMessage: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(spanIframeUpdateBody: SpanIframeUpdateBody) = apply { - this.name = spanIframeUpdateBody.name - this.postMessage = spanIframeUpdateBody.postMessage - this.url = spanIframeUpdateBody.url - additionalProperties(spanIframeUpdateBody.additionalProperties) + name = spanIframeUpdateBody.name + postMessage = spanIframeUpdateBody.postMessage + url = spanIframeUpdateBody.url + additionalProperties = spanIframeUpdateBody.additionalProperties.toMutableMap() } /** Name of the span iframe */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Name of the span iframe */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the span iframe */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun postMessage(postMessage: Optional) = + postMessage(postMessage.orElse(null) as Boolean?) /** * Whether to post messages to the iframe containing the span's data. This is useful * when you want to render more data than fits in the URL. */ - @JsonProperty("post_message") - fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + fun postMessage(postMessage: JsonField) = apply { + this.postMessage = postMessage + } /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") fun url(url: String) = apply { this.url = url } + fun url(url: String?) = url(JsonField.ofNullable(url)) + + /** URL to embed the project viewer in an iframe */ + fun url(url: Optional) = url(url.orElse(null)) + + /** URL to embed the project viewer in an iframe */ + fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): SpanIframeUpdateBody = SpanIframeUpdateBody( name, @@ -171,43 +260,88 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SpanIframeUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var spanIframeId: String? = null - private var name: String? = null - private var postMessage: Boolean? = null - private var url: String? = null + private var body: SpanIframeUpdateBody.Builder = SpanIframeUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = apply { spanIframeId = spanIframeUpdateParams.spanIframeId - name = spanIframeUpdateParams.name - postMessage = spanIframeUpdateParams.postMessage - url = spanIframeUpdateParams.url + body = spanIframeUpdateParams.body.toBuilder() additionalHeaders = spanIframeUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = spanIframeUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - spanIframeUpdateParams.additionalBodyProperties.toMutableMap() } /** SpanIframe id */ fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } /** Name of the span iframe */ - fun name(name: String) = apply { this.name = name } + fun name(name: String?) = apply { body.name(name) } + + /** Name of the span iframe */ + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the span iframe */ + fun name(name: JsonField) = apply { body.name(name) } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean) = apply { this.postMessage = postMessage } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun postMessage(postMessage: Optional) = + postMessage(postMessage.orElse(null) as Boolean?) + + /** + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. + */ + fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + + /** URL to embed the project viewer in an iframe */ + fun url(url: String?) = apply { body.url(url) } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = apply { this.url = url } + fun url(url: Optional) = url(url.orElse(null)) + + /** URL to embed the project viewer in an iframe */ + fun url(url: JsonField) = apply { body.url(url) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -307,37 +441,12 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): SpanIframeUpdateParams = SpanIframeUpdateParams( - checkNotNull(spanIframeId) { "`spanIframeId` is required but was not set" }, - name, - postMessage, - url, + checkRequired("spanIframeId", spanIframeId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } @@ -346,11 +455,11 @@ constructor( return true } - return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && name == other.name && postMessage == other.postMessage && url == other.url && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, name, postMessage, url, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "SpanIframeUpdateParams{spanIframeId=$spanIframeId, name=$name, postMessage=$postMessage, url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "SpanIframeUpdateParams{spanIframeId=$spanIframeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 51b2eef2..5b0db332 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -7,73 +7,93 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional /** Summary of a dataset */ -@JsonDeserialize(builder = SummarizeDatasetResponse.Builder::class) @NoAutoDetect class SummarizeDatasetResponse +@JsonCreator private constructor( - private val projectName: JsonField, - private val datasetName: JsonField, - private val projectUrl: JsonField, - private val datasetUrl: JsonField, - private val dataSummary: JsonField, - private val additionalProperties: Map, + @JsonProperty("dataset_name") + @ExcludeMissing + private val datasetName: JsonField = JsonMissing.of(), + @JsonProperty("dataset_url") + @ExcludeMissing + private val datasetUrl: JsonField = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("project_url") + @ExcludeMissing + private val projectUrl: JsonField = JsonMissing.of(), + @JsonProperty("data_summary") + @ExcludeMissing + private val dataSummary: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Name of the dataset */ + fun datasetName(): String = datasetName.getRequired("dataset_name") + + /** URL to the dataset's page in the Braintrust app */ + fun datasetUrl(): String = datasetUrl.getRequired("dataset_url") /** Name of the project that the dataset belongs to */ fun projectName(): String = projectName.getRequired("project_name") - /** Name of the dataset */ - fun datasetName(): String = datasetName.getRequired("dataset_name") - /** URL to the project's page in the Braintrust app */ fun projectUrl(): String = projectUrl.getRequired("project_url") - /** URL to the dataset's page in the Braintrust app */ - fun datasetUrl(): String = datasetUrl.getRequired("dataset_url") - /** Summary of a dataset's data */ fun dataSummary(): Optional = Optional.ofNullable(dataSummary.getNullable("data_summary")) - /** Name of the project that the dataset belongs to */ - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName - /** Name of the dataset */ - @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName() = datasetName - - /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl + @JsonProperty("dataset_name") + @ExcludeMissing + fun _datasetName(): JsonField = datasetName /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl() = datasetUrl + @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl(): JsonField = datasetUrl + + /** Name of the project that the dataset belongs to */ + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName(): JsonField = projectName + + /** URL to the project's page in the Braintrust app */ + @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl /** Summary of a dataset's data */ - @JsonProperty("data_summary") @ExcludeMissing fun _dataSummary() = dataSummary + @JsonProperty("data_summary") + @ExcludeMissing + fun _dataSummary(): JsonField = dataSummary @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): SummarizeDatasetResponse = apply { - if (!validated) { - projectName() - datasetName() - projectUrl() - datasetUrl() - dataSummary().map { it.validate() } - validated = true + if (validated) { + return@apply } + + datasetName() + datasetUrl() + projectName() + projectUrl() + dataSummary().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -83,87 +103,86 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SummarizeDatasetResponse]. */ + class Builder internal constructor() { - private var projectName: JsonField = JsonMissing.of() - private var datasetName: JsonField = JsonMissing.of() - private var projectUrl: JsonField = JsonMissing.of() - private var datasetUrl: JsonField = JsonMissing.of() + private var datasetName: JsonField? = null + private var datasetUrl: JsonField? = null + private var projectName: JsonField? = null + private var projectUrl: JsonField? = null private var dataSummary: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(summarizeDatasetResponse: SummarizeDatasetResponse) = apply { - this.projectName = summarizeDatasetResponse.projectName - this.datasetName = summarizeDatasetResponse.datasetName - this.projectUrl = summarizeDatasetResponse.projectUrl - this.datasetUrl = summarizeDatasetResponse.datasetUrl - this.dataSummary = summarizeDatasetResponse.dataSummary - additionalProperties(summarizeDatasetResponse.additionalProperties) + datasetName = summarizeDatasetResponse.datasetName + datasetUrl = summarizeDatasetResponse.datasetUrl + projectName = summarizeDatasetResponse.projectName + projectUrl = summarizeDatasetResponse.projectUrl + dataSummary = summarizeDatasetResponse.dataSummary + additionalProperties = summarizeDatasetResponse.additionalProperties.toMutableMap() } - /** Name of the project that the dataset belongs to */ - fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - - /** Name of the project that the dataset belongs to */ - @JsonProperty("project_name") - @ExcludeMissing - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } - /** Name of the dataset */ fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) /** Name of the dataset */ - @JsonProperty("dataset_name") - @ExcludeMissing fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } + /** URL to the dataset's page in the Braintrust app */ + fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) + + /** URL to the dataset's page in the Braintrust app */ + fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } + + /** Name of the project that the dataset belongs to */ + fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + + /** Name of the project that the dataset belongs to */ + fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") - @ExcludeMissing fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } - /** URL to the dataset's page in the Braintrust app */ - fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) - - /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") - @ExcludeMissing - fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } + /** Summary of a dataset's data */ + fun dataSummary(dataSummary: DataSummary?) = dataSummary(JsonField.ofNullable(dataSummary)) /** Summary of a dataset's data */ - fun dataSummary(dataSummary: DataSummary) = dataSummary(JsonField.of(dataSummary)) + fun dataSummary(dataSummary: Optional) = dataSummary(dataSummary.orElse(null)) /** Summary of a dataset's data */ - @JsonProperty("data_summary") - @ExcludeMissing fun dataSummary(dataSummary: JsonField) = apply { this.dataSummary = dataSummary } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): SummarizeDatasetResponse = SummarizeDatasetResponse( - projectName, - datasetName, - projectUrl, - datasetUrl, + checkRequired("datasetName", datasetName), + checkRequired("datasetUrl", datasetUrl), + checkRequired("projectName", projectName), + checkRequired("projectUrl", projectUrl), dataSummary, additionalProperties.toImmutable(), ) @@ -174,15 +193,15 @@ private constructor( return true } - return /* spotless:off */ other is SummarizeDatasetResponse && projectName == other.projectName && datasetName == other.datasetName && projectUrl == other.projectUrl && datasetUrl == other.datasetUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeDatasetResponse && datasetName == other.datasetName && datasetUrl == other.datasetUrl && projectName == other.projectName && projectUrl == other.projectUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(projectName, datasetName, projectUrl, datasetUrl, dataSummary, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(datasetName, datasetUrl, projectName, projectUrl, dataSummary, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SummarizeDatasetResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" + "SummarizeDatasetResponse{datasetName=$datasetName, datasetUrl=$datasetUrl, projectName=$projectName, projectUrl=$projectUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 721160c7..122c0887 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -7,91 +7,115 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional /** Summary of an experiment */ -@JsonDeserialize(builder = SummarizeExperimentResponse.Builder::class) @NoAutoDetect class SummarizeExperimentResponse +@JsonCreator private constructor( - private val projectName: JsonField, - private val experimentName: JsonField, - private val projectUrl: JsonField, - private val experimentUrl: JsonField, - private val comparisonExperimentName: JsonField, - private val scores: JsonField, - private val metrics: JsonField, - private val additionalProperties: Map, + @JsonProperty("experiment_name") + @ExcludeMissing + private val experimentName: JsonField = JsonMissing.of(), + @JsonProperty("experiment_url") + @ExcludeMissing + private val experimentUrl: JsonField = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("project_url") + @ExcludeMissing + private val projectUrl: JsonField = JsonMissing.of(), + @JsonProperty("comparison_experiment_name") + @ExcludeMissing + private val comparisonExperimentName: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false + /** Name of the experiment */ + fun experimentName(): String = experimentName.getRequired("experiment_name") + + /** URL to the experiment's page in the Braintrust app */ + fun experimentUrl(): String = experimentUrl.getRequired("experiment_url") /** Name of the project that the experiment belongs to */ fun projectName(): String = projectName.getRequired("project_name") - /** Name of the experiment */ - fun experimentName(): String = experimentName.getRequired("experiment_name") - /** URL to the project's page in the Braintrust app */ fun projectUrl(): String = projectUrl.getRequired("project_url") - /** URL to the experiment's page in the Braintrust app */ - fun experimentUrl(): String = experimentUrl.getRequired("experiment_url") - /** The experiment which scores are baselined against */ fun comparisonExperimentName(): Optional = Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) - /** Summary of the experiment's scores */ - fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - /** Summary of the experiment's metrics */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - /** Name of the project that the experiment belongs to */ - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName + /** Summary of the experiment's scores */ + fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Name of the experiment */ - @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName() = experimentName - - /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl + @JsonProperty("experiment_name") + @ExcludeMissing + fun _experimentName(): JsonField = experimentName /** URL to the experiment's page in the Braintrust app */ - @JsonProperty("experiment_url") @ExcludeMissing fun _experimentUrl() = experimentUrl + @JsonProperty("experiment_url") + @ExcludeMissing + fun _experimentUrl(): JsonField = experimentUrl + + /** Name of the project that the experiment belongs to */ + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName(): JsonField = projectName + + /** URL to the project's page in the Braintrust app */ + @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl /** The experiment which scores are baselined against */ @JsonProperty("comparison_experiment_name") @ExcludeMissing - fun _comparisonExperimentName() = comparisonExperimentName - - /** Summary of the experiment's scores */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + fun _comparisonExperimentName(): JsonField = comparisonExperimentName /** Summary of the experiment's metrics */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + + /** Summary of the experiment's scores */ + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): SummarizeExperimentResponse = apply { - if (!validated) { - projectName() - experimentName() - projectUrl() - experimentUrl() - comparisonExperimentName() - scores().map { it.validate() } - metrics().map { it.validate() } - validated = true + if (validated) { + return@apply } + + experimentName() + experimentUrl() + projectName() + projectUrl() + comparisonExperimentName() + metrics().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -101,137 +125,142 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SummarizeExperimentResponse]. */ + class Builder internal constructor() { - private var projectName: JsonField = JsonMissing.of() - private var experimentName: JsonField = JsonMissing.of() - private var projectUrl: JsonField = JsonMissing.of() - private var experimentUrl: JsonField = JsonMissing.of() + private var experimentName: JsonField? = null + private var experimentUrl: JsonField? = null + private var projectName: JsonField? = null + private var projectUrl: JsonField? = null private var comparisonExperimentName: JsonField = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() + private var scores: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(summarizeExperimentResponse: SummarizeExperimentResponse) = apply { - this.projectName = summarizeExperimentResponse.projectName - this.experimentName = summarizeExperimentResponse.experimentName - this.projectUrl = summarizeExperimentResponse.projectUrl - this.experimentUrl = summarizeExperimentResponse.experimentUrl - this.comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName - this.scores = summarizeExperimentResponse.scores - this.metrics = summarizeExperimentResponse.metrics - additionalProperties(summarizeExperimentResponse.additionalProperties) + experimentName = summarizeExperimentResponse.experimentName + experimentUrl = summarizeExperimentResponse.experimentUrl + projectName = summarizeExperimentResponse.projectName + projectUrl = summarizeExperimentResponse.projectUrl + comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName + metrics = summarizeExperimentResponse.metrics + scores = summarizeExperimentResponse.scores + additionalProperties = summarizeExperimentResponse.additionalProperties.toMutableMap() } - /** Name of the project that the experiment belongs to */ - fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - - /** Name of the project that the experiment belongs to */ - @JsonProperty("project_name") - @ExcludeMissing - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } - /** Name of the experiment */ fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) /** Name of the experiment */ - @JsonProperty("experiment_name") - @ExcludeMissing fun experimentName(experimentName: JsonField) = apply { this.experimentName = experimentName } - /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) - - /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") - @ExcludeMissing - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } - /** URL to the experiment's page in the Braintrust app */ fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) /** URL to the experiment's page in the Braintrust app */ - @JsonProperty("experiment_url") - @ExcludeMissing fun experimentUrl(experimentUrl: JsonField) = apply { this.experimentUrl = experimentUrl } + /** Name of the project that the experiment belongs to */ + fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + + /** Name of the project that the experiment belongs to */ + fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + + /** URL to the project's page in the Braintrust app */ + fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) + + /** URL to the project's page in the Braintrust app */ + fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: String) = - comparisonExperimentName(JsonField.of(comparisonExperimentName)) + fun comparisonExperimentName(comparisonExperimentName: String?) = + comparisonExperimentName(JsonField.ofNullable(comparisonExperimentName)) + + /** The experiment which scores are baselined against */ + fun comparisonExperimentName(comparisonExperimentName: Optional) = + comparisonExperimentName(comparisonExperimentName.orElse(null)) /** The experiment which scores are baselined against */ - @JsonProperty("comparison_experiment_name") - @ExcludeMissing fun comparisonExperimentName(comparisonExperimentName: JsonField) = apply { this.comparisonExperimentName = comparisonExperimentName } - /** Summary of the experiment's scores */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** Summary of the experiment's scores */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + /** Summary of the experiment's metrics */ + fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** Summary of the experiment's metrics */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) + fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) /** Summary of the experiment's metrics */ - @JsonProperty("metrics") - @ExcludeMissing fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + /** Summary of the experiment's scores */ + fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) + + /** Summary of the experiment's scores */ + fun scores(scores: Optional) = scores(scores.orElse(null)) + + /** Summary of the experiment's scores */ + fun scores(scores: JsonField) = apply { this.scores = scores } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): SummarizeExperimentResponse = SummarizeExperimentResponse( - projectName, - experimentName, - projectUrl, - experimentUrl, + checkRequired("experimentName", experimentName), + checkRequired("experimentUrl", experimentUrl), + checkRequired("projectName", projectName), + checkRequired("projectUrl", projectUrl), comparisonExperimentName, - scores, metrics, + scores, additionalProperties.toImmutable(), ) } /** Summary of the experiment's metrics */ - @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect class Metrics + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Metrics = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -241,29 +270,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Metrics]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metrics: Metrics) = apply { - additionalProperties(metrics.additionalProperties) + additionalProperties = metrics.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Metrics = Metrics(additionalProperties.toImmutable()) } @@ -285,23 +320,26 @@ private constructor( } /** Summary of the experiment's scores */ - @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect class Scores + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Scores = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -311,29 +349,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Scores]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) + additionalProperties = scores.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): Scores = Scores(additionalProperties.toImmutable()) } @@ -359,15 +403,15 @@ private constructor( return true } - return /* spotless:off */ other is SummarizeExperimentResponse && projectName == other.projectName && experimentName == other.experimentName && projectUrl == other.projectUrl && experimentUrl == other.experimentUrl && comparisonExperimentName == other.comparisonExperimentName && scores == other.scores && metrics == other.metrics && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeExperimentResponse && experimentName == other.experimentName && experimentUrl == other.experimentUrl && projectName == other.projectName && projectUrl == other.projectUrl && comparisonExperimentName == other.comparisonExperimentName && metrics == other.metrics && scores == other.scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(projectName, experimentName, projectUrl, experimentUrl, comparisonExperimentName, scores, metrics, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(experimentName, experimentUrl, projectName, projectUrl, comparisonExperimentName, metrics, scores, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SummarizeExperimentResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" + "SummarizeExperimentResponse{experimentName=$experimentName, experimentUrl=$experimentUrl, projectName=$projectName, projectUrl=$projectUrl, comparisonExperimentName=$comparisonExperimentName, metrics=$metrics, scores=$scores, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index a2e5425f..19f3a587 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -3,24 +3,25 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import java.util.Objects +/** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ class TopLevelHelloWorldParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -29,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [TopLevelHelloWorldParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index b17e4ade..de583017 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -7,80 +7,92 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = User.Builder::class) @NoAutoDetect class User +@JsonCreator private constructor( - private val id: JsonField, - private val givenName: JsonField, - private val familyName: JsonField, - private val email: JsonField, - private val avatarUrl: JsonField, - private val created: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("avatar_url") + @ExcludeMissing + private val avatarUrl: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing private val email: JsonField = JsonMissing.of(), + @JsonProperty("family_name") + @ExcludeMissing + private val familyName: JsonField = JsonMissing.of(), + @JsonProperty("given_name") + @ExcludeMissing + private val givenName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the user */ fun id(): String = id.getRequired("id") - /** Given name of the user */ - fun givenName(): Optional = Optional.ofNullable(givenName.getNullable("given_name")) + /** URL of the user's Avatar image */ + fun avatarUrl(): Optional = Optional.ofNullable(avatarUrl.getNullable("avatar_url")) - /** Family name of the user */ - fun familyName(): Optional = Optional.ofNullable(familyName.getNullable("family_name")) + /** Date of user creation */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** The user's email */ fun email(): Optional = Optional.ofNullable(email.getNullable("email")) - /** URL of the user's Avatar image */ - fun avatarUrl(): Optional = Optional.ofNullable(avatarUrl.getNullable("avatar_url")) + /** Family name of the user */ + fun familyName(): Optional = Optional.ofNullable(familyName.getNullable("family_name")) - /** Date of user creation */ - fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** Given name of the user */ + fun givenName(): Optional = Optional.ofNullable(givenName.getNullable("given_name")) /** Unique identifier for the user */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Given name of the user */ - @JsonProperty("given_name") @ExcludeMissing fun _givenName() = givenName + /** URL of the user's Avatar image */ + @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl(): JsonField = avatarUrl - /** Family name of the user */ - @JsonProperty("family_name") @ExcludeMissing fun _familyName() = familyName + /** Date of user creation */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** The user's email */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - /** URL of the user's Avatar image */ - @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl() = avatarUrl + /** Family name of the user */ + @JsonProperty("family_name") @ExcludeMissing fun _familyName(): JsonField = familyName - /** Date of user creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + /** Given name of the user */ + @JsonProperty("given_name") @ExcludeMissing fun _givenName(): JsonField = givenName @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): User = apply { - if (!validated) { - id() - givenName() - familyName() - email() - avatarUrl() - created() - validated = true + if (validated) { + return@apply } + + id() + avatarUrl() + created() + email() + familyName() + givenName() + validated = true } fun toBuilder() = Builder().from(this) @@ -90,95 +102,106 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [User]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var givenName: JsonField = JsonMissing.of() - private var familyName: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() + private var id: JsonField? = null private var avatarUrl: JsonField = JsonMissing.of() private var created: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var familyName: JsonField = JsonMissing.of() + private var givenName: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(user: User) = apply { - this.id = user.id - this.givenName = user.givenName - this.familyName = user.familyName - this.email = user.email - this.avatarUrl = user.avatarUrl - this.created = user.created - additionalProperties(user.additionalProperties) + id = user.id + avatarUrl = user.avatarUrl + created = user.created + email = user.email + familyName = user.familyName + givenName = user.givenName + additionalProperties = user.additionalProperties.toMutableMap() } /** Unique identifier for the user */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the user */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** Given name of the user */ - fun givenName(givenName: String) = givenName(JsonField.of(givenName)) + /** URL of the user's Avatar image */ + fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) - /** Given name of the user */ - @JsonProperty("given_name") - @ExcludeMissing - fun givenName(givenName: JsonField) = apply { this.givenName = givenName } + /** URL of the user's Avatar image */ + fun avatarUrl(avatarUrl: Optional) = avatarUrl(avatarUrl.orElse(null)) - /** Family name of the user */ - fun familyName(familyName: String) = familyName(JsonField.of(familyName)) + /** URL of the user's Avatar image */ + fun avatarUrl(avatarUrl: JsonField) = apply { this.avatarUrl = avatarUrl } - /** Family name of the user */ - @JsonProperty("family_name") - @ExcludeMissing - fun familyName(familyName: JsonField) = apply { this.familyName = familyName } + /** Date of user creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) + + /** Date of user creation */ + fun created(created: Optional) = created(created.orElse(null)) + + /** Date of user creation */ + fun created(created: JsonField) = apply { this.created = created } /** The user's email */ - fun email(email: String) = email(JsonField.of(email)) + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** The user's email */ + fun email(email: Optional) = email(email.orElse(null)) /** The user's email */ - @JsonProperty("email") - @ExcludeMissing fun email(email: JsonField) = apply { this.email = email } - /** URL of the user's Avatar image */ - fun avatarUrl(avatarUrl: String) = avatarUrl(JsonField.of(avatarUrl)) + /** Family name of the user */ + fun familyName(familyName: String?) = familyName(JsonField.ofNullable(familyName)) - /** URL of the user's Avatar image */ - @JsonProperty("avatar_url") - @ExcludeMissing - fun avatarUrl(avatarUrl: JsonField) = apply { this.avatarUrl = avatarUrl } + /** Family name of the user */ + fun familyName(familyName: Optional) = familyName(familyName.orElse(null)) - /** Date of user creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + /** Family name of the user */ + fun familyName(familyName: JsonField) = apply { this.familyName = familyName } - /** Date of user creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + /** Given name of the user */ + fun givenName(givenName: String?) = givenName(JsonField.ofNullable(givenName)) + + /** Given name of the user */ + fun givenName(givenName: Optional) = givenName(givenName.orElse(null)) + + /** Given name of the user */ + fun givenName(givenName: JsonField) = apply { this.givenName = givenName } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): User = User( - id, - givenName, - familyName, - email, + checkRequired("id", id), avatarUrl, created, + email, + familyName, + givenName, additionalProperties.toImmutable(), ) } @@ -188,15 +211,15 @@ private constructor( return true } - return /* spotless:off */ other is User && id == other.id && givenName == other.givenName && familyName == other.familyName && email == other.email && avatarUrl == other.avatarUrl && created == other.created && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && id == other.id && avatarUrl == other.avatarUrl && created == other.created && email == other.email && familyName == other.familyName && givenName == other.givenName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, givenName, familyName, email, avatarUrl, created, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, avatarUrl, created, email, familyName, givenName, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "User{id=$id, givenName=$givenName, familyName=$familyName, email=$email, avatarUrl=$avatarUrl, created=$created, additionalProperties=$additionalProperties}" + "User{id=$id, avatarUrl=$avatarUrl, created=$created, email=$email, familyName=$familyName, givenName=$givenName, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index bb5feed1..3b55e885 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.UserService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all users. The users are sorted by creation date, with the most recently-created users + * coming first + */ class UserListPage private constructor( private val usersService: UserService, @@ -79,16 +84,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -98,11 +102,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,10 +146,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -150,8 +156,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: UserListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 7d2c1d8d..473bca01 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.UserServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all users. The users are sorted by creation date, with the most recently-created users + * coming first + */ class UserListPageAsync private constructor( private val usersService: UserServiceAsync, @@ -82,16 +87,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -101,11 +105,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -141,10 +149,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -153,8 +159,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: UserListPageAsync, ) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index dd9bc6a5..64c102de 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -6,11 +6,11 @@ import com.braintrustdata.api.core.BaseDeserializer import com.braintrustdata.api.core.BaseSerializer import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params 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.braintrustdata.api.models.* import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.JsonNode @@ -21,8 +21,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all users. The users are sorted by creation date, with the most recently-created users + * coming first + */ class UserListParams -constructor( +private constructor( private val email: Email?, private val endingBefore: String?, private val familyName: FamilyName?, @@ -33,32 +37,63 @@ constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email + */ fun email(): Optional = Optional.ofNullable(email) + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Family name of the user to search for. You may pass the param multiple times to filter for + * more than one family name + */ fun familyName(): Optional = Optional.ofNullable(familyName) + /** + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name + */ fun givenName(): Optional = Optional.ofNullable(givenName) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter search results to within a particular organization */ fun orgName(): Optional = Optional.ofNullable(orgName) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.email?.let { queryParams.put("email", listOf(it.toString())) } this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } @@ -79,8 +114,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [UserListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var email: Email? = null private var endingBefore: String? = null @@ -111,19 +147,25 @@ constructor( * Email of the user to search for. You may pass the param multiple times to filter for more * than one email */ - fun email(email: Email) = apply { this.email = email } + fun email(email: Email?) = apply { this.email = email } /** * Email of the user to search for. You may pass the param multiple times to filter for more * than one email */ - fun email(string: String) = apply { this.email = Email.ofString(string) } + fun email(email: Optional) = email(email.orElse(null)) /** * Email of the user to search for. You may pass the param multiple times to filter for more * than one email */ - fun emailOfStrings(strings: List) = apply { this.email = Email.ofStrings(strings) } + fun email(string: String) = email(Email.ofString(string)) + + /** + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email + */ + fun emailOfStrings(strings: List) = email(Email.ofStrings(strings)) /** * Pagination cursor id. @@ -132,71 +174,104 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Family name of the user to search for. You may pass the param multiple times to filter * for more than one family name */ - fun familyName(familyName: FamilyName) = apply { this.familyName = familyName } + fun familyName(familyName: FamilyName?) = apply { this.familyName = familyName } /** * Family name of the user to search for. You may pass the param multiple times to filter * for more than one family name */ - fun familyName(string: String) = apply { this.familyName = FamilyName.ofString(string) } + fun familyName(familyName: Optional) = familyName(familyName.orElse(null)) /** * Family name of the user to search for. You may pass the param multiple times to filter * for more than one family name */ - fun familyNameOfStrings(strings: List) = apply { - this.familyName = FamilyName.ofStrings(strings) - } + fun familyName(string: String) = familyName(FamilyName.ofString(string)) + + /** + * Family name of the user to search for. You may pass the param multiple times to filter + * for more than one family name + */ + fun familyNameOfStrings(strings: List) = familyName(FamilyName.ofStrings(strings)) /** * Given name of the user to search for. You may pass the param multiple times to filter for * more than one given name */ - fun givenName(givenName: GivenName) = apply { this.givenName = givenName } + fun givenName(givenName: GivenName?) = apply { this.givenName = givenName } /** * Given name of the user to search for. You may pass the param multiple times to filter for * more than one given name */ - fun givenName(string: String) = apply { this.givenName = GivenName.ofString(string) } + fun givenName(givenName: Optional) = givenName(givenName.orElse(null)) /** * Given name of the user to search for. You may pass the param multiple times to filter for * more than one given name */ - fun givenNameOfStrings(strings: List) = apply { - this.givenName = GivenName.ofStrings(strings) - } + fun givenName(string: String) = givenName(GivenName.ofString(string)) + + /** + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name + */ + fun givenNameOfStrings(strings: List) = givenName(GivenName.ofStrings(strings)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) + + /** Limit the number of objects to return */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = apply { this.orgName = orgName } + + /** Filter search results to within a particular organization */ + fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) /** * Pagination cursor id. @@ -205,7 +280,17 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -320,6 +405,10 @@ constructor( ) } + /** + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email + */ @JsonDeserialize(using = Email.Deserializer::class) @JsonSerialize(using = Email.Serializer::class) class Email @@ -329,8 +418,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -353,15 +440,6 @@ constructor( } } - fun validate(): Email = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Email: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -387,18 +465,29 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Email(strings = strings) } + /** An interface that defines how to map each variant of [Email] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Email] to a value of type [T]. + * + * An instance of [Email] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Email: $json") } } - class Deserializer : BaseDeserializer(Email::class) { + internal class Deserializer : BaseDeserializer(Email::class) { override fun ObjectCodec.deserialize(node: JsonNode): Email { val json = JsonValue.fromJsonNode(node) @@ -414,7 +503,7 @@ constructor( } } - class Serializer : BaseSerializer(Email::class) { + internal class Serializer : BaseSerializer(Email::class) { override fun serialize( value: Email, @@ -431,6 +520,10 @@ constructor( } } + /** + * Family name of the user to search for. You may pass the param multiple times to filter for + * more than one family name + */ @JsonDeserialize(using = FamilyName.Deserializer::class) @JsonSerialize(using = FamilyName.Serializer::class) class FamilyName @@ -440,8 +533,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -464,15 +555,6 @@ constructor( } } - fun validate(): FamilyName = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown FamilyName: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -498,18 +580,31 @@ constructor( @JvmStatic fun ofStrings(strings: List) = FamilyName(strings = strings) } + /** + * An interface that defines how to map each variant of [FamilyName] to a value of type [T]. + */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [FamilyName] to a value of type [T]. + * + * An instance of [FamilyName] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown FamilyName: $json") } } - class Deserializer : BaseDeserializer(FamilyName::class) { + internal class Deserializer : BaseDeserializer(FamilyName::class) { override fun ObjectCodec.deserialize(node: JsonNode): FamilyName { val json = JsonValue.fromJsonNode(node) @@ -525,7 +620,7 @@ constructor( } } - class Serializer : BaseSerializer(FamilyName::class) { + internal class Serializer : BaseSerializer(FamilyName::class) { override fun serialize( value: FamilyName, @@ -542,6 +637,10 @@ constructor( } } + /** + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name + */ @JsonDeserialize(using = GivenName.Deserializer::class) @JsonSerialize(using = GivenName.Serializer::class) class GivenName @@ -551,8 +650,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -575,15 +672,6 @@ constructor( } } - fun validate(): GivenName = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown GivenName: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -609,18 +697,31 @@ constructor( @JvmStatic fun ofStrings(strings: List) = GivenName(strings = strings) } + /** + * An interface that defines how to map each variant of [GivenName] to a value of type [T]. + */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [GivenName] to a value of type [T]. + * + * An instance of [GivenName] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown GivenName: $json") } } - class Deserializer : BaseDeserializer(GivenName::class) { + internal class Deserializer : BaseDeserializer(GivenName::class) { override fun ObjectCodec.deserialize(node: JsonNode): GivenName { val json = JsonValue.fromJsonNode(node) @@ -636,7 +737,7 @@ constructor( } } - class Serializer : BaseSerializer(GivenName::class) { + internal class Serializer : BaseSerializer(GivenName::class) { override fun serialize( value: GivenName, @@ -653,6 +754,10 @@ constructor( } } + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -662,8 +767,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -686,15 +789,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -720,18 +814,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -747,7 +851,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 6ec27bd7..1b67abb8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -3,27 +3,30 @@ package com.braintrustdata.api.models 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.models.* import java.util.Objects +/** Get a user object by its id */ class UserRetrieveParams -constructor( +private constructor( private val userId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** User id */ fun userId(): String = userId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +42,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [UserRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var userId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -156,7 +160,7 @@ constructor( fun build(): UserRetrieveParams = UserRetrieveParams( - checkNotNull(userId) { "`userId` is required but was not set" }, + checkRequired("userId", userId), additionalHeaders.build(), additionalQueryParams.build(), ) 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 1800405d..bda8824d 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 @@ -8,56 +8,72 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue 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 import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = View.Builder::class) @NoAutoDetect class View +@JsonCreator private constructor( - private val id: JsonField, - private val objectType: JsonField, - private val objectId: JsonField, - private val viewType: JsonField, - private val name: JsonField, - private val created: JsonField, - private val viewData: JsonField, - private val options: JsonField, - private val userId: JsonField, - private val deletedAt: JsonField, - private val additionalProperties: Map, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") + @ExcludeMissing + private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") + @ExcludeMissing + private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - /** Unique identifier for the view */ fun id(): String = id.getRequired("id") - /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") + /** Name of the view */ + fun name(): String = name.getRequired("name") /** The id of the object the view applies to */ fun objectId(): String = objectId.getRequired("object_id") + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + /** Type of table that the view corresponds to. */ fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) - /** Name of the view */ - fun name(): String = name.getRequired("name") - /** Date of view creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** The view definition */ - fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -65,58 +81,65 @@ private constructor( /** Identifies the user who created the view */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + /** The view definition */ + fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Unique identifier for the view */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + /** Name of the view */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType() = viewType + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType - /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + /** Type of table that the view corresponds to. */ + @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType /** Date of view creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData() = viewData + /** Date of role deletion, or null if the role is still active */ + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options() = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + /** The view definition */ + @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): View = apply { - if (!validated) { - id() - objectType() - objectId() - viewType() - name() - created() - viewData().map { it.validate() } - options().map { it.validate() } - userId() - deletedAt() - validated = true + if (validated) { + return@apply } + + id() + name() + objectId() + objectType() + viewType() + created() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -126,190 +149,194 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [View]. */ + class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var viewType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var viewType: JsonField? = null private var created: JsonField = JsonMissing.of() - private var viewData: JsonField = JsonMissing.of() + private var deletedAt: JsonField = JsonMissing.of() private var options: JsonField = JsonMissing.of() private var userId: JsonField = JsonMissing.of() - private var deletedAt: JsonField = JsonMissing.of() + private var viewData: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(view: View) = apply { - this.id = view.id - this.objectType = view.objectType - this.objectId = view.objectId - this.viewType = view.viewType - this.name = view.name - this.created = view.created - this.viewData = view.viewData - this.options = view.options - this.userId = view.userId - this.deletedAt = view.deletedAt - additionalProperties(view.additionalProperties) + id = view.id + name = view.name + objectId = view.objectId + objectType = view.objectType + viewType = view.viewType + created = view.created + deletedAt = view.deletedAt + options = view.options + userId = view.userId + viewData = view.viewData + additionalProperties = view.additionalProperties.toMutableMap() } /** Unique identifier for the view */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the view */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { this.id = id } - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + /** Name of the view */ + fun name(name: String) = name(JsonField.of(name)) - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + /** Name of the view */ + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = viewType(JsonField.of(viewType)) + fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - @ExcludeMissing - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) - /** Name of the view */ - fun name(name: String) = name(JsonField.of(name)) + /** Type of table that the view corresponds to. */ + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } - /** Name of the view */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + /** Date of view creation */ + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of view creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: Optional) = created(created.orElse(null)) /** Date of view creation */ - @JsonProperty("created") - @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } - /** The view definition */ - fun viewData(viewData: ViewData) = viewData(JsonField.of(viewData)) + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** The view definition */ - @JsonProperty("view_data") - @ExcludeMissing - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + + /** Options for the view in the app */ + fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) /** Options for the view in the app */ - fun options(options: ViewOptions) = options(JsonField.of(options)) + fun options(options: Optional) = options(options.orElse(null)) /** Options for the view in the app */ - @JsonProperty("options") - @ExcludeMissing fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ - fun userId(userId: String) = userId(JsonField.of(userId)) + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Identifies the user who created the view */ + fun userId(userId: Optional) = userId(userId.orElse(null)) /** Identifies the user who created the view */ - @JsonProperty("user_id") - @ExcludeMissing fun userId(userId: JsonField) = apply { this.userId = userId } - /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) + /** The view definition */ + fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) - /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + /** The view definition */ + fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + + /** The view definition */ + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): View = View( - id, - objectType, - objectId, - viewType, - name, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + checkRequired("viewType", viewType), created, - viewData, + deletedAt, options, userId, - deletedAt, + viewData, additionalProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -324,6 +351,15 @@ private constructor( 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, @@ -336,9 +372,19 @@ private constructor( 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 @@ -355,6 +401,15 @@ private constructor( 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 @@ -372,49 +427,59 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + 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 { + + /** + * 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 = ViewType(JsonField.of("projects")) + @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = ViewType(JsonField.of("logs")) + @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) + @JvmField val EXPERIMENTS = of("experiments") - @JvmField val DATASETS = ViewType(JsonField.of("datasets")) + @JvmField val DATASETS = of("datasets") - @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) + @JvmField val PLAYGROUNDS = of("playgrounds") - @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ViewType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } + /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, LOGS, @@ -426,6 +491,15 @@ private constructor( DATASET, } + /** + * 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, LOGS, @@ -435,9 +509,17 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, + /** 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 @@ -451,6 +533,15 @@ private constructor( 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 @@ -465,6 +556,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -472,15 +575,15 @@ private constructor( return true } - return /* spotless:off */ other is View && id == other.id && objectType == other.objectType && objectId == other.objectId && viewType == other.viewType && name == other.name && created == other.created && viewData == other.viewData && options == other.options && userId == other.userId && deletedAt == other.deletedAt && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is View && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && created == other.created && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, objectType, objectId, viewType, name, created, viewData, options, userId, deletedAt, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, objectId, objectType, viewType, created, deletedAt, options, userId, viewData, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "View{id=$id, objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, created=$created, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" + "View{id=$id, name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, created=$created, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } 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 09431370..c44ac228 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 @@ -5,121 +5,202 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * Create a new view. If there is an existing view with the same name as the one specified in the + * request, will return the existing view unmodified + */ class ViewCreateParams -constructor( - private val name: String, - private val objectId: String, - private val objectType: ObjectType, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, +private constructor( + private val body: ViewCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the view */ + fun name(): String = body.name() - fun objectId(): String = objectId + /** The id of the object the view applies to */ + fun objectId(): String = body.objectId() - fun objectType(): ObjectType = objectType + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = body.objectType() - fun viewType(): Optional = Optional.ofNullable(viewType) + /** Type of table that the view corresponds to. */ + fun viewType(): Optional = body.viewType() - fun deletedAt(): Optional = Optional.ofNullable(deletedAt) + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(): Optional = body.deletedAt() - fun options(): Optional = Optional.ofNullable(options) + /** Options for the view in the app */ + fun options(): Optional = body.options() - fun userId(): Optional = Optional.ofNullable(userId) + /** Identifies the user who created the view */ + fun userId(): Optional = body.userId() - fun viewData(): Optional = Optional.ofNullable(viewData) + /** The view definition */ + fun viewData(): Optional = body.viewData() + + /** Name of the view */ + fun _name(): JsonField = body._name() + + /** 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() + + /** Type of table that the view corresponds to. */ + fun _viewType(): JsonField = body._viewType() + + /** Date of role deletion, or null if the role is still active */ + fun _deletedAt(): JsonField = body._deletedAt() + + /** Options for the view in the app */ + fun _options(): JsonField = body._options() + + /** Identifies the user who created the view */ + fun _userId(): JsonField = body._userId() + + /** The view definition */ + fun _viewData(): JsonField = body._viewData() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ViewCreateBody { - return ViewCreateBody( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ViewCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = ViewCreateBody.Builder::class) @NoAutoDetect class ViewCreateBody + @JsonCreator internal constructor( - private val name: String?, - private val objectId: String?, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") + @ExcludeMissing + private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") + @ExcludeMissing + private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the view */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** The id of the object the view applies to */ + fun objectId(): String = objectId.getRequired("object_id") + + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** Type of table that the view corresponds to. */ + fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) + + /** Options for the view in the app */ + fun options(): Optional = Optional.ofNullable(options.getNullable("options")) + + /** Identifies the user who created the view */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The view definition */ + fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) + + /** Name of the view */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") fun viewType(): ViewType? = viewType + @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") fun deletedAt(): OffsetDateTime? = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") fun options(): ViewOptions? = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(): String? = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") fun viewData(): ViewData? = viewData + @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ViewCreateBody = apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + viewType() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -127,81 +208,124 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ViewCreateBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var viewType: ViewType? = null - private var deletedAt: OffsetDateTime? = null - private var options: ViewOptions? = null - private var userId: String? = null - private var viewData: ViewData? = null + private var name: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var viewType: JsonField? = null + private var deletedAt: JsonField = JsonMissing.of() + private var options: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var viewData: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewCreateBody: ViewCreateBody) = apply { - this.name = viewCreateBody.name - this.objectId = viewCreateBody.objectId - this.objectType = viewCreateBody.objectType - this.viewType = viewCreateBody.viewType - this.deletedAt = viewCreateBody.deletedAt - this.options = viewCreateBody.options - this.userId = viewCreateBody.userId - this.viewData = viewCreateBody.viewData - additionalProperties(viewCreateBody.additionalProperties) + name = viewCreateBody.name + objectId = viewCreateBody.objectId + objectType = viewCreateBody.objectType + viewType = viewCreateBody.viewType + deletedAt = viewCreateBody.deletedAt + options = viewCreateBody.options + userId = viewCreateBody.userId + viewData = viewCreateBody.viewData + additionalProperties = viewCreateBody.additionalProperties.toMutableMap() } /** Name of the view */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the view */ + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the view applies to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ - @JsonProperty("options") - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) + + /** Options for the view in the app */ + fun options(options: Optional) = options(options.orElse(null)) + + /** Options for the view in the app */ + fun options(options: JsonField) = apply { this.options = options } + + /** Identifies the user who created the view */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Identifies the user who created the view */ + fun userId(userId: Optional) = userId(userId.orElse(null)) /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ - @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) + + /** The view definition */ + fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + + /** The view definition */ + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ViewCreateBody = ViewCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - viewType, + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + checkRequired("viewType", viewType), deletedAt, options, userId, @@ -235,59 +359,102 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ViewCreateParams]. */ @NoAutoDetect - class Builder { - - private var name: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var viewType: ViewType? = null - private var deletedAt: OffsetDateTime? = null - private var options: ViewOptions? = null - private var userId: String? = null - private var viewData: ViewData? = null + class Builder internal constructor() { + + private var body: ViewCreateBody.Builder = ViewCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewCreateParams: ViewCreateParams) = apply { - name = viewCreateParams.name - objectId = viewCreateParams.objectId - objectType = viewCreateParams.objectType - viewType = viewCreateParams.viewType - deletedAt = viewCreateParams.deletedAt - options = viewCreateParams.options - userId = viewCreateParams.userId - viewData = viewCreateParams.viewData + body = viewCreateParams.body.toBuilder() additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = viewCreateParams.additionalBodyProperties.toMutableMap() } /** Name of the view */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the view */ + fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { body.objectId(objectId) } + + /** The id of the object the view applies to */ + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } + + /** Options for the view in the app */ + fun options(options: ViewOptions?) = apply { body.options(options) } + + /** Options for the view in the app */ + fun options(options: Optional) = options(options.orElse(null)) /** Options for the view in the app */ - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: JsonField) = apply { body.options(options) } /** Identifies the user who created the view */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String?) = apply { body.userId(userId) } + + /** Identifies the user who created the view */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Identifies the user who created the view */ + fun userId(userId: JsonField) = apply { body.userId(userId) } + + /** The view definition */ + fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + + /** The view definition */ + fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) /** The view definition */ - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -387,91 +554,59 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ViewCreateParams = ViewCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - viewType, - deletedAt, - options, - userId, - viewData, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -486,6 +621,15 @@ constructor( 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, @@ -498,9 +642,19 @@ constructor( 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 @@ -517,6 +671,15 @@ constructor( 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 @@ -534,49 +697,59 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + 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 { + + /** + * 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 = ViewType(JsonField.of("projects")) + @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = ViewType(JsonField.of("logs")) + @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) + @JvmField val EXPERIMENTS = of("experiments") - @JvmField val DATASETS = ViewType(JsonField.of("datasets")) + @JvmField val DATASETS = of("datasets") - @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) + @JvmField val PLAYGROUNDS = of("playgrounds") - @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ViewType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } + /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, LOGS, @@ -588,6 +761,15 @@ constructor( DATASET, } + /** + * 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, LOGS, @@ -597,9 +779,17 @@ constructor( PLAYGROUNDS, EXPERIMENT, DATASET, + /** 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 @@ -613,6 +803,15 @@ constructor( 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 @@ -627,6 +826,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -634,11 +845,11 @@ constructor( return true } - return /* spotless:off */ other is ViewCreateParams && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ViewCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 54e1a726..3ea48703 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -7,38 +7,43 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional /** The view definition */ -@JsonDeserialize(builder = ViewData.Builder::class) @NoAutoDetect class ViewData +@JsonCreator private constructor( - private val search: JsonField, - private val additionalProperties: Map, + @JsonProperty("search") + @ExcludeMissing + private val search: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun search(): Optional = Optional.ofNullable(search.getNullable("search")) - @JsonProperty("search") @ExcludeMissing fun _search() = search + @JsonProperty("search") @ExcludeMissing fun _search(): JsonField = search @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ViewData = apply { - if (!validated) { - search().map { it.validate() } - validated = true + if (validated) { + return@apply } + + search().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -48,37 +53,43 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ViewData]. */ + class Builder internal constructor() { private var search: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewData: ViewData) = apply { - this.search = viewData.search - additionalProperties(viewData.additionalProperties) + search = viewData.search + additionalProperties = viewData.additionalProperties.toMutableMap() } - fun search(search: ViewDataSearch) = search(JsonField.of(search)) + fun search(search: ViewDataSearch?) = search(JsonField.ofNullable(search)) + + fun search(search: Optional) = search(search.orElse(null)) - @JsonProperty("search") - @ExcludeMissing fun search(search: JsonField) = apply { this.search = search } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ViewData = ViewData(search, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 1ec4696a..1c403815 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -7,55 +7,66 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional -@JsonDeserialize(builder = ViewDataSearch.Builder::class) @NoAutoDetect class ViewDataSearch +@JsonCreator private constructor( - private val filter: JsonField>, - private val tag: JsonField>, - private val match: JsonField>, - private val sort: JsonField>, - private val additionalProperties: Map, + @JsonProperty("filter") + @ExcludeMissing + private val filter: JsonField> = JsonMissing.of(), + @JsonProperty("match") + @ExcludeMissing + private val match: JsonField> = JsonMissing.of(), + @JsonProperty("sort") + @ExcludeMissing + private val sort: JsonField> = JsonMissing.of(), + @JsonProperty("tag") + @ExcludeMissing + private val tag: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun filter(): Optional> = Optional.ofNullable(filter.getNullable("filter")) - fun tag(): Optional> = Optional.ofNullable(tag.getNullable("tag")) - fun match(): Optional> = Optional.ofNullable(match.getNullable("match")) fun sort(): Optional> = Optional.ofNullable(sort.getNullable("sort")) - @JsonProperty("filter") @ExcludeMissing fun _filter() = filter + fun tag(): Optional> = Optional.ofNullable(tag.getNullable("tag")) - @JsonProperty("tag") @ExcludeMissing fun _tag() = tag + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField> = filter - @JsonProperty("match") @ExcludeMissing fun _match() = match + @JsonProperty("match") @ExcludeMissing fun _match(): JsonField> = match - @JsonProperty("sort") @ExcludeMissing fun _sort() = sort + @JsonProperty("sort") @ExcludeMissing fun _sort(): JsonField> = sort + + @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField> = tag @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ViewDataSearch = apply { - if (!validated) { - filter() - tag() - match() - sort() - validated = true + if (validated) { + return@apply } + + filter() + match() + sort() + tag() + validated = true } fun toBuilder() = Builder().from(this) @@ -65,67 +76,133 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ViewDataSearch]. */ + class Builder internal constructor() { - private var filter: JsonField> = JsonMissing.of() - private var tag: JsonField> = JsonMissing.of() - private var match: JsonField> = JsonMissing.of() - private var sort: JsonField> = JsonMissing.of() + private var filter: JsonField>? = null + private var match: JsonField>? = null + private var sort: JsonField>? = null + private var tag: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewDataSearch: ViewDataSearch) = apply { - this.filter = viewDataSearch.filter - this.tag = viewDataSearch.tag - this.match = viewDataSearch.match - this.sort = viewDataSearch.sort - additionalProperties(viewDataSearch.additionalProperties) + filter = viewDataSearch.filter.map { it.toMutableList() } + match = viewDataSearch.match.map { it.toMutableList() } + sort = viewDataSearch.sort.map { it.toMutableList() } + tag = viewDataSearch.tag.map { it.toMutableList() } + additionalProperties = viewDataSearch.additionalProperties.toMutableMap() } - fun filter(filter: List) = filter(JsonField.of(filter)) + fun filter(filter: List?) = filter(JsonField.ofNullable(filter)) - @JsonProperty("filter") - @ExcludeMissing - fun filter(filter: JsonField>) = apply { this.filter = filter } + fun filter(filter: Optional>) = filter(filter.orElse(null)) - fun tag(tag: List) = tag(JsonField.of(tag)) + fun filter(filter: JsonField>) = apply { + this.filter = filter.map { it.toMutableList() } + } - @JsonProperty("tag") - @ExcludeMissing - fun tag(tag: JsonField>) = apply { this.tag = tag } + fun addFilter(filter: JsonValue) = apply { + this.filter = + (this.filter ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(filter) + } + } - fun match(match: List) = match(JsonField.of(match)) + fun match(match: List?) = match(JsonField.ofNullable(match)) - @JsonProperty("match") - @ExcludeMissing - fun match(match: JsonField>) = apply { this.match = match } + fun match(match: Optional>) = match(match.orElse(null)) - fun sort(sort: List) = sort(JsonField.of(sort)) + fun match(match: JsonField>) = apply { + this.match = match.map { it.toMutableList() } + } - @JsonProperty("sort") - @ExcludeMissing - fun sort(sort: JsonField>) = apply { this.sort = sort } + fun addMatch(match: JsonValue) = apply { + this.match = + (this.match ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(match) + } + } + + fun sort(sort: List?) = sort(JsonField.ofNullable(sort)) + + fun sort(sort: Optional>) = sort(sort.orElse(null)) + + fun sort(sort: JsonField>) = apply { + this.sort = sort.map { it.toMutableList() } + } + + fun addSort(sort: JsonValue) = apply { + this.sort = + (this.sort ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(sort) + } + } + + fun tag(tag: List?) = tag(JsonField.ofNullable(tag)) + + fun tag(tag: Optional>) = tag(tag.orElse(null)) + + fun tag(tag: JsonField>) = apply { + this.tag = tag.map { it.toMutableList() } + } + + fun addTag(tag: JsonValue) = apply { + this.tag = + (this.tag ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tag) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ViewDataSearch = ViewDataSearch( - filter.map { it.toImmutable() }, - tag.map { it.toImmutable() }, - match.map { it.toImmutable() }, - sort.map { it.toImmutable() }, + (filter ?: JsonMissing.of()).map { it.toImmutable() }, + (match ?: JsonMissing.of()).map { it.toImmutable() }, + (sort ?: JsonMissing.of()).map { it.toImmutable() }, + (tag ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -135,15 +212,15 @@ private constructor( return true } - return /* spotless:off */ other is ViewDataSearch && filter == other.filter && tag == other.tag && match == other.match && sort == other.sort && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewDataSearch && filter == other.filter && match == other.match && sort == other.sort && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(filter, tag, match, sort, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(filter, match, sort, tag, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ViewDataSearch{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" + "ViewDataSearch{filter=$filter, match=$match, sort=$sort, tag=$tag, additionalProperties=$additionalProperties}" } 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 000f4ab3..b983002f 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 @@ -5,54 +5,57 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects +/** Delete a view object by its id */ class ViewDeleteParams -constructor( +private constructor( private val viewId: String, - private val objectId: String, - private val objectType: ObjectType, + private val body: ViewDeleteBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** View id */ fun viewId(): String = viewId - fun objectId(): String = objectId + /** The id of the object the view applies to */ + fun objectId(): String = body.objectId() - fun objectType(): ObjectType = objectType + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = 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 _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties + @JvmSynthetic internal fun _body(): ViewDeleteBody = body - @JvmSynthetic - internal fun getBody(): ViewDeleteBody { - return ViewDeleteBody( - objectId, - objectType, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -61,25 +64,50 @@ constructor( } } - @JsonDeserialize(builder = ViewDeleteBody.Builder::class) @NoAutoDetect class ViewDeleteBody + @JsonCreator internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the view applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** The id of the object the view applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ViewDeleteBody = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -87,45 +115,57 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ViewDeleteBody]. */ + class Builder internal constructor() { - private var objectId: String? = null - private var objectType: ObjectType? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewDeleteBody: ViewDeleteBody) = apply { - this.objectId = viewDeleteBody.objectId - this.objectType = viewDeleteBody.objectType - additionalProperties(viewDeleteBody.additionalProperties) + objectId = viewDeleteBody.objectId + objectType = viewDeleteBody.objectType + additionalProperties = viewDeleteBody.additionalProperties.toMutableMap() } /** The id of the object the view applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the view applies to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ViewDeleteBody = ViewDeleteBody( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), additionalProperties.toImmutable(), ) } @@ -155,34 +195,56 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ViewDeleteParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var viewId: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null + private var body: ViewDeleteBody.Builder = ViewDeleteBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewDeleteParams: ViewDeleteParams) = apply { viewId = viewDeleteParams.viewId - objectId = viewDeleteParams.objectId - objectType = viewDeleteParams.objectType + body = viewDeleteParams.body.toBuilder() additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = viewDeleteParams.additionalBodyProperties.toMutableMap() } /** View id */ fun viewId(viewId: String) = apply { this.viewId = viewId } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { body.objectId(objectId) } + + /** The id of the object the view applies to */ + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -282,86 +344,60 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ViewDeleteParams = ViewDeleteParams( - checkNotNull(viewId) { "`viewId` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("viewId", viewId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -376,6 +412,15 @@ constructor( 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, @@ -388,9 +433,19 @@ constructor( 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 @@ -407,6 +462,15 @@ constructor( 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 @@ -424,6 +488,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -431,11 +507,11 @@ constructor( return true } - return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ViewDeleteParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index 0c004876..3cc46b1f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -7,17 +7,22 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.blocking.ViewService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * List out all views. The views are sorted by creation date, with the most recently-created views + * coming first + */ class ViewListPage private constructor( private val viewsService: ViewService, @@ -79,16 +84,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -98,11 +102,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,10 +146,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -150,8 +156,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ViewListPage, ) : Iterable { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index d524096c..a0e07698 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -7,18 +7,23 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.services.async.ViewServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * List out all views. The views are sorted by creation date, with the most recently-created views + * coming first + */ class ViewListPageAsync private constructor( private val viewsService: ViewServiceAsync, @@ -82,16 +87,15 @@ private constructor( ) } - @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect class Response + @JsonCreator constructor( - private val objects: JsonField>, - private val additionalProperties: Map, + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun objects(): List = objects.getNullable("objects") ?: listOf() @JsonProperty("objects") @@ -101,11 +105,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true + if (validated) { + return@apply } + + objects().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -141,10 +149,8 @@ private constructor( fun objects(objects: List) = objects(JsonField.of(objects)) - @JsonProperty("objects") fun objects(objects: JsonField>) = apply { this.objects = objects } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } @@ -153,8 +159,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ViewListPageAsync, ) { 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 9f97f328..b26927cf 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 @@ -8,11 +8,12 @@ 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 +import com.braintrustdata.api.core.checkRequired 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.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -24,8 +25,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +/** + * List out all views. The views are sorted by creation date, with the most recently-created views + * coming first + */ class ViewListParams -constructor( +private constructor( private val objectId: String, private val objectType: ObjectType, private val endingBefore: String?, @@ -36,32 +41,54 @@ constructor( private val viewType: ViewType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** The id of the object the ACL applies to */ fun objectId(): String = objectId + /** The object type that the ACL applies to */ fun objectType(): ObjectType = objectType + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times + */ fun ids(): Optional = Optional.ofNullable(ids) + /** Limit the number of objects to return */ fun limit(): Optional = Optional.ofNullable(limit) + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` + */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + /** Name of the view to search for */ fun viewName(): Optional = Optional.ofNullable(viewName) + /** Type of table that the view corresponds to. */ fun viewType(): Optional = Optional.ofNullable(viewType) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } @@ -82,8 +109,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ViewListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var objectId: String? = null private var objectType: ObjectType? = null @@ -123,28 +151,50 @@ constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** + * Pagination cursor id. + * + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Ids) = apply { this.ids = ids } + fun ids(ids: Ids?) = apply { this.ids = ids } /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(ids: Optional) = ids(ids.orElse(null)) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun idsOfStrings(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(string: String) = ids(Ids.ofString(string)) + + /** + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times + */ + fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } + fun limit(limit: Long?) = apply { this.limit = limit } + + /** Limit the number of objects to return */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Limit the number of objects to return */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) /** * Pagination cursor id. @@ -153,13 +203,29 @@ constructor( * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** + * Pagination cursor id. + * + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` + */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.orElse(null)) + + /** Name of the view to search for */ + fun viewName(viewName: String?) = apply { this.viewName = viewName } /** Name of the view to search for */ - fun viewName(viewName: String) = apply { this.viewName = viewName } + fun viewName(viewName: Optional) = viewName(viewName.orElse(null)) /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType?) = apply { this.viewType = viewType } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -261,8 +327,8 @@ constructor( fun build(): ViewListParams = ViewListParams( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), endingBefore, ids, limit, @@ -274,53 +340,51 @@ 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -335,6 +399,15 @@ constructor( 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, @@ -347,9 +420,19 @@ constructor( 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 @@ -366,6 +449,15 @@ constructor( 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 @@ -383,8 +475,24 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 + */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) class Ids @@ -394,8 +502,6 @@ constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - fun string(): Optional = Optional.ofNullable(string) fun strings(): Optional> = Optional.ofNullable(strings) @@ -418,15 +524,6 @@ constructor( } } - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -452,18 +549,28 @@ constructor( @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T fun visitStrings(strings: List): T + /** + * Maps an unknown variant of [Ids] to a value of type [T]. + * + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ fun unknown(json: JsonValue?): T { throw BraintrustInvalidDataException("Unknown Ids: $json") } } - class Deserializer : BaseDeserializer(Ids::class) { + internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { val json = JsonValue.fromJsonNode(node) @@ -479,7 +586,7 @@ constructor( } } - class Serializer : BaseSerializer(Ids::class) { + internal class Serializer : BaseSerializer(Ids::class) { override fun serialize( value: Ids, @@ -496,47 +603,45 @@ 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 - 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() - companion object { - @JvmField val PROJECTS = ViewType(JsonField.of("projects")) + @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = ViewType(JsonField.of("logs")) + @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) + @JvmField val EXPERIMENTS = of("experiments") - @JvmField val DATASETS = ViewType(JsonField.of("datasets")) + @JvmField val DATASETS = of("datasets") - @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) + @JvmField val PLAYGROUNDS = of("playgrounds") - @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ViewType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } + /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, LOGS, @@ -548,6 +653,15 @@ constructor( DATASET, } + /** + * 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, LOGS, @@ -557,9 +671,17 @@ constructor( PLAYGROUNDS, EXPERIMENT, DATASET, + /** 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 @@ -573,6 +695,15 @@ constructor( 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 @@ -587,6 +718,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 29a55165..aa11025b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -7,53 +7,68 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing 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.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional /** Options for the view in the app */ -@JsonDeserialize(builder = ViewOptions.Builder::class) @NoAutoDetect class ViewOptions +@JsonCreator private constructor( - private val columnVisibility: JsonField, - private val columnOrder: JsonField>, - private val columnSizing: JsonField, - private val additionalProperties: Map, + @JsonProperty("columnOrder") + @ExcludeMissing + private val columnOrder: JsonField> = JsonMissing.of(), + @JsonProperty("columnSizing") + @ExcludeMissing + private val columnSizing: JsonField = JsonMissing.of(), + @JsonProperty("columnVisibility") + @ExcludeMissing + private val columnVisibility: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - - fun columnVisibility(): Optional = - Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) - fun columnOrder(): Optional> = Optional.ofNullable(columnOrder.getNullable("columnOrder")) fun columnSizing(): Optional = Optional.ofNullable(columnSizing.getNullable("columnSizing")) - @JsonProperty("columnVisibility") @ExcludeMissing fun _columnVisibility() = columnVisibility + fun columnVisibility(): Optional = + Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) + + @JsonProperty("columnOrder") + @ExcludeMissing + fun _columnOrder(): JsonField> = columnOrder - @JsonProperty("columnOrder") @ExcludeMissing fun _columnOrder() = columnOrder + @JsonProperty("columnSizing") + @ExcludeMissing + fun _columnSizing(): JsonField = columnSizing - @JsonProperty("columnSizing") @ExcludeMissing fun _columnSizing() = columnSizing + @JsonProperty("columnVisibility") + @ExcludeMissing + fun _columnVisibility(): JsonField = columnVisibility @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ViewOptions = apply { - if (!validated) { - columnVisibility().map { it.validate() } - columnOrder() - columnSizing().map { it.validate() } - validated = true + if (validated) { + return@apply } + + columnOrder() + columnSizing().ifPresent { it.validate() } + columnVisibility().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -63,86 +78,111 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ViewOptions]. */ + class Builder internal constructor() { - private var columnVisibility: JsonField = JsonMissing.of() - private var columnOrder: JsonField> = JsonMissing.of() + private var columnOrder: JsonField>? = null private var columnSizing: JsonField = JsonMissing.of() + private var columnVisibility: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewOptions: ViewOptions) = apply { - this.columnVisibility = viewOptions.columnVisibility - this.columnOrder = viewOptions.columnOrder - this.columnSizing = viewOptions.columnSizing - additionalProperties(viewOptions.additionalProperties) + columnOrder = viewOptions.columnOrder.map { it.toMutableList() } + columnSizing = viewOptions.columnSizing + columnVisibility = viewOptions.columnVisibility + additionalProperties = viewOptions.additionalProperties.toMutableMap() } - fun columnVisibility(columnVisibility: ColumnVisibility) = - columnVisibility(JsonField.of(columnVisibility)) - - @JsonProperty("columnVisibility") - @ExcludeMissing - fun columnVisibility(columnVisibility: JsonField) = apply { - this.columnVisibility = columnVisibility - } + fun columnOrder(columnOrder: List?) = columnOrder(JsonField.ofNullable(columnOrder)) - fun columnOrder(columnOrder: List) = columnOrder(JsonField.of(columnOrder)) + fun columnOrder(columnOrder: Optional>) = columnOrder(columnOrder.orElse(null)) - @JsonProperty("columnOrder") - @ExcludeMissing fun columnOrder(columnOrder: JsonField>) = apply { - this.columnOrder = columnOrder + this.columnOrder = columnOrder.map { it.toMutableList() } + } + + fun addColumnOrder(columnOrder: String) = apply { + this.columnOrder = + (this.columnOrder ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(columnOrder) + } } - fun columnSizing(columnSizing: ColumnSizing) = columnSizing(JsonField.of(columnSizing)) + fun columnSizing(columnSizing: ColumnSizing?) = + columnSizing(JsonField.ofNullable(columnSizing)) + + fun columnSizing(columnSizing: Optional) = + columnSizing(columnSizing.orElse(null)) - @JsonProperty("columnSizing") - @ExcludeMissing fun columnSizing(columnSizing: JsonField) = apply { this.columnSizing = columnSizing } + fun columnVisibility(columnVisibility: ColumnVisibility?) = + columnVisibility(JsonField.ofNullable(columnVisibility)) + + fun columnVisibility(columnVisibility: Optional) = + columnVisibility(columnVisibility.orElse(null)) + + fun columnVisibility(columnVisibility: JsonField) = apply { + this.columnVisibility = columnVisibility + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ViewOptions = ViewOptions( - columnVisibility, - columnOrder.map { it.toImmutable() }, + (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, columnSizing, + columnVisibility, additionalProperties.toImmutable(), ) } - @JsonDeserialize(builder = ColumnSizing.Builder::class) @NoAutoDetect class ColumnSizing + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ColumnSizing = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -152,29 +192,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ColumnSizing]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(columnSizing: ColumnSizing) = apply { - additionalProperties(columnSizing.additionalProperties) + additionalProperties = columnSizing.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ColumnSizing = ColumnSizing(additionalProperties.toImmutable()) } @@ -195,23 +241,26 @@ private constructor( override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" } - @JsonDeserialize(builder = ColumnVisibility.Builder::class) @NoAutoDetect class ColumnVisibility + @JsonCreator private constructor( - private val additionalProperties: Map, + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): ColumnVisibility = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -221,29 +270,35 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ColumnVisibility]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(columnVisibility: ColumnVisibility) = apply { - additionalProperties(columnVisibility.additionalProperties) + additionalProperties = columnVisibility.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toImmutable()) } @@ -269,15 +324,15 @@ private constructor( return true } - return /* spotless:off */ other is ViewOptions && columnVisibility == other.columnVisibility && columnOrder == other.columnOrder && columnSizing == other.columnSizing && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(columnVisibility, columnOrder, columnSizing, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(columnOrder, columnSizing, columnVisibility, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ViewOptions{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" + "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" } 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 73d0660c..bec281e7 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 @@ -5,121 +5,202 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * Create or replace view. If there is an existing view with the same name as the one specified in + * the request, will replace the existing view with the provided fields + */ class ViewReplaceParams -constructor( - private val name: String, - private val objectId: String, - private val objectType: ObjectType, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, +private constructor( + private val body: ViewReplaceBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { - fun name(): String = name + /** Name of the view */ + fun name(): String = body.name() - fun objectId(): String = objectId + /** The id of the object the view applies to */ + fun objectId(): String = body.objectId() - fun objectType(): ObjectType = objectType + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = body.objectType() - fun viewType(): Optional = Optional.ofNullable(viewType) + /** Type of table that the view corresponds to. */ + fun viewType(): Optional = body.viewType() - fun deletedAt(): Optional = Optional.ofNullable(deletedAt) + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(): Optional = body.deletedAt() - fun options(): Optional = Optional.ofNullable(options) + /** Options for the view in the app */ + fun options(): Optional = body.options() - fun userId(): Optional = Optional.ofNullable(userId) + /** Identifies the user who created the view */ + fun userId(): Optional = body.userId() - fun viewData(): Optional = Optional.ofNullable(viewData) + /** The view definition */ + fun viewData(): Optional = body.viewData() + + /** Name of the view */ + fun _name(): JsonField = body._name() + + /** 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() + + /** Type of table that the view corresponds to. */ + fun _viewType(): JsonField = body._viewType() + + /** Date of role deletion, or null if the role is still active */ + fun _deletedAt(): JsonField = body._deletedAt() + + /** Options for the view in the app */ + fun _options(): JsonField = body._options() + + /** Identifies the user who created the view */ + fun _userId(): JsonField = body._userId() + + /** The view definition */ + fun _viewData(): JsonField = body._viewData() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ViewReplaceBody { - return ViewReplaceBody( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ViewReplaceBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(builder = ViewReplaceBody.Builder::class) @NoAutoDetect class ViewReplaceBody + @JsonCreator internal constructor( - private val name: String?, - private val objectId: String?, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalProperties: Map, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") + @ExcludeMissing + private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") + @ExcludeMissing + private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the view */ - @JsonProperty("name") fun name(): String? = name + fun name(): String = name.getRequired("name") + + /** The id of the object the view applies to */ + fun objectId(): String = objectId.getRequired("object_id") + + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** Type of table that the view corresponds to. */ + fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) + + /** Options for the view in the app */ + fun options(): Optional = Optional.ofNullable(options.getNullable("options")) + + /** Identifies the user who created the view */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The view definition */ + fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) + + /** Name of the view */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") fun viewType(): ViewType? = viewType + @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") fun deletedAt(): OffsetDateTime? = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") fun options(): ViewOptions? = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(): String? = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") fun viewData(): ViewData? = viewData + @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ViewReplaceBody = apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + viewType() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -127,81 +208,124 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ViewReplaceBody]. */ + class Builder internal constructor() { - private var name: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var viewType: ViewType? = null - private var deletedAt: OffsetDateTime? = null - private var options: ViewOptions? = null - private var userId: String? = null - private var viewData: ViewData? = null + private var name: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var viewType: JsonField? = null + private var deletedAt: JsonField = JsonMissing.of() + private var options: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var viewData: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewReplaceBody: ViewReplaceBody) = apply { - this.name = viewReplaceBody.name - this.objectId = viewReplaceBody.objectId - this.objectType = viewReplaceBody.objectType - this.viewType = viewReplaceBody.viewType - this.deletedAt = viewReplaceBody.deletedAt - this.options = viewReplaceBody.options - this.userId = viewReplaceBody.userId - this.viewData = viewReplaceBody.viewData - additionalProperties(viewReplaceBody.additionalProperties) + name = viewReplaceBody.name + objectId = viewReplaceBody.objectId + objectType = viewReplaceBody.objectType + viewType = viewReplaceBody.viewType + deletedAt = viewReplaceBody.deletedAt + options = viewReplaceBody.options + userId = viewReplaceBody.userId + viewData = viewReplaceBody.viewData + additionalProperties = viewReplaceBody.additionalProperties.toMutableMap() } /** Name of the view */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Name of the view */ + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the view applies to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ - @JsonProperty("options") - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) + + /** Options for the view in the app */ + fun options(options: Optional) = options(options.orElse(null)) + + /** Options for the view in the app */ + fun options(options: JsonField) = apply { this.options = options } + + /** Identifies the user who created the view */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Identifies the user who created the view */ + fun userId(userId: Optional) = userId(userId.orElse(null)) /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ - @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) + + /** The view definition */ + fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + + /** The view definition */ + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ViewReplaceBody = ViewReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - viewType, + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + checkRequired("viewType", viewType), deletedAt, options, userId, @@ -235,59 +359,102 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ViewReplaceParams]. */ @NoAutoDetect - class Builder { - - private var name: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var viewType: ViewType? = null - private var deletedAt: OffsetDateTime? = null - private var options: ViewOptions? = null - private var userId: String? = null - private var viewData: ViewData? = null + class Builder internal constructor() { + + private var body: ViewReplaceBody.Builder = ViewReplaceBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewReplaceParams: ViewReplaceParams) = apply { - name = viewReplaceParams.name - objectId = viewReplaceParams.objectId - objectType = viewReplaceParams.objectType - viewType = viewReplaceParams.viewType - deletedAt = viewReplaceParams.deletedAt - options = viewReplaceParams.options - userId = viewReplaceParams.userId - viewData = viewReplaceParams.viewData + body = viewReplaceParams.body.toBuilder() additionalHeaders = viewReplaceParams.additionalHeaders.toBuilder() additionalQueryParams = viewReplaceParams.additionalQueryParams.toBuilder() - additionalBodyProperties = viewReplaceParams.additionalBodyProperties.toMutableMap() } /** Name of the view */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { body.name(name) } + + /** Name of the view */ + fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { body.objectId(objectId) } + + /** The id of the object the view applies to */ + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + + /** Date of role deletion, or null if the role is still active */ + fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } + + /** Options for the view in the app */ + fun options(options: ViewOptions?) = apply { body.options(options) } + + /** Options for the view in the app */ + fun options(options: Optional) = options(options.orElse(null)) /** Options for the view in the app */ - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: JsonField) = apply { body.options(options) } /** Identifies the user who created the view */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String?) = apply { body.userId(userId) } + + /** Identifies the user who created the view */ + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Identifies the user who created the view */ + fun userId(userId: JsonField) = apply { body.userId(userId) } + + /** The view definition */ + fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + + /** The view definition */ + fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) /** The view definition */ - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -387,91 +554,59 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ViewReplaceParams = ViewReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - viewType, - deletedAt, - options, - userId, - viewData, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -486,6 +621,15 @@ constructor( 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, @@ -498,9 +642,19 @@ constructor( 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 @@ -517,6 +671,15 @@ constructor( 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 @@ -534,49 +697,59 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + 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 { + + /** + * 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 = ViewType(JsonField.of("projects")) + @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = ViewType(JsonField.of("logs")) + @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) + @JvmField val EXPERIMENTS = of("experiments") - @JvmField val DATASETS = ViewType(JsonField.of("datasets")) + @JvmField val DATASETS = of("datasets") - @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) + @JvmField val PLAYGROUNDS = of("playgrounds") - @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ViewType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } + /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, LOGS, @@ -588,6 +761,15 @@ constructor( DATASET, } + /** + * 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, LOGS, @@ -597,9 +779,17 @@ constructor( PLAYGROUNDS, EXPERIMENT, DATASET, + /** 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 @@ -613,6 +803,15 @@ constructor( 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 @@ -627,6 +826,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -634,11 +845,11 @@ constructor( return true } - return /* spotless:off */ other is ViewReplaceParams && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, objectId, objectType, viewType, deletedAt, options, userId, viewData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ViewReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 13133781..7f86b892 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 @@ -4,38 +4,41 @@ package com.braintrustdata.api.models 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 +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.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects +/** Get a view object by its id */ class ViewRetrieveParams -constructor( +private constructor( private val viewId: String, private val objectId: String, private val objectType: ObjectType, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** View id */ fun viewId(): String = viewId + /** The id of the object the ACL applies to */ fun objectId(): String = objectId + /** The object type that the ACL applies to */ fun objectType(): ObjectType = objectType fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } @@ -57,8 +60,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ViewRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var viewId: String? = null private var objectId: String? = null @@ -184,61 +188,59 @@ constructor( fun build(): ViewRetrieveParams = ViewRetrieveParams( - checkNotNull(viewId) { "`viewId` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("viewId", viewId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -253,6 +255,15 @@ constructor( 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, @@ -265,9 +276,19 @@ constructor( 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 @@ -284,6 +305,15 @@ constructor( 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 @@ -301,6 +331,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { 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 5a7e0a69..9f99e17f 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 @@ -5,75 +5,92 @@ 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 import com.braintrustdata.api.core.JsonValue 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.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import java.util.Objects import java.util.Optional +/** + * Partially update a view object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. + */ class ViewUpdateParams -constructor( +private constructor( private val viewId: String, - private val objectId: String, - private val objectType: ObjectType, - private val name: String?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val viewType: ViewType?, + private val body: ViewUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { +) : Params { + /** View id */ fun viewId(): String = viewId - fun objectId(): String = objectId + /** The id of the object the view applies to */ + fun objectId(): String = body.objectId() - fun objectType(): ObjectType = objectType + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = body.objectType() - fun name(): Optional = Optional.ofNullable(name) + /** Name of the view */ + fun name(): Optional = body.name() - fun options(): Optional = Optional.ofNullable(options) + /** Options for the view in the app */ + fun options(): Optional = body.options() - fun userId(): Optional = Optional.ofNullable(userId) + /** Identifies the user who created the view */ + fun userId(): Optional = body.userId() - fun viewData(): Optional = Optional.ofNullable(viewData) + /** The view definition */ + fun viewData(): Optional = body.viewData() - fun viewType(): Optional = Optional.ofNullable(viewType) + /** Type of table that the view corresponds to. */ + fun viewType(): Optional = body.viewType() + + /** 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() + + /** Name of the view */ + fun _name(): JsonField = body._name() + + /** Options for the view in the app */ + fun _options(): JsonField = body._options() + + /** Identifies the user who created the view */ + fun _userId(): JsonField = body._userId() + + /** The view definition */ + fun _viewData(): JsonField = body._viewData() + + /** Type of table that the view corresponds to. */ + fun _viewType(): JsonField = body._viewType() + + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ViewUpdateBody { - return ViewUpdateBody( - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalBodyProperties, - ) - } + @JvmSynthetic internal fun _body(): ViewUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -82,45 +99,100 @@ constructor( } } - @JsonDeserialize(builder = ViewUpdateBody.Builder::class) @NoAutoDetect class ViewUpdateBody + @JsonCreator internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val name: String?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val viewType: ViewType?, - private val additionalProperties: Map, + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") + @ExcludeMissing + private val viewData: JsonField = JsonMissing.of(), + @JsonProperty("view_type") + @ExcludeMissing + private val viewType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the view applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + fun objectId(): String = objectId.getRequired("object_id") /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + fun objectType(): ObjectType = objectType.getRequired("object_type") /** Name of the view */ - @JsonProperty("name") fun name(): String? = name + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** Options for the view in the app */ - @JsonProperty("options") fun options(): ViewOptions? = options + fun options(): Optional = Optional.ofNullable(options.getNullable("options")) /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(): String? = userId + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The view definition */ - @JsonProperty("view_data") fun viewData(): ViewData? = viewData + fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") fun viewType(): ViewType? = viewType + fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) + + /** The id of the object the view applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + /** Name of the view */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Options for the view in the app */ + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + + /** Identifies the user who created the view */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + /** The view definition */ + @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + + /** Type of table that the view corresponds to. */ + @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ViewUpdateBody = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + name() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + viewType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -128,73 +200,112 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ViewUpdateBody]. */ + class Builder internal constructor() { - private var objectId: String? = null - private var objectType: ObjectType? = null - private var name: String? = null - private var options: ViewOptions? = null - private var userId: String? = null - private var viewData: ViewData? = null - private var viewType: ViewType? = null + private var objectId: 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() + private var viewData: JsonField = JsonMissing.of() + private var viewType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewUpdateBody: ViewUpdateBody) = apply { - this.objectId = viewUpdateBody.objectId - this.objectType = viewUpdateBody.objectType - this.name = viewUpdateBody.name - this.options = viewUpdateBody.options - this.userId = viewUpdateBody.userId - this.viewData = viewUpdateBody.viewData - this.viewType = viewUpdateBody.viewType - additionalProperties(viewUpdateBody.additionalProperties) + objectId = viewUpdateBody.objectId + objectType = viewUpdateBody.objectType + name = viewUpdateBody.name + options = viewUpdateBody.options + userId = viewUpdateBody.userId + viewData = viewUpdateBody.viewData + viewType = viewUpdateBody.viewType + additionalProperties = viewUpdateBody.additionalProperties.toMutableMap() } /** The id of the object the view applies to */ - @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the view applies to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** Name of the view */ + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the view */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the view */ + fun name(name: JsonField) = apply { this.name = name } /** Options for the view in the app */ - @JsonProperty("options") - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) + + /** Options for the view in the app */ + fun options(options: Optional) = options(options.orElse(null)) + + /** Options for the view in the app */ + fun options(options: JsonField) = apply { this.options = options } + + /** Identifies the user who created the view */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: Optional) = userId(userId.orElse(null)) + + /** Identifies the user who created the view */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** The view definition */ + fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) + + /** The view definition */ + fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) /** The view definition */ - @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) + putAllAdditionalProperties(additionalProperties) } - @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + fun build(): ViewUpdateBody = ViewUpdateBody( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), name, options, userId, @@ -229,59 +340,101 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ViewUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var viewId: String? = null - private var objectId: String? = null - private var objectType: ObjectType? = null - private var name: String? = null - private var options: ViewOptions? = null - private var userId: String? = null - private var viewData: ViewData? = null - private var viewType: ViewType? = null + private var body: ViewUpdateBody.Builder = ViewUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(viewUpdateParams: ViewUpdateParams) = apply { viewId = viewUpdateParams.viewId - objectId = viewUpdateParams.objectId - objectType = viewUpdateParams.objectType - name = viewUpdateParams.name - options = viewUpdateParams.options - userId = viewUpdateParams.userId - viewData = viewUpdateParams.viewData - viewType = viewUpdateParams.viewType + body = viewUpdateParams.body.toBuilder() additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = viewUpdateParams.additionalBodyProperties.toMutableMap() } /** View id */ fun viewId(viewId: String) = apply { this.viewId = viewId } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { body.objectId(objectId) } + + /** The id of the object the view applies to */ + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + + /** Name of the view */ + fun name(name: String?) = apply { body.name(name) } /** Name of the view */ - fun name(name: String) = apply { this.name = name } + fun name(name: Optional) = name(name.orElse(null)) + + /** Name of the view */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Options for the view in the app */ + fun options(options: ViewOptions?) = apply { body.options(options) } + + /** Options for the view in the app */ + fun options(options: Optional) = options(options.orElse(null)) /** Options for the view in the app */ - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: JsonField) = apply { body.options(options) } + + /** Identifies the user who created the view */ + fun userId(userId: String?) = apply { body.userId(userId) } + + /** Identifies the user who created the view */ + fun userId(userId: Optional) = userId(userId.orElse(null)) /** Identifies the user who created the view */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { body.userId(userId) } /** The view definition */ - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + + /** The view definition */ + fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + + /** The view definition */ + fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + + /** Type of table that the view corresponds to. */ + fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -381,91 +534,60 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - fun build(): ViewUpdateParams = ViewUpdateParams( - checkNotNull(viewId) { "`viewId` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - checkNotNull(objectType) { "`objectType` is required but was not set" }, - name, - options, - userId, - viewData, - viewType, + checkRequired("viewId", viewId), + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } + /** 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 - 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() - companion object { - @JvmField val ORGANIZATION = ObjectType(JsonField.of("organization")) + @JvmField val ORGANIZATION = of("organization") - @JvmField val PROJECT = ObjectType(JsonField.of("project")) + @JvmField val PROJECT = of("project") - @JvmField val EXPERIMENT = ObjectType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ObjectType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") - @JvmField val PROMPT = ObjectType(JsonField.of("prompt")) + @JvmField val PROMPT = of("prompt") - @JvmField val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) + @JvmField val PROMPT_SESSION = of("prompt_session") - @JvmField val GROUP = ObjectType(JsonField.of("group")) + @JvmField val GROUP = of("group") - @JvmField val ROLE = ObjectType(JsonField.of("role")) + @JvmField val ROLE = of("role") - @JvmField val ORG_MEMBER = ObjectType(JsonField.of("org_member")) + @JvmField val ORG_MEMBER = of("org_member") - @JvmField val PROJECT_LOG = ObjectType(JsonField.of("project_log")) + @JvmField val PROJECT_LOG = of("project_log") - @JvmField val ORG_PROJECT = ObjectType(JsonField.of("org_project")) + @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, @@ -480,6 +602,15 @@ constructor( 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, @@ -492,9 +623,19 @@ constructor( 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 @@ -511,6 +652,15 @@ constructor( 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 @@ -528,49 +678,59 @@ constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + 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 { + + /** + * 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 = ViewType(JsonField.of("projects")) + @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = ViewType(JsonField.of("logs")) + @JvmField val LOGS = of("logs") - @JvmField val EXPERIMENTS = ViewType(JsonField.of("experiments")) + @JvmField val EXPERIMENTS = of("experiments") - @JvmField val DATASETS = ViewType(JsonField.of("datasets")) + @JvmField val DATASETS = of("datasets") - @JvmField val PROMPTS = ViewType(JsonField.of("prompts")) + @JvmField val PROMPTS = of("prompts") - @JvmField val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) + @JvmField val PLAYGROUNDS = of("playgrounds") - @JvmField val EXPERIMENT = ViewType(JsonField.of("experiment")) + @JvmField val EXPERIMENT = of("experiment") - @JvmField val DATASET = ViewType(JsonField.of("dataset")) + @JvmField val DATASET = of("dataset") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } + /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, LOGS, @@ -582,6 +742,15 @@ constructor( DATASET, } + /** + * 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, LOGS, @@ -591,9 +760,17 @@ constructor( PLAYGROUNDS, EXPERIMENT, DATASET, + /** 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 @@ -607,6 +784,15 @@ constructor( 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 @@ -621,6 +807,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + 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 { @@ -628,11 +826,11 @@ constructor( return true } - return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, name, options, userId, viewData, viewType, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ViewUpdateParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 32a8700c..d2c00c6e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclBatchUpdateParams @@ -24,7 +25,7 @@ import com.braintrustdata.api.models.AclRetrieveParams import java.util.concurrent.CompletableFuture class AclServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AclServiceAsync { @@ -45,22 +46,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -75,21 +74,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -108,22 +105,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { AclListPageAsync.of(this, params, it) } - } + .let { AclListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -138,22 +133,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val batchUpdateHandler: Handler = @@ -171,22 +164,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl", "batch-update") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { batchUpdateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { batchUpdateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val findAndDeleteHandler: Handler = @@ -201,21 +192,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { findAndDeleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index eb4a1a92..e4ace220 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams @@ -24,7 +25,7 @@ import com.braintrustdata.api.models.AiSecretUpdateParams import java.util.concurrent.CompletableFuture class AiSecretServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AiSecretServiceAsync { @@ -45,22 +46,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -75,21 +74,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -108,22 +105,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -142,22 +137,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { AiSecretListPageAsync.of(this, params, it) } - } + .let { AiSecretListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -172,22 +165,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val findAndDeleteHandler: Handler = @@ -202,22 +193,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { findAndDeleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -235,21 +224,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index 3eb4c34e..ffa38dde 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.CreateApiKeyOutput import java.util.concurrent.CompletableFuture class ApiKeyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ApiKeyServiceAsync { @@ -43,22 +44,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -73,21 +72,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -106,22 +103,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { ApiKeyListPageAsync.of(this, params, it) } - } + .let { ApiKeyListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -136,21 +131,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index b767b4bd..edd093c0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams @@ -31,7 +32,7 @@ import com.braintrustdata.api.models.SummarizeDatasetResponse import java.util.concurrent.CompletableFuture class DatasetServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : DatasetServiceAsync { @@ -52,22 +53,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -82,21 +81,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -115,22 +112,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -149,22 +144,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { DatasetListPageAsync.of(this, params, it) } - } + .let { DatasetListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -179,22 +172,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val feedbackHandler: Handler = @@ -209,22 +200,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val fetchHandler: Handler = @@ -244,21 +233,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val fetchPostHandler: Handler = @@ -278,22 +265,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val insertHandler: Handler = @@ -308,22 +293,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val summarizeHandler: Handler = @@ -339,20 +322,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { summarizeHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index 7a62395d..efe93148 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EnvVar import com.braintrustdata.api.models.EnvVarCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.EnvVarUpdateParams import java.util.concurrent.CompletableFuture class EnvVarServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : EnvVarServiceAsync { @@ -44,22 +45,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -74,21 +73,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -107,22 +104,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -140,21 +135,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val deleteHandler: Handler = @@ -169,22 +162,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -202,21 +193,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index 441ad750..6a9fac5e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture class EvalServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : EvalServiceAsync { @@ -42,21 +43,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "eval") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 7753231b..5f9bc122 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams @@ -31,7 +32,7 @@ import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture class ExperimentServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ExperimentServiceAsync { @@ -52,22 +53,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -82,21 +81,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -115,22 +112,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -149,22 +144,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { ExperimentListPageAsync.of(this, params, it) } - } + .let { ExperimentListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -179,22 +172,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val feedbackHandler: Handler = @@ -209,22 +200,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val fetchHandler: Handler = @@ -244,21 +233,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val fetchPostHandler: Handler = @@ -278,22 +265,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val insertHandler: Handler = @@ -308,22 +293,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val summarizeHandler: Handler = @@ -339,20 +322,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { summarizeHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 18a8522f..c45def2d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams @@ -26,7 +27,7 @@ import java.util.Optional import java.util.concurrent.CompletableFuture class FunctionServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : FunctionServiceAsync { @@ -47,22 +48,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -77,21 +76,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -110,22 +107,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -144,22 +139,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { FunctionListPageAsync.of(this, params, it) } - } + .let { FunctionListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -174,26 +167,25 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } - private val invokeHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val invokeHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Invoke a function. */ override fun invoke( @@ -204,16 +196,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response.use { invokeHandler.handle(it) } - } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { invokeHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.ifPresent { it.validate() } + } + } + } } private val replaceHandler: Handler = @@ -232,21 +228,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index ee69b25e..784a8a7c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.GroupUpdateParams import java.util.concurrent.CompletableFuture class GroupServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : GroupServiceAsync { @@ -44,22 +45,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -74,21 +73,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -107,22 +104,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -141,22 +136,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { GroupListPageAsync.of(this, params, it) } - } + .let { GroupListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -171,22 +164,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -204,21 +195,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index c4901660..4e327d73 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.services.async.organizations.MemberServiceAsyncImp import java.util.concurrent.CompletableFuture class OrganizationServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : OrganizationServiceAsync { @@ -45,21 +46,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -78,22 +77,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -112,22 +109,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { OrganizationListPageAsync.of(this, params, it) } - } + .let { OrganizationListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -142,21 +137,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index ae17a3a6..1a53137f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.ProjectScoreUpdateParams import java.util.concurrent.CompletableFuture class ProjectScoreServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ProjectScoreServiceAsync { @@ -45,22 +46,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -75,21 +74,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -108,22 +105,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -142,22 +137,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { ProjectScoreListPageAsync.of(this, params, it) } - } + .let { ProjectScoreListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -172,22 +165,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -206,21 +197,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index f7a7a8e2..4abd543b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams @@ -24,7 +25,7 @@ import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl import java.util.concurrent.CompletableFuture class ProjectServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ProjectServiceAsync { @@ -49,22 +50,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -79,21 +78,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -112,22 +109,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -146,22 +141,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { ProjectListPageAsync.of(this, params, it) } - } + .let { ProjectListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -176,21 +169,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index 08ee7044..d49eea51 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.ProjectTagUpdateParams import java.util.concurrent.CompletableFuture class ProjectTagServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ProjectTagServiceAsync { @@ -44,22 +45,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -74,21 +73,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -107,22 +104,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -141,22 +136,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { ProjectTagListPageAsync.of(this, params, it) } - } + .let { ProjectTagListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -171,22 +164,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -205,21 +196,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 83b6a06f..632898a5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.PromptUpdateParams import java.util.concurrent.CompletableFuture class PromptServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PromptServiceAsync { @@ -44,22 +45,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -74,21 +73,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -107,22 +104,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -141,22 +136,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { PromptListPageAsync.of(this, params, it) } - } + .let { PromptListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -171,22 +164,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -204,21 +195,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index 386cecbc..442db1ac 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.RoleUpdateParams import java.util.concurrent.CompletableFuture class RoleServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RoleServiceAsync { @@ -44,22 +45,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -74,21 +73,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -107,22 +104,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -141,22 +136,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { RoleListPageAsync.of(this, params, it) } - } + .let { RoleListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -171,22 +164,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -204,21 +195,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt index 53c59a72..c79a81e7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.SpanIFrame import com.braintrustdata.api.models.SpanIframeCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.SpanIframeUpdateParams import java.util.concurrent.CompletableFuture class SpanIframeServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SpanIframeServiceAsync { @@ -44,22 +45,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "span_iframe") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -74,21 +73,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -107,22 +104,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -141,22 +136,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "span_iframe") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { SpanIframeListPageAsync.of(this, params, it) } - } + .let { SpanIframeListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -171,22 +164,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -204,21 +195,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "span_iframe") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index 68b9e154..3e53d718 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -10,12 +10,13 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams import java.util.concurrent.CompletableFuture class TopLevelServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TopLevelServiceAsync { @@ -32,14 +33,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response.use { helloWorldHandler.handle(it) } - } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> response.use { helloWorldHandler.handle(it) } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index fb6da392..3658ab80 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPageAsync @@ -18,7 +19,7 @@ import com.braintrustdata.api.models.UserRetrieveParams import java.util.concurrent.CompletableFuture class UserServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : UserServiceAsync { @@ -36,21 +37,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -69,21 +68,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { UserListPageAsync.of(this, params, it) } - } + .let { UserListPageAsync.of(this, params, it) } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index f0f3ced4..48806c81 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.ViewUpdateParams import java.util.concurrent.CompletableFuture class ViewServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ViewServiceAsync { @@ -44,22 +45,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -74,21 +73,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -107,22 +104,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -141,22 +136,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { ViewListPageAsync.of(this, params, it) } - } + .let { ViewListPageAsync.of(this, params, it) } + } } private val deleteHandler: Handler = @@ -171,22 +164,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val replaceHandler: Handler = @@ -204,21 +195,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 4597e448..4d122529 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput import java.util.concurrent.CompletableFuture class MemberServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : MemberServiceAsync { @@ -36,21 +37,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index a1432eaa..3a7bf06c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.ProjectLogInsertParams import java.util.concurrent.CompletableFuture class LogServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : LogServiceAsync { @@ -40,22 +41,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val fetchHandler: Handler = @@ -75,21 +74,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val fetchPostHandler: Handler = @@ -109,22 +106,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val insertHandler: Handler = @@ -139,21 +134,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index 0d325f0c..e38f3265 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclBatchUpdateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams class AclServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AclService { @@ -41,21 +42,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -67,20 +64,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -95,21 +88,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { AclListPage.of(this, params, it) } - } + } + .let { AclListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -121,21 +110,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val batchUpdateHandler: Handler = @@ -153,21 +138,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "acl", "batch-update") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { batchUpdateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { batchUpdateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val findAndDeleteHandler: Handler = @@ -182,20 +163,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { findAndDeleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index d13101d7..8b90d183 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams class AiSecretServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AiSecretService { @@ -41,21 +42,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -70,20 +67,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -99,21 +92,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -132,21 +121,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { AiSecretListPage.of(this, params, it) } - } + } + .let { AiSecretListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -158,21 +143,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val findAndDeleteHandler: Handler = @@ -187,21 +168,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { findAndDeleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -216,20 +193,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "ai_secret") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index 63e0f79d..25dc919a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams @@ -21,7 +22,7 @@ import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput class ApiKeyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ApiKeyService { @@ -42,21 +43,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -68,20 +65,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -97,21 +90,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { ApiKeyListPage.of(this, params, it) } - } + } + .let { ApiKeyListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -123,20 +112,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 66b4afd6..6a53d244 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams @@ -30,7 +31,7 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse class DatasetServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : DatasetService { @@ -48,21 +49,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -74,20 +71,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -103,21 +96,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -133,21 +122,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { DatasetListPage.of(this, params, it) } - } + } + .let { DatasetListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -159,21 +144,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val feedbackHandler: Handler = @@ -188,21 +169,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val fetchHandler: Handler = @@ -222,20 +199,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val fetchPostHandler: Handler = @@ -255,21 +228,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val insertHandler: Handler = @@ -284,21 +253,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val summarizeHandler: Handler = @@ -314,19 +279,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { summarizeHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index ba1b5b89..bb9c40ee 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EnvVar import com.braintrustdata.api.models.EnvVarCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams class EnvVarServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : EnvVarService { @@ -40,21 +41,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -66,20 +63,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -95,21 +88,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -127,20 +116,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val deleteHandler: Handler = @@ -152,21 +137,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "env_var", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -181,20 +162,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "env_var") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index 3f1e2147..e0af0896 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -11,12 +11,13 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse class EvalServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : EvalService { @@ -41,20 +42,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "eval") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index fdecad4d..0d5d88c6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams @@ -30,7 +31,7 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse class ExperimentServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ExperimentService { @@ -51,21 +52,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -80,20 +77,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -112,21 +105,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -145,21 +134,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { ExperimentListPage.of(this, params, it) } - } + } + .let { ExperimentListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -174,21 +159,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val feedbackHandler: Handler = @@ -203,21 +184,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val fetchHandler: Handler = @@ -237,20 +214,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val fetchPostHandler: Handler = @@ -270,21 +243,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val insertHandler: Handler = @@ -299,21 +268,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val summarizeHandler: Handler = @@ -329,19 +294,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { summarizeHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 934e083c..b15fbd46 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams @@ -25,7 +26,7 @@ import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional class FunctionServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : FunctionService { @@ -43,21 +44,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -72,20 +69,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -101,21 +94,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -134,21 +123,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { FunctionListPage.of(this, params, it) } - } + } + .let { FunctionListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -160,25 +145,22 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } - private val invokeHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val invokeHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Invoke a function. */ override fun invoke( @@ -189,15 +171,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response.use { invokeHandler.handle(it) } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { invokeHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.ifPresent { it.validate() } + } + } } private val replaceHandler: Handler = @@ -213,20 +197,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 8f0f3c23..0bd791dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams class GroupServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : GroupService { @@ -40,21 +41,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -66,20 +63,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -95,21 +88,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -124,21 +113,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { GroupListPage.of(this, params, it) } - } + } + .let { GroupListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -150,21 +135,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -179,20 +160,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index 3a0795fc..98b0a04a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.services.blocking.organizations.MemberService import com.braintrustdata.api.services.blocking.organizations.MemberServiceImpl class OrganizationServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : OrganizationService { @@ -44,20 +45,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -76,21 +73,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -109,21 +102,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { OrganizationListPage.of(this, params, it) } - } + } + .let { OrganizationListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -138,20 +127,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index 0dd24e78..1f9eddec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams class ProjectScoreServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ProjectScoreService { @@ -44,21 +45,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -73,20 +70,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -105,21 +98,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -138,21 +127,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { ProjectScoreListPage.of(this, params, it) } - } + } + .let { ProjectScoreListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -167,21 +152,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -200,20 +181,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 2cb38111..ebfba434 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams @@ -23,7 +24,7 @@ import com.braintrustdata.api.services.blocking.projects.LogService import com.braintrustdata.api.services.blocking.projects.LogServiceImpl class ProjectServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ProjectService { @@ -45,21 +46,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -71,20 +68,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -100,21 +93,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -130,21 +119,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { ProjectListPage.of(this, params, it) } - } + } + .let { ProjectListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -156,20 +141,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 1246432d..da6ce3e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams class ProjectTagServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ProjectTagService { @@ -43,21 +44,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -72,20 +69,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -104,21 +97,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -137,21 +126,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { ProjectTagListPage.of(this, params, it) } - } + } + .let { ProjectTagListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -166,21 +151,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -199,20 +180,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index 93acdfe1..c4bc8056 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams class PromptServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PromptService { @@ -40,21 +41,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -66,20 +63,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -95,21 +88,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -125,21 +114,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { PromptListPage.of(this, params, it) } - } + } + .let { PromptListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -151,21 +136,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -180,20 +161,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 60cfc01e..bd7af730 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams class RoleServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RoleService { @@ -40,21 +41,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -66,20 +63,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -95,21 +88,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -124,21 +113,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { RoleListPage.of(this, params, it) } - } + } + .let { RoleListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -150,21 +135,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -179,20 +160,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt index 5d542791..1c43d65d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.SpanIFrame import com.braintrustdata.api.models.SpanIframeCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams class SpanIframeServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SpanIframeService { @@ -43,21 +44,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "span_iframe") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -72,20 +69,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -104,21 +97,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -137,21 +126,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "span_iframe") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { SpanIframeListPage.of(this, params, it) } - } + } + .let { SpanIframeListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -166,21 +151,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -198,20 +179,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "span_iframe") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index f6dc73dc..a7da817d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -10,11 +10,12 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams class TopLevelServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : TopLevelService { @@ -31,13 +32,9 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response.use { helloWorldHandler.handle(it) } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.use { helloWorldHandler.handle(it) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 79360d9b..aa7ef359 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPage @@ -17,7 +18,7 @@ import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams class UserServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : UserService { @@ -32,20 +33,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -60,20 +57,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { UserListPage.of(this, params, it) } - } + } + .let { UserListPage.of(this, params, it) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 4747d2fd..b1280e4a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams @@ -22,7 +23,7 @@ import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams class ViewServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ViewService { @@ -40,21 +41,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -66,20 +63,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -95,21 +88,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -124,21 +113,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { ViewListPage.of(this, params, it) } - } + } + .let { ViewListPage.of(this, params, it) } } private val deleteHandler: Handler = @@ -150,21 +135,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val replaceHandler: Handler = @@ -179,20 +160,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index 7f8086ba..86c911ff 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -11,12 +11,13 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput class MemberServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : MemberService { @@ -35,20 +36,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PATCH) .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 72e74f7a..a2effeb5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.json +import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse @@ -21,7 +22,7 @@ import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams class LogServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : LogService { @@ -39,21 +40,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val fetchHandler: Handler = @@ -73,20 +70,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val fetchPostHandler: Handler = @@ -106,21 +99,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val insertHandler: Handler = @@ -135,20 +124,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt index 2ab73012..60a23068 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt @@ -1,42 +1,87 @@ package com.braintrustdata.api.core.http import com.braintrustdata.api.client.okhttp.OkHttpClient +import com.braintrustdata.api.core.RequestOptions import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario +import java.io.InputStream +import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource @WireMockTest internal class RetryingHttpClientTest { + private var openResponseCount = 0 private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - httpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + httpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions + ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions + ): CompletableFuture = + okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } + + override fun close() = okHttpClient.close() + + private fun trackClose(response: HttpResponse): HttpResponse { + openResponseCount++ + return object : HttpResponse { + private var isClosed = false + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = response.body() + + override fun close() { + response.close() + if (isClosed) { + return + } + openResponseCount-- + isClosed = true + } + } + } + } resetAllScenarios() } - @Test - fun byDefaultShouldNotAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } - @Test - fun whenProvidedShouldAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) @@ -45,21 +90,28 @@ internal class RetryingHttpClientTest { val retryingClient = RetryingHttpClient.builder() .httpClient(httpClient) + .maxRetries(2) .idempotencyHeader("X-Some-Header") .build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun retryAfterHeader(async: Boolean) { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + fun execute_withRetryAfterHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // first we fail with a retry after header given as a date + // First we fail with a retry after header given as a date + .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) .willReturn( serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") @@ -68,14 +120,16 @@ internal class RetryingHttpClientTest { ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we fail with a retry after header given as a delay + // Then we fail with a retry after header given as a delay + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DATE") .willReturn(serviceUnavailable().withHeader("Retry-After", "1.234")) .willSetStateTo("RETRY_AFTER_DELAY") ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we return a success + // Then we return a success + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DELAY") .willReturn(ok()) .willSetStateTo("COMPLETED") @@ -84,8 +138,10 @@ internal class RetryingHttpClientTest { RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) assertThat(response.statusCode()).isEqualTo(200) verify( @@ -103,17 +159,12 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")) ) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun overwriteRetryCountHeader(async: Boolean) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .putHeader("x-stainless-retry-count", "42") - .build() + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date @@ -134,8 +185,14 @@ internal class RetryingHttpClientTest { RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async + ) assertThat(response.statusCode()).isEqualTo(200) verify( @@ -143,12 +200,12 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")) ) + assertNoResponseLeaks() } - @Test - fun retryAfterMsHeader() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") @@ -165,8 +222,22 @@ internal class RetryingHttpClientTest { ) val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) + + // When retrying, all failed responses should be closed. Only the final returned response should + // be open. + private fun assertNoResponseLeaks() = assertThat(openResponseCount).isEqualTo(1) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt index fa99908e..fc573164 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt @@ -65,7 +65,8 @@ internal class SerializerTest { } @NoAutoDetect - class Builder { + class Builder internal constructor() { + private var isActive: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt index 06232123..59e99875 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -16,7 +17,11 @@ class AISecretTest { .name("name") .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(AISecret.Metadata.builder().build()) + .metadata( + AISecret.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .previewSecret("preview_secret") .type("type") .build() @@ -25,7 +30,12 @@ class AISecretTest { assertThat(aISecret.name()).isEqualTo("name") assertThat(aISecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(aISecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(aISecret.metadata()).contains(AISecret.Metadata.builder().build()) + assertThat(aISecret.metadata()) + .contains( + AISecret.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(aISecret.previewSecret()).contains("preview_secret") assertThat(aISecret.type()).contains("type") } 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 7fe6d87f..f4e0b644 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 @@ -2,17 +2,46 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AclBatchUpdateParamsTest { @Test - fun createAclBatchUpdateParams() { + fun create() { AclBatchUpdateParams.builder() - .addAcls( - listOf( + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + AclBatchUpdateParams.builder() + .addAddAcl( AclBatchUpdateParams.AddAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) @@ -25,9 +54,7 @@ class AclBatchUpdateParamsTest { .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - ) - .removeAcls( - listOf( + .addRemoveAcl( AclBatchUpdateParams.RemoveAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) @@ -40,49 +67,11 @@ class AclBatchUpdateParamsTest { .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - ) - .build() - } - - @Test - fun getBody() { - val params = - AclBatchUpdateParams.builder() - .addAcls( - listOf( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) - .removeAcls( - listOf( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.addAcls()) - .isEqualTo( + .contains( listOf( AclBatchUpdateParams.AddAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -98,7 +87,7 @@ class AclBatchUpdateParamsTest { ) ) assertThat(body.removeAcls()) - .isEqualTo( + .contains( listOf( AclBatchUpdateParams.RemoveAcl.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -116,9 +105,9 @@ class AclBatchUpdateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = AclBatchUpdateParams.builder().build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } } 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 a6d7aec5..02a37951 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 @@ -12,37 +12,33 @@ class AclBatchUpdateResponseTest { fun createAclBatchUpdateResponse() { val aclBatchUpdateResponse = AclBatchUpdateResponse.builder() - .addedAcls( - listOf( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + .addAddedAcl( + Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() ) - .removedAcls( - listOf( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + .addRemovedAcl( + Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() ) .build() assertThat(aclBatchUpdateResponse).isNotNull 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 95dcb724..fa1940ba 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 @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AclCreateParamsTest { @Test - fun createAclCreateParams() { + fun create() { AclCreateParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclCreateParams.ObjectType.ORGANIZATION) @@ -22,7 +21,7 @@ class AclCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = AclCreateParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -33,26 +32,26 @@ class AclCreateParamsTest { .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) - assertThat(body.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).isEqualTo(AclCreateParams.Permission.CREATE) + assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).contains(AclCreateParams.Permission.CREATE) assertThat(body.restrictObjectType()) - .isEqualTo(AclCreateParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .contains(AclCreateParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = AclCreateParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclCreateParams.ObjectType.ORGANIZATION) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt index 5b65f5d1..51793459 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AclDeleteParamsTest { @Test - fun createAclDeleteParams() { + fun create() { AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } 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 90f45c40..d82dd66e 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 @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AclFindAndDeleteParamsTest { @Test - fun createAclFindAndDeleteParams() { + fun create() { AclFindAndDeleteParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) @@ -22,7 +21,7 @@ class AclFindAndDeleteParamsTest { } @Test - fun getBody() { + fun body() { val params = AclFindAndDeleteParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -33,26 +32,26 @@ class AclFindAndDeleteParamsTest { .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - assertThat(body.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).isEqualTo(AclFindAndDeleteParams.Permission.CREATE) + assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).contains(AclFindAndDeleteParams.Permission.CREATE) assertThat(body.restrictObjectType()) - .isEqualTo(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .contains(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = AclFindAndDeleteParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.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 0953fa59..f842bd44 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 @@ -3,33 +3,32 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AclListParamsTest { @Test - fun createAclListParams() { + fun create() { AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclListParams.ObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclListParams.ObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = QueryParams.builder() @@ -40,13 +39,13 @@ class AclListParamsTest { "ids", AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -55,6 +54,6 @@ class AclListParamsTest { val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt index ed334cc7..fd23f612 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AclRetrieveParamsTest { @Test - fun createAclRetrieveParams() { + fun create() { AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt index 803786eb..6d70eaca 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt @@ -2,17 +2,21 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AiSecretCreateParamsTest { @Test - fun createAiSecretCreateParams() { + fun create() { AiSecretCreateParams.builder() .name("name") - .metadata(AiSecretCreateParams.Metadata.builder().build()) + .metadata( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .orgName("org_name") .secret("secret") .type("type") @@ -20,28 +24,37 @@ class AiSecretCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = AiSecretCreateParams.builder() .name("name") - .metadata(AiSecretCreateParams.Metadata.builder().build()) + .metadata( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .orgName("org_name") .secret("secret") .type("type") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()).isEqualTo(AiSecretCreateParams.Metadata.builder().build()) - assertThat(body.orgName()).isEqualTo("org_name") - assertThat(body.secret()).isEqualTo("secret") - assertThat(body.type()).isEqualTo("type") + assertThat(body.metadata()) + .contains( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.orgName()).contains("org_name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = AiSecretCreateParams.builder().name("name").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt index 5f984b71..a59725a1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AiSecretDeleteParamsTest { @Test - fun createAiSecretDeleteParams() { + fun create() { AiSecretDeleteParams.builder().aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt index e3e4da8a..8dbe57c5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt @@ -2,30 +2,29 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AiSecretFindAndDeleteParamsTest { @Test - fun createAiSecretFindAndDeleteParams() { + fun create() { AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() } @Test - fun getBody() { + fun body() { val params = AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.orgName()).contains("org_name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = AiSecretFindAndDeleteParams.builder().name("name").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt index bb1dd611..07e6c4f5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt @@ -3,34 +3,33 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AiSecretListParamsTest { @Test - fun createAiSecretListParams() { + fun create() { AiSecretListParams.builder() .aiSecretName("ai_secret_name") - .aiSecretType(AiSecretListParams.AiSecretType.ofString("string")) + .aiSecretType("string") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = AiSecretListParams.builder() .aiSecretName("ai_secret_name") - .aiSecretType(AiSecretListParams.AiSecretType.ofString("string")) + .aiSecretType("string") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -45,16 +44,16 @@ class AiSecretListParamsTest { "ids", AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = AiSecretListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt index 3204ee97..660c7917 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt @@ -2,17 +2,21 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AiSecretReplaceParamsTest { @Test - fun createAiSecretReplaceParams() { + fun create() { AiSecretReplaceParams.builder() .name("name") - .metadata(AiSecretReplaceParams.Metadata.builder().build()) + .metadata( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .orgName("org_name") .secret("secret") .type("type") @@ -20,28 +24,37 @@ class AiSecretReplaceParamsTest { } @Test - fun getBody() { + fun body() { val params = AiSecretReplaceParams.builder() .name("name") - .metadata(AiSecretReplaceParams.Metadata.builder().build()) + .metadata( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .orgName("org_name") .secret("secret") .type("type") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()).isEqualTo(AiSecretReplaceParams.Metadata.builder().build()) - assertThat(body.orgName()).isEqualTo("org_name") - assertThat(body.secret()).isEqualTo("secret") - assertThat(body.type()).isEqualTo("type") + assertThat(body.metadata()) + .contains( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.orgName()).contains("org_name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = AiSecretReplaceParams.builder().name("name").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt index c2a28575..5c6d07cc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AiSecretRetrieveParamsTest { @Test - fun createAiSecretRetrieveParams() { + fun create() { AiSecretRetrieveParams.builder().aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt index d324f0a2..d2aff29a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt @@ -2,17 +2,21 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class AiSecretUpdateParamsTest { @Test - fun createAiSecretUpdateParams() { + fun create() { AiSecretUpdateParams.builder() .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(AiSecretUpdateParams.Metadata.builder().build()) + .metadata( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .secret("secret") .type("type") @@ -20,30 +24,39 @@ class AiSecretUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = AiSecretUpdateParams.builder() .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(AiSecretUpdateParams.Metadata.builder().build()) + .metadata( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .secret("secret") .type("type") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.metadata()).isEqualTo(AiSecretUpdateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") - assertThat(body.secret()).isEqualTo("secret") - assertThat(body.type()).isEqualTo("type") + assertThat(body.metadata()) + .contains( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.name()).contains("name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = AiSecretUpdateParams.builder() .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt index 8c337a43..4b331282 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -2,30 +2,29 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ApiKeyCreateParamsTest { @Test - fun createApiKeyCreateParams() { + fun create() { ApiKeyCreateParams.builder().name("name").orgName("org_name").build() } @Test - fun getBody() { + fun body() { val params = ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.orgName()).contains("org_name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ApiKeyCreateParams.builder().name("name").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt index bbcd063d..0b7c5a7d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ApiKeyDeleteParamsTest { @Test - fun createApiKeyDeleteParams() { + fun create() { ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index 10c5936f..60a9e7bb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -3,32 +3,31 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ApiKeyListParamsTest { @Test - fun createApiKeyListParams() { + fun create() { ApiKeyListParams.builder() .apiKeyName("api_key_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = ApiKeyListParams.builder() .apiKeyName("api_key_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -39,16 +38,16 @@ class ApiKeyListParamsTest { "ids", ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ApiKeyListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt index 48a5016b..2170ff30 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ApiKeyRetrieveParamsTest { @Test - fun createApiKeyRetrieveParams() { + fun create() { ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt index 8b8ede41..7cced6c5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt @@ -13,21 +13,15 @@ class CodeBundleTest { CodeBundle.builder() .bundleId("bundle_id") .location( - CodeBundle.Location.ofExperiment( - CodeBundle.Location.Experiment.builder() - .evalName("eval_name") - .position( - CodeBundle.Location.Experiment.Position.ofType( - CodeBundle.Location.Experiment.Position.Type.builder() - .type( - CodeBundle.Location.Experiment.Position.Type.Type.TASK - ) - .build() - ) - ) - .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) - .build() - ) + CodeBundle.Location.Experiment.builder() + .evalName("eval_name") + .position( + CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) + .build() + ) + .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) + .build() ) .runtimeContext( CodeBundle.RuntimeContext.builder() @@ -45,11 +39,9 @@ class CodeBundleTest { CodeBundle.Location.Experiment.builder() .evalName("eval_name") .position( - CodeBundle.Location.Experiment.Position.ofType( - CodeBundle.Location.Experiment.Position.Type.builder() - .type(CodeBundle.Location.Experiment.Position.Type.Type.TASK) - .build() - ) + CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) + .build() ) .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt index dca2c6ff..5e7da92f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,16 +12,58 @@ class CrossObjectInsertResponseTest { fun createCrossObjectInsertResponse() { val crossObjectInsertResponse = CrossObjectInsertResponse.builder() - .dataset(CrossObjectInsertResponse.Dataset.builder().build()) - .experiment(CrossObjectInsertResponse.Experiment.builder().build()) - .projectLogs(CrossObjectInsertResponse.ProjectLogs.builder().build()) + .dataset( + CrossObjectInsertResponse.Dataset.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))) + ) + .build() + ) + .experiment( + CrossObjectInsertResponse.Experiment.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))) + ) + .build() + ) + .projectLogs( + CrossObjectInsertResponse.ProjectLogs.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))) + ) + .build() + ) .build() assertThat(crossObjectInsertResponse).isNotNull assertThat(crossObjectInsertResponse.dataset()) - .contains(CrossObjectInsertResponse.Dataset.builder().build()) + .contains( + CrossObjectInsertResponse.Dataset.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))) + ) + .build() + ) assertThat(crossObjectInsertResponse.experiment()) - .contains(CrossObjectInsertResponse.Experiment.builder().build()) + .contains( + CrossObjectInsertResponse.Experiment.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))) + ) + .build() + ) assertThat(crossObjectInsertResponse.projectLogs()) - .contains(CrossObjectInsertResponse.ProjectLogs.builder().build()) + .contains( + CrossObjectInsertResponse.ProjectLogs.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))) + ) + .build() + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt index 544c8f05..4cc2a2db 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt @@ -9,8 +9,8 @@ class DataSummaryTest { @Test fun createDataSummary() { - val dataSummary = DataSummary.builder().totalRecords(123L).build() + val dataSummary = DataSummary.builder().totalRecords(0L).build() assertThat(dataSummary).isNotNull - assertThat(dataSummary.totalRecords()).isEqualTo(123L) + assertThat(dataSummary.totalRecords()).isEqualTo(0L) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index aa92e1c3..6c32ee7f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -2,47 +2,60 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetCreateParamsTest { @Test - fun createDatasetCreateParams() { + fun create() { DatasetCreateParams.builder() .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .metadata(DatasetCreateParams.Metadata.builder().build()) + .metadata( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() } @Test - fun getBody() { + fun body() { val params = DatasetCreateParams.builder() .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .metadata(DatasetCreateParams.Metadata.builder().build()) + .metadata( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.description()).isEqualTo("description") - assertThat(body.metadata()).isEqualTo(DatasetCreateParams.Metadata.builder().build()) + assertThat(body.description()).contains("description") + assertThat(body.metadata()) + .contains( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = DatasetCreateParams.builder() .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt index bb209233..8b41dbf4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetDeleteParamsTest { @Test - fun createDatasetDeleteParams() { + fun create() { DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt index 4249590b..687f05e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -20,10 +20,14 @@ class DatasetEventTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .rootSpanId("root_span_id") .spanId("span_id") - .expected(JsonNull.of()) - .input(JsonNull.of()) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata(DatasetEvent.Metadata.builder().build()) + .metadata( + DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .origin( DatasetEvent.Origin.builder() .id("id") @@ -32,7 +36,7 @@ class DatasetEventTest { .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) .build() ) - .tags(listOf("string")) + .addTag("string") .build() assertThat(datasetEvent).isNotNull assertThat(datasetEvent.id()).isEqualTo("id") @@ -43,10 +47,15 @@ class DatasetEventTest { assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(datasetEvent.rootSpanId()).isEqualTo("root_span_id") assertThat(datasetEvent.spanId()).isEqualTo("span_id") - assertThat(datasetEvent._expected()).isEqualTo(JsonNull.of()) - assertThat(datasetEvent._input()).isEqualTo(JsonNull.of()) + assertThat(datasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(datasetEvent.isRoot()).contains(true) - assertThat(datasetEvent.metadata()).contains(DatasetEvent.Metadata.builder().build()) + assertThat(datasetEvent.metadata()) + .contains( + DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(datasetEvent.origin()) .contains( DatasetEvent.Origin.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index 116f69f8..a3a1a359 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -2,48 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetFeedbackParamsTest { @Test - fun createDatasetFeedbackParams() { + fun create() { DatasetFeedbackParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() ) .build() } @Test - fun getBody() { + fun body() { val params = DatasetFeedbackParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo( @@ -51,22 +55,26 @@ class DatasetFeedbackParamsTest { FeedbackDatasetItem.builder() .id("id") .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) + .addTag("string") .build() ) ) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = DatasetFeedbackParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackDatasetItem.builder().id("id").build())) + .addFeedback(FeedbackDatasetItem.builder().id("id").build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo(listOf(FeedbackDatasetItem.builder().id("id").build())) @@ -77,7 +85,7 @@ class DatasetFeedbackParamsTest { val params = DatasetFeedbackParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackDatasetItem.builder().id("id").build())) + .addFeedback(FeedbackDatasetItem.builder().id("id").build()) .build() assertThat(params).isNotNull // path param "datasetId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index cc537185..1a2a1725 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -3,17 +3,16 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetFetchParamsTest { @Test - fun createDatasetFetchParams() { + fun create() { DatasetFetchParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -21,29 +20,29 @@ class DatasetFetchParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = DatasetFetchParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") .build() val expected = QueryParams.builder() - expected.put("limit", "123") + expected.put("limit", "0") expected.put("max_root_span_id", "max_root_span_id") expected.put("max_xact_id", "max_xact_id") expected.put("version", "version") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index f92d1111..22e25376 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -2,18 +2,17 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetFetchPostParamsTest { @Test - fun createDatasetFetchPostParams() { + fun create() { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -21,32 +20,32 @@ class DatasetFetchPostParamsTest { } @Test - fun getBody() { + fun body() { val params = DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index a2054ae2..a9353b93 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -2,8 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,57 +10,61 @@ import org.junit.jupiter.api.Test class DatasetInsertParamsTest { @Test - fun createDatasetInsertParams() { + fun create() { DatasetInsertParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( + .addEvent( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( InsertDatasetEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEvent.Metadata.builder().build()) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .rootSpanId("root_span_id") .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() ) - ) - .build() - } - - @Test - fun getBody() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEvent.Metadata.builder().build()) - .rootSpanId("root_span_id") - .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.events()) .isEqualTo( @@ -69,30 +72,34 @@ class DatasetInsertParamsTest { InsertDatasetEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEvent.Metadata.builder().build()) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .rootSpanId("root_span_id") .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() ) ) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = DatasetInsertParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(InsertDatasetEvent.builder().build())) + .addEvent(InsertDatasetEvent.builder().build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) } @@ -102,7 +109,7 @@ class DatasetInsertParamsTest { val params = DatasetInsertParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(InsertDatasetEvent.builder().build())) + .addEvent(InsertDatasetEvent.builder().build()) .build() assertThat(params).isNotNull // path param "datasetId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index 89973320..7ba3c2ac 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -3,19 +3,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetListParamsTest { @Test - fun createDatasetListParams() { + fun create() { DatasetListParams.builder() .datasetName("dataset_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -24,13 +23,13 @@ class DatasetListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = DatasetListParams.builder() .datasetName("dataset_name") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -43,18 +42,18 @@ class DatasetListParamsTest { "ids", DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("project_name", "project_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = DatasetListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt index 776cce3b..95326568 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetRetrieveParamsTest { @Test - fun createDatasetRetrieveParams() { + fun create() { DatasetRetrieveParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index a4d6224d..83303cf0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -3,14 +3,13 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetSummarizeParamsTest { @Test - fun createDatasetSummarizeParams() { + fun create() { DatasetSummarizeParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .summarizeData(true) @@ -18,7 +17,7 @@ class DatasetSummarizeParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = DatasetSummarizeParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -26,17 +25,17 @@ class DatasetSummarizeParamsTest { .build() val expected = QueryParams.builder() expected.put("summarize_data", "true") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = DatasetSummarizeParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt index 59f91add..829a918e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -18,7 +19,11 @@ class DatasetTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .metadata(Dataset.Metadata.builder().build()) + .metadata( + Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(dataset).isNotNull @@ -28,7 +33,12 @@ class DatasetTest { assertThat(dataset.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(dataset.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(dataset.description()).contains("description") - assertThat(dataset.metadata()).contains(Dataset.Metadata.builder().build()) + assertThat(dataset.metadata()) + .contains( + Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(dataset.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index e8dfdbe0..3fe6dfd1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -2,43 +2,56 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class DatasetUpdateParamsTest { @Test - fun createDatasetUpdateParams() { + fun create() { DatasetUpdateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .metadata(DatasetUpdateParams.Metadata.builder().build()) + .metadata( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() } @Test - fun getBody() { + fun body() { val params = DatasetUpdateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .metadata(DatasetUpdateParams.Metadata.builder().build()) + .metadata( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("description") - assertThat(body.metadata()).isEqualTo(DatasetUpdateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).contains("description") + assertThat(body.metadata()) + .contains( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.name()).contains("name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt index 7700b365..59313199 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class EnvVarCreateParamsTest { @Test - fun createEnvVarCreateParams() { + fun create() { EnvVarCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -19,7 +18,7 @@ class EnvVarCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = EnvVarCreateParams.builder() .name("name") @@ -27,23 +26,23 @@ class EnvVarCreateParamsTest { .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) .value("value") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) - assertThat(body.value()).isEqualTo("value") + assertThat(body.value()).contains("value") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = EnvVarCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt index 29879f19..b6264f9d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class EnvVarDeleteParamsTest { @Test - fun createEnvVarDeleteParams() { + fun create() { EnvVarDeleteParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } 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 7c9ac87b..f05ccab5 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 @@ -3,30 +3,29 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class EnvVarListParamsTest { @Test - fun createEnvVarListParams() { + fun create() { EnvVarListParams.builder() .envVarName("env_var_name") - .ids(EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarListParams.ObjectType.ORGANIZATION) .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = EnvVarListParams.builder() .envVarName("env_var_name") - .ids(EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarListParams.ObjectType.ORGANIZATION) .build() @@ -36,16 +35,16 @@ class EnvVarListParamsTest { "ids", EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = EnvVarListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt index 0024324f..35b86df1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt @@ -12,17 +12,15 @@ class EnvVarListResponseTest { fun createEnvVarListResponse() { val envVarListResponse = EnvVarListResponse.builder() - .objects( - listOf( - EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) + .addObject( + EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() ) .build() assertThat(envVarListResponse).isNotNull diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt index 7be569fb..18ec7415 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class EnvVarReplaceParamsTest { @Test - fun createEnvVarReplaceParams() { + fun create() { EnvVarReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -19,7 +18,7 @@ class EnvVarReplaceParamsTest { } @Test - fun getBody() { + fun body() { val params = EnvVarReplaceParams.builder() .name("name") @@ -27,23 +26,23 @@ class EnvVarReplaceParamsTest { .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) .value("value") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.value()).isEqualTo("value") + assertThat(body.value()).contains("value") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = EnvVarReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt index 52c6148b..bca82bdc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class EnvVarRetrieveParamsTest { @Test - fun createEnvVarRetrieveParams() { + fun create() { EnvVarRetrieveParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt index 3ebce16f..062d510b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class EnvVarUpdateParamsTest { @Test - fun createEnvVarUpdateParams() { + fun create() { EnvVarUpdateParams.builder() .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") @@ -18,27 +17,27 @@ class EnvVarUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = EnvVarUpdateParams.builder() .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") .value("value") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") - assertThat(body.value()).isEqualTo("value") + assertThat(body.value()).contains("value") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = EnvVarUpdateParams.builder() .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index df685f8f..d64378bb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -2,38 +2,28 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class EvalCreateParamsTest { @Test - fun createEvalCreateParams() { + fun create() { EvalCreateParams.builder() - .data( - EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() - ) - ) + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) .projectId("project_id") - .scores( - listOf( - EvalCreateParams.Score.ofFunctionId( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - ) + .addScore( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() ) .task( - EvalCreateParams.Task.ofFunctionId( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() ) .baseExperimentId("base_experiment_id") .baseExperimentName("base_experiment_name") @@ -41,12 +31,16 @@ class EvalCreateParamsTest { .gitMetadataSettings( EvalCreateParams.GitMetadataSettings.builder() .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .fields(listOf(EvalCreateParams.GitMetadataSettings.Field.COMMIT)) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) .build() ) .isPublic(true) - .maxConcurrency(42.23) - .metadata(EvalCreateParams.Metadata.builder().build()) + .maxConcurrency(0.0) + .metadata( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") @@ -61,38 +55,28 @@ class EvalCreateParamsTest { .build() ) .stream(true) - .timeout(42.23) - .trialCount(42.23) + .timeout(0.0) + .trialCount(0.0) .build() } @Test - fun getBody() { + fun body() { val params = EvalCreateParams.builder() - .data( - EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() - ) - ) + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) .projectId("project_id") - .scores( - listOf( - EvalCreateParams.Score.ofFunctionId( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - ) + .addScore( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() ) .task( - EvalCreateParams.Task.ofFunctionId( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() ) .baseExperimentId("base_experiment_id") .baseExperimentName("base_experiment_name") @@ -100,12 +84,16 @@ class EvalCreateParamsTest { .gitMetadataSettings( EvalCreateParams.GitMetadataSettings.builder() .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .fields(listOf(EvalCreateParams.GitMetadataSettings.Field.COMMIT)) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) .build() ) .isPublic(true) - .maxConcurrency(42.23) - .metadata(EvalCreateParams.Metadata.builder().build()) + .maxConcurrency(0.0) + .metadata( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") @@ -120,10 +108,10 @@ class EvalCreateParamsTest { .build() ) .stream(true) - .timeout(42.23) - .trialCount(42.23) + .timeout(0.0) + .trialCount(0.0) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.data()) .isEqualTo( @@ -152,21 +140,26 @@ class EvalCreateParamsTest { .build() ) ) - assertThat(body.baseExperimentId()).isEqualTo("base_experiment_id") - assertThat(body.baseExperimentName()).isEqualTo("base_experiment_name") - assertThat(body.experimentName()).isEqualTo("experiment_name") + assertThat(body.baseExperimentId()).contains("base_experiment_id") + assertThat(body.baseExperimentName()).contains("base_experiment_name") + assertThat(body.experimentName()).contains("experiment_name") assertThat(body.gitMetadataSettings()) - .isEqualTo( + .contains( EvalCreateParams.GitMetadataSettings.builder() .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .fields(listOf(EvalCreateParams.GitMetadataSettings.Field.COMMIT)) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build() + ) + assertThat(body.isPublic()).contains(true) + assertThat(body.maxConcurrency()).contains(0.0) + assertThat(body.metadata()) + .contains( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - assertThat(body.isPublic()).isEqualTo(true) - assertThat(body.maxConcurrency()).isEqualTo(42.23) - assertThat(body.metadata()).isEqualTo(EvalCreateParams.Metadata.builder().build()) assertThat(body.repoInfo()) - .isEqualTo( + .contains( RepoInfo.builder() .authorEmail("author_email") .authorName("author_name") @@ -179,37 +172,23 @@ class EvalCreateParamsTest { .tag("tag") .build() ) - assertThat(body.stream()).isEqualTo(true) - assertThat(body.timeout()).isEqualTo(42.23) - assertThat(body.trialCount()).isEqualTo(42.23) + assertThat(body.stream()).contains(true) + assertThat(body.timeout()).contains(0.0) + assertThat(body.trialCount()).contains(0.0) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = EvalCreateParams.builder() - .data( - EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() - ) - ) + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) .projectId("project_id") - .scores( - listOf( - EvalCreateParams.Score.ofFunctionId( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .build() - ) - ) - ) - .task( - EvalCreateParams.Task.ofFunctionId( - EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build() - ) + .addScore( + EvalCreateParams.Score.FunctionId.builder().functionId("function_id").build() ) + .task(EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.data()) .isEqualTo( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 27054310..41b09d75 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -2,14 +2,14 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentCreateParamsTest { @Test - fun createExperimentCreateParams() { + fun create() { ExperimentCreateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -17,7 +17,11 @@ class ExperimentCreateParamsTest { .datasetVersion("dataset_version") .description("description") .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder().build()) + .metadata( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("x") .public_(true) .repoInfo( @@ -37,7 +41,7 @@ class ExperimentCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = ExperimentCreateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -46,7 +50,11 @@ class ExperimentCreateParamsTest { .datasetVersion("dataset_version") .description("description") .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder().build()) + .metadata( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("x") .public_(true) .repoInfo( @@ -63,19 +71,24 @@ class ExperimentCreateParamsTest { .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).isEqualTo("dataset_version") - assertThat(body.description()).isEqualTo("description") - assertThat(body.ensureNew()).isEqualTo(true) - assertThat(body.metadata()).isEqualTo(ExperimentCreateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("x") - assertThat(body.public_()).isEqualTo(true) + assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.description()).contains("description") + assertThat(body.ensureNew()).contains(true) + assertThat(body.metadata()) + .contains( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.name()).contains("x") + assertThat(body.public_()).contains(true) assertThat(body.repoInfo()) - .isEqualTo( + .contains( RepoInfo.builder() .authorEmail("author_email") .authorName("author_name") @@ -91,12 +104,12 @@ class ExperimentCreateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ExperimentCreateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt index 4577db52..30220ebc 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentDeleteParamsTest { @Test - fun createExperimentDeleteParams() { + fun create() { ExperimentDeleteParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .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 eb549b4c..3830f18c 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 @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -24,25 +24,29 @@ class ExperimentEventTest { ExperimentEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata(ExperimentEvent.Metadata.builder().build()) + .metadata( + ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( ExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) .origin( @@ -53,13 +57,17 @@ class ExperimentEventTest { .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) .build() ) - .output(JsonNull.of()) - .scores(ExperimentEvent.Scores.builder().build()) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() assertThat(experimentEvent).isNotNull assertThat(experimentEvent.id()).isEqualTo("id") @@ -75,26 +83,31 @@ class ExperimentEventTest { ExperimentEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") - assertThat(experimentEvent._error()).isEqualTo(JsonNull.of()) - assertThat(experimentEvent._expected()).isEqualTo(JsonNull.of()) - assertThat(experimentEvent._input()).isEqualTo(JsonNull.of()) + assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(experimentEvent.isRoot()).contains(true) - assertThat(experimentEvent.metadata()).contains(ExperimentEvent.Metadata.builder().build()) + assertThat(experimentEvent.metadata()) + .contains( + ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(experimentEvent.metrics()) .contains( ExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) assertThat(experimentEvent.origin()) @@ -106,8 +119,13 @@ class ExperimentEventTest { .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) .build() ) - assertThat(experimentEvent._output()).isEqualTo(JsonNull.of()) - assertThat(experimentEvent.scores()).contains(ExperimentEvent.Scores.builder().build()) + assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.scores()) + .contains( + ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(experimentEvent.spanAttributes()) .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) assertThat(experimentEvent.spanParents().get()).containsExactly("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index a0dafd44..01c11387 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -2,53 +2,64 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentFeedbackParamsTest { @Test - fun createExperimentFeedbackParams() { + fun create() { ExperimentFeedbackParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() ) .build() } @Test - fun getBody() { + fun body() { val params = ExperimentFeedbackParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo( @@ -56,24 +67,32 @@ class ExperimentFeedbackParamsTest { FeedbackExperimentItem.builder() .id("id") .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) + .addTag("string") .build() ) ) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ExperimentFeedbackParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackExperimentItem.builder().id("id").build())) + .addFeedback(FeedbackExperimentItem.builder().id("id").build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo(listOf(FeedbackExperimentItem.builder().id("id").build())) @@ -84,7 +103,7 @@ class ExperimentFeedbackParamsTest { val params = ExperimentFeedbackParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackExperimentItem.builder().id("id").build())) + .addFeedback(FeedbackExperimentItem.builder().id("id").build()) .build() assertThat(params).isNotNull // path param "experimentId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index 65cde54d..a699676d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -3,17 +3,16 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentFetchParamsTest { @Test - fun createExperimentFetchParams() { + fun create() { ExperimentFetchParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -21,31 +20,31 @@ class ExperimentFetchParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ExperimentFetchParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") .build() val expected = QueryParams.builder() - expected.put("limit", "123") + expected.put("limit", "0") expected.put("max_root_span_id", "max_root_span_id") expected.put("max_xact_id", "max_xact_id") expected.put("version", "version") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ExperimentFetchParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index fde0406f..e0f8a28a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -2,18 +2,17 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentFetchPostParamsTest { @Test - fun createExperimentFetchPostParams() { + fun create() { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -21,32 +20,32 @@ class ExperimentFetchPostParamsTest { } @Test - fun getBody() { + fun body() { val params = ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } 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 657899f2..d1f5ec03 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 @@ -2,8 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,45 +10,111 @@ import org.junit.jupiter.api.Test class ExperimentInsertParamsTest { @Test - fun createExperimentInsertParams() { + fun create() { ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( + .addEvent( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( InsertExperimentEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .context( InsertExperimentEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEvent.Metadata.builder().build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) - .output(JsonNull.of()) + .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder().build()) + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder() .name("name") @@ -57,69 +122,12 @@ class ExperimentInsertParamsTest { .build() ) .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() ) - ) - .build() - } - - @Test - fun getBody() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEvent.Metadata.builder().build()) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder().build()) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.events()) .isEqualTo( @@ -127,37 +135,45 @@ class ExperimentInsertParamsTest { InsertExperimentEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .context( InsertExperimentEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEvent.Metadata.builder().build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) - .output(JsonNull.of()) + .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder().build()) + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder() .name("name") @@ -165,21 +181,21 @@ class ExperimentInsertParamsTest { .build() ) .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() ) ) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(InsertExperimentEvent.builder().build())) + .addEvent(InsertExperimentEvent.builder().build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) } @@ -189,7 +205,7 @@ class ExperimentInsertParamsTest { val params = ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(InsertExperimentEvent.builder().build())) + .addEvent(InsertExperimentEvent.builder().build()) .build() assertThat(params).isNotNull // path param "experimentId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 738a0197..61605b19 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -3,19 +3,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentListParamsTest { @Test - fun createExperimentListParams() { + fun create() { ExperimentListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .experimentName("experiment_name") - .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -24,13 +23,13 @@ class ExperimentListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ExperimentListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .experimentName("experiment_name") - .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -43,18 +42,18 @@ class ExperimentListParamsTest { "ids", ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("project_name", "project_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ExperimentListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt index 5efe0624..b9530a24 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentRetrieveParamsTest { @Test - fun createExperimentRetrieveParams() { + fun create() { ExperimentRetrieveParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index fe05c8ec..257ca247 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -3,14 +3,13 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentSummarizeParamsTest { @Test - fun createExperimentSummarizeParams() { + fun create() { ExperimentSummarizeParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -19,7 +18,7 @@ class ExperimentSummarizeParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ExperimentSummarizeParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -29,17 +28,17 @@ class ExperimentSummarizeParamsTest { val expected = QueryParams.builder() expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("summarize_scores", "true") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ExperimentSummarizeParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt index 7ab7dcdc..2d2df4e3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -23,7 +24,11 @@ class ExperimentTest { .datasetVersion("dataset_version") .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .metadata(Experiment.Metadata.builder().build()) + .metadata( + Experiment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") @@ -52,7 +57,12 @@ class ExperimentTest { assertThat(experiment.deletedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(experiment.description()).contains("description") - assertThat(experiment.metadata()).contains(Experiment.Metadata.builder().build()) + assertThat(experiment.metadata()) + .contains( + Experiment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(experiment.repoInfo()) .contains( RepoInfo.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index 22231f89..19cb4e57 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -2,21 +2,25 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ExperimentUpdateParamsTest { @Test - fun createExperimentUpdateParams() { + fun create() { ExperimentUpdateParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetVersion("dataset_version") .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder().build()) + .metadata( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .public_(true) .repoInfo( @@ -36,7 +40,7 @@ class ExperimentUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = ExperimentUpdateParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -44,7 +48,11 @@ class ExperimentUpdateParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetVersion("dataset_version") .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder().build()) + .metadata( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .public_(true) .repoInfo( @@ -61,17 +69,22 @@ class ExperimentUpdateParamsTest { .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).isEqualTo("dataset_version") - assertThat(body.description()).isEqualTo("description") - assertThat(body.metadata()).isEqualTo(ExperimentUpdateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") - assertThat(body.public_()).isEqualTo(true) + assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.description()).contains("description") + assertThat(body.metadata()) + .contains( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.name()).contains("name") + assertThat(body.public_()).contains(true) assertThat(body.repoInfo()) - .isEqualTo( + .contains( RepoInfo.builder() .authorEmail("author_email") .authorName("author_name") @@ -87,12 +100,12 @@ class ExperimentUpdateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ExperimentUpdateParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index b3719906..6543fca7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,15 +14,23 @@ class FeedbackDatasetItemTest { FeedbackDatasetItem.builder() .id("id") .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) + .addTag("string") .build() assertThat(feedbackDatasetItem).isNotNull assertThat(feedbackDatasetItem.id()).isEqualTo("id") assertThat(feedbackDatasetItem.comment()).contains("comment") assertThat(feedbackDatasetItem.metadata()) - .contains(FeedbackDatasetItem.Metadata.builder().build()) + .contains( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index 7e050574..eef4dee8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,20 +14,37 @@ class FeedbackExperimentItemTest { FeedbackExperimentItem.builder() .id("id") .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) + .addTag("string") .build() assertThat(feedbackExperimentItem).isNotNull assertThat(feedbackExperimentItem.id()).isEqualTo("id") assertThat(feedbackExperimentItem.comment()).contains("comment") - assertThat(feedbackExperimentItem._expected()).isEqualTo(JsonNull.of()) + assertThat(feedbackExperimentItem._expected()) + .isEqualTo(JsonValue.from(mapOf())) assertThat(feedbackExperimentItem.metadata()) - .contains(FeedbackExperimentItem.Metadata.builder().build()) + .contains( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(feedbackExperimentItem.scores()) - .contains(FeedbackExperimentItem.Scores.builder().build()) + .contains( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index b622ead2..34f44497 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,20 +14,37 @@ class FeedbackProjectLogsItemTest { FeedbackProjectLogsItem.builder() .id("id") .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) + .addTag("string") .build() assertThat(feedbackProjectLogsItem).isNotNull assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") assertThat(feedbackProjectLogsItem.comment()).contains("comment") - assertThat(feedbackProjectLogsItem._expected()).isEqualTo(JsonNull.of()) + assertThat(feedbackProjectLogsItem._expected()) + .isEqualTo(JsonValue.from(mapOf())) assertThat(feedbackProjectLogsItem.metadata()) - .contains(FeedbackProjectLogsItem.Metadata.builder().build()) + .contains( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(feedbackProjectLogsItem.scores()) - .contains(FeedbackProjectLogsItem.Scores.builder().build()) + .contains( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt index edc1f179..ad7d703b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,31 +13,33 @@ class FetchDatasetEventsResponseTest { fun createFetchDatasetEventsResponse() { val fetchDatasetEventsResponse = FetchDatasetEventsResponse.builder() - .events( - listOf( - DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonNull.of()) - .input(JsonNull.of()) - .isRoot(true) - .metadata(DatasetEvent.Metadata.builder().build()) - .origin( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .tags(listOf("string")) - .build() - ) + .addEvent( + DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .origin( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .addTag("string") + .build() ) .cursor("cursor") .build() @@ -52,10 +54,14 @@ class FetchDatasetEventsResponseTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .rootSpanId("root_span_id") .spanId("span_id") - .expected(JsonNull.of()) - .input(JsonNull.of()) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata(DatasetEvent.Metadata.builder().build()) + .metadata( + DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .origin( DatasetEvent.Origin.builder() .id("id") @@ -64,7 +70,7 @@ class FetchDatasetEventsResponseTest { .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) .build() ) - .tags(listOf("string")) + .addTag("string") .build() ) assertThat(fetchDatasetEventsResponse.cursor()).contains("cursor") 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 59428a69..7e95ce35 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 @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,61 +13,67 @@ class FetchExperimentEventsResponseTest { fun createFetchExperimentEventsResponse() { val fetchExperimentEventsResponse = FetchExperimentEventsResponse.builder() - .events( - listOf( - ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .isRoot(true) - .metadata(ExperimentEvent.Metadata.builder().build()) - .metrics( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .origin( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonNull.of()) - .scores(ExperimentEvent.Scores.builder().build()) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) + .addEvent( + ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .origin( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .addSpanParent("string") + .addTag("string") + .build() ) .cursor("cursor") .build() @@ -86,25 +92,29 @@ class FetchExperimentEventsResponseTest { ExperimentEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata(ExperimentEvent.Metadata.builder().build()) + .metadata( + ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( ExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) .origin( @@ -115,13 +125,17 @@ class FetchExperimentEventsResponseTest { .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) .build() ) - .output(JsonNull.of()) - .scores(ExperimentEvent.Scores.builder().build()) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() ) assertThat(fetchExperimentEventsResponse.cursor()).contains("cursor") 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 589fb2a1..4c35853e 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 @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,61 +13,67 @@ class FetchProjectLogsEventsResponseTest { fun createFetchProjectLogsEventsResponse() { val fetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse.builder() - .events( - listOf( - ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .isRoot(true) - .metadata(ProjectLogsEvent.Metadata.builder().build()) - .metrics( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .origin( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonNull.of()) - .scores(ProjectLogsEvent.Scores.builder().build()) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) + .addEvent( + ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .origin( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .addSpanParent("string") + .addTag("string") + .build() ) .cursor("cursor") .build() @@ -87,24 +93,28 @@ class FetchProjectLogsEventsResponseTest { ProjectLogsEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata(ProjectLogsEvent.Metadata.builder().build()) + .metadata( + ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) .origin( @@ -115,13 +125,17 @@ class FetchProjectLogsEventsResponseTest { .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) .build() ) - .output(JsonNull.of()) - .scores(ProjectLogsEvent.Scores.builder().build()) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() ) assertThat(fetchProjectLogsEventsResponse.cursor()).contains("cursor") 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 37a9323e..eeac10b7 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 @@ -2,22 +2,19 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class FunctionCreateParamsTest { @Test - fun createFunctionCreateParams() { + fun create() { FunctionCreateParams.builder() .functionData( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -25,8 +22,8 @@ class FunctionCreateParamsTest { .description("description") .functionSchema( FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) .functionType(FunctionCreateParams.FunctionType.LLM) @@ -43,53 +40,12 @@ class FunctionCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -103,45 +59,41 @@ class FunctionCreateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() } @Test - fun getBody() { + fun body() { val params = FunctionCreateParams.builder() .functionData( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -149,8 +101,8 @@ class FunctionCreateParamsTest { .description("description") .functionSchema( FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) .functionType(FunctionCreateParams.FunctionType.LLM) @@ -167,55 +119,12 @@ class FunctionCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -229,34 +138,32 @@ class FunctionCreateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.functionData()) .isEqualTo( @@ -269,17 +176,17 @@ class FunctionCreateParamsTest { assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).isEqualTo("description") + assertThat(body.description()).contains("description") assertThat(body.functionSchema()) - .isEqualTo( + .contains( FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) - assertThat(body.functionType()).isEqualTo(FunctionCreateParams.FunctionType.LLM) + assertThat(body.functionType()).contains(FunctionCreateParams.FunctionType.LLM) assertThat(body.origin()) - .isEqualTo( + .contains( FunctionCreateParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) @@ -287,59 +194,18 @@ class FunctionCreateParamsTest { .build() ) assertThat(body.promptData()) - .isEqualTo( + .contains( PromptData.builder() .options( PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -353,50 +219,46 @@ class FunctionCreateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - assertThat(body.tags()).isEqualTo(listOf("string")) + assertThat(body.tags()).contains(listOf("string")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = FunctionCreateParams.builder() .functionData( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("x") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.functionData()) .isEqualTo( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt index b6a1f5f2..480affa6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class FunctionDeleteParamsTest { @Test - fun createFunctionDeleteParams() { + fun create() { FunctionDeleteParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index 8b261382..b80c7210 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -2,32 +2,65 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class FunctionInvokeParamsTest { @Test - fun createFunctionInvokeParams() { + fun create() { FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonNull.of()) - .messages( - listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - ) + .input(JsonValue.from(mapOf())) + .addMessage( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( - FunctionInvokeParams.Parent.ofSpanParentStruct( + FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + .stream(true) + .version("version") + .build() + } + + @Test + fun body() { + val params = + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() .objectId("object_id") .objectType( @@ -35,6 +68,7 @@ class FunctionInvokeParamsTest { ) .propagatedEvent( FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .rowIds( @@ -46,60 +80,14 @@ class FunctionInvokeParamsTest { ) .build() ) - ) - .stream(true) - .version("version") - .build() - } - - @Test - fun getBody() { - val params = - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonNull.of()) - .messages( - listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - ) - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.ofSpanParentStruct( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent - .builder() - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - ) .stream(true) .version("version") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.input()).isEqualTo(JsonNull.of()) + assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.messages()) - .isEqualTo( + .contains( listOf( FunctionInvokeParams.Message.ofSystem( FunctionInvokeParams.Message.System.builder() @@ -110,9 +98,9 @@ class FunctionInvokeParamsTest { ) ) ) - assertThat(body.mode()).isEqualTo(FunctionInvokeParams.Mode.AUTO) + assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) assertThat(body.parent()) - .isEqualTo( + .contains( FunctionInvokeParams.Parent.ofSpanParentStruct( FunctionInvokeParams.Parent.SpanParentStruct.builder() .objectId("object_id") @@ -121,6 +109,7 @@ class FunctionInvokeParamsTest { ) .propagatedEvent( FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .rowIds( @@ -133,17 +122,17 @@ class FunctionInvokeParamsTest { .build() ) ) - assertThat(body.stream()).isEqualTo(true) - assertThat(body.version()).isEqualTo("version") + assertThat(body.stream()).contains(true) + assertThat(body.version()).contains("version") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 7593f144..3f340fc9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -3,19 +3,18 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class FunctionListParamsTest { @Test - fun createFunctionListParams() { + fun create() { FunctionListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .functionName("function_name") - .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -26,13 +25,13 @@ class FunctionListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = FunctionListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .functionName("function_name") - .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -47,20 +46,20 @@ class FunctionListParamsTest { "ids", FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("project_name", "project_name") expected.put("slug", "slug") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("version", "version") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = FunctionListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.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 8e387b3e..df7c0649 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 @@ -2,22 +2,19 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class FunctionReplaceParamsTest { @Test - fun createFunctionReplaceParams() { + fun create() { FunctionReplaceParams.builder() .functionData( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -25,8 +22,8 @@ class FunctionReplaceParamsTest { .description("description") .functionSchema( FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) .functionType(FunctionReplaceParams.FunctionType.LLM) @@ -43,53 +40,12 @@ class FunctionReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -103,45 +59,41 @@ class FunctionReplaceParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() } @Test - fun getBody() { + fun body() { val params = FunctionReplaceParams.builder() .functionData( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -149,8 +101,8 @@ class FunctionReplaceParamsTest { .description("description") .functionSchema( FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) .functionType(FunctionReplaceParams.FunctionType.LLM) @@ -167,55 +119,12 @@ class FunctionReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -229,34 +138,32 @@ class FunctionReplaceParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.functionData()) .isEqualTo( @@ -269,17 +176,17 @@ class FunctionReplaceParamsTest { assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).isEqualTo("description") + assertThat(body.description()).contains("description") assertThat(body.functionSchema()) - .isEqualTo( + .contains( FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) - assertThat(body.functionType()).isEqualTo(FunctionReplaceParams.FunctionType.LLM) + assertThat(body.functionType()).contains(FunctionReplaceParams.FunctionType.LLM) assertThat(body.origin()) - .isEqualTo( + .contains( FunctionReplaceParams.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) @@ -287,59 +194,18 @@ class FunctionReplaceParamsTest { .build() ) assertThat(body.promptData()) - .isEqualTo( + .contains( PromptData.builder() .options( PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -353,50 +219,46 @@ class FunctionReplaceParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - assertThat(body.tags()).isEqualTo(listOf("string")) + assertThat(body.tags()).contains(listOf("string")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = FunctionReplaceParams.builder() .functionData( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("x") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.functionData()) .isEqualTo( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt index e67f96c5..95d6777e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class FunctionRetrieveParamsTest { @Test - fun createFunctionRetrieveParams() { + fun create() { FunctionRetrieveParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").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 6aa745a0..fffade2d 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 @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -16,11 +16,9 @@ class FunctionTest { .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") ._xactId("_xact_id") .functionData( - Function.FunctionData.ofPrompt( - Function.FunctionData.Prompt.builder() - .type(Function.FunctionData.Prompt.Type.PROMPT) - .build() - ) + Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build() ) .logId(Function.LogId.P) .name("name") @@ -31,12 +29,16 @@ class FunctionTest { .description("description") .functionSchema( Function.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) .functionType(Function.FunctionType.LLM) - .metadata(Function.Metadata.builder().build()) + .metadata( + Function.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .origin( Function.Origin.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -50,55 +52,12 @@ class FunctionTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -112,32 +71,30 @@ class FunctionTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() assertThat(function).isNotNull assertThat(function.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -160,12 +117,17 @@ class FunctionTest { assertThat(function.functionSchema()) .contains( Function.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) assertThat(function.functionType()).contains(Function.FunctionType.LLM) - assertThat(function.metadata()).contains(Function.Metadata.builder().build()) + assertThat(function.metadata()) + .contains( + Function.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(function.origin()) .contains( Function.Origin.builder() @@ -181,53 +143,12 @@ class FunctionTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -241,28 +162,26 @@ class FunctionTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index a7724f5e..72c57065 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -2,23 +2,21 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class FunctionUpdateParamsTest { @Test - fun createFunctionUpdateParams() { + fun create() { FunctionUpdateParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .functionData( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("name") .promptData( @@ -27,53 +25,12 @@ class FunctionUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -87,47 +44,43 @@ class FunctionUpdateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() } @Test - fun getBody() { + fun body() { val params = FunctionUpdateParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .functionData( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("name") .promptData( @@ -136,55 +89,12 @@ class FunctionUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -198,99 +108,56 @@ class FunctionUpdateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("description") + assertThat(body.description()).contains("description") assertThat(body.functionData()) - .isEqualTo( + .contains( FunctionUpdateParams.FunctionData.ofPrompt( FunctionUpdateParams.FunctionData.Prompt.builder() .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) .build() ) ) - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).contains("name") assertThat(body.promptData()) - .isEqualTo( + .contains( PromptData.builder() .options( PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -304,41 +171,39 @@ class FunctionUpdateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - assertThat(body.tags()).isEqualTo(listOf("string")) + assertThat(body.tags()).contains(listOf("string")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = FunctionUpdateParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index 4b672ac6..6b80eb15 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -2,46 +2,45 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class GroupCreateParamsTest { @Test - fun createGroupCreateParams() { + fun create() { GroupCreateParams.builder() .name("x") .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() } @Test - fun getBody() { + fun body() { val params = GroupCreateParams.builder() .name("x") .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.description()).contains("description") + assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = GroupCreateParams.builder().name("x").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt index dd8a03f2..e7f479a6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class GroupDeleteParamsTest { @Test - fun createGroupDeleteParams() { + fun create() { GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index 6953b0c4..149ae449 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -3,32 +3,31 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class GroupListParamsTest { @Test - fun createGroupListParams() { + fun create() { GroupListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .groupName("group_name") - .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = GroupListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .groupName("group_name") - .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -39,16 +38,16 @@ class GroupListParamsTest { "ids", GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = GroupListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index 99a651e9..eea89257 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -2,46 +2,45 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class GroupReplaceParamsTest { @Test - fun createGroupReplaceParams() { + fun create() { GroupReplaceParams.builder() .name("x") .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() } @Test - fun getBody() { + fun body() { val params = GroupReplaceParams.builder() .name("x") .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.description()).contains("description") + assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = GroupReplaceParams.builder().name("x").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt index 40cb190f..289d5b88 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class GroupRetrieveParamsTest { @Test - fun createGroupRetrieveParams() { + fun create() { GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt index 4b8a9f64..1acccdaa 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt @@ -18,8 +18,8 @@ class GroupTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(group).isNotNull diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index e0bc5b14..fa36b2eb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -2,54 +2,53 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class GroupUpdateParamsTest { @Test - fun createGroupUpdateParams() { + fun create() { GroupUpdateParams.builder() .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .name("x") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getBody() { + fun body() { val params = GroupUpdateParams.builder() .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .name("x") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.addMemberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.addMemberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("x") + assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("x") assertThat(body.removeMemberGroups()) - .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.removeMemberUsers()) - .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt index 7191f0b7..53366aec 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,17 +15,21 @@ class InsertDatasetEventTest { InsertDatasetEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEvent.Metadata.builder().build()) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .rootSpanId("root_span_id") .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() assertThat(insertDatasetEvent).isNotNull assertThat(insertDatasetEvent.id()).contains("id") @@ -35,10 +39,14 @@ class InsertDatasetEventTest { assertThat(insertDatasetEvent._parentId()).contains("_parent_id") assertThat(insertDatasetEvent.created()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertDatasetEvent._expected()).isEqualTo(JsonNull.of()) - assertThat(insertDatasetEvent._input()).isEqualTo(JsonNull.of()) + assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertDatasetEvent.metadata()) - .contains(InsertDatasetEvent.Metadata.builder().build()) + .contains( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") assertThat(insertDatasetEvent.spanId()).contains("span_id") assertThat(insertDatasetEvent.spanParents().get()).containsExactly("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt index a55a1208..96d2a732 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt @@ -9,7 +9,7 @@ class InsertEventsResponseTest { @Test fun createInsertEventsResponse() { - val insertEventsResponse = InsertEventsResponse.builder().rowIds(listOf("string")).build() + val insertEventsResponse = InsertEventsResponse.builder().addRowId("string").build() assertThat(insertEventsResponse).isNotNull assertThat(insertEventsResponse.rowIds()).containsExactly("string") } 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 4f2d0418..e9425570 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 @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,43 +15,51 @@ class InsertExperimentEventTest { InsertExperimentEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .context( InsertExperimentEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEvent.Metadata.builder().build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) - .output(JsonNull.of()) + .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder().build()) + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() assertThat(insertExperimentEvent).isNotNull assertThat(insertExperimentEvent.id()).contains("id") @@ -64,34 +72,43 @@ class InsertExperimentEventTest { InsertExperimentEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) assertThat(insertExperimentEvent.created()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") - assertThat(insertExperimentEvent._error()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEvent._expected()).isEqualTo(JsonNull.of()) - assertThat(insertExperimentEvent._input()).isEqualTo(JsonNull.of()) + assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent.metadata()) - .contains(InsertExperimentEvent.Metadata.builder().build()) + .contains( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(insertExperimentEvent.metrics()) .contains( InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) - assertThat(insertExperimentEvent._output()).isEqualTo(JsonNull.of()) + assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") assertThat(insertExperimentEvent.scores()) - .contains(InsertExperimentEvent.Scores.builder().build()) + .contains( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(insertExperimentEvent.spanAttributes()) .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) assertThat(insertExperimentEvent.spanId()).contains("span_id") 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 66f6ac96..3454b8e9 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 @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,42 +15,50 @@ class InsertProjectLogsEventTest { InsertProjectLogsEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .context( InsertProjectLogsEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEvent.Metadata.builder().build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) - .output(JsonNull.of()) + .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder().build()) + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() assertThat(insertProjectLogsEvent).isNotNull assertThat(insertProjectLogsEvent.id()).contains("id") @@ -63,33 +71,42 @@ class InsertProjectLogsEventTest { InsertProjectLogsEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) assertThat(insertProjectLogsEvent.created()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEvent._expected()).isEqualTo(JsonNull.of()) - assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonNull.of()) + assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertProjectLogsEvent.metadata()) - .contains(InsertProjectLogsEvent.Metadata.builder().build()) + .contains( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(insertProjectLogsEvent.metrics()) .contains( InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) - assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonNull.of()) + assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") assertThat(insertProjectLogsEvent.scores()) - .contains(InsertProjectLogsEvent.Scores.builder().build()) + .contains( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(insertProjectLogsEvent.spanAttributes()) .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) assertThat(insertProjectLogsEvent.spanId()).contains("span_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt index 50e74b12..cc848c7c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt @@ -11,19 +11,19 @@ class MetricSummaryTest { fun createMetricSummary() { val metricSummary = MetricSummary.builder() - .improvements(123L) - .metric(42.23) + .improvements(0L) + .metric(0.0) .name("name") - .regressions(123L) + .regressions(0L) .unit("unit") - .diff(42.23) + .diff(0.0) .build() assertThat(metricSummary).isNotNull - assertThat(metricSummary.improvements()).isEqualTo(123L) - assertThat(metricSummary.metric()).isEqualTo(42.23) + assertThat(metricSummary.improvements()).isEqualTo(0L) + assertThat(metricSummary.metric()).isEqualTo(0.0) assertThat(metricSummary.name()).isEqualTo("name") - assertThat(metricSummary.regressions()).isEqualTo(123L) + assertThat(metricSummary.regressions()).isEqualTo(0L) assertThat(metricSummary.unit()).isEqualTo("unit") - assertThat(metricSummary.diff()).contains(42.23) + assertThat(metricSummary.diff()).contains(0.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt index 1248b4b2..33f7f133 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt @@ -11,22 +11,18 @@ class OnlineScoreConfigTest { fun createOnlineScoreConfig() { val onlineScoreConfig = OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() assertThat(onlineScoreConfig).isNotNull - assertThat(onlineScoreConfig.samplingRate()).isEqualTo(1.0) + assertThat(onlineScoreConfig.samplingRate()).isEqualTo(0.0) assertThat(onlineScoreConfig.scorers()) .containsExactly( OnlineScoreConfig.Scorer.ofFunction( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt index 1c6fe6ac..b86730ee 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class OrganizationDeleteParamsTest { @Test - fun createOrganizationDeleteParams() { + fun create() { OrganizationDeleteParams.builder() .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index d62a5248..66664552 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -3,30 +3,29 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class OrganizationListParamsTest { @Test - fun createOrganizationListParams() { + fun create() { OrganizationListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = OrganizationListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -36,16 +35,16 @@ class OrganizationListParamsTest { "ids", OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = OrganizationListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt index 99b5aca9..bce46ec6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -2,23 +2,22 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class OrganizationMemberUpdateParamsTest { @Test - fun createOrganizationMemberUpdateParams() { + fun create() { OrganizationMemberUpdateParams.builder() .inviteUsers( OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) + .addEmail("string") .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .groupName("group_name") - .groupNames(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sendInviteEmails(true) .build() ) @@ -26,25 +25,25 @@ class OrganizationMemberUpdateParamsTest { .orgName("org_name") .removeUsers( OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) .build() } @Test - fun getBody() { + fun body() { val params = OrganizationMemberUpdateParams.builder() .inviteUsers( OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) + .addEmail("string") .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .groupName("group_name") - .groupNames(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sendInviteEmails(true) .build() ) @@ -52,40 +51,40 @@ class OrganizationMemberUpdateParamsTest { .orgName("org_name") .removeUsers( OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.inviteUsers()) - .isEqualTo( + .contains( OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) + .addEmail("string") .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .groupName("group_name") - .groupNames(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sendInviteEmails(true) .build() ) - assertThat(body.orgId()).isEqualTo("org_id") - assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.orgId()).contains("org_id") + assertThat(body.orgName()).contains("org_name") assertThat(body.removeUsers()) - .isEqualTo( + .contains( OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = OrganizationMemberUpdateParams.builder().build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt index 4ccbda0e..d7faaa14 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class OrganizationRetrieveParamsTest { @Test - fun createOrganizationRetrieveParams() { + fun create() { OrganizationRetrieveParams.builder() .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt index cc38ee32..c311f880 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class OrganizationUpdateParamsTest { @Test - fun createOrganizationUpdateParams() { + fun create() { OrganizationUpdateParams.builder() .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .apiUrl("api_url") @@ -21,7 +20,7 @@ class OrganizationUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = OrganizationUpdateParams.builder() .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -31,22 +30,22 @@ class OrganizationUpdateParamsTest { .proxyUrl("proxy_url") .realtimeUrl("realtime_url") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.apiUrl()).isEqualTo("api_url") - assertThat(body.isUniversalApi()).isEqualTo(true) - assertThat(body.name()).isEqualTo("name") - assertThat(body.proxyUrl()).isEqualTo("proxy_url") - assertThat(body.realtimeUrl()).isEqualTo("realtime_url") + assertThat(body.apiUrl()).contains("api_url") + assertThat(body.isUniversalApi()).contains(true) + assertThat(body.name()).contains("name") + assertThat(body.proxyUrl()).contains("proxy_url") + assertThat(body.realtimeUrl()).contains("realtime_url") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = OrganizationUpdateParams.builder() .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index 745c9b01..e9a16b54 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -2,30 +2,29 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectCreateParamsTest { @Test - fun createProjectCreateParams() { + fun create() { ProjectCreateParams.builder().name("x").orgName("org_name").build() } @Test - fun getBody() { + fun body() { val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") - assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.orgName()).contains("org_name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectCreateParams.builder().name("x").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt index caa2ac8b..b55b368f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectDeleteParamsTest { @Test - fun createProjectDeleteParams() { + fun create() { ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 33006eaa..90339cf7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -3,18 +3,17 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectListParamsTest { @Test - fun createProjectListParams() { + fun create() { ProjectListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -22,12 +21,12 @@ class ProjectListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ProjectListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -38,17 +37,17 @@ class ProjectListParamsTest { "ids", ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("project_name", "project_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ProjectListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index 4b9a5bb8..c8daa5bf 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -2,53 +2,64 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectLogFeedbackParamsTest { @Test - fun createProjectLogFeedbackParams() { + fun create() { ProjectLogFeedbackParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() ) .build() } @Test - fun getBody() { + fun body() { val params = ProjectLogFeedbackParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo( @@ -56,24 +67,32 @@ class ProjectLogFeedbackParamsTest { FeedbackProjectLogsItem.builder() .id("id") .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) + .addTag("string") .build() ) ) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectLogFeedbackParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackProjectLogsItem.builder().id("id").build())) + .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo(listOf(FeedbackProjectLogsItem.builder().id("id").build())) @@ -84,7 +103,7 @@ class ProjectLogFeedbackParamsTest { val params = ProjectLogFeedbackParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackProjectLogsItem.builder().id("id").build())) + .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) .build() assertThat(params).isNotNull // path param "projectId" diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index 16937d36..6e341ea3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -3,17 +3,16 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectLogFetchParamsTest { @Test - fun createProjectLogFetchParams() { + fun create() { ProjectLogFetchParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -21,31 +20,31 @@ class ProjectLogFetchParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ProjectLogFetchParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") .build() val expected = QueryParams.builder() - expected.put("limit", "123") + expected.put("limit", "0") expected.put("max_root_span_id", "max_root_span_id") expected.put("max_xact_id", "max_xact_id") expected.put("version", "version") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ProjectLogFetchParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 421ef272..4dc85b96 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -2,18 +2,17 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectLogFetchPostParamsTest { @Test - fun createProjectLogFetchPostParams() { + fun create() { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -21,32 +20,32 @@ class ProjectLogFetchPostParamsTest { } @Test - fun getBody() { + fun body() { val params = ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } 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 851546b4..d75d255a 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 @@ -2,8 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,44 +10,109 @@ import org.junit.jupiter.api.Test class ProjectLogInsertParamsTest { @Test - fun createProjectLogInsertParams() { + fun create() { ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( + .addEvent( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( InsertProjectLogsEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .context( InsertProjectLogsEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEvent.Metadata.builder().build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) - .output(JsonNull.of()) + .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder().build()) + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder() .name("name") @@ -56,68 +120,12 @@ class ProjectLogInsertParamsTest { .build() ) .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() ) - ) - .build() - } - - @Test - fun getBody() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEvent.Metadata.builder().build()) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder().build()) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.events()) .isEqualTo( @@ -125,36 +133,44 @@ class ProjectLogInsertParamsTest { InsertProjectLogsEvent.builder() .id("id") ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) + .addMergePath(listOf("string")) ._objectDelete(true) ._parentId("_parent_id") .context( InsertProjectLogsEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEvent.Metadata.builder().build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) - .output(JsonNull.of()) + .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder().build()) + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder() .name("name") @@ -162,21 +178,21 @@ class ProjectLogInsertParamsTest { .build() ) .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() ) ) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(InsertProjectLogsEvent.builder().build())) + .addEvent(InsertProjectLogsEvent.builder().build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) } @@ -186,7 +202,7 @@ class ProjectLogInsertParamsTest { val params = ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events(listOf(InsertProjectLogsEvent.builder().build())) + .addEvent(InsertProjectLogsEvent.builder().build()) .build() assertThat(params).isNotNull // path param "projectId" 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 7b27c557..d49aac8a 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 @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -25,24 +25,28 @@ class ProjectLogsEventTest { ProjectLogsEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata(ProjectLogsEvent.Metadata.builder().build()) + .metadata( + ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .metrics( ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) .origin( @@ -53,13 +57,17 @@ class ProjectLogsEventTest { .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) .build() ) - .output(JsonNull.of()) - .scores(ProjectLogsEvent.Scores.builder().build()) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .spanAttributes( SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() ) - .spanParents(listOf("string")) - .tags(listOf("string")) + .addSpanParent("string") + .addTag("string") .build() assertThat(projectLogsEvent).isNotNull assertThat(projectLogsEvent.id()).isEqualTo("id") @@ -76,26 +84,30 @@ class ProjectLogsEventTest { ProjectLogsEvent.Context.builder() .callerFilename("caller_filename") .callerFunctionname("caller_functionname") - .callerLineno(123L) + .callerLineno(0L) .build() ) - assertThat(projectLogsEvent._error()).isEqualTo(JsonNull.of()) - assertThat(projectLogsEvent._expected()).isEqualTo(JsonNull.of()) - assertThat(projectLogsEvent._input()).isEqualTo(JsonNull.of()) + assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(projectLogsEvent.isRoot()).contains(true) assertThat(projectLogsEvent.metadata()) - .contains(ProjectLogsEvent.Metadata.builder().build()) + .contains( + ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(projectLogsEvent.metrics()) .contains( ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) .build() ) assertThat(projectLogsEvent.origin()) @@ -107,8 +119,13 @@ class ProjectLogsEventTest { .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) .build() ) - assertThat(projectLogsEvent._output()).isEqualTo(JsonNull.of()) - assertThat(projectLogsEvent.scores()).contains(ProjectLogsEvent.Scores.builder().build()) + assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.scores()) + .contains( + ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(projectLogsEvent.spanAttributes()) .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) assertThat(projectLogsEvent.spanParents().get()).containsExactly("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt index 231a1864..071ceffa 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectRetrieveParamsTest { @Test - fun createProjectRetrieveParams() { + fun create() { ProjectRetrieveParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt index a190a270..95a3b093 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt @@ -9,9 +9,9 @@ class ProjectScoreCategoryTest { @Test fun createProjectScoreCategory() { - val projectScoreCategory = ProjectScoreCategory.builder().name("name").value(42.23).build() + val projectScoreCategory = ProjectScoreCategory.builder().name("name").value(0.0).build() assertThat(projectScoreCategory).isNotNull assertThat(projectScoreCategory.name()).isEqualTo("name") - assertThat(projectScoreCategory.value()).isEqualTo(42.23) + assertThat(projectScoreCategory.value()).isEqualTo(0.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt index 7639e899..ebd3f975 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt @@ -15,19 +15,15 @@ class ProjectScoreConfigTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() @@ -38,19 +34,15 @@ class ProjectScoreConfigTest { assertThat(projectScoreConfig.online()) .contains( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) } 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 72943820..6848c8a4 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 @@ -2,22 +2,19 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectScoreCreateParamsTest { @Test - fun createProjectScoreCreateParams() { + fun create() { ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categories( - ProjectScoreCreateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -25,19 +22,15 @@ class ProjectScoreCreateParamsTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() @@ -47,16 +40,14 @@ class ProjectScoreCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categories( - ProjectScoreCreateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -64,74 +55,64 @@ class ProjectScoreCreateParamsTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type( - OnlineScoreConfig.Scorer.Function.Type.FUNCTION - ) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() ) .description("description") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) assertThat(body.categories()) - .isEqualTo( + .contains( ProjectScoreCreateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) ) assertThat(body.config()) - .isEqualTo( + .contains( ProjectScoreConfig.builder() .destination(ProjectScoreConfig.Destination.EXPECTED) .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() ) - assertThat(body.description()).isEqualTo("description") + assertThat(body.description()).contains("description") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectScoreCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt index 896f79a5..f341257a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectScoreDeleteParamsTest { @Test - fun createProjectScoreDeleteParams() { + fun create() { ProjectScoreDeleteParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() 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 b47368d1..17726294 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 @@ -3,47 +3,38 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectScoreListParamsTest { @Test - fun createProjectScoreListParams() { + fun create() { ProjectScoreListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectScoreName("project_score_name") - .scoreType( - ProjectScoreListParams.ScoreType.ofProjectScoreType( - ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER - ) - ) + .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = ProjectScoreListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") .projectScoreName("project_score_name") - .scoreType( - ProjectScoreListParams.ScoreType.ofProjectScoreType( - ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER - ) - ) + .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val expected = QueryParams.builder() @@ -52,26 +43,26 @@ class ProjectScoreListParamsTest { "ids", ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("project_name", "project_name") expected.put("project_score_name", "project_score_name") expected.put( "score_type", - ProjectScoreListParams.ScoreType.ofProjectScoreType( - ProjectScoreListParams.ProjectScoreType.SLIDER.toString() + ProjectScoreListParams.ScoreType.ofProject( + ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString() ) .toString() ) expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ProjectScoreListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } 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 d24b9895..e88918bb 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 @@ -2,22 +2,19 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectScoreReplaceParamsTest { @Test - fun createProjectScoreReplaceParams() { + fun create() { ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categories( - ProjectScoreReplaceParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -25,19 +22,15 @@ class ProjectScoreReplaceParamsTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() @@ -47,16 +40,14 @@ class ProjectScoreReplaceParamsTest { } @Test - fun getBody() { + fun body() { val params = ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categories( - ProjectScoreReplaceParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -64,74 +55,64 @@ class ProjectScoreReplaceParamsTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type( - OnlineScoreConfig.Scorer.Function.Type.FUNCTION - ) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() ) .description("description") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) assertThat(body.categories()) - .isEqualTo( + .contains( ProjectScoreReplaceParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) ) assertThat(body.config()) - .isEqualTo( + .contains( ProjectScoreConfig.builder() .destination(ProjectScoreConfig.Destination.EXPECTED) .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() ) - assertThat(body.description()).isEqualTo("description") + assertThat(body.description()).contains("description") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectScoreReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt index 9237a10b..d5ba83a1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectScoreRetrieveParamsTest { @Test - fun createProjectScoreRetrieveParams() { + fun create() { ProjectScoreRetrieveParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() 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 4fd8e414..888ef861 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 @@ -17,10 +17,8 @@ class ProjectScoreTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScore.ScoreType.SLIDER) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categories( - ProjectScore.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -28,21 +26,15 @@ class ProjectScoreTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type( - OnlineScoreConfig.Scorer.Function.Type.FUNCTION - ) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() @@ -60,7 +52,7 @@ class ProjectScoreTest { assertThat(projectScore.categories()) .contains( ProjectScore.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) ) assertThat(projectScore.config()) @@ -70,19 +62,15 @@ class ProjectScoreTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() 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 64e20ccc..80265044 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 @@ -2,20 +2,17 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectScoreUpdateParamsTest { @Test - fun createProjectScoreUpdateParams() { + fun create() { ProjectScoreUpdateParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categories( - ProjectScoreUpdateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -23,19 +20,15 @@ class ProjectScoreUpdateParamsTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() @@ -47,14 +40,12 @@ class ProjectScoreUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = ProjectScoreUpdateParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categories( - ProjectScoreUpdateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -62,21 +53,15 @@ class ProjectScoreUpdateParamsTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type( - OnlineScoreConfig.Scorer.Function.Type.FUNCTION - ) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() @@ -85,50 +70,46 @@ class ProjectScoreUpdateParamsTest { .name("name") .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.categories()) - .isEqualTo( + .contains( ProjectScoreUpdateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) ) assertThat(body.config()) - .isEqualTo( + .contains( ProjectScoreConfig.builder() .destination(ProjectScoreConfig.Destination.EXPECTED) .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() ) - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") - assertThat(body.scoreType()).isEqualTo(ProjectScoreUpdateParams.ScoreType.SLIDER) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.scoreType()).contains(ProjectScoreUpdateParams.ScoreType.SLIDER) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectScoreUpdateParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt index 111ab845..0b059956 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectTagCreateParamsTest { @Test - fun createProjectTagCreateParams() { + fun create() { ProjectTagCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -19,7 +18,7 @@ class ProjectTagCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = ProjectTagCreateParams.builder() .name("name") @@ -27,22 +26,22 @@ class ProjectTagCreateParamsTest { .color("color") .description("description") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).isEqualTo("color") - assertThat(body.description()).isEqualTo("description") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectTagCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt index 12369e03..30ff07c4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectTagDeleteParamsTest { @Test - fun createProjectTagDeleteParams() { + fun create() { ProjectTagDeleteParams.builder() .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index 09aa0048..d007b0c8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -3,18 +3,17 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectTagListParamsTest { @Test - fun createProjectTagListParams() { + fun create() { ProjectTagListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -24,12 +23,12 @@ class ProjectTagListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ProjectTagListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -42,19 +41,19 @@ class ProjectTagListParamsTest { "ids", ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("project_name", "project_name") expected.put("project_tag_name", "project_tag_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ProjectTagListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt index bec95fa1..5ea11901 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectTagReplaceParamsTest { @Test - fun createProjectTagReplaceParams() { + fun create() { ProjectTagReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -19,7 +18,7 @@ class ProjectTagReplaceParamsTest { } @Test - fun getBody() { + fun body() { val params = ProjectTagReplaceParams.builder() .name("name") @@ -27,22 +26,22 @@ class ProjectTagReplaceParamsTest { .color("color") .description("description") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).isEqualTo("color") - assertThat(body.description()).isEqualTo("description") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectTagReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt index cd792595..a1d9d5ee 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectTagRetrieveParamsTest { @Test - fun createProjectTagRetrieveParams() { + fun create() { ProjectTagRetrieveParams.builder() .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt index 9b5ac6a1..259f1643 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectTagUpdateParamsTest { @Test - fun createProjectTagUpdateParams() { + fun create() { ProjectTagUpdateParams.builder() .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .color("color") @@ -19,7 +18,7 @@ class ProjectTagUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = ProjectTagUpdateParams.builder() .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -27,20 +26,20 @@ class ProjectTagUpdateParamsTest { .description("description") .name("name") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.color()).isEqualTo("color") - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectTagUpdateParams.builder() .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 9ea7f42d..69c200c0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ProjectUpdateParamsTest { @Test - fun createProjectUpdateParams() { + fun create() { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") @@ -18,25 +17,25 @@ class ProjectUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).contains("name") assertThat(body.settings()) - .isEqualTo(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index e7962b7d..55c872d4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -2,14 +2,14 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class PromptCreateParamsTest { @Test - fun createPromptCreateParams() { + fun create() { PromptCreateParams.builder() .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -22,53 +22,12 @@ class PromptCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -82,37 +41,35 @@ class PromptCreateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() } @Test - fun getBody() { + fun body() { val params = PromptCreateParams.builder() .name("x") @@ -126,55 +83,12 @@ class PromptCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -188,94 +102,51 @@ class PromptCreateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(PromptCreateParams.FunctionType.LLM) + assertThat(body.description()).contains("description") + assertThat(body.functionType()).contains(PromptCreateParams.FunctionType.LLM) assertThat(body.promptData()) - .isEqualTo( + .contains( PromptData.builder() .options( PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -289,43 +160,41 @@ class PromptCreateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - assertThat(body.tags()).isEqualTo(listOf("string")) + assertThat(body.tags()).contains(listOf("string")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = PromptCreateParams.builder() .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("x") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index 33c52da4..9bd6b0c7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,47 +16,12 @@ class PromptDataTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.ofAuto( - PromptOptions.Params.OpenAIModelParams.FunctionCall.Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.ofAuto( - PromptOptions.Params.OpenAIModelParams.ToolChoice.Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -69,28 +35,26 @@ class PromptDataTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() assertThat(promptData).isNotNull @@ -99,45 +63,12 @@ class PromptDataTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.ofAuto( - PromptOptions.Params.OpenAIModelParams.FunctionCall.Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.ofAuto( - PromptOptions.Params.OpenAIModelParams.ToolChoice.Auto.AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -153,7 +84,11 @@ class PromptDataTest { assertThat(promptData.parser()) .contains( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt index a819f9d2..ac1b91bb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class PromptDeleteParamsTest { @Test - fun createPromptDeleteParams() { + fun create() { PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index 81adc194..c740d3a6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -3,18 +3,17 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class PromptListParamsTest { @Test - fun createPromptListParams() { + fun create() { PromptListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -26,12 +25,12 @@ class PromptListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = PromptListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectName("project_name") @@ -46,7 +45,7 @@ class PromptListParamsTest { "ids", PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("project_name", "project_name") @@ -54,13 +53,13 @@ class PromptListParamsTest { expected.put("slug", "slug") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("version", "version") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = PromptListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt index 15042e53..a33f35c4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -13,41 +13,12 @@ class PromptOptionsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.ofAuto( - PromptOptions.Params.OpenAIModelParams.FunctionCall.Auto.AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.ofJsonObject( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.ofAuto( - PromptOptions.Params.OpenAIModelParams.ToolChoice.Auto.AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -55,38 +26,11 @@ class PromptOptionsTest { assertThat(promptOptions.model()).contains("model") assertThat(promptOptions.params()) .contains( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.ofAuto( - PromptOptions.Params.OpenAIModelParams.FunctionCall.Auto.AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.ofJsonObject( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.ofAuto( - PromptOptions.Params.OpenAIModelParams.ToolChoice.Auto.AUTO - ) - ) - .topP(42.23) + PromptOptions.Params.ofAnthropicModel( + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) .useCache(true) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 9aa91544..bf3ef884 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -2,14 +2,14 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class PromptReplaceParamsTest { @Test - fun createPromptReplaceParams() { + fun create() { PromptReplaceParams.builder() .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -22,53 +22,12 @@ class PromptReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -82,37 +41,35 @@ class PromptReplaceParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() } @Test - fun getBody() { + fun body() { val params = PromptReplaceParams.builder() .name("x") @@ -126,55 +83,12 @@ class PromptReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -188,94 +102,51 @@ class PromptReplaceParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(PromptReplaceParams.FunctionType.LLM) + assertThat(body.description()).contains("description") + assertThat(body.functionType()).contains(PromptReplaceParams.FunctionType.LLM) assertThat(body.promptData()) - .isEqualTo( + .contains( PromptData.builder() .options( PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -289,43 +160,41 @@ class PromptReplaceParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - assertThat(body.tags()).isEqualTo(listOf("string")) + assertThat(body.tags()).contains(listOf("string")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = PromptReplaceParams.builder() .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("x") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt index d8aa5099..622fb8c9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class PromptRetrieveParamsTest { @Test - fun createPromptRetrieveParams() { + fun create() { PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index d33be2b4..427df08d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -22,62 +23,23 @@ class PromptTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") .functionType(Prompt.FunctionType.LLM) - .metadata(Prompt.Metadata.builder().build()) + .metadata( + Prompt.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .promptData( PromptData.builder() .options( PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -91,32 +53,30 @@ class PromptTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() assertThat(prompt).isNotNull assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -129,7 +89,12 @@ class PromptTest { assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(prompt.description()).contains("description") assertThat(prompt.functionType()).contains(Prompt.FunctionType.LLM) - assertThat(prompt.metadata()).contains(Prompt.Metadata.builder().build()) + assertThat(prompt.metadata()) + .contains( + Prompt.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(prompt.promptData()) .contains( PromptData.builder() @@ -137,53 +102,12 @@ class PromptTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -197,28 +121,26 @@ class PromptTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index a9dbfada..f7181177 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -2,14 +2,14 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class PromptUpdateParamsTest { @Test - fun createPromptUpdateParams() { + fun create() { PromptUpdateParams.builder() .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") @@ -20,53 +20,12 @@ class PromptUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -80,38 +39,36 @@ class PromptUpdateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) .slug("slug") - .tags(listOf("string")) + .addTag("string") .build() } @Test - fun getBody() { + fun body() { val params = PromptUpdateParams.builder() .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -123,55 +80,12 @@ class PromptUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -185,92 +99,49 @@ class PromptUpdateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) .slug("slug") - .tags(listOf("string")) + .addTag("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") assertThat(body.promptData()) - .isEqualTo( + .contains( PromptData.builder() .options( PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -284,40 +155,38 @@ class PromptUpdateParamsTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - assertThat(body.slug()).isEqualTo("slug") - assertThat(body.tags()).isEqualTo(listOf("string")) + assertThat(body.slug()).contains("slug") + assertThat(body.tags()).contains(listOf("string")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } 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 ab989df1..6c366ac1 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 @@ -2,57 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class RoleCreateParamsTest { @Test - fun createRoleCreateParams() { + fun create() { RoleCreateParams.builder() .name("x") .description("description") - .memberPermissions( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) + .addMemberPermission( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() } @Test - fun getBody() { + fun body() { val params = RoleCreateParams.builder() .name("x") .description("description") - .memberPermissions( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) + .addMemberPermission( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).isEqualTo("description") + assertThat(body.description()).contains("description") assertThat(body.memberPermissions()) - .isEqualTo( + .contains( listOf( RoleCreateParams.MemberPermission.builder() .permission(RoleCreateParams.MemberPermission.Permission.CREATE) @@ -62,14 +57,14 @@ class RoleCreateParamsTest { .build() ) ) - assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = RoleCreateParams.builder().name("x").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt index df2e651a..3d7f97a5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class RoleDeleteParamsTest { @Test - fun createRoleDeleteParams() { + fun create() { RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 1080806c..1a8c09f7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -3,18 +3,17 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class RoleListParamsTest { @Test - fun createRoleListParams() { + fun create() { RoleListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .roleName("role_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -22,12 +21,12 @@ class RoleListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = RoleListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .roleName("role_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -38,17 +37,17 @@ class RoleListParamsTest { "ids", RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("role_name", "role_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = RoleListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.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 2609c52f..9b800fc5 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 @@ -2,57 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class RoleReplaceParamsTest { @Test - fun createRoleReplaceParams() { + fun create() { RoleReplaceParams.builder() .name("x") .description("description") - .memberPermissions( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) + .addMemberPermission( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() } @Test - fun getBody() { + fun body() { val params = RoleReplaceParams.builder() .name("x") .description("description") - .memberPermissions( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) + .addMemberPermission( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).isEqualTo("description") + assertThat(body.description()).contains("description") assertThat(body.memberPermissions()) - .isEqualTo( + .contains( listOf( RoleReplaceParams.MemberPermission.builder() .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) @@ -62,14 +57,14 @@ class RoleReplaceParamsTest { .build() ) ) - assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = RoleReplaceParams.builder().name("x").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt index d0791c4d..696fe39a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class RoleRetrieveParamsTest { @Test - fun createRoleRetrieveParams() { + fun create() { RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").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 c2325951..6187d100 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 @@ -17,17 +17,13 @@ class RoleTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") - .memberPermissions( - listOf( - Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType( - Role.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) + .addMemberPermission( + Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build() ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgId("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/RoleUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt index 081e5a52..338f33b0 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 @@ -2,78 +2,68 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class RoleUpdateParamsTest { @Test - fun createRoleUpdateParams() { + fun create() { RoleUpdateParams.builder() .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberPermissions( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) + .addAddMemberPermission( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .name("x") - .removeMemberPermissions( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) + .addRemoveMemberPermission( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getBody() { + fun body() { val params = RoleUpdateParams.builder() .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberPermissions( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) + .addAddMemberPermission( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .name("x") - .removeMemberPermissions( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) + .addRemoveMemberPermission( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.addMemberPermissions()) - .isEqualTo( + .contains( listOf( RoleUpdateParams.AddMemberPermission.builder() .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) @@ -83,11 +73,11 @@ class RoleUpdateParamsTest { .build() ) ) - assertThat(body.addMemberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("x") + assertThat(body.addMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("x") assertThat(body.removeMemberPermissions()) - .isEqualTo( + .contains( listOf( RoleUpdateParams.RemoveMemberPermission.builder() .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) @@ -98,14 +88,14 @@ class RoleUpdateParamsTest { ) ) assertThat(body.removeMemberRoles()) - .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt index 8081fbbc..35c169e5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt @@ -11,17 +11,17 @@ class ScoreSummaryTest { fun createScoreSummary() { val scoreSummary = ScoreSummary.builder() - .improvements(123L) + .improvements(0L) .name("name") - .regressions(123L) - .score(1.0) - .diff(1.0) + .regressions(0L) + .score(0.0) + .diff(-1.0) .build() assertThat(scoreSummary).isNotNull - assertThat(scoreSummary.improvements()).isEqualTo(123L) + assertThat(scoreSummary.improvements()).isEqualTo(0L) assertThat(scoreSummary.name()).isEqualTo("name") - assertThat(scoreSummary.regressions()).isEqualTo(123L) - assertThat(scoreSummary.score()).isEqualTo(1.0) - assertThat(scoreSummary.diff()).contains(1.0) + assertThat(scoreSummary.regressions()).isEqualTo(0L) + assertThat(scoreSummary.score()).isEqualTo(0.0) + assertThat(scoreSummary.diff()).contains(-1.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt index 67738f2e..7016af4b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class SpanIframeCreateParamsTest { @Test - fun createSpanIframeCreateParams() { + fun create() { SpanIframeCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -20,7 +19,7 @@ class SpanIframeCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = SpanIframeCreateParams.builder() .name("name") @@ -29,24 +28,24 @@ class SpanIframeCreateParamsTest { .description("description") .postMessage(true) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.url()).isEqualTo("url") - assertThat(body.description()).isEqualTo("description") - assertThat(body.postMessage()).isEqualTo(true) + assertThat(body.description()).contains("description") + assertThat(body.postMessage()).contains(true) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SpanIframeCreateParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .url("url") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt index 16288ccf..a1a4a437 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class SpanIframeDeleteParamsTest { @Test - fun createSpanIframeDeleteParams() { + fun create() { SpanIframeDeleteParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt index 0b86e244..cf530193 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt @@ -3,18 +3,17 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class SpanIframeListParamsTest { @Test - fun createSpanIframeListParams() { + fun create() { SpanIframeListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .spanIframeName("span_iframe_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -22,12 +21,12 @@ class SpanIframeListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = SpanIframeListParams.builder() .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .spanIframeName("span_iframe_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -38,17 +37,17 @@ class SpanIframeListParamsTest { "ids", SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("span_iframe_name", "span_iframe_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = SpanIframeListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt index a6700e57..efdaaa4d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class SpanIframeReplaceParamsTest { @Test - fun createSpanIframeReplaceParams() { + fun create() { SpanIframeReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -20,7 +19,7 @@ class SpanIframeReplaceParamsTest { } @Test - fun getBody() { + fun body() { val params = SpanIframeReplaceParams.builder() .name("name") @@ -29,24 +28,24 @@ class SpanIframeReplaceParamsTest { .description("description") .postMessage(true) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.url()).isEqualTo("url") - assertThat(body.description()).isEqualTo("description") - assertThat(body.postMessage()).isEqualTo(true) + assertThat(body.description()).contains("description") + assertThat(body.postMessage()).contains(true) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SpanIframeReplaceParams.builder() .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .url("url") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt index 6624ae3b..ad6927a4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class SpanIframeRetrieveParamsTest { @Test - fun createSpanIframeRetrieveParams() { + fun create() { SpanIframeRetrieveParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index d1d84057..4910bc50 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class SpanIframeUpdateParamsTest { @Test - fun createSpanIframeUpdateParams() { + fun create() { SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") @@ -19,7 +18,7 @@ class SpanIframeUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -27,20 +26,20 @@ class SpanIframeUpdateParamsTest { .postMessage(true) .url("url") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.postMessage()).isEqualTo(true) - assertThat(body.url()).isEqualTo("url") + assertThat(body.name()).contains("name") + assertThat(body.postMessage()).contains(true) + assertThat(body.url()).contains("url") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt index ab202a17..a9675505 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt @@ -15,7 +15,7 @@ class SummarizeDatasetResponseTest { .datasetUrl("https://example.com") .projectName("project_name") .projectUrl("https://example.com") - .dataSummary(DataSummary.builder().totalRecords(123L).build()) + .dataSummary(DataSummary.builder().totalRecords(0L).build()) .build() assertThat(summarizeDatasetResponse).isNotNull assertThat(summarizeDatasetResponse.datasetName()).isEqualTo("dataset_name") @@ -23,6 +23,6 @@ class SummarizeDatasetResponseTest { assertThat(summarizeDatasetResponse.projectName()).isEqualTo("project_name") assertThat(summarizeDatasetResponse.projectUrl()).isEqualTo("https://example.com") assertThat(summarizeDatasetResponse.dataSummary()) - .contains(DataSummary.builder().totalRecords(123L).build()) + .contains(DataSummary.builder().totalRecords(0L).build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt index 75a79570..eec695dc 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -16,8 +17,39 @@ class SummarizeExperimentResponseTest { .projectName("project_name") .projectUrl("https://example.com") .comparisonExperimentName("comparison_experiment_name") - .metrics(SummarizeExperimentResponse.Metrics.builder().build()) - .scores(SummarizeExperimentResponse.Scores.builder().build()) + .metrics( + SummarizeExperimentResponse.Metrics.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improvements" to 0, + "metric" to 0, + "name" to "name", + "regressions" to 0, + "unit" to "unit", + "diff" to 0, + ) + ) + ) + .build() + ) + .scores( + SummarizeExperimentResponse.Scores.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improvements" to 0, + "name" to "name", + "regressions" to 0, + "score" to 0, + "diff" to -1, + ) + ) + ) + .build() + ) .build() assertThat(summarizeExperimentResponse).isNotNull assertThat(summarizeExperimentResponse.experimentName()).isEqualTo("experiment_name") @@ -27,8 +59,39 @@ class SummarizeExperimentResponseTest { assertThat(summarizeExperimentResponse.comparisonExperimentName()) .contains("comparison_experiment_name") assertThat(summarizeExperimentResponse.metrics()) - .contains(SummarizeExperimentResponse.Metrics.builder().build()) + .contains( + SummarizeExperimentResponse.Metrics.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improvements" to 0, + "metric" to 0, + "name" to "name", + "regressions" to 0, + "unit" to "unit", + "diff" to 0, + ) + ) + ) + .build() + ) assertThat(summarizeExperimentResponse.scores()) - .contains(SummarizeExperimentResponse.Scores.builder().build()) + .contains( + SummarizeExperimentResponse.Scores.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improvements" to 0, + "name" to "name", + "regressions" to 0, + "score" to 0, + "diff" to -1, + ) + ) + ) + .build() + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt index b059ced3..56273dcf 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt @@ -2,13 +2,12 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.junit.jupiter.api.Test class TopLevelHelloWorldParamsTest { @Test - fun createTopLevelHelloWorldParams() { + fun create() { TopLevelHelloWorldParams.builder().build() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index fa8ed3a0..815ec2d7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -3,36 +3,35 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class UserListParamsTest { @Test - fun createUserListParams() { + fun create() { UserListParams.builder() - .email(UserListParams.Email.ofString("string")) + .email("string") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName(UserListParams.FamilyName.ofString("string")) - .givenName(UserListParams.GivenName.ofString("string")) - .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .familyName("string") + .givenName("string") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = UserListParams.builder() - .email(UserListParams.Email.ofString("string")) + .email("string") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName(UserListParams.FamilyName.ofString("string")) - .givenName(UserListParams.GivenName.ofString("string")) - .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .familyName("string") + .givenName("string") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() @@ -45,16 +44,16 @@ class UserListParamsTest { "ids", UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + expected.put("limit", "0") expected.put("org_name", "org_name") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = UserListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt index ee03a0d3..f1686cc4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class UserRetrieveParamsTest { @Test - fun createUserRetrieveParams() { + fun create() { UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } 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 931b25d4..c6e16619 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 @@ -2,8 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,7 +10,7 @@ import org.junit.jupiter.api.Test class ViewCreateParamsTest { @Test - fun createViewCreateParams() { + fun create() { ViewCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -20,9 +19,17 @@ class ViewCreateParamsTest { .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -30,10 +37,10 @@ class ViewCreateParamsTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -42,7 +49,7 @@ class ViewCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = ViewCreateParams.builder() .name("name") @@ -52,9 +59,17 @@ class ViewCreateParamsTest { .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -62,40 +77,48 @@ class ViewCreateParamsTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) - assertThat(body.viewType()).isEqualTo(ViewCreateParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(body.options()) - .isEqualTo( + .contains( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.viewData()) - .isEqualTo( + .contains( ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -103,17 +126,19 @@ class ViewCreateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ViewCreateParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt index beb70915..7d1baa55 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -12,15 +12,18 @@ class ViewDataSearchTest { fun createViewDataSearch() { val viewDataSearch = ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() assertThat(viewDataSearch).isNotNull - assertThat(viewDataSearch.filter().get()).containsExactly(JsonNull.of()) - assertThat(viewDataSearch.match().get()).containsExactly(JsonNull.of()) - assertThat(viewDataSearch.sort().get()).containsExactly(JsonNull.of()) - assertThat(viewDataSearch.tag().get()).containsExactly(JsonNull.of()) + assertThat(viewDataSearch.filter().get()) + .containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.match().get()) + .containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.sort().get()) + .containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.tag().get()).containsExactly(JsonValue.from(mapOf())) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt index ba16adf2..10157eee 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,10 +14,10 @@ class ViewDataTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -25,10 +25,10 @@ class ViewDataTest { assertThat(viewData.search()) .contains( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) } 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 76883050..66bfa167 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 @@ -2,14 +2,13 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ViewDeleteParamsTest { @Test - fun createViewDeleteParams() { + fun create() { ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -18,28 +17,28 @@ class ViewDeleteParamsTest { } @Test - fun getBody() { + fun body() { val params = ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ViewDeleteParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) 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 ece2791b..4a5f2d9e 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 @@ -3,20 +3,19 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ViewListParamsTest { @Test - fun createViewListParams() { + fun create() { ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewListParams.ObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .viewName("view_name") .viewType(ViewListParams.ViewType.PROJECTS) @@ -24,14 +23,14 @@ class ViewListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewListParams.ObjectType.ORGANIZATION) .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .viewName("view_name") .viewType(ViewListParams.ViewType.PROJECTS) @@ -44,15 +43,15 @@ class ViewListParamsTest { "ids", ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() ) - expected.put("limit", "123") + 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()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -61,6 +60,6 @@ class ViewListParamsTest { val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt index 7aea4ce7..3d6989ba 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,14 +12,31 @@ class ViewOptionsTest { fun createViewOptions() { val viewOptions = ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() assertThat(viewOptions).isNotNull assertThat(viewOptions.columnOrder().get()).containsExactly("string") - assertThat(viewOptions.columnSizing()).contains(ViewOptions.ColumnSizing.builder().build()) + assertThat(viewOptions.columnSizing()) + .contains( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(viewOptions.columnVisibility()) - .contains(ViewOptions.ColumnVisibility.builder().build()) + .contains( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .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 6162d192..1355462b 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 @@ -2,8 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -11,7 +10,7 @@ import org.junit.jupiter.api.Test class ViewReplaceParamsTest { @Test - fun createViewReplaceParams() { + fun create() { ViewReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -20,9 +19,17 @@ class ViewReplaceParamsTest { .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -30,10 +37,10 @@ class ViewReplaceParamsTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -42,7 +49,7 @@ class ViewReplaceParamsTest { } @Test - fun getBody() { + fun body() { val params = ViewReplaceParams.builder() .name("name") @@ -52,9 +59,17 @@ class ViewReplaceParamsTest { .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -62,40 +77,48 @@ class ViewReplaceParamsTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.viewType()).isEqualTo(ViewReplaceParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(body.options()) - .isEqualTo( + .contains( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.viewData()) - .isEqualTo( + .contains( ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -103,17 +126,19 @@ class ViewReplaceParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ViewReplaceParams.builder() .name("name") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.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 de373498..31fdf385 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 @@ -3,14 +3,13 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.http.QueryParams -import com.braintrustdata.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ViewRetrieveParamsTest { @Test - fun createViewRetrieveParams() { + fun create() { ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -19,7 +18,7 @@ class ViewRetrieveParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -29,11 +28,11 @@ class ViewRetrieveParamsTest { val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ViewRetrieveParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -43,7 +42,7 @@ class ViewRetrieveParamsTest { val expected = QueryParams.builder() expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test 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 ce897144..fd19dbb6 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 @@ -2,7 +2,7 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -22,9 +22,17 @@ class ViewTest { .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -32,10 +40,10 @@ class ViewTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -52,9 +60,17 @@ class ViewTest { assertThat(view.options()) .contains( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -63,10 +79,10 @@ class ViewTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() 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 bfed15c2..eb609330 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 @@ -2,15 +2,14 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test class ViewUpdateParamsTest { @Test - fun createViewUpdateParams() { + fun create() { ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -18,9 +17,17 @@ class ViewUpdateParamsTest { .name("name") .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -28,10 +35,10 @@ class ViewUpdateParamsTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -41,7 +48,7 @@ class ViewUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -50,9 +57,17 @@ class ViewUpdateParamsTest { .name("name") .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -60,55 +75,63 @@ class ViewUpdateParamsTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() ) .viewType(ViewUpdateParams.ViewType.PROJECTS) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) - assertThat(body.name()).isEqualTo("name") + assertThat(body.name()).contains("name") assertThat(body.options()) - .isEqualTo( + .contains( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.viewData()) - .isEqualTo( + .contains( ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() ) - assertThat(body.viewType()).isEqualTo(ViewUpdateParams.ViewType.PROJECTS) + assertThat(body.viewType()).contains(ViewUpdateParams.ViewType.PROJECTS) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ViewUpdateParams.builder() .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 313eef1e..fce7d036 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.services import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.jsonMapper import com.braintrustdata.api.errors.BadRequestException @@ -17,13 +17,13 @@ import com.braintrustdata.api.errors.RateLimitException import com.braintrustdata.api.errors.UnauthorizedException import com.braintrustdata.api.errors.UnexpectedStatusCodeException import com.braintrustdata.api.errors.UnprocessableEntityException -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.Project +import com.braintrustdata.api.models.ProjectCreateParams +import com.braintrustdata.api.models.ProjectSettings import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl -import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post -import com.github.tomakehurst.wiremock.client.WireMock.put import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo @@ -41,7 +41,7 @@ class ErrorHandlingTest { private val JSON_MAPPER: JsonMapper = jsonMapper() private val BRAINTRUST_ERROR: BraintrustError = - BraintrustError.builder().putAdditionalProperty("key", JsonString.of("value")).build() + BraintrustError.builder().putAdditionalProperty("key", JsonValue.from("value")).build() private lateinit var client: BraintrustClient diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt index d353dd1f..acd72ac7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt @@ -4,19 +4,18 @@ package com.braintrustdata.api.services import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.jsonMapper -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.Project +import com.braintrustdata.api.models.ProjectCreateParams +import com.braintrustdata.api.models.ProjectSettings import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo -import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor -import com.github.tomakehurst.wiremock.client.WireMock.put import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo @@ -53,7 +52,7 @@ class ServiceParamsTest { val additionalBodyProperties = mutableMapOf() - additionalBodyProperties.put("testBodyProperty", JsonString.of("ghi890")) + additionalBodyProperties.put("testBodyProperty", JsonValue.from("ghi890")) val params = ProjectCreateParams.builder() 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 20c3d3f6..3248c0c1 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 @@ -4,8 +4,12 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.AclBatchUpdateParams +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.AclRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -98,35 +102,31 @@ class AclServiceTest { val aclBatchUpdateResponse = aclService.batchUpdate( AclBatchUpdateParams.builder() - .addAcls( - listOf( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() ) - .removeAcls( - listOf( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt index 2eb15e81..74538436 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt @@ -4,8 +4,14 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.AiSecretCreateParams +import com.braintrustdata.api.models.AiSecretDeleteParams +import com.braintrustdata.api.models.AiSecretFindAndDeleteParams import com.braintrustdata.api.models.AiSecretListParams +import com.braintrustdata.api.models.AiSecretReplaceParams +import com.braintrustdata.api.models.AiSecretRetrieveParams +import com.braintrustdata.api.models.AiSecretUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -24,7 +30,11 @@ class AiSecretServiceTest { aiSecretService.create( AiSecretCreateParams.builder() .name("name") - .metadata(AiSecretCreateParams.Metadata.builder().build()) + .metadata( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .orgName("org_name") .secret("secret") .type("type") @@ -64,7 +74,11 @@ class AiSecretServiceTest { aiSecretService.update( AiSecretUpdateParams.builder() .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(AiSecretUpdateParams.Metadata.builder().build()) + .metadata( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .secret("secret") .type("type") @@ -133,7 +147,11 @@ class AiSecretServiceTest { aiSecretService.replace( AiSecretReplaceParams.builder() .name("name") - .metadata(AiSecretReplaceParams.Metadata.builder().build()) + .metadata( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .orgName("org_name") .secret("secret") .type("type") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index bef46629..1beb9ba3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -4,8 +4,10 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ApiKeyCreateParams +import com.braintrustdata.api.models.ApiKeyDeleteParams import com.braintrustdata.api.models.ApiKeyListParams +import com.braintrustdata.api.models.ApiKeyRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index 774cd505..d239ec07 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -4,9 +4,19 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.DatasetCreateParams +import com.braintrustdata.api.models.DatasetDeleteParams +import com.braintrustdata.api.models.DatasetFeedbackParams +import com.braintrustdata.api.models.DatasetFetchParams +import com.braintrustdata.api.models.DatasetFetchPostParams +import com.braintrustdata.api.models.DatasetInsertParams import com.braintrustdata.api.models.DatasetListParams +import com.braintrustdata.api.models.DatasetRetrieveParams +import com.braintrustdata.api.models.DatasetSummarizeParams +import com.braintrustdata.api.models.DatasetUpdateParams +import com.braintrustdata.api.models.FeedbackDatasetItem +import com.braintrustdata.api.models.InsertDatasetEvent import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -28,7 +38,11 @@ class DatasetServiceTest { .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .metadata(DatasetCreateParams.Metadata.builder().build()) + .metadata( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) println(dataset) @@ -66,7 +80,11 @@ class DatasetServiceTest { DatasetUpdateParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") - .metadata(DatasetUpdateParams.Metadata.builder().build()) + .metadata( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .build() ) @@ -117,16 +135,18 @@ class DatasetServiceTest { datasetService.feedback( DatasetFeedbackParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() ) .build() ) @@ -146,7 +166,7 @@ class DatasetServiceTest { datasetService.fetch( DatasetFetchParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -169,7 +189,7 @@ class DatasetServiceTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -191,24 +211,26 @@ class DatasetServiceTest { datasetService.insert( DatasetInsertParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertDatasetEvent.Metadata.builder().build()) - .rootSpanId("root_span_id") - .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) + .addEvent( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() ) .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 81350114..8d435c90 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 @@ -4,7 +4,12 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.EnvVarCreateParams +import com.braintrustdata.api.models.EnvVarDeleteParams +import com.braintrustdata.api.models.EnvVarListParams +import com.braintrustdata.api.models.EnvVarReplaceParams +import com.braintrustdata.api.models.EnvVarRetrieveParams +import com.braintrustdata.api.models.EnvVarUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -82,7 +87,8 @@ class EnvVarServiceTest { envVarService.list( EnvVarListParams.builder() .envVarName("env_var_name") - .limit(123L) + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarListParams.ObjectType.ORGANIZATION) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index 05975beb..0b5e8eae 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -4,7 +4,9 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.EvalCreateParams +import com.braintrustdata.api.models.RepoInfo import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,31 +24,19 @@ class EvalServiceTest { val summarizeExperimentResponse = evalService.create( EvalCreateParams.builder() - .data( - EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder() - .datasetId("dataset_id") - .build() - ) - ) + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) .projectId("project_id") - .scores( - listOf( - EvalCreateParams.Score.ofFunctionId( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - ) + .addScore( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() ) .task( - EvalCreateParams.Task.ofFunctionId( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() ) .baseExperimentId("base_experiment_id") .baseExperimentName("base_experiment_name") @@ -54,12 +44,16 @@ class EvalServiceTest { .gitMetadataSettings( EvalCreateParams.GitMetadataSettings.builder() .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .fields(listOf(EvalCreateParams.GitMetadataSettings.Field.COMMIT)) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) .build() ) .isPublic(true) - .maxConcurrency(42.23) - .metadata(EvalCreateParams.Metadata.builder().build()) + .maxConcurrency(0.0) + .metadata( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") @@ -74,8 +68,8 @@ class EvalServiceTest { .build() ) .stream(true) - .timeout(42.23) - .trialCount(42.23) + .timeout(0.0) + .trialCount(0.0) .build() ) println(summarizeExperimentResponse) 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 a80a6a14..ff81c512 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 @@ -4,9 +4,21 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ExperimentCreateParams +import com.braintrustdata.api.models.ExperimentDeleteParams +import com.braintrustdata.api.models.ExperimentFeedbackParams +import com.braintrustdata.api.models.ExperimentFetchParams +import com.braintrustdata.api.models.ExperimentFetchPostParams +import com.braintrustdata.api.models.ExperimentInsertParams import com.braintrustdata.api.models.ExperimentListParams +import com.braintrustdata.api.models.ExperimentRetrieveParams +import com.braintrustdata.api.models.ExperimentSummarizeParams +import com.braintrustdata.api.models.ExperimentUpdateParams +import com.braintrustdata.api.models.FeedbackExperimentItem +import com.braintrustdata.api.models.InsertExperimentEvent +import com.braintrustdata.api.models.RepoInfo +import com.braintrustdata.api.models.SpanAttributes import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -31,7 +43,11 @@ class ExperimentServiceTest { .datasetVersion("dataset_version") .description("description") .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder().build()) + .metadata( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("x") .public_(true) .repoInfo( @@ -87,7 +103,11 @@ class ExperimentServiceTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .datasetVersion("dataset_version") .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder().build()) + .metadata( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .name("name") .public_(true) .repoInfo( @@ -152,18 +172,24 @@ class ExperimentServiceTest { experimentService.feedback( ExperimentFeedbackParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() ) .build() ) @@ -183,7 +209,7 @@ class ExperimentServiceTest { experimentService.fetch( ExperimentFetchParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -206,7 +232,7 @@ class ExperimentServiceTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -228,53 +254,59 @@ class ExperimentServiceTest { experimentService.insert( ExperimentInsertParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertExperimentEvent.Metadata.builder().build()) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder().build()) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) + .addEvent( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() ) .build() ) 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 e2606aa4..3aee103d 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 @@ -4,9 +4,16 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FunctionCreateParams +import com.braintrustdata.api.models.FunctionDeleteParams +import com.braintrustdata.api.models.FunctionInvokeParams import com.braintrustdata.api.models.FunctionListParams +import com.braintrustdata.api.models.FunctionReplaceParams +import com.braintrustdata.api.models.FunctionRetrieveParams +import com.braintrustdata.api.models.FunctionUpdateParams +import com.braintrustdata.api.models.PromptData +import com.braintrustdata.api.models.PromptOptions import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,11 +32,9 @@ class FunctionServiceTest { functionService.create( FunctionCreateParams.builder() .functionData( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -37,8 +42,8 @@ class FunctionServiceTest { .description("description") .functionSchema( FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) .functionType(FunctionCreateParams.FunctionType.LLM) @@ -55,57 +60,12 @@ class FunctionServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -119,32 +79,30 @@ class FunctionServiceTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() ) println(function) @@ -183,11 +141,9 @@ class FunctionServiceTest { .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .functionData( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("name") .promptData( @@ -196,57 +152,12 @@ class FunctionServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -260,32 +171,30 @@ class FunctionServiceTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() ) println(function) @@ -335,41 +244,35 @@ class FunctionServiceTest { functionService.invoke( FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonNull.of()) - .messages( - listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - ) + .input(JsonValue.from(mapOf())) + .addMessage( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( - FunctionInvokeParams.Parent.ofSpanParentStruct( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType - .PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent - .builder() - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) + FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() ) .stream(true) .version("version") @@ -390,11 +293,9 @@ class FunctionServiceTest { functionService.replace( FunctionReplaceParams.builder() .functionData( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() ) .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -402,8 +303,8 @@ class FunctionServiceTest { .description("description") .functionSchema( FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonNull.of()) - .returns(JsonNull.of()) + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) .build() ) .functionType(FunctionReplaceParams.FunctionType.LLM) @@ -420,57 +321,12 @@ class FunctionServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -484,32 +340,30 @@ class FunctionServiceTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() ) println(function) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index 5f1645db..b805c59d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -4,8 +4,12 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.GroupCreateParams +import com.braintrustdata.api.models.GroupDeleteParams import com.braintrustdata.api.models.GroupListParams +import com.braintrustdata.api.models.GroupReplaceParams +import com.braintrustdata.api.models.GroupRetrieveParams +import com.braintrustdata.api.models.GroupUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,8 +29,8 @@ class GroupServiceTest { GroupCreateParams.builder() .name("x") .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() ) @@ -64,12 +68,12 @@ class GroupServiceTest { groupService.update( GroupUpdateParams.builder() .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .name("x") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) println(group) @@ -118,8 +122,8 @@ class GroupServiceTest { GroupReplaceParams.builder() .name("x") .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt index 17bcb9d2..90284cdd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt @@ -4,8 +4,10 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListParams +import com.braintrustdata.api.models.OrganizationRetrieveParams +import com.braintrustdata.api.models.OrganizationUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith 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 43cccc02..7eb898e2 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 @@ -4,8 +4,15 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OnlineScoreConfig +import com.braintrustdata.api.models.ProjectScoreCategory +import com.braintrustdata.api.models.ProjectScoreConfig +import com.braintrustdata.api.models.ProjectScoreCreateParams +import com.braintrustdata.api.models.ProjectScoreDeleteParams import com.braintrustdata.api.models.ProjectScoreListParams +import com.braintrustdata.api.models.ProjectScoreReplaceParams +import com.braintrustdata.api.models.ProjectScoreRetrieveParams +import com.braintrustdata.api.models.ProjectScoreUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,10 +33,8 @@ class ProjectScoreServiceTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categories( - ProjectScoreCreateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -37,22 +42,15 @@ class ProjectScoreServiceTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type( - OnlineScoreConfig.Scorer.Function.Type - .FUNCTION - ) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() @@ -94,10 +92,8 @@ class ProjectScoreServiceTest { projectScoreService.update( ProjectScoreUpdateParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categories( - ProjectScoreUpdateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -105,22 +101,15 @@ class ProjectScoreServiceTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type( - OnlineScoreConfig.Scorer.Function.Type - .FUNCTION - ) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() @@ -179,10 +168,8 @@ class ProjectScoreServiceTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categories( - ProjectScoreReplaceParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) ) .config( ProjectScoreConfig.builder() @@ -190,22 +177,15 @@ class ProjectScoreServiceTest { .multiSelect(true) .online( OnlineScoreConfig.builder() - .samplingRate(1.0) - .scorers( - listOf( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type( - OnlineScoreConfig.Scorer.Function.Type - .FUNCTION - ) - .build() - ) - ) + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() ) .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) + .addApplyToSpanName("string") .build() ) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 77a28f8e..dd8ab204 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -4,8 +4,12 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectCreateParams +import com.braintrustdata.api.models.ProjectDeleteParams import com.braintrustdata.api.models.ProjectListParams +import com.braintrustdata.api.models.ProjectRetrieveParams +import com.braintrustdata.api.models.ProjectSettings +import com.braintrustdata.api.models.ProjectUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt index bffa8967..5bd1c595 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -4,8 +4,12 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectTagCreateParams +import com.braintrustdata.api.models.ProjectTagDeleteParams import com.braintrustdata.api.models.ProjectTagListParams +import com.braintrustdata.api.models.ProjectTagReplaceParams +import com.braintrustdata.api.models.ProjectTagRetrieveParams +import com.braintrustdata.api.models.ProjectTagUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 4d53e986..818b6df1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -4,8 +4,15 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.PromptCreateParams +import com.braintrustdata.api.models.PromptData +import com.braintrustdata.api.models.PromptDeleteParams import com.braintrustdata.api.models.PromptListParams +import com.braintrustdata.api.models.PromptOptions +import com.braintrustdata.api.models.PromptReplaceParams +import com.braintrustdata.api.models.PromptRetrieveParams +import com.braintrustdata.api.models.PromptUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -34,57 +41,12 @@ class PromptServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -98,32 +60,30 @@ class PromptServiceTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() ) println(prompt) @@ -168,57 +128,12 @@ class PromptServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -232,33 +147,31 @@ class PromptServiceTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) .slug("slug") - .tags(listOf("string")) + .addTag("string") .build() ) println(prompt) @@ -318,57 +231,12 @@ class PromptServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.ofOpenAIModelParams( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .ofJsonObject( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params - .OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptOptions.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) + PromptOptions.Params.AnthropicModelParams.builder() + .maxTokens(0.0) + .temperature(0.0) + .topP(0.0) + .useCache(true) + .build() ) .position("position") .build() @@ -382,32 +250,30 @@ class PromptServiceTest { ) .parser( PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .type(PromptData.Parser.Type.LLM_CLASSIFIER) .useCot(true) .build() ) .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() ) - .toolFunctions( - listOf( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() ) .build() ) - .tags(listOf("string")) + .addTag("string") .build() ) println(prompt) 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 3478e6f4..bd9e856f 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,8 +4,12 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.RoleCreateParams +import com.braintrustdata.api.models.RoleDeleteParams import com.braintrustdata.api.models.RoleListParams +import com.braintrustdata.api.models.RoleReplaceParams +import com.braintrustdata.api.models.RoleRetrieveParams +import com.braintrustdata.api.models.RoleUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,18 +29,15 @@ class RoleServiceTest { RoleCreateParams.builder() .name("x") .description("description") - .memberPermissions( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) + .addMemberPermission( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() ) @@ -72,34 +73,27 @@ class RoleServiceTest { roleService.update( RoleUpdateParams.builder() .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberPermissions( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) + .addAddMemberPermission( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("description") .name("x") - .removeMemberPermissions( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission( - RoleUpdateParams.RemoveMemberPermission.Permission.CREATE - ) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) + .addRemoveMemberPermission( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() ) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) println(role) @@ -148,18 +142,15 @@ class RoleServiceTest { RoleReplaceParams.builder() .name("x") .description("description") - .memberPermissions( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) + .addMemberPermission( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index a08406db..9e914d1c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -4,8 +4,12 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.SpanIframeCreateParams +import com.braintrustdata.api.models.SpanIframeDeleteParams import com.braintrustdata.api.models.SpanIframeListParams +import com.braintrustdata.api.models.SpanIframeReplaceParams +import com.braintrustdata.api.models.SpanIframeRetrieveParams +import com.braintrustdata.api.models.SpanIframeUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt index ab277bdc..a8ae19a3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.TopLevelHelloWorldParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index 24f732e2..31fcd52f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -4,8 +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.* import com.braintrustdata.api.models.UserListParams +import com.braintrustdata.api.models.UserRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith 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 5eefd68b..d30bfc13 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 @@ -4,9 +4,16 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ViewCreateParams +import com.braintrustdata.api.models.ViewData +import com.braintrustdata.api.models.ViewDataSearch +import com.braintrustdata.api.models.ViewDeleteParams import com.braintrustdata.api.models.ViewListParams +import com.braintrustdata.api.models.ViewOptions +import com.braintrustdata.api.models.ViewReplaceParams +import com.braintrustdata.api.models.ViewRetrieveParams +import com.braintrustdata.api.models.ViewUpdateParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -32,9 +39,17 @@ class ViewServiceTest { .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -42,10 +57,10 @@ class ViewServiceTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -93,9 +108,17 @@ class ViewServiceTest { .name("name") .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -103,10 +126,10 @@ class ViewServiceTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() @@ -175,9 +198,17 @@ class ViewServiceTest { .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .options( ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -185,10 +216,10 @@ class ViewServiceTest { ViewData.builder() .search( ViewDataSearch.builder() - .filter(listOf(JsonNull.of())) - .match(listOf(JsonNull.of())) - .sort(listOf(JsonNull.of())) - .tag(listOf(JsonNull.of())) + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) .build() ) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt index 6f12d171..9967915e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.services.blocking.organizations import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrganizationMemberUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -24,12 +24,12 @@ class MemberServiceTest { OrganizationMemberUpdateParams.builder() .inviteUsers( OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) + .addEmail("string") .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .groupName("group_name") - .groupNames(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .sendInviteEmails(true) .build() ) @@ -37,8 +37,8 @@ class MemberServiceTest { .orgName("org_name") .removeUsers( OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) .build() 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 1ae8216b..0c88b1e1 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 @@ -4,8 +4,14 @@ package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonNull -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FeedbackProjectLogsItem +import com.braintrustdata.api.models.InsertProjectLogsEvent +import com.braintrustdata.api.models.ProjectLogFeedbackParams +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 java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,18 +31,24 @@ class LogServiceTest { logService.feedback( ProjectLogFeedbackParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonNull.of()) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .tags(listOf("string")) - .build() - ) + .addFeedback( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() ) .build() ) @@ -56,7 +68,7 @@ class LogServiceTest { logService.fetch( ProjectLogFetchParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -79,7 +91,7 @@ class LogServiceTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cursor("cursor") - .limit(123L) + .limit(0L) .maxRootSpanId("max_root_span_id") .maxXactId("max_xact_id") .version("version") @@ -101,52 +113,58 @@ class LogServiceTest { logService.insert( ProjectLogInsertParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonNull.of()) - .expected(JsonNull.of()) - .input(JsonNull.of()) - .metadata(InsertProjectLogsEvent.Metadata.builder().build()) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonNull.of()) - .callerFunctionname(JsonNull.of()) - .callerLineno(JsonNull.of()) - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonNull.of()) - .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder().build()) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) + .addEvent( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() ) .build() ) diff --git a/braintrust-java-example/build.gradle.kts b/braintrust-java-example/build.gradle.kts new file mode 100644 index 00000000..c64a1556 --- /dev/null +++ b/braintrust-java-example/build.gradle.kts @@ -0,0 +1,18 @@ +plugins { + id("braintrust.kotlin") + id("java") + application +} + +dependencies { + implementation(project(":braintrust-java")) +} + +tasks.withType().configureEach { + // Allow using more modern APIs, like `List.of` and `Map.of`, in examples. + options.release.set(9) +} + +application { + mainClass = "com.braintrustdata.api.example.Main" +} diff --git a/build.gradle.kts b/build.gradle.kts index d33feea6..3fc50216 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,4 @@ -plugins { - -} - allprojects { group = "com.braintrustdata.api" version = "0.7.0" // x-release-please-version } - - diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 493cb327..8a1d7a10 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `kotlin-dsl` - kotlin("jvm") version "1.9.22" + kotlin("jvm") version "2.1.0" id("com.vanniktech.maven.publish") version "0.28.0" } diff --git a/buildSrc/src/main/kotlin/braintrust.java.gradle.kts b/buildSrc/src/main/kotlin/braintrust.java.gradle.kts index 32a150ed..a2c35b93 100755 --- a/buildSrc/src/main/kotlin/braintrust.java.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.java.gradle.kts @@ -1,9 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar -import com.vanniktech.maven.publish.MavenPublishBaseExtension -import com.vanniktech.maven.publish.SonatypeHost plugins { `java-library` diff --git a/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts b/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts index 21c44eda..5d605cc4 100755 --- a/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts @@ -1,6 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import com.vanniktech.maven.publish.* plugins { id("braintrust.java") @@ -22,8 +21,12 @@ configure { tasks.withType().configureEach { kotlinOptions { - allWarningsAsErrors = true - freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=1.8") + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + "-Xsuppress-warning=DEPRECATION" + ) jvmTarget = "1.8" } } diff --git a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts index cf06fbdd..5f98590e 100755 --- a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts @@ -1,10 +1,3 @@ -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.get -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost @@ -25,7 +18,7 @@ configure { signAllPublications() publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - this.coordinates(project.group.toString(), project.name, project.version.toString()) + coordinates(project.group.toString(), project.name, project.version.toString()) pom { name.set("Braintrust API") diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136f3d4ba8a0da8d277868979cfbc8ad796..a4b76b9530d66f5e68d973ea569d8e19de379189 100644 GIT binary patch delta 12612 zcmY+pRa6|n(lttO3GVLh?(Xh3xVuAe26uONcL=V5;I6?T_zdn2`Oi5I_gl9gx~lft zRjVKRp?B~8Wyrx5$mS3|py!Njy{0Wt4i%@s8v88pK z6fPNA45)|*9+*w5kcg$o)}2g}%JfXe6l9ig4T8ia3Hlw#3f^fAKW63%<~GZJd-0YA z9YjleCs~#Y?V+`#nr+49hhsr$K$k!lg}AZDw@>2j=f7t~5IW6#K|lAX7|^N}lJ)I!km`nrwx> z))1Es16__aXGVzQM0EC8xH+O!nqTFBg9Ci{NwRK*CP<6s`Gq(~#lqb(zOlh6ZDBK* zr$|NDj^s6VanrKa+QC;5>twePaexqRI%RO~OY075y?NN90I|f^(P# zF=b>fZ73b5JzD`#GC3lTQ_B3lMeBWgQUGYnFw*HQC}^z{$6G4j(n4y-pRxPT(d2Wgb%vCH(?+t&Pj z)QM`zc`U`+<~D+9E{4Uj2kc#*6eZMU$4Oj6QMfA^K!rbl`iBix=2sPrs7j@aqIrE zTaZJ2M09>rp$mgyUZ!r2$UK{+DGqgl`n;*qFF~M(r#eh`T{MO?2&j?xgr8FU$u3-` zhRDc_I23LL4)K&xg$^&l-W=!Jp-P(_Ie07q>Je;QLxi8LaEc%;WIacJD_T69egF?7 z;I_Sg_!+qrur8$Hq4grigaiVF>U7uWJ@Hkd&%kmFnQN-P^fq0gB1|uRt!U#X;DnlV zo?yHWTw7g5B;#xxY`adhi4yZn@f(7-Xa(J6S=#d@&rlFw!qfvholE>MEb|VWn^g}G zMSrK&zQ^vDId&ojL!{%{o7?s{7;{+u%L{|tar(gp?Uxq3p?xAysB>0E$eG#$tvkk9 z2Q2gEP17{U6@UD*v({5MP-CTZfvWMItVjb4c;i~WLq&{?Q1(koX&vt7+$z}10{^Id z{KDjGi0JpD7@;~odF__0m|p;5rIrHidOP9^mwKe#-&JX-X@acc)06G{LO1Wu)#gvZ za~y9(fhA%UwkDOVU1LBJ`0ROE z4&)dJKK%mG@+CIm?+wt9f~@xIMr8}UH*K1j| z0pppo{7gv3v{URwxVMeg>Ps!L5IKxm zjac2egjgb0vH5i75$s|sY_RYec#>faqJk|AGgV;v=^%BM(^p{p;(^SVt-88G9f!q; z>p}9E4^f0=01S2pQBE4}9YqE%TV)*hlU^8k9{&=K76+*Ax^r=AkBb%OCP^P2nm0Ri z;D-|Zk?gGeU<12ti2CnPVNA(Pb)02+r|&yTWW-OJO7 zNLb0pps6aN?A~NJp5kj{{IOlf!5KWMleV@-hYLift)D>-7K+tgs=7Ake}oBnIy-y1 z(Hn@Hjw=_(x>dO5ysQsrnE%A*bk0K<-j{1Yqz@#n#jOL^AzCr#wR|WYzqk6i7v)Lf zkXdKxzuu20aP{Tbg$(+9&oh7cd(Uoqqf<#ujb$q4sZ~gxFbQfS zS)kNklyL*{2AELgjZ(LBu*>S(oH5AaJ;YiB@;l@=O%F6B?oanzoYRM^fQ9-<~^=3$H0g^JPMLQo@SZ@QuNvy)tyJ)LSj`+()#fy?{aV4Yg^7dlQ7AQM^3GLCR2dAFR zJjtfKiVqF`l-H_fz0HD|9g>)pOxn}k!vdZ=DO!7Sikm{Z%P6BrRkBS6W?ZB5W&7rT z@uYpf@M@a!z7H&o@-yrcCL^Ff3e7p3T`R9p?@o-acXmbTSa0>ZANzCSgovsd%;i$| zVus`not!oL#(W`L-!9w0jdaECaG4hk{V7IOs676ZquZH~0TX5hDq|)x z6T497l|E?f4)LA>j=S8}b$0LS=I4h|hUFJYJODT8Li@#6kF$k0)@*l{RnM1HQ%?VT ze-Pqlc!~t(oumVC*?5fwR;P6u{tHaZ~*LlD;B)4f? z?lpWfa2P@)g57flVl83Ej%P`2)gGyaPjhvD(%i~{`2b>#3!+y&` z!2nuwHMFA-zUY}f1^0B8<`N)Gr=A4TS@b1qykmd0Pq{?r)+1^^+D(=xasb^Tf!oK9 zBLL+*p6M_#ufgLzgq1zcSwZsZnQWFLC3`Yxdg-2=*tT`J9nrfYt)RF)YryBf8_gW{ zvKbB+oZLehfT)S#<|y1)E0hW^?+AnqPXq9Hu;v3dsMGdr{SVyF63;K<8VcgI#~}1i zLYSBL0K;RTT(;>2x=*!1Di9w0mwr;`CN}kM65|Ay{~z}_^JKOsRaN<~#9O^iiW<5P zYN7r~HV!#Nz~IZU`P>1Xe%4f~K}KcF#X&5kO*G}-)74S*tQ8CietdPcA1Yl;S=Mr# z`#MYY!{s^uo=jn7;k6O%(}fN+*0cWMpt~#n9DR<3NyU?+3D^AgI}S)Cu-Tljg`VY} zX1=fq$?8$DtOeGxE6f8lbS_6Q3C4+LDTO$}_IpM$Xv<|QSC%+Oll^q$y`7o@jD{dp zNDl|&X)r7wETa-#h*d`KXntxI(Y{vLha{$0i7@G8xx^m=c<{lJ9?p-i!^W{%j7-oo z0W^SzZ^(Wkyz*We{lEn%Yhu-ycUOHtrRiVJL4~&S91*D0MrLu}Q>v-Mc?GcWfpyz% zX|UvcN@krFO#@v|CtYM}g|=L3%aMo$E5<@CM%c*;?u>LOTz00@+dt1{yg1y=$h+{|D17U}$*^fE^H&8b431EUE z<9tv0V_#%#&1N#j7AKCj!tTK@J%oFW*ESW<(#Gl#Xs%v<@AitI?s92nLzm<)w3Wkkom1f$gcdUi%g_*jofy&}N#luL<$GVIe{iQkQ)sIHVy zBgItnPBFamrv6Kb{eE($Q(f`ZPeW!Hm%Y@F*OF1sKB{Yy|C>WEv_mfvv-N-jh)B-5 z4a!1WcT@9a+hGaBrc~sz=>G?Q!*Zp^JFRUvBMyNR1;`)j$RhH$6gEyVKhd$&K-CFT zXaWC-Y=fyOnqT84iMn9o5oLEOI(_3fk!W^8-74|q1QhQ|CmT0i=b;6Z3u?E{p7V{? z;f#Q-33!L+4&QQcZ~GAqu$NS{M;u%`+#9=7^Oa5PKvCCCWNG_~l(CidS!+xr-*gg{ z$UQ`_1tLT_9jB=Hckkwu>G{s0b0F4bnR7GibmHo?>TR&<3?D;5Fb#gd8*wYa$$~ar z7epl1qM)L{kwiNjQk}?)CFpNTd?0wAOUZ|gC{Ub|c-7h~+Rm(JbdoRe!RNVBQi!M8 z+~U6E2X&KSA*T6KJvsqwqZl#1&==Dm(#b^&VAKQ>7ygv*Fyr;)q9*^F@dCTg2g!w~ z%hg)UXAUyIpIbLXJv1nZX+a_C)BOH2hUim|>=JHCRf(!dtTidb&*~I!JrfRe+PO>w z@ox$G2a3i9d_N9J=|2$y2m-P&#PTNwe!oLBZFs;z|F5kXvBDn<)WwE0E3$ow=zg3R zK(9;sf0t;VEV3@gAg7jRtnj%-6O@!Hvg*;XcUAw}!=2*aErvB(eQIm(-UGmq^J=XN zTqJo$Y|WKo^HlBF3BXJrA#}7ZLg=r*w`I*~Ix`o&2k8^(0mt8Rp=A>F`&gehhp@Jy z^e^#B2!~$LvNCKugg)8)-G%&THdk~kfextilegP9?#C#()F59U$&eo(h|5>ceo*Em z{PEE79T$YP|Kr7K`WBHbtQwyxFkCl6xX&+oUf90B5xoi3_5KHHCyEE*oPbOQkfMz& z6^hT8_NXd2iWk{q9IKae1{_7hMPH8I7_BMtVOM4 z6jm?E0QJOn$qrgsJ`9w##GB9?G})-GXSQo6(tYS(Q0-Ct$co?Zzl0?NHsDRron?;_ zZZgQg)%XW>P?8_&zoGuF(>Och2kEJXsu1_X&~w87x!b z>~h!a>e7{`p@+#hXF88wI*JeWRZ;J4ev4<}HWf|Z;(7$E!S5l9wzBHFe>^I{2`a;a)QnAwa2xv1e(bq$<}!8o^ofGvYpk7dBR+`*%iE;hUY5 zaHF}OjGO9r*{%lmcK^uFiTHgoUD`^9Nx@~;Bg!V* zuuJ&ti{DQiq7RyJAR94wem{}cPK1J(Yxnn_{=>?USqz-~&QXRStS^s-7TksZ$AEI! z#og36s3JGtGU{CnDHRFtipFqvrE*gw7_K@NN0h+ItTq@4fqN!HeQU1y7*X?9+IfZT4Vxebpt z%#VzgdDK~-&+=Z*#>=n#XUhNvBZp3=Cr41jMqwJkHLf3L7Vm~V#GgJ(Jpii~PmJ#s zA7Ft!{xD@z>9DUb4JbiUBdNEcU4BO$651iN*mp*f)HbRRM`Cx5cR?5IfEcU{IZWwf zz(M6CDv)>xa3x}K6%tP^i15P1&&DOLK=k~+jNR$UK3frSl+|PjSC-dBItvD~LL! z>_g(YYdO4k(5EbPOw+v+;G7~jYm>F@Ai|o`gs%F)F8tDz$dl7Q%aCe|v|$UkAul_R zNlA-beBX^IJU?kgS`E$it7nF4DaI!SJAGq)2P&Few(-|tp z?K+%D3e4{pfkayrcbm0ftu6Ol2ZzdKM+4i!hNP3NRL`EvvZJ3yvNr2MV%igZ4kj``Qrdb_OI$7jWP z;l0DYf&0(-*QcP5zrP`HVznW+SbH63Qx$7_9~NjRNg7eKqI!UJ=XH`g^=t8GiFTu( z?2L{JKEu%jJx&XjNzU(*!ZNmL1@RlJA0G$2_LrAb_7lmjil(GSlSM zwTes`m+3R;3#N~Xg#9owh3ycXV8@ZlaY_16kpPFA={721b~URO4HD3sp%fmkZM}k) zZB0#)kP=RkNB~R-MCk8aljG_bagt4vIb~8)BV%(b8_;)&Kf9GX+%O_cNG|(D$!3&D zL(I8}*LqN5NntipFlN13=`D>6!{D@CFMBH0kW3=HccJV+xW~|$qeFR5i-2{X+iWMu zI2$gepQ)H_B%ip_BlWOQ*|pErXs|4ir{IHccgaIJ84irE{?+$KDABXr&f`jB^V-c% z$$u`uU1YB^{<+UN2cNg#7&0bz@yF?5>j|;)5&IV3wIQp58X#OE-M^$HdyvL|Um5t? zhZlAG!Mz%XkUe3t471JM*Yur}o30vzu6RN7gJyNcf!IItsDO730mcJ*O!~V``y5=3 zNJGp34DZ}wd1H6V`Uuy%es>BiO_aE-S8jzir#$& zyk)@2a5tP$@g%jW^b^JGdo)X@Q%sE`^lDQmY9m%uDFpPX`w9%=yQ+nneMm#OaXcD` z9}{tn5A2b2z9783vL2_jSao?uxJhWJoq%47*RafM4o0@gY(p)F>qT4^XM5GLzV#6j zC+HoGhAne7o_w{WUo(B++z7lU3Y0k1rYv9|TSv0vR-Du(5=VakbbelgZTeDn+a_Wv zq_j-^+Qz1WAl;Zg>ahX|CERbX1V%B!hTKN?M}fGoA07M(WU&NfT&TmN`P@56U2 z^)vLDs|Ln~0iTtn-?KTeQl@T&bskJFuTUS!m+$CS9vnd}8(UMO|Kv6TCfGN9NUu&4 zL{)GTxPq>fwsJ~aU=4Qhuq8*RzDsP(LZh$BHezq&9gK$IS<|DYbm})$QTGCS6T;Dr zEkLct!b+#<1r9OKG@P!f1wm8>=Nz!7OzJm!g<+`?N3;YaA3(P@EL=(sTaRMDD!c8=-XN^4BXp(eVkj$NmEMYPP>YJ4bJ3yUud z<3BeJAJ$6z^TuywnfH5lv#$lgwraNw{IV=tIznPH1DT`v-5yS=!)J<}xxl}uZf9azA2A97Haf!;<3y01hlw?dWNEv@TLi1s-mO4vmIT%O_42nS z$VRWrs9NngqRRkWAnWkn%`Rw@?wH|)7XL`EL5EZu$qyJW31&CB^T_)qwIv!{;E_6 zo-9XAryQRlk-O0>o#-SZO>|6OYq;}<*>Wu1AsVRiXY4f8qb;+sItv3AyS!4Ry+q}) zA!pAB|BmC;=RIOk^^vlsEH(!Q!7_1FK~ZB2err*o!+b(r=m1b?$6d!%zmN+69LXnT z&gRmM+n_R-F@sT*IYv0_mGPvur!u`iWbQO7SqiGFLeY&yga zf`lM&B74FA2C?N@8_z652fjhBEoDUKbP8hL{0{HAF%qDo7)o3=3rg#6)T7%%5^wl% z9R0*S*<~>nzYOdQk2l`9h#t+gJy_xujw6xjV(8S<_DbVg61&pT%Hi42l%D73G?adn znB%UdNM0p}lEF-P2%TAMam2zpQev71e>a$$%i+r~b+D9G9pF|oY_*(-u*89oKsXLY+UIbqq)MQ%(GYS{(*n_S_*RN$*~`zUtab%0aKwhx znc)Yo?{xq1sJCgQD)TeTci1ucvbez9q=A72H(-SB18Kl&6^vHV8^i!p@>iF!DIw17 z+8Q)TNisB7>pwyww4y)yJx*wX6SJO78eLBC-ar1+k$Z9fy;wBD|3kzI{<+l*>PSY^ z_?nLOZaeWbU@C3hfK?X;Di*8CHCPkx2qco6(ZyJdqSzp^TJ_5Lpa0UP{Gy+!b0Lr% z@xYxSjUKoY6L#>$qx~KD$-0=|OF7zhVP~ntMgEALYPIfhj@+ z!;JJ7te>CcovruwHsJH6Lta$nm|%^C@=V-rmhU{+I~0(|XHQ9jt@L7pb{gx#{4r!) zg($FyFTslcgu(~6lYr$nW?)%*l#VJ=R-jxK(x=t1bWlu(nL66T#qj%3aZ@uVhy}Co zDU_q61DD5FqqJ*#c|(M5tV)XBN?Ac^12*q)VN4yKPJ|#==S_`_QD9|0ls!`2)SwuHDRA_OfXQDq3%qW&MZB}Z!=k-9xqev8jHz(H z{^D@cIB~QiK>~wa)A&^Ll^Wi6QgCzU;iv-BHsLBs zH7=jN%|>0S`SjP%M&AF1PNVDp_FZ?2Bm@7`DC&v(pYrw!!yD#4 z6+<=HS0Ln6MhoKxF<%~H`y20{vf#pxh=;j{zY381gvAFekgG|>G1zo8$&az{V=;JR zy_puF4$L$?EMhT?;TpQoR*j16ll`#AS4e96C}yp_aGKkBe?1H|k_;gG-~Xorc<;lI zkB}fB{$c-D2mGA&{rm<*@F5)c3X+6??g~XoEwuzSuch0D@W~P5(2I8v8F$c2$Vw51 zP#YLSBDqtWW^EYBl^QYHF+MA7am6f4DOhwnJM=W9$uvMOsZ%_~?)2C#wb?CkI$7{K zEi)=#|5pFvg^){zK5kpBLjB2kZ+$ZB|L=W|aNwyyb(gC2l7bcpx{E-H@)q6@D6N^xh`{1E%ItF2$eeB_SjI@b2WgTpS1thwg&n`jiIzw^TtXUyB{00($GIq>vbj|}bav}}Q_~wp3>k8!E@hVC;OMUTu|= zAy#vXH*GrUHu7^cNZWe1>y;2(51js9wbu+R3Aa*(wzH9+X0dIsf&gc_x|_LP z>~CF^?(~U}+l~ehe|i>?4eo!xkq&Lk+RR-1duNP#o~>@1x)s&i&u zRaYL@+D&_M|JLI6fHbEr_`U;HgPTh#E3?sB)A$*gqyBgg*ql|a-m*TX5rACbWKCE6 zdeQ`v8m6>g^ugv`p|HY^#1QZrGGUj0^HVDc@{?Q0yhalbBEV{+|HzC^-{&e{5K%z9 z6Bxtnfu1!@Mp+Q&*&~;FOg&*Vm<@4b;{FG0-!UUXX!|)1w}op!B_|7_s~d(+=9Gba zKp8`LaB4D(H=cGcspJ_TjYaOwMb=sGn^gtUVhK!UI~2KKYEE-NC}F>+BEY7IVvy%KRvm00tg!Q`y=er}wpEetX}K@;}(}{s9AzV#q2@ zBy7}->|N?13POrs`;U?(qAG(I$~Gt+Rgw%aNZ_0fs_utVvRJT-7z4!@x36v@=NBX=IqkK{#Kg0w48de@?#Yb4M(Svj5=T+<ONr8-oh7l?Cji@+erqur zFhZ=9|Lk=$`c}v4u`)-!!UI=!9Jo@h&7p4RlS#u! zZ7-prn75JkV?VjptX;@$#`U`{vB!=Z?V`T*FBF>J?vsML7e6@2GbUteMFfX-TUu{2 zLNIG*;dV)8GV8gAgEf#)X3A>p3^CRka1v?~8x^anBhQ=L=LsOl=&pcOYHo98m##ye z34MtGCDK!`ptl?taGMr5q{!zVc? zG00e){TV?`YA9eB;(lA3lXI?RrB4BYQGk?vOmTIUJED=(`_*gtn2DB-t4WW54as*W zb2kD-lWX>lb$+W!VFakki>B^Vc+u$?NLF>)!U%b@Y}gYJ>m2H=^x0=nsE0TF^Yu0h ztgH8-o1%+jCk(+&`|)tTfEVHq0cMeFa{Uz)X$;fCq%Y=SOWML6bYfeP8j5hktL`KK z(18`XrUn&WN9PtFxh&dX`y~YBsmdhi7Kw%tKzM%^VEhdD<_XkulW-x=JN6OPbFI4@ zzDDRN+f=@{0h*MswwOqG6gJ?{NuHx(y-|FUGsxyZ*x0~$MW(eY>vqq4Fh#t7uzw=- zKB?|!0N~!h^AMdLa)oR!Ca#HZ9&Zf)ghuO<^RN)4twRlygHnQG(BE{cDc5E}OF4;xss6gYyV~EcJvJkX)xNWb=@yw!uq0v-sf^rvkp-;?DPWK@*SEw|V;IH=7 zfQqEV_>DjOPT~8X*J|H8=&RnzK4~S7ML~nLX^%s-Vqc^aWy7N$y57qciZGcqy#=zU zs8hcHiI=D$+RB{|62{ohCTiaML6FI4Uhzo5D{Jik@poCs0w7F)*w}F4r0sJ~#u-72 z5bK=ANt=M$Dh5NKnxGsg9NRR?WD-x|FhTwBjd zD<-K>44DB~i%frJOfnzh1R>PRY34kw!6~p3M$JLaD1r@`=h)~Ngks-(gdXh^Q?BTP zZ^Zj5w1AwtuR2$~E7s9iZdF}z%pv1em^V2rM{1tLUY@-+Sc0(9jA|iZWml1;v13=U zHf?y@#mb--7z6$ue>`qjhE~brk$AY-RG90~5wcBbDReXR2)pKg{L>;H(DI`U!MLNQ zY9rFJP@ZQ}jlcMh%WSCo%vf+nd0Gmd*F%KMIe>slCUh)8Ma|;M_I+v#;|ueg9oLg; zq2HtZX%&#F7vdpNlkX?}(C7dGC^y#NB#m4%69RzTNrk%4ol~hSI%>2r6B|*ZkW(*P z;u#s;+faHo{tfy+1L^RzWDi*^JR0iY(zJDB36y_QJ+|E-2x+cY z!V8uLNktH~q>WQZuY!Ap66WP|E!0PA1jK~)^8oJVGbspJs6QL!!-5Qm7 zHYI|_`Actg?vDzdg5{86w@GS$G6ANzff7->6i5pB$T4O}`fZ_;{217Om0gN5zTr12 z5mW{hCzCE-QubjxN$TAE-XgI-8dTY@OZmq`y+y_>dk*(qXF0{nam|q@~i}Utp*k{yurq(DW54hkDT4bbg z=_etM?Nf5W^o-HEu9_?&xEqPg^P^mTxLH8n%u$!mWvFG|{&)jtnU&6|5-`~eaNz0%D1BDo`{ zS1N5(KW5v^2eLdd_%`uaRndF@h0Uo6=M|8?b~KbOLZk{HXEnGmtgZXf2inI*1r%n! zQ3&%RI4r{f&dwW~HwH0Ked9b!k6{>_19H z_Ai>5IChDMY(FfMyG%;30?SQ{iV9KyGru62+Y)~qSQ91}b~}w<&*}R&1c#$O`H@~c z5)2S_eXx}M#N{MuGeQS9@#UJB@;W_j50b}jIhxMPloEFQZdvwxiU^RYycTzgK)-vl3LT&$L8~@68$C8~5_U{cR$E#w*x65(qw&eoL@>%ZHvj zWnEMlSh*(o&oy|J7eJ5OD`ssy%F?*Vp?`Cq;FShyl{ZoKCG5g{y}>usznni#8ki(i zO{w@n{iAj1_ooX@+s*!uW60WcH~*bNOT6z%0jVML5};wVrQp~`Uss_{cO2oud_nNA8^B$?07fJ6?iI)Q zuo9G)O-z)DqstrBqf>B%S05hf-wep0@$BFHKSrkZ{za3D)yVzRz)2{wf8(Wp+xyAM z$rtyx$gi3A=V~V!`Q3;BM0$>*VVtxEM|xDL^gew7ydy3Q6YzD&THRz*q33Ms_D;M- zbCx1Ft#UNB)V3bf`~{ImI72OTp^|bF8?G8#FRj+Biy8ET5#rA3sd|0FR@U(LAJ%w8 zS1%n8Z=Amhw)92rIsof=YVWF4jw&F*j1LG@-`+cR0-~2LqXRH8(Ccne{y#MCPncF64U`0uO zWmi$dlii~1D0rLR{qc|_2M!C$t8^=G7xQY)9!#Y331A|>N)EhmyVdLWL9I3YLJ`7? zZmpqUJB>Ni9oiL)^1IK1UoMyhWE{$9M2M6Xi zPKk7GpMsA6vjZbU7~i+u|J6Nk|Ci!Y3UMUT2|`M;JsNQACdJ%ooo9Yt{?A+0hMpxi znEa~~sxC>rKrU6bd=WRb;%wsH>A#j4{({&1GYSNR57Gama(3)2A;SM>qop}l>Jk2* zn1+C$fIxuwzg3mCU#SOqb-wOCb6mBcYlA5+mt<&_J~sBxc(GQtBFINUO~Mr7<-uu($>P HJ4oML2Lo<@i8BwbL^1~GkG`E7C$SEa_ zF^}Ea+#Je`Xy6;#D0FPnSrR%Y!QGA~NA^{oWmW8C<3dr{x6wWQ{4+bzemqV5W$i5~ z=J0jXZ>uZb>DT@0Ks?4QJ{`z?8JWl3$y;2pj#$XP*pv$>$g(z43{YH9KmmR6<#sIn zA`#=0#sgycaBQ^&}Xba!|KaZ8~b30v~nLt z9%#gz_*=~KD{3t^X~l>480*}PhKN=??g`RV|4Ud{Gyyl187MJ}r(#e+H$GEdI+p1s zq_25h;fV)$EPK%Dw-(G=f`yHB-_tttsC!?k7*#!|4a>`Ahj8nm?&n>NRs%jkZW^3-0P_yMP5&*6a26{MRj1&TPF zyE#|c)5uUHzMWx=rMKpuPih*V=S;W3MzIZTw2uTbr}8`p2bm+Z6Sa%vvWAWSf4H)p(+ zSQ8;EvUa#wqWV+9vmIio(%7wukK2SwjUS8Yl%Rq%=~PU)2$Tvm6`1!r3H@U#_|bB0 zmlT1PS3wPB(b&^+@YY7Y$n4l3mV3-X0$>z|gZp6O*Lhzn&?Gad2ZCF;+#95-Y?#y+ z?*l@Yf=a4w{Px=o!N|3~_XKfk&G;fN>Ps&dp2FpA~qD=0~=!NOS@B#XAKKkND>Y{4>rqxrViKD7;?>j8`R` z&G)3FN|dfsxnaI^!d1G%=>AbTTxZWo;n-DLrQ!sj=f~VAOe5zhGS(dgx|!ls62fbX zV@<7Ck^!}R=`Swr?(7w1rY6Nmq~sfXJ?TiKJLn=&SQdEt9$@0 zA+h1Wbwbri0s-stc8yVq;mRa6@kEf8^KXUz&jcic!+avDvvJFa>k0ioWug=T3oPw; zyj4it&0@>_*uI@2=^+T7sL1_!^aJW@Xfo8aC#3^WtQC7fET8b9C} z*u^ue6Ojn z7@(eskJ2+cNnH9~VyfIh<-|7!je~vGy*odz(sk-u$~SrYF3glruZ*W`{sqnS+9=;Z zh{D@MSG91%lr&ua8%$sJF%y1I<|e;EdfJykY8#D$Hc_81n5`$7;1N|b0tvvPLzSg& zn7!5x?T*@rQUKcUhTIjV(rw*5oQYlm5DbEO?60#mohHfbR$3_x#+PZoYi@Vd4`#YgKyTd^!4n{fN~WZDY61sAOm6 zl!d^i*a01QxpWM9Pcl?&{RgO}uq%ErOk5WpECvnfEh!*YP&1Sl)uTN4hg??Vqs~i5 zYsfufz3?{TtwuBN=`0~Qg1PlWH#OGG$ zLLWU17$v``)CE1cds_7kj8mJ{-+l8{DS|zAQ&3|qpOY=!J|kXUhXue9|H>4gqk|n) z-i34GmxLFj8asb3D#D&=ya*a5`C<=o?G;Ev^LV%;l#nH#O=7Nh@z1Do>j6Q;I5S2P zhg|AZbC&|c7}uSJt57s2IK#rSWuararn-02dkptTjo*R{c5o(bWV}_k3BBnKcE|6l zrHl&ezUyw^DmaMdDFVn<8ZY=7_{u{uW&*F<7Al6};lD(u;SB=RpIwI)PTyL=e25h* zGi{lRT}snjbMK~IUx|EGonH+w;iC2Ws)x>=5_{5$m?K z5(*1jMn%u0V1Y%m@`YS3kskt~`1p(rA4uk;Cs!w^KL$w>MH)+cP6|XKr4FfHIATJH z!EGAK4N>1yFR`-zW|w%ByRe#=&kA&#WyUldDGpt!wf-8SFWiSi!5QZL+l7*CE?u!NW1T$<1rdLJ9y3u{_zvHaM?#Rm4 zFk}^1!ffcrB|XK3gsO-s=wr*sUe&^$yN|KxrA)uW00Gu60%pw_+DcUjW`oW<35OC8 zq2{j8SgC}W$?10pvFU83(SL$%C?Kctu3*cs0aa%q!fjn1%xD*Jrm!F3HGR9-C{b?- zHp(cL;ezXMpL@0-1v0DMWddSDNZ5h?q50cOZyVi#bU3&PWE=(hpVn|M4_KYG5h9LffKNRsfhr^=SYiKg?#r&HNMi2@cd4aYL9lw(5_IvQJ zcB*DD()hUSAD^PdA0y|QrVnqwgI@pUXZXjHq3lG2OU&7sPOxxU$Y3&ytj6Qb=2#cC z;{d-{k|xI*bu+Vy&N+}{i(+1me!M;nshY_*&ZQLTGG*xNw#{RpI`3^eGfHck+*38NRgiGahkFethtVY=czJs#)VVc{T65rhU#3Vf?X)8f0)X{w!J3J{z|Sq|%?)nA+zo?$>L9@o`Kc|*7sJo4UjIqu0Ir~S5k^vEH};6K?-dZ0h*m%-1L zf!VC%YbM1~sZOG5zu&Sh>R;(md*_)kGHP)<;OA44W?y53PI%{&@MEN}9TOiqu+1a3AGetBr$c)Ao3OX>iGxmA;^^_alwS818r4Pn&uYe^;z6dh z)68T|AN=hjNdGpF7n>y+RTAZc9&opTXf zqWfK_dUv=mW{p_vN>|(cIkd(+Jy}qnK{IW%X*3!l`^H~FbAHwof+vLZ0C2ZXN1$v7 zgN&R9c8IO`fkR{6U%ERq8FN<1DQYbAN0-pH7EfcA{A&nhT!Be>jj>J!bNRw4NF|}! z1c70_#fkk!VQ!q1h2ff@`yDyrI1`np>*e#D4-Z~*!T^8#o*$V~!8bWQaie?P@KGBb z8rXc!YDL!$3ZgZZ%;-%~0Kn<+d+{xJ$stQbtN8GWV?MCJvzPU|(E(1z;rFw{&6vy) z3*@y%7Tx8rH-p$boS>bLyod?OKRE8v`QSBvGfY6f}_{Zo1q85xoyOF16n~yHx2W ziydUoYLkJmzq|n&2S(O!ZmLdP1(o1Jsq88cX)x3V-BK5eF&0e_0G!5?U7&3KN0`mc zH&Lt)q8!d_VgzxyL^(@xrbp2y)Hmr^V48));RSfE=*Ly0uh9!$3dv-vMZr2URf@l5zdwLjGZB zugY>7_fd_vbV*Qv1?H~>Z%RD%nEeFSI$n$$Lrpc6g>i4+XdBB!%zM$Bhrz5Swzyg? z$~I~n@~-wTBY3-T&pr+|gC+OHDoR?I(eLWa{Z#Rsh>lc~%u0!&R|s0pA*w<7QZ}{i z*AFr~0F3y~f$MGh_HDL7J_1?SxKL}fWIk!$G}`^{)xh*dZ5kK>xGL9>V`WZZg_ z)^Vm)EQK`yfh5KiR(vb&aHvhich z_5o+{d~0+4BEBqYJXyXBIEb1UgVDs;a!N2$9WA>CbfrWryqT25)S4E4)QXBd*3jN} z?phkAt`1rKW?xoLzEm!*IfkH|P>BtECVr0l8-IGk_`UjE#IWkUGqvyS+dMrCnFl<7RCgSMX^qn|Ld_4iYRldO zY&cHhv)GDo8nKvKwAbfyLR%t?9gG?R7~PSD#4D-;?F&!kV59O}neYut5AGbKwy-(U zqyBi=&Mgj|VIo>$u!DHM`R7O?W8-idbePuxiJMH``6c_5L-chKd}=rGC5Gfrc{f!* zWFEBm?l@_b7kzY7%1RQQbG5V<4=ZlkZ%sF74Q|mKOc7Ak7dP2#quiGcZ0_J%7Q?j{ zv9{WFw;n5G-Mn%r#0R;{jLt{yy}9J6rQ(>X9pJ`7Xy?Zv z=lNit#qXaq?CnElK^zF~sG}U5oCpR0T>FH=ZX}Prju$);?;VOhFH8L3I><9P_A|C+ z{;>~dk%9rrq(snjsEm}oUz2FQ21MCG*e?g)?{!&|eg7PX@I+Q0!hL6C7ZVY|g2E>i zr!Ri2@OfEu$)d52+>+cpgh6Z;cLYCZ&EMR0i<^~4&wEu_bdo;y^6}+U2GIQgW$|Od z_jg{O=pU>0-H$P-EOlWyQy#W0r@@_uT}Lg+!d5NxMii7aT1=|qm6BRaWOf{Pws54v zTu=}LR!V(JzI07>QR;;px0+zq=(s+XH-0~rVbmGp8<)7G+Jf)UYs<$Dd>-K+4}CsD zS}KYLmkbRvjwBO3PB%2@j(vOpm)!JABH_E7X^f#V-bzifSaKtE)|QrczC1$sC<<*Y z$hY*3E10fYk`2W09gM_U<2>+r^+ro$Bqh-O7uSa)cfPE_<#^O) zF+5V;-8LaCLKdIh3UB@idQZL`0Vx8`OE#6*1<;8(zi&E7MWB1S%~HAm%axyIHN2vd zA(pJGm_PraB0Aat3~?obWBs?iSc*NhM!{-l_WNCx4@F7I?)5&oI|z{o@JKd1HZ}zf*#}JjK3$ z-;3V*WJZvUcKvSOBH4c7C{fl8oRw8-vfgKQjNiR|KhQ%k6hWNEke(k8w-Ro| z7Y3)FsY-?7%;VT64vRM)l0%&HI~BXkSAOV#F3Bf#|3QLZM%6C{paqLTb3MU-_)`{R zRdfVQ)uX90VCa3ja$8m;cdtxQ*(tNjIfVb%#TCJWeH?o4RY#LWpyZBJHR| z6G-!4W5O^Z8U}e5GfZ!_M{B``ve{r0Z#CXV0x@~X#Pc;}{{ClY_uw^=wWurj0RKnoFzeY` z;gS!PCLCo*c}-hLc?C&wv&>P1hH75=p#;D3{Q8UZ0ctX!b)_@Ur=WCMEuz>pTs$@s z#7bIutL9Pm2FDb~d+H}uBI#pu6R}T{nzpz9U0XLb9lu@=9bTY&PEyFwhHHtXFX~6C zrcg|qqTk(|MIM%KQ<@j=DOjt|V)+8K26wE_CBNnZTg+Z+s}AU|jp6CFoIptG1{J*# z7Ne~l;ba*=bSwAMQ|Vq#fW~+je4PXA91YFzBubNF?ovIOw-$C-8=Ehed{lGD0}(Id zRe4sh8L>&T%{>8o))he}eE;5_ zxoXk3wX?MyNl-xF!q1d$G?=wp^`@09(jU&X zOqZIBI#dN`2PJNdATR3ivtub|nO$dulSaP|e4)WXF1YAGN1pDQIbIjXFG!oC85Mt; zW$eteoL{y^5t4TMRwP$jNPjZFpGsWnGe=jMMqKtcZm9Y9PFZLi*1p@qoKKub^T@2+ zk$@*KYdQ?Z`}<%4ALwk*Yc{(WTf@#u;as(fvE^9{Gk)lWbJP*SjttWofV0s?AB({~l zZI1hZVWFT~W-T?nfMMcnCS4-#6H-MU7H$KxD;yaM46K4Kc@~Q>xzB+QnD_I`b_l3m zo9pRx46b!p?a^&zCDwygqqV3epjs(s0NQI6ARA1n!Yy-qduipxQ& zUAlqRpNjBS+y-ZheD(!R;F}&^V_}b_gqH%tVZ5%%ziO7k^w=es+wZtK^i*vmrWNLMs{oWu_CIov|s1raZiS)>38>pYu;i+-t zI_DiNe6aA4KTZ2P09qPj(0~K4nUq^0+f(2$g`229zkG4jLzRvJUWE0oF1XHL4t3UN zDH466G56sy9hTZoAJB!C3;@F;ONxEk5u6Mv%zdo}Rq`=* zw1n7MOhfNSV48TS989ArIcj`C%Gk8~93~u>)!Yt2b4ZriKj9x2d`H2HQNJ=I>hkDlcZn zqRj>!;oRMTIOu zx|Zfsu~v76T{z7AC(jxj^c@tnJHZtGPsq$DE!8kqvkDx5W?KUJPL+!Ffpwfa+|5z5 zKPCiOPqZZrAG;2%OH0T$W|`C@C*!Z`@Wkop{CTjB&Tk`+{XPnt`ND`Haz;xV`H^RS zyXYtw@WlqTvToi;=mq1<-|IQ(gcOpU%)b#_46|IuWL#4$oYLbqwuk6=Q@xZaJSKVF zZcHs~ZBl;&lF3=+nK; zF`4gSCeZXlwmC_t4I`#PUNQ*)Uv&oGxMALip|sxv^lyVV73tKI7)+QY5=tEMas{vTD-BaTJ^*Y6gq~PU;F5X!sxqiq$iFCo+Uv7m%1w((=e}Vf*=dtds|6 zbX}91!G?C*KG03eHoN}RZS9DJxa&8YwNCT8?JxMXyZqZr13NA|GB{+vG`08C{V(yy zf*Lw$+tYSU_+dI`3n{bMrPdDb`A=Mkg!O=k>1|*3MC8j~- zXL79J4E=U^H=iBLTeHE_OKzE&dws8RNynsSJ!d;`zK?P92U{f)xvD7VQVosrXZrL+ z6lMVdD1YgL;%(1cq{#bS6yXmp|DS@nax#AqqlZhtUQdh<^2vr5`EpAO

LGYq)sa(w9^3-f}NHy=GR4v%t2YZly3m1G@5y`xBh_HGrD%f z>;|Ty?9FiJAc&UVD(StT4I` zfVQwxhE9bXE6r2mKO8Ag7{L^jCyqQb0QqKDPE=RAgqn8q1O^>(z7h5kE(6va%QqRZ zkIOmp(})rLSS(2{=C12e&@!W2=Jel-^_R``0xHO^+t!(oXbcv5yhD4g*$t_F)_5Dl zSVCgesW%;DtYPCFs{G;GX_o?1J3;QQPPv)rWw;>} zJ&KwnUqwNXloNXlK_+pNDfI~hON#SokVJb&ilg8d7^NWo2ZQymCqQMnjfi>ePibjr z-Z@q!?RGN$Mj}Nk){X_vaj6?Mj$>ACR*z|6MsXy3VZ^PFn@yHkPo(>m(iWepn8SC@ z>D2;R4m+gDRZ=SIX!b+CP(qE=JDIUkn=D$aUu+Ihn9-+k1LS3PreQg0N5eWIG@x${nC3v^7caS>1!PKNAY9J z#}E}Q9w#SP>(GY7Hbj&z4$Li6o5taBO|4+F`yS9zq*LJ<38wy4I>HA9(&GYrk4dLajKGww))BWli6Ln1A^Lda@N~p+snkb9C z@OthI+<##vp8!HVQT4Wk(=@zQ{OvZ$EKWS73+JHb)eYLGD-cqi6^|vd$<+IHuc?Nq zW7JertT~3))4?J|28n$I@nAD0c1%9C&IVhEZX~mUsf{efyS(XNG%ch;!N~d7S(Ri7 zb&=BuON95aVA&kLn6&MVU|x}xPMp7xwWxNU1wS+F6#y}1@^wQZB*(&ecT?RnQcI}Y z2*z!^!D?gDUhc@;M^OpLs4mq>C&p{}OWVv<)S9KMars@0JQ{c_ScGsFo3BJ)Irg++ zAWwypJdTO-_{Uh8m(Z!3KL7K{ZZzKHj;{M8I$mV>k znTM?sa0);^=X^cglL`uC+^J)M7nEa$w=VwFULg~%DJllw+7dJAj3{qnP5i3@wr7%y zjXp?Wl2%Th=my&3u?Q$RV6N5tzKMSPTsc#J+-cDDp~qFB6bL2C8AS7Y3PKtVhdhl) zIaLqH5+OnWPWSt(lQCgkN8lczc-V%_iZ{>#1%Z$N*>lu#S;0MZ$T2Y8Kg!U;hAZj> z6S#%$DQ_`Ic%Zr@?}GgjRXg@qTj^17n`65oJ@Wj0u1X8&+UVd|Xs?J+i_^GZ94m6= zUc96~Q`OJvlKB_Lr15*Yw_PUPEr?f?H&00b^-W%26mD)(n(rGGNfK9~2h=C>p-7BZ zFd&*&Msdu{w~(eyFOglwCPH^Rb}O(N7LtS+nnEwDx*pGD?|&9Si~M43a+*L(b0$5A zv`T`(G3xO;I_sx;FwTP21ZlfDpz zOo?}Vlgf~fo{YWm@n_JyD*frOg{XsvBA~|Tn4V6hu>Gd>89-rblfVJUaGvj6X%NZ} z$tFF9sx=4_$*c~G`9iPLGh@=sV+O{D2-t*K@J7H=`V+oVt}8?04WwU3h1BgS!f%1P zFak-T#7`TtLcR=Yz>g0R!ZQrH!YiZOQN=_V-UyncN1Rc18?KY?#O`v#JK+pq0K$~H z3D@v9DZF42R)b9#BBX{^$DOMlJ!g)Gc za{o-1e%F6NvgKq9tC8pV+9S$;9*zNv{J*)n&dmf~anP1)4~N%~h#c(=B#3*KgzhCKhFdgDoWi2IDog{RVyzK|Y`rCUs3T~pJMmdZJy4?b z&s5G=zhf**(t7Y^oC_mcTsE-{^}wiaoUu&?kojLKs>SJPxjcP>{a5CbXCx92AcBE) zHtqP}LjZ{W>PH?Tu(E0X=%{PBMW@F_?#7b&#!^q`<-5$ur+-q6 z{dn=(^UZw6*3-XM_(=@<1_*i&XM4=0t5u!gm6 z{UlmNGPKgO_;e;q9|#esq~Sq`<}%d{+sRmhvsA{5i*91=tub>OZZ%)xUA#4q$dDyy z1`w4%?OPLg3JeZb#cqSMO?*Xn%|-FCcuH2i2fn_{IFusub6;NQdN|7TD1N?%E8*g? z$apAt@cEe!I%jB=*q$p_3=t_5R0ph%{qaq+QDg!c99Y!Xa!&oDZOeis_ot)gNXr{l zdY$|So2Qed2Y7KMNBrS^E169kG%h<+z{Z_p_;shB!uY)>yAVcK=&!bg`lVg)4T1|7 z0}7FpfydVH4F87K@c!nEG+WGKm{Ouo)Slpl;#qcEIQ0zdMfLA#;dBxYw;p;KoVv6| z3_D5&7rJdG12CnDSvZUW?$UC6^UVSW^|vw|o-_4bz)(w5(3AiVhpeT(|=f#x_}E?s#qHZF#xA6AF_ujl$G z-jHD%q(d2}v2PhXx&6YWps~m(^+RXl91Q#xRRJBhjKl$FG4bk);|ag;ieUZ&!Ii3$ z(iGz1+0m7#g5>ASldBbNZL=ZHh=tmmJt$!71; zIML2GhEz1pg@1rQN(M^_691wAGkJ@Pga_05WuQ6! zG5RkGY2^`@(H~pp7&Ga+Pwh3L!Njj!-rc;^bTIfo5hP@H##1X8xUZJckrx>id`bAd3QUx9GuomqBYZ!uN1-&o zvTxC?;p8vL67&fW8fw(YOqt>L@bdLrEF*3OgYe$4n4{ zEB40LiU#6-0@5jdN`0w}N0qi@c0~oT2FP z)LNk&a82my?jv(tQpiMi$TK_L@lub#lsM$R{Dk?Ya@%%%huZkct~tSWM714c!45k}-ZLVA-bVM`>|_ZBbW_m-7| z3U%xrAhi}n?T(2F{_n4EZ10inkIFl#y09?7$uwBoJgqY8vylwev)fDOn;>0R!aEnV zBz%j0Mqpx~EZU3q@%+oV7;}|vt7$~ou@faEIq{p?FY$XXg&6*K)b_LP=}gi9`Bij3 zN`zEo|B6*|-;>S`rNa^BKRDbDAk>X#MsR`EvL>6bqU@SaDDs z8>bu@3YdRaWs*Te@G-UHjU%F~kTHw5(0PVJ+pwh#ha2u;DB+UMo@A5UYIl#5rtBV- zGX_hIpw}3C@H*Us(Cc-d#-gNrG#w$(9+S=GxO>3SR`SE2fHZ2KrDc#_C^$jI>Y}#; zMwY=R6@+dWi~0RXw(c@3GZ&%~9K(q&ee0Zw;pwL`E_tZak-#8^_b)Dpyi73^he?xV zXJ08&wh5-M&}qy4f7!D&=E)puDD(Nmg1d_(j`4LvxM5x_huNg-pGG%9rYqO6mImyJ@}*3Y>^3OvcnTG%EV1) zq_Ap?Z!Iw__7#D=pOWnQN$gB!Mr0!9yx|g<4icJh{cFOu3B8}&RiYm+Mb;VEK``LK zL(NcpcTiGieOIssSjr?ob}^``nNf&UcJhXyncO9m{6gD$kqSD`S69(aF8dkWz5>!9 zBLe4Sib7Hs2x_L2Ls6Ish$MGVKrGt5+_2zCyP1byaCg3upo+-I}R4&$m)8 zQ7|jc1Z^VWggpuQj*cP;>Zo9LS!VSzrqmZczaf;u`d0J(f%Z9r%An@s!e>n9%y=n!IZ_tVGu{Jmsbp}Fk%HJIU?a+-~bjfLTuH|JExA8EROowzr zqW9{YyZhR0a4clRK>1I4Ncx&WER~{iE;F^$T7K%X@3PGOA%6#Z%p3TS^&M;Dnjw@i z^o!$9nhcsmcHcY4?4j9+ofL_CWsZ4Hcch(rjsGfGD(nsH>w}^ERqGnz%iGj0j{g}h z7wMkJ-2Z2~eS>2!i}0~B63i;>SyFJU2+>VCS^AxaDOx%g6-t0eM^P<3+*z`ztvOqrG3)&#$K?& z_Y0wbWID47@cU`E1A6A&!`aZk0ZE@z-h#l1NqX2#`$Uev2gepW`rf8*!=rD5&;Jb{ zl08rU>dPo=K%-1Ao1~G-@4ve~y5#9E8x;TE0k5d^TC(=Zc>mwjW^c=+U-<9}b0ku~}gj z3sbW>R2M6DR!g#NUP;nxo>)@7*=RP{U18SDop6b2&PHce^&h97@xx3t+VK+!keE#} z;(Uf&89as9k8{$nkLbuB!-d7TP`_VJpL^Xs8OKB~ri$YUbW8fch64}7|0EWoT(TRj{ z*GT<7Y<7DsrCi79ZsM)z#c(!nNOGySOCkY1fAuQOq12&iUVC!a`#O;dBLf=d?&4*B zI~LgAO7E0qxK(uRTM;IgJ}+z^gD+bi-6I!3x{r9`l~%8TRP%UE0V8E*Sz>Nl1NVG<<7(wDHZ+HcOkQm$O&k+vyx)y)x{Pz!U8hS$*m zByc0h6BUI*BOpuL==P+H|Hx%`>7!W+1H!l9vi&)`V zyn2o9{z=lc+VX*!Vh~SF=)L}Z40XeG>LF6cP^b+R$NxSeUqbK^Q*UTalKzP8X%{9@RSCXm_NhF>{=S2 zi}ezam_^P`S!!-cyEW9y7DBbK93roz@Raccy*v}?mKXScU9E_4g;hBU7}zSofAFda zKYEe?{{I54 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..cea7a793 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42..f3b75f3b 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30db..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## From a8b7cd7d1e5346b702483b336f9a1d9f71f38c11 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 8 Feb 2025 06:42:25 +0000 Subject: [PATCH 39/87] chore(internal): codegen related update (#109) --- .../api/models/FunctionCreateParamsTest.kt | 87 +++++++++++++++++- .../api/models/FunctionReplaceParamsTest.kt | 87 +++++++++++++++++- .../braintrustdata/api/models/FunctionTest.kt | 58 +++++++++++- .../api/models/FunctionUpdateParamsTest.kt | 87 +++++++++++++++++- .../api/models/PromptCreateParamsTest.kt | 87 +++++++++++++++++- .../api/models/PromptDataTest.kt | 49 +++++++++- .../api/models/PromptOptionsTest.kt | 46 +++++++++- .../api/models/PromptReplaceParamsTest.kt | 87 +++++++++++++++++- .../braintrustdata/api/models/PromptTest.kt | 58 +++++++++++- .../api/models/PromptUpdateParamsTest.kt | 87 +++++++++++++++++- .../services/blocking/FunctionServiceTest.kt | 90 ++++++++++++++++++- .../services/blocking/PromptServiceTest.kt | 90 ++++++++++++++++++- 12 files changed, 880 insertions(+), 33 deletions(-) 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 eeac10b7..e8903e3f 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 @@ -40,9 +40,36 @@ class FunctionCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -119,9 +146,36 @@ class FunctionCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -200,9 +254,36 @@ class FunctionCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(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 df7c0649..598e23c1 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 @@ -40,9 +40,36 @@ class FunctionReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -119,9 +146,36 @@ class FunctionReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -200,9 +254,36 @@ class FunctionReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(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 fffade2d..b6570597 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 @@ -52,9 +52,36 @@ class FunctionTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -143,9 +170,36 @@ class FunctionTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index 72c57065..576aa177 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -25,9 +25,36 @@ class FunctionUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -89,9 +116,36 @@ class FunctionUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -152,9 +206,36 @@ class FunctionUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 55c872d4..53cf165c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -22,9 +22,36 @@ class PromptCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -83,9 +110,36 @@ class PromptCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -141,9 +195,36 @@ class PromptCreateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index 9bd6b0c7..f2acf4d6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -16,9 +16,32 @@ class PromptDataTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -63,9 +86,31 @@ class PromptDataTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO + ) .topP(0.0) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt index a33f35c4..119a47b3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -13,9 +13,29 @@ class PromptOptionsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO + ) .topP(0.0) .useCache(true) .build() @@ -26,10 +46,30 @@ class PromptOptionsTest { assertThat(promptOptions.model()).contains("model") assertThat(promptOptions.params()) .contains( - PromptOptions.Params.ofAnthropicModel( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.ofOpenAIModel( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO + ) .topP(0.0) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index bf3ef884..5042646d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -22,9 +22,36 @@ class PromptReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -83,9 +110,36 @@ class PromptReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -141,9 +195,36 @@ class PromptReplaceParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index 427df08d..c65cd2c6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -34,9 +34,36 @@ class PromptTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -102,9 +129,36 @@ class PromptTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index f7181177..e47bb2d1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -20,9 +20,36 @@ class PromptUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -80,9 +107,36 @@ class PromptUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -136,9 +190,36 @@ class PromptUpdateParamsTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() 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 3aee103d..69655b05 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 @@ -60,9 +60,37 @@ class FunctionServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -152,9 +180,37 @@ class FunctionServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -321,9 +377,37 @@ class FunctionServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 818b6df1..15a5ec99 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -41,9 +41,37 @@ class PromptServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -128,9 +156,37 @@ class PromptServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() @@ -231,9 +287,37 @@ class PromptServiceTest { PromptOptions.builder() .model("model") .params( - PromptOptions.Params.AnthropicModelParams.builder() + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) .topP(0.0) .useCache(true) .build() From d1647dff5977260e2346ad1eeaa5105cc82f8463 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 07:25:06 +0000 Subject: [PATCH 40/87] chore(internal): refactor `PhantomReachableClosingAsyncStreamResponse` impl (#110) docs: add more phantom reachability docs --- .../api/core/http/PhantomReachableClosingHttpClient.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt index 3f4673df..efd180a9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt @@ -4,6 +4,11 @@ import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.closeWhenPhantomReachable import java.util.concurrent.CompletableFuture +/** + * A delegating wrapper around an `HttpClient` that closes it once it's only phantom reachable. + * + * This class ensures the `HttpClient` is closed even if the user forgets to close it. + */ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { init { closeWhenPhantomReachable(this, httpClient) From 029cbc78bf94c707da26f3550db354480909bd78 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 07:25:33 +0000 Subject: [PATCH 41/87] chore(internal): codegen related update (#111) --- .../api/client/okhttp/OkHttpClient.kt | 9 +- .../api/client/BraintrustClientAsyncImpl.kt | 4 +- .../api/client/BraintrustClientImpl.kt | 4 +- .../api/core/BaseDeserializer.kt | 6 +- .../api/core/HttpRequestBodies.kt | 11 +- .../braintrustdata/api/core/PrepareRequest.kt | 2 +- .../braintrustdata/api/core/RequestOptions.kt | 6 +- .../com/braintrustdata/api/core/Values.kt | 19 ++- .../braintrustdata/api/core/http/Headers.kt | 4 +- .../http/PhantomReachableClosingHttpClient.kt | 2 +- .../api/core/http/QueryParams.kt | 2 +- .../api/core/http/RetryingHttpClient.kt | 15 +-- .../api/errors/BadRequestException.kt | 7 +- .../api/errors/BraintrustError.kt | 2 +- .../api/errors/BraintrustServiceException.kt | 2 +- .../api/errors/NotFoundException.kt | 7 +- .../api/errors/PermissionDeniedException.kt | 7 +- .../api/errors/RateLimitException.kt | 7 +- .../api/errors/UnauthorizedException.kt | 7 +- .../errors/UnprocessableEntityException.kt | 7 +- .../com/braintrustdata/api/models/AISecret.kt | 2 +- .../com/braintrustdata/api/models/Acl.kt | 16 +-- .../api/models/AclBatchUpdateParams.kt | 36 ++---- .../api/models/AclCreateParams.kt | 22 +--- .../api/models/AclFindAndDeleteParams.kt | 16 +-- .../braintrustdata/api/models/AclListPage.kt | 10 +- .../api/models/AclListPageAsync.kt | 14 +-- .../api/models/AclListParams.kt | 8 +- .../api/models/AiSecretCreateParams.kt | 2 +- .../api/models/AiSecretListPage.kt | 10 +- .../api/models/AiSecretListPageAsync.kt | 17 +-- .../api/models/AiSecretListParams.kt | 4 +- .../api/models/AiSecretReplaceParams.kt | 2 +- .../api/models/AiSecretUpdateParams.kt | 10 +- .../api/models/ApiKeyListPage.kt | 10 +- .../api/models/ApiKeyListPageAsync.kt | 14 +-- .../api/models/ApiKeyListParams.kt | 2 +- .../models/ChatCompletionContentPartImage.kt | 20 +--- .../models/ChatCompletionContentPartText.kt | 8 +- .../models/ChatCompletionMessageToolCall.kt | 8 +- .../braintrustdata/api/models/CodeBundle.kt | 41 +++---- .../api/models/CrossObjectInsertResponse.kt | 6 +- .../braintrustdata/api/models/DataSummary.kt | 2 +- .../com/braintrustdata/api/models/Dataset.kt | 2 +- .../api/models/DatasetCreateParams.kt | 2 +- .../braintrustdata/api/models/DatasetEvent.kt | 9 +- .../api/models/DatasetFeedbackParams.kt | 2 +- .../api/models/DatasetInsertParams.kt | 2 +- .../api/models/DatasetListPage.kt | 10 +- .../api/models/DatasetListPageAsync.kt | 17 +-- .../api/models/DatasetListParams.kt | 2 +- .../api/models/DatasetUpdateParams.kt | 9 +- .../com/braintrustdata/api/models/EnvVar.kt | 6 +- .../api/models/EnvVarCreateParams.kt | 6 +- .../api/models/EnvVarListParams.kt | 8 +- .../api/models/EnvVarListResponse.kt | 2 +- .../api/models/EnvVarReplaceParams.kt | 6 +- .../api/models/EvalCreateParams.kt | 41 ++----- .../braintrustdata/api/models/Experiment.kt | 2 +- .../api/models/ExperimentCreateParams.kt | 2 +- .../api/models/ExperimentEvent.kt | 11 +- .../api/models/ExperimentFeedbackParams.kt | 2 +- .../api/models/ExperimentInsertParams.kt | 2 +- .../api/models/ExperimentListPage.kt | 13 +- .../api/models/ExperimentListPageAsync.kt | 17 +-- .../api/models/ExperimentListParams.kt | 2 +- .../api/models/ExperimentUpdateParams.kt | 2 +- .../api/models/FeedbackDatasetItem.kt | 8 +- .../api/models/FeedbackExperimentItem.kt | 10 +- .../api/models/FeedbackProjectLogsItem.kt | 10 +- .../api/models/FeedbackResponseSchema.kt | 10 +- .../com/braintrustdata/api/models/Function.kt | 77 ++++-------- .../api/models/FunctionCreateParams.kt | 67 ++++------- .../api/models/FunctionInvokeParams.kt | 74 ++++-------- .../api/models/FunctionInvokeResponse.kt | 2 +- .../api/models/FunctionListPage.kt | 10 +- .../api/models/FunctionListPageAsync.kt | 17 +-- .../api/models/FunctionListParams.kt | 2 +- .../api/models/FunctionReplaceParams.kt | 67 ++++------- .../api/models/FunctionUpdateParams.kt | 49 +++----- .../api/models/GroupListPage.kt | 10 +- .../api/models/GroupListPageAsync.kt | 14 +-- .../api/models/GroupListParams.kt | 2 +- .../api/models/InsertDatasetEvent.kt | 2 +- .../api/models/InsertEventsResponse.kt | 2 +- .../api/models/InsertExperimentEvent.kt | 4 +- .../api/models/InsertProjectLogsEvent.kt | 4 +- .../api/models/OnlineScoreConfig.kt | 20 ++-- .../api/models/OrganizationListPage.kt | 13 +- .../api/models/OrganizationListPageAsync.kt | 17 +-- .../api/models/OrganizationListParams.kt | 2 +- .../models/PatchOrganizationMembersOutput.kt | 8 +- .../api/models/ProjectListPage.kt | 10 +- .../api/models/ProjectListPageAsync.kt | 17 +-- .../api/models/ProjectListParams.kt | 2 +- .../api/models/ProjectLogFeedbackParams.kt | 2 +- .../api/models/ProjectLogInsertParams.kt | 2 +- .../api/models/ProjectLogsEvent.kt | 19 +-- .../braintrustdata/api/models/ProjectScore.kt | 12 +- .../api/models/ProjectScoreConfig.kt | 16 +-- .../api/models/ProjectScoreCreateParams.kt | 12 +- .../api/models/ProjectScoreListPage.kt | 13 +- .../api/models/ProjectScoreListPageAsync.kt | 17 +-- .../api/models/ProjectScoreListParams.kt | 12 +- .../api/models/ProjectScoreReplaceParams.kt | 12 +- .../api/models/ProjectScoreUpdateParams.kt | 12 +- .../api/models/ProjectTagListPage.kt | 13 +- .../api/models/ProjectTagListPageAsync.kt | 17 +-- .../api/models/ProjectTagListParams.kt | 2 +- .../api/models/ProjectTagUpdateParams.kt | 7 +- .../api/models/ProjectUpdateParams.kt | 6 +- .../com/braintrustdata/api/models/Prompt.kt | 17 +-- .../api/models/PromptCreateParams.kt | 7 +- .../braintrustdata/api/models/PromptData.kt | 111 ++++++------------ .../api/models/PromptListPage.kt | 10 +- .../api/models/PromptListPageAsync.kt | 14 +-- .../api/models/PromptListParams.kt | 2 +- .../api/models/PromptOptions.kt | 57 ++++----- .../api/models/PromptReplaceParams.kt | 7 +- .../com/braintrustdata/api/models/Role.kt | 11 +- .../api/models/RoleCreateParams.kt | 17 +-- .../braintrustdata/api/models/RoleListPage.kt | 10 +- .../api/models/RoleListPageAsync.kt | 14 +-- .../api/models/RoleListParams.kt | 2 +- .../api/models/RoleReplaceParams.kt | 11 +- .../api/models/RoleUpdateParams.kt | 22 +--- .../api/models/SpanAttributes.kt | 13 +- .../api/models/SpanIframeListPage.kt | 13 +- .../api/models/SpanIframeListPageAsync.kt | 17 +-- .../api/models/SpanIframeListParams.kt | 2 +- .../api/models/SpanIframeUpdateParams.kt | 7 +- .../api/models/SummarizeExperimentResponse.kt | 4 +- .../braintrustdata/api/models/UserListPage.kt | 10 +- .../api/models/UserListPageAsync.kt | 14 +-- .../api/models/UserListParams.kt | 8 +- .../com/braintrustdata/api/models/View.kt | 12 +- .../api/models/ViewCreateParams.kt | 18 +-- .../api/models/ViewDeleteParams.kt | 6 +- .../braintrustdata/api/models/ViewListPage.kt | 10 +- .../api/models/ViewListPageAsync.kt | 14 +-- .../api/models/ViewListParams.kt | 14 +-- .../braintrustdata/api/models/ViewOptions.kt | 4 +- .../api/models/ViewReplaceParams.kt | 12 +- .../api/models/ViewRetrieveParams.kt | 6 +- .../api/models/ViewUpdateParams.kt | 12 +- .../api/services/async/AclServiceAsync.kt | 12 +- .../api/services/async/AclServiceAsyncImpl.kt | 18 ++- .../services/async/AiSecretServiceAsync.kt | 14 +-- .../async/AiSecretServiceAsyncImpl.kt | 20 ++-- .../api/services/async/ApiKeyServiceAsync.kt | 8 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 14 +-- .../api/services/async/DatasetServiceAsync.kt | 20 ++-- .../services/async/DatasetServiceAsyncImpl.kt | 26 ++-- .../api/services/async/EnvVarServiceAsync.kt | 12 +- .../services/async/EnvVarServiceAsyncImpl.kt | 18 ++- .../api/services/async/EvalServiceAsync.kt | 2 +- .../services/async/EvalServiceAsyncImpl.kt | 8 +- .../services/async/ExperimentServiceAsync.kt | 20 ++-- .../async/ExperimentServiceAsyncImpl.kt | 26 ++-- .../services/async/FunctionServiceAsync.kt | 14 +-- .../async/FunctionServiceAsyncImpl.kt | 20 ++-- .../api/services/async/GroupServiceAsync.kt | 12 +- .../services/async/GroupServiceAsyncImpl.kt | 18 ++- .../async/OrganizationServiceAsync.kt | 8 +- .../async/OrganizationServiceAsyncImpl.kt | 14 +-- .../async/ProjectScoreServiceAsync.kt | 12 +- .../async/ProjectScoreServiceAsyncImpl.kt | 18 ++- .../api/services/async/ProjectServiceAsync.kt | 10 +- .../services/async/ProjectServiceAsyncImpl.kt | 16 ++- .../services/async/ProjectTagServiceAsync.kt | 12 +- .../async/ProjectTagServiceAsyncImpl.kt | 18 ++- .../api/services/async/PromptServiceAsync.kt | 12 +- .../services/async/PromptServiceAsyncImpl.kt | 18 ++- .../api/services/async/RoleServiceAsync.kt | 12 +- .../services/async/RoleServiceAsyncImpl.kt | 18 ++- .../services/async/SpanIframeServiceAsync.kt | 12 +- .../async/SpanIframeServiceAsyncImpl.kt | 18 ++- .../services/async/TopLevelServiceAsync.kt | 2 +- .../async/TopLevelServiceAsyncImpl.kt | 8 +- .../api/services/async/UserServiceAsync.kt | 4 +- .../services/async/UserServiceAsyncImpl.kt | 10 +- .../api/services/async/ViewServiceAsync.kt | 12 +- .../services/async/ViewServiceAsyncImpl.kt | 18 ++- .../async/organizations/MemberServiceAsync.kt | 2 +- .../organizations/MemberServiceAsyncImpl.kt | 8 +- .../async/projects/LogServiceAsync.kt | 8 +- .../async/projects/LogServiceAsyncImpl.kt | 14 +-- .../api/services/blocking/AclService.kt | 8 +- .../api/services/blocking/AclServiceImpl.kt | 9 +- .../api/services/blocking/AiSecretService.kt | 14 +-- .../services/blocking/AiSecretServiceImpl.kt | 12 +- .../api/services/blocking/ApiKeyService.kt | 8 +- .../services/blocking/ApiKeyServiceImpl.kt | 8 +- .../api/services/blocking/DatasetService.kt | 20 ++-- .../services/blocking/DatasetServiceImpl.kt | 16 ++- .../api/services/blocking/EnvVarService.kt | 12 +- .../services/blocking/EnvVarServiceImpl.kt | 8 +- .../api/services/blocking/EvalService.kt | 2 +- .../api/services/blocking/EvalServiceImpl.kt | 7 +- .../services/blocking/ExperimentService.kt | 20 ++-- .../blocking/ExperimentServiceImpl.kt | 26 ++-- .../api/services/blocking/FunctionService.kt | 14 +-- .../services/blocking/FunctionServiceImpl.kt | 12 +- .../api/services/blocking/GroupService.kt | 12 +- .../api/services/blocking/GroupServiceImpl.kt | 6 +- .../services/blocking/OrganizationService.kt | 8 +- .../blocking/OrganizationServiceImpl.kt | 14 +-- .../services/blocking/ProjectScoreService.kt | 12 +- .../blocking/ProjectScoreServiceImpl.kt | 18 ++- .../api/services/blocking/ProjectService.kt | 10 +- .../services/blocking/ProjectServiceImpl.kt | 6 +- .../services/blocking/ProjectTagService.kt | 12 +- .../blocking/ProjectTagServiceImpl.kt | 18 ++- .../api/services/blocking/PromptService.kt | 12 +- .../services/blocking/PromptServiceImpl.kt | 6 +- .../api/services/blocking/RoleService.kt | 12 +- .../api/services/blocking/RoleServiceImpl.kt | 5 +- .../services/blocking/SpanIframeService.kt | 12 +- .../blocking/SpanIframeServiceImpl.kt | 18 ++- .../api/services/blocking/TopLevelService.kt | 2 +- .../services/blocking/TopLevelServiceImpl.kt | 8 +- .../api/services/blocking/UserService.kt | 4 +- .../api/services/blocking/UserServiceImpl.kt | 5 +- .../api/services/blocking/ViewService.kt | 12 +- .../api/services/blocking/ViewServiceImpl.kt | 5 +- .../blocking/organizations/MemberService.kt | 2 +- .../organizations/MemberServiceImpl.kt | 8 +- .../services/blocking/projects/LogService.kt | 8 +- .../blocking/projects/LogServiceImpl.kt | 13 +- .../braintrustdata/api/TestServerExtension.kt | 2 +- .../api/core/PhantomReachableTest.kt | 2 +- .../api/core/http/HeadersTest.kt | 64 +++++----- .../api/core/http/QueryParamsTest.kt | 50 ++++---- .../api/core/http/RetryingHttpClientTest.kt | 22 ++-- .../api/core/http/SerializerTest.kt | 11 +- .../api/models/AclListParamsTest.kt | 2 +- .../api/models/AiSecretListParamsTest.kt | 4 +- .../api/models/ApiKeyListParamsTest.kt | 2 +- .../models/CrossObjectInsertResponseTest.kt | 12 +- .../api/models/DatasetListParamsTest.kt | 2 +- .../api/models/EnvVarListParamsTest.kt | 2 +- .../api/models/ExperimentListParamsTest.kt | 2 +- .../api/models/FunctionListParamsTest.kt | 2 +- .../api/models/GroupListParamsTest.kt | 2 +- .../api/models/OrganizationListParamsTest.kt | 2 +- .../api/models/ProjectListParamsTest.kt | 2 +- .../api/models/ProjectScoreListParamsTest.kt | 4 +- .../api/models/ProjectTagListParamsTest.kt | 2 +- .../api/models/PromptListParamsTest.kt | 2 +- .../api/models/RoleListParamsTest.kt | 2 +- .../api/models/SpanIframeListParamsTest.kt | 2 +- .../models/SummarizeExperimentResponseTest.kt | 8 +- .../api/models/UserListParamsTest.kt | 2 +- .../api/models/ViewListParamsTest.kt | 2 +- .../api/services/ErrorHandlingTest.kt | 16 +-- buildSrc/build.gradle.kts | 6 +- .../main/kotlin/braintrust.java.gradle.kts | 6 +- .../main/kotlin/braintrust.kotlin.gradle.kts | 11 +- gradle.properties | 4 +- scripts/format | 2 +- scripts/lint | 2 +- scripts/test | 2 +- 262 files changed, 1129 insertions(+), 1938 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index 60b45b95..e5c36439 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -31,10 +31,7 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) return try { @@ -120,13 +117,13 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val ) { builder.header( "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString() + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { builder.header( "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString() + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index 544e4880..fd5d5299 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -43,9 +43,7 @@ import com.braintrustdata.api.services.async.UserServiceAsyncImpl import com.braintrustdata.api.services.async.ViewServiceAsync import com.braintrustdata.api.services.async.ViewServiceAsyncImpl -class BraintrustClientAsyncImpl( - private val clientOptions: ClientOptions, -) : BraintrustClientAsync { +class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : BraintrustClientAsync { private val clientOptionsWithUserAgent = if (clientOptions.headers.names().contains("User-Agent")) clientOptions diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index 2c8268d1..e0b76da7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -43,9 +43,7 @@ import com.braintrustdata.api.services.blocking.UserServiceImpl import com.braintrustdata.api.services.blocking.ViewService import com.braintrustdata.api.services.blocking.ViewServiceImpl -class BraintrustClientImpl( - private val clientOptions: ClientOptions, -) : BraintrustClient { +class BraintrustClientImpl(private val clientOptions: ClientOptions) : BraintrustClient { private val clientOptionsWithUserAgent = if (clientOptions.headers.names().contains("User-Agent")) clientOptions diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt index a38e39bd..64d8a5b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt @@ -18,7 +18,7 @@ abstract class BaseDeserializer(type: KClass) : override fun createContextual( context: DeserializationContext, - property: BeanProperty? + property: BeanProperty?, ): JsonDeserializer { return this } @@ -32,7 +32,7 @@ abstract class BaseDeserializer(type: KClass) : protected fun ObjectCodec.tryDeserialize( node: JsonNode, type: TypeReference, - validate: (T) -> Unit = {} + validate: (T) -> Unit = {}, ): T? { return try { readValue(treeAsTokens(node), type).apply(validate) @@ -46,7 +46,7 @@ abstract class BaseDeserializer(type: KClass) : protected fun ObjectCodec.tryDeserialize( node: JsonNode, type: JavaType, - validate: (T) -> Unit = {} + validate: (T) -> Unit = {}, ): T? { return try { readValue(treeAsTokens(node), type).apply(validate) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt index 65052ee1..6cadab0b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt @@ -10,10 +10,7 @@ import java.io.OutputStream import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder @JvmSynthetic -internal inline fun json( - jsonMapper: JsonMapper, - value: T, -): HttpRequestBody { +internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody { return object : HttpRequestBody { private var cachedBytes: ByteArray? = null @@ -49,7 +46,7 @@ internal inline fun json( @JvmSynthetic internal fun multipartFormData( jsonMapper: JsonMapper, - parts: Array?> + parts: Array?>, ): HttpRequestBody { val builder = MultipartEntityBuilder.create() parts.forEach { part -> @@ -66,14 +63,14 @@ internal fun multipartFormData( part.name, buffer.toByteArray(), part.contentType, - part.filename + part.filename, ) } is Boolean -> builder.addTextBody( part.name, if (part.value) "true" else "false", - part.contentType + part.contentType, ) is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt index 5df92543..e9aaadff 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt @@ -17,7 +17,7 @@ internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): @JvmSynthetic internal fun HttpRequest.prepareAsync( clientOptions: ClientOptions, - params: Params + params: Params, ): CompletableFuture = // This async version exists to make it easier to add async specific preparation logic in the // future. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt index ff946373..d89e0590 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt @@ -2,11 +2,7 @@ package com.braintrustdata.api.core import java.time.Duration -class RequestOptions -private constructor( - val responseValidation: Boolean?, - val timeout: Duration?, -) { +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Duration?) { fun applyDefaults(options: RequestOptions): RequestOptions { return RequestOptions( responseValidation = this.responseValidation ?: options.responseValidation, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 89e4dc64..2442514d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -287,7 +287,7 @@ class JsonMissing : JsonValue() { override fun serialize( value: JsonMissing, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { throw RuntimeException("JsonMissing cannot be serialized") } @@ -422,10 +422,7 @@ private constructor( } @JacksonAnnotationsInside -@JsonInclude( - JsonInclude.Include.CUSTOM, - valueFilter = JsonField.IsMissing::class, -) +@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) annotation class ExcludeMissing @JacksonAnnotationsInside @@ -434,7 +431,7 @@ annotation class ExcludeMissing isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE + fieldVisibility = Visibility.NONE, ) annotation class NoAutoDetect @@ -443,7 +440,7 @@ internal constructor( val name: String, val value: T, val contentType: ContentType, - val filename: String? = null + val filename: String? = null, ) { private var hashCode: Int = 0 @@ -462,7 +459,7 @@ internal constructor( is Long -> value is Double -> value else -> value?.hashCode() - } + }, ) } return hashCode @@ -496,7 +493,7 @@ internal constructor( internal fun fromString( name: String, value: String, - contentType: ContentType + contentType: ContentType, ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromBoolean( @@ -520,14 +517,14 @@ internal constructor( internal fun fromEnum( name: String, value: T, - contentType: ContentType + contentType: ContentType, ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromByteArray( name: String, value: ByteArray, contentType: ContentType, - filename: String? = null + filename: String? = null, ): MultipartFormValue = MultipartFormValue(name, value, contentType, filename) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt index d5795453..6d37e804 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt @@ -6,7 +6,7 @@ import java.util.TreeMap class Headers private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() @@ -74,7 +74,7 @@ private constructor( values.toImmutable() } .toImmutable(), - size + size, ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt index efd180a9..e766e040 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt @@ -19,7 +19,7 @@ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpCli override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture = httpClient.executeAsync(request, requestOptions) override fun close() = httpClient.close() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt index 1604872d..215eea16 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt @@ -5,7 +5,7 @@ import com.braintrustdata.api.core.toImmutable class QueryParams private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 2fbb8396..56bdac87 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -28,10 +28,7 @@ private constructor( private val idempotencyHeader: String?, ) : HttpClient { - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) } @@ -100,7 +97,7 @@ private constructor( .handleAsync( fun( response: HttpResponse?, - throwable: Throwable? + throwable: Throwable?, ): CompletableFuture { if (response != null) { if (++retries > maxRetries || !shouldRetry(response)) { @@ -120,7 +117,7 @@ private constructor( return sleepAsync(backoffMillis.toMillis()).thenCompose { executeWithRetries(requestWithRetryCount, requestOptions) } - }, + } ) { // Run in the same thread. it.run() @@ -200,8 +197,8 @@ private constructor( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, - DateTimeFormatter.RFC_1123_DATE_TIME - ) + DateTimeFormatter.RFC_1123_DATE_TIME, + ), ) } catch (e: DateTimeParseException) { null @@ -239,7 +236,7 @@ private constructor( future.complete(null) } }, - millis + millis, ) return future } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt index 07641724..b8c65254 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class BadRequestException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(400, headers, body, error) +class BadRequestException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(400, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index 4712bd76..b1f14ed8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -20,7 +20,7 @@ private constructor( @ExcludeMissing @JsonAnySetter @get:JvmName("additionalProperties") - val additionalProperties: Map = immutableEmptyMap(), + val additionalProperties: Map = immutableEmptyMap() ) { fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt index 5c545f07..728ac6bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt @@ -10,7 +10,7 @@ constructor( private val body: String, private val error: BraintrustError, message: String = "$statusCode: $error", - cause: Throwable? = null + cause: Throwable? = null, ) : BraintrustException(message, cause) { fun statusCode(): Int = statusCode diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt index f99a4eed..ecc1a307 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class NotFoundException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(404, headers, body, error) +class NotFoundException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(404, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt index 7f7ea797..27380e3e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class PermissionDeniedException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(403, headers, body, error) +class PermissionDeniedException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(403, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt index 59a00393..a9352a3a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class RateLimitException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(429, headers, body, error) +class RateLimitException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(429, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt index 8bc7c82e..57f9242f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class UnauthorizedException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(401, headers, body, error) +class UnauthorizedException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(401, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt index 35dad36e..6e216b4e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class UnprocessableEntityException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(422, headers, body, error) +class UnprocessableEntityException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(422, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index a1b84877..f69ebc24 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -215,7 +215,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter 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 c9b17129..434a78f4 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 @@ -363,11 +363,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -512,11 +508,7 @@ private constructor( } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -648,9 +640,7 @@ private constructor( */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 4bfabd52..26fd6110 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 @@ -920,11 +920,8 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1070,11 +1067,8 @@ private constructor( } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1207,9 +1201,7 @@ private constructor( */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1678,11 +1670,8 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1828,11 +1817,8 @@ private constructor( } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1965,9 +1951,7 @@ private constructor( */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 7a01698a..eb221d16 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 @@ -656,19 +656,11 @@ private constructor( } fun build(): AclCreateParams = - AclCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + 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 { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -813,11 +805,7 @@ private constructor( } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -949,9 +937,7 @@ private constructor( */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 252fd873..b07b4e96 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 @@ -661,11 +661,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -810,11 +806,7 @@ private constructor( } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -946,9 +938,7 @@ private constructor( */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index 4f437d03..98db6fd8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -77,11 +77,7 @@ private constructor( @JvmStatic fun of(aclsService: AclService, params: AclListParams, response: Response) = - AclListPage( - aclsService, - params, - response, - ) + AclListPage(aclsService, params, response) } @NoAutoDetect @@ -156,9 +152,7 @@ private constructor( } } - class AutoPager( - private val firstPage: AclListPage, - ) : Iterable { + class AutoPager(private val firstPage: AclListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index 8c7986b3..ae704c5c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -80,11 +80,7 @@ private constructor( @JvmStatic fun of(aclsService: AclServiceAsync, params: AclListParams, response: Response) = - AclListPageAsync( - aclsService, - params, - response, - ) + AclListPageAsync(aclsService, params, response) } @NoAutoDetect @@ -159,14 +155,12 @@ private constructor( } } - class AutoPager( - private val firstPage: AclListPageAsync, - ) { + class AutoPager(private val firstPage: AclListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Acl) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -175,7 +169,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) 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 faf2beeb..93c0dc48 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 @@ -313,11 +313,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -563,7 +559,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index dff8800a..009c5e73 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -506,7 +506,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index 771e6960..5919487c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -83,11 +83,7 @@ private constructor( @JvmStatic fun of(aiSecretsService: AiSecretService, params: AiSecretListParams, response: Response) = - AiSecretListPage( - aiSecretsService, - params, - response, - ) + AiSecretListPage(aiSecretsService, params, response) } @NoAutoDetect @@ -162,9 +158,7 @@ private constructor( } } - class AutoPager( - private val firstPage: AiSecretListPage, - ) : Iterable { + class AutoPager(private val firstPage: AiSecretListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 76bd74f3..ae18f256 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( aiSecretsService: AiSecretServiceAsync, params: AiSecretListParams, - response: Response - ) = - AiSecretListPageAsync( - aiSecretsService, - params, - response, - ) + response: Response, + ) = AiSecretListPageAsync(aiSecretsService, params, response) } @NoAutoDetect @@ -169,14 +164,12 @@ private constructor( } } - class AutoPager( - private val firstPage: AiSecretListPageAsync, - ) { + class AutoPager(private val firstPage: AiSecretListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (AISecret) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -185,7 +178,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 402fb4cf..b1fee508 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -433,7 +433,7 @@ private constructor( override fun serialize( value: AiSecretType, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) @@ -547,7 +547,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index a1a01520..8af3e1ff 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -506,7 +506,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index c5c38aa5..a0320d60 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -201,13 +201,7 @@ private constructor( } fun build(): AiSecretUpdateBody = - AiSecretUpdateBody( - metadata, - name, - secret, - type, - additionalProperties.toImmutable(), - ) + AiSecretUpdateBody(metadata, name, secret, type, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -413,7 +407,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 846d2563..0b1f6fef 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -77,11 +77,7 @@ private constructor( @JvmStatic fun of(apiKeysService: ApiKeyService, params: ApiKeyListParams, response: Response) = - ApiKeyListPage( - apiKeysService, - params, - response, - ) + ApiKeyListPage(apiKeysService, params, response) } @NoAutoDetect @@ -156,9 +152,7 @@ private constructor( } } - class AutoPager( - private val firstPage: ApiKeyListPage, - ) : Iterable { + class AutoPager(private val firstPage: ApiKeyListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index 1e9dfbd6..3220ac2f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -80,11 +80,7 @@ private constructor( @JvmStatic fun of(apiKeysService: ApiKeyServiceAsync, params: ApiKeyListParams, response: Response) = - ApiKeyListPageAsync( - apiKeysService, - params, - response, - ) + ApiKeyListPageAsync(apiKeysService, params, response) } @NoAutoDetect @@ -159,14 +155,12 @@ private constructor( } } - class AutoPager( - private val firstPage: ApiKeyListPageAsync, - ) { + class AutoPager(private val firstPage: ApiKeyListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (ApiKey) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -175,7 +169,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index c641baca..649765d6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -416,7 +416,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index df858b7b..732ac18c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -196,18 +196,10 @@ private constructor( } fun build(): ImageUrl = - ImageUrl( - checkRequired("url", url), - detail, - additionalProperties.toImmutable(), - ) + ImageUrl(checkRequired("url", url), detail, additionalProperties.toImmutable()) } - class Detail - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Detail @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -321,11 +313,7 @@ private constructor( "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -346,7 +334,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - IMAGE_URL, + IMAGE_URL } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index fd421416..eb1db215 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -108,11 +108,7 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -133,7 +129,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - TEXT, + TEXT } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 26594d72..0f0ee94c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -234,11 +234,7 @@ private constructor( "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -259,7 +255,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index b7f16dd4..0cc68cc4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -292,7 +292,7 @@ private constructor( override fun serialize( value: Location, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.experiment != null -> generator.writeObject(value.experiment) @@ -546,7 +546,7 @@ private constructor( override fun serialize( value: Position, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.type != null -> generator.writeObject(value.type) @@ -639,9 +639,7 @@ private constructor( class InnerType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -663,7 +661,7 @@ private constructor( /** An enum containing [InnerType]'s known values. */ enum class Known { - TASK, + TASK } /** @@ -850,9 +848,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -874,7 +870,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - SCORER, + SCORER } /** @@ -958,11 +954,8 @@ private constructor( } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -983,7 +976,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - EXPERIMENT, + EXPERIMENT } /** @@ -1161,11 +1154,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1186,7 +1176,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** @@ -1362,11 +1352,8 @@ private constructor( ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index 055f0e83..fbba8639 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -159,7 +159,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -238,7 +238,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -317,7 +317,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index de709547..59ba3a7c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -97,7 +97,7 @@ private constructor( fun build(): DataSummary = DataSummary( checkRequired("totalRecords", totalRecords), - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 2db02449..a128199b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -254,7 +254,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 92780096..78a46026 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -419,7 +419,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index dd7edd64..6b3eac17 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -436,7 +436,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -653,11 +653,8 @@ private constructor( } /** Type of the object the event is originating from. */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 4cf3b15a..3d9778cf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -153,7 +153,7 @@ private constructor( fun build(): DatasetFeedbackBody = DatasetFeedbackBody( checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 234bd79f..35984246 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -153,7 +153,7 @@ private constructor( fun build(): DatasetInsertBody = DatasetInsertBody( checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index 532b9e08..df8d57fb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -83,11 +83,7 @@ private constructor( @JvmStatic fun of(datasetsService: DatasetService, params: DatasetListParams, response: Response) = - DatasetListPage( - datasetsService, - params, - response, - ) + DatasetListPage(datasetsService, params, response) } @NoAutoDetect @@ -162,9 +158,7 @@ private constructor( } } - class AutoPager( - private val firstPage: DatasetListPage, - ) : Iterable { + class AutoPager(private val firstPage: DatasetListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index e8d3d34a..8a94e372 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( datasetsService: DatasetServiceAsync, params: DatasetListParams, - response: Response - ) = - DatasetListPageAsync( - datasetsService, - params, - response, - ) + response: Response, + ) = DatasetListPageAsync(datasetsService, params, response) } @NoAutoDetect @@ -169,14 +164,12 @@ private constructor( } } - class AutoPager( - private val firstPage: DatasetListPageAsync, - ) { + class AutoPager(private val firstPage: DatasetListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Dataset) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -185,7 +178,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index fd0395c1..550f2cde 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -444,7 +444,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 9b5950db..22e60d26 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -200,12 +200,7 @@ private constructor( } fun build(): DatasetUpdateBody = - DatasetUpdateBody( - description, - metadata, - name, - additionalProperties.toImmutable(), - ) + DatasetUpdateBody(description, metadata, name, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -412,7 +407,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 4ef7096d..2dc9bd7e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -202,11 +202,7 @@ private constructor( } /** The type of the object the environment variable is scoped for */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index a441ab30..f4f956fd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -409,11 +409,7 @@ private constructor( } /** The type of the object the environment variable is scoped for */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 850813c0..ad3830af 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 @@ -368,7 +368,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) @@ -381,11 +381,7 @@ private constructor( } /** The type of the object the environment variable is scoped for */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 9fffe418..9228eebe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -110,7 +110,7 @@ private constructor( fun build(): EnvVarListResponse = EnvVarListResponse( checkRequired("objects", objects).map { it.toImmutable() }, - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index e74d281e..40de51c8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -409,11 +409,7 @@ private constructor( } /** The type of the object the environment variable is scoped for */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index bb4bde1d..5fbff021 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -1284,11 +1284,7 @@ private constructor( } fun build(): EvalCreateParams = - EvalCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + EvalCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } /** The dataset to use */ @@ -1425,7 +1421,7 @@ private constructor( override fun serialize( value: Data, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.datasetId != null -> generator.writeObject(value.datasetId) @@ -1518,7 +1514,7 @@ private constructor( fun build(): DatasetId = DatasetId( checkRequired("datasetId", datasetId), - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } @@ -1902,7 +1898,7 @@ private constructor( override fun serialize( value: Score, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.functionId != null -> generator.writeObject(value.functionId) @@ -2292,7 +2288,7 @@ private constructor( fun build(): GlobalFunction = GlobalFunction( checkRequired("globalFunction", globalFunction), - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } @@ -2698,9 +2694,7 @@ private constructor( class Runtime @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -3201,7 +3195,7 @@ private constructor( override fun serialize( value: Task, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.functionId != null -> generator.writeObject(value.functionId) @@ -3591,7 +3585,7 @@ private constructor( fun build(): GlobalFunction = GlobalFunction( checkRequired("globalFunction", globalFunction), - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } @@ -3997,9 +3991,7 @@ private constructor( class Runtime @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -4378,11 +4370,8 @@ private constructor( ) } - class Collect - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Collect @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -4478,11 +4467,7 @@ private constructor( override fun toString() = value.toString() } - class Field - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Field @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -4641,7 +4626,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 964fcd1f..f125e24c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -423,7 +423,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 7dad203e..0b90945f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -809,7 +809,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index 53e1f675..076b0833 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -943,7 +943,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1505,11 +1505,8 @@ private constructor( } /** Type of the object the event is originating from. */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1656,7 +1653,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index a7ee93f5..077c9861 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -153,7 +153,7 @@ private constructor( fun build(): ExperimentFeedbackBody = ExperimentFeedbackBody( checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 6acaea61..1a7c1d8e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -153,7 +153,7 @@ private constructor( fun build(): ExperimentInsertBody = ExperimentInsertBody( checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index de9aff31..53a6e31c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -85,13 +85,8 @@ private constructor( fun of( experimentsService: ExperimentService, params: ExperimentListParams, - response: Response - ) = - ExperimentListPage( - experimentsService, - params, - response, - ) + response: Response, + ) = ExperimentListPage(experimentsService, params, response) } @NoAutoDetect @@ -167,9 +162,7 @@ private constructor( } } - class AutoPager( - private val firstPage: ExperimentListPage, - ) : Iterable { + class AutoPager(private val firstPage: ExperimentListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index 63d7b8ac..b4b530d3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( experimentsService: ExperimentServiceAsync, params: ExperimentListParams, - response: Response - ) = - ExperimentListPageAsync( - experimentsService, - params, - response, - ) + response: Response, + ) = ExperimentListPageAsync(experimentsService, params, response) } @NoAutoDetect @@ -170,14 +165,12 @@ private constructor( } } - class AutoPager( - private val firstPage: ExperimentListPageAsync, - ) { + class AutoPager(private val firstPage: ExperimentListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Experiment) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -186,7 +179,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index d51ea84a..d3d4277b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -445,7 +445,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 9978756e..b8397e4b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -701,7 +701,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 2821649e..25b354ff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -245,7 +245,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -319,11 +319,7 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Source @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index 9abb9867..71c42a9b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -298,7 +298,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -380,7 +380,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -454,11 +454,7 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Source @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 7f7fbb08..9f9b909c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -298,7 +298,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -380,7 +380,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -454,11 +454,7 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Source @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index 9268d6bc..8c3567a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -92,15 +92,11 @@ private constructor( fun build(): FeedbackResponseSchema = FeedbackResponseSchema( checkRequired("status", status), - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -121,7 +117,7 @@ private constructor( /** An enum containing [Status]'s known values. */ enum class Known { - SUCCESS, + SUCCESS } /** 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 42e7a83b..f2bdc4c3 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 @@ -603,7 +603,7 @@ private constructor( override fun serialize( value: FunctionData, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.prompt != null -> generator.writeObject(value.prompt) @@ -694,11 +694,8 @@ private constructor( Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -719,7 +716,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT, + PROMPT } /** @@ -1026,7 +1023,7 @@ private constructor( override fun serialize( value: Data, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.bundle != null -> generator.writeObject(value.bundle) @@ -1223,9 +1220,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1247,7 +1242,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE, + BUNDLE } /** @@ -1559,9 +1554,7 @@ private constructor( class Runtime @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1679,9 +1672,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1703,7 +1694,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE, + INLINE } /** @@ -1787,11 +1778,8 @@ private constructor( } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1812,7 +1800,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE, + CODE } /** @@ -1990,11 +1978,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2015,7 +2000,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** @@ -2098,11 +2083,7 @@ private constructor( } /** A literal 'p' which identifies the object as a project prompt */ - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -2123,7 +2104,7 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - P, + P } /** @@ -2260,11 +2241,7 @@ private constructor( } fun build(): FunctionSchema = - FunctionSchema( - parameters, - returns, - additionalProperties.toImmutable(), - ) + FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2285,11 +2262,8 @@ private constructor( "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2397,7 +2371,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -2622,11 +2596,8 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. 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 43ce5e69..0565a1df 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 @@ -820,7 +820,7 @@ private constructor( override fun serialize( value: FunctionData, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.prompt != null -> generator.writeObject(value.prompt) @@ -911,11 +911,8 @@ private constructor( Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -936,7 +933,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT, + PROMPT } /** @@ -1243,7 +1240,7 @@ private constructor( override fun serialize( value: Data, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.bundle != null -> generator.writeObject(value.bundle) @@ -1440,9 +1437,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1464,7 +1459,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE, + BUNDLE } /** @@ -1776,9 +1771,7 @@ private constructor( class Runtime @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1896,9 +1889,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1920,7 +1911,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE, + INLINE } /** @@ -2004,11 +1995,8 @@ private constructor( } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2029,7 +2017,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE, + CODE } /** @@ -2207,11 +2195,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2232,7 +2217,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** @@ -2390,11 +2375,7 @@ private constructor( } fun build(): FunctionSchema = - FunctionSchema( - parameters, - returns, - additionalProperties.toImmutable(), - ) + FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2415,11 +2396,8 @@ private constructor( "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2673,11 +2651,8 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index c8168be4..84b8ebbe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -806,7 +806,7 @@ private constructor( override fun serialize( value: Message, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.system != null -> generator.writeObject(value.system) @@ -933,11 +933,8 @@ private constructor( ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -958,7 +955,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - SYSTEM, + SYSTEM } /** @@ -1156,11 +1153,8 @@ private constructor( ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1181,7 +1175,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - USER, + USER } /** @@ -1369,7 +1363,7 @@ private constructor( override fun serialize( value: Content, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.text != null -> generator.writeObject(value.text) @@ -1525,7 +1519,7 @@ private constructor( override fun serialize( value: ChatCompletionContentPart, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.text != null -> generator.writeObject(value.text) @@ -1735,11 +1729,8 @@ private constructor( ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1760,7 +1751,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - ASSISTANT, + ASSISTANT } /** @@ -2077,11 +2068,8 @@ private constructor( ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2102,7 +2090,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - TOOL, + TOOL } /** @@ -2295,11 +2283,8 @@ private constructor( ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2320,7 +2305,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** @@ -2500,11 +2485,8 @@ private constructor( ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2525,7 +2507,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - MODEL, + MODEL } /** @@ -2608,11 +2590,7 @@ private constructor( } /** The mode format of the returned value (defaults to 'auto') */ - class Mode - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Mode @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -2830,7 +2808,7 @@ private constructor( override fun serialize( value: Parent, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) @@ -3000,9 +2978,7 @@ private constructor( class ObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -3099,7 +3075,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 835ed858..602cdae8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -16,7 +16,7 @@ import java.util.Objects class FunctionInvokeResponse @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index e6a195bf..cbc7dd3b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -83,11 +83,7 @@ private constructor( @JvmStatic fun of(functionsService: FunctionService, params: FunctionListParams, response: Response) = - FunctionListPage( - functionsService, - params, - response, - ) + FunctionListPage(functionsService, params, response) } @NoAutoDetect @@ -162,9 +158,7 @@ private constructor( } } - class AutoPager( - private val firstPage: FunctionListPage, - ) : Iterable { + class AutoPager(private val firstPage: FunctionListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 6fe2a2d9..fae52ba9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( functionsService: FunctionServiceAsync, params: FunctionListParams, - response: Response - ) = - FunctionListPageAsync( - functionsService, - params, - response, - ) + response: Response, + ) = FunctionListPageAsync(functionsService, params, response) } @NoAutoDetect @@ -169,14 +164,12 @@ private constructor( } } - class AutoPager( - private val firstPage: FunctionListPageAsync, - ) { + class AutoPager(private val firstPage: FunctionListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Function) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -185,7 +178,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 581a6807..f458f679 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -487,7 +487,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) 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 7cc5822d..b6b2b90d 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 @@ -820,7 +820,7 @@ private constructor( override fun serialize( value: FunctionData, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.prompt != null -> generator.writeObject(value.prompt) @@ -911,11 +911,8 @@ private constructor( Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -936,7 +933,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT, + PROMPT } /** @@ -1243,7 +1240,7 @@ private constructor( override fun serialize( value: Data, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.bundle != null -> generator.writeObject(value.bundle) @@ -1440,9 +1437,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1464,7 +1459,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE, + BUNDLE } /** @@ -1776,9 +1771,7 @@ private constructor( class Runtime @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1896,9 +1889,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1920,7 +1911,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE, + INLINE } /** @@ -2004,11 +1995,8 @@ private constructor( } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2029,7 +2017,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE, + CODE } /** @@ -2207,11 +2195,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2232,7 +2217,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** @@ -2390,11 +2375,7 @@ private constructor( } fun build(): FunctionSchema = - FunctionSchema( - parameters, - returns, - additionalProperties.toImmutable(), - ) + FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2415,11 +2396,8 @@ private constructor( "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2673,11 +2651,8 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 49dd90a1..20a52674 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -700,7 +700,7 @@ private constructor( override fun serialize( value: FunctionData, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.prompt != null -> generator.writeObject(value.prompt) @@ -792,11 +792,8 @@ private constructor( Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -817,7 +814,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT, + PROMPT } /** @@ -1124,7 +1121,7 @@ private constructor( override fun serialize( value: Data, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.bundle != null -> generator.writeObject(value.bundle) @@ -1321,9 +1318,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1345,7 +1340,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE, + BUNDLE } /** @@ -1657,9 +1652,7 @@ private constructor( class Runtime @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1777,9 +1770,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1801,7 +1792,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE, + INLINE } /** @@ -1885,11 +1876,8 @@ private constructor( } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1910,7 +1898,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE, + CODE } /** @@ -2088,11 +2076,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2113,7 +2098,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** @@ -2199,7 +2184,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 928ff615..6c40d306 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -77,11 +77,7 @@ private constructor( @JvmStatic fun of(groupsService: GroupService, params: GroupListParams, response: Response) = - GroupListPage( - groupsService, - params, - response, - ) + GroupListPage(groupsService, params, response) } @NoAutoDetect @@ -156,9 +152,7 @@ private constructor( } } - class AutoPager( - private val firstPage: GroupListPage, - ) : Iterable { + class AutoPager(private val firstPage: GroupListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index 8c473bfe..8aaa5521 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -80,11 +80,7 @@ private constructor( @JvmStatic fun of(groupsService: GroupServiceAsync, params: GroupListParams, response: Response) = - GroupListPageAsync( - groupsService, - params, - response, - ) + GroupListPageAsync(groupsService, params, response) } @NoAutoDetect @@ -159,14 +155,12 @@ private constructor( } } - class AutoPager( - private val firstPage: GroupListPageAsync, - ) { + class AutoPager(private val firstPage: GroupListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Group) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -175,7 +169,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 0010b69e..68722b89 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -416,7 +416,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index 11fc83da..ee1ad30e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -948,7 +948,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index d057d704..37dfc296 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -123,7 +123,7 @@ private constructor( fun build(): InsertEventsResponse = InsertEventsResponse( checkRequired("rowIds", rowIds).map { it.toImmutable() }, - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index adeac0f2..a7befd2e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -1392,7 +1392,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1824,7 +1824,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index 6b33a1a6..3974ac51 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -1340,7 +1340,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1772,7 +1772,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 7f1799d4..294f7fd2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -354,7 +354,7 @@ private constructor( override fun serialize( value: Scorer, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.function != null -> generator.writeObject(value.function) @@ -462,11 +462,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -487,7 +484,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** @@ -665,11 +662,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -690,7 +684,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index f347b31b..57326a65 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -85,13 +85,8 @@ private constructor( fun of( organizationsService: OrganizationService, params: OrganizationListParams, - response: Response - ) = - OrganizationListPage( - organizationsService, - params, - response, - ) + response: Response, + ) = OrganizationListPage(organizationsService, params, response) } @NoAutoDetect @@ -167,9 +162,7 @@ private constructor( } } - class AutoPager( - private val firstPage: OrganizationListPage, - ) : Iterable { + class AutoPager(private val firstPage: OrganizationListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index e5ab24f5..6fea0dce 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( organizationsService: OrganizationServiceAsync, params: OrganizationListParams, - response: Response - ) = - OrganizationListPageAsync( - organizationsService, - params, - response, - ) + response: Response, + ) = OrganizationListPageAsync(organizationsService, params, response) } @NoAutoDetect @@ -170,14 +165,12 @@ private constructor( } } - class AutoPager( - private val firstPage: OrganizationListPageAsync, - ) { + class AutoPager(private val firstPage: OrganizationListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Organization) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -186,7 +179,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 325a6b2b..9d8b7263 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -402,7 +402,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 0ceee718..4f8446c8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -159,11 +159,7 @@ private constructor( ) } - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -184,7 +180,7 @@ private constructor( /** An enum containing [Status]'s known values. */ enum class Known { - SUCCESS, + SUCCESS } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index 7ed60f96..a7870a50 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -83,11 +83,7 @@ private constructor( @JvmStatic fun of(projectsService: ProjectService, params: ProjectListParams, response: Response) = - ProjectListPage( - projectsService, - params, - response, - ) + ProjectListPage(projectsService, params, response) } @NoAutoDetect @@ -162,9 +158,7 @@ private constructor( } } - class AutoPager( - private val firstPage: ProjectListPage, - ) : Iterable { + class AutoPager(private val firstPage: ProjectListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 1fcb984b..1318884a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( projectsService: ProjectServiceAsync, params: ProjectListParams, - response: Response - ) = - ProjectListPageAsync( - projectsService, - params, - response, - ) + response: Response, + ) = ProjectListPageAsync(projectsService, params, response) } @NoAutoDetect @@ -169,14 +164,12 @@ private constructor( } } - class AutoPager( - private val firstPage: ProjectListPageAsync, - ) { + class AutoPager(private val firstPage: ProjectListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Project) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -185,7 +178,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index a3099c06..2cd2c10a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -416,7 +416,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 3ed038e0..eb3857e5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -153,7 +153,7 @@ private constructor( fun build(): ProjectLogFeedbackBody = ProjectLogFeedbackBody( checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 264010df..9220b6d1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -153,7 +153,7 @@ private constructor( fun build(): ProjectLogInsertBody = ProjectLogInsertBody( checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 351a1817..272eb81e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -718,11 +718,7 @@ private constructor( } /** A literal 'g' which identifies the log as a project log */ - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -743,7 +739,7 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - G, + G } /** @@ -993,7 +989,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1555,11 +1551,8 @@ private constructor( } /** Type of the object the event is originating from. */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1706,7 +1699,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter 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 c0fc104b..b4e81b59 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 @@ -302,11 +302,7 @@ private constructor( } /** The type of the configured score */ - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -602,7 +598,7 @@ private constructor( override fun serialize( value: Categories, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.categorical != null -> generator.writeObject(value.categorical) @@ -621,7 +617,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -702,7 +698,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index ecdf62c2..808c09c0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -136,19 +136,11 @@ private constructor( } fun build(): ProjectScoreConfig = - ProjectScoreConfig( - destination, - multiSelect, - online, - additionalProperties.toImmutable(), - ) + ProjectScoreConfig(destination, multiSelect, online, additionalProperties.toImmutable()) } - class Destination - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Destination @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -169,7 +161,7 @@ private constructor( /** An enum containing [Destination]'s known values. */ enum class Known { - EXPECTED, + EXPECTED } /** 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 f2a700a4..b010fd53 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 @@ -521,11 +521,7 @@ private constructor( } /** The type of the configured score */ - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -821,7 +817,7 @@ private constructor( override fun serialize( value: Categories, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.categorical != null -> generator.writeObject(value.categorical) @@ -840,7 +836,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -921,7 +917,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index 10e8bdea..8931ebb4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -85,13 +85,8 @@ private constructor( fun of( projectScoresService: ProjectScoreService, params: ProjectScoreListParams, - response: Response - ) = - ProjectScoreListPage( - projectScoresService, - params, - response, - ) + response: Response, + ) = ProjectScoreListPage(projectScoresService, params, response) } @NoAutoDetect @@ -167,9 +162,7 @@ private constructor( } } - class AutoPager( - private val firstPage: ProjectScoreListPage, - ) : Iterable { + class AutoPager(private val firstPage: ProjectScoreListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index 8f2d5398..b6e95b97 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( projectScoresService: ProjectScoreServiceAsync, params: ProjectScoreListParams, - response: Response - ) = - ProjectScoreListPageAsync( - projectScoresService, - params, - response, - ) + response: Response, + ) = ProjectScoreListPageAsync(projectScoresService, params, response) } @NoAutoDetect @@ -170,14 +165,12 @@ private constructor( } } - class AutoPager( - private val firstPage: ProjectScoreListPageAsync, - ) { + class AutoPager(private val firstPage: ProjectScoreListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (ProjectScore) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -186,7 +179,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) 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 2ad5f16c..6fc3408e 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 @@ -471,7 +471,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) @@ -597,7 +597,7 @@ private constructor( override fun serialize( value: ScoreType, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.project != null -> generator.writeObject(value.project) @@ -612,9 +612,7 @@ private constructor( /** The type of the configured score */ class ProjectScoreType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -733,9 +731,7 @@ private constructor( /** The type of the configured score */ class ProjectScoreType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 5439a1c4..920f7593 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 @@ -522,11 +522,7 @@ private constructor( } /** The type of the configured score */ - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -822,7 +818,7 @@ private constructor( override fun serialize( value: Categories, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.categorical != null -> generator.writeObject(value.categorical) @@ -841,7 +837,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -922,7 +918,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter 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 73dd76e3..a98320f1 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 @@ -702,7 +702,7 @@ private constructor( override fun serialize( value: Categories, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.categorical != null -> generator.writeObject(value.categorical) @@ -721,7 +721,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -802,7 +802,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -880,11 +880,7 @@ private constructor( } /** The type of the configured score */ - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 29cc199a..9dfbf8e9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -85,13 +85,8 @@ private constructor( fun of( projectTagsService: ProjectTagService, params: ProjectTagListParams, - response: Response - ) = - ProjectTagListPage( - projectTagsService, - params, - response, - ) + response: Response, + ) = ProjectTagListPage(projectTagsService, params, response) } @NoAutoDetect @@ -167,9 +162,7 @@ private constructor( } } - class AutoPager( - private val firstPage: ProjectTagListPage, - ) : Iterable { + class AutoPager(private val firstPage: ProjectTagListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 3cb31a0b..019068c8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( projectTagsService: ProjectTagServiceAsync, params: ProjectTagListParams, - response: Response - ) = - ProjectTagListPageAsync( - projectTagsService, - params, - response, - ) + response: Response, + ) = ProjectTagListPageAsync(projectTagsService, params, response) } @NoAutoDetect @@ -170,14 +165,12 @@ private constructor( } } - class AutoPager( - private val firstPage: ProjectTagListPageAsync, - ) { + class AutoPager(private val firstPage: ProjectTagListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (ProjectTag) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -186,7 +179,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 872ca35b..ccc1e53e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -445,7 +445,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 99621883..d3562ad7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -200,12 +200,7 @@ private constructor( } fun build(): ProjectTagUpdateBody = - ProjectTagUpdateBody( - color, - description, - name, - additionalProperties.toImmutable(), - ) + ProjectTagUpdateBody(color, description, name, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index 0114bd24..056e3ade 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -192,11 +192,7 @@ private constructor( } fun build(): ProjectUpdateBody = - ProjectUpdateBody( - name, - settings, - additionalProperties.toImmutable(), - ) + ProjectUpdateBody(name, settings, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 55622506..e3b02dfd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -377,11 +377,7 @@ private constructor( } /** A literal 'p' which identifies the object as a project prompt */ - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -402,7 +398,7 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - P, + P } /** @@ -463,11 +459,8 @@ private constructor( override fun toString() = value.toString() } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -575,7 +568,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 4a7efdcb..eea17347 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -544,11 +544,8 @@ private constructor( ) } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 6ae99c99..1aa1d554 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -315,12 +315,7 @@ private constructor( } fun build(): Origin = - Origin( - projectId, - promptId, - promptVersion, - additionalProperties.toImmutable(), - ) + Origin(projectId, promptId, promptVersion, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -457,7 +452,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -533,11 +528,7 @@ private constructor( override fun toString() = "ChoiceScores{additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -558,7 +549,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - LLM_CLASSIFIER, + LLM_CLASSIFIER } /** @@ -782,7 +773,7 @@ private constructor( override fun serialize( value: Prompt, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.completion != null -> generator.writeObject(value.completion) @@ -891,11 +882,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -916,7 +904,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - COMPLETION, + COMPLETION } /** @@ -1351,7 +1339,7 @@ private constructor( override fun serialize( value: Message, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.system != null -> generator.writeObject(value.system) @@ -1484,9 +1472,7 @@ private constructor( class Role @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1508,7 +1494,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - SYSTEM, + SYSTEM } /** @@ -1714,9 +1700,7 @@ private constructor( class Role @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1738,7 +1722,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - USER, + USER } /** @@ -1918,7 +1902,7 @@ private constructor( } tryDeserialize( node, - jacksonTypeRef>() + jacksonTypeRef>(), ) { it.forEach { it.validate() } } @@ -1935,7 +1919,7 @@ private constructor( override fun serialize( value: Content, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.text != null -> generator.writeObject(value.text) @@ -2079,26 +2063,26 @@ private constructor( tryDeserialize( node, - jacksonTypeRef() + jacksonTypeRef(), ) { it.validate() } ?.let { return ChatCompletionContentPart( text = it, - _json = json + _json = json, ) } tryDeserialize( node, - jacksonTypeRef() + jacksonTypeRef(), ) { it.validate() } ?.let { return ChatCompletionContentPart( image = it, - _json = json + _json = json, ) } @@ -2114,7 +2098,7 @@ private constructor( override fun serialize( value: ChatCompletionContentPart, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.text != null -> generator.writeObject(value.text) @@ -2335,9 +2319,7 @@ private constructor( class Role @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -2359,7 +2341,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - ASSISTANT, + ASSISTANT } /** @@ -2687,9 +2669,7 @@ private constructor( class Role @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -2711,7 +2691,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - TOOL, + TOOL } /** @@ -2912,9 +2892,7 @@ private constructor( class Role @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -2936,7 +2914,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** @@ -3124,9 +3102,7 @@ private constructor( class Role @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -3148,7 +3124,7 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - MODEL, + MODEL } /** @@ -3232,11 +3208,8 @@ private constructor( } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -3257,7 +3230,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CHAT, + CHAT } /** @@ -3343,7 +3316,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -3545,7 +3518,7 @@ private constructor( override fun serialize( value: ToolFunction, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.function != null -> generator.writeObject(value.function) @@ -3653,11 +3626,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -3678,7 +3648,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** @@ -3856,11 +3826,8 @@ private constructor( ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -3881,7 +3848,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index 0901fd57..7d805029 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -77,11 +77,7 @@ private constructor( @JvmStatic fun of(promptsService: PromptService, params: PromptListParams, response: Response) = - PromptListPage( - promptsService, - params, - response, - ) + PromptListPage(promptsService, params, response) } @NoAutoDetect @@ -156,9 +152,7 @@ private constructor( } } - class AutoPager( - private val firstPage: PromptListPage, - ) : Iterable { + class AutoPager(private val firstPage: PromptListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index 88ccf7c7..f9a8ebf8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -80,11 +80,7 @@ private constructor( @JvmStatic fun of(promptsService: PromptServiceAsync, params: PromptListParams, response: Response) = - PromptListPageAsync( - promptsService, - params, - response, - ) + PromptListPageAsync(promptsService, params, response) } @NoAutoDetect @@ -159,14 +155,12 @@ private constructor( } } - class AutoPager( - private val firstPage: PromptListPageAsync, - ) { + class AutoPager(private val firstPage: PromptListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Prompt) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -175,7 +169,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index d24b3f68..0815efa1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -487,7 +487,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 1191f0f3..f6602edd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -142,12 +142,7 @@ private constructor( } fun build(): PromptOptions = - PromptOptions( - model, - params, - position, - additionalProperties.toImmutable(), - ) + PromptOptions(model, params, position, additionalProperties.toImmutable()) } @JsonDeserialize(using = Params.Deserializer::class) @@ -343,7 +338,7 @@ private constructor( override fun serialize( value: Params, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.openaiModel != null -> generator.writeObject(value.openaiModel) @@ -791,7 +786,7 @@ private constructor( override fun serialize( value: FunctionCall, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.unionMember0 != null -> generator.writeObject(value.unionMember0) @@ -804,9 +799,7 @@ private constructor( class UnionMember0 @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -980,7 +973,7 @@ private constructor( fun build(): Function = Function( checkRequired("name", name), - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } @@ -1180,7 +1173,7 @@ private constructor( override fun serialize( value: ResponseFormat, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.jsonObject != null -> generator.writeObject(value.jsonObject) @@ -1273,15 +1266,13 @@ private constructor( fun build(): JsonObject = JsonObject( checkRequired("type", type), - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1303,7 +1294,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - JSON_OBJECT, + JSON_OBJECT } /** @@ -1645,7 +1636,7 @@ private constructor( private constructor( @JsonAnySetter private val additionalProperties: Map = - immutableEmptyMap(), + immutableEmptyMap() ) { @JsonAnyGetter @@ -1746,9 +1737,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1770,7 +1759,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - JSON_SCHEMA, + JSON_SCHEMA } /** @@ -1935,9 +1924,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1959,7 +1946,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - TEXT, + TEXT } /** @@ -2047,7 +2034,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -2252,7 +2239,7 @@ private constructor( override fun serialize( value: ToolChoice, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.unionMember0 != null -> generator.writeObject(value.unionMember0) @@ -2265,9 +2252,7 @@ private constructor( class UnionMember0 @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -2551,7 +2536,7 @@ private constructor( fun build(): InnerFunction = InnerFunction( checkRequired("name", name), - additionalProperties.toImmutable() + additionalProperties.toImmutable(), ) } @@ -2575,9 +2560,7 @@ private constructor( class Type @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -2599,7 +2582,7 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 8ea32140..8d2bfd3e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -544,11 +544,8 @@ private constructor( ) } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. 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 a95ec69b..ac84d02f 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 @@ -522,11 +522,8 @@ private constructor( * * 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 { + class Permission @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -656,9 +653,7 @@ private constructor( /** The object type that the ACL applies to */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 1b1265bc..30964964 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 @@ -608,11 +608,7 @@ private constructor( } fun build(): RoleCreateParams = - RoleCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + RoleCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } @NoAutoDetect @@ -754,11 +750,8 @@ private constructor( * * 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 { + class Permission @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -888,9 +881,7 @@ private constructor( /** The object type that the ACL applies to */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index 2f6e3ecf..7d9463cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -77,11 +77,7 @@ private constructor( @JvmStatic fun of(rolesService: RoleService, params: RoleListParams, response: Response) = - RoleListPage( - rolesService, - params, - response, - ) + RoleListPage(rolesService, params, response) } @NoAutoDetect @@ -156,9 +152,7 @@ private constructor( } } - class AutoPager( - private val firstPage: RoleListPage, - ) : Iterable { + class AutoPager(private val firstPage: RoleListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index 6b505c7c..68486075 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -80,11 +80,7 @@ private constructor( @JvmStatic fun of(rolesService: RoleServiceAsync, params: RoleListParams, response: Response) = - RoleListPageAsync( - rolesService, - params, - response, - ) + RoleListPageAsync(rolesService, params, response) } @NoAutoDetect @@ -159,14 +155,12 @@ private constructor( } } - class AutoPager( - private val firstPage: RoleListPageAsync, - ) { + class AutoPager(private val firstPage: RoleListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (Role) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -175,7 +169,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 9a1cb2ad..595fdd45 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -416,7 +416,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) 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 44df148c..e99acb9e 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 @@ -754,11 +754,8 @@ private constructor( * * 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 { + class Permission @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -888,9 +885,7 @@ private constructor( /** The object type that the ACL applies to */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 760264f4..4170bd2e 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 @@ -794,11 +794,8 @@ private constructor( * * 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 { + class Permission @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -928,9 +925,7 @@ private constructor( /** The object type that the ACL applies to */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1235,11 +1230,8 @@ private constructor( * * 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 { + class Permission @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1369,9 +1361,7 @@ private constructor( /** The object type that the ACL applies to */ class RestrictObjectType @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 b32a7b0d..f7b309ae 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 @@ -114,20 +114,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toImmutable(), - ) + 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 { + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index e91debd9..99733ffb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -85,13 +85,8 @@ private constructor( fun of( spanIframesService: SpanIframeService, params: SpanIframeListParams, - response: Response - ) = - SpanIframeListPage( - spanIframesService, - params, - response, - ) + response: Response, + ) = SpanIframeListPage(spanIframesService, params, response) } @NoAutoDetect @@ -167,9 +162,7 @@ private constructor( } } - class AutoPager( - private val firstPage: SpanIframeListPage, - ) : Iterable { + class AutoPager(private val firstPage: SpanIframeListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt index 90b8949e..ed0236e1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -88,13 +88,8 @@ private constructor( fun of( spanIframesService: SpanIframeServiceAsync, params: SpanIframeListParams, - response: Response - ) = - SpanIframeListPageAsync( - spanIframesService, - params, - response, - ) + response: Response, + ) = SpanIframeListPageAsync(spanIframesService, params, response) } @NoAutoDetect @@ -170,14 +165,12 @@ private constructor( } } - class AutoPager( - private val firstPage: SpanIframeListPageAsync, - ) { + class AutoPager(private val firstPage: SpanIframeListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (SpanIFrame) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -186,7 +179,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 632ac128..354d21c8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -417,7 +417,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 8fb1ce65..0ee845f4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -227,12 +227,7 @@ private constructor( } fun build(): SpanIframeUpdateBody = - SpanIframeUpdateBody( - name, - postMessage, - url, - additionalProperties.toImmutable(), - ) + SpanIframeUpdateBody(name, postMessage, url, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 122c0887..862495e0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -246,7 +246,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -325,7 +325,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 3b55e885..296fd25e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -77,11 +77,7 @@ private constructor( @JvmStatic fun of(usersService: UserService, params: UserListParams, response: Response) = - UserListPage( - usersService, - params, - response, - ) + UserListPage(usersService, params, response) } @NoAutoDetect @@ -156,9 +152,7 @@ private constructor( } } - class AutoPager( - private val firstPage: UserListPage, - ) : Iterable { + class AutoPager(private val firstPage: UserListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 473bca01..476c3745 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -80,11 +80,7 @@ private constructor( @JvmStatic fun of(usersService: UserServiceAsync, params: UserListParams, response: Response) = - UserListPageAsync( - usersService, - params, - response, - ) + UserListPageAsync(usersService, params, response) } @NoAutoDetect @@ -159,14 +155,12 @@ private constructor( } } - class AutoPager( - private val firstPage: UserListPageAsync, - ) { + class AutoPager(private val firstPage: UserListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (User) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -175,7 +169,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 64c102de..44263a33 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -508,7 +508,7 @@ private constructor( override fun serialize( value: Email, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) @@ -625,7 +625,7 @@ private constructor( override fun serialize( value: FamilyName, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) @@ -742,7 +742,7 @@ private constructor( override fun serialize( value: GivenName, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) @@ -856,7 +856,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) 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 bda8824d..fe103a6f 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 @@ -293,11 +293,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -442,11 +438,7 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 c44ac228..6d9f62cf 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 @@ -555,19 +555,11 @@ private constructor( } fun build(): ViewCreateParams = - ViewCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + 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 { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -712,11 +704,7 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 b983002f..43eac0be 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 @@ -354,11 +354,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index 3cc46b1f..51d70895 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -77,11 +77,7 @@ private constructor( @JvmStatic fun of(viewsService: ViewService, params: ViewListParams, response: Response) = - ViewListPage( - viewsService, - params, - response, - ) + ViewListPage(viewsService, params, response) } @NoAutoDetect @@ -156,9 +152,7 @@ private constructor( } } - class AutoPager( - private val firstPage: ViewListPage, - ) : Iterable { + class AutoPager(private val firstPage: ViewListPage) : Iterable { override fun iterator(): Iterator = iterator { var page = firstPage diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index a0e07698..e2984788 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -80,11 +80,7 @@ private constructor( @JvmStatic fun of(viewsService: ViewServiceAsync, params: ViewListParams, response: Response) = - ViewListPageAsync( - viewsService, - params, - response, - ) + ViewListPageAsync(viewsService, params, response) } @NoAutoDetect @@ -159,14 +155,12 @@ private constructor( } } - class AutoPager( - private val firstPage: ViewListPageAsync, - ) { + class AutoPager(private val firstPage: ViewListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( action: (View) -> Boolean, - executor: Executor + executor: Executor, ): CompletableFuture = thenComposeAsync( { page -> @@ -175,7 +169,7 @@ private constructor( .map { it.getNextPage().forEach(action, executor) } .orElseGet { CompletableFuture.completedFuture(null) } }, - executor + executor, ) return CompletableFuture.completedFuture(Optional.of(firstPage)) .forEach(action::test, executor) 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 b26927cf..fef74844 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 @@ -341,11 +341,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -591,7 +587,7 @@ private constructor( override fun serialize( value: Ids, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { when { value.string != null -> generator.writeObject(value.string) @@ -604,11 +600,7 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index aa11025b..7e9c92f4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -168,7 +168,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -246,7 +246,7 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter 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 bec281e7..dd00fe93 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 @@ -563,11 +563,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -712,11 +708,7 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 7f86b892..79500a4c 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 @@ -197,11 +197,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. 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 9f99e17f..c63e8beb 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 @@ -544,11 +544,7 @@ private constructor( } /** The object type that the ACL applies to */ - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -693,11 +689,7 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 29a5433d..ec49b677 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -25,14 +25,14 @@ interface AclServiceAsync { @JvmOverloads fun create( params: AclCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an acl object by its id */ @JvmOverloads fun retrieve( params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,14 +42,14 @@ interface AclServiceAsync { @JvmOverloads fun list( params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete an acl object by its id */ @JvmOverloads fun delete( params: AclDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -59,13 +59,13 @@ interface AclServiceAsync { @JvmOverloads fun batchUpdate( params: AclBatchUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a single acl */ @JvmOverloads fun findAndDelete( params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index d2c00c6e..bb9f6b26 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -24,10 +24,8 @@ import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams import java.util.concurrent.CompletableFuture -class AclServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : AclServiceAsync { +class AclServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AclServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -40,7 +38,7 @@ internal constructor( */ override fun create( params: AclCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -68,7 +66,7 @@ internal constructor( /** Get an acl object by its id */ override fun retrieve( params: AclRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -99,7 +97,7 @@ internal constructor( */ override fun list( params: AclListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -127,7 +125,7 @@ internal constructor( /** Delete an acl object by its id */ override fun delete( params: AclDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -158,7 +156,7 @@ internal constructor( */ override fun batchUpdate( params: AclBatchUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -186,7 +184,7 @@ internal constructor( /** Delete a single acl */ override fun findAndDelete( params: AclFindAndDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt index ff2feb19..717c2c97 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt @@ -25,14 +25,14 @@ interface AiSecretServiceAsync { @JvmOverloads fun create( params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an ai_secret object by its id */ @JvmOverloads fun retrieve( params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -43,7 +43,7 @@ interface AiSecretServiceAsync { @JvmOverloads fun update( params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -53,21 +53,21 @@ interface AiSecretServiceAsync { @JvmOverloads fun list( params: AiSecretListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete an ai_secret object by its id */ @JvmOverloads fun delete( params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a single ai_secret */ @JvmOverloads fun findAndDelete( params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -77,6 +77,6 @@ interface AiSecretServiceAsync { @JvmOverloads fun replace( params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index e4ace220..ed213522 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -24,10 +24,8 @@ import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams import java.util.concurrent.CompletableFuture -class AiSecretServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : AiSecretServiceAsync { +class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AiSecretServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -40,7 +38,7 @@ internal constructor( */ override fun create( params: AiSecretCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -68,7 +66,7 @@ internal constructor( /** Get an ai_secret object by its id */ override fun retrieve( params: AiSecretRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -99,7 +97,7 @@ internal constructor( */ override fun update( params: AiSecretUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -131,7 +129,7 @@ internal constructor( */ override fun list( params: AiSecretListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -159,7 +157,7 @@ internal constructor( /** Delete an ai_secret object by its id */ override fun delete( params: AiSecretDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -187,7 +185,7 @@ internal constructor( /** Delete a single ai_secret */ override fun findAndDelete( params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -218,7 +216,7 @@ internal constructor( */ override fun replace( params: AiSecretReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index 3dab4049..073af6ef 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -23,14 +23,14 @@ interface ApiKeyServiceAsync { @JvmOverloads fun create( params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an api_key object by its id */ @JvmOverloads fun retrieve( params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -40,13 +40,13 @@ interface ApiKeyServiceAsync { @JvmOverloads fun list( params: ApiKeyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete an api_key object by its id */ @JvmOverloads fun delete( params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index ffa38dde..7a0815d3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput import java.util.concurrent.CompletableFuture -class ApiKeyServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ApiKeyServiceAsync { +class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -38,7 +36,7 @@ internal constructor( */ override fun create( params: ApiKeyCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -66,7 +64,7 @@ internal constructor( /** Get an api_key object by its id */ override fun retrieve( params: ApiKeyRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -97,7 +95,7 @@ internal constructor( */ override fun list( params: ApiKeyListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -125,7 +123,7 @@ internal constructor( /** Delete an api_key object by its id */ override fun delete( params: ApiKeyDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index ca44dff1..b78df736 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -32,14 +32,14 @@ interface DatasetServiceAsync { @JvmOverloads fun create( params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a dataset object by its id */ @JvmOverloads fun retrieve( params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -50,7 +50,7 @@ interface DatasetServiceAsync { @JvmOverloads fun update( params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -60,21 +60,21 @@ interface DatasetServiceAsync { @JvmOverloads fun list( params: DatasetListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a dataset object by its id */ @JvmOverloads fun delete( params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Log feedback for a set of dataset events */ @JvmOverloads fun feedback( params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -85,7 +85,7 @@ interface DatasetServiceAsync { @JvmOverloads fun fetch( params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -96,20 +96,20 @@ interface DatasetServiceAsync { @JvmOverloads fun fetchPost( params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Insert a set of events into the dataset */ @JvmOverloads fun insert( params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Summarize dataset */ @JvmOverloads fun summarize( params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index edd093c0..ec9cb0b2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -31,10 +31,8 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse import java.util.concurrent.CompletableFuture -class DatasetServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : DatasetServiceAsync { +class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -47,7 +45,7 @@ internal constructor( */ override fun create( params: DatasetCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -75,7 +73,7 @@ internal constructor( /** Get a dataset object by its id */ override fun retrieve( params: DatasetRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -106,7 +104,7 @@ internal constructor( */ override fun update( params: DatasetUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -138,7 +136,7 @@ internal constructor( */ override fun list( params: DatasetListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -166,7 +164,7 @@ internal constructor( /** Delete a dataset object by its id */ override fun delete( params: DatasetDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -194,7 +192,7 @@ internal constructor( /** Log feedback for a set of dataset events */ override fun feedback( params: DatasetFeedbackParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -227,7 +225,7 @@ internal constructor( */ override fun fetch( params: DatasetFetchParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -259,7 +257,7 @@ internal constructor( */ override fun fetchPost( params: DatasetFetchPostParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -287,7 +285,7 @@ internal constructor( /** Insert a set of events into the dataset */ override fun insert( params: DatasetInsertParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -316,7 +314,7 @@ internal constructor( /** Summarize dataset */ override fun summarize( params: DatasetSummarizeParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt index 5edf3e15..9e7a7f7f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt @@ -24,14 +24,14 @@ interface EnvVarServiceAsync { @JvmOverloads fun create( params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an env_var object by its id */ @JvmOverloads fun retrieve( params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,7 +42,7 @@ interface EnvVarServiceAsync { @JvmOverloads fun update( params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -52,14 +52,14 @@ interface EnvVarServiceAsync { @JvmOverloads fun list( params: EnvVarListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete an env_var object by its id */ @JvmOverloads fun delete( params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -69,6 +69,6 @@ interface EnvVarServiceAsync { @JvmOverloads fun replace( params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index efe93148..afb0f12b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams import java.util.concurrent.CompletableFuture -class EnvVarServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : EnvVarServiceAsync { +class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + EnvVarServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( */ override fun create( params: EnvVarCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -67,7 +65,7 @@ internal constructor( /** Get an env_var object by its id */ override fun retrieve( params: EnvVarRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -98,7 +96,7 @@ internal constructor( */ override fun update( params: EnvVarUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -129,7 +127,7 @@ internal constructor( */ override fun list( params: EnvVarListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -156,7 +154,7 @@ internal constructor( /** Delete an env_var object by its id */ override fun delete( params: EnvVarDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -187,7 +185,7 @@ internal constructor( */ override fun replace( params: EnvVarReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt index 7e172805..0945abee 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt @@ -21,6 +21,6 @@ interface EvalServiceAsync { @JvmOverloads fun create( params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index 6a9fac5e..524a50fe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -17,10 +17,8 @@ import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture -class EvalServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : EvalServiceAsync { +class EvalServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + EvalServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -37,7 +35,7 @@ internal constructor( */ override fun create( params: EvalCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index 1b601325..888477e8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -32,14 +32,14 @@ interface ExperimentServiceAsync { @JvmOverloads fun create( params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an experiment object by its id */ @JvmOverloads fun retrieve( params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -50,7 +50,7 @@ interface ExperimentServiceAsync { @JvmOverloads fun update( params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -60,21 +60,21 @@ interface ExperimentServiceAsync { @JvmOverloads fun list( params: ExperimentListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete an experiment object by its id */ @JvmOverloads fun delete( params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Log feedback for a set of experiment events */ @JvmOverloads fun feedback( params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -85,7 +85,7 @@ interface ExperimentServiceAsync { @JvmOverloads fun fetch( params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -96,20 +96,20 @@ interface ExperimentServiceAsync { @JvmOverloads fun fetchPost( params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Insert a set of events into the experiment */ @JvmOverloads fun insert( params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Summarize experiment */ @JvmOverloads fun summarize( params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 5f9bc122..d384b3c1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -31,10 +31,8 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture -class ExperimentServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ExperimentServiceAsync { +class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -47,7 +45,7 @@ internal constructor( */ override fun create( params: ExperimentCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -75,7 +73,7 @@ internal constructor( /** Get an experiment object by its id */ override fun retrieve( params: ExperimentRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -106,7 +104,7 @@ internal constructor( */ override fun update( params: ExperimentUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -138,7 +136,7 @@ internal constructor( */ override fun list( params: ExperimentListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -166,7 +164,7 @@ internal constructor( /** Delete an experiment object by its id */ override fun delete( params: ExperimentDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -194,7 +192,7 @@ internal constructor( /** Log feedback for a set of experiment events */ override fun feedback( params: ExperimentFeedbackParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -227,7 +225,7 @@ internal constructor( */ override fun fetch( params: ExperimentFetchParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -259,7 +257,7 @@ internal constructor( */ override fun fetchPost( params: ExperimentFetchPostParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -287,7 +285,7 @@ internal constructor( /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -316,7 +314,7 @@ internal constructor( /** Summarize experiment */ override fun summarize( params: ExperimentSummarizeParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index 4f6dae32..0d80aef0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -27,14 +27,14 @@ interface FunctionServiceAsync { @JvmOverloads fun create( params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a function object by its id */ @JvmOverloads fun retrieve( params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -45,7 +45,7 @@ interface FunctionServiceAsync { @JvmOverloads fun update( params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -55,21 +55,21 @@ interface FunctionServiceAsync { @JvmOverloads fun list( params: FunctionListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a function object by its id */ @JvmOverloads fun delete( params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Invoke a function. */ @JvmOverloads fun invoke( params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @@ -80,6 +80,6 @@ interface FunctionServiceAsync { @JvmOverloads fun replace( params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index c45def2d..9f254448 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -26,10 +26,8 @@ import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional import java.util.concurrent.CompletableFuture -class FunctionServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : FunctionServiceAsync { +class FunctionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FunctionServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -42,7 +40,7 @@ internal constructor( */ override fun create( params: FunctionCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -70,7 +68,7 @@ internal constructor( /** Get a function object by its id */ override fun retrieve( params: FunctionRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -101,7 +99,7 @@ internal constructor( */ override fun update( params: FunctionUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -133,7 +131,7 @@ internal constructor( */ override fun list( params: FunctionListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -161,7 +159,7 @@ internal constructor( /** Delete a function object by its id */ override fun delete( params: FunctionDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -190,7 +188,7 @@ internal constructor( /** Invoke a function. */ override fun invoke( params: FunctionInvokeParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture> { val request = HttpRequest.builder() @@ -222,7 +220,7 @@ internal constructor( */ override fun replace( params: FunctionReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index 62c6f177..442f6551 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -24,14 +24,14 @@ interface GroupServiceAsync { @JvmOverloads fun create( params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a group object by its id */ @JvmOverloads fun retrieve( params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,7 +42,7 @@ interface GroupServiceAsync { @JvmOverloads fun update( params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -52,14 +52,14 @@ interface GroupServiceAsync { @JvmOverloads fun list( params: GroupListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a group object by its id */ @JvmOverloads fun delete( params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -69,6 +69,6 @@ interface GroupServiceAsync { @JvmOverloads fun replace( params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index 784a8a7c..08015024 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams import java.util.concurrent.CompletableFuture -class GroupServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : GroupServiceAsync { +class GroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + GroupServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( */ override fun create( params: GroupCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -67,7 +65,7 @@ internal constructor( /** Get a group object by its id */ override fun retrieve( params: GroupRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -98,7 +96,7 @@ internal constructor( */ override fun update( params: GroupUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -130,7 +128,7 @@ internal constructor( */ override fun list( params: GroupListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -158,7 +156,7 @@ internal constructor( /** Delete a group object by its id */ override fun delete( params: GroupDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -189,7 +187,7 @@ internal constructor( */ override fun replace( params: GroupReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index f1cd38e1..e4598604 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -22,7 +22,7 @@ interface OrganizationServiceAsync { @JvmOverloads fun retrieve( params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -33,7 +33,7 @@ interface OrganizationServiceAsync { @JvmOverloads fun update( params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -43,13 +43,13 @@ interface OrganizationServiceAsync { @JvmOverloads fun list( params: OrganizationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete an organization object by its id */ @JvmOverloads fun delete( params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 4e327d73..691d8fb5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.services.async.organizations.MemberServiceAsync import com.braintrustdata.api.services.async.organizations.MemberServiceAsyncImpl import java.util.concurrent.CompletableFuture -class OrganizationServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : OrganizationServiceAsync { +class OrganizationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + OrganizationServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -40,7 +38,7 @@ internal constructor( /** Get an organization object by its id */ override fun retrieve( params: OrganizationRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -71,7 +69,7 @@ internal constructor( */ override fun update( params: OrganizationUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -103,7 +101,7 @@ internal constructor( */ override fun list( params: OrganizationListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -131,7 +129,7 @@ internal constructor( /** Delete an organization object by its id */ override fun delete( params: OrganizationDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index a5c58d32..0909b50f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -25,14 +25,14 @@ interface ProjectScoreServiceAsync { @JvmOverloads fun create( params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a project_score object by its id */ @JvmOverloads fun retrieve( params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -43,7 +43,7 @@ interface ProjectScoreServiceAsync { @JvmOverloads fun update( params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -53,14 +53,14 @@ interface ProjectScoreServiceAsync { @JvmOverloads fun list( params: ProjectScoreListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a project_score object by its id */ @JvmOverloads fun delete( params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -71,6 +71,6 @@ interface ProjectScoreServiceAsync { @JvmOverloads fun replace( params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index 1a53137f..a565c873 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams import java.util.concurrent.CompletableFuture -class ProjectScoreServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ProjectScoreServiceAsync { +class ProjectScoreServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectScoreServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -40,7 +38,7 @@ internal constructor( */ override fun create( params: ProjectScoreCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -68,7 +66,7 @@ internal constructor( /** Get a project_score object by its id */ override fun retrieve( params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -99,7 +97,7 @@ internal constructor( */ override fun update( params: ProjectScoreUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -131,7 +129,7 @@ internal constructor( */ override fun list( params: ProjectScoreListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -159,7 +157,7 @@ internal constructor( /** Delete a project_score object by its id */ override fun delete( params: ProjectScoreDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -191,7 +189,7 @@ internal constructor( */ override fun replace( params: ProjectScoreReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index a9b81dd5..8419d071 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -26,14 +26,14 @@ interface ProjectServiceAsync { @JvmOverloads fun create( params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a project object by its id */ @JvmOverloads fun retrieve( params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -44,7 +44,7 @@ interface ProjectServiceAsync { @JvmOverloads fun update( params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -54,13 +54,13 @@ interface ProjectServiceAsync { @JvmOverloads fun list( params: ProjectListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a project object by its id */ @JvmOverloads fun delete( params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index 4abd543b..df0d8bad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -24,10 +24,8 @@ import com.braintrustdata.api.services.async.projects.LogServiceAsync import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl import java.util.concurrent.CompletableFuture -class ProjectServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ProjectServiceAsync { +class ProjectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -44,7 +42,7 @@ internal constructor( */ override fun create( params: ProjectCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -72,7 +70,7 @@ internal constructor( /** Get a project object by its id */ override fun retrieve( params: ProjectRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -103,7 +101,7 @@ internal constructor( */ override fun update( params: ProjectUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -135,7 +133,7 @@ internal constructor( */ override fun list( params: ProjectListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -163,7 +161,7 @@ internal constructor( /** Delete a project object by its id */ override fun delete( params: ProjectDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index 7c06cd95..f9b28282 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -24,14 +24,14 @@ interface ProjectTagServiceAsync { @JvmOverloads fun create( params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a project_tag object by its id */ @JvmOverloads fun retrieve( params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,7 +42,7 @@ interface ProjectTagServiceAsync { @JvmOverloads fun update( params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -52,14 +52,14 @@ interface ProjectTagServiceAsync { @JvmOverloads fun list( params: ProjectTagListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a project_tag object by its id */ @JvmOverloads fun delete( params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -70,6 +70,6 @@ interface ProjectTagServiceAsync { @JvmOverloads fun replace( params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index d49eea51..d72ea0d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams import java.util.concurrent.CompletableFuture -class ProjectTagServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ProjectTagServiceAsync { +class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectTagServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( */ override fun create( params: ProjectTagCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -67,7 +65,7 @@ internal constructor( /** Get a project_tag object by its id */ override fun retrieve( params: ProjectTagRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -98,7 +96,7 @@ internal constructor( */ override fun update( params: ProjectTagUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -130,7 +128,7 @@ internal constructor( */ override fun list( params: ProjectTagListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -158,7 +156,7 @@ internal constructor( /** Delete a project_tag object by its id */ override fun delete( params: ProjectTagDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -190,7 +188,7 @@ internal constructor( */ override fun replace( params: ProjectTagReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index 2d444758..a293667f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -24,14 +24,14 @@ interface PromptServiceAsync { @JvmOverloads fun create( params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a prompt object by its id */ @JvmOverloads fun retrieve( params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,7 +42,7 @@ interface PromptServiceAsync { @JvmOverloads fun update( params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -52,14 +52,14 @@ interface PromptServiceAsync { @JvmOverloads fun list( params: PromptListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a prompt object by its id */ @JvmOverloads fun delete( params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -69,6 +69,6 @@ interface PromptServiceAsync { @JvmOverloads fun replace( params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 632898a5..e3acb9d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams import java.util.concurrent.CompletableFuture -class PromptServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : PromptServiceAsync { +class PromptServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PromptServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( */ override fun create( params: PromptCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -67,7 +65,7 @@ internal constructor( /** Get a prompt object by its id */ override fun retrieve( params: PromptRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -98,7 +96,7 @@ internal constructor( */ override fun update( params: PromptUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -130,7 +128,7 @@ internal constructor( */ override fun list( params: PromptListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -158,7 +156,7 @@ internal constructor( /** Delete a prompt object by its id */ override fun delete( params: PromptDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -189,7 +187,7 @@ internal constructor( */ override fun replace( params: PromptReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index e5b84aba..9f8726d3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -24,14 +24,14 @@ interface RoleServiceAsync { @JvmOverloads fun create( params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a role object by its id */ @JvmOverloads fun retrieve( params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,7 +42,7 @@ interface RoleServiceAsync { @JvmOverloads fun update( params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -52,14 +52,14 @@ interface RoleServiceAsync { @JvmOverloads fun list( params: RoleListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a role object by its id */ @JvmOverloads fun delete( params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -69,6 +69,6 @@ interface RoleServiceAsync { @JvmOverloads fun replace( params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index 442db1ac..ed8c8fe3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams import java.util.concurrent.CompletableFuture -class RoleServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RoleServiceAsync { +class RoleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RoleServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( */ override fun create( params: RoleCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -67,7 +65,7 @@ internal constructor( /** Get a role object by its id */ override fun retrieve( params: RoleRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -98,7 +96,7 @@ internal constructor( */ override fun update( params: RoleUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -130,7 +128,7 @@ internal constructor( */ override fun list( params: RoleListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -158,7 +156,7 @@ internal constructor( /** Delete a role object by its id */ override fun delete( params: RoleDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -189,7 +187,7 @@ internal constructor( */ override fun replace( params: RoleReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt index 3ce9449a..ddf6b168 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt @@ -24,14 +24,14 @@ interface SpanIframeServiceAsync { @JvmOverloads fun create( params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a span_iframe object by its id */ @JvmOverloads fun retrieve( params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,7 +42,7 @@ interface SpanIframeServiceAsync { @JvmOverloads fun update( params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -52,14 +52,14 @@ interface SpanIframeServiceAsync { @JvmOverloads fun list( params: SpanIframeListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a span_iframe object by its id */ @JvmOverloads fun delete( params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -69,6 +69,6 @@ interface SpanIframeServiceAsync { @JvmOverloads fun replace( params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt index c79a81e7..745acd9a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams import java.util.concurrent.CompletableFuture -class SpanIframeServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : SpanIframeServiceAsync { +class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SpanIframeServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( */ override fun create( params: SpanIframeCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -67,7 +65,7 @@ internal constructor( /** Get a span_iframe object by its id */ override fun retrieve( params: SpanIframeRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -98,7 +96,7 @@ internal constructor( */ override fun update( params: SpanIframeUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -130,7 +128,7 @@ internal constructor( */ override fun list( params: SpanIframeListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -158,7 +156,7 @@ internal constructor( /** Delete a span_iframe object by its id */ override fun delete( params: SpanIframeDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -189,7 +187,7 @@ internal constructor( */ override fun replace( params: SpanIframeReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index 14126ddc..10f2028b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -14,6 +14,6 @@ interface TopLevelServiceAsync { @JvmOverloads fun helloWorld( params: TopLevelHelloWorldParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index 3e53d718..03b94366 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -15,10 +15,8 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams import java.util.concurrent.CompletableFuture -class TopLevelServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TopLevelServiceAsync { +class TopLevelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -27,7 +25,7 @@ internal constructor( /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ override fun helloWorld( params: TopLevelHelloWorldParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index e7d83503..d20e9d77 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -17,7 +17,7 @@ interface UserServiceAsync { @JvmOverloads fun retrieve( params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -27,6 +27,6 @@ interface UserServiceAsync { @JvmOverloads fun list( params: UserListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 3658ab80..8962743f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -18,10 +18,8 @@ import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import java.util.concurrent.CompletableFuture -class UserServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : UserServiceAsync { +class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UserServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -31,7 +29,7 @@ internal constructor( /** Get a user object by its id */ override fun retrieve( params: UserRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -62,7 +60,7 @@ internal constructor( */ override fun list( params: UserListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index 805e10ff..24c13d8f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -24,14 +24,14 @@ interface ViewServiceAsync { @JvmOverloads fun create( params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a view object by its id */ @JvmOverloads fun retrieve( params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,7 +42,7 @@ interface ViewServiceAsync { @JvmOverloads fun update( params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -52,14 +52,14 @@ interface ViewServiceAsync { @JvmOverloads fun list( params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a view object by its id */ @JvmOverloads fun delete( params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -69,6 +69,6 @@ interface ViewServiceAsync { @JvmOverloads fun replace( params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 48806c81..8ce4709a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams import java.util.concurrent.CompletableFuture -class ViewServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ViewServiceAsync { +class ViewServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ViewServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( */ override fun create( params: ViewCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -67,7 +65,7 @@ internal constructor( /** Get a view object by its id */ override fun retrieve( params: ViewRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -98,7 +96,7 @@ internal constructor( */ override fun update( params: ViewUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -130,7 +128,7 @@ internal constructor( */ override fun list( params: ViewListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -158,7 +156,7 @@ internal constructor( /** Delete a view object by its id */ override fun delete( params: ViewDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -189,7 +187,7 @@ internal constructor( */ override fun replace( params: ViewReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt index de4cc02c..56d59671 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -15,6 +15,6 @@ interface MemberServiceAsync { @JvmOverloads fun update( params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 4d122529..4607e2bf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -17,10 +17,8 @@ import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput import java.util.concurrent.CompletableFuture -class MemberServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : MemberServiceAsync { +class MemberServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -31,7 +29,7 @@ internal constructor( /** Modify organization membership */ override fun update( params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index 782f3331..943bd6d8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -20,7 +20,7 @@ interface LogServiceAsync { @JvmOverloads fun feedback( params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -31,7 +31,7 @@ interface LogServiceAsync { @JvmOverloads fun fetch( params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @@ -42,13 +42,13 @@ interface LogServiceAsync { @JvmOverloads fun fetchPost( params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Insert a set of events into the project logs */ @JvmOverloads fun insert( params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 3a7bf06c..de0d28d4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams import java.util.concurrent.CompletableFuture -class LogServiceAsyncImpl -internal constructor( - private val clientOptions: ClientOptions, -) : LogServiceAsync { +class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LogServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -35,7 +33,7 @@ internal constructor( /** Log feedback for a set of project logs events */ override fun feedback( params: ProjectLogFeedbackParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -68,7 +66,7 @@ internal constructor( */ override fun fetch( params: ProjectLogFetchParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -100,7 +98,7 @@ internal constructor( */ override fun fetchPost( params: ProjectLogFetchPostParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() @@ -128,7 +126,7 @@ internal constructor( /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index b47af970..a6d47676 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -28,7 +28,7 @@ interface AclService { @JvmOverloads fun retrieve( params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Acl /** @@ -38,7 +38,7 @@ interface AclService { @JvmOverloads fun list( params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AclListPage /** Delete an acl object by its id */ @@ -52,13 +52,13 @@ interface AclService { @JvmOverloads fun batchUpdate( params: AclBatchUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AclBatchUpdateResponse /** Delete a single acl */ @JvmOverloads fun findAndDelete( params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Acl } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index e38f3265..daa29513 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -23,10 +23,7 @@ import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -class AclServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : AclService { +class AclServiceImpl internal constructor(private val clientOptions: ClientOptions) : AclService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -132,7 +129,7 @@ internal constructor( */ override fun batchUpdate( params: AclBatchUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): AclBatchUpdateResponse { val request = HttpRequest.builder() @@ -157,7 +154,7 @@ internal constructor( /** Delete a single acl */ override fun findAndDelete( params: AclFindAndDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Acl { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt index a9445bf7..b6e34664 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt @@ -24,14 +24,14 @@ interface AiSecretService { @JvmOverloads fun create( params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AISecret /** Get an ai_secret object by its id */ @JvmOverloads fun retrieve( params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AISecret /** @@ -42,7 +42,7 @@ interface AiSecretService { @JvmOverloads fun update( params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AISecret /** @@ -52,21 +52,21 @@ interface AiSecretService { @JvmOverloads fun list( params: AiSecretListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AiSecretListPage /** Delete an ai_secret object by its id */ @JvmOverloads fun delete( params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AISecret /** Delete a single ai_secret */ @JvmOverloads fun findAndDelete( params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AISecret /** @@ -76,6 +76,6 @@ interface AiSecretService { @JvmOverloads fun replace( params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): AISecret } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index 8b90d183..eb6b559b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams -class AiSecretServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : AiSecretService { +class AiSecretServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AiSecretService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -61,7 +59,7 @@ internal constructor( /** Get an ai_secret object by its id */ override fun retrieve( params: AiSecretRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): AISecret { val request = HttpRequest.builder() @@ -115,7 +113,7 @@ internal constructor( */ override fun list( params: AiSecretListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): AiSecretListPage { val request = HttpRequest.builder() @@ -162,7 +160,7 @@ internal constructor( /** Delete a single ai_secret */ override fun findAndDelete( params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): AISecret { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index a98e1d7e..8b53fbd7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -22,14 +22,14 @@ interface ApiKeyService { @JvmOverloads fun create( params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CreateApiKeyOutput /** Get an api_key object by its id */ @JvmOverloads fun retrieve( params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ApiKey /** @@ -39,13 +39,13 @@ interface ApiKeyService { @JvmOverloads fun list( params: ApiKeyListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ApiKeyListPage /** Delete an api_key object by its id */ @JvmOverloads fun delete( params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ApiKey } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index 25dc919a..c300b883 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -21,10 +21,8 @@ import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput -class ApiKeyServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ApiKeyService { +class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -37,7 +35,7 @@ internal constructor( */ override fun create( params: ApiKeyCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CreateApiKeyOutput { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 9a8e7b8e..2d4a5dc9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -31,14 +31,14 @@ interface DatasetService { @JvmOverloads fun create( params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Dataset /** Get a dataset object by its id */ @JvmOverloads fun retrieve( params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Dataset /** @@ -49,7 +49,7 @@ interface DatasetService { @JvmOverloads fun update( params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Dataset /** @@ -59,21 +59,21 @@ interface DatasetService { @JvmOverloads fun list( params: DatasetListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): DatasetListPage /** Delete a dataset object by its id */ @JvmOverloads fun delete( params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Dataset /** Log feedback for a set of dataset events */ @JvmOverloads fun feedback( params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FeedbackResponseSchema /** @@ -84,7 +84,7 @@ interface DatasetService { @JvmOverloads fun fetch( params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FetchDatasetEventsResponse /** @@ -95,20 +95,20 @@ interface DatasetService { @JvmOverloads fun fetchPost( params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FetchDatasetEventsResponse /** Insert a set of events into the dataset */ @JvmOverloads fun insert( params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): InsertEventsResponse /** Summarize dataset */ @JvmOverloads fun summarize( params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SummarizeDatasetResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 6a53d244..3e76ec99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -30,10 +30,8 @@ import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse -class DatasetServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : DatasetService { +class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -163,7 +161,7 @@ internal constructor( /** Log feedback for a set of dataset events */ override fun feedback( params: DatasetFeedbackParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FeedbackResponseSchema { val request = HttpRequest.builder() @@ -193,7 +191,7 @@ internal constructor( */ override fun fetch( params: DatasetFetchParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FetchDatasetEventsResponse { val request = HttpRequest.builder() @@ -222,7 +220,7 @@ internal constructor( */ override fun fetchPost( params: DatasetFetchPostParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FetchDatasetEventsResponse { val request = HttpRequest.builder() @@ -247,7 +245,7 @@ internal constructor( /** Insert a set of events into the dataset */ override fun insert( params: DatasetInsertParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): InsertEventsResponse { val request = HttpRequest.builder() @@ -273,7 +271,7 @@ internal constructor( /** Summarize dataset */ override fun summarize( params: DatasetSummarizeParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SummarizeDatasetResponse { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt index 5162047c..108d0eb9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt @@ -23,14 +23,14 @@ interface EnvVarService { @JvmOverloads fun create( params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): EnvVar /** Get an env_var object by its id */ @JvmOverloads fun retrieve( params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): EnvVar /** @@ -41,7 +41,7 @@ interface EnvVarService { @JvmOverloads fun update( params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): EnvVar /** @@ -51,14 +51,14 @@ interface EnvVarService { @JvmOverloads fun list( params: EnvVarListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): EnvVarListResponse /** Delete an env_var object by its id */ @JvmOverloads fun delete( params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): EnvVar /** @@ -68,6 +68,6 @@ interface EnvVarService { @JvmOverloads fun replace( params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): EnvVar } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index bb9c40ee..b26dfba6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams -class EnvVarServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : EnvVarService { +class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOptions) : + EnvVarService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -110,7 +108,7 @@ internal constructor( */ override fun list( params: EnvVarListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): EnvVarListResponse { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt index 54249924..4667577d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt @@ -20,6 +20,6 @@ interface EvalService { @JvmOverloads fun create( params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SummarizeExperimentResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index e0af0896..21dfd9ab 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -16,10 +16,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse -class EvalServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : EvalService { +class EvalServiceImpl internal constructor(private val clientOptions: ClientOptions) : EvalService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -36,7 +33,7 @@ internal constructor( */ override fun create( params: EvalCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SummarizeExperimentResponse { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index b8dcc7bf..371e2fd3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -31,14 +31,14 @@ interface ExperimentService { @JvmOverloads fun create( params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Experiment /** Get an experiment object by its id */ @JvmOverloads fun retrieve( params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Experiment /** @@ -49,7 +49,7 @@ interface ExperimentService { @JvmOverloads fun update( params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Experiment /** @@ -59,21 +59,21 @@ interface ExperimentService { @JvmOverloads fun list( params: ExperimentListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ExperimentListPage /** Delete an experiment object by its id */ @JvmOverloads fun delete( params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Experiment /** Log feedback for a set of experiment events */ @JvmOverloads fun feedback( params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FeedbackResponseSchema /** @@ -84,7 +84,7 @@ interface ExperimentService { @JvmOverloads fun fetch( params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FetchExperimentEventsResponse /** @@ -95,20 +95,20 @@ interface ExperimentService { @JvmOverloads fun fetchPost( params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FetchExperimentEventsResponse /** Insert a set of events into the experiment */ @JvmOverloads fun insert( params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): InsertEventsResponse /** Summarize experiment */ @JvmOverloads fun summarize( params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SummarizeExperimentResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 0d5d88c6..29549e25 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -30,10 +30,8 @@ import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse -class ExperimentServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ExperimentService { +class ExperimentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -46,7 +44,7 @@ internal constructor( */ override fun create( params: ExperimentCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Experiment { val request = HttpRequest.builder() @@ -71,7 +69,7 @@ internal constructor( /** Get an experiment object by its id */ override fun retrieve( params: ExperimentRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Experiment { val request = HttpRequest.builder() @@ -99,7 +97,7 @@ internal constructor( */ override fun update( params: ExperimentUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Experiment { val request = HttpRequest.builder() @@ -128,7 +126,7 @@ internal constructor( */ override fun list( params: ExperimentListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ExperimentListPage { val request = HttpRequest.builder() @@ -153,7 +151,7 @@ internal constructor( /** Delete an experiment object by its id */ override fun delete( params: ExperimentDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Experiment { val request = HttpRequest.builder() @@ -178,7 +176,7 @@ internal constructor( /** Log feedback for a set of experiment events */ override fun feedback( params: ExperimentFeedbackParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FeedbackResponseSchema { val request = HttpRequest.builder() @@ -208,7 +206,7 @@ internal constructor( */ override fun fetch( params: ExperimentFetchParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FetchExperimentEventsResponse { val request = HttpRequest.builder() @@ -237,7 +235,7 @@ internal constructor( */ override fun fetchPost( params: ExperimentFetchPostParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FetchExperimentEventsResponse { val request = HttpRequest.builder() @@ -262,7 +260,7 @@ internal constructor( /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): InsertEventsResponse { val request = HttpRequest.builder() @@ -288,7 +286,7 @@ internal constructor( /** Summarize experiment */ override fun summarize( params: ExperimentSummarizeParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SummarizeExperimentResponse { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 33f0e993..86a147a2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -26,14 +26,14 @@ interface FunctionService { @JvmOverloads fun create( params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Function /** Get a function object by its id */ @JvmOverloads fun retrieve( params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Function /** @@ -44,7 +44,7 @@ interface FunctionService { @JvmOverloads fun update( params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Function /** @@ -54,21 +54,21 @@ interface FunctionService { @JvmOverloads fun list( params: FunctionListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FunctionListPage /** Delete a function object by its id */ @JvmOverloads fun delete( params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Function /** Invoke a function. */ @JvmOverloads fun invoke( params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Optional /** @@ -79,6 +79,6 @@ interface FunctionService { @JvmOverloads fun replace( params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Function } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index b15fbd46..92ebbe6f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -25,10 +25,8 @@ import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional -class FunctionServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : FunctionService { +class FunctionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FunctionService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -63,7 +61,7 @@ internal constructor( /** Get a function object by its id */ override fun retrieve( params: FunctionRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Function { val request = HttpRequest.builder() @@ -117,7 +115,7 @@ internal constructor( */ override fun list( params: FunctionListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FunctionListPage { val request = HttpRequest.builder() @@ -165,7 +163,7 @@ internal constructor( /** Invoke a function. */ override fun invoke( params: FunctionInvokeParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Optional { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index 2b544c2e..6a3a773a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -23,14 +23,14 @@ interface GroupService { @JvmOverloads fun create( params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Group /** Get a group object by its id */ @JvmOverloads fun retrieve( params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Group /** @@ -41,7 +41,7 @@ interface GroupService { @JvmOverloads fun update( params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Group /** @@ -51,14 +51,14 @@ interface GroupService { @JvmOverloads fun list( params: GroupListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): GroupListPage /** Delete a group object by its id */ @JvmOverloads fun delete( params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Group /** @@ -68,6 +68,6 @@ interface GroupService { @JvmOverloads fun replace( params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Group } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 0bd791dc..ebeff796 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -class GroupServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : GroupService { +class GroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : + GroupService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index f4ca1ae2..f3336cb0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -21,7 +21,7 @@ interface OrganizationService { @JvmOverloads fun retrieve( params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Organization /** @@ -32,7 +32,7 @@ interface OrganizationService { @JvmOverloads fun update( params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Organization /** @@ -42,13 +42,13 @@ interface OrganizationService { @JvmOverloads fun list( params: OrganizationListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): OrganizationListPage /** Delete an organization object by its id */ @JvmOverloads fun delete( params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Organization } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index 98b0a04a..315c2ea6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.OrganizationUpdateParams import com.braintrustdata.api.services.blocking.organizations.MemberService import com.braintrustdata.api.services.blocking.organizations.MemberServiceImpl -class OrganizationServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : OrganizationService { +class OrganizationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + OrganizationService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( /** Get an organization object by its id */ override fun retrieve( params: OrganizationRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Organization { val request = HttpRequest.builder() @@ -67,7 +65,7 @@ internal constructor( */ override fun update( params: OrganizationUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Organization { val request = HttpRequest.builder() @@ -96,7 +94,7 @@ internal constructor( */ override fun list( params: OrganizationListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): OrganizationListPage { val request = HttpRequest.builder() @@ -121,7 +119,7 @@ internal constructor( /** Delete an organization object by its id */ override fun delete( params: OrganizationDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): Organization { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index d440a9a6..7eafe1f3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -24,14 +24,14 @@ interface ProjectScoreService { @JvmOverloads fun create( params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScore /** Get a project_score object by its id */ @JvmOverloads fun retrieve( params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScore /** @@ -42,7 +42,7 @@ interface ProjectScoreService { @JvmOverloads fun update( params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScore /** @@ -52,14 +52,14 @@ interface ProjectScoreService { @JvmOverloads fun list( params: ProjectScoreListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScoreListPage /** Delete a project_score object by its id */ @JvmOverloads fun delete( params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScore /** @@ -70,6 +70,6 @@ interface ProjectScoreService { @JvmOverloads fun replace( params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScore } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index 1f9eddec..aa7ae8eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -class ProjectScoreServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ProjectScoreService { +class ProjectScoreServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectScoreService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -39,7 +37,7 @@ internal constructor( */ override fun create( params: ProjectScoreCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectScore { val request = HttpRequest.builder() @@ -64,7 +62,7 @@ internal constructor( /** Get a project_score object by its id */ override fun retrieve( params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectScore { val request = HttpRequest.builder() @@ -92,7 +90,7 @@ internal constructor( */ override fun update( params: ProjectScoreUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectScore { val request = HttpRequest.builder() @@ -121,7 +119,7 @@ internal constructor( */ override fun list( params: ProjectScoreListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectScoreListPage { val request = HttpRequest.builder() @@ -146,7 +144,7 @@ internal constructor( /** Delete a project_score object by its id */ override fun delete( params: ProjectScoreDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectScore { val request = HttpRequest.builder() @@ -175,7 +173,7 @@ internal constructor( */ override fun replace( params: ProjectScoreReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectScore { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index 3c46992f..941dbcca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -25,14 +25,14 @@ interface ProjectService { @JvmOverloads fun create( params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Project /** Get a project object by its id */ @JvmOverloads fun retrieve( params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Project /** @@ -43,7 +43,7 @@ interface ProjectService { @JvmOverloads fun update( params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Project /** @@ -53,13 +53,13 @@ interface ProjectService { @JvmOverloads fun list( params: ProjectListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectListPage /** Delete a project object by its id */ @JvmOverloads fun delete( params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Project } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index ebfba434..02f59abb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -23,10 +23,8 @@ import com.braintrustdata.api.models.ProjectUpdateParams import com.braintrustdata.api.services.blocking.projects.LogService import com.braintrustdata.api.services.blocking.projects.LogServiceImpl -class ProjectServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ProjectService { +class ProjectServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index e240afdc..c9ce87a7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -23,14 +23,14 @@ interface ProjectTagService { @JvmOverloads fun create( params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTag /** Get a project_tag object by its id */ @JvmOverloads fun retrieve( params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTag /** @@ -41,7 +41,7 @@ interface ProjectTagService { @JvmOverloads fun update( params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTag /** @@ -51,14 +51,14 @@ interface ProjectTagService { @JvmOverloads fun list( params: ProjectTagListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTagListPage /** Delete a project_tag object by its id */ @JvmOverloads fun delete( params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTag /** @@ -69,6 +69,6 @@ interface ProjectTagService { @JvmOverloads fun replace( params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTag } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index da6ce3e3..e95a6ff1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -class ProjectTagServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ProjectTagService { +class ProjectTagServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectTagService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -38,7 +36,7 @@ internal constructor( */ override fun create( params: ProjectTagCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectTag { val request = HttpRequest.builder() @@ -63,7 +61,7 @@ internal constructor( /** Get a project_tag object by its id */ override fun retrieve( params: ProjectTagRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectTag { val request = HttpRequest.builder() @@ -91,7 +89,7 @@ internal constructor( */ override fun update( params: ProjectTagUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectTag { val request = HttpRequest.builder() @@ -120,7 +118,7 @@ internal constructor( */ override fun list( params: ProjectTagListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectTagListPage { val request = HttpRequest.builder() @@ -145,7 +143,7 @@ internal constructor( /** Delete a project_tag object by its id */ override fun delete( params: ProjectTagDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectTag { val request = HttpRequest.builder() @@ -174,7 +172,7 @@ internal constructor( */ override fun replace( params: ProjectTagReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): ProjectTag { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index 78316068..e233aa64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -23,14 +23,14 @@ interface PromptService { @JvmOverloads fun create( params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Prompt /** Get a prompt object by its id */ @JvmOverloads fun retrieve( params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Prompt /** @@ -41,7 +41,7 @@ interface PromptService { @JvmOverloads fun update( params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Prompt /** @@ -51,14 +51,14 @@ interface PromptService { @JvmOverloads fun list( params: PromptListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): PromptListPage /** Delete a prompt object by its id */ @JvmOverloads fun delete( params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Prompt /** @@ -68,6 +68,6 @@ interface PromptService { @JvmOverloads fun replace( params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Prompt } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index c4bc8056..82e3c2b1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -class PromptServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : PromptService { +class PromptServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PromptService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index 6ae7e700..06c6aa37 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -23,14 +23,14 @@ interface RoleService { @JvmOverloads fun create( params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Role /** Get a role object by its id */ @JvmOverloads fun retrieve( params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Role /** @@ -41,7 +41,7 @@ interface RoleService { @JvmOverloads fun update( params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Role /** @@ -51,14 +51,14 @@ interface RoleService { @JvmOverloads fun list( params: RoleListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): RoleListPage /** Delete a role object by its id */ @JvmOverloads fun delete( params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Role /** @@ -68,6 +68,6 @@ interface RoleService { @JvmOverloads fun replace( params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): Role } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index bd7af730..ed4bbeb2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -22,10 +22,7 @@ import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -class RoleServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : RoleService { +class RoleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RoleService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt index 26033908..168b53bd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt @@ -23,14 +23,14 @@ interface SpanIframeService { @JvmOverloads fun create( params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SpanIFrame /** Get a span_iframe object by its id */ @JvmOverloads fun retrieve( params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SpanIFrame /** @@ -41,7 +41,7 @@ interface SpanIframeService { @JvmOverloads fun update( params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SpanIFrame /** @@ -51,14 +51,14 @@ interface SpanIframeService { @JvmOverloads fun list( params: SpanIframeListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SpanIframeListPage /** Delete a span_iframe object by its id */ @JvmOverloads fun delete( params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SpanIFrame /** @@ -68,6 +68,6 @@ interface SpanIframeService { @JvmOverloads fun replace( params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): SpanIFrame } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt index 1c43d65d..a30f3c91 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -22,10 +22,8 @@ import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams -class SpanIframeServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : SpanIframeService { +class SpanIframeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SpanIframeService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -38,7 +36,7 @@ internal constructor( */ override fun create( params: SpanIframeCreateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SpanIFrame { val request = HttpRequest.builder() @@ -63,7 +61,7 @@ internal constructor( /** Get a span_iframe object by its id */ override fun retrieve( params: SpanIframeRetrieveParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SpanIFrame { val request = HttpRequest.builder() @@ -91,7 +89,7 @@ internal constructor( */ override fun update( params: SpanIframeUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SpanIFrame { val request = HttpRequest.builder() @@ -120,7 +118,7 @@ internal constructor( */ override fun list( params: SpanIframeListParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SpanIframeListPage { val request = HttpRequest.builder() @@ -145,7 +143,7 @@ internal constructor( /** Delete a span_iframe object by its id */ override fun delete( params: SpanIframeDeleteParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SpanIFrame { val request = HttpRequest.builder() @@ -173,7 +171,7 @@ internal constructor( */ override fun replace( params: SpanIframeReplaceParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): SpanIFrame { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index 5aba74fe..f35bbbcb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -13,6 +13,6 @@ interface TopLevelService { @JvmOverloads fun helloWorld( params: TopLevelHelloWorldParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): String } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index a7da817d..79dfb27b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -14,10 +14,8 @@ import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams -class TopLevelServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : TopLevelService { +class TopLevelServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -26,7 +24,7 @@ internal constructor( /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ override fun helloWorld( params: TopLevelHelloWorldParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): String { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index 53e07dcb..30abf630 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -16,7 +16,7 @@ interface UserService { @JvmOverloads fun retrieve( params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): User /** @@ -26,6 +26,6 @@ interface UserService { @JvmOverloads fun list( params: UserListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): UserListPage } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index aa7ef359..0fdfce45 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -17,10 +17,7 @@ import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams -class UserServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : UserService { +class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index d71f5ab5..73aa6d7c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -23,14 +23,14 @@ interface ViewService { @JvmOverloads fun create( params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): View /** Get a view object by its id */ @JvmOverloads fun retrieve( params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): View /** @@ -41,7 +41,7 @@ interface ViewService { @JvmOverloads fun update( params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): View /** @@ -51,14 +51,14 @@ interface ViewService { @JvmOverloads fun list( params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ViewListPage /** Delete a view object by its id */ @JvmOverloads fun delete( params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): View /** @@ -68,6 +68,6 @@ interface ViewService { @JvmOverloads fun replace( params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): View } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index b1280e4a..068df7b6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -22,10 +22,7 @@ import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -class ViewServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : ViewService { +class ViewServiceImpl internal constructor(private val clientOptions: ClientOptions) : ViewService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt index 6ef76fdf..4cfb03db 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -14,6 +14,6 @@ interface MemberService { @JvmOverloads fun update( params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): PatchOrganizationMembersOutput } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index 86c911ff..02db3575 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -16,10 +16,8 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput -class MemberServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : MemberService { +class MemberServiceImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -30,7 +28,7 @@ internal constructor( /** Modify organization membership */ override fun update( params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): PatchOrganizationMembersOutput { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index c36b6e81..e8b51534 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -19,7 +19,7 @@ interface LogService { @JvmOverloads fun feedback( params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FeedbackResponseSchema /** @@ -30,7 +30,7 @@ interface LogService { @JvmOverloads fun fetch( params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FetchProjectLogsEventsResponse /** @@ -41,13 +41,13 @@ interface LogService { @JvmOverloads fun fetchPost( params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): FetchProjectLogsEventsResponse /** Insert a set of events into the project logs */ @JvmOverloads fun insert( params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): InsertEventsResponse } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index a2effeb5..62c44a7a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -21,10 +21,7 @@ import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -class LogServiceImpl -internal constructor( - private val clientOptions: ClientOptions, -) : LogService { +class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -34,7 +31,7 @@ internal constructor( /** Log feedback for a set of project logs events */ override fun feedback( params: ProjectLogFeedbackParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FeedbackResponseSchema { val request = HttpRequest.builder() @@ -64,7 +61,7 @@ internal constructor( */ override fun fetch( params: ProjectLogFetchParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FetchProjectLogsEventsResponse { val request = HttpRequest.builder() @@ -93,7 +90,7 @@ internal constructor( */ override fun fetchPost( params: ProjectLogFetchPostParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): FetchProjectLogsEventsResponse { val request = HttpRequest.builder() @@ -118,7 +115,7 @@ internal constructor( /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): InsertEventsResponse { val request = HttpRequest.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt index d79a0c57..1d2dd2d0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt @@ -36,7 +36,7 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { $ prism mock path/to/your.openapi.yml """ .trimIndent(), - e + e, ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt index adf8a799..a7a9b514 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt @@ -14,7 +14,7 @@ internal class PhantomReachableTest { // Pass an inline object for the object to observe so that it becomes immediately // unreachable. Any(), - closeable + closeable, ) assertThat(closed).isFalse() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt index 30156281..2a5ed57a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt @@ -11,28 +11,28 @@ internal class HeadersTest { enum class TestCase( val headers: Headers, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( Headers.builder().put("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( Headers.builder().put("name1", "value").put("name2", "value").build(), expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( Headers.builder().put("name", "value1").put("name", "value2").build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( Headers.builder() @@ -40,7 +40,7 @@ internal class HeadersTest { .put("name", listOf("value1", "value2")) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_CASE_INSENSITIVE( Headers.builder() @@ -49,25 +49,25 @@ internal class HeadersTest { .put("nAmE", "value3") .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), PUT_ALL_MAP( Headers.builder() .putAll( mapOf( "name1" to listOf("value1", "value2"), - "name2" to listOf("value1", "value2") + "name2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_ALL_CASE_INSENSITIVE( Headers.builder() @@ -75,32 +75,32 @@ internal class HeadersTest { mapOf( "name" to listOf("value1"), "NAME" to listOf("value2"), - "nAmE" to listOf("value3") + "nAmE" to listOf("value3"), ) ) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), REMOVE_ABSENT( Headers.builder().remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( Headers.builder().put("name", "value").remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_CASE_INSENSITIVE( Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( Headers.builder() @@ -109,7 +109,7 @@ internal class HeadersTest { .removeAll(setOf("name1", "name2", "name3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -118,22 +118,22 @@ internal class HeadersTest { .removeAll(setOf("NAME1", "nAmE3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( Headers.builder().put("name1", "value").put("name2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( Headers.builder().replace("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( Headers.builder().put("name", "value1").replace("name", "value2").build(), expectedMap = mapOf("name" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( Headers.builder() @@ -141,12 +141,12 @@ internal class HeadersTest { .replace("name", "value3") .build(), expectedMap = mapOf("name" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( Headers.builder().replace("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( Headers.builder() @@ -154,7 +154,7 @@ internal class HeadersTest { .replace("name", listOf("value2", "value3")) .build(), expectedMap = mapOf("name" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( Headers.builder() @@ -162,7 +162,7 @@ internal class HeadersTest { .replace("name", listOf("value3", "value4")) .build(), expectedMap = mapOf("name" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_CASE_INSENSITIVE( Headers.builder() @@ -170,7 +170,7 @@ internal class HeadersTest { .replace("NAME", listOf("value2", "value3")) .build(), expectedMap = mapOf("NAME" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( Headers.builder() @@ -183,9 +183,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( Headers.builder() @@ -198,9 +198,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -209,8 +209,8 @@ internal class HeadersTest { .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) .build(), expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), - expectedSize = 2 - ) + expectedSize = 2, + ), } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt index bc1d36a0..08e55c66 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt @@ -11,28 +11,28 @@ internal class QueryParamsTest { enum class TestCase( val queryParams: QueryParams, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( QueryParams.builder().put("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( QueryParams.builder().put("key1", "value").put("key2", "value").build(), expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( QueryParams.builder().put("key", "value1").put("key", "value2").build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( QueryParams.builder() @@ -40,40 +40,40 @@ internal class QueryParamsTest { .put("key", listOf("value1", "value2")) .build(), expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_MAP( QueryParams.builder() .putAll( mapOf( "key1" to listOf("value1", "value2"), - "key2" to listOf("value1", "value2") + "key2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REMOVE_ABSENT( QueryParams.builder().remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( QueryParams.builder().put("key", "value").remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( QueryParams.builder() @@ -82,22 +82,22 @@ internal class QueryParamsTest { .removeAll(setOf("key1", "key2", "key3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( QueryParams.builder().replace("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( QueryParams.builder().put("key", "value1").replace("key", "value2").build(), expectedMap = mapOf("key" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( QueryParams.builder() @@ -105,12 +105,12 @@ internal class QueryParamsTest { .replace("key", "value3") .build(), expectedMap = mapOf("key" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( QueryParams.builder().replace("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( QueryParams.builder() @@ -118,7 +118,7 @@ internal class QueryParamsTest { .replace("key", listOf("value2", "value3")) .build(), expectedMap = mapOf("key" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( QueryParams.builder() @@ -126,7 +126,7 @@ internal class QueryParamsTest { .replace("key", listOf("value3", "value4")) .build(), expectedMap = mapOf("key" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( QueryParams.builder() @@ -139,9 +139,9 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( QueryParams.builder() @@ -156,10 +156,10 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 - ) + expectedSize = 3, + ), } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt index 60a23068..d538b9b3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt @@ -26,12 +26,12 @@ internal class RetryingHttpClientTest { object : HttpClient { override fun execute( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture = okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } @@ -71,7 +71,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) @@ -97,7 +97,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) @@ -140,24 +140,24 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("0")) + .withHeader("x-stainless-retry-count", equalTo("0")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("1")) + .withHeader("x-stainless-retry-count", equalTo("1")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("2")) + .withHeader("x-stainless-retry-count", equalTo("2")), ) assertNoResponseLeaks() } @@ -191,14 +191,14 @@ internal class RetryingHttpClientTest { .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) verify( 2, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("42")) + .withHeader("x-stainless-retry-count", equalTo("42")), ) assertNoResponseLeaks() } @@ -226,7 +226,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt index fc573164..824c8711 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt @@ -48,11 +48,7 @@ internal class SerializerTest { override fun hashCode(): Int { if (hashCode == 0) { - hashCode = - Objects.hash( - isActive, - additionalProperties, - ) + hashCode = Objects.hash(isActive, additionalProperties) } return hashCode } @@ -91,10 +87,7 @@ internal class SerializerTest { } fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs( - isActive, - additionalProperties.toImmutable(), - ) + ClassWithBooleanFieldPrefixedWithIs(isActive, additionalProperties.toImmutable()) } } 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 f842bd44..174747e9 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 @@ -37,7 +37,7 @@ class AclListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt index 07e6c4f5..fff7ec47 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt @@ -37,12 +37,12 @@ class AiSecretListParamsTest { expected.put("ai_secret_name", "ai_secret_name") expected.put( "ai_secret_type", - AiSecretListParams.AiSecretType.ofString("string").toString() + AiSecretListParams.AiSecretType.ofString("string").toString(), ) expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index 60a9e7bb..41532fd3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -36,7 +36,7 @@ class ApiKeyListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt index 5e7da92f..6ce8e5d3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt @@ -16,7 +16,7 @@ class CrossObjectInsertResponseTest { CrossObjectInsertResponse.Dataset.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))) + JsonValue.from(mapOf("row_ids" to listOf("string"))), ) .build() ) @@ -24,7 +24,7 @@ class CrossObjectInsertResponseTest { CrossObjectInsertResponse.Experiment.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))) + JsonValue.from(mapOf("row_ids" to listOf("string"))), ) .build() ) @@ -32,7 +32,7 @@ class CrossObjectInsertResponseTest { CrossObjectInsertResponse.ProjectLogs.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))) + JsonValue.from(mapOf("row_ids" to listOf("string"))), ) .build() ) @@ -43,7 +43,7 @@ class CrossObjectInsertResponseTest { CrossObjectInsertResponse.Dataset.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))) + JsonValue.from(mapOf("row_ids" to listOf("string"))), ) .build() ) @@ -52,7 +52,7 @@ class CrossObjectInsertResponseTest { CrossObjectInsertResponse.Experiment.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))) + JsonValue.from(mapOf("row_ids" to listOf("string"))), ) .build() ) @@ -61,7 +61,7 @@ class CrossObjectInsertResponseTest { CrossObjectInsertResponse.ProjectLogs.builder() .putAdditionalProperty( "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))) + JsonValue.from(mapOf("row_ids" to listOf("string"))), ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index 7ba3c2ac..de58fd44 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -40,7 +40,7 @@ class DatasetListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") 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 f05ccab5..4af4a47a 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 @@ -33,7 +33,7 @@ class EnvVarListParamsTest { expected.put("env_var_name", "env_var_name") expected.put( "ids", - EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 61605b19..06a265e5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -40,7 +40,7 @@ class ExperimentListParamsTest { expected.put("experiment_name", "experiment_name") expected.put( "ids", - ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 3f340fc9..289b3695 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -44,7 +44,7 @@ class FunctionListParamsTest { expected.put("function_name", "function_name") expected.put( "ids", - FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index 149ae449..c5cd5eb4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -36,7 +36,7 @@ class GroupListParamsTest { expected.put("group_name", "group_name") expected.put( "ids", - GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index 66664552..823cdd9c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -33,7 +33,7 @@ class OrganizationListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 90339cf7..2f0484be 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -35,7 +35,7 @@ class ProjectListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") 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 17726294..6084f831 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 @@ -41,7 +41,7 @@ class ProjectScoreListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") @@ -53,7 +53,7 @@ class ProjectScoreListParamsTest { ProjectScoreListParams.ScoreType.ofProject( ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString() ) - .toString() + .toString(), ) expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(params._queryParams()).isEqualTo(expected.build()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index d007b0c8..b0008157 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -39,7 +39,7 @@ class ProjectTagListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index c740d3a6..913ef416 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -43,7 +43,7 @@ class PromptListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 1a8c09f7..9a390aec 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -35,7 +35,7 @@ class RoleListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt index cf530193..50d720b8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt @@ -35,7 +35,7 @@ class SpanIframeListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt index eec695dc..35580e00 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt @@ -30,7 +30,7 @@ class SummarizeExperimentResponseTest { "unit" to "unit", "diff" to 0, ) - ) + ), ) .build() ) @@ -46,7 +46,7 @@ class SummarizeExperimentResponseTest { "score" to 0, "diff" to -1, ) - ) + ), ) .build() ) @@ -72,7 +72,7 @@ class SummarizeExperimentResponseTest { "unit" to "unit", "diff" to 0, ) - ) + ), ) .build() ) @@ -89,7 +89,7 @@ class SummarizeExperimentResponseTest { "score" to 0, "diff" to -1, ) - ) + ), ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 815ec2d7..02f28453 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -42,7 +42,7 @@ class UserListParamsTest { expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) expected.put( "ids", - UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("org_name", "org_name") 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 4a5f2d9e..35c71549 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 @@ -41,7 +41,7 @@ class ViewListParamsTest { expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put( "ids", - ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() + ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), ) expected.put("limit", "0") expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index fce7d036..49e14b56 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -118,7 +118,7 @@ class ErrorHandlingTest { assertPermissionDenied( e, Headers.builder().put("Foo", "Bar").build(), - BRAINTRUST_ERROR + BRAINTRUST_ERROR, ) }) } @@ -152,7 +152,7 @@ class ErrorHandlingTest { assertUnprocessableEntity( e, Headers.builder().put("Foo", "Bar").build(), - BRAINTRUST_ERROR + BRAINTRUST_ERROR, ) }) } @@ -186,7 +186,7 @@ class ErrorHandlingTest { assertInternalServer( e, Headers.builder().put("Foo", "Bar").build(), - BRAINTRUST_ERROR + BRAINTRUST_ERROR, ) }) } @@ -206,7 +206,7 @@ class ErrorHandlingTest { e, 999, Headers.builder().put("Foo", "Bar").build(), - toJson(BRAINTRUST_ERROR) + toJson(BRAINTRUST_ERROR), ) }) } @@ -245,7 +245,7 @@ class ErrorHandlingTest { throwable: Throwable, statusCode: Int, headers: Headers, - responseBody: ByteArray + responseBody: ByteArray, ) { assertThat(throwable) .asInstanceOf( @@ -281,7 +281,7 @@ class ErrorHandlingTest { private fun assertPermissionDenied( throwable: Throwable, headers: Headers, - error: BraintrustError + error: BraintrustError, ) { assertThat(throwable) .asInstanceOf( @@ -307,7 +307,7 @@ class ErrorHandlingTest { private fun assertUnprocessableEntity( throwable: Throwable, headers: Headers, - error: BraintrustError + error: BraintrustError, ) { assertThat(throwable) .asInstanceOf( @@ -333,7 +333,7 @@ class ErrorHandlingTest { private fun assertInternalServer( throwable: Throwable, headers: Headers, - error: BraintrustError + error: BraintrustError, ) { assertThat(throwable) .asInstanceOf(InstanceOfAssertFactories.throwable(InternalServerException::class.java)) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 8a1d7a10..d1ed374d 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `kotlin-dsl` - kotlin("jvm") version "2.1.0" + kotlin("jvm") version "2.1.10" id("com.vanniktech.maven.publish") version "0.28.0" } @@ -10,7 +10,7 @@ repositories { } dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23") + implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.10") implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/braintrust.java.gradle.kts b/buildSrc/src/main/kotlin/braintrust.java.gradle.kts index a2c35b93..597b6e80 100755 --- a/buildSrc/src/main/kotlin/braintrust.java.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.java.gradle.kts @@ -39,9 +39,13 @@ tasks.named("jar") { } } -tasks.named("test") { +tasks.withType().configureEach { useJUnitPlatform() + // Run tests in parallel to some degree. + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 + testLogging { exceptionFormat = TestExceptionFormat.FULL } diff --git a/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts b/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts index 5d605cc4..322e94ff 100755 --- a/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts @@ -1,4 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -20,13 +21,19 @@ configure { } tasks.withType().configureEach { - kotlinOptions { + compilerOptions { freeCompilerArgs = listOf( "-Xjvm-default=all", "-Xjdk-release=1.8", // Suppress deprecation warnings because we may still reference and test deprecated members. "-Xsuppress-warning=DEPRECATION" ) - jvmTarget = "1.8" + jvmTarget.set(JvmTarget.JVM_1_8) } } + +// Run tests in parallel to some degree. +tasks.withType().configureEach { + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 +} diff --git a/gradle.properties b/gradle.properties index a3bc58f2..ec5c5092 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,6 @@ +org.gradle.configuration-cache=true org.gradle.caching=true -org.gradle.jvmargs=-Xmx4g org.gradle.parallel=true +org.gradle.daemon=false +org.gradle.jvmargs=-Xmx4g kotlin.daemon.jvmargs=-Xmx4g diff --git a/scripts/format b/scripts/format index c6239fab..456a69db 100755 --- a/scripts/format +++ b/scripts/format @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Running spotlessApply" -./gradlew --build-cache --parallel --no-daemon spotlessApply +./gradlew spotlessApply diff --git a/scripts/lint b/scripts/lint index 58753d0b..e3a5f5e2 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Build classes" -./gradlew --build-cache --parallel --no-daemon build testClasses -x test +./gradlew build testClasses -x test diff --git a/scripts/test b/scripts/test index 72ed0333..6b750a74 100755 --- a/scripts/test +++ b/scripts/test @@ -53,4 +53,4 @@ else fi echo "==> Running tests" -./gradlew --build-cache --parallel --no-daemon test +./gradlew test From b417ac7d07cc916a3928a17a57406b08ed014fa0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 07:29:12 +0000 Subject: [PATCH 42/87] chore(internal): use better test example values (#112) chore(internal): rename internal body classes chore(internal): make body class constructors private chore(internal): make body classes for multipart requests chore(internal): misc formatting changes --- .../api/models/AclBatchUpdateParams.kt | 30 +++++----- .../api/models/AclCreateParams.kt | 40 ++++++------- .../api/models/AclFindAndDeleteParams.kt | 40 ++++++------- .../api/models/AiSecretCreateParams.kt | 36 ++++++------ .../api/models/AiSecretFindAndDeleteParams.kt | 34 +++++------ .../api/models/AiSecretReplaceParams.kt | 36 ++++++------ .../api/models/AiSecretUpdateParams.kt | 34 +++++------ .../api/models/ApiKeyCreateParams.kt | 34 +++++------ .../api/models/DatasetCreateParams.kt | 34 +++++------ .../api/models/DatasetFeedbackParams.kt | 28 +++++----- .../api/models/DatasetFetchPostParams.kt | 36 ++++++------ .../api/models/DatasetInsertParams.kt | 29 +++++----- .../api/models/DatasetUpdateParams.kt | 32 +++++------ .../api/models/EnvVarCreateParams.kt | 34 +++++------ .../api/models/EnvVarReplaceParams.kt | 34 +++++------ .../api/models/EnvVarUpdateParams.kt | 34 +++++------ .../api/models/EvalCreateParams.kt | 56 +++++++++---------- .../api/models/ExperimentCreateParams.kt | 46 +++++++-------- .../api/models/ExperimentFeedbackParams.kt | 28 +++++----- .../api/models/ExperimentFetchPostParams.kt | 36 ++++++------ .../api/models/ExperimentInsertParams.kt | 29 +++++----- .../api/models/ExperimentUpdateParams.kt | 42 +++++++------- .../api/models/FunctionCreateParams.kt | 46 +++++++-------- .../api/models/FunctionInvokeParams.kt | 38 ++++++------- .../api/models/FunctionReplaceParams.kt | 46 +++++++-------- .../api/models/FunctionUpdateParams.kt | 36 ++++++------ .../api/models/GroupCreateParams.kt | 36 ++++++------ .../api/models/GroupReplaceParams.kt | 36 ++++++------ .../api/models/GroupUpdateParams.kt | 38 ++++++------- .../models/OrganizationMemberUpdateParams.kt | 42 ++++++-------- .../api/models/OrganizationUpdateParams.kt | 36 ++++++------ .../api/models/ProjectCreateParams.kt | 34 +++++------ .../api/models/ProjectLogFeedbackParams.kt | 28 +++++----- .../api/models/ProjectLogFetchPostParams.kt | 36 ++++++------ .../api/models/ProjectLogInsertParams.kt | 29 +++++----- .../api/models/ProjectScoreCreateParams.kt | 38 ++++++------- .../api/models/ProjectScoreReplaceParams.kt | 38 ++++++------- .../api/models/ProjectScoreUpdateParams.kt | 36 ++++++------ .../api/models/ProjectTagCreateParams.kt | 34 +++++------ .../api/models/ProjectTagReplaceParams.kt | 34 +++++------ .../api/models/ProjectTagUpdateParams.kt | 31 +++++----- .../api/models/ProjectUpdateParams.kt | 29 +++++----- .../api/models/PromptCreateParams.kt | 40 ++++++------- .../api/models/PromptReplaceParams.kt | 40 ++++++------- .../api/models/PromptUpdateParams.kt | 36 ++++++------ .../api/models/RoleCreateParams.kt | 36 ++++++------ .../api/models/RoleReplaceParams.kt | 36 ++++++------ .../api/models/RoleUpdateParams.kt | 40 +++++++------ .../api/models/SpanIframeCreateParams.kt | 36 ++++++------ .../api/models/SpanIframeReplaceParams.kt | 36 ++++++------ .../api/models/SpanIframeUpdateParams.kt | 31 +++++----- .../api/models/ViewCreateParams.kt | 42 +++++++------- .../api/models/ViewDeleteParams.kt | 30 +++++----- .../api/models/ViewReplaceParams.kt | 42 +++++++------- .../api/models/ViewUpdateParams.kt | 40 ++++++------- .../api/models/AclBatchUpdateParamsTest.kt | 4 ++ .../api/models/AclCreateParamsTest.kt | 4 ++ .../api/models/AclFindAndDeleteParamsTest.kt | 4 ++ .../api/models/AiSecretCreateParamsTest.kt | 4 ++ .../models/AiSecretFindAndDeleteParamsTest.kt | 4 ++ .../api/models/AiSecretReplaceParamsTest.kt | 4 ++ .../api/models/AiSecretUpdateParamsTest.kt | 4 ++ .../api/models/ApiKeyCreateParamsTest.kt | 4 ++ .../api/models/DatasetCreateParamsTest.kt | 4 ++ .../api/models/DatasetFeedbackParamsTest.kt | 4 ++ .../api/models/DatasetFetchPostParamsTest.kt | 4 ++ .../api/models/DatasetInsertParamsTest.kt | 4 ++ .../api/models/DatasetUpdateParamsTest.kt | 4 ++ .../api/models/EnvVarCreateParamsTest.kt | 4 ++ .../api/models/EnvVarReplaceParamsTest.kt | 4 ++ .../api/models/EnvVarUpdateParamsTest.kt | 4 ++ .../api/models/EvalCreateParamsTest.kt | 4 ++ .../api/models/ExperimentCreateParamsTest.kt | 4 ++ .../models/ExperimentFeedbackParamsTest.kt | 4 ++ .../models/ExperimentFetchPostParamsTest.kt | 4 ++ .../api/models/ExperimentInsertParamsTest.kt | 4 ++ .../api/models/ExperimentUpdateParamsTest.kt | 4 ++ .../api/models/FunctionCreateParamsTest.kt | 4 ++ .../api/models/FunctionInvokeParamsTest.kt | 4 ++ .../api/models/FunctionReplaceParamsTest.kt | 4 ++ .../api/models/FunctionUpdateParamsTest.kt | 4 ++ .../api/models/GroupCreateParamsTest.kt | 4 ++ .../api/models/GroupReplaceParamsTest.kt | 4 ++ .../api/models/GroupUpdateParamsTest.kt | 4 ++ .../OrganizationMemberUpdateParamsTest.kt | 4 ++ .../models/OrganizationUpdateParamsTest.kt | 4 ++ .../api/models/ProjectCreateParamsTest.kt | 4 ++ .../models/ProjectLogFeedbackParamsTest.kt | 4 ++ .../models/ProjectLogFetchPostParamsTest.kt | 4 ++ .../api/models/ProjectLogInsertParamsTest.kt | 4 ++ .../models/ProjectScoreCreateParamsTest.kt | 4 ++ .../models/ProjectScoreReplaceParamsTest.kt | 4 ++ .../models/ProjectScoreUpdateParamsTest.kt | 4 ++ .../api/models/ProjectTagCreateParamsTest.kt | 4 ++ .../api/models/ProjectTagReplaceParamsTest.kt | 4 ++ .../api/models/ProjectTagUpdateParamsTest.kt | 4 ++ .../api/models/ProjectUpdateParamsTest.kt | 4 ++ .../api/models/PromptCreateParamsTest.kt | 4 ++ .../api/models/PromptReplaceParamsTest.kt | 4 ++ .../api/models/PromptUpdateParamsTest.kt | 4 ++ .../api/models/RoleCreateParamsTest.kt | 4 ++ .../api/models/RoleReplaceParamsTest.kt | 4 ++ .../api/models/RoleUpdateParamsTest.kt | 4 ++ .../api/models/SpanIframeCreateParamsTest.kt | 4 ++ .../api/models/SpanIframeReplaceParamsTest.kt | 4 ++ .../api/models/SpanIframeUpdateParamsTest.kt | 4 ++ .../api/models/ViewCreateParamsTest.kt | 4 ++ .../api/models/ViewDeleteParamsTest.kt | 4 ++ .../api/models/ViewReplaceParamsTest.kt | 4 ++ .../api/models/ViewUpdateParamsTest.kt | 4 ++ 110 files changed, 1198 insertions(+), 1010 deletions(-) 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 26fd6110..0e65c029 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 @@ -28,7 +28,7 @@ import java.util.Optional */ class AclBatchUpdateParams private constructor( - private val body: AclBatchUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -87,16 +87,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): AclBatchUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class AclBatchUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("add_acls") @ExcludeMissing private val addAcls: JsonField> = JsonMissing.of(), @@ -164,7 +164,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AclBatchUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -181,7 +181,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AclBatchUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var addAcls: JsonField>? = null @@ -189,10 +189,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclBatchUpdateBody: AclBatchUpdateBody) = apply { - addAcls = aclBatchUpdateBody.addAcls.map { it.toMutableList() } - removeAcls = aclBatchUpdateBody.removeAcls.map { it.toMutableList() } - additionalProperties = aclBatchUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + addAcls = body.addAcls.map { it.toMutableList() } + removeAcls = body.removeAcls.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** @@ -346,8 +346,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AclBatchUpdateBody = - AclBatchUpdateBody( + fun build(): Body = + Body( (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), @@ -359,7 +359,7 @@ private constructor( return true } - return /* spotless:off */ other is AclBatchUpdateBody && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -369,7 +369,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AclBatchUpdateBody{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" + "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -383,7 +383,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: AclBatchUpdateBody.Builder = AclBatchUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 eb221d16..f5aafa3e 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 @@ -28,7 +28,7 @@ import java.util.Optional */ class AclCreateParams private constructor( - private val body: AclCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -95,7 +95,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): AclCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -112,9 +112,9 @@ private constructor( * ACL, as part of a direct permission grant or as part of a role. */ @NoAutoDetect - class AclCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), @@ -218,7 +218,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AclCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -240,7 +240,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AclCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var objectId: JsonField? = null @@ -253,15 +253,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclCreateBody: AclCreateBody) = apply { - objectId = aclCreateBody.objectId - objectType = aclCreateBody.objectType - groupId = aclCreateBody.groupId - permission = aclCreateBody.permission - restrictObjectType = aclCreateBody.restrictObjectType - roleId = aclCreateBody.roleId - userId = aclCreateBody.userId - additionalProperties = aclCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + objectId = body.objectId + objectType = body.objectType + groupId = body.groupId + permission = body.permission + restrictObjectType = body.restrictObjectType + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() } /** The id of the object the ACL applies to */ @@ -390,8 +390,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AclCreateBody = - AclCreateBody( + fun build(): Body = + Body( checkRequired("objectId", objectId), checkRequired("objectType", objectType), groupId, @@ -408,7 +408,7 @@ private constructor( return true } - return /* spotless:off */ other is AclCreateBody && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -418,7 +418,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -432,7 +432,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: AclCreateBody.Builder = AclCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 b07b4e96..0bf8a642 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 @@ -25,7 +25,7 @@ import java.util.Optional /** Delete a single acl */ class AclFindAndDeleteParams private constructor( - private val body: AclFindAndDeleteBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -92,7 +92,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): AclFindAndDeleteBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -109,9 +109,9 @@ private constructor( * ACL, as part of a direct permission grant or as part of a role. */ @NoAutoDetect - class AclFindAndDeleteBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), @@ -215,7 +215,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AclFindAndDeleteBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -237,7 +237,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AclFindAndDeleteBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var objectId: JsonField? = null @@ -250,15 +250,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclFindAndDeleteBody: AclFindAndDeleteBody) = apply { - objectId = aclFindAndDeleteBody.objectId - objectType = aclFindAndDeleteBody.objectType - groupId = aclFindAndDeleteBody.groupId - permission = aclFindAndDeleteBody.permission - restrictObjectType = aclFindAndDeleteBody.restrictObjectType - roleId = aclFindAndDeleteBody.roleId - userId = aclFindAndDeleteBody.userId - additionalProperties = aclFindAndDeleteBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + objectId = body.objectId + objectType = body.objectType + groupId = body.groupId + permission = body.permission + restrictObjectType = body.restrictObjectType + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() } /** The id of the object the ACL applies to */ @@ -387,8 +387,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AclFindAndDeleteBody = - AclFindAndDeleteBody( + fun build(): Body = + Body( checkRequired("objectId", objectId), checkRequired("objectType", objectType), groupId, @@ -405,7 +405,7 @@ private constructor( return true } - return /* spotless:off */ other is AclFindAndDeleteBody && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -415,7 +415,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AclFindAndDeleteBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -429,7 +429,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: AclFindAndDeleteBody.Builder = AclFindAndDeleteBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 009c5e73..52186b1d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class AiSecretCreateParams private constructor( - private val body: AiSecretCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -77,16 +77,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): AiSecretCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class AiSecretCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -152,7 +152,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AiSecretCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -172,7 +172,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AiSecretCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -183,13 +183,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecretCreateBody: AiSecretCreateBody) = apply { - name = aiSecretCreateBody.name - metadata = aiSecretCreateBody.metadata - orgName = aiSecretCreateBody.orgName - secret = aiSecretCreateBody.secret - type = aiSecretCreateBody.type - additionalProperties = aiSecretCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + metadata = body.metadata + orgName = body.orgName + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the AI secret */ @@ -268,8 +268,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AiSecretCreateBody = - AiSecretCreateBody( + fun build(): Body = + Body( checkRequired("name", name), metadata, orgName, @@ -284,7 +284,7 @@ private constructor( return true } - return /* spotless:off */ other is AiSecretCreateBody && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -294,7 +294,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AiSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -308,7 +308,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: AiSecretCreateBody.Builder = AiSecretCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 7496e3a5..0ce64f06 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -23,7 +23,7 @@ import java.util.Optional /** Delete a single ai_secret */ class AiSecretFindAndDeleteParams private constructor( - private val body: AiSecretFindAndDeleteBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -54,16 +54,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): AiSecretFindAndDeleteBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class AiSecretFindAndDeleteBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -100,7 +100,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AiSecretFindAndDeleteBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -117,7 +117,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AiSecretFindAndDeleteBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -125,10 +125,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecretFindAndDeleteBody: AiSecretFindAndDeleteBody) = apply { - name = aiSecretFindAndDeleteBody.name - orgName = aiSecretFindAndDeleteBody.orgName - additionalProperties = aiSecretFindAndDeleteBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the AI secret */ @@ -177,12 +177,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AiSecretFindAndDeleteBody = - AiSecretFindAndDeleteBody( - checkRequired("name", name), - orgName, - additionalProperties.toImmutable(), - ) + fun build(): Body = + Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -190,7 +186,7 @@ private constructor( return true } - return /* spotless:off */ other is AiSecretFindAndDeleteBody && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -200,7 +196,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AiSecretFindAndDeleteBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -214,7 +210,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: AiSecretFindAndDeleteBody.Builder = AiSecretFindAndDeleteBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 8af3e1ff..49d9681f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class AiSecretReplaceParams private constructor( - private val body: AiSecretReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -77,16 +77,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): AiSecretReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class AiSecretReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -152,7 +152,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AiSecretReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -172,7 +172,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AiSecretReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -183,13 +183,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecretReplaceBody: AiSecretReplaceBody) = apply { - name = aiSecretReplaceBody.name - metadata = aiSecretReplaceBody.metadata - orgName = aiSecretReplaceBody.orgName - secret = aiSecretReplaceBody.secret - type = aiSecretReplaceBody.type - additionalProperties = aiSecretReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + metadata = body.metadata + orgName = body.orgName + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the AI secret */ @@ -268,8 +268,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AiSecretReplaceBody = - AiSecretReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), metadata, orgName, @@ -284,7 +284,7 @@ private constructor( return true } - return /* spotless:off */ other is AiSecretReplaceBody && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -294,7 +294,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AiSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -308,7 +308,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: AiSecretReplaceBody.Builder = AiSecretReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index a0320d60..12b710da 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class AiSecretUpdateParams private constructor( private val aiSecretId: String, - private val body: AiSecretUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -60,7 +60,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): AiSecretUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -74,9 +74,9 @@ private constructor( } @NoAutoDetect - class AiSecretUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), @@ -117,7 +117,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AiSecretUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -136,7 +136,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AiSecretUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var metadata: JsonField = JsonMissing.of() @@ -146,12 +146,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecretUpdateBody: AiSecretUpdateBody) = apply { - metadata = aiSecretUpdateBody.metadata - name = aiSecretUpdateBody.name - secret = aiSecretUpdateBody.secret - type = aiSecretUpdateBody.type - additionalProperties = aiSecretUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + metadata = body.metadata + name = body.name + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -200,8 +200,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AiSecretUpdateBody = - AiSecretUpdateBody(metadata, name, secret, type, additionalProperties.toImmutable()) + fun build(): Body = + Body(metadata, name, secret, type, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -209,7 +209,7 @@ private constructor( return true } - return /* spotless:off */ other is AiSecretUpdateBody && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -219,7 +219,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AiSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + "Body{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -234,7 +234,7 @@ private constructor( class Builder internal constructor() { private var aiSecretId: String? = null - private var body: AiSecretUpdateBody.Builder = AiSecretUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 057a7a4f..f806f2b0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class ApiKeyCreateParams private constructor( - private val body: ApiKeyCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -57,16 +57,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ApiKeyCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class ApiKeyCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -103,7 +103,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ApiKeyCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -120,7 +120,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ApiKeyCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -128,10 +128,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyCreateBody: ApiKeyCreateBody) = apply { - name = apiKeyCreateBody.name - orgName = apiKeyCreateBody.orgName - additionalProperties = apiKeyCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the api key. Does not have to be unique */ @@ -180,12 +180,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ApiKeyCreateBody = - ApiKeyCreateBody( - checkRequired("name", name), - orgName, - additionalProperties.toImmutable(), - ) + fun build(): Body = + Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -193,7 +189,7 @@ private constructor( return true } - return /* spotless:off */ other is ApiKeyCreateBody && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -203,7 +199,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -217,7 +213,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ApiKeyCreateBody.Builder = ApiKeyCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 78a46026..461f22a5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class DatasetCreateParams private constructor( - private val body: DatasetCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -61,16 +61,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): DatasetCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class DatasetCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -120,7 +120,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -139,7 +139,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DatasetCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -149,12 +149,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetCreateBody: DatasetCreateBody) = apply { - name = datasetCreateBody.name - projectId = datasetCreateBody.projectId - description = datasetCreateBody.description - metadata = datasetCreateBody.metadata - additionalProperties = datasetCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + description = body.description + metadata = body.metadata + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the dataset. Within a project, dataset names are unique */ @@ -208,8 +208,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): DatasetCreateBody = - DatasetCreateBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), description, @@ -223,7 +223,7 @@ private constructor( return true } - return /* spotless:off */ other is DatasetCreateBody && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -233,7 +233,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DatasetCreateBody{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -247,7 +247,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: DatasetCreateBody.Builder = DatasetCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 3d9778cf..39b4e5cc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -23,7 +23,7 @@ import java.util.Objects class DatasetFeedbackParams private constructor( private val datasetId: String, - private val body: DatasetFeedbackBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -43,7 +43,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): DatasetFeedbackBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -57,9 +57,9 @@ private constructor( } @NoAutoDetect - class DatasetFeedbackBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), @@ -81,7 +81,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetFeedbackBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -97,16 +97,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DatasetFeedbackBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var feedback: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetFeedbackBody: DatasetFeedbackBody) = apply { - feedback = datasetFeedbackBody.feedback.map { it.toMutableList() } - additionalProperties = datasetFeedbackBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** A list of dataset feedback items */ @@ -150,8 +150,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): DatasetFeedbackBody = - DatasetFeedbackBody( + fun build(): Body = + Body( checkRequired("feedback", feedback).map { it.toImmutable() }, additionalProperties.toImmutable(), ) @@ -162,7 +162,7 @@ private constructor( return true } - return /* spotless:off */ other is DatasetFeedbackBody && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -172,7 +172,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -187,7 +187,7 @@ private constructor( class Builder internal constructor() { private var datasetId: String? = null - private var body: DatasetFeedbackBody.Builder = DatasetFeedbackBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 98ba9956..9f7615ab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class DatasetFetchPostParams private constructor( private val datasetId: String, - private val body: DatasetFetchPostBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -162,7 +162,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): DatasetFetchPostBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -176,9 +176,9 @@ private constructor( } @NoAutoDetect - class DatasetFetchPostBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @@ -332,7 +332,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetFetchPostBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -352,7 +352,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DatasetFetchPostBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var cursor: JsonField = JsonMissing.of() @@ -363,13 +363,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetFetchPostBody: DatasetFetchPostBody) = apply { - cursor = datasetFetchPostBody.cursor - limit = datasetFetchPostBody.limit - maxRootSpanId = datasetFetchPostBody.maxRootSpanId - maxXactId = datasetFetchPostBody.maxXactId - version = datasetFetchPostBody.version - additionalProperties = datasetFetchPostBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() } /** @@ -602,8 +602,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): DatasetFetchPostBody = - DatasetFetchPostBody( + fun build(): Body = + Body( cursor, limit, maxRootSpanId, @@ -618,7 +618,7 @@ private constructor( return true } - return /* spotless:off */ other is DatasetFetchPostBody && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,7 +628,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DatasetFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -643,7 +643,7 @@ private constructor( class Builder internal constructor() { private var datasetId: String? = null - private var body: DatasetFetchPostBody.Builder = DatasetFetchPostBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 35984246..36e3bf88 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -23,7 +23,7 @@ import java.util.Objects class DatasetInsertParams private constructor( private val datasetId: String, - private val body: DatasetInsertBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -43,7 +43,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): DatasetInsertBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -57,9 +57,9 @@ private constructor( } @NoAutoDetect - class DatasetInsertBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), @@ -81,7 +81,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetInsertBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -97,16 +97,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DatasetInsertBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetInsertBody: DatasetInsertBody) = apply { - events = datasetInsertBody.events.map { it.toMutableList() } - additionalProperties = datasetInsertBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** A list of dataset events to insert */ @@ -150,8 +150,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): DatasetInsertBody = - DatasetInsertBody( + fun build(): Body = + Body( checkRequired("events", events).map { it.toImmutable() }, additionalProperties.toImmutable(), ) @@ -162,7 +162,7 @@ private constructor( return true } - return /* spotless:off */ other is DatasetInsertBody && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -171,8 +171,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = "Body{events=$events, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -187,7 +186,7 @@ private constructor( class Builder internal constructor() { private var datasetId: String? = null - private var body: DatasetInsertBody.Builder = DatasetInsertBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 22e60d26..53eee982 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class DatasetUpdateParams private constructor( private val datasetId: String, - private val body: DatasetUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -60,7 +60,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): DatasetUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -74,9 +74,9 @@ private constructor( } @NoAutoDetect - class DatasetUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -117,7 +117,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -135,7 +135,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DatasetUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var description: JsonField = JsonMissing.of() @@ -144,11 +144,11 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetUpdateBody: DatasetUpdateBody) = apply { - description = datasetUpdateBody.description - metadata = datasetUpdateBody.metadata - name = datasetUpdateBody.name - additionalProperties = datasetUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + description = body.description + metadata = body.metadata + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() } /** Textual description of the dataset */ @@ -199,8 +199,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): DatasetUpdateBody = - DatasetUpdateBody(description, metadata, name, additionalProperties.toImmutable()) + fun build(): Body = + Body(description, metadata, name, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -208,7 +208,7 @@ private constructor( return true } - return /* spotless:off */ other is DatasetUpdateBody && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -218,7 +218,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" + "Body{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -233,7 +233,7 @@ private constructor( class Builder internal constructor() { private var datasetId: String? = null - private var body: DatasetUpdateBody.Builder = DatasetUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index f4f956fd..5c80a17f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional */ class EnvVarCreateParams private constructor( - private val body: EnvVarCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -63,16 +63,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): EnvVarCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class EnvVarCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -121,7 +121,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EnvVarCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -140,7 +140,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EnvVarCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -150,12 +150,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarCreateBody: EnvVarCreateBody) = apply { - name = envVarCreateBody.name - objectId = envVarCreateBody.objectId - objectType = envVarCreateBody.objectType - value = envVarCreateBody.value - additionalProperties = envVarCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() } /** The name of the environment variable */ @@ -206,8 +206,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): EnvVarCreateBody = - EnvVarCreateBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("objectId", objectId), checkRequired("objectType", objectType), @@ -221,7 +221,7 @@ private constructor( return true } - return /* spotless:off */ other is EnvVarCreateBody && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -231,7 +231,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EnvVarCreateBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" + "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -245,7 +245,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: EnvVarCreateBody.Builder = EnvVarCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index 40de51c8..f42d2c35 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -28,7 +28,7 @@ import java.util.Optional */ class EnvVarReplaceParams private constructor( - private val body: EnvVarReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -63,16 +63,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): EnvVarReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class EnvVarReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -121,7 +121,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EnvVarReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -140,7 +140,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EnvVarReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -150,12 +150,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarReplaceBody: EnvVarReplaceBody) = apply { - name = envVarReplaceBody.name - objectId = envVarReplaceBody.objectId - objectType = envVarReplaceBody.objectType - value = envVarReplaceBody.value - additionalProperties = envVarReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() } /** The name of the environment variable */ @@ -206,8 +206,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): EnvVarReplaceBody = - EnvVarReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("objectId", objectId), checkRequired("objectType", objectType), @@ -221,7 +221,7 @@ private constructor( return true } - return /* spotless:off */ other is EnvVarReplaceBody && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -231,7 +231,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EnvVarReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" + "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -245,7 +245,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: EnvVarReplaceBody.Builder = EnvVarReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 145dc69f..03cd42ed 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class EnvVarUpdateParams private constructor( private val envVarId: String, - private val body: EnvVarUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -54,7 +54,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): EnvVarUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -68,9 +68,9 @@ private constructor( } @NoAutoDetect - class EnvVarUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -99,7 +99,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EnvVarUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -116,7 +116,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EnvVarUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -124,10 +124,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarUpdateBody: EnvVarUpdateBody) = apply { - name = envVarUpdateBody.name - value = envVarUpdateBody.value - additionalProperties = envVarUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() } /** The name of the environment variable */ @@ -164,12 +164,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): EnvVarUpdateBody = - EnvVarUpdateBody( - checkRequired("name", name), - value, - additionalProperties.toImmutable(), - ) + fun build(): Body = + Body(checkRequired("name", name), value, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -177,7 +173,7 @@ private constructor( return true } - return /* spotless:off */ other is EnvVarUpdateBody && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -187,7 +183,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EnvVarUpdateBody{name=$name, value=$value, additionalProperties=$additionalProperties}" + "Body{name=$name, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -202,7 +198,7 @@ private constructor( class Builder internal constructor() { private var envVarId: String? = null - private var body: EnvVarUpdateBody.Builder = EnvVarUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 5fbff021..9e741c34 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -41,7 +41,7 @@ import java.util.Optional */ class EvalCreateParams private constructor( - private val body: EvalCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -200,16 +200,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): EvalCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class EvalCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), @JsonProperty("project_id") @ExcludeMissing @@ -427,7 +427,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EvalCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -457,7 +457,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EvalCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var data: JsonField? = null @@ -478,23 +478,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(evalCreateBody: EvalCreateBody) = apply { - data = evalCreateBody.data - projectId = evalCreateBody.projectId - scores = evalCreateBody.scores.map { it.toMutableList() } - task = evalCreateBody.task - baseExperimentId = evalCreateBody.baseExperimentId - baseExperimentName = evalCreateBody.baseExperimentName - experimentName = evalCreateBody.experimentName - gitMetadataSettings = evalCreateBody.gitMetadataSettings - isPublic = evalCreateBody.isPublic - maxConcurrency = evalCreateBody.maxConcurrency - metadata = evalCreateBody.metadata - repoInfo = evalCreateBody.repoInfo - stream = evalCreateBody.stream - timeout = evalCreateBody.timeout - trialCount = evalCreateBody.trialCount - additionalProperties = evalCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + data = body.data + projectId = body.projectId + scores = body.scores.map { it.toMutableList() } + task = body.task + baseExperimentId = body.baseExperimentId + baseExperimentName = body.baseExperimentName + experimentName = body.experimentName + gitMetadataSettings = body.gitMetadataSettings + isPublic = body.isPublic + maxConcurrency = body.maxConcurrency + metadata = body.metadata + repoInfo = body.repoInfo + stream = body.stream + timeout = body.timeout + trialCount = body.trialCount + additionalProperties = body.additionalProperties.toMutableMap() } /** The dataset to use */ @@ -818,8 +818,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): EvalCreateBody = - EvalCreateBody( + fun build(): Body = + Body( checkRequired("data", data), checkRequired("projectId", projectId), checkRequired("scores", scores).map { it.toImmutable() }, @@ -844,7 +844,7 @@ private constructor( return true } - return /* spotless:off */ other is EvalCreateBody && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -854,7 +854,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EvalCreateBody{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" + "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -868,7 +868,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: EvalCreateBody.Builder = EvalCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 0b90945f..5b9bc375 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class ExperimentCreateParams private constructor( - private val body: ExperimentCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -117,16 +117,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ExperimentCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class ExperimentCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @@ -259,7 +259,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExperimentCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -284,7 +284,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExperimentCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var projectId: JsonField? = null @@ -300,18 +300,18 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentCreateBody: ExperimentCreateBody) = apply { - projectId = experimentCreateBody.projectId - baseExpId = experimentCreateBody.baseExpId - datasetId = experimentCreateBody.datasetId - datasetVersion = experimentCreateBody.datasetVersion - description = experimentCreateBody.description - ensureNew = experimentCreateBody.ensureNew - metadata = experimentCreateBody.metadata - name = experimentCreateBody.name - public_ = experimentCreateBody.public_ - repoInfo = experimentCreateBody.repoInfo - additionalProperties = experimentCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + projectId = body.projectId + baseExpId = body.baseExpId + datasetId = body.datasetId + datasetVersion = body.datasetVersion + description = body.description + ensureNew = body.ensureNew + metadata = body.metadata + name = body.name + public_ = body.public_ + repoInfo = body.repoInfo + additionalProperties = body.additionalProperties.toMutableMap() } /** Unique identifier for the project that the experiment belongs under */ @@ -481,8 +481,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ExperimentCreateBody = - ExperimentCreateBody( + fun build(): Body = + Body( checkRequired("projectId", projectId), baseExpId, datasetId, @@ -502,7 +502,7 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentCreateBody && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -512,7 +512,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + "Body{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -526,7 +526,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ExperimentCreateBody.Builder = ExperimentCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 077c9861..e451ff7f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -23,7 +23,7 @@ import java.util.Objects class ExperimentFeedbackParams private constructor( private val experimentId: String, - private val body: ExperimentFeedbackBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -43,7 +43,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ExperimentFeedbackBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -57,9 +57,9 @@ private constructor( } @NoAutoDetect - class ExperimentFeedbackBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), @@ -81,7 +81,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExperimentFeedbackBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -97,16 +97,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExperimentFeedbackBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var feedback: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentFeedbackBody: ExperimentFeedbackBody) = apply { - feedback = experimentFeedbackBody.feedback.map { it.toMutableList() } - additionalProperties = experimentFeedbackBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** A list of experiment feedback items */ @@ -150,8 +150,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ExperimentFeedbackBody = - ExperimentFeedbackBody( + fun build(): Body = + Body( checkRequired("feedback", feedback).map { it.toImmutable() }, additionalProperties.toImmutable(), ) @@ -162,7 +162,7 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentFeedbackBody && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -172,7 +172,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -187,7 +187,7 @@ private constructor( class Builder internal constructor() { private var experimentId: String? = null - private var body: ExperimentFeedbackBody.Builder = ExperimentFeedbackBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index a5f7a4d7..9df7026b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class ExperimentFetchPostParams private constructor( private val experimentId: String, - private val body: ExperimentFetchPostBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -162,7 +162,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ExperimentFetchPostBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -176,9 +176,9 @@ private constructor( } @NoAutoDetect - class ExperimentFetchPostBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @@ -332,7 +332,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExperimentFetchPostBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -352,7 +352,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExperimentFetchPostBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var cursor: JsonField = JsonMissing.of() @@ -363,13 +363,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentFetchPostBody: ExperimentFetchPostBody) = apply { - cursor = experimentFetchPostBody.cursor - limit = experimentFetchPostBody.limit - maxRootSpanId = experimentFetchPostBody.maxRootSpanId - maxXactId = experimentFetchPostBody.maxXactId - version = experimentFetchPostBody.version - additionalProperties = experimentFetchPostBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() } /** @@ -602,8 +602,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ExperimentFetchPostBody = - ExperimentFetchPostBody( + fun build(): Body = + Body( cursor, limit, maxRootSpanId, @@ -618,7 +618,7 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentFetchPostBody && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,7 +628,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExperimentFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -643,7 +643,7 @@ private constructor( class Builder internal constructor() { private var experimentId: String? = null - private var body: ExperimentFetchPostBody.Builder = ExperimentFetchPostBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 1a7c1d8e..162cdf74 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -23,7 +23,7 @@ import java.util.Objects class ExperimentInsertParams private constructor( private val experimentId: String, - private val body: ExperimentInsertBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -43,7 +43,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ExperimentInsertBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -57,9 +57,9 @@ private constructor( } @NoAutoDetect - class ExperimentInsertBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), @@ -81,7 +81,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExperimentInsertBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -97,16 +97,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExperimentInsertBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentInsertBody: ExperimentInsertBody) = apply { - events = experimentInsertBody.events.map { it.toMutableList() } - additionalProperties = experimentInsertBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** A list of experiment events to insert */ @@ -150,8 +150,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ExperimentInsertBody = - ExperimentInsertBody( + fun build(): Body = + Body( checkRequired("events", events).map { it.toImmutable() }, additionalProperties.toImmutable(), ) @@ -162,7 +162,7 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentInsertBody && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -171,8 +171,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = "Body{events=$events, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -187,7 +186,7 @@ private constructor( class Builder internal constructor() { private var experimentId: String? = null - private var body: ExperimentInsertBody.Builder = ExperimentInsertBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index b8397e4b..a444d59d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class ExperimentUpdateParams private constructor( private val experimentId: String, - private val body: ExperimentUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -102,7 +102,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ExperimentUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -116,9 +116,9 @@ private constructor( } @NoAutoDetect - class ExperimentUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), @@ -224,7 +224,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExperimentUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -247,7 +247,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExperimentUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var baseExpId: JsonField = JsonMissing.of() @@ -261,16 +261,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentUpdateBody: ExperimentUpdateBody) = apply { - baseExpId = experimentUpdateBody.baseExpId - datasetId = experimentUpdateBody.datasetId - datasetVersion = experimentUpdateBody.datasetVersion - description = experimentUpdateBody.description - metadata = experimentUpdateBody.metadata - name = experimentUpdateBody.name - public_ = experimentUpdateBody.public_ - repoInfo = experimentUpdateBody.repoInfo - additionalProperties = experimentUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + baseExpId = body.baseExpId + datasetId = body.datasetId + datasetVersion = body.datasetVersion + description = body.description + metadata = body.metadata + name = body.name + public_ = body.public_ + repoInfo = body.repoInfo + additionalProperties = body.additionalProperties.toMutableMap() } /** Id of default base experiment to compare against when viewing this experiment */ @@ -404,8 +404,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ExperimentUpdateBody = - ExperimentUpdateBody( + fun build(): Body = + Body( baseExpId, datasetId, datasetVersion, @@ -423,7 +423,7 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentUpdateBody && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -433,7 +433,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + "Body{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -448,7 +448,7 @@ private constructor( class Builder internal constructor() { private var experimentId: String? = null - private var body: ExperimentUpdateBody.Builder = ExperimentUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 0565a1df..8aff6f63 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 @@ -39,7 +39,7 @@ import java.util.Optional */ class FunctionCreateParams private constructor( - private val body: FunctionCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -104,16 +104,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): FunctionCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class FunctionCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), @@ -222,7 +222,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -247,7 +247,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FunctionCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var functionData: JsonField? = null @@ -263,18 +263,18 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionCreateBody: FunctionCreateBody) = apply { - functionData = functionCreateBody.functionData - name = functionCreateBody.name - projectId = functionCreateBody.projectId - slug = functionCreateBody.slug - description = functionCreateBody.description - functionSchema = functionCreateBody.functionSchema - functionType = functionCreateBody.functionType - origin = functionCreateBody.origin - promptData = functionCreateBody.promptData - tags = functionCreateBody.tags.map { it.toMutableList() } - additionalProperties = functionCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + functionData = body.functionData + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionSchema = body.functionSchema + functionType = body.functionType + origin = body.origin + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) @@ -404,8 +404,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): FunctionCreateBody = - FunctionCreateBody( + fun build(): Body = + Body( checkRequired("functionData", functionData), checkRequired("name", name), checkRequired("projectId", projectId), @@ -425,7 +425,7 @@ private constructor( return true } - return /* spotless:off */ other is FunctionCreateBody && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -435,7 +435,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -449,7 +449,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: FunctionCreateBody.Builder = FunctionCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 84b8ebbe..80cf8d50 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -36,7 +36,7 @@ import java.util.Optional class FunctionInvokeParams private constructor( private val functionId: String, - private val body: FunctionInvokeBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -89,7 +89,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): FunctionInvokeBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -104,9 +104,9 @@ private constructor( /** The request to invoke a function */ @NoAutoDetect - class FunctionInvokeBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), @JsonProperty("messages") @ExcludeMissing @@ -173,7 +173,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionInvokeBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -193,7 +193,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FunctionInvokeBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var input: JsonValue = JsonMissing.of() @@ -205,14 +205,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionInvokeBody: FunctionInvokeBody) = apply { - input = functionInvokeBody.input - messages = functionInvokeBody.messages.map { it.toMutableList() } - mode = functionInvokeBody.mode - parent = functionInvokeBody.parent - stream = functionInvokeBody.stream - version = functionInvokeBody.version - additionalProperties = functionInvokeBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + input = body.input + messages = body.messages.map { it.toMutableList() } + mode = body.mode + parent = body.parent + stream = body.stream + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() } /** Argument to the function, which can be any JSON serializable value */ @@ -331,8 +331,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): FunctionInvokeBody = - FunctionInvokeBody( + fun build(): Body = + Body( input, (messages ?: JsonMissing.of()).map { it.toImmutable() }, mode, @@ -348,7 +348,7 @@ private constructor( return true } - return /* spotless:off */ other is FunctionInvokeBody && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -358,7 +358,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FunctionInvokeBody{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" + "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -373,7 +373,7 @@ private constructor( class Builder internal constructor() { private var functionId: String? = null - private var body: FunctionInvokeBody.Builder = FunctionInvokeBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 b6b2b90d..59b2877a 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 @@ -39,7 +39,7 @@ import java.util.Optional */ class FunctionReplaceParams private constructor( - private val body: FunctionReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -104,16 +104,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): FunctionReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class FunctionReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), @@ -222,7 +222,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -247,7 +247,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FunctionReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var functionData: JsonField? = null @@ -263,18 +263,18 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionReplaceBody: FunctionReplaceBody) = apply { - functionData = functionReplaceBody.functionData - name = functionReplaceBody.name - projectId = functionReplaceBody.projectId - slug = functionReplaceBody.slug - description = functionReplaceBody.description - functionSchema = functionReplaceBody.functionSchema - functionType = functionReplaceBody.functionType - origin = functionReplaceBody.origin - promptData = functionReplaceBody.promptData - tags = functionReplaceBody.tags.map { it.toMutableList() } - additionalProperties = functionReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + functionData = body.functionData + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionSchema = body.functionSchema + functionType = body.functionType + origin = body.origin + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) @@ -404,8 +404,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): FunctionReplaceBody = - FunctionReplaceBody( + fun build(): Body = + Body( checkRequired("functionData", functionData), checkRequired("name", name), checkRequired("projectId", projectId), @@ -425,7 +425,7 @@ private constructor( return true } - return /* spotless:off */ other is FunctionReplaceBody && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -435,7 +435,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -449,7 +449,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: FunctionReplaceBody.Builder = FunctionReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 20a52674..6b453f32 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -41,7 +41,7 @@ import java.util.Optional class FunctionUpdateParams private constructor( private val functionId: String, - private val body: FunctionUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -83,7 +83,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): FunctionUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -97,9 +97,9 @@ private constructor( } @NoAutoDetect - class FunctionUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -162,7 +162,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -182,7 +182,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FunctionUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var description: JsonField = JsonMissing.of() @@ -193,13 +193,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionUpdateBody: FunctionUpdateBody) = apply { - description = functionUpdateBody.description - functionData = functionUpdateBody.functionData - name = functionUpdateBody.name - promptData = functionUpdateBody.promptData - tags = functionUpdateBody.tags.map { it.toMutableList() } - additionalProperties = functionUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + description = body.description + functionData = body.functionData + name = body.name + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** Textual description of the prompt */ @@ -294,8 +294,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): FunctionUpdateBody = - FunctionUpdateBody( + fun build(): Body = + Body( description, functionData, name, @@ -310,7 +310,7 @@ private constructor( return true } - return /* spotless:off */ other is FunctionUpdateBody && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -320,7 +320,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + "Body{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -335,7 +335,7 @@ private constructor( class Builder internal constructor() { private var functionId: String? = null - private var body: FunctionUpdateBody.Builder = FunctionUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 4ecf780d..f1ae10f4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class GroupCreateParams private constructor( - private val body: GroupCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -85,16 +85,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): GroupCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class GroupCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -177,7 +177,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -197,7 +197,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -208,13 +208,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupCreateBody: GroupCreateBody) = apply { - name = groupCreateBody.name - description = groupCreateBody.description - memberGroups = groupCreateBody.memberGroups.map { it.toMutableList() } - memberUsers = groupCreateBody.memberUsers.map { it.toMutableList() } - orgName = groupCreateBody.orgName - additionalProperties = groupCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + description = body.description + memberGroups = body.memberGroups.map { it.toMutableList() } + memberUsers = body.memberUsers.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the group */ @@ -348,8 +348,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): GroupCreateBody = - GroupCreateBody( + fun build(): Body = + Body( checkRequired("name", name), description, (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, @@ -364,7 +364,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupCreateBody && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -374,7 +374,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -388,7 +388,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: GroupCreateBody.Builder = GroupCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 90421aef..a89087da 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class GroupReplaceParams private constructor( - private val body: GroupReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -85,16 +85,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): GroupReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class GroupReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -177,7 +177,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -197,7 +197,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -208,13 +208,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupReplaceBody: GroupReplaceBody) = apply { - name = groupReplaceBody.name - description = groupReplaceBody.description - memberGroups = groupReplaceBody.memberGroups.map { it.toMutableList() } - memberUsers = groupReplaceBody.memberUsers.map { it.toMutableList() } - orgName = groupReplaceBody.orgName - additionalProperties = groupReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + description = body.description + memberGroups = body.memberGroups.map { it.toMutableList() } + memberUsers = body.memberUsers.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the group */ @@ -348,8 +348,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): GroupReplaceBody = - GroupReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), description, (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, @@ -364,7 +364,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupReplaceBody && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -374,7 +374,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -388,7 +388,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: GroupReplaceBody.Builder = GroupReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index bdb048a6..c6387d5c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class GroupUpdateParams private constructor( private val groupId: String, - private val body: GroupUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -78,7 +78,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): GroupUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -92,9 +92,9 @@ private constructor( } @NoAutoDetect - class GroupUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("add_member_groups") @ExcludeMissing private val addMemberGroups: JsonField> = JsonMissing.of(), @@ -174,7 +174,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -195,7 +195,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var addMemberGroups: JsonField>? = null @@ -207,14 +207,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupUpdateBody: GroupUpdateBody) = apply { - addMemberGroups = groupUpdateBody.addMemberGroups.map { it.toMutableList() } - addMemberUsers = groupUpdateBody.addMemberUsers.map { it.toMutableList() } - description = groupUpdateBody.description - name = groupUpdateBody.name - removeMemberGroups = groupUpdateBody.removeMemberGroups.map { it.toMutableList() } - removeMemberUsers = groupUpdateBody.removeMemberUsers.map { it.toMutableList() } - additionalProperties = groupUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + addMemberGroups = body.addMemberGroups.map { it.toMutableList() } + addMemberUsers = body.addMemberUsers.map { it.toMutableList() } + description = body.description + name = body.name + removeMemberGroups = body.removeMemberGroups.map { it.toMutableList() } + removeMemberUsers = body.removeMemberUsers.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** A list of group IDs to add to the group's inheriting-from set */ @@ -364,8 +364,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): GroupUpdateBody = - GroupUpdateBody( + fun build(): Body = + Body( (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, (addMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, description, @@ -381,7 +381,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupUpdateBody && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -391,7 +391,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" + "Body{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -406,7 +406,7 @@ private constructor( class Builder internal constructor() { private var groupId: String? = null - private var body: GroupUpdateBody.Builder = GroupUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 911055df..a74bde98 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -22,7 +22,7 @@ import java.util.Optional /** Modify organization membership */ class OrganizationMemberUpdateParams private constructor( - private val body: OrganizationMemberUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -73,16 +73,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): OrganizationMemberUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class OrganizationMemberUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("invite_users") @ExcludeMissing private val inviteUsers: JsonField = JsonMissing.of(), @@ -151,7 +151,7 @@ private constructor( private var validated: Boolean = false - fun validate(): OrganizationMemberUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -170,7 +170,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [OrganizationMemberUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var inviteUsers: JsonField = JsonMissing.of() @@ -180,13 +180,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(organizationMemberUpdateBody: OrganizationMemberUpdateBody) = apply { - inviteUsers = organizationMemberUpdateBody.inviteUsers - orgId = organizationMemberUpdateBody.orgId - orgName = organizationMemberUpdateBody.orgName - removeUsers = organizationMemberUpdateBody.removeUsers - additionalProperties = - organizationMemberUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + inviteUsers = body.inviteUsers + orgId = body.orgId + orgName = body.orgName + removeUsers = body.removeUsers + additionalProperties = body.additionalProperties.toMutableMap() } /** Users to invite to the organization */ @@ -282,14 +281,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): OrganizationMemberUpdateBody = - OrganizationMemberUpdateBody( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalProperties.toImmutable(), - ) + fun build(): Body = + Body(inviteUsers, orgId, orgName, removeUsers, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -297,7 +290,7 @@ private constructor( return true } - return /* spotless:off */ other is OrganizationMemberUpdateBody && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -307,7 +300,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" + "Body{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -321,8 +314,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: OrganizationMemberUpdateBody.Builder = - OrganizationMemberUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 7e36e178..9d6505d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class OrganizationUpdateParams private constructor( private val organizationId: String, - private val body: OrganizationUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -64,7 +64,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): OrganizationUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -78,9 +78,9 @@ private constructor( } @NoAutoDetect - class OrganizationUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("api_url") @ExcludeMissing private val apiUrl: JsonField = JsonMissing.of(), @@ -134,7 +134,7 @@ private constructor( private var validated: Boolean = false - fun validate(): OrganizationUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -154,7 +154,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [OrganizationUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var apiUrl: JsonField = JsonMissing.of() @@ -165,13 +165,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(organizationUpdateBody: OrganizationUpdateBody) = apply { - apiUrl = organizationUpdateBody.apiUrl - isUniversalApi = organizationUpdateBody.isUniversalApi - name = organizationUpdateBody.name - proxyUrl = organizationUpdateBody.proxyUrl - realtimeUrl = organizationUpdateBody.realtimeUrl - additionalProperties = organizationUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + apiUrl = body.apiUrl + isUniversalApi = body.isUniversalApi + name = body.name + proxyUrl = body.proxyUrl + realtimeUrl = body.realtimeUrl + additionalProperties = body.additionalProperties.toMutableMap() } fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) @@ -235,8 +235,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): OrganizationUpdateBody = - OrganizationUpdateBody( + fun build(): Body = + Body( apiUrl, isUniversalApi, name, @@ -251,7 +251,7 @@ private constructor( return true } - return /* spotless:off */ other is OrganizationUpdateBody && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -261,7 +261,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + "Body{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -276,7 +276,7 @@ private constructor( class Builder internal constructor() { private var organizationId: String? = null - private var body: OrganizationUpdateBody.Builder = OrganizationUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 8f519311..09283740 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class ProjectCreateParams private constructor( - private val body: ProjectCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -57,16 +57,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class ProjectCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -103,7 +103,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -120,7 +120,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -128,10 +128,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectCreateBody: ProjectCreateBody) = apply { - name = projectCreateBody.name - orgName = projectCreateBody.orgName - additionalProperties = projectCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the project */ @@ -180,12 +180,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectCreateBody = - ProjectCreateBody( - checkRequired("name", name), - orgName, - additionalProperties.toImmutable(), - ) + fun build(): Body = + Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -193,7 +189,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectCreateBody && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -203,7 +199,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -217,7 +213,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ProjectCreateBody.Builder = ProjectCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index eb3857e5..c2ac0341 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -23,7 +23,7 @@ import java.util.Objects class ProjectLogFeedbackParams private constructor( private val projectId: String, - private val body: ProjectLogFeedbackBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -43,7 +43,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectLogFeedbackBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -57,9 +57,9 @@ private constructor( } @NoAutoDetect - class ProjectLogFeedbackBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), @@ -81,7 +81,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectLogFeedbackBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -97,16 +97,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectLogFeedbackBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var feedback: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogFeedbackBody: ProjectLogFeedbackBody) = apply { - feedback = projectLogFeedbackBody.feedback.map { it.toMutableList() } - additionalProperties = projectLogFeedbackBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** A list of project logs feedback items */ @@ -150,8 +150,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectLogFeedbackBody = - ProjectLogFeedbackBody( + fun build(): Body = + Body( checkRequired("feedback", feedback).map { it.toImmutable() }, additionalProperties.toImmutable(), ) @@ -162,7 +162,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectLogFeedbackBody && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -172,7 +172,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -187,7 +187,7 @@ private constructor( class Builder internal constructor() { private var projectId: String? = null - private var body: ProjectLogFeedbackBody.Builder = ProjectLogFeedbackBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index d56ae77a..46c79a30 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class ProjectLogFetchPostParams private constructor( private val projectId: String, - private val body: ProjectLogFetchPostBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -162,7 +162,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectLogFetchPostBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -176,9 +176,9 @@ private constructor( } @NoAutoDetect - class ProjectLogFetchPostBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @@ -332,7 +332,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectLogFetchPostBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -352,7 +352,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectLogFetchPostBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var cursor: JsonField = JsonMissing.of() @@ -363,13 +363,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogFetchPostBody: ProjectLogFetchPostBody) = apply { - cursor = projectLogFetchPostBody.cursor - limit = projectLogFetchPostBody.limit - maxRootSpanId = projectLogFetchPostBody.maxRootSpanId - maxXactId = projectLogFetchPostBody.maxXactId - version = projectLogFetchPostBody.version - additionalProperties = projectLogFetchPostBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() } /** @@ -602,8 +602,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectLogFetchPostBody = - ProjectLogFetchPostBody( + fun build(): Body = + Body( cursor, limit, maxRootSpanId, @@ -618,7 +618,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectLogFetchPostBody && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,7 +628,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectLogFetchPostBody{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -643,7 +643,7 @@ private constructor( class Builder internal constructor() { private var projectId: String? = null - private var body: ProjectLogFetchPostBody.Builder = ProjectLogFetchPostBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 9220b6d1..ee64bbc9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -23,7 +23,7 @@ import java.util.Objects class ProjectLogInsertParams private constructor( private val projectId: String, - private val body: ProjectLogInsertBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -43,7 +43,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectLogInsertBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -57,9 +57,9 @@ private constructor( } @NoAutoDetect - class ProjectLogInsertBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), @@ -81,7 +81,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectLogInsertBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -97,16 +97,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectLogInsertBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogInsertBody: ProjectLogInsertBody) = apply { - events = projectLogInsertBody.events.map { it.toMutableList() } - additionalProperties = projectLogInsertBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** A list of project logs events to insert */ @@ -150,8 +150,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectLogInsertBody = - ProjectLogInsertBody( + fun build(): Body = + Body( checkRequired("events", events).map { it.toImmutable() }, additionalProperties.toImmutable(), ) @@ -162,7 +162,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectLogInsertBody && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -171,8 +171,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = "Body{events=$events, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -187,7 +186,7 @@ private constructor( class Builder internal constructor() { private var projectId: String? = null - private var body: ProjectLogInsertBody.Builder = ProjectLogInsertBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 b010fd53..4a6d0280 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 @@ -38,7 +38,7 @@ import java.util.Optional */ class ProjectScoreCreateParams private constructor( - private val body: ProjectScoreCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -83,7 +83,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectScoreCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -91,9 +91,9 @@ private constructor( /** A project score is a user-configured score, which can be manually-labeled through the UI */ @NoAutoDetect - class ProjectScoreCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -167,7 +167,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -188,7 +188,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectScoreCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -200,14 +200,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreCreateBody: ProjectScoreCreateBody) = apply { - name = projectScoreCreateBody.name - projectId = projectScoreCreateBody.projectId - scoreType = projectScoreCreateBody.scoreType - categories = projectScoreCreateBody.categories - config = projectScoreCreateBody.config - description = projectScoreCreateBody.description - additionalProperties = projectScoreCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + scoreType = body.scoreType + categories = body.categories + config = body.config + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the project score */ @@ -288,8 +288,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectScoreCreateBody = - ProjectScoreCreateBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), checkRequired("scoreType", scoreType), @@ -305,7 +305,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScoreCreateBody && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -315,7 +315,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -329,7 +329,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ProjectScoreCreateBody.Builder = ProjectScoreCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 920f7593..48bf17a4 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 @@ -39,7 +39,7 @@ import java.util.Optional */ class ProjectScoreReplaceParams private constructor( - private val body: ProjectScoreReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -84,7 +84,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectScoreReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -92,9 +92,9 @@ private constructor( /** A project score is a user-configured score, which can be manually-labeled through the UI */ @NoAutoDetect - class ProjectScoreReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -168,7 +168,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -189,7 +189,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectScoreReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -201,14 +201,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreReplaceBody: ProjectScoreReplaceBody) = apply { - name = projectScoreReplaceBody.name - projectId = projectScoreReplaceBody.projectId - scoreType = projectScoreReplaceBody.scoreType - categories = projectScoreReplaceBody.categories - config = projectScoreReplaceBody.config - description = projectScoreReplaceBody.description - additionalProperties = projectScoreReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + scoreType = body.scoreType + categories = body.categories + config = body.config + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the project score */ @@ -289,8 +289,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectScoreReplaceBody = - ProjectScoreReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), checkRequired("scoreType", scoreType), @@ -306,7 +306,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScoreReplaceBody && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -316,7 +316,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -330,7 +330,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ProjectScoreReplaceBody.Builder = ProjectScoreReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 a98320f1..50ce0885 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 @@ -40,7 +40,7 @@ import java.util.Optional class ProjectScoreUpdateParams private constructor( private val projectScoreId: String, - private val body: ProjectScoreUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -82,7 +82,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectScoreUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -97,9 +97,9 @@ private constructor( /** A project score is a user-configured score, which can be manually-labeled through the UI */ @NoAutoDetect - class ProjectScoreUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), @@ -165,7 +165,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -185,7 +185,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectScoreUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var categories: JsonField = JsonMissing.of() @@ -196,13 +196,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreUpdateBody: ProjectScoreUpdateBody) = apply { - categories = projectScoreUpdateBody.categories - config = projectScoreUpdateBody.config - description = projectScoreUpdateBody.description - name = projectScoreUpdateBody.name - scoreType = projectScoreUpdateBody.scoreType - additionalProperties = projectScoreUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + categories = body.categories + config = body.config + description = body.description + name = body.name + scoreType = body.scoreType + additionalProperties = body.additionalProperties.toMutableMap() } /** For categorical-type project scores, the list of all categories */ @@ -283,8 +283,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectScoreUpdateBody = - ProjectScoreUpdateBody( + fun build(): Body = + Body( categories, config, description, @@ -299,7 +299,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectScoreUpdateBody && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -309,7 +309,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectScoreUpdateBody{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" + "Body{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -324,7 +324,7 @@ private constructor( class Builder internal constructor() { private var projectScoreId: String? = null - private var body: ProjectScoreUpdateBody.Builder = ProjectScoreUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index d61f3934..9a41823d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class ProjectTagCreateParams private constructor( - private val body: ProjectTagCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -61,16 +61,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectTagCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class ProjectTagCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -120,7 +120,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectTagCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -139,7 +139,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectTagCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -149,12 +149,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTagCreateBody: ProjectTagCreateBody) = apply { - name = projectTagCreateBody.name - projectId = projectTagCreateBody.projectId - color = projectTagCreateBody.color - description = projectTagCreateBody.description - additionalProperties = projectTagCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + color = body.color + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the project tag */ @@ -208,8 +208,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectTagCreateBody = - ProjectTagCreateBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), color, @@ -223,7 +223,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectTagCreateBody && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -233,7 +233,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -247,7 +247,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ProjectTagCreateBody.Builder = ProjectTagCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index 13336fc8..82151795 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -27,7 +27,7 @@ import java.util.Optional */ class ProjectTagReplaceParams private constructor( - private val body: ProjectTagReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -62,16 +62,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectTagReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class ProjectTagReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -121,7 +121,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectTagReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -140,7 +140,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectTagReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -150,12 +150,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTagReplaceBody: ProjectTagReplaceBody) = apply { - name = projectTagReplaceBody.name - projectId = projectTagReplaceBody.projectId - color = projectTagReplaceBody.color - description = projectTagReplaceBody.description - additionalProperties = projectTagReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + color = body.color + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the project tag */ @@ -209,8 +209,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectTagReplaceBody = - ProjectTagReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), color, @@ -224,7 +224,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectTagReplaceBody && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -234,7 +234,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -248,7 +248,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ProjectTagReplaceBody.Builder = ProjectTagReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index d3562ad7..66b64560 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class ProjectTagUpdateParams private constructor( private val projectTagId: String, - private val body: ProjectTagUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -60,7 +60,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectTagUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -74,9 +74,9 @@ private constructor( } @NoAutoDetect - class ProjectTagUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), @@ -117,7 +117,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectTagUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -135,7 +135,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectTagUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var color: JsonField = JsonMissing.of() @@ -144,11 +144,11 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTagUpdateBody: ProjectTagUpdateBody) = apply { - color = projectTagUpdateBody.color - description = projectTagUpdateBody.description - name = projectTagUpdateBody.name - additionalProperties = projectTagUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + color = body.color + description = body.description + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() } /** Color of the tag for the UI */ @@ -199,8 +199,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectTagUpdateBody = - ProjectTagUpdateBody(color, description, name, additionalProperties.toImmutable()) + fun build(): Body = Body(color, description, name, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -208,7 +207,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectTagUpdateBody && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -218,7 +217,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" + "Body{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -233,7 +232,7 @@ private constructor( class Builder internal constructor() { private var projectTagId: String? = null - private var body: ProjectTagUpdateBody.Builder = ProjectTagUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index 056e3ade..6632d7bb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class ProjectUpdateParams private constructor( private val projectId: String, - private val body: ProjectUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -60,7 +60,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ProjectUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -74,9 +74,9 @@ private constructor( } @NoAutoDetect - class ProjectUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -114,7 +114,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -131,7 +131,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ProjectUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField = JsonMissing.of() @@ -139,10 +139,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectUpdateBody: ProjectUpdateBody) = apply { - name = projectUpdateBody.name - settings = projectUpdateBody.settings - additionalProperties = projectUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + settings = body.settings + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the project */ @@ -191,8 +191,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ProjectUpdateBody = - ProjectUpdateBody(name, settings, additionalProperties.toImmutable()) + fun build(): Body = Body(name, settings, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -200,7 +199,7 @@ private constructor( return true } - return /* spotless:off */ other is ProjectUpdateBody && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -210,7 +209,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" + "Body{name=$name, settings=$settings, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -225,7 +224,7 @@ private constructor( class Builder internal constructor() { private var projectId: String? = null - private var body: ProjectUpdateBody.Builder = ProjectUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index eea17347..69d18794 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional */ class PromptCreateParams private constructor( - private val body: PromptCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -79,16 +79,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): PromptCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class PromptCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -169,7 +169,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -191,7 +191,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PromptCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -204,15 +204,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptCreateBody: PromptCreateBody) = apply { - name = promptCreateBody.name - projectId = promptCreateBody.projectId - slug = promptCreateBody.slug - description = promptCreateBody.description - functionType = promptCreateBody.functionType - promptData = promptCreateBody.promptData - tags = promptCreateBody.tags.map { it.toMutableList() } - additionalProperties = promptCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionType = body.functionType + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the prompt */ @@ -309,8 +309,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): PromptCreateBody = - PromptCreateBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), checkRequired("slug", slug), @@ -327,7 +327,7 @@ private constructor( return true } - return /* spotless:off */ other is PromptCreateBody && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -337,7 +337,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -351,7 +351,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: PromptCreateBody.Builder = PromptCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 8d2bfd3e..988681ed 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -28,7 +28,7 @@ import java.util.Optional */ class PromptReplaceParams private constructor( - private val body: PromptReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -79,16 +79,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): PromptReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class PromptReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -169,7 +169,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -191,7 +191,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PromptReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -204,15 +204,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptReplaceBody: PromptReplaceBody) = apply { - name = promptReplaceBody.name - projectId = promptReplaceBody.projectId - slug = promptReplaceBody.slug - description = promptReplaceBody.description - functionType = promptReplaceBody.functionType - promptData = promptReplaceBody.promptData - tags = promptReplaceBody.tags.map { it.toMutableList() } - additionalProperties = promptReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionType = body.functionType + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the prompt */ @@ -309,8 +309,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): PromptReplaceBody = - PromptReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), checkRequired("slug", slug), @@ -327,7 +327,7 @@ private constructor( return true } - return /* spotless:off */ other is PromptReplaceBody && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -337,7 +337,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -351,7 +351,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: PromptReplaceBody.Builder = PromptReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index 16359960..c0e63fa7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class PromptUpdateParams private constructor( private val promptId: String, - private val body: PromptUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -72,7 +72,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): PromptUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -86,9 +86,9 @@ private constructor( } @NoAutoDetect - class PromptUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -150,7 +150,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -170,7 +170,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PromptUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var description: JsonField = JsonMissing.of() @@ -181,13 +181,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptUpdateBody: PromptUpdateBody) = apply { - description = promptUpdateBody.description - name = promptUpdateBody.name - promptData = promptUpdateBody.promptData - slug = promptUpdateBody.slug - tags = promptUpdateBody.tags.map { it.toMutableList() } - additionalProperties = promptUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + description = body.description + name = body.name + promptData = body.promptData + slug = body.slug + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** Textual description of the prompt */ @@ -274,8 +274,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): PromptUpdateBody = - PromptUpdateBody( + fun build(): Body = + Body( description, name, promptData, @@ -290,7 +290,7 @@ private constructor( return true } - return /* spotless:off */ other is PromptUpdateBody && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -300,7 +300,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" + "Body{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -315,7 +315,7 @@ private constructor( class Builder internal constructor() { private var promptId: String? = null - private var body: PromptUpdateBody.Builder = PromptUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 30964964..8c4b28b8 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 @@ -28,7 +28,7 @@ import java.util.Optional */ class RoleCreateParams private constructor( - private val body: RoleCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -87,16 +87,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): RoleCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class RoleCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -179,7 +179,7 @@ private constructor( private var validated: Boolean = false - fun validate(): RoleCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -199,7 +199,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [RoleCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -210,13 +210,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(roleCreateBody: RoleCreateBody) = apply { - name = roleCreateBody.name - description = roleCreateBody.description - memberPermissions = roleCreateBody.memberPermissions.map { it.toMutableList() } - memberRoles = roleCreateBody.memberRoles.map { it.toMutableList() } - orgName = roleCreateBody.orgName - additionalProperties = roleCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + description = body.description + memberPermissions = body.memberPermissions.map { it.toMutableList() } + memberRoles = body.memberRoles.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the role */ @@ -350,8 +350,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): RoleCreateBody = - RoleCreateBody( + fun build(): Body = + Body( checkRequired("name", name), description, (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, @@ -366,7 +366,7 @@ private constructor( return true } - return /* spotless:off */ other is RoleCreateBody && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -376,7 +376,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -390,7 +390,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: RoleCreateBody.Builder = RoleCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 e99acb9e..ddcb1c75 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 @@ -28,7 +28,7 @@ import java.util.Optional */ class RoleReplaceParams private constructor( - private val body: RoleReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -87,16 +87,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): RoleReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class RoleReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -179,7 +179,7 @@ private constructor( private var validated: Boolean = false - fun validate(): RoleReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -199,7 +199,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [RoleReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -210,13 +210,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(roleReplaceBody: RoleReplaceBody) = apply { - name = roleReplaceBody.name - description = roleReplaceBody.description - memberPermissions = roleReplaceBody.memberPermissions.map { it.toMutableList() } - memberRoles = roleReplaceBody.memberRoles.map { it.toMutableList() } - orgName = roleReplaceBody.orgName - additionalProperties = roleReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + description = body.description + memberPermissions = body.memberPermissions.map { it.toMutableList() } + memberRoles = body.memberRoles.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the role */ @@ -350,8 +350,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): RoleReplaceBody = - RoleReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), description, (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, @@ -366,7 +366,7 @@ private constructor( return true } - return /* spotless:off */ other is RoleReplaceBody && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -376,7 +376,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -390,7 +390,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: RoleReplaceBody.Builder = RoleReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 4170bd2e..57ef099c 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 @@ -30,7 +30,7 @@ import java.util.Optional class RoleUpdateParams private constructor( private val roleId: String, - private val body: RoleUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -82,7 +82,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): RoleUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -96,9 +96,9 @@ private constructor( } @NoAutoDetect - class RoleUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("add_member_permissions") @ExcludeMissing private val addMemberPermissions: JsonField> = JsonMissing.of(), @@ -180,7 +180,7 @@ private constructor( private var validated: Boolean = false - fun validate(): RoleUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -201,7 +201,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [RoleUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var addMemberPermissions: JsonField>? = null @@ -214,16 +214,14 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(roleUpdateBody: RoleUpdateBody) = apply { - addMemberPermissions = - roleUpdateBody.addMemberPermissions.map { it.toMutableList() } - addMemberRoles = roleUpdateBody.addMemberRoles.map { it.toMutableList() } - description = roleUpdateBody.description - name = roleUpdateBody.name - removeMemberPermissions = - roleUpdateBody.removeMemberPermissions.map { it.toMutableList() } - removeMemberRoles = roleUpdateBody.removeMemberRoles.map { it.toMutableList() } - additionalProperties = roleUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + addMemberPermissions = body.addMemberPermissions.map { it.toMutableList() } + addMemberRoles = body.addMemberRoles.map { it.toMutableList() } + description = body.description + name = body.name + removeMemberPermissions = body.removeMemberPermissions.map { it.toMutableList() } + removeMemberRoles = body.removeMemberRoles.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() } /** A list of permissions to add to the role */ @@ -377,8 +375,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): RoleUpdateBody = - RoleUpdateBody( + fun build(): Body = + Body( (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, (addMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, description, @@ -394,7 +392,7 @@ private constructor( return true } - return /* spotless:off */ other is RoleUpdateBody && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -404,7 +402,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" + "Body{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -419,7 +417,7 @@ private constructor( class Builder internal constructor() { private var roleId: String? = null - private var body: RoleUpdateBody.Builder = RoleUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 280fdb69..5fb0428d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class SpanIframeCreateParams private constructor( - private val body: SpanIframeCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -73,16 +73,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): SpanIframeCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class SpanIframeCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -148,7 +148,7 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanIframeCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -168,7 +168,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [SpanIframeCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -179,13 +179,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIframeCreateBody: SpanIframeCreateBody) = apply { - name = spanIframeCreateBody.name - projectId = spanIframeCreateBody.projectId - url = spanIframeCreateBody.url - description = spanIframeCreateBody.description - postMessage = spanIframeCreateBody.postMessage - additionalProperties = spanIframeCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + url = body.url + description = body.description + postMessage = body.postMessage + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the span iframe */ @@ -264,8 +264,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): SpanIframeCreateBody = - SpanIframeCreateBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), checkRequired("url", url), @@ -280,7 +280,7 @@ private constructor( return true } - return /* spotless:off */ other is SpanIframeCreateBody && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -290,7 +290,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SpanIframeCreateBody{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -304,7 +304,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: SpanIframeCreateBody.Builder = SpanIframeCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index 97a2fe65..abeb50c4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -26,7 +26,7 @@ import java.util.Optional */ class SpanIframeReplaceParams private constructor( - private val body: SpanIframeReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -73,16 +73,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): SpanIframeReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class SpanIframeReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -148,7 +148,7 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanIframeReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -168,7 +168,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [SpanIframeReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -179,13 +179,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIframeReplaceBody: SpanIframeReplaceBody) = apply { - name = spanIframeReplaceBody.name - projectId = spanIframeReplaceBody.projectId - url = spanIframeReplaceBody.url - description = spanIframeReplaceBody.description - postMessage = spanIframeReplaceBody.postMessage - additionalProperties = spanIframeReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + url = body.url + description = body.description + postMessage = body.postMessage + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the span iframe */ @@ -264,8 +264,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): SpanIframeReplaceBody = - SpanIframeReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("projectId", projectId), checkRequired("url", url), @@ -280,7 +280,7 @@ private constructor( return true } - return /* spotless:off */ other is SpanIframeReplaceBody && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -290,7 +290,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SpanIframeReplaceBody{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -304,7 +304,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: SpanIframeReplaceBody.Builder = SpanIframeReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 0ee845f4..db292a0f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -28,7 +28,7 @@ import java.util.Optional class SpanIframeUpdateParams private constructor( private val spanIframeId: String, - private val body: SpanIframeUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -66,7 +66,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): SpanIframeUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -80,9 +80,9 @@ private constructor( } @NoAutoDetect - class SpanIframeUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -127,7 +127,7 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanIframeUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -145,7 +145,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [SpanIframeUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField = JsonMissing.of() @@ -154,11 +154,11 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIframeUpdateBody: SpanIframeUpdateBody) = apply { - name = spanIframeUpdateBody.name - postMessage = spanIframeUpdateBody.postMessage - url = spanIframeUpdateBody.url - additionalProperties = spanIframeUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + postMessage = body.postMessage + url = body.url + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the span iframe */ @@ -226,8 +226,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): SpanIframeUpdateBody = - SpanIframeUpdateBody(name, postMessage, url, additionalProperties.toImmutable()) + fun build(): Body = Body(name, postMessage, url, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -235,7 +234,7 @@ private constructor( return true } - return /* spotless:off */ other is SpanIframeUpdateBody && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -245,7 +244,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SpanIframeUpdateBody{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" + "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -260,7 +259,7 @@ private constructor( class Builder internal constructor() { private var spanIframeId: String? = null - private var body: SpanIframeUpdateBody.Builder = SpanIframeUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 6d9f62cf..5078ecd7 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 @@ -29,7 +29,7 @@ import java.util.Optional */ class ViewCreateParams private constructor( - private val body: ViewCreateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -88,16 +88,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ViewCreateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class ViewCreateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -185,7 +185,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewCreateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -208,7 +208,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ViewCreateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -222,16 +222,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewCreateBody: ViewCreateBody) = apply { - name = viewCreateBody.name - objectId = viewCreateBody.objectId - objectType = viewCreateBody.objectType - viewType = viewCreateBody.viewType - deletedAt = viewCreateBody.deletedAt - options = viewCreateBody.options - userId = viewCreateBody.userId - viewData = viewCreateBody.viewData - additionalProperties = viewCreateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + viewType = body.viewType + deletedAt = body.deletedAt + options = body.options + userId = body.userId + viewData = body.viewData + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the view */ @@ -320,8 +320,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ViewCreateBody = - ViewCreateBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("objectId", objectId), checkRequired("objectType", objectType), @@ -339,7 +339,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewCreateBody && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -349,7 +349,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -363,7 +363,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ViewCreateBody.Builder = ViewCreateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 43eac0be..dcc170a3 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 @@ -25,7 +25,7 @@ import java.util.Objects class ViewDeleteParams private constructor( private val viewId: String, - private val body: ViewDeleteBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -51,7 +51,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ViewDeleteBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -65,9 +65,9 @@ private constructor( } @NoAutoDetect - class ViewDeleteBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), @@ -98,7 +98,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewDeleteBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -115,7 +115,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ViewDeleteBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var objectId: JsonField? = null @@ -123,10 +123,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewDeleteBody: ViewDeleteBody) = apply { - objectId = viewDeleteBody.objectId - objectType = viewDeleteBody.objectType - additionalProperties = viewDeleteBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + objectId = body.objectId + objectType = body.objectType + additionalProperties = body.additionalProperties.toMutableMap() } /** The id of the object the view applies to */ @@ -162,8 +162,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ViewDeleteBody = - ViewDeleteBody( + fun build(): Body = + Body( checkRequired("objectId", objectId), checkRequired("objectType", objectType), additionalProperties.toImmutable(), @@ -175,7 +175,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewDeleteBody && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -185,7 +185,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + "Body{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -200,7 +200,7 @@ private constructor( class Builder internal constructor() { private var viewId: String? = null - private var body: ViewDeleteBody.Builder = ViewDeleteBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 dd00fe93..4ef8a132 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 @@ -29,7 +29,7 @@ import java.util.Optional */ class ViewReplaceParams private constructor( - private val body: ViewReplaceBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -88,16 +88,16 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ViewReplaceBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class ViewReplaceBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -185,7 +185,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewReplaceBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -208,7 +208,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ViewReplaceBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var name: JsonField? = null @@ -222,16 +222,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewReplaceBody: ViewReplaceBody) = apply { - name = viewReplaceBody.name - objectId = viewReplaceBody.objectId - objectType = viewReplaceBody.objectType - viewType = viewReplaceBody.viewType - deletedAt = viewReplaceBody.deletedAt - options = viewReplaceBody.options - userId = viewReplaceBody.userId - viewData = viewReplaceBody.viewData - additionalProperties = viewReplaceBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + viewType = body.viewType + deletedAt = body.deletedAt + options = body.options + userId = body.userId + viewData = body.viewData + additionalProperties = body.additionalProperties.toMutableMap() } /** Name of the view */ @@ -320,8 +320,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ViewReplaceBody = - ViewReplaceBody( + fun build(): Body = + Body( checkRequired("name", name), checkRequired("objectId", objectId), checkRequired("objectType", objectType), @@ -339,7 +339,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewReplaceBody && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -349,7 +349,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -363,7 +363,7 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: ViewReplaceBody.Builder = ViewReplaceBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 c63e8beb..540feec9 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 @@ -30,7 +30,7 @@ import java.util.Optional class ViewUpdateParams private constructor( private val viewId: String, - private val body: ViewUpdateBody, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -86,7 +86,7 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): ViewUpdateBody = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders @@ -100,9 +100,9 @@ private constructor( } @NoAutoDetect - class ViewUpdateBody + class Body @JsonCreator - internal constructor( + private constructor( @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), @@ -178,7 +178,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewUpdateBody = apply { + fun validate(): Body = apply { if (validated) { return@apply } @@ -200,7 +200,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ViewUpdateBody]. */ + /** A builder for [Body]. */ class Builder internal constructor() { private var objectId: JsonField? = null @@ -213,15 +213,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewUpdateBody: ViewUpdateBody) = apply { - objectId = viewUpdateBody.objectId - objectType = viewUpdateBody.objectType - name = viewUpdateBody.name - options = viewUpdateBody.options - userId = viewUpdateBody.userId - viewData = viewUpdateBody.viewData - viewType = viewUpdateBody.viewType - additionalProperties = viewUpdateBody.additionalProperties.toMutableMap() + internal fun from(body: Body) = apply { + objectId = body.objectId + objectType = body.objectType + name = body.name + options = body.options + userId = body.userId + viewData = body.viewData + viewType = body.viewType + additionalProperties = body.additionalProperties.toMutableMap() } /** The id of the object the view applies to */ @@ -302,8 +302,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ViewUpdateBody = - ViewUpdateBody( + fun build(): Body = + Body( checkRequired("objectId", objectId), checkRequired("objectType", objectType), name, @@ -320,7 +320,7 @@ private constructor( return true } - return /* spotless:off */ other is ViewUpdateBody && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -330,7 +330,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" + "Body{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -345,7 +345,7 @@ private constructor( class Builder internal constructor() { private var viewId: String? = null - private var body: ViewUpdateBody.Builder = ViewUpdateBody.builder() + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 f4e0b644..2aa46d8b 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 @@ -68,7 +68,9 @@ class AclBatchUpdateParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.addAcls()) .contains( @@ -107,7 +109,9 @@ class AclBatchUpdateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = AclBatchUpdateParams.builder().build() + val body = params._body() + assertThat(body).isNotNull } } 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 fa1940ba..941f9331 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 @@ -32,7 +32,9 @@ class AclCreateParamsTest { .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) @@ -51,7 +53,9 @@ class AclCreateParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclCreateParams.ObjectType.ORGANIZATION) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.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 d82dd66e..e585c5fb 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 @@ -32,7 +32,9 @@ class AclFindAndDeleteParamsTest { .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) @@ -51,7 +53,9 @@ class AclFindAndDeleteParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt index 6d70eaca..3cc34e58 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt @@ -37,7 +37,9 @@ class AiSecretCreateParamsTest { .secret("secret") .type("type") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.metadata()) @@ -54,7 +56,9 @@ class AiSecretCreateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = AiSecretCreateParams.builder().name("name").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt index 8dbe57c5..4e028f50 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt @@ -15,7 +15,9 @@ class AiSecretFindAndDeleteParamsTest { @Test fun body() { val params = AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.orgName()).contains("org_name") @@ -24,7 +26,9 @@ class AiSecretFindAndDeleteParamsTest { @Test fun bodyWithoutOptionalFields() { val params = AiSecretFindAndDeleteParams.builder().name("name").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt index 660c7917..2598f52a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt @@ -37,7 +37,9 @@ class AiSecretReplaceParamsTest { .secret("secret") .type("type") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.metadata()) @@ -54,7 +56,9 @@ class AiSecretReplaceParamsTest { @Test fun bodyWithoutOptionalFields() { val params = AiSecretReplaceParams.builder().name("name").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt index d2aff29a..a3167595 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt @@ -37,7 +37,9 @@ class AiSecretUpdateParamsTest { .secret("secret") .type("type") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.metadata()) .contains( @@ -56,7 +58,9 @@ class AiSecretUpdateParamsTest { AiSecretUpdateParams.builder() .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt index 4b331282..592c3500 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -15,7 +15,9 @@ class ApiKeyCreateParamsTest { @Test fun body() { val params = ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.orgName()).contains("org_name") @@ -24,7 +26,9 @@ class ApiKeyCreateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = ApiKeyCreateParams.builder().name("name").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index 6c32ee7f..e51c08fb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -35,7 +35,9 @@ class DatasetCreateParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -55,7 +57,9 @@ class DatasetCreateParamsTest { .name("x") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index a3a1a359..0686d6b3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -47,7 +47,9 @@ class DatasetFeedbackParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo( @@ -74,7 +76,9 @@ class DatasetFeedbackParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addFeedback(FeedbackDatasetItem.builder().id("id").build()) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo(listOf(FeedbackDatasetItem.builder().id("id").build())) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index 22e25376..58379710 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -30,7 +30,9 @@ class DatasetFetchPostParamsTest { .maxXactId("max_xact_id") .version("version") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.cursor()).contains("cursor") assertThat(body.limit()).contains(0L) @@ -45,7 +47,9 @@ class DatasetFetchPostParamsTest { DatasetFetchPostParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index a9353b93..b944b3c1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -64,7 +64,9 @@ class DatasetInsertParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.events()) .isEqualTo( @@ -99,7 +101,9 @@ class DatasetInsertParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEvent(InsertDatasetEvent.builder().build()) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index 3fe6dfd1..2419bb8a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -35,7 +35,9 @@ class DatasetUpdateParamsTest { ) .name("name") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.description()).contains("description") assertThat(body.metadata()) @@ -51,7 +53,9 @@ class DatasetUpdateParamsTest { fun bodyWithoutOptionalFields() { val params = DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt index 59313199..a2601ff8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt @@ -26,7 +26,9 @@ class EnvVarCreateParamsTest { .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) .value("value") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -42,7 +44,9 @@ class EnvVarCreateParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt index 18ec7415..2acb4222 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt @@ -26,7 +26,9 @@ class EnvVarReplaceParamsTest { .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) .value("value") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -42,7 +44,9 @@ class EnvVarReplaceParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt index 062d510b..7403582f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt @@ -24,7 +24,9 @@ class EnvVarUpdateParamsTest { .name("name") .value("value") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.value()).contains("value") @@ -37,7 +39,9 @@ class EnvVarUpdateParamsTest { .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index d64378bb..088dff26 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -111,7 +111,9 @@ class EvalCreateParamsTest { .timeout(0.0) .trialCount(0.0) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.data()) .isEqualTo( @@ -188,7 +190,9 @@ class EvalCreateParamsTest { ) .task(EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build()) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.data()) .isEqualTo( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 41b09d75..0fc3f173 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -71,7 +71,9 @@ class ExperimentCreateParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -109,7 +111,9 @@ class ExperimentCreateParamsTest { ExperimentCreateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index 01c11387..726c899c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -59,7 +59,9 @@ class ExperimentFeedbackParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo( @@ -92,7 +94,9 @@ class ExperimentFeedbackParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addFeedback(FeedbackExperimentItem.builder().id("id").build()) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo(listOf(FeedbackExperimentItem.builder().id("id").build())) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index e0f8a28a..a6ecedfe 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -30,7 +30,9 @@ class ExperimentFetchPostParamsTest { .maxXactId("max_xact_id") .version("version") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.cursor()).contains("cursor") assertThat(body.limit()).contains(0L) @@ -45,7 +47,9 @@ class ExperimentFetchPostParamsTest { ExperimentFetchPostParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } 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 d1f5ec03..4ab46acb 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 @@ -127,7 +127,9 @@ class ExperimentInsertParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.events()) .isEqualTo( @@ -195,7 +197,9 @@ class ExperimentInsertParamsTest { .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEvent(InsertExperimentEvent.builder().build()) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index 19cb4e57..5705ba3c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -69,7 +69,9 @@ class ExperimentUpdateParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -105,7 +107,9 @@ class ExperimentUpdateParamsTest { ExperimentUpdateParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } 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 e8903e3f..85403cb0 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 @@ -217,7 +217,9 @@ class FunctionCreateParamsTest { ) .addTag("string") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.functionData()) .isEqualTo( @@ -339,7 +341,9 @@ class FunctionCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("x") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.functionData()) .isEqualTo( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index b80c7210..65e86566 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -83,7 +83,9 @@ class FunctionInvokeParamsTest { .stream(true) .version("version") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.messages()) @@ -132,7 +134,9 @@ class FunctionInvokeParamsTest { FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } 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 598e23c1..91846cf5 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 @@ -217,7 +217,9 @@ class FunctionReplaceParamsTest { ) .addTag("string") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.functionData()) .isEqualTo( @@ -339,7 +341,9 @@ class FunctionReplaceParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("x") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.functionData()) .isEqualTo( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index 576aa177..c3dfbb9a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -187,7 +187,9 @@ class FunctionUpdateParamsTest { ) .addTag("string") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.description()).contains("description") assertThat(body.functionData()) @@ -284,7 +286,9 @@ class FunctionUpdateParamsTest { FunctionUpdateParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index 6b80eb15..bc3836e6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -28,7 +28,9 @@ class GroupCreateParamsTest { .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") @@ -40,7 +42,9 @@ class GroupCreateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = GroupCreateParams.builder().name("x").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index eea89257..1b4bf806 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -28,7 +28,9 @@ class GroupReplaceParamsTest { .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") @@ -40,7 +42,9 @@ class GroupReplaceParamsTest { @Test fun bodyWithoutOptionalFields() { val params = GroupReplaceParams.builder().name("x").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index fa36b2eb..114ae451 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -32,7 +32,9 @@ class GroupUpdateParamsTest { .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -48,7 +50,9 @@ class GroupUpdateParamsTest { fun bodyWithoutOptionalFields() { val params = GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt index bce46ec6..d13cd4b6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -56,7 +56,9 @@ class OrganizationMemberUpdateParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.inviteUsers()) .contains( @@ -84,7 +86,9 @@ class OrganizationMemberUpdateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = OrganizationMemberUpdateParams.builder().build() + val body = params._body() + assertThat(body).isNotNull } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt index c311f880..cd409c37 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -30,7 +30,9 @@ class OrganizationUpdateParamsTest { .proxyUrl("proxy_url") .realtimeUrl("realtime_url") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.apiUrl()).contains("api_url") assertThat(body.isUniversalApi()).contains(true) @@ -45,7 +47,9 @@ class OrganizationUpdateParamsTest { OrganizationUpdateParams.builder() .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index e9a16b54..a4a7efda 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -15,7 +15,9 @@ class ProjectCreateParamsTest { @Test fun body() { val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.orgName()).contains("org_name") @@ -24,7 +26,9 @@ class ProjectCreateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = ProjectCreateParams.builder().name("x").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index c8daa5bf..a1b6dfb1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -59,7 +59,9 @@ class ProjectLogFeedbackParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo( @@ -92,7 +94,9 @@ class ProjectLogFeedbackParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.feedback()) .isEqualTo(listOf(FeedbackProjectLogsItem.builder().id("id").build())) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 4dc85b96..8208afaa 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -30,7 +30,9 @@ class ProjectLogFetchPostParamsTest { .maxXactId("max_xact_id") .version("version") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.cursor()).contains("cursor") assertThat(body.limit()).contains(0L) @@ -45,7 +47,9 @@ class ProjectLogFetchPostParamsTest { ProjectLogFetchPostParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } 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 d75d255a..7cef665e 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 @@ -125,7 +125,9 @@ class ProjectLogInsertParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.events()) .isEqualTo( @@ -192,7 +194,9 @@ class ProjectLogInsertParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEvent(InsertProjectLogsEvent.builder().build()) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) } 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 6848c8a4..9351c8ed 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 @@ -70,7 +70,9 @@ class ProjectScoreCreateParamsTest { ) .description("description") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -112,7 +114,9 @@ class ProjectScoreCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("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 e88918bb..f55560d0 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 @@ -70,7 +70,9 @@ class ProjectScoreReplaceParamsTest { ) .description("description") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -112,7 +114,9 @@ class ProjectScoreReplaceParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 80265044..85568ddd 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 @@ -70,7 +70,9 @@ class ProjectScoreUpdateParamsTest { .name("name") .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.categories()) .contains( @@ -109,7 +111,9 @@ class ProjectScoreUpdateParamsTest { ProjectScoreUpdateParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt index 0b059956..269115e9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -26,7 +26,9 @@ class ProjectTagCreateParamsTest { .color("color") .description("description") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -41,7 +43,9 @@ class ProjectTagCreateParamsTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt index 5ea11901..1501850a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -26,7 +26,9 @@ class ProjectTagReplaceParamsTest { .color("color") .description("description") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -41,7 +43,9 @@ class ProjectTagReplaceParamsTest { .name("name") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt index 259f1643..39cb58d2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -26,7 +26,9 @@ class ProjectTagUpdateParamsTest { .description("description") .name("name") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.color()).contains("color") assertThat(body.description()).contains("description") @@ -39,7 +41,9 @@ class ProjectTagUpdateParamsTest { ProjectTagUpdateParams.builder() .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 69c200c0..591d4905 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -24,7 +24,9 @@ class ProjectUpdateParamsTest { .name("name") .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).contains("name") assertThat(body.settings()) @@ -35,7 +37,9 @@ class ProjectUpdateParamsTest { fun bodyWithoutOptionalFields() { val params = ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 53cf165c..404585ad 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -181,7 +181,9 @@ class PromptCreateParamsTest { ) .addTag("string") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -275,7 +277,9 @@ class PromptCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("x") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 5042646d..ad32d022 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -181,7 +181,9 @@ class PromptReplaceParamsTest { ) .addTag("string") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -275,7 +277,9 @@ class PromptReplaceParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .slug("x") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index e47bb2d1..9112aa11 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -179,7 +179,9 @@ class PromptUpdateParamsTest { .slug("slug") .addTag("string") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.description()).contains("description") assertThat(body.name()).contains("name") @@ -267,7 +269,9 @@ class PromptUpdateParamsTest { fun bodyWithoutOptionalFields() { val params = PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params._body() + assertThat(body).isNotNull } 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 6c366ac1..0e894c79 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 @@ -42,7 +42,9 @@ class RoleCreateParamsTest { .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") @@ -64,7 +66,9 @@ class RoleCreateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = RoleCreateParams.builder().name("x").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } 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 9b800fc5..020866ba 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 @@ -42,7 +42,9 @@ class RoleReplaceParamsTest { .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .orgName("org_name") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") @@ -64,7 +66,9 @@ class RoleReplaceParamsTest { @Test fun bodyWithoutOptionalFields() { val params = RoleReplaceParams.builder().name("x").build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("x") } 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 338f33b0..6fc8460c 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 @@ -60,7 +60,9 @@ class RoleUpdateParamsTest { ) .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.addMemberPermissions()) .contains( @@ -95,7 +97,9 @@ class RoleUpdateParamsTest { fun bodyWithoutOptionalFields() { val params = RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val body = params._body() + assertThat(body).isNotNull } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt index 7016af4b..bcc72601 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt @@ -28,7 +28,9 @@ class SpanIframeCreateParamsTest { .description("description") .postMessage(true) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -45,7 +47,9 @@ class SpanIframeCreateParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .url("url") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt index efdaaa4d..4de31d36 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt @@ -28,7 +28,9 @@ class SpanIframeReplaceParamsTest { .description("description") .postMessage(true) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -45,7 +47,9 @@ class SpanIframeReplaceParamsTest { .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .url("url") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index 4910bc50..d03de12f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -26,7 +26,9 @@ class SpanIframeUpdateParamsTest { .postMessage(true) .url("url") .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).contains("name") assertThat(body.postMessage()).contains(true) @@ -39,7 +41,9 @@ class SpanIframeUpdateParamsTest { SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() + val body = params._body() + assertThat(body).isNotNull } 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 c6e16619..898590d1 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 @@ -86,7 +86,9 @@ class ViewCreateParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -134,7 +136,9 @@ class ViewCreateParamsTest { .objectType(ViewCreateParams.ObjectType.ORGANIZATION) .viewType(ViewCreateParams.ViewType.PROJECTS) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 66bfa167..34750bb8 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 @@ -24,7 +24,9 @@ class ViewDeleteParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) @@ -38,7 +40,9 @@ class ViewDeleteParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) 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 1355462b..11a07d8c 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 @@ -86,7 +86,9 @@ class ViewReplaceParamsTest { .build() ) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -134,7 +136,9 @@ class ViewReplaceParamsTest { .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) .viewType(ViewReplaceParams.ViewType.PROJECTS) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 eb609330..2730c177 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 @@ -85,7 +85,9 @@ class ViewUpdateParamsTest { ) .viewType(ViewUpdateParams.ViewType.PROJECTS) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) @@ -131,7 +133,9 @@ class ViewUpdateParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) .build() + val body = params._body() + assertThat(body).isNotNull assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) From ed83ac52612873519062919eae567a1e82b3b221 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 07:31:49 +0000 Subject: [PATCH 43/87] feat(client): update enum `asX` methods (#113) --- .../com/braintrustdata/api/models/Acl.kt | 42 ++++- .../api/models/AclBatchUpdateParams.kt | 84 +++++++++- .../api/models/AclCreateParams.kt | 42 ++++- .../api/models/AclFindAndDeleteParams.kt | 42 ++++- .../api/models/AclListParams.kt | 14 +- .../models/ChatCompletionContentPartImage.kt | 28 +++- .../models/ChatCompletionContentPartText.kt | 14 +- .../models/ChatCompletionMessageToolCall.kt | 14 +- .../braintrustdata/api/models/CodeBundle.kt | 70 +++++++- .../braintrustdata/api/models/DatasetEvent.kt | 14 +- .../com/braintrustdata/api/models/EnvVar.kt | 14 +- .../api/models/EnvVarCreateParams.kt | 14 +- .../api/models/EnvVarListParams.kt | 14 +- .../api/models/EnvVarReplaceParams.kt | 14 +- .../api/models/EvalCreateParams.kt | 56 ++++++- .../api/models/ExperimentEvent.kt | 14 +- .../api/models/FeedbackDatasetItem.kt | 14 +- .../api/models/FeedbackExperimentItem.kt | 14 +- .../api/models/FeedbackProjectLogsItem.kt | 14 +- .../api/models/FeedbackResponseSchema.kt | 14 +- .../com/braintrustdata/api/models/Function.kt | 126 +++++++++++++- .../api/models/FunctionCreateParams.kt | 112 ++++++++++++- .../api/models/FunctionInvokeParams.kt | 112 ++++++++++++- .../api/models/FunctionReplaceParams.kt | 112 ++++++++++++- .../api/models/FunctionUpdateParams.kt | 84 +++++++++- .../api/models/OnlineScoreConfig.kt | 28 +++- .../models/PatchOrganizationMembersOutput.kt | 14 +- .../api/models/ProjectLogsEvent.kt | 28 +++- .../braintrustdata/api/models/ProjectScore.kt | 14 +- .../api/models/ProjectScoreConfig.kt | 14 +- .../api/models/ProjectScoreCreateParams.kt | 14 +- .../api/models/ProjectScoreListParams.kt | 28 +++- .../api/models/ProjectScoreReplaceParams.kt | 14 +- .../api/models/ProjectScoreUpdateParams.kt | 14 +- .../com/braintrustdata/api/models/Prompt.kt | 28 +++- .../api/models/PromptCreateParams.kt | 14 +- .../braintrustdata/api/models/PromptData.kt | 154 ++++++++++++++++-- .../api/models/PromptOptions.kt | 84 +++++++++- .../api/models/PromptReplaceParams.kt | 14 +- .../com/braintrustdata/api/models/Role.kt | 28 +++- .../api/models/RoleCreateParams.kt | 28 +++- .../api/models/RoleReplaceParams.kt | 28 +++- .../api/models/RoleUpdateParams.kt | 56 ++++++- .../api/models/SpanAttributes.kt | 14 +- .../com/braintrustdata/api/models/View.kt | 28 +++- .../api/models/ViewCreateParams.kt | 28 +++- .../api/models/ViewDeleteParams.kt | 14 +- .../api/models/ViewListParams.kt | 28 +++- .../api/models/ViewReplaceParams.kt | 28 +++- .../api/models/ViewRetrieveParams.kt | 14 +- .../api/models/ViewUpdateParams.kt | 28 +++- 51 files changed, 1742 insertions(+), 134 deletions(-) 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 434a78f4..2c19ed13 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 @@ -492,7 +492,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -619,7 +631,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -770,7 +794,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 0e65c029..475d5dba 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 @@ -1051,7 +1051,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1180,7 +1192,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1334,7 +1358,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1801,7 +1837,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1930,7 +1978,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2084,7 +2144,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 f5aafa3e..323a03d3 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 @@ -789,7 +789,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -916,7 +928,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1067,7 +1091,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 0bf8a642..55efc0b7 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 @@ -790,7 +790,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -917,7 +929,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1068,7 +1092,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 93c0dc48..8fad90f0 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 @@ -442,7 +442,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index 732ac18c..a5b81c7c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -280,7 +280,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Detail: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -380,7 +392,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index eb1db215..effad23e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -175,7 +175,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 0f0ee94c..2a8fda20 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -301,7 +301,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index 0cc68cc4..c3674b44 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -715,7 +715,19 @@ private constructor( ) } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -920,7 +932,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1024,7 +1048,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1224,7 +1260,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1428,7 +1476,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 6b3eac17..ee04f29a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -754,7 +754,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 2dc9bd7e..68316f5b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -283,7 +283,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 5c80a17f..c9d89fc3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -490,7 +490,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 ad3830af..59351f94 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 @@ -462,7 +462,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index f42d2c35..d5fd3641 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -490,7 +490,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 9e741c34..b05bd6d6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -2771,7 +2771,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -4068,7 +4080,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -4452,7 +4476,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Collect: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -4584,7 +4620,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Field: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index 076b0833..515c67f6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -1606,7 +1606,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 25b354ff..2d80ddb9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -398,7 +398,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Source: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index 71c42a9b..f3e3c234 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -533,7 +533,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Source: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 9f9b909c..d928cf3b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -533,7 +533,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Source: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index 8c3567a0..a70ee246 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -163,7 +163,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Status: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 f2bdc4c3..3d57ba98 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 @@ -764,7 +764,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1292,7 +1304,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1637,7 +1661,19 @@ private constructor( ) } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1744,7 +1780,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1848,7 +1896,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2048,7 +2108,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2150,7 +2222,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown LogId: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2350,7 +2434,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2727,7 +2823,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 8aff6f63..b7d04da2 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 @@ -981,7 +981,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1509,7 +1521,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1854,7 +1878,19 @@ private constructor( ) } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1961,7 +1997,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2065,7 +2113,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2265,7 +2325,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2484,7 +2556,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2782,7 +2866,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 80cf8d50..c10b0dc4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -1003,7 +1003,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1223,7 +1235,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1799,7 +1823,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2138,7 +2174,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2353,7 +2401,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2555,7 +2615,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2663,7 +2735,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Mode: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -3054,7 +3138,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 59b2877a..a13c8b1d 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 @@ -981,7 +981,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1509,7 +1521,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1854,7 +1878,19 @@ private constructor( ) } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1961,7 +1997,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2065,7 +2113,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2265,7 +2325,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2484,7 +2556,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2782,7 +2866,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 6b453f32..3fb0cd5b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -862,7 +862,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1390,7 +1402,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1735,7 +1759,19 @@ private constructor( ) } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1842,7 +1878,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1946,7 +1994,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2146,7 +2206,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 294f7fd2..5a017ef4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -532,7 +532,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -732,7 +744,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 4f8446c8..53a0f32d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -226,7 +226,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Status: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 272eb81e..171bcb19 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -785,7 +785,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown LogId: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1652,7 +1664,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 b4e81b59..3671d969 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 @@ -401,7 +401,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 808c09c0..469e2f5d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -209,7 +209,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Destination: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 4a6d0280..5d3b4a60 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 @@ -620,7 +620,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 6fc3408e..7b5f9f21 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 @@ -713,7 +713,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -832,7 +844,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 48bf17a4..e79be7dc 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 @@ -621,7 +621,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 50ce0885..eade11e7 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 @@ -979,7 +979,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index e3b02dfd..b5f8ede1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -444,7 +444,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown LogId: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -547,7 +559,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 69d18794..9e47c217 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -632,7 +632,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 1aa1d554..0effa429 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -595,7 +595,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -952,7 +964,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1544,7 +1568,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1772,7 +1808,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2391,7 +2439,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2741,7 +2801,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2964,7 +3036,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -3174,7 +3258,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Role: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -3278,7 +3374,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -3696,7 +3804,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -3896,7 +4016,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index f6602edd..f445cf18 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -879,7 +879,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1344,7 +1356,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1809,7 +1833,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1996,7 +2032,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2338,7 +2386,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -2632,7 +2692,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 988681ed..da342ba8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -632,7 +632,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 ac84d02f..3235cf51 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 @@ -635,7 +635,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -786,7 +798,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 8c4b28b8..1fb4e5f8 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 @@ -863,7 +863,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1014,7 +1026,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 ddcb1c75..87959e90 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 @@ -867,7 +867,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1018,7 +1030,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 57ef099c..c7ee787e 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 @@ -905,7 +905,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1056,7 +1068,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1341,7 +1365,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Permission: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -1492,7 +1528,19 @@ private constructor( throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 f7b309ae..4e3c4b1d 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 @@ -215,7 +215,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown Type: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 fe103a6f..31cf4186 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 @@ -422,7 +422,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -547,7 +559,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 5078ecd7..96521ff2 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 @@ -688,7 +688,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -813,7 +825,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 dcc170a3..6ad63372 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 @@ -483,7 +483,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 fef74844..ed674b48 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 @@ -470,7 +470,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -709,7 +721,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 4ef8a132..647d092d 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 @@ -692,7 +692,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -817,7 +829,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 79500a4c..2c64f30e 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 @@ -326,7 +326,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { 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 540feec9..6b0bf9c9 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 @@ -673,7 +673,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { @@ -798,7 +810,19 @@ private constructor( else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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) { From 550e1a8e92513d874055b527c8b20188078fe312 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 07:47:38 +0000 Subject: [PATCH 44/87] feat(client): support `JsonField#asX()` for known values (#114) chore(internal): update some formatting in `Values.kt` --- .../com/braintrustdata/api/core/Values.kt | 77 +++++++--- .../com/braintrustdata/api/core/ValuesTest.kt | 144 ++++++++++++++++++ 2 files changed, 196 insertions(+), 25 deletions(-) create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 2442514d..3436d574 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -59,36 +59,69 @@ sealed class JsonField { fun asBoolean(): Optional = when (this) { is JsonBoolean -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Boolean) else -> Optional.empty() } fun asNumber(): Optional = when (this) { is JsonNumber -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Number) else -> Optional.empty() } fun asString(): Optional = when (this) { is JsonString -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? String) else -> Optional.empty() } fun asStringOrThrow(): String = - when (this) { - is JsonString -> value - else -> throw BraintrustInvalidDataException("Value is not a string") - } + asString().orElseThrow { BraintrustInvalidDataException("Value is not a string") } fun asArray(): Optional> = when (this) { is JsonArray -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? List<*>)?.map { + try { + JsonValue.from(it) + } catch (e: IllegalArgumentException) { + // The known value is a list, but not all values are convertible to + // `JsonValue`. + return Optional.empty() + } + } + ) else -> Optional.empty() } fun asObject(): Optional> = when (this) { is JsonObject -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? Map<*, *>) + ?.map { (key, value) -> + if (key !is String) { + return Optional.empty() + } + + val jsonValue = + try { + JsonValue.from(value) + } catch (e: IllegalArgumentException) { + // The known value is a map, but not all items are convertible + // to `JsonValue`. + return Optional.empty() + } + + key to jsonValue + } + ?.toMap() + ) else -> Optional.empty() } @@ -96,9 +129,9 @@ sealed class JsonField { internal fun getRequired(name: String): T = when (this) { is KnownValue -> value - is JsonMissing -> throw BraintrustInvalidDataException("'${name}' is not set") - is JsonNull -> throw BraintrustInvalidDataException("'${name}' is null") - else -> throw BraintrustInvalidDataException("'${name}' is invalid, received ${this}") + is JsonMissing -> throw BraintrustInvalidDataException("`$name` is not set") + is JsonNull -> throw BraintrustInvalidDataException("`$name` is null") + else -> throw BraintrustInvalidDataException("`$name` is invalid, received $this") } @JvmSynthetic @@ -107,7 +140,7 @@ sealed class JsonField { is KnownValue -> value is JsonMissing -> null is JsonNull -> null - else -> throw BraintrustInvalidDataException("'${name}' is invalid, received ${this}") + else -> throw BraintrustInvalidDataException("`$name` is invalid, received $this") } @JvmSynthetic @@ -140,8 +173,11 @@ sealed class JsonField { } } - // This class is a Jackson filter that can be used to exclude missing properties from objects - // This filter should not be used directly and should instead use the @ExcludeMissing annotation + /** + * This class is a Jackson filter that can be used to exclude missing properties from objects. + * This filter should not be used directly and should instead use the @ExcludeMissing + * annotation. + */ class IsMissing { override fun equals(other: Any?): Boolean = other is JsonMissing @@ -154,18 +190,13 @@ sealed class JsonField { override fun createContextual( context: DeserializationContext, property: BeanProperty?, - ): JsonDeserializer> { - return Deserializer(context.contextualType?.containedType(0)) - } + ): JsonDeserializer> = Deserializer(context.contextualType?.containedType(0)) - override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> { - return type?.let { tryDeserialize(node, type) }?.let { of(it) } + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> = + type?.let { tryDeserialize(node, type) }?.let { of(it) } ?: JsonValue.fromJsonNode(node) - } - override fun getNullValue(context: DeserializationContext): JsonField<*> { - return JsonNull.of() - } + override fun getNullValue(context: DeserializationContext): JsonField<*> = JsonNull.of() } } @@ -240,13 +271,9 @@ sealed class JsonValue : JsonField() { } class Deserializer : BaseDeserializer(JsonValue::class) { - override fun ObjectCodec.deserialize(node: JsonNode): JsonValue { - return fromJsonNode(node) - } + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue = fromJsonNode(node) - override fun getNullValue(context: DeserializationContext?): JsonValue { - return JsonNull.of() - } + override fun getNullValue(context: DeserializationContext?): JsonValue = JsonNull.of() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt new file mode 100644 index 00000000..fcdb9f5c --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt @@ -0,0 +1,144 @@ +package com.braintrustdata.api.core + +import java.util.Optional +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ValuesTest { + companion object { + private val NON_JSON = Any() + } + + enum class TestCase( + val value: JsonField<*>, + val expectedIsMissing: Boolean = false, + val expectedIsNull: Boolean = false, + val expectedAsKnown: Optional<*> = Optional.empty(), + val expectedAsBoolean: Optional = Optional.empty(), + val expectedAsNumber: Optional = Optional.empty(), + val expectedAsString: Optional = Optional.empty(), + val expectedAsArray: Optional> = Optional.empty(), + val expectedAsObject: Optional> = Optional.empty(), + ) { + MISSING(JsonMissing.of(), expectedIsMissing = true), + NULL(JsonNull.of(), expectedIsNull = true), + KNOWN(KnownValue.of(NON_JSON), expectedAsKnown = Optional.of(NON_JSON)), + KNOWN_BOOLEAN( + KnownValue.of(true), + expectedAsKnown = Optional.of(true), + expectedAsBoolean = Optional.of(true), + ), + BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), + KNOWN_NUMBER( + KnownValue.of(42), + expectedAsKnown = Optional.of(42), + expectedAsNumber = Optional.of(42), + ), + NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), + KNOWN_STRING( + KnownValue.of("hello"), + expectedAsKnown = Optional.of("hello"), + expectedAsString = Optional.of("hello"), + ), + STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), + KNOWN_ARRAY_NOT_ALL_JSON( + KnownValue.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + ), + KNOWN_ARRAY( + KnownValue.of(listOf("a", "b", "c")), + expectedAsKnown = Optional.of(listOf("a", "b", "c")), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + ARRAY( + JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + KNOWN_OBJECT_NOT_ALL_STRING_KEYS( + KnownValue.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + ), + KNOWN_OBJECT_NOT_ALL_JSON( + KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + ), + KNOWN_OBJECT( + KnownValue.of(mapOf("a" to "b", "b" to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + OBJECT( + JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + } + + @ParameterizedTest + @EnumSource + fun isMissing(testCase: TestCase) { + val isMissing = testCase.value.isMissing() + + assertThat(isMissing).isEqualTo(testCase.expectedIsMissing) + } + + @ParameterizedTest + @EnumSource + fun isNull(testCase: TestCase) { + val isNull = testCase.value.isNull() + + assertThat(isNull).isEqualTo(testCase.expectedIsNull) + } + + @ParameterizedTest + @EnumSource + fun asKnown(testCase: TestCase) { + val known = testCase.value.asKnown() + + assertThat(known).isEqualTo(testCase.expectedAsKnown) + } + + @ParameterizedTest + @EnumSource + fun asBoolean(testCase: TestCase) { + val boolean = testCase.value.asBoolean() + + assertThat(boolean).isEqualTo(testCase.expectedAsBoolean) + } + + @ParameterizedTest + @EnumSource + fun asNumber(testCase: TestCase) { + val number = testCase.value.asNumber() + + assertThat(number).isEqualTo(testCase.expectedAsNumber) + } + + @ParameterizedTest + @EnumSource + fun asString(testCase: TestCase) { + val string = testCase.value.asString() + + assertThat(string).isEqualTo(testCase.expectedAsString) + } + + @ParameterizedTest + @EnumSource + fun asArray(testCase: TestCase) { + val array = testCase.value.asArray() + + assertThat(array).isEqualTo(testCase.expectedAsArray) + } + + @ParameterizedTest + @EnumSource + fun asObject(testCase: TestCase) { + val obj = testCase.value.asObject() + + assertThat(obj).isEqualTo(testCase.expectedAsObject) + } +} From b65c5991e1451302fd20fb345d82c89fbd47bc80 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 20 Feb 2025 05:30:52 +0000 Subject: [PATCH 45/87] chore(docs): reorganize readme (#115) --- README.md | 352 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 221 insertions(+), 131 deletions(-) diff --git a/README.md b/README.md index 460c5029..1734468c 100644 --- a/README.md +++ b/README.md @@ -42,145 +42,135 @@ This library requires Java 8 or later. ## Usage -### Configure the client - -Use `BraintrustOkHttpClient.builder()` to configure the client. - -Alternately, set the environment with `BRAINTRUST_API_KEY`, and use `BraintrustOkHttpClient.fromEnv()` to read from the environment. - ```java import com.braintrustdata.api.client.BraintrustClient; import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; - -BraintrustClient client = BraintrustOkHttpClient.fromEnv(); - -// Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties -BraintrustClient client = BraintrustOkHttpClient.builder() - .fromEnv() - // ... set properties on the builder - .build(); -``` - -| Property | Environment variable | Required | Default value | -| -------- | -------------------- | -------- | ------------- | -| apiKey | `BRAINTRUST_API_KEY` | false | — | - -Read the documentation for more configuration options. - ---- - -### Example: creating a resource - -To create a new project, first use the `ProjectCreateParams` builder to specify attributes, then pass that to the `create` method of the `projects` service. - -```java import com.braintrustdata.api.models.Project; import com.braintrustdata.api.models.ProjectCreateParams; +// Configures using the `BRAINTRUST_API_KEY` environment variable +BraintrustClient client = BraintrustOkHttpClient.fromEnv(); + ProjectCreateParams params = ProjectCreateParams.builder() .name("foobar") .build(); Project project = client.projects().create(params); ``` -### Example: listing resources +## Client configuration -The Braintrust API provides a `list` method to get a paginated list of projects. You can retrieve the first page by: +Configure the client using environment variables: ```java -import com.braintrustdata.api.models.Project; -import com.braintrustdata.api.models.ProjectListPage; +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; -ProjectListPage page = client.projects().list(); -for (Project project : page.objects()) { - System.out.println(project); -} +// Configures using the `BRAINTRUST_API_KEY` environment variable +BraintrustClient client = BraintrustOkHttpClient.fromEnv(); ``` -Use the `ProjectListParams` builder to set parameters: +Or manually: ```java -import com.braintrustdata.api.models.ProjectListPage; -import com.braintrustdata.api.models.ProjectListParams; - -ProjectListParams params = ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; + +BraintrustClient client = BraintrustOkHttpClient.builder() + .apiKey("My API Key") .build(); -ProjectListPage page1 = client.projects().list(params); +``` -// Using the `from` method of the builder you can reuse previous params values: -ProjectListPage page2 = client.projects().list(ProjectListParams.builder() - .from(params) - .build()); +Or using a combination of the two approaches: -// Or easily get params for the next page by using the helper `getNextPageParams`: -ProjectListPage page3 = client.projects().list(params.getNextPageParams(page2)); -``` +```java +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; -See [Pagination](#pagination) below for more information on transparently working with lists of objects without worrying about fetching each page. +BraintrustClient client = BraintrustOkHttpClient.builder() + // Configures using the `BRAINTRUST_API_KEY` environment variable + .fromEnv() + .apiKey("My API Key") + .build(); +``` ---- +See this table for the available options: -## Requests +| Setter | Environment variable | Required | Default value | +| -------- | -------------------- | -------- | ------------- | +| `apiKey` | `BRAINTRUST_API_KEY` | false | - | -### Parameters and bodies +> [!TIP] +> Don't create more than one client in the same application. Each client has a connection pool and +> thread pools, which are more efficient to share between requests. -To make a request to the Braintrust API, you generally build an instance of the appropriate `Params` class. +## Requests and responses -See [Undocumented request params](#undocumented-request-params) for how to send arbitrary parameters. +To send a request to the Braintrust API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -## Responses +For example, `client.projects().create(...)` should be called with an instance of `ProjectCreateParams`, and it will return an instance of `Project`. -### Response validation +## Asynchronous execution -When receiving a response, the Braintrust Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `BraintrustInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model. +The default client is synchronous. To switch to asynchronous execution, call the `async()` method: ```java +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; import com.braintrustdata.api.models.Project; +import com.braintrustdata.api.models.ProjectCreateParams; +import java.util.concurrent.CompletableFuture; -Project project = client.projects().create().validate(); -``` +// Configures using the `BRAINTRUST_API_KEY` environment variable +BraintrustClient client = BraintrustOkHttpClient.fromEnv(); -### Response properties as JSON +ProjectCreateParams params = ProjectCreateParams.builder() + .name("foobar") + .build(); +CompletableFuture project = client.async().projects().create(params); +``` -In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value. +Or create an asynchronous client from the beginning: ```java -import com.braintrustdata.api.core.JsonField; -import java.util.Optional; - -JsonField field = responseObj._field(); +import com.braintrustdata.api.client.BraintrustClientAsync; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync; +import com.braintrustdata.api.models.Project; +import com.braintrustdata.api.models.ProjectCreateParams; +import java.util.concurrent.CompletableFuture; -if (field.isMissing()) { - // Value was not specified in the JSON response -} else if (field.isNull()) { - // Value was provided as a literal null -} else { - // See if value was provided as a string - Optional jsonString = field.asString(); +// Configures using the `BRAINTRUST_API_KEY` environment variable +BraintrustClientAsync client = BraintrustOkHttpClientAsync.fromEnv(); - // If the value given by the API did not match the shape that the SDK expects - // you can deserialise into a custom type - MyClass myObj = responseObj._field().asUnknown().orElseThrow().convert(MyClass.class); -} +ProjectCreateParams params = ProjectCreateParams.builder() + .name("foobar") + .build(); +CompletableFuture project = client.projects().create(params); ``` -### Additional model properties +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. -Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method: +## Error handling -```java -import com.braintrustdata.api.core.JsonValue; +The SDK throws custom unchecked exception types: -JsonValue secret = aISecret._additionalProperties().get("secret_field"); -``` +- `BraintrustServiceException`: Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: + + | Status | Exception | + | ------ | ------------------------------- | + | 400 | `BadRequestException` | + | 401 | `AuthenticationException` | + | 403 | `PermissionDeniedException` | + | 404 | `NotFoundException` | + | 422 | `UnprocessableEntityException` | + | 429 | `RateLimitException` | + | 5xx | `InternalServerException` | + | others | `UnexpectedStatusCodeException` | + +- `BraintrustIoException`: I/O networking errors. ---- +- `BraintrustInvalidDataException`: Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. + +- `BraintrustException`: Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. ## Pagination @@ -234,36 +224,39 @@ while (page != null) { } ``` ---- - -## Error handling +## Logging -This library throws exceptions in a single hierarchy for easy handling: +The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). -- **`BraintrustException`** - Base exception for all exceptions +Enable logging by setting the `BRAINTRUST_LOG` environment variable to `info`: -- **`BraintrustServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server. +```sh +$ export BRAINTRUST_LOG=info +``` - | 400 | BadRequestException | - | ------ | ----------------------------- | - | 401 | AuthenticationException | - | 403 | PermissionDeniedException | - | 404 | NotFoundException | - | 422 | UnprocessableEntityException | - | 429 | RateLimitException | - | 5xx | InternalServerException | - | others | UnexpectedStatusCodeException | +Or to `debug` for more verbose logging: -- **`BraintrustIoException`** - I/O networking errors -- **`BraintrustInvalidDataException`** - any other exceptions on the client side, e.g.: - - We failed to serialize the request body - - We failed to parse the response body (has access to response code and body) +```sh +$ export BRAINTRUST_LOG=debug +``` ## Network options ### Retries -Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. You can provide a `maxRetries` on the client builder to configure this: +The SDK automatically retries 2 times by default, with a short exponential backoff. + +Only the following error types are retried: + +- Connection errors (for example, due to a network connectivity problem) +- 408 Request Timeout +- 409 Conflict +- 429 Rate Limit +- 5xx Internal + +The API may also explicitly instruct the SDK to retry or not retry a response. + +To set a custom number of retries, configure the client using the `maxRetries` method: ```java import com.braintrustdata.api.client.BraintrustClient; @@ -277,7 +270,20 @@ BraintrustClient client = BraintrustOkHttpClient.builder() ### Timeouts -Requests time out after 1 minute by default. You can configure this on the client builder: +Requests time out after 1 minute by default. + +To set a custom timeout, configure the method call using the `timeout` method: + +```java +import com.braintrustdata.api.models.Project; +import com.braintrustdata.api.models.ProjectCreateParams; + +Project project = client.projects().create( + params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() +); +``` + +Or configure the default for all method calls at the client level: ```java import com.braintrustdata.api.client.BraintrustClient; @@ -292,7 +298,7 @@ BraintrustClient client = BraintrustOkHttpClient.builder() ### Proxies -Requests can be routed through a proxy. You can configure this on the client builder: +To route requests through a proxy, configure the client using the `proxy` method: ```java import com.braintrustdata.api.client.BraintrustClient; @@ -302,19 +308,21 @@ import java.net.Proxy; BraintrustClient client = BraintrustOkHttpClient.builder() .fromEnv() - .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("example.com", 8080))) + .proxy(new Proxy( + Proxy.Type.HTTP, new InetSocketAddress( + "https://example.com", 8080 + ) + )) .build(); ``` -## Making custom/undocumented requests - -This library is typed for convenient access to the documented API. If you need to access undocumented params or response properties, the library can still be used. +## Undocumented API functionality -### Undocumented request params +The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. -In [Example: creating a resource](#example-creating-a-resource) above, we used the `ProjectCreateParams.builder()` to pass to the `create` method of the `projects` service. +### Parameters -Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using raw setters: +To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class: ```java import com.braintrustdata.api.core.JsonValue; @@ -327,26 +335,108 @@ ProjectCreateParams params = ProjectCreateParams.builder() .build(); ``` -You can also use the `putAdditionalProperty` method on nested headers, query params, or body objects. +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. You can also set undocumented parameters on nested headers, query params, or body classes using the `putAdditionalProperty` method. These properties can be accessed on the built object later using the `_additionalProperties()` method. -### Undocumented response properties +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a `JsonValue` object to its setter: -To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `res._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. +```java +import com.braintrustdata.api.core.JsonValue; +import com.braintrustdata.api.models.ProjectCreateParams; -## Logging +ProjectCreateParams params = ProjectCreateParams.builder() + .name(JsonValue.from(42)) + .build(); +``` -We use the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). +### Response properties -You can enable logging by setting the environment variable `BRAINTRUST_LOG` to `info`. +To access undocumented response properties, call the `_additionalProperties()` method: -```sh -$ export BRAINTRUST_LOG=info +```java +import com.braintrustdata.api.core.JsonValue; +import java.util.Map; + +Map additionalProperties = client.projects().create(params)._additionalProperties(); +JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); + +String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { + @Override + public String visitNull() { + return "It's null!"; + } + + @Override + public String visitBoolean(boolean value) { + return "It's a boolean!"; + } + + @Override + public String visitNumber(Number value) { + return "It's a number!"; + } + + // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject` + // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden +}); ``` -Or to `debug` for more verbose logging. +To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: -```sh -$ export BRAINTRUST_LOG=debug +```java +import com.braintrustdata.api.core.JsonField; +import java.util.Optional; + +JsonField name = client.projects().create(params)._name(); + +if (name.isMissing()) { + // The property is absent from the JSON response +} else if (name.isNull()) { + // The property was set to literal null +} else { + // Check if value was provided as a string + // Other methods include `asNumber()`, `asBoolean()`, etc. + Optional jsonString = name.asString(); + + // Try to deserialize into a custom type + MyClass myObject = name.asUnknown().orElseThrow().convert(MyClass.class); +} +``` + +### Response validation + +In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. + +By default, the SDK will not throw an exception in this case. It will throw `BraintrustInvalidDataException` only if you directly access the property. + +If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: + +```java +import com.braintrustdata.api.models.Project; + +Project project = client.projects().create(params).validate(); +``` + +Or configure the method call to validate the response using the `responseValidation` method: + +```java +import com.braintrustdata.api.models.Project; +import com.braintrustdata.api.models.ProjectCreateParams; + +Project project = client.projects().create( + params, RequestOptions.builder().responseValidation(true).build() +); +``` + +Or configure the default for all method calls at the client level: + +```java +import com.braintrustdata.api.client.BraintrustClient; +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient; + +BraintrustClient client = BraintrustOkHttpClient.builder() + .fromEnv() + .responseValidation(true) + .build(); ``` ## Semantic versioning From 1a69b73fdc5eb657e72fd3b3d8d3c4f34378cbc3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 08:59:26 +0000 Subject: [PATCH 46/87] chore(internal): get rid of configuration cache (#116) It's causing release issues in some cases. --- gradle.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ec5c5092..0c8d4ded 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ -org.gradle.configuration-cache=true org.gradle.caching=true org.gradle.parallel=true org.gradle.daemon=false From aaaef188d4fbe8ba97fcc55fe1dac15d527cf1ec Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 09:45:28 +0000 Subject: [PATCH 47/87] chore(internal): codegen related update (#117) --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71594a4c..121ace97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Validate Gradle wrapper - uses: gradle/actions/wrapper-validation@v3 - - name: Set up Java uses: actions/setup-java@v4 with: @@ -30,7 +27,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v4 - name: Run lints run: ./scripts/lint From 0aabe74100f814d12b472e5f4d8344b851804d0a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 10:02:15 +0000 Subject: [PATCH 48/87] feat(client): get rid of annoying checked exceptions (#118) --- .../kotlin/com/braintrustdata/api/core/http/HttpClient.kt | 3 +++ .../com/braintrustdata/api/core/http/HttpRequestBody.kt | 4 ++-- .../kotlin/com/braintrustdata/api/core/http/HttpResponse.kt | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt index 2d8ef81e..1a8a3910 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt @@ -19,4 +19,7 @@ interface HttpClient : AutoCloseable { request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt index e5c7df37..ebf2b4d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt @@ -1,12 +1,11 @@ package com.braintrustdata.api.core.http -import java.io.IOException import java.io.OutputStream import java.lang.AutoCloseable interface HttpRequestBody : AutoCloseable { - @Throws(IOException::class) fun writeTo(outputStream: OutputStream) + fun writeTo(outputStream: OutputStream) fun contentType(): String? @@ -21,5 +20,6 @@ interface HttpRequestBody : AutoCloseable { */ fun repeatable(): Boolean + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ override fun close() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt index 150bd762..901b030b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponse.kt @@ -11,6 +11,9 @@ interface HttpResponse : AutoCloseable { fun body(): InputStream + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() + interface Handler { fun handle(response: HttpResponse): T From 5b4d07fc3da4e77c62bdffddd4f6e215401755b2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 10:18:27 +0000 Subject: [PATCH 49/87] chore(docs): add faq to readme (#119) --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 1734468c..67c63b33 100644 --- a/README.md +++ b/README.md @@ -439,6 +439,35 @@ BraintrustClient client = BraintrustOkHttpClient.builder() .build(); ``` +## FAQ + +### Why don't you use plain `enum` classes? + +Java `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value. + +### Why do you represent fields using `JsonField` instead of just plain `T`? + +Using `JsonField` enables a few features: + +- Allowing usage of [undocumented API functionality](#undocumented-api-functionality) +- Lazily [validating the API response against the expected shape](#response-validation) +- Representing absent vs explicitly null values + +### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)? + +It is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class. + +### Why don't you use checked exceptions? + +Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason. + +Checked exceptions: + +- Are verbose to handle +- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error +- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function) +- Don't play well with lambdas (also due to the function coloring problem) + ## Semantic versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: From 274c95c6df23554f747392fb51a50f3a327125af Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 10:23:02 +0000 Subject: [PATCH 50/87] fix(client): mark some request bodies as optional (#120) chore(internal): use `assertNotNull` in tests for type narrowing chore(internal): remove unnecessary non-null asserts in tests --- .../braintrustdata/api/models/AclBatchUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/AclCreateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/AclFindAndDeleteParamsTest.kt | 5 +++-- .../braintrustdata/api/models/AiSecretCreateParamsTest.kt | 5 +++-- .../api/models/AiSecretFindAndDeleteParamsTest.kt | 5 +++-- .../braintrustdata/api/models/AiSecretReplaceParamsTest.kt | 5 +++-- .../braintrustdata/api/models/AiSecretUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/DatasetCreateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/DatasetFeedbackParamsTest.kt | 5 +++-- .../braintrustdata/api/models/DatasetFetchPostParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/DatasetInsertParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/DatasetUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/EnvVarCreateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/EvalCreateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/ExperimentCreateParamsTest.kt | 5 +++-- .../api/models/ExperimentFeedbackParamsTest.kt | 5 +++-- .../api/models/ExperimentFetchPostParamsTest.kt | 5 +++-- .../braintrustdata/api/models/ExperimentInsertParamsTest.kt | 5 +++-- .../braintrustdata/api/models/ExperimentUpdateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/FunctionCreateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/FunctionInvokeParamsTest.kt | 5 +++-- .../braintrustdata/api/models/FunctionReplaceParamsTest.kt | 5 +++-- .../braintrustdata/api/models/FunctionUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/GroupCreateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/GroupReplaceParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/GroupUpdateParamsTest.kt | 5 +++-- .../api/models/OrganizationMemberUpdateParamsTest.kt | 5 +++-- .../api/models/OrganizationUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/ProjectCreateParamsTest.kt | 5 +++-- .../api/models/ProjectLogFeedbackParamsTest.kt | 5 +++-- .../api/models/ProjectLogFetchPostParamsTest.kt | 5 +++-- .../braintrustdata/api/models/ProjectLogInsertParamsTest.kt | 5 +++-- .../api/models/ProjectScoreCreateParamsTest.kt | 5 +++-- .../api/models/ProjectScoreReplaceParamsTest.kt | 5 +++-- .../api/models/ProjectScoreUpdateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/ProjectTagCreateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/ProjectTagReplaceParamsTest.kt | 5 +++-- .../braintrustdata/api/models/ProjectTagUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/ProjectUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/PromptCreateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/PromptReplaceParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/PromptUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/RoleCreateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/RoleReplaceParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/RoleUpdateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/SpanIframeCreateParamsTest.kt | 5 +++-- .../braintrustdata/api/models/SpanIframeReplaceParamsTest.kt | 5 +++-- .../braintrustdata/api/models/SpanIframeUpdateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/ViewCreateParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/ViewDeleteParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/ViewReplaceParamsTest.kt | 5 +++-- .../com/braintrustdata/api/models/ViewUpdateParamsTest.kt | 5 +++-- 55 files changed, 165 insertions(+), 110 deletions(-) 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 2aa46d8b..ce3f43d3 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -71,7 +72,7 @@ class AclBatchUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.addAcls()) .contains( listOf( @@ -112,6 +113,6 @@ class AclBatchUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } } 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 941f9331..2f1cbe6c 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -35,7 +36,7 @@ class AclCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -56,7 +57,7 @@ class AclCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.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 e585c5fb..8c64fe8b 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -35,7 +36,7 @@ class AclFindAndDeleteParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) assertThat(body.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -56,7 +57,7 @@ class AclFindAndDeleteParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt index 3cc34e58..213130fd 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -40,7 +41,7 @@ class AiSecretCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.metadata()) .contains( @@ -59,7 +60,7 @@ class AiSecretCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt index 4e028f50..f46d2fb2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -18,7 +19,7 @@ class AiSecretFindAndDeleteParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.orgName()).contains("org_name") } @@ -29,7 +30,7 @@ class AiSecretFindAndDeleteParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt index 2598f52a..b716129c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -40,7 +41,7 @@ class AiSecretReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.metadata()) .contains( @@ -59,7 +60,7 @@ class AiSecretReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt index a3167595..b45e1c86 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -40,7 +41,7 @@ class AiSecretUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.metadata()) .contains( AiSecretUpdateParams.Metadata.builder() @@ -61,7 +62,7 @@ class AiSecretUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt index 592c3500..d450a958 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -18,7 +19,7 @@ class ApiKeyCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.orgName()).contains("org_name") } @@ -29,7 +30,7 @@ class ApiKeyCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index e51c08fb..53e0d257 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -38,7 +39,7 @@ class DatasetCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.description()).contains("description") @@ -60,7 +61,7 @@ class DatasetCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index 0686d6b3..512fb176 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -50,7 +51,7 @@ class DatasetFeedbackParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.feedback()) .isEqualTo( listOf( @@ -79,7 +80,7 @@ class DatasetFeedbackParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.feedback()) .isEqualTo(listOf(FeedbackDatasetItem.builder().id("id").build())) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index 58379710..3120e7e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -33,7 +34,7 @@ class DatasetFetchPostParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.cursor()).contains("cursor") assertThat(body.limit()).contains(0L) assertThat(body.maxRootSpanId()).contains("max_root_span_id") @@ -50,7 +51,7 @@ class DatasetFetchPostParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index b944b3c1..9f080dd0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -67,7 +68,7 @@ class DatasetInsertParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.events()) .isEqualTo( listOf( @@ -104,7 +105,7 @@ class DatasetInsertParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index 2419bb8a..c7976ff2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -38,7 +39,7 @@ class DatasetUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.description()).contains("description") assertThat(body.metadata()) .contains( @@ -56,7 +57,7 @@ class DatasetUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt index a2601ff8..d5e8e9f1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,7 +30,7 @@ class EnvVarCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) @@ -47,7 +48,7 @@ class EnvVarCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt index 2acb4222..68d9ebd2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,7 +30,7 @@ class EnvVarReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) @@ -47,7 +48,7 @@ class EnvVarReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt index 7403582f..e4ad1080 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -27,7 +28,7 @@ class EnvVarUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.value()).contains("value") } @@ -42,7 +43,7 @@ class EnvVarUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index 088dff26..5ac72887 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -114,7 +115,7 @@ class EvalCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.data()) .isEqualTo( EvalCreateParams.Data.ofDatasetId( @@ -193,7 +194,7 @@ class EvalCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.data()) .isEqualTo( EvalCreateParams.Data.ofDatasetId( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 0fc3f173..0b43f784 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -74,7 +75,7 @@ class ExperimentCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -114,7 +115,7 @@ class ExperimentCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index 726c899c..edb22bd0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -62,7 +63,7 @@ class ExperimentFeedbackParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.feedback()) .isEqualTo( listOf( @@ -97,7 +98,7 @@ class ExperimentFeedbackParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.feedback()) .isEqualTo(listOf(FeedbackExperimentItem.builder().id("id").build())) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index a6ecedfe..f537a14a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -33,7 +34,7 @@ class ExperimentFetchPostParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.cursor()).contains("cursor") assertThat(body.limit()).contains(0L) assertThat(body.maxRootSpanId()).contains("max_root_span_id") @@ -50,7 +51,7 @@ class ExperimentFetchPostParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test 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 4ab46acb..9627ff9b 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 @@ -4,6 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -130,7 +131,7 @@ class ExperimentInsertParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.events()) .isEqualTo( listOf( @@ -200,7 +201,7 @@ class ExperimentInsertParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index 5705ba3c..e7ed2b95 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -72,7 +73,7 @@ class ExperimentUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.datasetVersion()).contains("dataset_version") @@ -110,7 +111,7 @@ class ExperimentUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test 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 85403cb0..f4114dc7 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 @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -220,7 +221,7 @@ class FunctionCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.functionData()) .isEqualTo( FunctionCreateParams.FunctionData.ofPrompt( @@ -344,7 +345,7 @@ class FunctionCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.functionData()) .isEqualTo( FunctionCreateParams.FunctionData.ofPrompt( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index 65e86566..dcfb6ecc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -86,7 +87,7 @@ class FunctionInvokeParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.messages()) .contains( @@ -137,7 +138,7 @@ class FunctionInvokeParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test 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 91846cf5..56eba313 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 @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -220,7 +221,7 @@ class FunctionReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.functionData()) .isEqualTo( FunctionReplaceParams.FunctionData.ofPrompt( @@ -344,7 +345,7 @@ class FunctionReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.functionData()) .isEqualTo( FunctionReplaceParams.FunctionData.ofPrompt( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index c3dfbb9a..051c89be 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -190,7 +191,7 @@ class FunctionUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.description()).contains("description") assertThat(body.functionData()) .contains( @@ -289,7 +290,7 @@ class FunctionUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index bc3836e6..c9d71536 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,7 +32,7 @@ class GroupCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -45,7 +46,7 @@ class GroupCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index 1b4bf806..093c89bc 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,7 +32,7 @@ class GroupReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) @@ -45,7 +46,7 @@ class GroupReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index 114ae451..cb449a6e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -35,7 +36,7 @@ class GroupUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) assertThat(body.description()).contains("description") @@ -53,7 +54,7 @@ class GroupUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt index d13cd4b6..ccb97ded 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -59,7 +60,7 @@ class OrganizationMemberUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.inviteUsers()) .contains( OrganizationMemberUpdateParams.InviteUsers.builder() @@ -89,6 +90,6 @@ class OrganizationMemberUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt index cd409c37..00ff172f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -33,7 +34,7 @@ class OrganizationUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.apiUrl()).contains("api_url") assertThat(body.isUniversalApi()).contains(true) assertThat(body.name()).contains("name") @@ -50,7 +51,7 @@ class OrganizationUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index a4a7efda..32b8bed3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -18,7 +19,7 @@ class ProjectCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.orgName()).contains("org_name") } @@ -29,7 +30,7 @@ class ProjectCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index a1b6dfb1..d7a429e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -62,7 +63,7 @@ class ProjectLogFeedbackParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.feedback()) .isEqualTo( listOf( @@ -97,7 +98,7 @@ class ProjectLogFeedbackParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.feedback()) .isEqualTo(listOf(FeedbackProjectLogsItem.builder().id("id").build())) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 8208afaa..9d2530b0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -33,7 +34,7 @@ class ProjectLogFetchPostParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.cursor()).contains("cursor") assertThat(body.limit()).contains(0L) assertThat(body.maxRootSpanId()).contains("max_root_span_id") @@ -50,7 +51,7 @@ class ProjectLogFetchPostParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test 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 7cef665e..24369344 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 @@ -4,6 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -128,7 +129,7 @@ class ProjectLogInsertParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.events()) .isEqualTo( listOf( @@ -197,7 +198,7 @@ class ProjectLogInsertParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) } 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 9351c8ed..f2eb7ba1 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -73,7 +74,7 @@ class ProjectScoreCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) @@ -117,7 +118,7 @@ class ProjectScoreCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) 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 f55560d0..022d016b 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -73,7 +74,7 @@ class ProjectScoreReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) @@ -117,7 +118,7 @@ class ProjectScoreReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) 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 85568ddd..7f153a84 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -73,7 +74,7 @@ class ProjectScoreUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.categories()) .contains( ProjectScoreUpdateParams.Categories.ofCategorical( @@ -114,7 +115,7 @@ class ProjectScoreUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt index 269115e9..04649ccf 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,7 +30,7 @@ class ProjectTagCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.color()).contains("color") @@ -46,7 +47,7 @@ class ProjectTagCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt index 1501850a..9e25d87a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,7 +30,7 @@ class ProjectTagReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.color()).contains("color") @@ -46,7 +47,7 @@ class ProjectTagReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt index 39cb58d2..343aa380 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,7 +30,7 @@ class ProjectTagUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.color()).contains("color") assertThat(body.description()).contains("description") assertThat(body.name()).contains("name") @@ -44,7 +45,7 @@ class ProjectTagUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 591d4905..63716ab9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -27,7 +28,7 @@ class ProjectUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).contains("name") assertThat(body.settings()) .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) @@ -40,7 +41,7 @@ class ProjectUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 404585ad..92e03d0c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -184,7 +185,7 @@ class PromptCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("x") @@ -280,7 +281,7 @@ class PromptCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("x") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index ad32d022..18d87eb2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -184,7 +185,7 @@ class PromptReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("x") @@ -280,7 +281,7 @@ class PromptReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.slug()).isEqualTo("x") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 9112aa11..7dae6fe3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -182,7 +183,7 @@ class PromptUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.description()).contains("description") assertThat(body.name()).contains("name") assertThat(body.promptData()) @@ -272,7 +273,7 @@ class PromptUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @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 0e894c79..2a910fde 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -45,7 +46,7 @@ class RoleCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") assertThat(body.memberPermissions()) @@ -69,7 +70,7 @@ class RoleCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") } } 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 020866ba..46264e88 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -45,7 +46,7 @@ class RoleReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") assertThat(body.description()).contains("description") assertThat(body.memberPermissions()) @@ -69,7 +70,7 @@ class RoleReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("x") } } 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 6fc8460c..ee226d14 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -63,7 +64,7 @@ class RoleUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.addMemberPermissions()) .contains( listOf( @@ -100,7 +101,7 @@ class RoleUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt index bcc72601..baf7a58f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,7 +32,7 @@ class SpanIframeCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.url()).isEqualTo("url") @@ -50,7 +51,7 @@ class SpanIframeCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.url()).isEqualTo("url") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt index 4de31d36..305c97ad 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -31,7 +32,7 @@ class SpanIframeReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.url()).isEqualTo("url") @@ -50,7 +51,7 @@ class SpanIframeReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.url()).isEqualTo("url") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index d03de12f..57fce4c2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,7 +30,7 @@ class SpanIframeUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).contains("name") assertThat(body.postMessage()).contains(true) assertThat(body.url()).contains("url") @@ -44,7 +45,7 @@ class SpanIframeUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) } @Test 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 898590d1..1f09c824 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 @@ -4,6 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -89,7 +90,7 @@ class ViewCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) @@ -139,7 +140,7 @@ class ViewCreateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) 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 34750bb8..20ab82f1 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 @@ -2,6 +2,7 @@ package com.braintrustdata.api.models +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -27,7 +28,7 @@ class ViewDeleteParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @@ -43,7 +44,7 @@ class ViewDeleteParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } 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 11a07d8c..069dcccd 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 @@ -4,6 +4,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue import java.time.OffsetDateTime +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -89,7 +90,7 @@ class ViewReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) @@ -139,7 +140,7 @@ class ViewReplaceParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.name()).isEqualTo("name") assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) 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 2730c177..67d83174 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 @@ -3,6 +3,7 @@ package com.braintrustdata.api.models import com.braintrustdata.api.core.JsonValue +import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -88,7 +89,7 @@ class ViewUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) assertThat(body.name()).contains("name") @@ -136,7 +137,7 @@ class ViewUpdateParamsTest { val body = params._body() - assertThat(body).isNotNull + assertNotNull(body) assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) } From 6a15c6f103419b9ebd420a5a40de9b675c5302f0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 10:27:10 +0000 Subject: [PATCH 51/87] docs: add immutability explanation to readme (#121) --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 67c63b33..27e3f949 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,14 @@ To send a request to the Braintrust API, build an instance of some `Params` clas For example, `client.projects().create(...)` should be called with an instance of `ProjectCreateParams`, and it will return an instance of `Project`. +## Immutability + +Each class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it. + +Each class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy. + +Because each class is immutable, builder modification will _never_ affect already built class instances. + ## Asynchronous execution The default client is synchronous. To switch to asynchronous execution, call the `async()` method: From c9d3840c4fded6c0ece296ceb60a5526c3d81c75 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 26 Feb 2025 04:50:35 +0000 Subject: [PATCH 52/87] chore(internal): codegen related update (#122) --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 27e3f949..f77a97be 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ The asynchronous client supports the same options as the synchronous one, except The SDK throws custom unchecked exception types: -- `BraintrustServiceException`: Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: +- [`BraintrustServiceException`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: | Status | Exception | | ------ | ------------------------------- | @@ -174,11 +174,11 @@ The SDK throws custom unchecked exception types: | 5xx | `InternalServerException` | | others | `UnexpectedStatusCodeException` | -- `BraintrustIoException`: I/O networking errors. +- [`BraintrustIoException`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt): I/O networking errors. -- `BraintrustInvalidDataException`: Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. +- [`BraintrustInvalidDataException`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. -- `BraintrustException`: Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. +- [`BraintrustException`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. ## Pagination @@ -345,7 +345,7 @@ ProjectCreateParams params = ProjectCreateParams.builder() These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. You can also set undocumented parameters on nested headers, query params, or body classes using the `putAdditionalProperty` method. These properties can be accessed on the built object later using the `_additionalProperties()` method. -To set a documented parameter or property to an undocumented or not yet supported _value_, pass a `JsonValue` object to its setter: +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/JsonValue.kt) object to its setter: ```java import com.braintrustdata.api.core.JsonValue; @@ -414,7 +414,7 @@ if (name.isMissing()) { In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. -By default, the SDK will not throw an exception in this case. It will throw `BraintrustInvalidDataException` only if you directly access the property. +By default, the SDK will not throw an exception in this case. It will throw [`BraintrustInvalidDataException`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt) only if you directly access the property. If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: From 9dbc537a6271bc2bbd2839515f77eeb58951e4ab Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 26 Feb 2025 05:44:46 +0000 Subject: [PATCH 53/87] chore(internal): codegen related update (#123) --- .../braintrustdata/api/models/AclBatchUpdateParams.kt | 2 ++ .../com/braintrustdata/api/models/AiSecretListParams.kt | 2 ++ .../com/braintrustdata/api/models/ApiKeyListParams.kt | 2 ++ .../com/braintrustdata/api/models/DatasetListParams.kt | 2 ++ .../com/braintrustdata/api/models/EnvVarListParams.kt | 2 ++ .../braintrustdata/api/models/ExperimentListParams.kt | 2 ++ .../com/braintrustdata/api/models/FunctionListParams.kt | 2 ++ .../com/braintrustdata/api/models/GroupListParams.kt | 2 ++ .../braintrustdata/api/models/OrganizationListParams.kt | 2 ++ .../api/models/OrganizationMemberUpdateParams.kt | 2 ++ .../com/braintrustdata/api/models/ProjectListParams.kt | 2 ++ .../braintrustdata/api/models/ProjectScoreListParams.kt | 2 ++ .../braintrustdata/api/models/ProjectTagListParams.kt | 2 ++ .../com/braintrustdata/api/models/PromptListParams.kt | 2 ++ .../com/braintrustdata/api/models/RoleListParams.kt | 2 ++ .../braintrustdata/api/models/SpanIframeListParams.kt | 2 ++ .../api/models/TopLevelHelloWorldParams.kt | 2 ++ .../com/braintrustdata/api/models/UserListParams.kt | 2 ++ .../braintrustdata/api/services/async/AclServiceAsync.kt | 9 ++++++++- .../api/services/async/AiSecretServiceAsync.kt | 9 ++++++++- .../api/services/async/ApiKeyServiceAsync.kt | 9 ++++++++- .../api/services/async/DatasetServiceAsync.kt | 9 ++++++++- .../api/services/async/EnvVarServiceAsync.kt | 9 ++++++++- .../api/services/async/ExperimentServiceAsync.kt | 9 ++++++++- .../api/services/async/FunctionServiceAsync.kt | 9 ++++++++- .../api/services/async/GroupServiceAsync.kt | 9 ++++++++- .../api/services/async/OrganizationServiceAsync.kt | 9 ++++++++- .../api/services/async/ProjectScoreServiceAsync.kt | 9 ++++++++- .../api/services/async/ProjectServiceAsync.kt | 9 ++++++++- .../api/services/async/ProjectTagServiceAsync.kt | 9 ++++++++- .../api/services/async/PromptServiceAsync.kt | 9 ++++++++- .../api/services/async/RoleServiceAsync.kt | 9 ++++++++- .../api/services/async/SpanIframeServiceAsync.kt | 9 ++++++++- .../api/services/async/TopLevelServiceAsync.kt | 6 +++++- .../api/services/async/UserServiceAsync.kt | 9 ++++++++- .../services/async/organizations/MemberServiceAsync.kt | 6 +++++- .../braintrustdata/api/services/blocking/AclService.kt | 9 ++++++++- .../api/services/blocking/AiSecretService.kt | 9 ++++++++- .../api/services/blocking/ApiKeyService.kt | 9 ++++++++- .../api/services/blocking/DatasetService.kt | 9 ++++++++- .../api/services/blocking/EnvVarService.kt | 9 ++++++++- .../api/services/blocking/ExperimentService.kt | 9 ++++++++- .../api/services/blocking/FunctionService.kt | 9 ++++++++- .../braintrustdata/api/services/blocking/GroupService.kt | 9 ++++++++- .../api/services/blocking/OrganizationService.kt | 9 ++++++++- .../api/services/blocking/ProjectScoreService.kt | 9 ++++++++- .../api/services/blocking/ProjectService.kt | 9 ++++++++- .../api/services/blocking/ProjectTagService.kt | 9 ++++++++- .../api/services/blocking/PromptService.kt | 9 ++++++++- .../braintrustdata/api/services/blocking/RoleService.kt | 9 ++++++++- .../api/services/blocking/SpanIframeService.kt | 9 ++++++++- .../api/services/blocking/TopLevelService.kt | 6 +++++- .../braintrustdata/api/services/blocking/UserService.kt | 9 ++++++++- .../api/services/blocking/organizations/MemberService.kt | 6 +++++- .../api/services/blocking/AiSecretServiceTest.kt | 3 +-- .../api/services/blocking/ApiKeyServiceTest.kt | 3 +-- .../api/services/blocking/DatasetServiceTest.kt | 3 +-- .../api/services/blocking/ExperimentServiceTest.kt | 3 +-- .../api/services/blocking/FunctionServiceTest.kt | 3 +-- .../api/services/blocking/GroupServiceTest.kt | 3 +-- .../api/services/blocking/OrganizationServiceTest.kt | 3 +-- .../api/services/blocking/ProjectScoreServiceTest.kt | 3 +-- .../api/services/blocking/ProjectServiceTest.kt | 3 +-- .../api/services/blocking/ProjectTagServiceTest.kt | 3 +-- .../api/services/blocking/PromptServiceTest.kt | 3 +-- .../api/services/blocking/RoleServiceTest.kt | 3 +-- .../api/services/blocking/SpanIframeServiceTest.kt | 3 +-- .../api/services/blocking/TopLevelServiceTest.kt | 4 +--- .../api/services/blocking/UserServiceTest.kt | 3 +-- 69 files changed, 327 insertions(+), 67 deletions(-) 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 475d5dba..22101b89 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 @@ -376,6 +376,8 @@ private constructor( companion object { + fun none(): AclBatchUpdateParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index b1fee508..fdd514f5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -96,6 +96,8 @@ private constructor( companion object { + fun none(): AiSecretListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 649765d6..9afbee94 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -92,6 +92,8 @@ private constructor( companion object { + fun none(): ApiKeyListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 550f2cde..310111b8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -102,6 +102,8 @@ private constructor( companion object { + fun none(): DatasetListParams = builder().build() + @JvmStatic fun builder() = Builder() } 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 59351f94..2c34eb05 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 @@ -78,6 +78,8 @@ private constructor( companion object { + fun none(): EnvVarListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index d3d4277b..5c394751 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -102,6 +102,8 @@ private constructor( companion object { + fun none(): ExperimentListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index f458f679..883b5b84 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -117,6 +117,8 @@ private constructor( companion object { + fun none(): FunctionListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 68722b89..5e658ea6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -92,6 +92,8 @@ private constructor( companion object { + fun none(): GroupListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 9d8b7263..5a7758ee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -87,6 +87,8 @@ private constructor( companion object { + fun none(): OrganizationListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index a74bde98..c9da4259 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -307,6 +307,8 @@ private constructor( companion object { + fun none(): OrganizationMemberUpdateParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 2cd2c10a..896ea63d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -92,6 +92,8 @@ private constructor( companion object { + fun none(): ProjectListParams = builder().build() + @JvmStatic fun builder() = Builder() } 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 7b5f9f21..4dc4ce37 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 @@ -110,6 +110,8 @@ private constructor( companion object { + fun none(): ProjectScoreListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index ccc1e53e..4239c6da 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -102,6 +102,8 @@ private constructor( companion object { + fun none(): ProjectTagListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 0815efa1..d216166f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -117,6 +117,8 @@ private constructor( companion object { + fun none(): PromptListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 595fdd45..d6def3cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -92,6 +92,8 @@ private constructor( companion object { + fun none(): RoleListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 354d21c8..aa40aff0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -92,6 +92,8 @@ private constructor( companion object { + fun none(): SpanIframeListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 19f3a587..a327f402 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -27,6 +27,8 @@ private constructor( companion object { + fun none(): TopLevelHelloWorldParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 44263a33..e10ad737 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -111,6 +111,8 @@ private constructor( companion object { + fun none(): UserListParams = builder().build() + @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index ec49b677..dc199615 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -58,10 +58,17 @@ interface AclServiceAsync { */ @JvmOverloads fun batchUpdate( - params: AclBatchUpdateParams, + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * Batch update acls. This operation is idempotent, so adding acls which already exist will have + * no effect, and removing acls which do not exist will have no effect. + */ + fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) + /** Delete a single acl */ @JvmOverloads fun findAndDelete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt index 717c2c97..b95bfd1b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt @@ -52,10 +52,17 @@ interface AiSecretServiceAsync { */ @JvmOverloads fun list( - params: AiSecretListParams, + params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(AiSecretListParams.none(), requestOptions) + /** Delete an ai_secret object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index 073af6ef..397e0d30 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -39,10 +39,17 @@ interface ApiKeyServiceAsync { */ @JvmOverloads fun list( - params: ApiKeyListParams, + params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all api_keys. The api_keys are sorted by creation date, with the most + * recently-created api_keys coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ApiKeyListParams.none(), requestOptions) + /** Delete an api_key object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index b78df736..5be2b336 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -59,10 +59,17 @@ interface DatasetServiceAsync { */ @JvmOverloads fun list( - params: DatasetListParams, + params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all datasets. The datasets are sorted by creation date, with the most + * recently-created datasets coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(DatasetListParams.none(), requestOptions) + /** Delete a dataset object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt index 9e7a7f7f..04fbcd40 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt @@ -51,10 +51,17 @@ interface EnvVarServiceAsync { */ @JvmOverloads fun list( - params: EnvVarListParams, + params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all env_vars. The env_vars are sorted by creation date, with the most + * recently-created env_vars coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(EnvVarListParams.none(), requestOptions) + /** Delete an env_var object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index 888477e8..a5288a1f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -59,10 +59,17 @@ interface ExperimentServiceAsync { */ @JvmOverloads fun list( - params: ExperimentListParams, + params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ExperimentListParams.none(), requestOptions) + /** Delete an experiment object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index 0d80aef0..edc8770a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -54,10 +54,17 @@ interface FunctionServiceAsync { */ @JvmOverloads fun list( - params: FunctionListParams, + params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all functions. The functions are sorted by creation date, with the most + * recently-created functions coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(FunctionListParams.none(), requestOptions) + /** Delete a function object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index 442f6551..28f3e023 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -51,10 +51,17 @@ interface GroupServiceAsync { */ @JvmOverloads fun list( - params: GroupListParams, + params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(GroupListParams.none(), requestOptions) + /** Delete a group object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index e4598604..25556b38 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -42,10 +42,17 @@ interface OrganizationServiceAsync { */ @JvmOverloads fun list( - params: OrganizationListParams, + params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(OrganizationListParams.none(), requestOptions) + /** Delete an organization object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index 0909b50f..e4e69909 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -52,10 +52,17 @@ interface ProjectScoreServiceAsync { */ @JvmOverloads fun list( - params: ProjectScoreListParams, + params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ProjectScoreListParams.none(), requestOptions) + /** Delete a project_score object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index 8419d071..2e66d3cd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -53,10 +53,17 @@ interface ProjectServiceAsync { */ @JvmOverloads fun list( - params: ProjectListParams, + params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all projects. The projects are sorted by creation date, with the most + * recently-created projects coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ProjectListParams.none(), requestOptions) + /** Delete a project object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index f9b28282..dea1315f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -51,10 +51,17 @@ interface ProjectTagServiceAsync { */ @JvmOverloads fun list( - params: ProjectTagListParams, + params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ProjectTagListParams.none(), requestOptions) + /** Delete a project_tag object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index a293667f..89dd34e0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -51,10 +51,17 @@ interface PromptServiceAsync { */ @JvmOverloads fun list( - params: PromptListParams, + params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(PromptListParams.none(), requestOptions) + /** Delete a prompt object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index 9f8726d3..19a197a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -51,10 +51,17 @@ interface RoleServiceAsync { */ @JvmOverloads fun list( - params: RoleListParams, + params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all roles. The roles are sorted by creation date, with the most recently-created + * roles coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(RoleListParams.none(), requestOptions) + /** Delete a role object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt index ddf6b168..65c97e12 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt @@ -51,10 +51,17 @@ interface SpanIframeServiceAsync { */ @JvmOverloads fun list( - params: SpanIframeListParams, + params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(SpanIframeListParams.none(), requestOptions) + /** Delete a span_iframe object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index 10f2028b..aef9b83f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -13,7 +13,11 @@ interface TopLevelServiceAsync { /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ @JvmOverloads fun helloWorld( - params: TopLevelHelloWorldParams, + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + fun helloWorld(requestOptions: RequestOptions): CompletableFuture = + helloWorld(TopLevelHelloWorldParams.none(), requestOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index d20e9d77..d285bf3f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -26,7 +26,14 @@ interface UserServiceAsync { */ @JvmOverloads fun list( - params: UserListParams, + params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * List out all users. The users are sorted by creation date, with the most recently-created + * users coming first + */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(UserListParams.none(), requestOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt index 56d59671..74e603fc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -14,7 +14,11 @@ interface MemberServiceAsync { /** Modify organization membership */ @JvmOverloads fun update( - params: OrganizationMemberUpdateParams, + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** Modify organization membership */ + fun update(requestOptions: RequestOptions): CompletableFuture = + update(OrganizationMemberUpdateParams.none(), requestOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index a6d47676..be830936 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -51,10 +51,17 @@ interface AclService { */ @JvmOverloads fun batchUpdate( - params: AclBatchUpdateParams, + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AclBatchUpdateResponse + /** + * Batch update acls. This operation is idempotent, so adding acls which already exist will have + * no effect, and removing acls which do not exist will have no effect. + */ + fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) + /** Delete a single acl */ @JvmOverloads fun findAndDelete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt index b6e34664..a0baaa93 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt @@ -51,10 +51,17 @@ interface AiSecretService { */ @JvmOverloads fun list( - params: AiSecretListParams, + params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AiSecretListPage + /** + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first + */ + fun list(requestOptions: RequestOptions): AiSecretListPage = + list(AiSecretListParams.none(), requestOptions) + /** Delete an ai_secret object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index 8b53fbd7..ef5ee665 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -38,10 +38,17 @@ interface ApiKeyService { */ @JvmOverloads fun list( - params: ApiKeyListParams, + params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ApiKeyListPage + /** + * List out all api_keys. The api_keys are sorted by creation date, with the most + * recently-created api_keys coming first + */ + fun list(requestOptions: RequestOptions): ApiKeyListPage = + list(ApiKeyListParams.none(), requestOptions) + /** Delete an api_key object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 2d4a5dc9..f28dc44f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -58,10 +58,17 @@ interface DatasetService { */ @JvmOverloads fun list( - params: DatasetListParams, + params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): DatasetListPage + /** + * List out all datasets. The datasets are sorted by creation date, with the most + * recently-created datasets coming first + */ + fun list(requestOptions: RequestOptions): DatasetListPage = + list(DatasetListParams.none(), requestOptions) + /** Delete a dataset object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt index 108d0eb9..cb3ff44a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt @@ -50,10 +50,17 @@ interface EnvVarService { */ @JvmOverloads fun list( - params: EnvVarListParams, + params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): EnvVarListResponse + /** + * List out all env_vars. The env_vars are sorted by creation date, with the most + * recently-created env_vars coming first + */ + fun list(requestOptions: RequestOptions): EnvVarListResponse = + list(EnvVarListParams.none(), requestOptions) + /** Delete an env_var object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 371e2fd3..2aa9303c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -58,10 +58,17 @@ interface ExperimentService { */ @JvmOverloads fun list( - params: ExperimentListParams, + params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ExperimentListPage + /** + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first + */ + fun list(requestOptions: RequestOptions): ExperimentListPage = + list(ExperimentListParams.none(), requestOptions) + /** Delete an experiment object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 86a147a2..242b1dbb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -53,10 +53,17 @@ interface FunctionService { */ @JvmOverloads fun list( - params: FunctionListParams, + params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): FunctionListPage + /** + * List out all functions. The functions are sorted by creation date, with the most + * recently-created functions coming first + */ + fun list(requestOptions: RequestOptions): FunctionListPage = + list(FunctionListParams.none(), requestOptions) + /** Delete a function object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index 6a3a773a..057ce985 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -50,10 +50,17 @@ interface GroupService { */ @JvmOverloads fun list( - params: GroupListParams, + params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GroupListPage + /** + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first + */ + fun list(requestOptions: RequestOptions): GroupListPage = + list(GroupListParams.none(), requestOptions) + /** Delete a group object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index f3336cb0..8a31e382 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -41,10 +41,17 @@ interface OrganizationService { */ @JvmOverloads fun list( - params: OrganizationListParams, + params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): OrganizationListPage + /** + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first + */ + fun list(requestOptions: RequestOptions): OrganizationListPage = + list(OrganizationListParams.none(), requestOptions) + /** Delete an organization object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index 7eafe1f3..4ef23a62 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -51,10 +51,17 @@ interface ProjectScoreService { */ @JvmOverloads fun list( - params: ProjectScoreListParams, + params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScoreListPage + /** + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first + */ + fun list(requestOptions: RequestOptions): ProjectScoreListPage = + list(ProjectScoreListParams.none(), requestOptions) + /** Delete a project_score object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index 941dbcca..60f9bcfc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -52,10 +52,17 @@ interface ProjectService { */ @JvmOverloads fun list( - params: ProjectListParams, + params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ProjectListPage + /** + * List out all projects. The projects are sorted by creation date, with the most + * recently-created projects coming first + */ + fun list(requestOptions: RequestOptions): ProjectListPage = + list(ProjectListParams.none(), requestOptions) + /** Delete a project object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index c9ce87a7..c4a3174a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -50,10 +50,17 @@ interface ProjectTagService { */ @JvmOverloads fun list( - params: ProjectTagListParams, + params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTagListPage + /** + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first + */ + fun list(requestOptions: RequestOptions): ProjectTagListPage = + list(ProjectTagListParams.none(), requestOptions) + /** Delete a project_tag object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index e233aa64..0dde79aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -50,10 +50,17 @@ interface PromptService { */ @JvmOverloads fun list( - params: PromptListParams, + params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): PromptListPage + /** + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first + */ + fun list(requestOptions: RequestOptions): PromptListPage = + list(PromptListParams.none(), requestOptions) + /** Delete a prompt object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index 06c6aa37..33f3942d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -50,10 +50,17 @@ interface RoleService { */ @JvmOverloads fun list( - params: RoleListParams, + params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): RoleListPage + /** + * List out all roles. The roles are sorted by creation date, with the most recently-created + * roles coming first + */ + fun list(requestOptions: RequestOptions): RoleListPage = + list(RoleListParams.none(), requestOptions) + /** Delete a role object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt index 168b53bd..804df013 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt @@ -50,10 +50,17 @@ interface SpanIframeService { */ @JvmOverloads fun list( - params: SpanIframeListParams, + params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): SpanIframeListPage + /** + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first + */ + fun list(requestOptions: RequestOptions): SpanIframeListPage = + list(SpanIframeListParams.none(), requestOptions) + /** Delete a span_iframe object by its id */ @JvmOverloads fun delete( diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index f35bbbcb..aca20acc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -12,7 +12,11 @@ interface TopLevelService { /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ @JvmOverloads fun helloWorld( - params: TopLevelHelloWorldParams, + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): String + + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + fun helloWorld(requestOptions: RequestOptions): String = + helloWorld(TopLevelHelloWorldParams.none(), requestOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index 30abf630..5ca8da21 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -25,7 +25,14 @@ interface UserService { */ @JvmOverloads fun list( - params: UserListParams, + params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): UserListPage + + /** + * List out all users. The users are sorted by creation date, with the most recently-created + * users coming first + */ + fun list(requestOptions: RequestOptions): UserListPage = + list(UserListParams.none(), requestOptions) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt index 4cfb03db..84092a5d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -13,7 +13,11 @@ interface MemberService { /** Modify organization membership */ @JvmOverloads fun update( - params: OrganizationMemberUpdateParams, + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): PatchOrganizationMembersOutput + + /** Modify organization membership */ + fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = + update(OrganizationMemberUpdateParams.none(), requestOptions) } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt index 74538436..c6ec566c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams -import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams @@ -96,7 +95,7 @@ class AiSecretServiceTest { .apiKey("My API Key") .build() val aiSecretService = client.aiSecrets() - val response = aiSecretService.list(AiSecretListParams.builder().build()) + val response = aiSecretService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index 1beb9ba3..e07314de 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams -import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -56,7 +55,7 @@ class ApiKeyServiceTest { .apiKey("My API Key") .build() val apiKeyService = client.apiKeys() - val response = apiKeyService.list(ApiKeyListParams.builder().build()) + val response = apiKeyService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index d239ec07..bd230c40 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -11,7 +11,6 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams @@ -100,7 +99,7 @@ class DatasetServiceTest { .apiKey("My API Key") .build() val datasetService = client.datasets() - val response = datasetService.list(DatasetListParams.builder().build()) + val response = datasetService.list() println(response) response.objects().forEach { it.validate() } } 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 ff81c512..5376b17f 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 @@ -11,7 +11,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams @@ -137,7 +136,7 @@ class ExperimentServiceTest { .apiKey("My API Key") .build() val experimentService = client.experiments() - val response = experimentService.list(ExperimentListParams.builder().build()) + val response = experimentService.list() println(response) response.objects().forEach { it.validate() } } 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 69655b05..beb059e2 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 @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams -import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams @@ -265,7 +264,7 @@ class FunctionServiceTest { .apiKey("My API Key") .build() val functionService = client.functions() - val response = functionService.list(FunctionListParams.builder().build()) + val response = functionService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index b805c59d..1c3d4641 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams -import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams @@ -88,7 +87,7 @@ class GroupServiceTest { .apiKey("My API Key") .build() val groupService = client.groups() - val response = groupService.list(GroupListParams.builder().build()) + val response = groupService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt index 90284cdd..a1e497da 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt @@ -5,7 +5,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.OrganizationDeleteParams -import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import org.junit.jupiter.api.Test @@ -63,7 +62,7 @@ class OrganizationServiceTest { .apiKey("My API Key") .build() val organizationService = client.organizations() - val response = organizationService.list(OrganizationListParams.builder().build()) + val response = organizationService.list() println(response) response.objects().forEach { it.validate() } } 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 7eb898e2..6b8364db 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 @@ -9,7 +9,6 @@ import com.braintrustdata.api.models.ProjectScoreCategory import com.braintrustdata.api.models.ProjectScoreConfig import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams -import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams @@ -131,7 +130,7 @@ class ProjectScoreServiceTest { .apiKey("My API Key") .build() val projectScoreService = client.projectScores() - val response = projectScoreService.list(ProjectScoreListParams.builder().build()) + val response = projectScoreService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index dd8ab204..23068949 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams -import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectSettings import com.braintrustdata.api.models.ProjectUpdateParams @@ -78,7 +77,7 @@ class ProjectServiceTest { .apiKey("My API Key") .build() val projectService = client.projects() - val response = projectService.list(ProjectListParams.builder().build()) + val response = projectService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt index 5bd1c595..1661ab10 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams -import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams @@ -84,7 +83,7 @@ class ProjectTagServiceTest { .apiKey("My API Key") .build() val projectTagService = client.projectTags() - val response = projectTagService.list(ProjectTagListParams.builder().build()) + val response = projectTagService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 15a5ec99..bfcea055 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptDeleteParams -import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptOptions import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams @@ -242,7 +241,7 @@ class PromptServiceTest { .apiKey("My API Key") .build() val promptService = client.prompts() - val response = promptService.list(PromptListParams.builder().build()) + val response = promptService.list() println(response) response.objects().forEach { it.validate() } } 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 bd9e856f..b9b46ca6 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 @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams -import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams @@ -108,7 +107,7 @@ class RoleServiceTest { .apiKey("My API Key") .build() val roleService = client.roles() - val response = roleService.list(RoleListParams.builder().build()) + val response = roleService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index 9e914d1c..b384a524 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams -import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams @@ -85,7 +84,7 @@ class SpanIframeServiceTest { .apiKey("My API Key") .build() val spanIframeService = client.spanIframes() - val response = spanIframeService.list(SpanIframeListParams.builder().build()) + val response = spanIframeService.list() println(response) response.objects().forEach { it.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt index a8ae19a3..30085f63 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.TopLevelHelloWorldParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,8 +19,7 @@ class TopLevelServiceTest { .apiKey("My API Key") .build() val topLevelService = client.topLevel() - val topLevelHelloWorldResponse = - topLevelService.helloWorld(TopLevelHelloWorldParams.builder().build()) + val topLevelHelloWorldResponse = topLevelService.helloWorld() println(topLevelHelloWorldResponse) assertThat(topLevelHelloWorldResponse).isNotBlank() } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index 31fcd52f..c1173eec 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -36,7 +35,7 @@ class UserServiceTest { .apiKey("My API Key") .build() val userService = client.users() - val response = userService.list(UserListParams.builder().build()) + val response = userService.list() println(response) response.objects().forEach { it.validate() } } From c4e0b8ad6755613242bcc135c36dd7538adb8c99 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 26 Feb 2025 05:55:14 +0000 Subject: [PATCH 54/87] fix(client): add missing `@JvmStatic` (#124) --- .../com/braintrustdata/api/models/AclBatchUpdateParams.kt | 2 +- .../kotlin/com/braintrustdata/api/models/AiSecretListParams.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt | 2 +- .../kotlin/com/braintrustdata/api/models/DatasetListParams.kt | 2 +- .../kotlin/com/braintrustdata/api/models/EnvVarListParams.kt | 2 +- .../com/braintrustdata/api/models/ExperimentListParams.kt | 2 +- .../kotlin/com/braintrustdata/api/models/FunctionListParams.kt | 2 +- .../kotlin/com/braintrustdata/api/models/GroupListParams.kt | 2 +- .../com/braintrustdata/api/models/OrganizationListParams.kt | 2 +- .../braintrustdata/api/models/OrganizationMemberUpdateParams.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ProjectListParams.kt | 2 +- .../com/braintrustdata/api/models/ProjectScoreListParams.kt | 2 +- .../com/braintrustdata/api/models/ProjectTagListParams.kt | 2 +- .../kotlin/com/braintrustdata/api/models/PromptListParams.kt | 2 +- .../main/kotlin/com/braintrustdata/api/models/RoleListParams.kt | 2 +- .../com/braintrustdata/api/models/SpanIframeListParams.kt | 2 +- .../com/braintrustdata/api/models/TopLevelHelloWorldParams.kt | 2 +- .../main/kotlin/com/braintrustdata/api/models/UserListParams.kt | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) 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 22101b89..e244101b 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 @@ -376,7 +376,7 @@ private constructor( companion object { - fun none(): AclBatchUpdateParams = builder().build() + @JvmStatic fun none(): AclBatchUpdateParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index fdd514f5..d13575ca 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -96,7 +96,7 @@ private constructor( companion object { - fun none(): AiSecretListParams = builder().build() + @JvmStatic fun none(): AiSecretListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 9afbee94..57f6f008 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -92,7 +92,7 @@ private constructor( companion object { - fun none(): ApiKeyListParams = builder().build() + @JvmStatic fun none(): ApiKeyListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 310111b8..8ca6cb67 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -102,7 +102,7 @@ private constructor( companion object { - fun none(): DatasetListParams = builder().build() + @JvmStatic fun none(): DatasetListParams = builder().build() @JvmStatic fun builder() = Builder() } 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 2c34eb05..f8bd3d69 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 @@ -78,7 +78,7 @@ private constructor( companion object { - fun none(): EnvVarListParams = builder().build() + @JvmStatic fun none(): EnvVarListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 5c394751..45ff6349 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -102,7 +102,7 @@ private constructor( companion object { - fun none(): ExperimentListParams = builder().build() + @JvmStatic fun none(): ExperimentListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 883b5b84..4eeb55b7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -117,7 +117,7 @@ private constructor( companion object { - fun none(): FunctionListParams = builder().build() + @JvmStatic fun none(): FunctionListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 5e658ea6..f3fc3721 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -92,7 +92,7 @@ private constructor( companion object { - fun none(): GroupListParams = builder().build() + @JvmStatic fun none(): GroupListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 5a7758ee..a132ae03 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -87,7 +87,7 @@ private constructor( companion object { - fun none(): OrganizationListParams = builder().build() + @JvmStatic fun none(): OrganizationListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index c9da4259..81801169 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -307,7 +307,7 @@ private constructor( companion object { - fun none(): OrganizationMemberUpdateParams = builder().build() + @JvmStatic fun none(): OrganizationMemberUpdateParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 896ea63d..f6c51805 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -92,7 +92,7 @@ private constructor( companion object { - fun none(): ProjectListParams = builder().build() + @JvmStatic fun none(): ProjectListParams = builder().build() @JvmStatic fun builder() = Builder() } 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 4dc4ce37..aa8094fe 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 @@ -110,7 +110,7 @@ private constructor( companion object { - fun none(): ProjectScoreListParams = builder().build() + @JvmStatic fun none(): ProjectScoreListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 4239c6da..8799826c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -102,7 +102,7 @@ private constructor( companion object { - fun none(): ProjectTagListParams = builder().build() + @JvmStatic fun none(): ProjectTagListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index d216166f..fc81d66a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -117,7 +117,7 @@ private constructor( companion object { - fun none(): PromptListParams = builder().build() + @JvmStatic fun none(): PromptListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index d6def3cb..b83f7508 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -92,7 +92,7 @@ private constructor( companion object { - fun none(): RoleListParams = builder().build() + @JvmStatic fun none(): RoleListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index aa40aff0..45d595ae 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -92,7 +92,7 @@ private constructor( companion object { - fun none(): SpanIframeListParams = builder().build() + @JvmStatic fun none(): SpanIframeListParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index a327f402..494454d9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -27,7 +27,7 @@ private constructor( companion object { - fun none(): TopLevelHelloWorldParams = builder().build() + @JvmStatic fun none(): TopLevelHelloWorldParams = builder().build() @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index e10ad737..cf9d9627 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -111,7 +111,7 @@ private constructor( companion object { - fun none(): UserListParams = builder().build() + @JvmStatic fun none(): UserListParams = builder().build() @JvmStatic fun builder() = Builder() } From 5dc06c8acd281951e841146b1b16803f017c9948 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 27 Feb 2025 06:33:19 +0000 Subject: [PATCH 55/87] chore(internal): add async service tests (#125) chore(internal): improve sync service tests docs: readme parameter tweaks --- .../api/services/async/AclServiceAsyncTest.kt | 172 +++++++ .../async/AiSecretServiceAsyncTest.kt | 176 +++++++ .../services/async/ApiKeyServiceAsyncTest.kt | 88 ++++ .../services/async/DatasetServiceAsyncTest.kt | 278 ++++++++++ .../services/async/EnvVarServiceAsyncTest.kt | 150 ++++++ .../services/async/EvalServiceAsyncTest.kt | 80 +++ .../async/ExperimentServiceAsyncTest.kt | 355 +++++++++++++ .../async/FunctionServiceAsyncTest.kt | 474 ++++++++++++++++++ .../services/async/GroupServiceAsyncTest.kt | 144 ++++++ .../async/OrganizationServiceAsyncTest.kt | 95 ++++ .../async/ProjectScoreServiceAsyncTest.kt | 210 ++++++++ .../services/async/ProjectServiceAsyncTest.kt | 112 +++++ .../async/ProjectTagServiceAsyncTest.kt | 141 ++++++ .../services/async/PromptServiceAsyncTest.kt | 377 ++++++++++++++ .../services/async/RoleServiceAsyncTest.kt | 171 +++++++ .../async/SpanIframeServiceAsyncTest.kt | 143 ++++++ .../async/TopLevelServiceAsyncTest.kt | 26 + .../services/async/UserServiceAsyncTest.kt | 46 ++ .../services/async/ViewServiceAsyncTest.kt | 244 +++++++++ .../organizations/MemberServiceAsyncTest.kt | 51 ++ .../async/projects/LogServiceAsyncTest.kt | 182 +++++++ .../api/services/blocking/AclServiceTest.kt | 34 +- .../services/blocking/AiSecretServiceTest.kt | 39 +- .../services/blocking/ApiKeyServiceTest.kt | 24 +- .../services/blocking/DatasetServiceTest.kt | 54 +- .../services/blocking/EnvVarServiceTest.kt | 34 +- .../api/services/blocking/EvalServiceTest.kt | 5 +- .../blocking/ExperimentServiceTest.kt | 54 +- .../services/blocking/FunctionServiceTest.kt | 46 +- .../api/services/blocking/GroupServiceTest.kt | 34 +- .../blocking/OrganizationServiceTest.kt | 24 +- .../blocking/ProjectScoreServiceTest.kt | 34 +- .../services/blocking/ProjectServiceTest.kt | 29 +- .../blocking/ProjectTagServiceTest.kt | 34 +- .../services/blocking/PromptServiceTest.kt | 34 +- .../api/services/blocking/RoleServiceTest.kt | 34 +- .../blocking/SpanIframeServiceTest.kt | 34 +- .../services/blocking/TopLevelServiceTest.kt | 8 +- .../api/services/blocking/UserServiceTest.kt | 14 +- .../api/services/blocking/ViewServiceTest.kt | 34 +- .../organizations/MemberServiceTest.kt | 5 +- .../blocking/projects/LogServiceTest.kt | 20 +- 42 files changed, 4085 insertions(+), 258 deletions(-) create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt 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 new file mode 100644 index 00000000..5df9416c --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncTest.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.AclBatchUpdateParams +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.AclRetrieveParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class AclServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = + aclServiceAsync.create( + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val acl = aclFuture.get() + acl.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = + aclServiceAsync.retrieve( + AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val acl = aclFuture.get() + acl.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val pageFuture = + aclServiceAsync.list( + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build() + ) + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = + aclServiceAsync.delete( + AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val acl = aclFuture.get() + acl.validate() + } + + @Test + fun batchUpdate() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclBatchUpdateResponseFuture = + aclServiceAsync.batchUpdate( + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() + aclBatchUpdateResponse.validate() + } + + @Test + fun findAndDelete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = + aclServiceAsync.findAndDelete( + AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val acl = aclFuture.get() + acl.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt new file mode 100644 index 00000000..cc5d3c0a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +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.AiSecretCreateParams +import com.braintrustdata.api.models.AiSecretDeleteParams +import com.braintrustdata.api.models.AiSecretFindAndDeleteParams +import com.braintrustdata.api.models.AiSecretReplaceParams +import com.braintrustdata.api.models.AiSecretRetrieveParams +import com.braintrustdata.api.models.AiSecretUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class AiSecretServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.create( + AiSecretCreateParams.builder() + .name("name") + .metadata( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.retrieve( + AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.update( + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .secret("secret") + .type("type") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val pageFuture = aiSecretServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.delete( + AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() + } + + @Test + fun findAndDelete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.findAndDelete( + AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.replace( + AiSecretReplaceParams.builder() + .name("name") + .metadata( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt new file mode 100644 index 00000000..f7d5a9ac --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.ApiKeyCreateParams +import com.braintrustdata.api.models.ApiKeyDeleteParams +import com.braintrustdata.api.models.ApiKeyRetrieveParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ApiKeyServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() + + val createApiKeyOutputFuture = + apiKeyServiceAsync.create( + ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + ) + + val createApiKeyOutput = createApiKeyOutputFuture.get() + createApiKeyOutput.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() + + val apiKeyFuture = + apiKeyServiceAsync.retrieve( + ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val apiKey = apiKeyFuture.get() + apiKey.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() + + val pageFuture = apiKeyServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() + + val apiKeyFuture = + apiKeyServiceAsync.delete( + ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val apiKey = apiKeyFuture.get() + apiKey.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt new file mode 100644 index 00000000..4e6b2e1f --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt @@ -0,0 +1,278 @@ +// File generated from our OpenAPI spec by Stainless. + +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.DatasetCreateParams +import com.braintrustdata.api.models.DatasetDeleteParams +import com.braintrustdata.api.models.DatasetFeedbackParams +import com.braintrustdata.api.models.DatasetFetchParams +import com.braintrustdata.api.models.DatasetFetchPostParams +import com.braintrustdata.api.models.DatasetInsertParams +import com.braintrustdata.api.models.DatasetRetrieveParams +import com.braintrustdata.api.models.DatasetSummarizeParams +import com.braintrustdata.api.models.DatasetUpdateParams +import com.braintrustdata.api.models.FeedbackDatasetItem +import com.braintrustdata.api.models.InsertDatasetEvent +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class DatasetServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = + datasetServiceAsync.create( + DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = + datasetServiceAsync.retrieve( + DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = + datasetServiceAsync.update( + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val pageFuture = datasetServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = + datasetServiceAsync.delete( + DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() + } + + @Test + fun feedback() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val feedbackResponseSchemaFuture = + datasetServiceAsync.feedback( + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() + } + + @Test + fun fetch() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val fetchDatasetEventsResponseFuture = + datasetServiceAsync.fetch( + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() + fetchDatasetEventsResponse.validate() + } + + @Test + fun fetchPost() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val fetchDatasetEventsResponseFuture = + datasetServiceAsync.fetchPost( + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() + fetchDatasetEventsResponse.validate() + } + + @Test + fun insert() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val insertEventsResponseFuture = + datasetServiceAsync.insert( + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() + } + + @Test + fun summarize() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val summarizeDatasetResponseFuture = + datasetServiceAsync.summarize( + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() + ) + + val summarizeDatasetResponse = summarizeDatasetResponseFuture.get() + summarizeDatasetResponse.validate() + } +} 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 new file mode 100644 index 00000000..b64fa2df --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +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.EnvVarReplaceParams +import com.braintrustdata.api.models.EnvVarRetrieveParams +import com.braintrustdata.api.models.EnvVarUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class EnvVarServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.create( + EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.retrieve( + EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.update( + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.list( + EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.delete( + EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.replace( + EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt new file mode 100644 index 00000000..406d7f7b --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +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.EvalCreateParams +import com.braintrustdata.api.models.RepoInfo +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class EvalServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val evalServiceAsync = client.evals() + + val summarizeExperimentResponseFuture = + evalServiceAsync.create( + EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .projectId("project_id") + .addScore( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .task( + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build() + ) + .isPublic(true) + .maxConcurrency(0.0) + .metadata( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() + ) + + val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() + summarizeExperimentResponse.validate() + } +} 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 new file mode 100644 index 00000000..e4ab67f2 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncTest.kt @@ -0,0 +1,355 @@ +// File generated from our OpenAPI spec by Stainless. + +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.ExperimentCreateParams +import com.braintrustdata.api.models.ExperimentDeleteParams +import com.braintrustdata.api.models.ExperimentFeedbackParams +import com.braintrustdata.api.models.ExperimentFetchParams +import com.braintrustdata.api.models.ExperimentFetchPostParams +import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentRetrieveParams +import com.braintrustdata.api.models.ExperimentSummarizeParams +import com.braintrustdata.api.models.ExperimentUpdateParams +import com.braintrustdata.api.models.FeedbackExperimentItem +import com.braintrustdata.api.models.InsertExperimentEvent +import com.braintrustdata.api.models.RepoInfo +import com.braintrustdata.api.models.SpanAttributes +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ExperimentServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = + experimentServiceAsync.create( + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("x") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + ) + + val experiment = experimentFuture.get() + experiment.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = + experimentServiceAsync.retrieve( + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val experiment = experimentFuture.get() + experiment.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = + experimentServiceAsync.update( + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + ) + + val experiment = experimentFuture.get() + experiment.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val pageFuture = experimentServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = + experimentServiceAsync.delete( + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val experiment = experimentFuture.get() + experiment.validate() + } + + @Test + fun feedback() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val feedbackResponseSchemaFuture = + experimentServiceAsync.feedback( + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() + } + + @Test + fun fetch() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val fetchExperimentEventsResponseFuture = + experimentServiceAsync.fetch( + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() + fetchExperimentEventsResponse.validate() + } + + @Test + fun fetchPost() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val fetchExperimentEventsResponseFuture = + experimentServiceAsync.fetchPost( + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() + fetchExperimentEventsResponse.validate() + } + + @Test + fun insert() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val insertEventsResponseFuture = + experimentServiceAsync.insert( + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() + } + + @Test + fun summarize() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val summarizeExperimentResponseFuture = + experimentServiceAsync.summarize( + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() + ) + + val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() + summarizeExperimentResponse.validate() + } +} 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 new file mode 100644 index 00000000..58578b30 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncTest.kt @@ -0,0 +1,474 @@ +// File generated from our OpenAPI spec by Stainless. + +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.FunctionCreateParams +import com.braintrustdata.api.models.FunctionDeleteParams +import com.braintrustdata.api.models.FunctionInvokeParams +import com.braintrustdata.api.models.FunctionReplaceParams +import com.braintrustdata.api.models.FunctionRetrieveParams +import com.braintrustdata.api.models.FunctionUpdateParams +import com.braintrustdata.api.models.PromptData +import com.braintrustdata.api.models.PromptOptions +import kotlin.jvm.optionals.getOrNull +import kotlin.test.assertNotNull +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class FunctionServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() + + val functionFuture = + functionServiceAsync.create( + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin( + FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + val function = functionFuture.get() + function.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() + + val functionFuture = + functionServiceAsync.retrieve( + FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val function = functionFuture.get() + function.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() + + val functionFuture = + functionServiceAsync.update( + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + val function = functionFuture.get() + function.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() + + val pageFuture = functionServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() + + val functionFuture = + functionServiceAsync.delete( + FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val function = functionFuture.get() + function.validate() + } + + @Test + fun invoke() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() + + val responseFuture = + functionServiceAsync.invoke( + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent( + FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + .stream(true) + .version("version") + .build() + ) + + val response = responseFuture.get() + val unwrappedResponse = response.getOrNull() + assertNotNull(unwrappedResponse) + unwrappedResponse.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() + + val functionFuture = + functionServiceAsync.replace( + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin( + FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + val function = functionFuture.get() + function.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt new file mode 100644 index 00000000..314e7023 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.GroupCreateParams +import com.braintrustdata.api.models.GroupDeleteParams +import com.braintrustdata.api.models.GroupReplaceParams +import com.braintrustdata.api.models.GroupRetrieveParams +import com.braintrustdata.api.models.GroupUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class GroupServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.create( + GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + val group = groupFuture.get() + group.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.retrieve( + GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val group = groupFuture.get() + group.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.update( + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val group = groupFuture.get() + group.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val pageFuture = groupServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.delete( + GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val group = groupFuture.get() + group.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.replace( + GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + val group = groupFuture.get() + group.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt new file mode 100644 index 00000000..b89247bd --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.OrganizationDeleteParams +import com.braintrustdata.api.models.OrganizationRetrieveParams +import com.braintrustdata.api.models.OrganizationUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class OrganizationServiceAsyncTest { + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() + + val organizationFuture = + organizationServiceAsync.retrieve( + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val organization = organizationFuture.get() + organization.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() + + val organizationFuture = + organizationServiceAsync.update( + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + ) + + val organization = organizationFuture.get() + organization.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() + + val pageFuture = organizationServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() + + val organizationFuture = + organizationServiceAsync.delete( + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val organization = organizationFuture.get() + organization.validate() + } +} 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 new file mode 100644 index 00000000..efa55642 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncTest.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.OnlineScoreConfig +import com.braintrustdata.api.models.ProjectScoreCategory +import com.braintrustdata.api.models.ProjectScoreConfig +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.ProjectScoreUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ProjectScoreServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.create( + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.retrieve( + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.update( + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val pageFuture = projectScoreServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.delete( + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.replace( + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt new file mode 100644 index 00000000..85f07a6a --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.ProjectCreateParams +import com.braintrustdata.api.models.ProjectDeleteParams +import com.braintrustdata.api.models.ProjectRetrieveParams +import com.braintrustdata.api.models.ProjectSettings +import com.braintrustdata.api.models.ProjectUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ProjectServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + + val project = projectFuture.get() + project.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.retrieve( + ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val project = projectFuture.get() + project.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.update( + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .build() + ) + + val project = projectFuture.get() + project.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val pageFuture = projectServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.delete( + ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val project = projectFuture.get() + project.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt new file mode 100644 index 00000000..8105ac95 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.ProjectTagCreateParams +import com.braintrustdata.api.models.ProjectTagDeleteParams +import com.braintrustdata.api.models.ProjectTagReplaceParams +import com.braintrustdata.api.models.ProjectTagRetrieveParams +import com.braintrustdata.api.models.ProjectTagUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ProjectTagServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.create( + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.retrieve( + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.update( + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val pageFuture = projectTagServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.delete( + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.replace( + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt new file mode 100644 index 00000000..2535012d --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt @@ -0,0 +1,377 @@ +// File generated from our OpenAPI spec by Stainless. + +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.PromptCreateParams +import com.braintrustdata.api.models.PromptData +import com.braintrustdata.api.models.PromptDeleteParams +import com.braintrustdata.api.models.PromptOptions +import com.braintrustdata.api.models.PromptReplaceParams +import com.braintrustdata.api.models.PromptRetrieveParams +import com.braintrustdata.api.models.PromptUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class PromptServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.create( + PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.retrieve( + PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.update( + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .slug("slug") + .addTag("string") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val pageFuture = promptServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.delete( + PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.replace( + PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() + } +} 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 new file mode 100644 index 00000000..140fdec7 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncTest.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.RoleCreateParams +import com.braintrustdata.api.models.RoleDeleteParams +import com.braintrustdata.api.models.RoleReplaceParams +import com.braintrustdata.api.models.RoleRetrieveParams +import com.braintrustdata.api.models.RoleUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class RoleServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.create( + RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + val role = roleFuture.get() + role.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.retrieve( + RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val role = roleFuture.get() + role.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.update( + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() + ) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val role = roleFuture.get() + role.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val pageFuture = roleServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.delete( + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val role = roleFuture.get() + role.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.replace( + RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + val role = roleFuture.get() + role.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt new file mode 100644 index 00000000..8d448a50 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.SpanIframeCreateParams +import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeReplaceParams +import com.braintrustdata.api.models.SpanIframeRetrieveParams +import com.braintrustdata.api.models.SpanIframeUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class SpanIframeServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.create( + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.retrieve( + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.update( + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val pageFuture = spanIframeServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.delete( + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.replace( + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt new file mode 100644 index 00000000..dee09b2e --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class TopLevelServiceAsyncTest { + + @Test + fun helloWorld() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val topLevelServiceAsync = client.topLevel() + + val responseFuture = topLevelServiceAsync.helloWorld() + + val response = responseFuture.get() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt new file mode 100644 index 00000000..38f452e7 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.UserRetrieveParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class UserServiceAsyncTest { + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userServiceAsync = client.users() + + val userFuture = + userServiceAsync.retrieve( + UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val user = userFuture.get() + user.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userServiceAsync = client.users() + + val pageFuture = userServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } +} 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 new file mode 100644 index 00000000..8a7b3bfb --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncTest.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +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.ViewCreateParams +import com.braintrustdata.api.models.ViewData +import com.braintrustdata.api.models.ViewDataSearch +import com.braintrustdata.api.models.ViewDeleteParams +import com.braintrustdata.api.models.ViewListParams +import com.braintrustdata.api.models.ViewOptions +import com.braintrustdata.api.models.ViewReplaceParams +import com.braintrustdata.api.models.ViewRetrieveParams +import com.braintrustdata.api.models.ViewUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ViewServiceAsyncTest { + + @Test + fun create() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.create( + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + + val view = viewFuture.get() + view.validate() + } + + @Test + fun retrieve() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.retrieve( + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + ) + + val view = viewFuture.get() + view.validate() + } + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.update( + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() + ) + + val view = viewFuture.get() + view.validate() + } + + @Test + fun list() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val pageFuture = + viewServiceAsync.list( + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build() + ) + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun delete() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.delete( + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + ) + + val view = viewFuture.get() + view.validate() + } + + @Test + fun replace() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.replace( + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + + val view = viewFuture.get() + view.validate() + } +} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt new file mode 100644 index 00000000..12efbd59 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async.organizations + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.OrganizationMemberUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class MemberServiceAsyncTest { + + @Test + fun update() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberServiceAsync = client.organizations().members() + + val patchOrganizationMembersOutputFuture = + memberServiceAsync.update( + OrganizationMemberUpdateParams.builder() + .inviteUsers( + OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + val patchOrganizationMembersOutput = patchOrganizationMembersOutputFuture.get() + patchOrganizationMembersOutput.validate() + } +} 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 new file mode 100644 index 00000000..fec1f6b8 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncTest.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.services.async.projects + +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FeedbackProjectLogsItem +import com.braintrustdata.api.models.InsertProjectLogsEvent +import com.braintrustdata.api.models.ProjectLogFeedbackParams +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 java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class LogServiceAsyncTest { + + @Test + fun feedback() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() + + val feedbackResponseSchemaFuture = + logServiceAsync.feedback( + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() + } + + @Test + fun fetch() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() + + val fetchProjectLogsEventsResponseFuture = + logServiceAsync.fetch( + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() + fetchProjectLogsEventsResponse.validate() + } + + @Test + fun fetchPost() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() + + val fetchProjectLogsEventsResponseFuture = + logServiceAsync.fetchPost( + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() + fetchProjectLogsEventsResponse.validate() + } + + @Test + fun insert() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() + + val insertEventsResponseFuture = + logServiceAsync.insert( + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() + } +} 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 3248c0c1..499ca976 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 @@ -17,13 +17,14 @@ import org.junit.jupiter.api.extension.ExtendWith class AclServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aclService = client.acls() + val acl = aclService.create( AclCreateParams.builder() @@ -36,69 +37,73 @@ class AclServiceTest { .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(acl) + acl.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aclService = client.acls() + val acl = aclService.retrieve( AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) - println(acl) + acl.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aclService = client.acls() - val response = + + val page = aclService.list( AclListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclListParams.ObjectType.ORGANIZATION) .build() ) - println(response) - response.objects().forEach { it.validate() } + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aclService = client.acls() + val acl = aclService.delete( AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) - println(acl) + acl.validate() } @Test - fun callBatchUpdate() { + fun batchUpdate() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aclService = client.acls() + val aclBatchUpdateResponse = aclService.batchUpdate( AclBatchUpdateParams.builder() @@ -130,18 +135,19 @@ class AclServiceTest { ) .build() ) - println(aclBatchUpdateResponse) + aclBatchUpdateResponse.validate() } @Test - fun callFindAndDelete() { + fun findAndDelete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aclService = client.acls() + val acl = aclService.findAndDelete( AclFindAndDeleteParams.builder() @@ -154,7 +160,7 @@ class AclServiceTest { .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(acl) + acl.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt index c6ec566c..6da192a1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt @@ -18,13 +18,14 @@ import org.junit.jupiter.api.extension.ExtendWith class AiSecretServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aiSecretService = client.aiSecrets() + val aISecret = aiSecretService.create( AiSecretCreateParams.builder() @@ -39,36 +40,38 @@ class AiSecretServiceTest { .type("type") .build() ) - println(aISecret) + aISecret.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aiSecretService = client.aiSecrets() + val aISecret = aiSecretService.retrieve( AiSecretRetrieveParams.builder() .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(aISecret) + aISecret.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aiSecretService = client.aiSecrets() + val aISecret = aiSecretService.update( AiSecretUpdateParams.builder() @@ -83,65 +86,69 @@ class AiSecretServiceTest { .type("type") .build() ) - println(aISecret) + aISecret.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aiSecretService = client.aiSecrets() - val response = aiSecretService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = aiSecretService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aiSecretService = client.aiSecrets() + val aISecret = aiSecretService.delete( AiSecretDeleteParams.builder() .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(aISecret) + aISecret.validate() } @Test - fun callFindAndDelete() { + fun findAndDelete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aiSecretService = client.aiSecrets() + val aISecret = aiSecretService.findAndDelete( AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() ) - println(aISecret) + aISecret.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val aiSecretService = client.aiSecrets() + val aISecret = aiSecretService.replace( AiSecretReplaceParams.builder() @@ -156,7 +163,7 @@ class AiSecretServiceTest { .type("type") .build() ) - println(aISecret) + aISecret.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index e07314de..46eefb44 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -14,67 +14,71 @@ import org.junit.jupiter.api.extension.ExtendWith class ApiKeyServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val apiKeyService = client.apiKeys() + val createApiKeyOutput = apiKeyService.create( ApiKeyCreateParams.builder().name("name").orgName("org_name").build() ) - println(createApiKeyOutput) + createApiKeyOutput.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val apiKeyService = client.apiKeys() + val apiKey = apiKeyService.retrieve( ApiKeyRetrieveParams.builder() .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(apiKey) + apiKey.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val apiKeyService = client.apiKeys() - val response = apiKeyService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = apiKeyService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val apiKeyService = client.apiKeys() + val apiKey = apiKeyService.delete( ApiKeyDeleteParams.builder() .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(apiKey) + apiKey.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index bd230c40..a9bae5c4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -24,13 +24,14 @@ import org.junit.jupiter.api.extension.ExtendWith class DatasetServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val dataset = datasetService.create( DatasetCreateParams.builder() @@ -44,36 +45,38 @@ class DatasetServiceTest { ) .build() ) - println(dataset) + dataset.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val dataset = datasetService.retrieve( DatasetRetrieveParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(dataset) + dataset.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val dataset = datasetService.update( DatasetUpdateParams.builder() @@ -87,49 +90,52 @@ class DatasetServiceTest { .name("name") .build() ) - println(dataset) + dataset.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() - val response = datasetService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = datasetService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val dataset = datasetService.delete( DatasetDeleteParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(dataset) + dataset.validate() } @Test - fun callFeedback() { + fun feedback() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val feedbackResponseSchema = datasetService.feedback( DatasetFeedbackParams.builder() @@ -149,18 +155,19 @@ class DatasetServiceTest { ) .build() ) - println(feedbackResponseSchema) + feedbackResponseSchema.validate() } @Test - fun callFetch() { + fun fetch() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val fetchDatasetEventsResponse = datasetService.fetch( DatasetFetchParams.builder() @@ -171,18 +178,19 @@ class DatasetServiceTest { .version("version") .build() ) - println(fetchDatasetEventsResponse) + fetchDatasetEventsResponse.validate() } @Test - fun callFetchPost() { + fun fetchPost() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val fetchDatasetEventsResponse = datasetService.fetchPost( DatasetFetchPostParams.builder() @@ -194,18 +202,19 @@ class DatasetServiceTest { .version("version") .build() ) - println(fetchDatasetEventsResponse) + fetchDatasetEventsResponse.validate() } @Test - fun callInsert() { + fun insert() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val insertEventsResponse = datasetService.insert( DatasetInsertParams.builder() @@ -233,18 +242,19 @@ class DatasetServiceTest { ) .build() ) - println(insertEventsResponse) + insertEventsResponse.validate() } @Test - fun callSummarize() { + fun summarize() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val datasetService = client.datasets() + val summarizeDatasetResponse = datasetService.summarize( DatasetSummarizeParams.builder() @@ -252,7 +262,7 @@ class DatasetServiceTest { .summarizeData(true) .build() ) - println(summarizeDatasetResponse) + summarizeDatasetResponse.validate() } } 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 8d435c90..94340681 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 @@ -17,13 +17,14 @@ import org.junit.jupiter.api.extension.ExtendWith class EnvVarServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val envVarService = client.envVars() + val envVar = envVarService.create( EnvVarCreateParams.builder() @@ -33,36 +34,38 @@ class EnvVarServiceTest { .value("value") .build() ) - println(envVar) + envVar.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val envVarService = client.envVars() + val envVar = envVarService.retrieve( EnvVarRetrieveParams.builder() .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(envVar) + envVar.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val envVarService = client.envVars() + val envVar = envVarService.update( EnvVarUpdateParams.builder() @@ -71,19 +74,20 @@ class EnvVarServiceTest { .value("value") .build() ) - println(envVar) + envVar.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val envVarService = client.envVars() - val envVarListResponse = + + val envVar = envVarService.list( EnvVarListParams.builder() .envVarName("env_var_name") @@ -93,36 +97,38 @@ class EnvVarServiceTest { .objectType(EnvVarListParams.ObjectType.ORGANIZATION) .build() ) - println(envVarListResponse) - envVarListResponse.validate() + + envVar.validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val envVarService = client.envVars() + val envVar = envVarService.delete( EnvVarDeleteParams.builder() .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(envVar) + envVar.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val envVarService = client.envVars() + val envVar = envVarService.replace( EnvVarReplaceParams.builder() @@ -132,7 +138,7 @@ class EnvVarServiceTest { .value("value") .build() ) - println(envVar) + envVar.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index 0b5e8eae..feaa3f95 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -14,13 +14,14 @@ import org.junit.jupiter.api.extension.ExtendWith class EvalServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val evalService = client.evals() + val summarizeExperimentResponse = evalService.create( EvalCreateParams.builder() @@ -72,7 +73,7 @@ class EvalServiceTest { .trialCount(0.0) .build() ) - println(summarizeExperimentResponse) + summarizeExperimentResponse.validate() } } 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 5376b17f..b4e00567 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 @@ -26,13 +26,14 @@ import org.junit.jupiter.api.extension.ExtendWith class ExperimentServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val experiment = experimentService.create( ExperimentCreateParams.builder() @@ -64,36 +65,38 @@ class ExperimentServiceTest { ) .build() ) - println(experiment) + experiment.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val experiment = experimentService.retrieve( ExperimentRetrieveParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(experiment) + experiment.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val experiment = experimentService.update( ExperimentUpdateParams.builder() @@ -124,49 +127,52 @@ class ExperimentServiceTest { ) .build() ) - println(experiment) + experiment.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() - val response = experimentService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = experimentService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val experiment = experimentService.delete( ExperimentDeleteParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(experiment) + experiment.validate() } @Test - fun callFeedback() { + fun feedback() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val feedbackResponseSchema = experimentService.feedback( ExperimentFeedbackParams.builder() @@ -192,18 +198,19 @@ class ExperimentServiceTest { ) .build() ) - println(feedbackResponseSchema) + feedbackResponseSchema.validate() } @Test - fun callFetch() { + fun fetch() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val fetchExperimentEventsResponse = experimentService.fetch( ExperimentFetchParams.builder() @@ -214,18 +221,19 @@ class ExperimentServiceTest { .version("version") .build() ) - println(fetchExperimentEventsResponse) + fetchExperimentEventsResponse.validate() } @Test - fun callFetchPost() { + fun fetchPost() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val fetchExperimentEventsResponse = experimentService.fetchPost( ExperimentFetchPostParams.builder() @@ -237,18 +245,19 @@ class ExperimentServiceTest { .version("version") .build() ) - println(fetchExperimentEventsResponse) + fetchExperimentEventsResponse.validate() } @Test - fun callInsert() { + fun insert() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val insertEventsResponse = experimentService.insert( ExperimentInsertParams.builder() @@ -309,18 +318,19 @@ class ExperimentServiceTest { ) .build() ) - println(insertEventsResponse) + insertEventsResponse.validate() } @Test - fun callSummarize() { + fun summarize() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val experimentService = client.experiments() + val summarizeExperimentResponse = experimentService.summarize( ExperimentSummarizeParams.builder() @@ -329,7 +339,7 @@ class ExperimentServiceTest { .summarizeScores(true) .build() ) - println(summarizeExperimentResponse) + summarizeExperimentResponse.validate() } } 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 beb059e2..d5caebf7 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 @@ -13,6 +13,8 @@ import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptOptions +import kotlin.jvm.optionals.getOrNull +import kotlin.test.assertNotNull import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,13 +22,14 @@ import org.junit.jupiter.api.extension.ExtendWith class FunctionServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val functionService = client.functions() + val function = functionService.create( FunctionCreateParams.builder() @@ -132,36 +135,38 @@ class FunctionServiceTest { .addTag("string") .build() ) - println(function) + function.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val functionService = client.functions() + val function = functionService.retrieve( FunctionRetrieveParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(function) + function.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val functionService = client.functions() + val function = functionService.update( FunctionUpdateParams.builder() @@ -252,50 +257,53 @@ class FunctionServiceTest { .addTag("string") .build() ) - println(function) + function.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val functionService = client.functions() - val response = functionService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = functionService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val functionService = client.functions() + val function = functionService.delete( FunctionDeleteParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(function) + function.validate() } @Test - fun callInvoke() { + fun invoke() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val functionService = client.functions() - val functionInvokeResponse = + + val response = functionService.invoke( FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -333,17 +341,21 @@ class FunctionServiceTest { .version("version") .build() ) - println(functionInvokeResponse) + + val unwrappedResponse = response.getOrNull() + assertNotNull(unwrappedResponse) + unwrappedResponse.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val functionService = client.functions() + val function = functionService.replace( FunctionReplaceParams.builder() @@ -449,7 +461,7 @@ class FunctionServiceTest { .addTag("string") .build() ) - println(function) + function.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index 1c3d4641..5bb132ad 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -16,13 +16,14 @@ import org.junit.jupiter.api.extension.ExtendWith class GroupServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val groupService = client.groups() + val group = groupService.create( GroupCreateParams.builder() @@ -33,36 +34,38 @@ class GroupServiceTest { .orgName("org_name") .build() ) - println(group) + group.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val groupService = client.groups() + val group = groupService.retrieve( GroupRetrieveParams.builder() .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(group) + group.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val groupService = client.groups() + val group = groupService.update( GroupUpdateParams.builder() @@ -75,47 +78,50 @@ class GroupServiceTest { .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(group) + group.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val groupService = client.groups() - val response = groupService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = groupService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val groupService = client.groups() + val group = groupService.delete( GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) - println(group) + group.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val groupService = client.groups() + val group = groupService.replace( GroupReplaceParams.builder() @@ -126,7 +132,7 @@ class GroupServiceTest { .orgName("org_name") .build() ) - println(group) + group.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt index a1e497da..97c88d5c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt @@ -14,31 +14,33 @@ import org.junit.jupiter.api.extension.ExtendWith class OrganizationServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val organizationService = client.organizations() + val organization = organizationService.retrieve( OrganizationRetrieveParams.builder() .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(organization) + organization.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val organizationService = client.organizations() + val organization = organizationService.update( OrganizationUpdateParams.builder() @@ -50,38 +52,40 @@ class OrganizationServiceTest { .realtimeUrl("realtime_url") .build() ) - println(organization) + organization.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val organizationService = client.organizations() - val response = organizationService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = organizationService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val organizationService = client.organizations() + val organization = organizationService.delete( OrganizationDeleteParams.builder() .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(organization) + organization.validate() } } 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 6b8364db..0f7d4d1c 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 @@ -19,13 +19,14 @@ import org.junit.jupiter.api.extension.ExtendWith class ProjectScoreServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectScoreService = client.projectScores() + val projectScore = projectScoreService.create( ProjectScoreCreateParams.builder() @@ -57,36 +58,38 @@ class ProjectScoreServiceTest { .description("description") .build() ) - println(projectScore) + projectScore.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectScoreService = client.projectScores() + val projectScore = projectScoreService.retrieve( ProjectScoreRetrieveParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(projectScore) + projectScore.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectScoreService = client.projectScores() + val projectScore = projectScoreService.update( ProjectScoreUpdateParams.builder() @@ -118,49 +121,52 @@ class ProjectScoreServiceTest { .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) .build() ) - println(projectScore) + projectScore.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectScoreService = client.projectScores() - val response = projectScoreService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = projectScoreService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectScoreService = client.projectScores() + val projectScore = projectScoreService.delete( ProjectScoreDeleteParams.builder() .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(projectScore) + projectScore.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectScoreService = client.projectScores() + val projectScore = projectScoreService.replace( ProjectScoreReplaceParams.builder() @@ -192,7 +198,7 @@ class ProjectScoreServiceTest { .description("description") .build() ) - println(projectScore) + projectScore.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 23068949..9b95d382 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -16,47 +16,50 @@ import org.junit.jupiter.api.extension.ExtendWith class ProjectServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectService = client.projects() + val project = projectService.create( ProjectCreateParams.builder().name("x").orgName("org_name").build() ) - println(project) + project.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectService = client.projects() + val project = projectService.retrieve( ProjectRetrieveParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(project) + project.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectService = client.projects() + val project = projectService.update( ProjectUpdateParams.builder() @@ -65,38 +68,40 @@ class ProjectServiceTest { .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) .build() ) - println(project) + project.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectService = client.projects() - val response = projectService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = projectService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectService = client.projects() + val project = projectService.delete( ProjectDeleteParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(project) + project.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt index 1661ab10..503f9390 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -16,13 +16,14 @@ import org.junit.jupiter.api.extension.ExtendWith class ProjectTagServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectTagService = client.projectTags() + val projectTag = projectTagService.create( ProjectTagCreateParams.builder() @@ -32,36 +33,38 @@ class ProjectTagServiceTest { .description("description") .build() ) - println(projectTag) + projectTag.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectTagService = client.projectTags() + val projectTag = projectTagService.retrieve( ProjectTagRetrieveParams.builder() .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(projectTag) + projectTag.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectTagService = client.projectTags() + val projectTag = projectTagService.update( ProjectTagUpdateParams.builder() @@ -71,49 +74,52 @@ class ProjectTagServiceTest { .name("name") .build() ) - println(projectTag) + projectTag.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectTagService = client.projectTags() - val response = projectTagService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = projectTagService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectTagService = client.projectTags() + val projectTag = projectTagService.delete( ProjectTagDeleteParams.builder() .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(projectTag) + projectTag.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectTagService = client.projectTags() + val projectTag = projectTagService.replace( ProjectTagReplaceParams.builder() @@ -123,7 +129,7 @@ class ProjectTagServiceTest { .description("description") .build() ) - println(projectTag) + projectTag.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index bfcea055..68eff58c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -19,13 +19,14 @@ import org.junit.jupiter.api.extension.ExtendWith class PromptServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val promptService = client.prompts() + val prompt = promptService.create( PromptCreateParams.builder() @@ -113,36 +114,38 @@ class PromptServiceTest { .addTag("string") .build() ) - println(prompt) + prompt.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val promptService = client.prompts() + val prompt = promptService.retrieve( PromptRetrieveParams.builder() .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(prompt) + prompt.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val promptService = client.prompts() + val prompt = promptService.update( PromptUpdateParams.builder() @@ -229,49 +232,52 @@ class PromptServiceTest { .addTag("string") .build() ) - println(prompt) + prompt.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val promptService = client.prompts() - val response = promptService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = promptService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val promptService = client.prompts() + val prompt = promptService.delete( PromptDeleteParams.builder() .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(prompt) + prompt.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val promptService = client.prompts() + val prompt = promptService.replace( PromptReplaceParams.builder() @@ -359,7 +365,7 @@ class PromptServiceTest { .addTag("string") .build() ) - println(prompt) + prompt.validate() } } 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 b9b46ca6..87471933 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 @@ -16,13 +16,14 @@ import org.junit.jupiter.api.extension.ExtendWith class RoleServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val roleService = client.roles() + val role = roleService.create( RoleCreateParams.builder() @@ -40,34 +41,36 @@ class RoleServiceTest { .orgName("org_name") .build() ) - println(role) + role.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val roleService = client.roles() + val role = roleService.retrieve( RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) - println(role) + role.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val roleService = client.roles() + val role = roleService.update( RoleUpdateParams.builder() @@ -95,47 +98,50 @@ class RoleServiceTest { .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(role) + role.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val roleService = client.roles() - val response = roleService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = roleService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val roleService = client.roles() + val role = roleService.delete( RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) - println(role) + role.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val roleService = client.roles() + val role = roleService.replace( RoleReplaceParams.builder() @@ -153,7 +159,7 @@ class RoleServiceTest { .orgName("org_name") .build() ) - println(role) + role.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index b384a524..0f18d989 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -16,13 +16,14 @@ import org.junit.jupiter.api.extension.ExtendWith class SpanIframeServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val spanIframeService = client.spanIframes() + val spanIFrame = spanIframeService.create( SpanIframeCreateParams.builder() @@ -33,36 +34,38 @@ class SpanIframeServiceTest { .postMessage(true) .build() ) - println(spanIFrame) + spanIFrame.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val spanIframeService = client.spanIframes() + val spanIFrame = spanIframeService.retrieve( SpanIframeRetrieveParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(spanIFrame) + spanIFrame.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val spanIframeService = client.spanIframes() + val spanIFrame = spanIframeService.update( SpanIframeUpdateParams.builder() @@ -72,49 +75,52 @@ class SpanIframeServiceTest { .url("url") .build() ) - println(spanIFrame) + spanIFrame.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val spanIframeService = client.spanIframes() - val response = spanIframeService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = spanIframeService.list() + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val spanIframeService = client.spanIframes() + val spanIFrame = spanIframeService.delete( SpanIframeDeleteParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) - println(spanIFrame) + spanIFrame.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val spanIframeService = client.spanIframes() + val spanIFrame = spanIframeService.replace( SpanIframeReplaceParams.builder() @@ -125,7 +131,7 @@ class SpanIframeServiceTest { .postMessage(true) .build() ) - println(spanIFrame) + spanIFrame.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt index 30085f63..a1e4f554 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -12,15 +11,14 @@ import org.junit.jupiter.api.extension.ExtendWith class TopLevelServiceTest { @Test - fun callHelloWorld() { + fun helloWorld() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val topLevelService = client.topLevel() - val topLevelHelloWorldResponse = topLevelService.helloWorld() - println(topLevelHelloWorldResponse) - assertThat(topLevelHelloWorldResponse).isNotBlank() + + topLevelService.helloWorld() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index c1173eec..bdf88104 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -12,31 +12,33 @@ import org.junit.jupiter.api.extension.ExtendWith class UserServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val userService = client.users() + val user = userService.retrieve( UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() ) - println(user) + user.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val userService = client.users() - val response = userService.list() - println(response) - response.objects().forEach { it.validate() } + + val page = userService.list() + + page.response().validate() } } 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 d30bfc13..888e7466 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 @@ -22,13 +22,14 @@ import org.junit.jupiter.api.extension.ExtendWith class ViewServiceTest { @Test - fun callCreate() { + fun create() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val viewService = client.views() + val view = viewService.create( ViewCreateParams.builder() @@ -67,18 +68,19 @@ class ViewServiceTest { ) .build() ) - println(view) + view.validate() } @Test - fun callRetrieve() { + fun retrieve() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val viewService = client.views() + val view = viewService.retrieve( ViewRetrieveParams.builder() @@ -87,18 +89,19 @@ class ViewServiceTest { .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) .build() ) - println(view) + view.validate() } @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val viewService = client.views() + val view = viewService.update( ViewUpdateParams.builder() @@ -137,37 +140,39 @@ class ViewServiceTest { .viewType(ViewUpdateParams.ViewType.PROJECTS) .build() ) - println(view) + view.validate() } @Test - fun callList() { + fun list() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val viewService = client.views() - val response = + + val page = viewService.list( ViewListParams.builder() .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(ViewListParams.ObjectType.ORGANIZATION) .build() ) - println(response) - response.objects().forEach { it.validate() } + + page.response().validate() } @Test - fun callDelete() { + fun delete() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val viewService = client.views() + val view = viewService.delete( ViewDeleteParams.builder() @@ -176,18 +181,19 @@ class ViewServiceTest { .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) .build() ) - println(view) + view.validate() } @Test - fun callReplace() { + fun replace() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val viewService = client.views() + val view = viewService.replace( ViewReplaceParams.builder() @@ -226,7 +232,7 @@ class ViewServiceTest { ) .build() ) - println(view) + view.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt index 9967915e..d23dacb9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt @@ -12,13 +12,14 @@ import org.junit.jupiter.api.extension.ExtendWith class MemberServiceTest { @Test - fun callUpdate() { + fun update() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val memberService = client.organizations().members() + val patchOrganizationMembersOutput = memberService.update( OrganizationMemberUpdateParams.builder() @@ -43,7 +44,7 @@ class MemberServiceTest { ) .build() ) - println(patchOrganizationMembersOutput) + patchOrganizationMembersOutput.validate() } } 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 0c88b1e1..fca0f5f6 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 @@ -20,13 +20,14 @@ import org.junit.jupiter.api.extension.ExtendWith class LogServiceTest { @Test - fun callFeedback() { + fun feedback() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val logService = client.projects().logs() + val feedbackResponseSchema = logService.feedback( ProjectLogFeedbackParams.builder() @@ -52,18 +53,19 @@ class LogServiceTest { ) .build() ) - println(feedbackResponseSchema) + feedbackResponseSchema.validate() } @Test - fun callFetch() { + fun fetch() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val logService = client.projects().logs() + val fetchProjectLogsEventsResponse = logService.fetch( ProjectLogFetchParams.builder() @@ -74,18 +76,19 @@ class LogServiceTest { .version("version") .build() ) - println(fetchProjectLogsEventsResponse) + fetchProjectLogsEventsResponse.validate() } @Test - fun callFetchPost() { + fun fetchPost() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val logService = client.projects().logs() + val fetchProjectLogsEventsResponse = logService.fetchPost( ProjectLogFetchPostParams.builder() @@ -97,18 +100,19 @@ class LogServiceTest { .version("version") .build() ) - println(fetchProjectLogsEventsResponse) + fetchProjectLogsEventsResponse.validate() } @Test - fun callInsert() { + fun insert() { val client = BraintrustOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val logService = client.projects().logs() + val insertEventsResponse = logService.insert( ProjectLogInsertParams.builder() @@ -168,7 +172,7 @@ class LogServiceTest { ) .build() ) - println(insertEventsResponse) + insertEventsResponse.validate() } } From effc19754eb651f3531959839e9a803d4b056587 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 27 Feb 2025 06:52:57 +0000 Subject: [PATCH 56/87] chore(client): use deep identity methods for primitive array types (#126) --- .../com/braintrustdata/api/core/Utils.kt | 36 ++++++++++++++++ .../com/braintrustdata/api/core/Values.kt | 43 +++++-------------- .../com/braintrustdata/api/core/UtilsTest.kt | 33 ++++++++++++++ 3 files changed, 80 insertions(+), 32 deletions(-) create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/UtilsTest.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 2e3d2548..6761ce6a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -25,4 +25,40 @@ internal fun , V> SortedMap.toImmutable(): SortedMap value.contentHashCode() - is String -> value - is Boolean -> value - is Long -> value - is Double -> value - else -> value?.hashCode() - }, - ) - } - return hashCode - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || this.javaClass != other.javaClass) return false + private val hashCode: Int by lazy { contentHash(name, value, contentType, filename) } - other as MultipartFormValue<*> + override fun hashCode(): Int = hashCode - if (name != other.name || contentType != other.contentType || filename != other.filename) - return false - - return when { - value is ByteArray && other.value is ByteArray -> value contentEquals other.value - else -> value?.equals(other.value) ?: (other.value == null) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is MultipartFormValue<*> && + name == other.name && + value contentEquals other.value && + contentType == other.contentType && + filename == other.filename } override fun toString(): String = diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/UtilsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/UtilsTest.kt new file mode 100644 index 00000000..43a97498 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/UtilsTest.kt @@ -0,0 +1,33 @@ +package com.braintrustdata.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtilsTest { + @Test + fun contentDeepEquals() { + assertThat(42 contentEquals 42).isTrue() + assertThat(42 contentEquals "Hello World!").isFalse() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 3)).isTrue() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 4)).isFalse() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) + ) + .isTrue() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1), byteArrayOf(2, 3)) + ) + .isFalse() + } + + @Test + fun contentToString() { + assertThat((42).contentToString()).isEqualTo("42") + assertThat("Hello World!".contentToString()).isEqualTo("Hello World!") + assertThat(byteArrayOf(1, 2, 3).contentToString()).isEqualTo("[1, 2, 3]") + assertThat(arrayOf(byteArrayOf(1, 2), byteArrayOf(3)).contentToString()) + .isEqualTo("[[1, 2], [3]]") + } +} From 410474405bf5b56695aea53e7d560d7cc48bc144 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 27 Feb 2025 06:56:18 +0000 Subject: [PATCH 57/87] chore(internal): refactor `ServiceParamsTest` (#127) --- .../api/services/ServiceParamsTest.kt | 61 +++++-------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt index acd72ac7..9e25370e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt @@ -5,11 +5,7 @@ package com.braintrustdata.api.services import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.jsonMapper -import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams -import com.braintrustdata.api.models.ProjectSettings -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -20,14 +16,11 @@ import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import java.time.OffsetDateTime import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @WireMockTest -class ServiceParamsTest { - - private val JSON_MAPPER: JsonMapper = jsonMapper() +internal class ServiceParamsTest { private lateinit var client: BraintrustClient @@ -35,55 +28,31 @@ class ServiceParamsTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = BraintrustOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) .build() } @Test - fun projectsCreateWithAdditionalParams() { - val additionalHeaders = mutableMapOf>() - - additionalHeaders.put("x-test-header", listOf("abc1234")) - - val additionalQueryParams = mutableMapOf>() - - additionalQueryParams.put("test_query_param", listOf("def567")) - - val additionalBodyProperties = mutableMapOf() - - additionalBodyProperties.put("testBodyProperty", JsonValue.from("ghi890")) + fun create() { + val projectService = client.projects() + stubFor(post(anyUrl()).willReturn(ok("{}"))) - val params = + projectService.create( ProjectCreateParams.builder() .name("x") .orgName("org_name") - .additionalHeaders(additionalHeaders) - .additionalBodyProperties(additionalBodyProperties) - .additionalQueryParams(additionalQueryParams) + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build() - - val apiResponse = - Project.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - stubFor( - post(anyUrl()) - .withHeader("x-test-header", equalTo("abc1234")) - .withQueryParam("test_query_param", equalTo("def567")) - .withRequestBody(matchingJsonPath("$.testBodyProperty", equalTo("ghi890"))) - .willReturn(ok(JSON_MAPPER.writeValueAsString(apiResponse))) ) - client.projects().create(params) - - verify(postRequestedFor(anyUrl())) + verify( + postRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) + ) } } From 57e17de51ce9372dee4dab1f3ad67a040d7900bb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 28 Feb 2025 03:41:51 +0000 Subject: [PATCH 58/87] docs: update URLs from stainlessapi.com to stainless.com (#128) More details at https://www.stainless.com/changelog/stainless-com --- README.md | 2 +- SECURITY.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f77a97be..ab6d77bb 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The Braintrust Java SDK provides convenient access to the Braintrust REST API fr The Braintrust Java SDK is similar to the Braintrust Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. -It is generated with [Stainless](https://www.stainlessapi.com/). +It is generated with [Stainless](https://www.stainless.com/). The REST API documentation can be found on [www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec). diff --git a/SECURITY.md b/SECURITY.md index 9e161b9a..0923aae0 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,9 @@ ## Reporting Security Issues -This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. -To report a security issue, please contact the Stainless team at security@stainlessapi.com. +To report a security issue, please contact the Stainless team at security@stainless.com. ## Responsible Disclosure From f61300b640f71f7d5ce0dee685b0d0524da59d08 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 4 Mar 2025 08:16:27 +0000 Subject: [PATCH 59/87] chore(internal): refactor `ErrorHandlingTest` (#129) --- .../api/services/ErrorHandlingTest.kt | 350 ++++++------------ 1 file changed, 122 insertions(+), 228 deletions(-) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 49e14b56..1d611bfb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -17,31 +17,37 @@ import com.braintrustdata.api.errors.RateLimitException import com.braintrustdata.api.errors.UnauthorizedException import com.braintrustdata.api.errors.UnexpectedStatusCodeException import com.braintrustdata.api.errors.UnprocessableEntityException -import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams -import com.braintrustdata.api.models.ProjectSettings -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl -import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatThrownBy -import org.assertj.core.api.InstanceOfAssertFactories +import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows @WireMockTest class ErrorHandlingTest { - private val JSON_MAPPER: JsonMapper = jsonMapper() + companion object { - private val BRAINTRUST_ERROR: BraintrustError = - BraintrustError.builder().putAdditionalProperty("key", JsonValue.from("value")).build() + private val ERROR: BraintrustError = + BraintrustError.builder() + .putAdditionalProperty("errorProperty", JsonValue.from("42")) + .build() + + private val ERROR_JSON: ByteArray = jsonMapper().writeValueAsBytes(ERROR) + + private const val HEADER_NAME: String = "Error-Header" + + private const val HEADER_VALUE: String = "42" + + private const val NOT_JSON: String = "Not JSON" + } private lateinit var client: BraintrustClient @@ -49,299 +55,187 @@ class ErrorHandlingTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = BraintrustOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") .build() } - @Test - fun projectsCreate200() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - - val expected = - Project.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - stubFor(post(anyUrl()).willReturn(ok().withBody(toJson(expected)))) - - assertThat(client.projects().create(params)).isEqualTo(expected) - } - @Test fun projectsCreate400() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - + val projectService = client.projects() stubFor( post(anyUrl()) - .willReturn(status(400).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) + .willReturn(status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertBadRequest(e, Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR) - }) + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate401() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - + val projectService = client.projects() stubFor( post(anyUrl()) - .willReturn(status(401).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) + .willReturn(status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertUnauthorized(e, Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR) - }) + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate403() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - + val projectService = client.projects() stubFor( post(anyUrl()) - .willReturn(status(403).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) + .willReturn(status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertPermissionDenied( - e, - Headers.builder().put("Foo", "Bar").build(), - BRAINTRUST_ERROR, + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() ) - }) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate404() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - + val projectService = client.projects() stubFor( post(anyUrl()) - .willReturn(status(404).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) + .willReturn(status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertNotFound(e, Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR) - }) + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate422() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - + val projectService = client.projects() stubFor( post(anyUrl()) - .willReturn(status(422).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) + .willReturn(status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertUnprocessableEntity( - e, - Headers.builder().put("Foo", "Bar").build(), - BRAINTRUST_ERROR, + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() ) - }) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate429() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - + val projectService = client.projects() stubFor( post(anyUrl()) - .willReturn(status(429).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) + .willReturn(status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertRateLimit(e, Headers.builder().put("Foo", "Bar").build(), BRAINTRUST_ERROR) - }) + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate500() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - + val projectService = client.projects() stubFor( post(anyUrl()) - .willReturn(status(500).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) + .willReturn(status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertInternalServer( - e, - Headers.builder().put("Foo", "Bar").build(), - BRAINTRUST_ERROR, + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() ) - }) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test - fun unexpectedStatusCode() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - + fun projectsCreate999() { + val projectService = client.projects() stubFor( post(anyUrl()) - .willReturn(status(999).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) + .willReturn(status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertUnexpectedStatusCodeException( - e, - 999, - Headers.builder().put("Foo", "Bar").build(), - toJson(BRAINTRUST_ERROR), + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() ) - }) - } + } - @Test - fun invalidBody() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - - stubFor(post(anyUrl()).willReturn(status(200).withBody("Not JSON"))) - - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertThat(e) - .isInstanceOf(BraintrustException::class.java) - .hasMessage("Error reading response") - }) + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test - fun invalidErrorBody() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - - stubFor(post(anyUrl()).willReturn(status(400).withBody("Not JSON"))) - - assertThatThrownBy({ client.projects().create(params) }) - .satisfies({ e -> - assertBadRequest(e, Headers.builder().build(), BraintrustError.builder().build()) - }) - } - - private fun toJson(body: T): ByteArray { - return JSON_MAPPER.writeValueAsBytes(body) - } - - private fun assertUnexpectedStatusCodeException( - throwable: Throwable, - statusCode: Int, - headers: Headers, - responseBody: ByteArray, - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnexpectedStatusCodeException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(statusCode) - assertThat(e.body()).isEqualTo(String(responseBody)) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertBadRequest(throwable: Throwable, headers: Headers, error: BraintrustError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(BadRequestException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertUnauthorized(throwable: Throwable, headers: Headers, error: BraintrustError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(UnauthorizedException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertPermissionDenied( - throwable: Throwable, - headers: Headers, - error: BraintrustError, - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(PermissionDeniedException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertNotFound(throwable: Throwable, headers: Headers, error: BraintrustError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertUnprocessableEntity( - throwable: Throwable, - headers: Headers, - error: BraintrustError, - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnprocessableEntityException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } + fun projectsCreateInvalidJsonBody() { + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) - private fun assertRateLimit(throwable: Throwable, headers: Headers, error: BraintrustError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } - private fun assertInternalServer( - throwable: Throwable, - headers: Headers, - error: BraintrustError, - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(InternalServerException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) + assertThat(e).hasMessage("Error reading response") } private fun Headers.toMap(): Map> = From 606ebb74dcc339190eeefe2b072f273783445edc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 08:18:21 +0000 Subject: [PATCH 60/87] feat(client): allow configuring timeouts granularly (#130) Note that previously the `timeout(Duration)` method on the client and `RequestOptions` corresponded to connect, read, write, and request timeout. Now it only corresponds to the request timeout. Use the new `timeout(Timeout)` method to configure other timeout values granularly. --- .../client/okhttp/BraintrustOkHttpClient.kt | 18 +- .../okhttp/BraintrustOkHttpClientAsync.kt | 18 +- .../api/client/okhttp/OkHttpClient.kt | 27 +-- .../braintrustdata/api/core/ClientOptions.kt | 6 + .../braintrustdata/api/core/RequestOptions.kt | 33 ++-- .../com/braintrustdata/api/core/Timeout.kt | 187 ++++++++++++++++++ .../api/services/async/AclServiceAsyncImpl.kt | 18 +- .../async/AiSecretServiceAsyncImpl.kt | 21 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 12 +- .../services/async/DatasetServiceAsyncImpl.kt | 30 ++- .../services/async/EnvVarServiceAsyncImpl.kt | 18 +- .../services/async/EvalServiceAsyncImpl.kt | 3 +- .../async/ExperimentServiceAsyncImpl.kt | 30 ++- .../async/FunctionServiceAsyncImpl.kt | 21 +- .../services/async/GroupServiceAsyncImpl.kt | 18 +- .../async/OrganizationServiceAsyncImpl.kt | 12 +- .../async/ProjectScoreServiceAsyncImpl.kt | 18 +- .../services/async/ProjectServiceAsyncImpl.kt | 15 +- .../async/ProjectTagServiceAsyncImpl.kt | 18 +- .../services/async/PromptServiceAsyncImpl.kt | 18 +- .../services/async/RoleServiceAsyncImpl.kt | 18 +- .../async/SpanIframeServiceAsyncImpl.kt | 18 +- .../async/TopLevelServiceAsyncImpl.kt | 1 + .../services/async/UserServiceAsyncImpl.kt | 6 +- .../services/async/ViewServiceAsyncImpl.kt | 18 +- .../organizations/MemberServiceAsyncImpl.kt | 3 +- .../async/projects/LogServiceAsyncImpl.kt | 12 +- .../api/services/blocking/AclServiceImpl.kt | 18 +- .../services/blocking/AiSecretServiceImpl.kt | 21 +- .../services/blocking/ApiKeyServiceImpl.kt | 12 +- .../services/blocking/DatasetServiceImpl.kt | 30 ++- .../services/blocking/EnvVarServiceImpl.kt | 18 +- .../api/services/blocking/EvalServiceImpl.kt | 3 +- .../blocking/ExperimentServiceImpl.kt | 30 ++- .../services/blocking/FunctionServiceImpl.kt | 21 +- .../api/services/blocking/GroupServiceImpl.kt | 18 +- .../blocking/OrganizationServiceImpl.kt | 12 +- .../blocking/ProjectScoreServiceImpl.kt | 18 +- .../services/blocking/ProjectServiceImpl.kt | 15 +- .../blocking/ProjectTagServiceImpl.kt | 18 +- .../services/blocking/PromptServiceImpl.kt | 18 +- .../api/services/blocking/RoleServiceImpl.kt | 18 +- .../blocking/SpanIframeServiceImpl.kt | 18 +- .../services/blocking/TopLevelServiceImpl.kt | 1 + .../api/services/blocking/UserServiceImpl.kt | 6 +- .../api/services/blocking/ViewServiceImpl.kt | 18 +- .../organizations/MemberServiceImpl.kt | 3 +- .../blocking/projects/LogServiceImpl.kt | 12 +- 48 files changed, 696 insertions(+), 249 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index f7b49e5c..376f0eef 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.client.okhttp import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.BraintrustClientImpl import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.Timeout import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.fasterxml.jackson.databind.json.JsonMapper @@ -27,8 +28,7 @@ class BraintrustOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { @@ -120,7 +120,19 @@ class BraintrustOkHttpClient private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index d812a431..25473f9a 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.client.okhttp import com.braintrustdata.api.client.BraintrustClientAsync import com.braintrustdata.api.client.BraintrustClientAsyncImpl import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.Timeout import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.fasterxml.jackson.databind.json.JsonMapper @@ -27,8 +28,7 @@ class BraintrustOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { @@ -120,7 +120,19 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index e5c36439..49a5df68 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -1,6 +1,7 @@ package com.braintrustdata.api.client.okhttp import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.Timeout import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpClient @@ -88,13 +89,12 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val ) } - val timeout = requestOptions.timeout - if (timeout != null) { + requestOptions.timeout?.let { clientBuilder - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .connectTimeout(it.connect()) + .readTimeout(it.read()) + .writeTimeout(it.write()) + .callTimeout(it.request()) } val client = clientBuilder.build() @@ -195,23 +195,24 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { private var baseUrl: HttpUrl? = null - // The default timeout is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) .proxy(proxy) .build(), checkRequired("baseUrl", baseUrl), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index ea3dd912..9b5dc8d1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -21,6 +21,7 @@ private constructor( @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, + @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, @get:JvmName("apiKey") val apiKey: String?, ) { @@ -46,6 +47,7 @@ private constructor( private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false + private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 private var apiKey: String? = null @@ -58,6 +60,7 @@ private constructor( headers = clientOptions.headers.toBuilder() queryParams = clientOptions.queryParams.toBuilder() responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries apiKey = clientOptions.apiKey } @@ -74,6 +77,8 @@ private constructor( this.responseValidation = responseValidation } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } @@ -197,6 +202,7 @@ private constructor( headers.build(), queryParams.build(), responseValidation, + timeout, maxRetries, apiKey, ) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt index d89e0590..fe7c8372 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt @@ -2,13 +2,7 @@ package com.braintrustdata.api.core import java.time.Duration -class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Duration?) { - fun applyDefaults(options: RequestOptions): RequestOptions { - return RequestOptions( - responseValidation = this.responseValidation ?: options.responseValidation, - timeout = this.timeout ?: options.timeout, - ) - } +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { companion object { @@ -16,22 +10,37 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t @JvmStatic fun none() = NONE + @JvmSynthetic + internal fun from(clientOptions: ClientOptions): RequestOptions = + builder() + .responseValidation(clientOptions.responseValidation) + .timeout(clientOptions.timeout) + .build() + @JvmStatic fun builder() = Builder() } + fun applyDefaults(options: RequestOptions): RequestOptions = + RequestOptions( + responseValidation = responseValidation ?: options.responseValidation, + timeout = + if (options.timeout != null && timeout != null) timeout.assign(options.timeout) + else timeout ?: options.timeout, + ) + class Builder internal constructor() { private var responseValidation: Boolean? = null - private var timeout: Duration? = null + private var timeout: Timeout? = null fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } - fun build(): RequestOptions { - return RequestOptions(responseValidation, timeout) - } + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun build(): RequestOptions = RequestOptions(responseValidation, timeout) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt new file mode 100644 index 00000000..c5ffa5e7 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt @@ -0,0 +1,187 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.core + +import java.time.Duration +import java.util.Objects +import java.util.Optional + +/** A class containing timeouts for various processing phases of a request. */ +class Timeout +private constructor( + private val connect: Duration?, + private val read: Duration?, + private val write: Duration?, + private val request: Duration?, +) { + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(): Duration = connect ?: Duration.ofMinutes(1) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(): Duration = read ?: request() + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(): Duration = write ?: request() + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(): Duration = request ?: Duration.ofMinutes(1) + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun default() = builder().build() + + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var connect: Duration? = null + private var read: Duration? = null + private var write: Duration? = null + private var request: Duration? = null + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Duration?) = apply { this.connect = connect } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Optional) = connect(connect.orElse(null)) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Duration?) = apply { this.read = read } + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Optional) = read(read.orElse(null)) + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Duration?) = apply { this.write = write } + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Optional) = write(write.orElse(null)) + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Duration?) = apply { this.request = request } + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Optional) = request(request.orElse(null)) + + fun build(): Timeout = Timeout(connect, read, write, request) + } + + @JvmSynthetic + internal fun assign(target: Timeout): Timeout = + target + .toBuilder() + .apply { + connect?.let(this::connect) + read?.let(this::read) + write?.let(this::write) + request?.let(this::request) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ + + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index bb9f6b26..8b587da2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -47,13 +47,14 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -74,13 +75,14 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client .addPathSegments("v1", "acl", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -105,13 +107,14 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client .addPathSegments("v1", "acl") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -134,13 +137,14 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -165,13 +169,14 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { batchUpdateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -193,13 +198,14 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { findAndDeleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index ed213522..b16cf183 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -47,13 +47,14 @@ class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: C .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -74,13 +75,14 @@ class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: C .addPathSegments("v1", "ai_secret", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -106,13 +108,14 @@ class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: C .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -137,13 +140,14 @@ class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: C .addPathSegments("v1", "ai_secret") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -166,13 +170,14 @@ class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: C .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -194,13 +199,14 @@ class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: C .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { findAndDeleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -225,13 +231,14 @@ class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: C .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index 7a0815d3..3a55e189 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -45,13 +45,14 @@ class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: Cli .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -72,13 +73,14 @@ class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: Cli .addPathSegments("v1", "api_key", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -103,13 +105,14 @@ class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: Cli .addPathSegments("v1", "api_key") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -132,13 +135,14 @@ class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: Cli .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index ec9cb0b2..f55b0239 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -54,13 +54,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -81,13 +82,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "dataset", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -113,13 +115,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -144,13 +147,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "dataset") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -173,13 +177,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -201,13 +206,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { feedbackHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -233,13 +239,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { fetchHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -266,13 +273,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { fetchPostHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -294,13 +302,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { insertHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -322,13 +331,14 @@ class DatasetServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { summarizeHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index afb0f12b..f984adc7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -46,13 +46,14 @@ class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: Cli .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -73,13 +74,14 @@ class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: Cli .addPathSegments("v1", "env_var", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -105,13 +107,14 @@ class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: Cli .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -135,13 +138,14 @@ class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: Cli .addPathSegments("v1", "env_var") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -163,13 +167,14 @@ class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: Cli .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -194,13 +199,14 @@ class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: Cli .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index 524a50fe..95d4f10d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -44,13 +44,14 @@ class EvalServiceAsyncImpl internal constructor(private val clientOptions: Clien .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index d384b3c1..1e36bfcd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -54,13 +54,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -81,13 +82,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .addPathSegments("v1", "experiment", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -113,13 +115,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -144,13 +147,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .addPathSegments("v1", "experiment") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -173,13 +177,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -201,13 +206,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { feedbackHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -233,13 +239,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { fetchHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -266,13 +273,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { fetchPostHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -294,13 +302,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { insertHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -322,13 +331,14 @@ class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { summarizeHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 9f254448..f3edf664 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -49,13 +49,14 @@ class FunctionServiceAsyncImpl internal constructor(private val clientOptions: C .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -76,13 +77,14 @@ class FunctionServiceAsyncImpl internal constructor(private val clientOptions: C .addPathSegments("v1", "function", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -108,13 +110,14 @@ class FunctionServiceAsyncImpl internal constructor(private val clientOptions: C .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -139,13 +142,14 @@ class FunctionServiceAsyncImpl internal constructor(private val clientOptions: C .addPathSegments("v1", "function") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -168,13 +172,14 @@ class FunctionServiceAsyncImpl internal constructor(private val clientOptions: C .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -197,13 +202,14 @@ class FunctionServiceAsyncImpl internal constructor(private val clientOptions: C .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { invokeHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.ifPresent { it.validate() } } } @@ -229,13 +235,14 @@ class FunctionServiceAsyncImpl internal constructor(private val clientOptions: C .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index 08015024..24bdd0c6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -46,13 +46,14 @@ class GroupServiceAsyncImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -73,13 +74,14 @@ class GroupServiceAsyncImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "group", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -105,13 +107,14 @@ class GroupServiceAsyncImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -136,13 +139,14 @@ class GroupServiceAsyncImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "group") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -165,13 +169,14 @@ class GroupServiceAsyncImpl internal constructor(private val clientOptions: Clie .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -196,13 +201,14 @@ class GroupServiceAsyncImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 691d8fb5..8cd52acd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -46,13 +46,14 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption .addPathSegments("v1", "organization", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -78,13 +79,14 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -109,13 +111,14 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption .addPathSegments("v1", "organization") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -138,13 +141,14 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index a565c873..98e631a1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -47,13 +47,14 @@ class ProjectScoreServiceAsyncImpl internal constructor(private val clientOption .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -74,13 +75,14 @@ class ProjectScoreServiceAsyncImpl internal constructor(private val clientOption .addPathSegments("v1", "project_score", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -106,13 +108,14 @@ class ProjectScoreServiceAsyncImpl internal constructor(private val clientOption .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -137,13 +140,14 @@ class ProjectScoreServiceAsyncImpl internal constructor(private val clientOption .addPathSegments("v1", "project_score") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -166,13 +170,14 @@ class ProjectScoreServiceAsyncImpl internal constructor(private val clientOption .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -198,13 +203,14 @@ class ProjectScoreServiceAsyncImpl internal constructor(private val clientOption .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index df0d8bad..2ad16227 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -51,13 +51,14 @@ class ProjectServiceAsyncImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -78,13 +79,14 @@ class ProjectServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "project", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -110,13 +112,14 @@ class ProjectServiceAsyncImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -141,13 +144,14 @@ class ProjectServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "project") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -170,13 +174,14 @@ class ProjectServiceAsyncImpl internal constructor(private val clientOptions: Cl .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index d72ea0d2..8de12f82 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -46,13 +46,14 @@ class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -73,13 +74,14 @@ class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: .addPathSegments("v1", "project_tag", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -105,13 +107,14 @@ class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -136,13 +139,14 @@ class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: .addPathSegments("v1", "project_tag") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -165,13 +169,14 @@ class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -197,13 +202,14 @@ class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index e3acb9d4..1f9425c8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -46,13 +46,14 @@ class PromptServiceAsyncImpl internal constructor(private val clientOptions: Cli .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -73,13 +74,14 @@ class PromptServiceAsyncImpl internal constructor(private val clientOptions: Cli .addPathSegments("v1", "prompt", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -105,13 +107,14 @@ class PromptServiceAsyncImpl internal constructor(private val clientOptions: Cli .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -136,13 +139,14 @@ class PromptServiceAsyncImpl internal constructor(private val clientOptions: Cli .addPathSegments("v1", "prompt") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -165,13 +169,14 @@ class PromptServiceAsyncImpl internal constructor(private val clientOptions: Cli .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -196,13 +201,14 @@ class PromptServiceAsyncImpl internal constructor(private val clientOptions: Cli .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index ed8c8fe3..557d8245 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -46,13 +46,14 @@ class RoleServiceAsyncImpl internal constructor(private val clientOptions: Clien .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -73,13 +74,14 @@ class RoleServiceAsyncImpl internal constructor(private val clientOptions: Clien .addPathSegments("v1", "role", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -105,13 +107,14 @@ class RoleServiceAsyncImpl internal constructor(private val clientOptions: Clien .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -136,13 +139,14 @@ class RoleServiceAsyncImpl internal constructor(private val clientOptions: Clien .addPathSegments("v1", "role") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -165,13 +169,14 @@ class RoleServiceAsyncImpl internal constructor(private val clientOptions: Clien .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -196,13 +201,14 @@ class RoleServiceAsyncImpl internal constructor(private val clientOptions: Clien .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt index 745acd9a..35b8dac4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -46,13 +46,14 @@ class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -73,13 +74,14 @@ class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: .addPathSegments("v1", "span_iframe", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -105,13 +107,14 @@ class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -136,13 +139,14 @@ class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: .addPathSegments("v1", "span_iframe") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -165,13 +169,14 @@ class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -196,13 +201,14 @@ class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index 03b94366..16a8992a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -33,6 +33,7 @@ class TopLevelServiceAsyncImpl internal constructor(private val clientOptions: C .addPathSegments("v1") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response.use { helloWorldHandler.handle(it) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 8962743f..b35e24b0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -37,13 +37,14 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .addPathSegments("v1", "user", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -68,13 +69,14 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .addPathSegments("v1", "user") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 8ce4709a..1de11874 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -46,13 +46,14 @@ class ViewServiceAsyncImpl internal constructor(private val clientOptions: Clien .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -73,13 +74,14 @@ class ViewServiceAsyncImpl internal constructor(private val clientOptions: Clien .addPathSegments("v1", "view", params.getPathParam(0)) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -105,13 +107,14 @@ class ViewServiceAsyncImpl internal constructor(private val clientOptions: Clien .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -136,13 +139,14 @@ class ViewServiceAsyncImpl internal constructor(private val clientOptions: Clien .addPathSegments("v1", "view") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -165,13 +169,14 @@ class ViewServiceAsyncImpl internal constructor(private val clientOptions: Clien .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -196,13 +201,14 @@ class ViewServiceAsyncImpl internal constructor(private val clientOptions: Clien .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 4607e2bf..416ac512 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -38,13 +38,14 @@ class MemberServiceAsyncImpl internal constructor(private val clientOptions: Cli .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index de0d28d4..8dce635c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -42,13 +42,14 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { feedbackHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -74,13 +75,14 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { fetchHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -107,13 +109,14 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { fetchPostHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -135,13 +138,14 @@ class LogServiceAsyncImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> response .use { insertHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index daa29513..730888a1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -42,11 +42,12 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -63,11 +64,12 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio .addPathSegments("v1", "acl", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -87,11 +89,12 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio .addPathSegments("v1", "acl") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -110,11 +113,12 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -138,11 +142,12 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { batchUpdateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -163,11 +168,12 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { findAndDeleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index eb6b559b..1e42d069 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -43,11 +43,12 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -67,11 +68,12 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client .addPathSegments("v1", "ai_secret", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -93,11 +95,12 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -121,11 +124,12 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client .addPathSegments("v1", "ai_secret") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -144,11 +148,12 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -169,11 +174,12 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { findAndDeleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -194,11 +200,12 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index c300b883..e56119d0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -44,11 +44,12 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -65,11 +66,12 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp .addPathSegments("v1", "api_key", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -90,11 +92,12 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp .addPathSegments("v1", "api_key") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -113,11 +116,12 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 3e76ec99..0c9707bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -50,11 +50,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -71,11 +72,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("v1", "dataset", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -97,11 +99,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -122,11 +125,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("v1", "dataset") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -145,11 +149,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -170,11 +175,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { feedbackHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -199,11 +205,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { fetchHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -229,11 +236,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { fetchPostHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -254,11 +262,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { insertHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -279,11 +288,12 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { summarizeHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index b26dfba6..9daa2b91 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -42,11 +42,12 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -63,11 +64,12 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp .addPathSegments("v1", "env_var", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -89,11 +91,12 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -116,11 +119,12 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp .addPathSegments("v1", "env_var") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -138,11 +142,12 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -163,11 +168,12 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index 21dfd9ab..9f26e66a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -42,11 +42,12 @@ class EvalServiceImpl internal constructor(private val clientOptions: ClientOpti .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 29549e25..896e6d31 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -53,11 +53,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -77,11 +78,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "experiment", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -106,11 +108,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -134,11 +137,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "experiment") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -160,11 +164,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -185,11 +190,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { feedbackHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -214,11 +220,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { fetchHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -244,11 +251,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { fetchPostHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -269,11 +277,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { insertHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -294,11 +303,12 @@ class ExperimentServiceImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { summarizeHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 92ebbe6f..003452f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -45,11 +45,12 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -69,11 +70,12 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client .addPathSegments("v1", "function", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -95,11 +97,12 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -123,11 +126,12 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client .addPathSegments("v1", "function") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -146,11 +150,12 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -172,11 +177,12 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { invokeHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.ifPresent { it.validate() } } } @@ -198,11 +204,12 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index ebeff796..2a42a7e9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -42,11 +42,12 @@ class GroupServiceImpl internal constructor(private val clientOptions: ClientOpt .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -63,11 +64,12 @@ class GroupServiceImpl internal constructor(private val clientOptions: ClientOpt .addPathSegments("v1", "group", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -89,11 +91,12 @@ class GroupServiceImpl internal constructor(private val clientOptions: ClientOpt .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -113,11 +116,12 @@ class GroupServiceImpl internal constructor(private val clientOptions: ClientOpt .addPathSegments("v1", "group") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -136,11 +140,12 @@ class GroupServiceImpl internal constructor(private val clientOptions: ClientOpt .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -161,11 +166,12 @@ class GroupServiceImpl internal constructor(private val clientOptions: ClientOpt .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index 315c2ea6..5d0bbd22 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -45,11 +45,12 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "organization", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -74,11 +75,12 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -102,11 +104,12 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "organization") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -128,11 +131,12 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index aa7ae8eb..0459cbba 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -46,11 +46,12 @@ class ProjectScoreServiceImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -70,11 +71,12 @@ class ProjectScoreServiceImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "project_score", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -99,11 +101,12 @@ class ProjectScoreServiceImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -127,11 +130,12 @@ class ProjectScoreServiceImpl internal constructor(private val clientOptions: Cl .addPathSegments("v1", "project_score") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -153,11 +157,12 @@ class ProjectScoreServiceImpl internal constructor(private val clientOptions: Cl .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -182,11 +187,12 @@ class ProjectScoreServiceImpl internal constructor(private val clientOptions: Cl .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 02f59abb..2c723eac 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -47,11 +47,12 @@ class ProjectServiceImpl internal constructor(private val clientOptions: ClientO .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -68,11 +69,12 @@ class ProjectServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("v1", "project", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -94,11 +96,12 @@ class ProjectServiceImpl internal constructor(private val clientOptions: ClientO .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -119,11 +122,12 @@ class ProjectServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("v1", "project") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -142,11 +146,12 @@ class ProjectServiceImpl internal constructor(private val clientOptions: ClientO .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index e95a6ff1..027be6d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -45,11 +45,12 @@ class ProjectTagServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -69,11 +70,12 @@ class ProjectTagServiceImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "project_tag", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -98,11 +100,12 @@ class ProjectTagServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -126,11 +129,12 @@ class ProjectTagServiceImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "project_tag") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -152,11 +156,12 @@ class ProjectTagServiceImpl internal constructor(private val clientOptions: Clie .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -181,11 +186,12 @@ class ProjectTagServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index 82e3c2b1..ac344b1b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -42,11 +42,12 @@ class PromptServiceImpl internal constructor(private val clientOptions: ClientOp .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -63,11 +64,12 @@ class PromptServiceImpl internal constructor(private val clientOptions: ClientOp .addPathSegments("v1", "prompt", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -89,11 +91,12 @@ class PromptServiceImpl internal constructor(private val clientOptions: ClientOp .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -114,11 +117,12 @@ class PromptServiceImpl internal constructor(private val clientOptions: ClientOp .addPathSegments("v1", "prompt") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -137,11 +141,12 @@ class PromptServiceImpl internal constructor(private val clientOptions: ClientOp .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -162,11 +167,12 @@ class PromptServiceImpl internal constructor(private val clientOptions: ClientOp .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index ed4bbeb2..74660aff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -41,11 +41,12 @@ class RoleServiceImpl internal constructor(private val clientOptions: ClientOpti .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -62,11 +63,12 @@ class RoleServiceImpl internal constructor(private val clientOptions: ClientOpti .addPathSegments("v1", "role", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -88,11 +90,12 @@ class RoleServiceImpl internal constructor(private val clientOptions: ClientOpti .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -112,11 +115,12 @@ class RoleServiceImpl internal constructor(private val clientOptions: ClientOpti .addPathSegments("v1", "role") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -135,11 +139,12 @@ class RoleServiceImpl internal constructor(private val clientOptions: ClientOpti .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -160,11 +165,12 @@ class RoleServiceImpl internal constructor(private val clientOptions: ClientOpti .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt index a30f3c91..6d9ece08 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -45,11 +45,12 @@ class SpanIframeServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -69,11 +70,12 @@ class SpanIframeServiceImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "span_iframe", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -98,11 +100,12 @@ class SpanIframeServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -126,11 +129,12 @@ class SpanIframeServiceImpl internal constructor(private val clientOptions: Clie .addPathSegments("v1", "span_iframe") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -152,11 +156,12 @@ class SpanIframeServiceImpl internal constructor(private val clientOptions: Clie .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -180,11 +185,12 @@ class SpanIframeServiceImpl internal constructor(private val clientOptions: Clie .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 79dfb27b..3a1825e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -32,6 +32,7 @@ class TopLevelServiceImpl internal constructor(private val clientOptions: Client .addPathSegments("v1") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response.use { helloWorldHandler.handle(it) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 0fdfce45..0163c4db 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -32,11 +32,12 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti .addPathSegments("v1", "user", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -56,11 +57,12 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti .addPathSegments("v1", "user") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 068df7b6..6c50ed16 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -41,11 +41,12 @@ class ViewServiceImpl internal constructor(private val clientOptions: ClientOpti .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { createHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -62,11 +63,12 @@ class ViewServiceImpl internal constructor(private val clientOptions: ClientOpti .addPathSegments("v1", "view", params.getPathParam(0)) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { retrieveHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -88,11 +90,12 @@ class ViewServiceImpl internal constructor(private val clientOptions: ClientOpti .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -112,11 +115,12 @@ class ViewServiceImpl internal constructor(private val clientOptions: ClientOpti .addPathSegments("v1", "view") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { listHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -135,11 +139,12 @@ class ViewServiceImpl internal constructor(private val clientOptions: ClientOpti .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { deleteHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -160,11 +165,12 @@ class ViewServiceImpl internal constructor(private val clientOptions: ClientOpti .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { replaceHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index 02db3575..c9d028ee 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -37,11 +37,12 @@ class MemberServiceImpl internal constructor(private val clientOptions: ClientOp .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { updateHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 62c44a7a..e86556ea 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -40,11 +40,12 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { feedbackHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -69,11 +70,12 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { fetchHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -99,11 +101,12 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { fetchPostHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } @@ -124,11 +127,12 @@ class LogServiceImpl internal constructor(private val clientOptions: ClientOptio .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response .use { insertHandler.handle(it) } .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + if (requestOptions.responseValidation!!) { it.validate() } } From cc8b5a5d66ca1a077e58cbf145e468effbfba2c3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 08:21:50 +0000 Subject: [PATCH 61/87] feat(client): support raw response access (#131) --- braintrust-java-core/build.gradle.kts | 1 + .../api/client/BraintrustClient.kt | 47 ++ .../api/client/BraintrustClientAsync.kt | 49 ++ .../api/client/BraintrustClientAsyncImpl.kt | 124 ++++ .../api/client/BraintrustClientImpl.kt | 124 ++++ .../api/core/http/HttpResponseFor.kt | 23 + .../api/services/async/AclServiceAsync.kt | 87 +++ .../api/services/async/AclServiceAsyncImpl.kt | 368 ++++++----- .../services/async/AiSecretServiceAsync.kt | 100 +++ .../async/AiSecretServiceAsyncImpl.kt | 433 ++++++------ .../api/services/async/ApiKeyServiceAsync.kt | 67 ++ .../services/async/ApiKeyServiceAsyncImpl.kt | 252 ++++--- .../api/services/async/DatasetServiceAsync.kt | 133 ++++ .../services/async/DatasetServiceAsyncImpl.kt | 616 ++++++++++-------- .../api/services/async/EnvVarServiceAsync.kt | 89 +++ .../services/async/EnvVarServiceAsyncImpl.kt | 365 ++++++----- .../api/services/async/EvalServiceAsync.kt | 22 + .../services/async/EvalServiceAsyncImpl.kt | 74 ++- .../services/async/ExperimentServiceAsync.kt | 134 ++++ .../async/ExperimentServiceAsyncImpl.kt | 616 ++++++++++-------- .../services/async/FunctionServiceAsync.kt | 100 +++ .../async/FunctionServiceAsyncImpl.kt | 436 +++++++------ .../api/services/async/GroupServiceAsync.kt | 87 +++ .../services/async/GroupServiceAsyncImpl.kt | 375 ++++++----- .../async/OrganizationServiceAsync.kt | 70 ++ .../async/OrganizationServiceAsyncImpl.kt | 261 +++++--- .../async/ProjectScoreServiceAsync.kt | 90 +++ .../async/ProjectScoreServiceAsyncImpl.kt | 377 ++++++----- .../api/services/async/ProjectServiceAsync.kt | 80 +++ .../services/async/ProjectServiceAsyncImpl.kt | 322 +++++---- .../services/async/ProjectTagServiceAsync.kt | 90 +++ .../async/ProjectTagServiceAsyncImpl.kt | 376 ++++++----- .../api/services/async/PromptServiceAsync.kt | 89 +++ .../services/async/PromptServiceAsyncImpl.kt | 375 ++++++----- .../api/services/async/RoleServiceAsync.kt | 87 +++ .../services/async/RoleServiceAsyncImpl.kt | 375 ++++++----- .../services/async/SpanIframeServiceAsync.kt | 90 +++ .../async/SpanIframeServiceAsyncImpl.kt | 375 ++++++----- .../services/async/TopLevelServiceAsync.kt | 32 + .../async/TopLevelServiceAsyncImpl.kt | 49 +- .../api/services/async/UserServiceAsync.kt | 43 ++ .../services/async/UserServiceAsyncImpl.kt | 133 ++-- .../api/services/async/ViewServiceAsync.kt | 77 +++ .../services/async/ViewServiceAsyncImpl.kt | 375 ++++++----- .../async/organizations/MemberServiceAsync.kt | 34 + .../organizations/MemberServiceAsyncImpl.kt | 68 +- .../async/projects/LogServiceAsync.kt | 55 ++ .../async/projects/LogServiceAsyncImpl.kt | 252 ++++--- .../api/services/blocking/AclService.kt | 85 +++ .../api/services/blocking/AclServiceImpl.kt | 329 ++++++---- .../api/services/blocking/AiSecretService.kt | 96 +++ .../services/blocking/AiSecretServiceImpl.kt | 383 ++++++----- .../api/services/blocking/ApiKeyService.kt | 63 ++ .../services/blocking/ApiKeyServiceImpl.kt | 216 +++--- .../api/services/blocking/DatasetService.kt | 129 ++++ .../services/blocking/DatasetServiceImpl.kt | 550 +++++++++------- .../api/services/blocking/EnvVarService.kt | 85 +++ .../services/blocking/EnvVarServiceImpl.kt | 329 ++++++---- .../api/services/blocking/EvalService.kt | 22 + .../api/services/blocking/EvalServiceImpl.kt | 68 +- .../services/blocking/ExperimentService.kt | 129 ++++ .../blocking/ExperimentServiceImpl.kt | 550 +++++++++------- .../api/services/blocking/FunctionService.kt | 96 +++ .../services/blocking/FunctionServiceImpl.kt | 386 ++++++----- .../api/services/blocking/GroupService.kt | 85 +++ .../api/services/blocking/GroupServiceImpl.kt | 334 ++++++---- .../services/blocking/OrganizationService.kt | 67 ++ .../blocking/OrganizationServiceImpl.kt | 233 ++++--- .../services/blocking/ProjectScoreService.kt | 87 +++ .../blocking/ProjectScoreServiceImpl.kt | 337 +++++----- .../api/services/blocking/ProjectService.kt | 76 +++ .../services/blocking/ProjectServiceImpl.kt | 286 ++++---- .../services/blocking/ProjectTagService.kt | 85 +++ .../blocking/ProjectTagServiceImpl.kt | 334 ++++++---- .../api/services/blocking/PromptService.kt | 85 +++ .../services/blocking/PromptServiceImpl.kt | 335 ++++++---- .../api/services/blocking/RoleService.kt | 85 +++ .../api/services/blocking/RoleServiceImpl.kt | 334 ++++++---- .../services/blocking/SpanIframeService.kt | 85 +++ .../blocking/SpanIframeServiceImpl.kt | 333 ++++++---- .../api/services/blocking/TopLevelService.kt | 30 + .../services/blocking/TopLevelServiceImpl.kt | 45 +- .../api/services/blocking/UserService.kt | 41 ++ .../api/services/blocking/UserServiceImpl.kt | 110 ++-- .../api/services/blocking/ViewService.kt | 77 +++ .../api/services/blocking/ViewServiceImpl.kt | 334 ++++++---- .../blocking/organizations/MemberService.kt | 32 + .../organizations/MemberServiceImpl.kt | 62 +- .../services/blocking/projects/LogService.kt | 55 ++ .../blocking/projects/LogServiceImpl.kt | 228 ++++--- 90 files changed, 11096 insertions(+), 5512 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponseFor.kt diff --git a/braintrust-java-core/build.gradle.kts b/braintrust-java-core/build.gradle.kts index 840fffe3..4d9c5428 100755 --- a/braintrust-java-core/build.gradle.kts +++ b/braintrust-java-core/build.gradle.kts @@ -6,6 +6,7 @@ plugins { dependencies { api("com.fasterxml.jackson.core:jackson-core:2.18.1") api("com.fasterxml.jackson.core:jackson-databind:2.18.1") + api("com.google.errorprone:error_prone_annotations:2.33.0") implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1") diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index e303c335..bc327480 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -46,6 +46,11 @@ interface BraintrustClient { */ fun async(): BraintrustClientAsync + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun topLevel(): TopLevelService fun projects(): ProjectService @@ -96,4 +101,46 @@ interface BraintrustClient { * method. */ fun close() + + /** A view of [BraintrustClient] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun topLevel(): TopLevelService.WithRawResponse + + fun projects(): ProjectService.WithRawResponse + + fun experiments(): ExperimentService.WithRawResponse + + fun datasets(): DatasetService.WithRawResponse + + fun prompts(): PromptService.WithRawResponse + + fun roles(): RoleService.WithRawResponse + + fun groups(): GroupService.WithRawResponse + + fun acls(): AclService.WithRawResponse + + fun users(): UserService.WithRawResponse + + fun projectScores(): ProjectScoreService.WithRawResponse + + fun projectTags(): ProjectTagService.WithRawResponse + + fun spanIframes(): SpanIframeService.WithRawResponse + + fun functions(): FunctionService.WithRawResponse + + fun views(): ViewService.WithRawResponse + + fun organizations(): OrganizationService.WithRawResponse + + fun apiKeys(): ApiKeyService.WithRawResponse + + fun aiSecrets(): AiSecretService.WithRawResponse + + fun envVars(): EnvVarService.WithRawResponse + + fun evals(): EvalService.WithRawResponse + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index c0b9db25..24ed3368 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -46,6 +46,11 @@ interface BraintrustClientAsync { */ fun sync(): BraintrustClient + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun topLevel(): TopLevelServiceAsync fun projects(): ProjectServiceAsync @@ -96,4 +101,48 @@ interface BraintrustClientAsync { * method. */ fun close() + + /** + * A view of [BraintrustClientAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun topLevel(): TopLevelServiceAsync.WithRawResponse + + fun projects(): ProjectServiceAsync.WithRawResponse + + fun experiments(): ExperimentServiceAsync.WithRawResponse + + fun datasets(): DatasetServiceAsync.WithRawResponse + + fun prompts(): PromptServiceAsync.WithRawResponse + + fun roles(): RoleServiceAsync.WithRawResponse + + fun groups(): GroupServiceAsync.WithRawResponse + + fun acls(): AclServiceAsync.WithRawResponse + + fun users(): UserServiceAsync.WithRawResponse + + fun projectScores(): ProjectScoreServiceAsync.WithRawResponse + + fun projectTags(): ProjectTagServiceAsync.WithRawResponse + + fun spanIframes(): SpanIframeServiceAsync.WithRawResponse + + fun functions(): FunctionServiceAsync.WithRawResponse + + fun views(): ViewServiceAsync.WithRawResponse + + fun organizations(): OrganizationServiceAsync.WithRawResponse + + fun apiKeys(): ApiKeyServiceAsync.WithRawResponse + + fun aiSecrets(): AiSecretServiceAsync.WithRawResponse + + fun envVars(): EnvVarServiceAsync.WithRawResponse + + fun evals(): EvalServiceAsync.WithRawResponse + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index fd5d5299..e945466b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -56,6 +56,10 @@ class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : Brai // Pass the original clientOptions so that this client sets its own User-Agent. private val sync: BraintrustClient by lazy { BraintrustClientImpl(clientOptions) } + private val withRawResponse: BraintrustClientAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -124,6 +128,8 @@ class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : Brai override fun sync(): BraintrustClient = sync + override fun withRawResponse(): BraintrustClientAsync.WithRawResponse = withRawResponse + override fun topLevel(): TopLevelServiceAsync = topLevel override fun projects(): ProjectServiceAsync = projects @@ -163,4 +169,122 @@ class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : Brai override fun evals(): EvalServiceAsync = evals override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BraintrustClientAsync.WithRawResponse { + + private val topLevel: TopLevelServiceAsync.WithRawResponse by lazy { + TopLevelServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val projects: ProjectServiceAsync.WithRawResponse by lazy { + ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val experiments: ExperimentServiceAsync.WithRawResponse by lazy { + ExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetServiceAsync.WithRawResponse by lazy { + DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val prompts: PromptServiceAsync.WithRawResponse by lazy { + PromptServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val roles: RoleServiceAsync.WithRawResponse by lazy { + RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val groups: GroupServiceAsync.WithRawResponse by lazy { + GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val acls: AclServiceAsync.WithRawResponse by lazy { + AclServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val users: UserServiceAsync.WithRawResponse by lazy { + UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val projectScores: ProjectScoreServiceAsync.WithRawResponse by lazy { + ProjectScoreServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val projectTags: ProjectTagServiceAsync.WithRawResponse by lazy { + ProjectTagServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val spanIframes: SpanIframeServiceAsync.WithRawResponse by lazy { + SpanIframeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val functions: FunctionServiceAsync.WithRawResponse by lazy { + FunctionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val views: ViewServiceAsync.WithRawResponse by lazy { + ViewServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val organizations: OrganizationServiceAsync.WithRawResponse by lazy { + OrganizationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val apiKeys: ApiKeyServiceAsync.WithRawResponse by lazy { + ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val aiSecrets: AiSecretServiceAsync.WithRawResponse by lazy { + AiSecretServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val envVars: EnvVarServiceAsync.WithRawResponse by lazy { + EnvVarServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val evals: EvalServiceAsync.WithRawResponse by lazy { + EvalServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel + + override fun projects(): ProjectServiceAsync.WithRawResponse = projects + + override fun experiments(): ExperimentServiceAsync.WithRawResponse = experiments + + override fun datasets(): DatasetServiceAsync.WithRawResponse = datasets + + override fun prompts(): PromptServiceAsync.WithRawResponse = prompts + + override fun roles(): RoleServiceAsync.WithRawResponse = roles + + override fun groups(): GroupServiceAsync.WithRawResponse = groups + + override fun acls(): AclServiceAsync.WithRawResponse = acls + + override fun users(): UserServiceAsync.WithRawResponse = users + + override fun projectScores(): ProjectScoreServiceAsync.WithRawResponse = projectScores + + override fun projectTags(): ProjectTagServiceAsync.WithRawResponse = projectTags + + override fun spanIframes(): SpanIframeServiceAsync.WithRawResponse = spanIframes + + override fun functions(): FunctionServiceAsync.WithRawResponse = functions + + override fun views(): ViewServiceAsync.WithRawResponse = views + + override fun organizations(): OrganizationServiceAsync.WithRawResponse = organizations + + override fun apiKeys(): ApiKeyServiceAsync.WithRawResponse = apiKeys + + override fun aiSecrets(): AiSecretServiceAsync.WithRawResponse = aiSecrets + + override fun envVars(): EnvVarServiceAsync.WithRawResponse = envVars + + override fun evals(): EvalServiceAsync.WithRawResponse = evals + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index e0b76da7..3eecd3cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -56,6 +56,10 @@ class BraintrustClientImpl(private val clientOptions: ClientOptions) : Braintrus // Pass the original clientOptions so that this client sets its own User-Agent. private val async: BraintrustClientAsync by lazy { BraintrustClientAsyncImpl(clientOptions) } + private val withRawResponse: BraintrustClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptionsWithUserAgent) } @@ -112,6 +116,8 @@ class BraintrustClientImpl(private val clientOptions: ClientOptions) : Braintrus override fun async(): BraintrustClientAsync = async + override fun withRawResponse(): BraintrustClient.WithRawResponse = withRawResponse + override fun topLevel(): TopLevelService = topLevel override fun projects(): ProjectService = projects @@ -151,4 +157,122 @@ class BraintrustClientImpl(private val clientOptions: ClientOptions) : Braintrus override fun evals(): EvalService = evals override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BraintrustClient.WithRawResponse { + + private val topLevel: TopLevelService.WithRawResponse by lazy { + TopLevelServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val projects: ProjectService.WithRawResponse by lazy { + ProjectServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val experiments: ExperimentService.WithRawResponse by lazy { + ExperimentServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val datasets: DatasetService.WithRawResponse by lazy { + DatasetServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val prompts: PromptService.WithRawResponse by lazy { + PromptServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val roles: RoleService.WithRawResponse by lazy { + RoleServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val groups: GroupService.WithRawResponse by lazy { + GroupServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val acls: AclService.WithRawResponse by lazy { + AclServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val users: UserService.WithRawResponse by lazy { + UserServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val projectScores: ProjectScoreService.WithRawResponse by lazy { + ProjectScoreServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val projectTags: ProjectTagService.WithRawResponse by lazy { + ProjectTagServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val spanIframes: SpanIframeService.WithRawResponse by lazy { + SpanIframeServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val functions: FunctionService.WithRawResponse by lazy { + FunctionServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val views: ViewService.WithRawResponse by lazy { + ViewServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val organizations: OrganizationService.WithRawResponse by lazy { + OrganizationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val apiKeys: ApiKeyService.WithRawResponse by lazy { + ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val aiSecrets: AiSecretService.WithRawResponse by lazy { + AiSecretServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val envVars: EnvVarService.WithRawResponse by lazy { + EnvVarServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val evals: EvalService.WithRawResponse by lazy { + EvalServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun topLevel(): TopLevelService.WithRawResponse = topLevel + + override fun projects(): ProjectService.WithRawResponse = projects + + override fun experiments(): ExperimentService.WithRawResponse = experiments + + override fun datasets(): DatasetService.WithRawResponse = datasets + + override fun prompts(): PromptService.WithRawResponse = prompts + + override fun roles(): RoleService.WithRawResponse = roles + + override fun groups(): GroupService.WithRawResponse = groups + + override fun acls(): AclService.WithRawResponse = acls + + override fun users(): UserService.WithRawResponse = users + + override fun projectScores(): ProjectScoreService.WithRawResponse = projectScores + + override fun projectTags(): ProjectTagService.WithRawResponse = projectTags + + override fun spanIframes(): SpanIframeService.WithRawResponse = spanIframes + + override fun functions(): FunctionService.WithRawResponse = functions + + override fun views(): ViewService.WithRawResponse = views + + override fun organizations(): OrganizationService.WithRawResponse = organizations + + override fun apiKeys(): ApiKeyService.WithRawResponse = apiKeys + + override fun aiSecrets(): AiSecretService.WithRawResponse = aiSecrets + + override fun envVars(): EnvVarService.WithRawResponse = envVars + + override fun evals(): EvalService.WithRawResponse = evals + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponseFor.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponseFor.kt new file mode 100644 index 00000000..6cb31fa8 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpResponseFor.kt @@ -0,0 +1,23 @@ +package com.braintrustdata.api.core.http + +import java.io.InputStream + +interface HttpResponseFor : HttpResponse { + + fun parse(): T +} + +@JvmSynthetic +internal fun HttpResponse.parseable(parse: () -> T): HttpResponseFor = + object : HttpResponseFor { + + override fun parse(): T = parse() + + override fun statusCode(): Int = this@parseable.statusCode() + + override fun headers(): Headers = this@parseable.headers() + + override fun body(): InputStream = this@parseable.body() + + override fun close() = this@parseable.close() + } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index dc199615..3ad05814 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclBatchUpdateParams import com.braintrustdata.api.models.AclBatchUpdateResponse @@ -14,10 +15,16 @@ import com.braintrustdata.api.models.AclFindAndDeleteParams import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface AclServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new acl. If there is an existing acl with the same contents as the one specified in * the request, will return the existing acl unmodified @@ -75,4 +82,84 @@ interface AclServiceAsync { params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** A view of [AclServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/acl`, but is otherwise the same as + * [AclServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: AclCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as + * [AclServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as + * [AclServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: AclListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as + * [AclServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as + * [AclServiceAsync.batchUpdate]. + */ + @JvmOverloads + @MustBeClosed + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as + * [AclServiceAsync.batchUpdate]. + */ + @MustBeClosed + fun batchUpdate( + requestOptions: RequestOptions + ): CompletableFuture> = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as + * [AclServiceAsync.findAndDelete]. + */ + @JvmOverloads + @MustBeClosed + fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 8b587da2..72bda297 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -27,188 +29,240 @@ import java.util.concurrent.CompletableFuture class AclServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AclServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AclServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): AclServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified - */ override fun create( params: AclCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/acl + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an acl object by its id */ override fun retrieve( params: AclRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/acl/{acl_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first - */ override fun list( params: AclListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { AclListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/acl + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an acl object by its id */ override fun delete( params: AclDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // delete /v1/acl/{acl_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. - */ override fun batchUpdate( params: AclBatchUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /v1/acl/batch-update + withRawResponse().batchUpdate(params, requestOptions).thenApply { it.parse() } - /** Delete a single acl */ override fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // delete /v1/acl + withRawResponse().findAndDelete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AclServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: AclCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AclListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AclListPageAsync.of(AclServiceAsyncImpl(clientOptions), params, it) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val batchUpdateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch-update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { batchUpdateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val findAndDeleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt index b95bfd1b..6cd0cd07 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams @@ -14,10 +15,16 @@ import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface AiSecretServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new ai_secret. If there is an existing ai_secret with the same name as the one * specified in the request, will return the existing ai_secret unmodified @@ -86,4 +93,97 @@ interface AiSecretServiceAsync { params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [AiSecretServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the + * same as [AiSecretServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise + * the same as [AiSecretServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: AiSecretListParams = AiSecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(AiSecretListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise + * the same as [AiSecretServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.findAndDelete]. + */ + @JvmOverloads + @MustBeClosed + fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index b16cf183..09ca49bc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -27,221 +29,280 @@ import java.util.concurrent.CompletableFuture class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AiSecretServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AiSecretServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): AiSecretServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will return the existing ai_secret unmodified - */ override fun create( params: AiSecretCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/ai_secret + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an ai_secret object by its id */ override fun retrieve( params: AiSecretRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/ai_secret/{ai_secret_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update an ai_secret object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: AiSecretUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/ai_secret/{ai_secret_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first - */ override fun list( params: AiSecretListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { AiSecretListPageAsync.of(this, params, it) } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/ai_secret + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - /** Delete an ai_secret object by its id */ override fun delete( params: AiSecretDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/ai_secret/{ai_secret_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** Delete a single ai_secret */ override fun findAndDelete( params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/ai_secret + withRawResponse().findAndDelete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will replace the existing ai_secret with the provided fields - */ override fun replace( params: AiSecretReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/ai_secret + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AiSecretServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AiSecretListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AiSecretListPageAsync.of( + AiSecretServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val findAndDeleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index 397e0d30..fde34650 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams @@ -12,10 +13,16 @@ import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface ApiKeyServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new api_key. It is possible to have multiple API keys with the same name. There is * no de-duplication @@ -56,4 +63,64 @@ interface ApiKeyServiceAsync { params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/api_key`, but is otherwise the same as + * [ApiKeyServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same + * as [ApiKeyServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as + * [ApiKeyServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ApiKeyListParams = ApiKeyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as + * [ApiKeyServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ApiKeyListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the + * same as [ApiKeyServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index 3a55e189..f92c27e3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -25,127 +27,169 @@ import java.util.concurrent.CompletableFuture class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ApiKeyServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ApiKeyServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication - */ override fun create( params: ApiKeyCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/api_key + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an api_key object by its id */ override fun retrieve( params: ApiKeyRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/api_key/{api_key_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first - */ override fun list( params: ApiKeyListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ApiKeyListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/api_key + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an api_key object by its id */ override fun delete( params: ApiKeyDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // delete /v1/api_key/{api_key_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ApiKeyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ApiKeyListPageAsync.of( + ApiKeyServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index 5be2b336..c415943b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -21,10 +22,16 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface DatasetServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new dataset. If there is an existing dataset in the project with the same name as * the one specified in the request, will return the existing dataset unmodified @@ -119,4 +126,130 @@ interface DatasetServiceAsync { params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/dataset`, but is otherwise the same as + * [DatasetServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same + * as [DatasetServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the + * same as [DatasetServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as + * [DatasetServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as + * [DatasetServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(DatasetListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the + * same as [DatasetServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is + * otherwise the same as [DatasetServiceAsync.feedback]. + */ + @JvmOverloads + @MustBeClosed + fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise + * the same as [DatasetServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise + * the same as [DatasetServiceAsync.fetchPost]. + */ + @JvmOverloads + @MustBeClosed + fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise + * the same as [DatasetServiceAsync.insert]. + */ + @JvmOverloads + @MustBeClosed + fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is + * otherwise the same as [DatasetServiceAsync.summarize]. + */ + @JvmOverloads + @MustBeClosed + fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index f55b0239..dddb4cb4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -34,314 +36,394 @@ import java.util.concurrent.CompletableFuture class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DatasetServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): DatasetServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified - */ override fun create( params: DatasetCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /v1/dataset + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - /** Get a dataset object by its id */ override fun retrieve( params: DatasetRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/dataset/{dataset_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a dataset object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: DatasetUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // patch /v1/dataset/{dataset_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - /** - * List out all datasets. The datasets are sorted by creation date, with the most - * recently-created datasets coming first - */ override fun list( params: DatasetListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { DatasetListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/dataset + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a dataset object by its id */ override fun delete( params: DatasetDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // delete /v1/dataset/{dataset_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Log feedback for a set of dataset events */ override fun feedback( params: DatasetFeedbackParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // post /v1/dataset/{dataset_id}/feedback + withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetch( params: DatasetFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/dataset/{dataset_id}/fetch + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetchPost( params: DatasetFetchPostParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /v1/dataset/{dataset_id}/fetch + withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - /** Insert a set of events into the dataset */ override fun insert( params: DatasetInsertParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/dataset/{dataset_id}/insert + withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Summarize dataset */ override fun summarize( params: DatasetSummarizeParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // get /v1/dataset/{dataset_id}/summarize + withRawResponse().summarize(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DatasetListPageAsync.of( + DatasetServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt index 04fbcd40..9a8d57ff 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.EnvVar import com.braintrustdata.api.models.EnvVarCreateParams import com.braintrustdata.api.models.EnvVarDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.EnvVarListResponse import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface EnvVarServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new env_var. If there is an existing env_var with the same name as the one specified * in the request, will return the existing env_var unmodified @@ -78,4 +85,86 @@ interface EnvVarServiceAsync { params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [EnvVarServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/env_var`, but is otherwise the same as + * [EnvVarServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same + * as [EnvVarServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the + * same as [EnvVarServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as + * [EnvVarServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: EnvVarListParams = EnvVarListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as + * [EnvVarServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(EnvVarListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the + * same as [EnvVarServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as + * [EnvVarServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index f984adc7..de39c4c8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,190 +28,235 @@ import java.util.concurrent.CompletableFuture class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EnvVarServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: EnvVarServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): EnvVarServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new env_var. If there is an existing env_var with the same name as the one specified - * in the request, will return the existing env_var unmodified - */ override fun create( params: EnvVarCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/env_var + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an env_var object by its id */ override fun retrieve( params: EnvVarRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/env_var/{env_var_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update an env_var object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: EnvVarUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/env_var/{env_var_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * List out all env_vars. The env_vars are sorted by creation date, with the most - * recently-created env_vars coming first - */ override fun list( params: EnvVarListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/env_var + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an env_var object by its id */ override fun delete( params: EnvVarDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/env_var/{env_var_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace env_var. If there is an existing env_var with the same name as the one - * specified in the request, will replace the existing env_var with the provided fields - */ override fun replace( params: EnvVarReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/env_var + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EnvVarServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list( + params: EnvVarListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt index 0945abee..26b58d6f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt @@ -5,12 +5,19 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface EvalServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and @@ -23,4 +30,19 @@ interface EvalServiceAsync { params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** A view of [EvalServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/eval`, but is otherwise the same as + * [EvalServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: EvalCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index 95d4f10d..01666bf8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -20,41 +22,53 @@ import java.util.concurrent.CompletableFuture class EvalServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EvalServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: EvalServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): EvalServiceAsync.WithRawResponse = withRawResponse - /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into - * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and - * scoring functions. The API will then run the evaluation, create an experiment, and return the - * results along with a link to the experiment. To learn more about evals, see the - * [Evals guide](https://www.braintrust.dev/docs/guides/evals). - */ override fun create( params: EvalCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "eval") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // post /v1/eval + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EvalServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: EvalCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "eval") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index a5288a1f..a4566fea 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -21,10 +22,16 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface ExperimentServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new experiment. If there is an existing experiment in the project with the same name * as the one specified in the request, will return the existing experiment unmodified @@ -119,4 +126,131 @@ interface ExperimentServiceAsync { params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [ExperimentServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as + * [ExperimentServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as + * [ExperimentServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ExperimentListParams = ExperimentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as + * [ExperimentServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ExperimentListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is + * otherwise the same as [ExperimentServiceAsync.feedback]. + */ + @JvmOverloads + @MustBeClosed + fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is + * otherwise the same as [ExperimentServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is + * otherwise the same as [ExperimentServiceAsync.fetchPost]. + */ + @JvmOverloads + @MustBeClosed + fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is + * otherwise the same as [ExperimentServiceAsync.insert]. + */ + @JvmOverloads + @MustBeClosed + fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is + * otherwise the same as [ExperimentServiceAsync.summarize]. + */ + @JvmOverloads + @MustBeClosed + fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 1e36bfcd..5b558c55 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -34,314 +36,394 @@ import java.util.concurrent.CompletableFuture class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExperimentServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ExperimentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ExperimentServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new experiment. If there is an existing experiment in the project with the same name - * as the one specified in the request, will return the existing experiment unmodified - */ override fun create( params: ExperimentCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /v1/experiment + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - /** Get an experiment object by its id */ override fun retrieve( params: ExperimentRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/experiment/{experiment_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: ExperimentUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // patch /v1/experiment/{experiment_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first - */ override fun list( params: ExperimentListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ExperimentListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/experiment + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an experiment object by its id */ override fun delete( params: ExperimentDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // delete /v1/experiment/{experiment_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Log feedback for a set of experiment events */ override fun feedback( params: ExperimentFeedbackParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // post /v1/experiment/{experiment_id}/feedback + withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetch( params: ExperimentFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/experiment/{experiment_id}/fetch + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetchPost( params: ExperimentFetchPostParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /v1/experiment/{experiment_id}/fetch + withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/experiment/{experiment_id}/insert + withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Summarize experiment */ override fun summarize( params: ExperimentSummarizeParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // get /v1/experiment/{experiment_id}/summarize + withRawResponse().summarize(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ExperimentListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ExperimentListPageAsync.of( + ExperimentServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index edc8770a..503ca793 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams @@ -15,11 +16,17 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.Optional import java.util.concurrent.CompletableFuture interface FunctionServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new function. If there is an existing function in the project with the same slug as * the one specified in the request, will return the existing function unmodified @@ -89,4 +96,97 @@ interface FunctionServiceAsync { params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [FunctionServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as + * [FunctionServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the + * same as [FunctionServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the + * same as [FunctionServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as + * [FunctionServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: FunctionListParams = FunctionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as + * [FunctionServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(FunctionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the + * same as [FunctionServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is + * otherwise the same as [FunctionServiceAsync.invoke]. + */ + @JvmOverloads + @MustBeClosed + fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** + * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as + * [FunctionServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index f3edf664..926c1de4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -29,223 +31,281 @@ import java.util.concurrent.CompletableFuture class FunctionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : FunctionServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: FunctionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): FunctionServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified - */ override fun create( params: FunctionCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/function + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a function object by its id */ override fun retrieve( params: FunctionRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/function/{function_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a function object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: FunctionUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/function/{function_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all functions. The functions are sorted by creation date, with the most - * recently-created functions coming first - */ override fun list( params: FunctionListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { FunctionListPageAsync.of(this, params, it) } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/function + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - /** Delete a function object by its id */ override fun delete( params: FunctionDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val invokeHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/function/{function_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** Invoke a function. */ override fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { invokeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture> = + // post /v1/function/{function_id}/invoke + withRawResponse().invoke(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace function. If there is an existing function in the project with the same - * slug as the one specified in the request, will replace the existing function with the - * provided fields - */ override fun replace( params: FunctionReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/function + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FunctionServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: FunctionListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + FunctionListPageAsync.of( + FunctionServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val invokeHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function", params.getPathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { invokeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index 28f3e023..dbe777cc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface GroupServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new group. If there is an existing group with the same name as the one specified in * the request, will return the existing group unmodified @@ -78,4 +85,84 @@ interface GroupServiceAsync { params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** A view of [GroupServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/group`, but is otherwise the same as + * [GroupServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as + * [GroupServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same + * as [GroupServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as + * [GroupServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: GroupListParams = GroupListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as + * [GroupServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(GroupListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same + * as [GroupServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as + * [GroupServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index 24bdd0c6..a7a33d1e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,192 +28,243 @@ import java.util.concurrent.CompletableFuture class GroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : GroupServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): GroupServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified - */ override fun create( params: GroupCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/group + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a group object by its id */ override fun retrieve( params: GroupRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/group/{group_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. - */ override fun update( params: GroupUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/group/{group_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first - */ override fun list( params: GroupListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { GroupListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/group + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a group object by its id */ override fun delete( params: GroupDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/group/{group_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace group. If there is an existing group with the same name as the one - * specified in the request, will replace the existing group with the provided fields - */ override fun replace( params: GroupReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/group + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + GroupServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: GroupListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + GroupListPageAsync.of( + GroupServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index 25556b38..7306e462 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPageAsync @@ -12,10 +13,16 @@ import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import com.braintrustdata.api.services.async.organizations.MemberServiceAsync +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface OrganizationServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun members(): MemberServiceAsync /** Get an organization object by its id */ @@ -59,4 +66,67 @@ interface OrganizationServiceAsync { params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [OrganizationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + fun members(): MemberServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as + * [OrganizationServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: OrganizationListParams = OrganizationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as + * [OrganizationServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(OrganizationListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 8cd52acd..6d5ca420 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,132 +28,179 @@ import java.util.concurrent.CompletableFuture class OrganizationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : OrganizationServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: OrganizationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val members: MemberServiceAsync by lazy { MemberServiceAsyncImpl(clientOptions) } - override fun members(): MemberServiceAsync = members + override fun withRawResponse(): OrganizationServiceAsync.WithRawResponse = withRawResponse - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun members(): MemberServiceAsync = members - /** Get an organization object by its id */ override fun retrieve( params: OrganizationRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/organization/{organization_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update an organization object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: OrganizationUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // patch /v1/organization/{organization_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first - */ override fun list( params: OrganizationListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { OrganizationListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/organization + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an organization object by its id */ override fun delete( params: OrganizationDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // delete /v1/organization/{organization_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrganizationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val members: MemberServiceAsync.WithRawResponse by lazy { + MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun members(): MemberServiceAsync.WithRawResponse = members + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: OrganizationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + OrganizationListPageAsync.of( + OrganizationServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index e4e69909..45be3a4c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface ProjectScoreServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new project_score. If there is an existing project_score in the project with the * same name as the one specified in the request, will return the existing project_score @@ -80,4 +87,87 @@ interface ProjectScoreServiceAsync { params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [ProjectScoreServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as + * [ProjectScoreServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as + * [ProjectScoreServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as + * [ProjectScoreServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ProjectScoreListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as + * [ProjectScoreServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index 98e631a1..b79fafae 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,194 +28,243 @@ import java.util.concurrent.CompletableFuture class ProjectScoreServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ProjectScoreServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ProjectScoreServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ProjectScoreServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new project_score. If there is an existing project_score in the project with the - * same name as the one specified in the request, will return the existing project_score - * unmodified - */ override fun create( params: ProjectScoreCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/project_score + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a project_score object by its id */ override fun retrieve( params: ProjectScoreRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/project_score/{project_score_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: ProjectScoreUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/project_score/{project_score_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first - */ override fun list( params: ProjectScoreListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectScoreListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/project_score + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a project_score object by its id */ override fun delete( params: ProjectScoreDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/project_score/{project_score_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace project_score. If there is an existing project_score in the project with - * the same name as the one specified in the request, will replace the existing project_score - * with the provided fields - */ override fun replace( params: ProjectScoreReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/project_score + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectScoreServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectScoreListPageAsync.of( + ProjectScoreServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index 2e66d3cd..33de4a97 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams import com.braintrustdata.api.services.async.projects.LogServiceAsync +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface ProjectServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun logs(): LogServiceAsync /** @@ -70,4 +77,77 @@ interface ProjectServiceAsync { params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [ProjectServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun logs(): LogServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/project`, but is otherwise the same as + * [ProjectServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same + * as [ProjectServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the + * same as [ProjectServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as + * [ProjectServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as + * [ProjectServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ProjectListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the + * same as [ProjectServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index 2ad16227..bbe1261b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -27,164 +29,216 @@ import java.util.concurrent.CompletableFuture class ProjectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ProjectServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ProjectServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val logs: LogServiceAsync by lazy { LogServiceAsyncImpl(clientOptions) } - override fun logs(): LogServiceAsync = logs + override fun withRawResponse(): ProjectServiceAsync.WithRawResponse = withRawResponse - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun logs(): LogServiceAsync = logs - /** - * Create a new project. If there is an existing project with the same name as the one specified - * in the request, will return the existing project unmodified - */ override fun create( params: ProjectCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/project + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a project object by its id */ override fun retrieve( params: ProjectRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/project/{project_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a project object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: ProjectUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // patch /v1/project/{project_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - /** - * List out all projects. The projects are sorted by creation date, with the most - * recently-created projects coming first - */ override fun list( params: ProjectListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectListPageAsync.of(this, params, it) } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/project + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - /** Delete a project object by its id */ override fun delete( params: ProjectDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // delete /v1/project/{project_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val logs: LogServiceAsync.WithRawResponse by lazy { + LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun logs(): LogServiceAsync.WithRawResponse = logs + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectListPageAsync.of( + ProjectServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index dea1315f..487570f1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface ProjectTagServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new project_tag. If there is an existing project_tag in the project with the same * name as the one specified in the request, will return the existing project_tag unmodified @@ -79,4 +86,87 @@ interface ProjectTagServiceAsync { params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [ProjectTagServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as + * [ProjectTagServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise + * the same as [ProjectTagServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as + * [ProjectTagServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ProjectTagListParams = ProjectTagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as + * [ProjectTagServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ProjectTagListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as + * [ProjectTagServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index 8de12f82..cc6de7ff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,193 +28,243 @@ import java.util.concurrent.CompletableFuture class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ProjectTagServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ProjectTagServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ProjectTagServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will return the existing project_tag unmodified - */ override fun create( params: ProjectTagCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/project_tag + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a project_tag object by its id */ override fun retrieve( params: ProjectTagRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/project_tag/{project_tag_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: ProjectTagUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/project_tag/{project_tag_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first - */ override fun list( params: ProjectTagListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectTagListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/project_tag + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a project_tag object by its id */ override fun delete( params: ProjectTagDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/project_tag/{project_tag_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace project_tag. If there is an existing project_tag in the project with the - * same name as the one specified in the request, will replace the existing project_tag with the - * provided fields - */ override fun replace( params: ProjectTagReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/project_tag + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectTagServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectTagListPageAsync.of( + ProjectTagServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index 89dd34e0..7ccef6e9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface PromptServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new prompt. If there is an existing prompt in the project with the same slug as the * one specified in the request, will return the existing prompt unmodified @@ -78,4 +85,86 @@ interface PromptServiceAsync { params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [PromptServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/prompt`, but is otherwise the same as + * [PromptServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: PromptCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same + * as [PromptServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same + * as [PromptServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as + * [PromptServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: PromptListParams = PromptListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as + * [PromptServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(PromptListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the + * same as [PromptServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as + * [PromptServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 1f9425c8..a391785d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,192 +28,243 @@ import java.util.concurrent.CompletableFuture class PromptServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PromptServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: PromptServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): PromptServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified - */ override fun create( params: PromptCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/prompt + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a prompt object by its id */ override fun retrieve( params: PromptRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/prompt/{prompt_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update a prompt object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: PromptUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/prompt/{prompt_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first - */ override fun list( params: PromptListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { PromptListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/prompt + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a prompt object by its id */ override fun delete( params: PromptDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/prompt/{prompt_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as - * the one specified in the request, will replace the existing prompt with the provided fields - */ override fun replace( params: PromptReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/prompt + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PromptServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: PromptCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: PromptListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + PromptListPageAsync.of( + PromptServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index 19a197a6..7ed61a5e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface RoleServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new role. If there is an existing role with the same name as the one specified in * the request, will return the existing role unmodified @@ -78,4 +85,84 @@ interface RoleServiceAsync { params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** A view of [RoleServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/role`, but is otherwise the same as + * [RoleServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as + * [RoleServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as + * [RoleServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as + * [RoleServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as + * [RoleServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(RoleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as + * [RoleServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as + * [RoleServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index 557d8245..80186773 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,192 +28,243 @@ import java.util.concurrent.CompletableFuture class RoleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RoleServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): RoleServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified - */ override fun create( params: RoleCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/role + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a role object by its id */ override fun retrieve( params: RoleRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/role/{role_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. - */ override fun update( params: RoleUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/role/{role_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all roles. The roles are sorted by creation date, with the most recently-created - * roles coming first - */ override fun list( params: RoleListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { RoleListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/role + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a role object by its id */ override fun delete( params: RoleDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/role/{role_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace role. If there is an existing role with the same name as the one specified - * in the request, will replace the existing role with the provided fields - */ override fun replace( params: RoleReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/role + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoleServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoleListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + RoleListPageAsync.of( + RoleServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt index 65c97e12..d1d9f896 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.SpanIFrame import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface SpanIframeServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new span_iframe. If there is an existing span_iframe with the same name as the one * specified in the request, will return the existing span_iframe unmodified @@ -78,4 +85,87 @@ interface SpanIframeServiceAsync { params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [SpanIframeServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as + * [SpanIframeServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise + * the same as [SpanIframeServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as + * [SpanIframeServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: SpanIframeListParams = SpanIframeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as + * [SpanIframeServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(SpanIframeListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as + * [SpanIframeServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt index 35b8dac4..b69e4def 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,192 +28,243 @@ import java.util.concurrent.CompletableFuture class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SpanIframeServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SpanIframeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): SpanIframeServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will return the existing span_iframe unmodified - */ override fun create( params: SpanIframeCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/span_iframe + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a span_iframe object by its id */ override fun retrieve( params: SpanIframeRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/span_iframe/{span_iframe_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update a span_iframe object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: SpanIframeUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/span_iframe/{span_iframe_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first - */ override fun list( params: SpanIframeListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { SpanIframeListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/span_iframe + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a span_iframe object by its id */ override fun delete( params: SpanIframeDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/span_iframe/{span_iframe_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace span_iframe. If there is an existing span_iframe with the same name as the - * one specified in the request, will replace the existing span_iframe with the provided fields - */ override fun replace( params: SpanIframeReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/span_iframe + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SpanIframeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SpanIframeListPageAsync.of( + SpanIframeServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index aef9b83f..7e84352b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -5,11 +5,18 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.TopLevelHelloWorldParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface TopLevelServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ @JvmOverloads fun helloWorld( @@ -20,4 +27,29 @@ interface TopLevelServiceAsync { /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ fun helloWorld(requestOptions: RequestOptions): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + + /** + * A view of [TopLevelServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /v1`, but is otherwise the same as + * [TopLevelServiceAsync.helloWorld]. + */ + @JvmOverloads + @MustBeClosed + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1`, but is otherwise the same as + * [TopLevelServiceAsync.helloWorld]. + */ + @MustBeClosed + fun helloWorld(requestOptions: RequestOptions): CompletableFuture> = + helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index 16a8992a..efc7d4ce 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams @@ -18,24 +20,43 @@ import java.util.concurrent.CompletableFuture class TopLevelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TopLevelServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TopLevelServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) + override fun withRawResponse(): TopLevelServiceAsync.WithRawResponse = withRawResponse - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ override fun helloWorld( params: TopLevelHelloWorldParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> response.use { helloWorldHandler.handle(it) } } + ): CompletableFuture = + // get /v1 + withRawResponse().helloWorld(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val helloWorldHandler: Handler = + stringHandler().withErrorHandler(errorHandler) + + override fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { response.use { helloWorldHandler.handle(it) } } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index d285bf3f..2da46b60 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -5,14 +5,21 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPageAsync import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface UserServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get a user object by its id */ @JvmOverloads fun retrieve( @@ -36,4 +43,40 @@ interface UserServiceAsync { */ fun list(requestOptions: RequestOptions): CompletableFuture = list(UserListParams.none(), requestOptions) + + /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as + * [UserServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as + * [UserServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: UserListParams = UserListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as + * [UserServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(UserListParams.none(), requestOptions) + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index b35e24b0..54c73c41 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.User @@ -21,66 +23,95 @@ import java.util.concurrent.CompletableFuture class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : UserServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): UserServiceAsync.WithRawResponse = withRawResponse - /** Get a user object by its id */ override fun retrieve( params: UserRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/user/{user_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all users. The users are sorted by creation date, with the most recently-created - * users coming first - */ override fun list( params: UserListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // get /v1/user + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UserServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: UserListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + UserListPageAsync.of( + UserServiceAsyncImpl(clientOptions), + params, + it, + ) + } } - .let { UserListPageAsync.of(this, params, it) } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index 24c13d8f..f3615339 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -13,10 +14,16 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface ViewServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new view. If there is an existing view with the same name as the one specified in * the request, will return the existing view unmodified @@ -71,4 +78,74 @@ interface ViewServiceAsync { params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** A view of [ViewServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/view`, but is otherwise the same as + * [ViewServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as + * [ViewServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as + * [ViewServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as + * [ViewServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as + * [ViewServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as + * [ViewServiceAsync.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 1de11874..424ddc4d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -26,192 +28,243 @@ import java.util.concurrent.CompletableFuture class ViewServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ViewServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ViewServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ViewServiceAsync.WithRawResponse = withRawResponse - /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified - */ override fun create( params: ViewCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/view + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a view object by its id */ override fun retrieve( params: ViewRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /v1/view/{view_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. - */ override fun update( params: ViewUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // patch /v1/view/{view_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all views. The views are sorted by creation date, with the most recently-created - * views coming first - */ override fun list( params: ViewListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ViewListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /v1/view + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a view object by its id */ override fun delete( params: ViewDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /v1/view/{view_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - /** - * Create or replace view. If there is an existing view with the same name as the one specified - * in the request, will replace the existing view with the provided fields - */ override fun replace( params: ViewReplaceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // put /v1/view + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ViewServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ViewListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ViewListPageAsync.of( + ViewServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt index 74e603fc..cf80d652 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -5,12 +5,19 @@ package com.braintrustdata.api.services.async.organizations import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface MemberServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Modify organization membership */ @JvmOverloads fun update( @@ -21,4 +28,31 @@ interface MemberServiceAsync { /** Modify organization membership */ fun update(requestOptions: RequestOptions): CompletableFuture = update(OrganizationMemberUpdateParams.none(), requestOptions) + + /** + * A view of [MemberServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the + * same as [MemberServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the + * same as [MemberServiceAsync.update]. + */ + @MustBeClosed + fun update( + requestOptions: RequestOptions + ): CompletableFuture> = + update(OrganizationMemberUpdateParams.none(), requestOptions) + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 416ac512..2731fa30 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -20,35 +22,53 @@ import java.util.concurrent.CompletableFuture class MemberServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MemberServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): MemberServiceAsync.WithRawResponse = withRawResponse - /** Modify organization membership */ override fun update( params: OrganizationMemberUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // patch /v1/organization/members + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index 943bd6d8..6d9e1663 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse import com.braintrustdata.api.models.InsertEventsResponse @@ -12,10 +13,16 @@ import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.google.errorprone.annotations.MustBeClosed import java.util.concurrent.CompletableFuture interface LogServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Log feedback for a set of project logs events */ @JvmOverloads fun feedback( @@ -51,4 +58,52 @@ interface LogServiceAsync { params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** A view of [LogServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is + * otherwise the same as [LogServiceAsync.feedback]. + */ + @JvmOverloads + @MustBeClosed + fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is + * otherwise the same as [LogServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is + * otherwise the same as [LogServiceAsync.fetchPost]. + */ + @JvmOverloads + @MustBeClosed + fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is + * otherwise the same as [LogServiceAsync.insert]. + */ + @JvmOverloads + @MustBeClosed + fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 8dce635c..ed3de639 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError @@ -25,130 +27,166 @@ import java.util.concurrent.CompletableFuture class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LogServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): LogServiceAsync.WithRawResponse = withRawResponse - /** Log feedback for a set of project logs events */ override fun feedback( params: ProjectLogFeedbackParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/project_logs/{project_id}/feedback + withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. - */ override fun fetch( params: ProjectLogFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /v1/project_logs/{project_id}/fetch + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetchPost( params: ProjectLogFetchPostParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /v1/project_logs/{project_id}/fetch + withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CompletableFuture = + // post /v1/project_logs/{project_id}/insert + withRawResponse().insert(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LogServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index be830936..5d570404 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclBatchUpdateParams import com.braintrustdata.api.models.AclBatchUpdateResponse @@ -14,9 +15,15 @@ import com.braintrustdata.api.models.AclFindAndDeleteParams import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams +import com.google.errorprone.annotations.MustBeClosed interface AclService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new acl. If there is an existing acl with the same contents as the one specified in * the request, will return the existing acl unmodified @@ -68,4 +75,82 @@ interface AclService { params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): Acl + + /** A view of [AclService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/acl`, but is otherwise the same as + * [AclService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: AclCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as + * [AclService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as + * [AclService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: AclListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as + * [AclService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as + * [AclService.batchUpdate]. + */ + @JvmOverloads + @MustBeClosed + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as + * [AclService.batchUpdate]. + */ + @MustBeClosed + fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as + * [AclService.findAndDelete]. + */ + @JvmOverloads + @MustBeClosed + fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index 730888a1..c95ac329 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -25,157 +27,208 @@ import com.braintrustdata.api.models.AclRetrieveParams class AclServiceImpl internal constructor(private val clientOptions: ClientOptions) : AclService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified - */ - override fun create(params: AclCreateParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: AclService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an acl object by its id */ - override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun withRawResponse(): AclService.WithRawResponse = withRawResponse - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first - */ - override fun list(params: AclListParams, requestOptions: RequestOptions): AclListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { AclListPage.of(this, params, it) } - } + override fun create(params: AclCreateParams, requestOptions: RequestOptions): Acl = + // post /v1/acl + withRawResponse().create(params, requestOptions).parse() - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an acl object by its id */ - override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): Acl = + // get /v1/acl/{acl_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: AclListParams, requestOptions: RequestOptions): AclListPage = + // get /v1/acl + withRawResponse().list(params, requestOptions).parse() - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): Acl = + // delete /v1/acl/{acl_id} + withRawResponse().delete(params, requestOptions).parse() - /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. - */ override fun batchUpdate( params: AclBatchUpdateParams, requestOptions: RequestOptions, - ): AclBatchUpdateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): AclBatchUpdateResponse = + // post /v1/acl/batch-update + withRawResponse().batchUpdate(params, requestOptions).parse() - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a single acl */ override fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions, - ): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): Acl = + // delete /v1/acl + withRawResponse().findAndDelete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AclService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: AclCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AclListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { AclListPage.of(AclServiceImpl(clientOptions), params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val batchUpdateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch-update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { batchUpdateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val findAndDeleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt index a0baaa93..d49fd448 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams @@ -14,9 +15,15 @@ import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface AiSecretService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new ai_secret. If there is an existing ai_secret with the same name as the one * specified in the request, will return the existing ai_secret unmodified @@ -85,4 +92,93 @@ interface AiSecretService { params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): AISecret + + /** A view of [AiSecretService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the + * same as [AiSecretService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise + * the same as [AiSecretService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: AiSecretListParams = AiSecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(AiSecretListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise + * the same as [AiSecretService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.findAndDelete]. + */ + @JvmOverloads + @MustBeClosed + fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index 1e42d069..3ee1d33c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -26,188 +28,241 @@ import com.braintrustdata.api.models.AiSecretUpdateParams class AiSecretServiceImpl internal constructor(private val clientOptions: ClientOptions) : AiSecretService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will return the existing ai_secret unmodified - */ - override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): AISecret { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: AiSecretService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): AiSecretService.WithRawResponse = withRawResponse + + override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): AISecret = + // post /v1/ai_secret + withRawResponse().create(params, requestOptions).parse() - /** Get an ai_secret object by its id */ override fun retrieve( params: AiSecretRetrieveParams, requestOptions: RequestOptions, - ): AISecret { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): AISecret = + // get /v1/ai_secret/{ai_secret_id} + withRawResponse().retrieve(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update an ai_secret object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ - override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): AISecret { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): AISecret = + // patch /v1/ai_secret/{ai_secret_id} + withRawResponse().update(params, requestOptions).parse() - /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first - */ override fun list( params: AiSecretListParams, requestOptions: RequestOptions, - ): AiSecretListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { AiSecretListPage.of(this, params, it) } - } + ): AiSecretListPage = + // get /v1/ai_secret + withRawResponse().list(params, requestOptions).parse() - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an ai_secret object by its id */ - override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): AISecret { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): AISecret = + // delete /v1/ai_secret/{ai_secret_id} + withRawResponse().delete(params, requestOptions).parse() - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a single ai_secret */ override fun findAndDelete( params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions, - ): AISecret { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): AISecret = + // delete /v1/ai_secret + withRawResponse().findAndDelete(params, requestOptions).parse() + + override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): AISecret = + // put /v1/ai_secret + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AiSecretService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AiSecretListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { AiSecretListPage.of(AiSecretServiceImpl(clientOptions), params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val findAndDeleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will replace the existing ai_secret with the provided fields - */ - override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): AISecret { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index ef5ee665..b7bbe672 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams @@ -12,9 +13,15 @@ import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput +import com.google.errorprone.annotations.MustBeClosed interface ApiKeyService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new api_key. It is possible to have multiple API keys with the same name. There is * no de-duplication @@ -55,4 +62,60 @@ interface ApiKeyService { params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): ApiKey + + /** A view of [ApiKeyService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/api_key`, but is otherwise the same as + * [ApiKeyService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same + * as [ApiKeyService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as + * [ApiKeyService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ApiKeyListParams = ApiKeyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as + * [ApiKeyService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ApiKeyListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the + * same as [ApiKeyService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index e56119d0..1b1dac5f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -24,106 +26,142 @@ import com.braintrustdata.api.models.CreateApiKeyOutput class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : ApiKeyService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ApiKeyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ApiKeyService.WithRawResponse = withRawResponse - /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication - */ override fun create( params: ApiKeyCreateParams, requestOptions: RequestOptions, - ): CreateApiKeyOutput { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): CreateApiKeyOutput = + // post /v1/api_key + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): ApiKey = + // get /v1/api_key/{api_key_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): ApiKeyListPage = + // get /v1/api_key + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): ApiKey = + // delete /v1/api_key/{api_key_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an api_key object by its id */ - override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first - */ - override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): ApiKeyListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ApiKeyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ApiKeyListPage.of(ApiKeyServiceImpl(clientOptions), params, it) } } - .let { ApiKeyListPage.of(this, params, it) } - } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an api_key object by its id */ - override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index f28dc44f..da17f213 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -21,9 +22,15 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse +import com.google.errorprone.annotations.MustBeClosed interface DatasetService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new dataset. If there is an existing dataset in the project with the same name as * the one specified in the request, will return the existing dataset unmodified @@ -118,4 +125,126 @@ interface DatasetService { params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none(), ): SummarizeDatasetResponse + + /** A view of [DatasetService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/dataset`, but is otherwise the same as + * [DatasetService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same + * as [DatasetService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the + * same as [DatasetService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as + * [DatasetService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as + * [DatasetService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(DatasetListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the + * same as [DatasetService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is + * otherwise the same as [DatasetService.feedback]. + */ + @JvmOverloads + @MustBeClosed + fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise + * the same as [DatasetService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise + * the same as [DatasetService.fetchPost]. + */ + @JvmOverloads + @MustBeClosed + fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise + * the same as [DatasetService.insert]. + */ + @JvmOverloads + @MustBeClosed + fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is + * otherwise the same as [DatasetService.summarize]. + */ + @JvmOverloads + @MustBeClosed + fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 0c9707bc..16fa5eed 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -33,269 +35,343 @@ import com.braintrustdata.api.models.SummarizeDatasetResponse class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : DatasetService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified - */ - override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: DatasetService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a dataset object by its id */ - override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun withRawResponse(): DatasetService.WithRawResponse = withRawResponse - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a dataset object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ - override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): Dataset = + // post /v1/dataset + withRawResponse().create(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all datasets. The datasets are sorted by creation date, with the most - * recently-created datasets coming first - */ - override fun list(params: DatasetListParams, requestOptions: RequestOptions): DatasetListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { DatasetListPage.of(this, params, it) } - } + override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): Dataset = + // get /v1/dataset/{dataset_id} + withRawResponse().retrieve(params, requestOptions).parse() - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a dataset object by its id */ - override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): Dataset = + // patch /v1/dataset/{dataset_id} + withRawResponse().update(params, requestOptions).parse() - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun list(params: DatasetListParams, requestOptions: RequestOptions): DatasetListPage = + // get /v1/dataset + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): Dataset = + // delete /v1/dataset/{dataset_id} + withRawResponse().delete(params, requestOptions).parse() - /** Log feedback for a set of dataset events */ override fun feedback( params: DatasetFeedbackParams, requestOptions: RequestOptions, - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): FeedbackResponseSchema = + // post /v1/dataset/{dataset_id}/feedback + withRawResponse().feedback(params, requestOptions).parse() - /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetch( params: DatasetFetchParams, requestOptions: RequestOptions, - ): FetchDatasetEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): FetchDatasetEventsResponse = + // get /v1/dataset/{dataset_id}/fetch + withRawResponse().fetch(params, requestOptions).parse() - /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetchPost( params: DatasetFetchPostParams, requestOptions: RequestOptions, - ): FetchDatasetEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): FetchDatasetEventsResponse = + // post /v1/dataset/{dataset_id}/fetch + withRawResponse().fetchPost(params, requestOptions).parse() - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Insert a set of events into the dataset */ override fun insert( params: DatasetInsertParams, requestOptions: RequestOptions, - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): InsertEventsResponse = + // post /v1/dataset/{dataset_id}/insert + withRawResponse().insert(params, requestOptions).parse() - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Summarize dataset */ override fun summarize( params: DatasetSummarizeParams, requestOptions: RequestOptions, - ): SummarizeDatasetResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): SummarizeDatasetResponse = + // get /v1/dataset/{dataset_id}/summarize + withRawResponse().summarize(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { DatasetListPage.of(DatasetServiceImpl(clientOptions), params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt index cb3ff44a..8f8610be 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.EnvVar import com.braintrustdata.api.models.EnvVarCreateParams import com.braintrustdata.api.models.EnvVarDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.EnvVarListResponse import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface EnvVarService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new env_var. If there is an existing env_var with the same name as the one specified * in the request, will return the existing env_var unmodified @@ -77,4 +84,82 @@ interface EnvVarService { params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): EnvVar + + /** A view of [EnvVarService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/env_var`, but is otherwise the same as + * [EnvVarService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same + * as [EnvVarService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the + * same as [EnvVarService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as + * [EnvVarService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: EnvVarListParams = EnvVarListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as + * [EnvVarService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(EnvVarListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the + * same as [EnvVarService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as + * [EnvVarService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index 9daa2b91..c69790bb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -25,157 +27,202 @@ import com.braintrustdata.api.models.EnvVarUpdateParams class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOptions) : EnvVarService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new env_var. If there is an existing env_var with the same name as the one specified - * in the request, will return the existing env_var unmodified - */ - override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): EnvVar { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: EnvVarService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an env_var object by its id */ - override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): EnvVar { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun withRawResponse(): EnvVarService.WithRawResponse = withRawResponse - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update an env_var object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ - override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): EnvVar { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): EnvVar = + // post /v1/env_var + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): EnvVar = + // get /v1/env_var/{env_var_id} + withRawResponse().retrieve(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): EnvVar = + // patch /v1/env_var/{env_var_id} + withRawResponse().update(params, requestOptions).parse() - /** - * List out all env_vars. The env_vars are sorted by creation date, with the most - * recently-created env_vars coming first - */ override fun list( params: EnvVarListParams, requestOptions: RequestOptions, - ): EnvVarListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): EnvVarListResponse = + // get /v1/env_var + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): EnvVar = + // delete /v1/env_var/{env_var_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): EnvVar = + // put /v1/env_var + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EnvVarService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an env_var object by its id */ - override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): EnvVar { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create or replace env_var. If there is an existing env_var with the same name as the one - * specified in the request, will replace the existing env_var with the provided fields - */ - override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): EnvVar { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list( + params: EnvVarListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt index 4667577d..3941bf02 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt @@ -5,11 +5,18 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse +import com.google.errorprone.annotations.MustBeClosed interface EvalService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and @@ -22,4 +29,19 @@ interface EvalService { params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): SummarizeExperimentResponse + + /** A view of [EvalService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/eval`, but is otherwise the same as + * [EvalService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: EvalCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index 9f26e66a..a90a7553 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -18,38 +20,50 @@ import com.braintrustdata.api.models.SummarizeExperimentResponse class EvalServiceImpl internal constructor(private val clientOptions: ClientOptions) : EvalService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: EvalService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): EvalService.WithRawResponse = withRawResponse - /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into - * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and - * scoring functions. The API will then run the evaluation, create an experiment, and return the - * results along with a link to the experiment. To learn more about evals, see the - * [Evals guide](https://www.braintrust.dev/docs/guides/evals). - */ override fun create( params: EvalCreateParams, requestOptions: RequestOptions, - ): SummarizeExperimentResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "eval") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): SummarizeExperimentResponse = + // post /v1/eval + withRawResponse().create(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EvalService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: EvalCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "eval") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 2aa9303c..c3231496 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -21,9 +22,15 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse +import com.google.errorprone.annotations.MustBeClosed interface ExperimentService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new experiment. If there is an existing experiment in the project with the same name * as the one specified in the request, will return the existing experiment unmodified @@ -118,4 +125,126 @@ interface ExperimentService { params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none(), ): SummarizeExperimentResponse + + /** A view of [ExperimentService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as + * [ExperimentService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as + * [ExperimentService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ExperimentListParams = ExperimentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as + * [ExperimentService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ExperimentListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is + * otherwise the same as [ExperimentService.feedback]. + */ + @JvmOverloads + @MustBeClosed + fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is + * otherwise the same as [ExperimentService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is + * otherwise the same as [ExperimentService.fetchPost]. + */ + @JvmOverloads + @MustBeClosed + fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is + * otherwise the same as [ExperimentService.insert]. + */ + @JvmOverloads + @MustBeClosed + fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is + * otherwise the same as [ExperimentService.summarize]. + */ + @JvmOverloads + @MustBeClosed + fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 896e6d31..44e4226f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -33,284 +35,358 @@ import com.braintrustdata.api.models.SummarizeExperimentResponse class ExperimentServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExperimentService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ExperimentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ExperimentService.WithRawResponse = withRawResponse - /** - * Create a new experiment. If there is an existing experiment in the project with the same name - * as the one specified in the request, will return the existing experiment unmodified - */ override fun create( params: ExperimentCreateParams, requestOptions: RequestOptions, - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): Experiment = + // post /v1/experiment + withRawResponse().create(params, requestOptions).parse() - /** Get an experiment object by its id */ override fun retrieve( params: ExperimentRetrieveParams, requestOptions: RequestOptions, - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): Experiment = + // get /v1/experiment/{experiment_id} + withRawResponse().retrieve(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: ExperimentUpdateParams, requestOptions: RequestOptions, - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): Experiment = + // patch /v1/experiment/{experiment_id} + withRawResponse().update(params, requestOptions).parse() - /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first - */ override fun list( params: ExperimentListParams, requestOptions: RequestOptions, - ): ExperimentListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ExperimentListPage.of(this, params, it) } - } + ): ExperimentListPage = + // get /v1/experiment + withRawResponse().list(params, requestOptions).parse() - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an experiment object by its id */ override fun delete( params: ExperimentDeleteParams, requestOptions: RequestOptions, - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): Experiment = + // delete /v1/experiment/{experiment_id} + withRawResponse().delete(params, requestOptions).parse() - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Log feedback for a set of experiment events */ override fun feedback( params: ExperimentFeedbackParams, requestOptions: RequestOptions, - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): FeedbackResponseSchema = + // post /v1/experiment/{experiment_id}/feedback + withRawResponse().feedback(params, requestOptions).parse() - /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetch( params: ExperimentFetchParams, requestOptions: RequestOptions, - ): FetchExperimentEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): FetchExperimentEventsResponse = + // get /v1/experiment/{experiment_id}/fetch + withRawResponse().fetch(params, requestOptions).parse() - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetchPost( params: ExperimentFetchPostParams, requestOptions: RequestOptions, - ): FetchExperimentEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): FetchExperimentEventsResponse = + // post /v1/experiment/{experiment_id}/fetch + withRawResponse().fetchPost(params, requestOptions).parse() - /** Insert a set of events into the experiment */ override fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions, - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): InsertEventsResponse = + // post /v1/experiment/{experiment_id}/insert + withRawResponse().insert(params, requestOptions).parse() - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Summarize experiment */ override fun summarize( params: ExperimentSummarizeParams, requestOptions: RequestOptions, - ): SummarizeExperimentResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): SummarizeExperimentResponse = + // get /v1/experiment/{experiment_id}/summarize + withRawResponse().summarize(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ExperimentListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ExperimentListPage.of(ExperimentServiceImpl(clientOptions), params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 242b1dbb..c39c68c2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams @@ -15,10 +16,16 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.Optional interface FunctionService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new function. If there is an existing function in the project with the same slug as * the one specified in the request, will return the existing function unmodified @@ -88,4 +95,93 @@ interface FunctionService { params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): Function + + /** A view of [FunctionService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as + * [FunctionService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the + * same as [FunctionService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the + * same as [FunctionService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as + * [FunctionService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: FunctionListParams = FunctionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as + * [FunctionService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(FunctionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the + * same as [FunctionService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is + * otherwise the same as [FunctionService.invoke]. + */ + @JvmOverloads + @MustBeClosed + fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** + * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as + * [FunctionService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 003452f9..4fc5a880 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -28,190 +30,242 @@ import java.util.Optional class FunctionServiceImpl internal constructor(private val clientOptions: ClientOptions) : FunctionService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified - */ - override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: FunctionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): FunctionService.WithRawResponse = withRawResponse + + override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): Function = + // post /v1/function + withRawResponse().create(params, requestOptions).parse() - /** Get a function object by its id */ override fun retrieve( params: FunctionRetrieveParams, requestOptions: RequestOptions, - ): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): Function = + // get /v1/function/{function_id} + withRawResponse().retrieve(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a function object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ - override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): Function = + // patch /v1/function/{function_id} + withRawResponse().update(params, requestOptions).parse() - /** - * List out all functions. The functions are sorted by creation date, with the most - * recently-created functions coming first - */ override fun list( params: FunctionListParams, requestOptions: RequestOptions, - ): FunctionListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { FunctionListPage.of(this, params, it) } - } + ): FunctionListPage = + // get /v1/function + withRawResponse().list(params, requestOptions).parse() - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a function object by its id */ - override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): Function = + // delete /v1/function/{function_id} + withRawResponse().delete(params, requestOptions).parse() - private val invokeHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Invoke a function. */ override fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions, - ): Optional { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { invokeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } - } + ): Optional = + // post /v1/function/{function_id}/invoke + withRawResponse().invoke(params, requestOptions).parse() + + override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): Function = + // put /v1/function + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FunctionService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: FunctionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { FunctionListPage.of(FunctionServiceImpl(clientOptions), params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val invokeHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function", params.getPathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { invokeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create or replace function. If there is an existing function in the project with the same - * slug as the one specified in the request, will replace the existing function with the - * provided fields - */ - override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index 057ce985..ab46545e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface GroupService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new group. If there is an existing group with the same name as the one specified in * the request, will return the existing group unmodified @@ -77,4 +84,82 @@ interface GroupService { params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): Group + + /** A view of [GroupService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/group`, but is otherwise the same as + * [GroupService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as + * [GroupService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same + * as [GroupService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as + * [GroupService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: GroupListParams = GroupListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as + * [GroupService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(GroupListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same + * as [GroupService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as + * [GroupService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 2a42a7e9..9d16a2eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -25,155 +27,201 @@ import com.braintrustdata.api.models.GroupUpdateParams class GroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : GroupService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified - */ - override fun create(params: GroupCreateParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: GroupService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a group object by its id */ - override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun withRawResponse(): GroupService.WithRawResponse = withRawResponse + + override fun create(params: GroupCreateParams, requestOptions: RequestOptions): Group = + // post /v1/group + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): Group = + // get /v1/group/{group_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): Group = + // patch /v1/group/{group_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: GroupListParams, requestOptions: RequestOptions): GroupListPage = + // get /v1/group + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): Group = + // delete /v1/group/{group_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): Group = + // put /v1/group + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + GroupService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. - */ - override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first - */ - override fun list(params: GroupListParams, requestOptions: RequestOptions): GroupListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - .let { GroupListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a group object by its id */ - override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: GroupListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { GroupListPage.of(GroupServiceImpl(clientOptions), params, it) } } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create or replace group. If there is an existing group with the same name as the one - * specified in the request, will replace the existing group with the provided fields - */ - override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index 8a31e382..4020d4c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPage @@ -12,9 +13,15 @@ import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import com.braintrustdata.api.services.blocking.organizations.MemberService +import com.google.errorprone.annotations.MustBeClosed interface OrganizationService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun members(): MemberService /** Get an organization object by its id */ @@ -58,4 +65,64 @@ interface OrganizationService { params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): Organization + + /** + * A view of [OrganizationService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun members(): MemberService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as + * [OrganizationService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: OrganizationListParams = OrganizationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as + * [OrganizationService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(OrganizationListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index 5d0bbd22..cd1846cc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -25,120 +27,163 @@ import com.braintrustdata.api.services.blocking.organizations.MemberServiceImpl class OrganizationServiceImpl internal constructor(private val clientOptions: ClientOptions) : OrganizationService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: OrganizationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val members: MemberService by lazy { MemberServiceImpl(clientOptions) } - override fun members(): MemberService = members + override fun withRawResponse(): OrganizationService.WithRawResponse = withRawResponse - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun members(): MemberService = members - /** Get an organization object by its id */ override fun retrieve( params: OrganizationRetrieveParams, requestOptions: RequestOptions, - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): Organization = + // get /v1/organization/{organization_id} + withRawResponse().retrieve(params, requestOptions).parse() - /** - * Partially update an organization object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: OrganizationUpdateParams, requestOptions: RequestOptions, - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): Organization = + // patch /v1/organization/{organization_id} + withRawResponse().update(params, requestOptions).parse() - /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first - */ override fun list( params: OrganizationListParams, requestOptions: RequestOptions, - ): OrganizationListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { OrganizationListPage.of(this, params, it) } - } + ): OrganizationListPage = + // get /v1/organization + withRawResponse().list(params, requestOptions).parse() - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an organization object by its id */ override fun delete( params: OrganizationDeleteParams, requestOptions: RequestOptions, - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): Organization = + // delete /v1/organization/{organization_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrganizationService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val members: MemberService.WithRawResponse by lazy { + MemberServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun members(): MemberService.WithRawResponse = members + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: OrganizationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + OrganizationListPage.of(OrganizationServiceImpl(clientOptions), params, it) + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index 4ef23a62..72a97f3e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface ProjectScoreService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new project_score. If there is an existing project_score in the project with the * same name as the one specified in the request, will return the existing project_score @@ -79,4 +86,84 @@ interface ProjectScoreService { params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScore + + /** + * A view of [ProjectScoreService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as + * [ProjectScoreService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as + * [ProjectScoreService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as + * [ProjectScoreService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ProjectScoreListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as + * [ProjectScoreService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index 0459cbba..590cb7e7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -25,176 +27,221 @@ import com.braintrustdata.api.models.ProjectScoreUpdateParams class ProjectScoreServiceImpl internal constructor(private val clientOptions: ClientOptions) : ProjectScoreService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ProjectScoreService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ProjectScoreService.WithRawResponse = withRawResponse - /** - * Create a new project_score. If there is an existing project_score in the project with the - * same name as the one specified in the request, will return the existing project_score - * unmodified - */ override fun create( params: ProjectScoreCreateParams, requestOptions: RequestOptions, - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): ProjectScore = + // post /v1/project_score + withRawResponse().create(params, requestOptions).parse() - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a project_score object by its id */ override fun retrieve( params: ProjectScoreRetrieveParams, requestOptions: RequestOptions, - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): ProjectScore = + // get /v1/project_score/{project_score_id} + withRawResponse().retrieve(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: ProjectScoreUpdateParams, requestOptions: RequestOptions, - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): ProjectScore = + // patch /v1/project_score/{project_score_id} + withRawResponse().update(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first - */ override fun list( params: ProjectScoreListParams, requestOptions: RequestOptions, - ): ProjectScoreListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectScoreListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): ProjectScoreListPage = + // get /v1/project_score + withRawResponse().list(params, requestOptions).parse() - /** Delete a project_score object by its id */ override fun delete( params: ProjectScoreDeleteParams, requestOptions: RequestOptions, - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): ProjectScore = + // delete /v1/project_score/{project_score_id} + withRawResponse().delete(params, requestOptions).parse() - /** - * Create or replace project_score. If there is an existing project_score in the project with - * the same name as the one specified in the request, will replace the existing project_score - * with the provided fields - */ override fun replace( params: ProjectScoreReplaceParams, requestOptions: RequestOptions, - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): ProjectScore = + // put /v1/project_score + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectScoreService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectScoreListPage.of(ProjectScoreServiceImpl(clientOptions), params, it) + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index 60f9bcfc..bd67e60e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams import com.braintrustdata.api.services.blocking.projects.LogService +import com.google.errorprone.annotations.MustBeClosed interface ProjectService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun logs(): LogService /** @@ -69,4 +76,73 @@ interface ProjectService { params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): Project + + /** A view of [ProjectService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun logs(): LogService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/project`, but is otherwise the same as + * [ProjectService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same + * as [ProjectService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the + * same as [ProjectService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as + * [ProjectService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as + * [ProjectService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ProjectListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the + * same as [ProjectService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 2c723eac..b4e13de3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -26,134 +28,180 @@ import com.braintrustdata.api.services.blocking.projects.LogServiceImpl class ProjectServiceImpl internal constructor(private val clientOptions: ClientOptions) : ProjectService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ProjectService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val logs: LogService by lazy { LogServiceImpl(clientOptions) } + override fun withRawResponse(): ProjectService.WithRawResponse = withRawResponse + override fun logs(): LogService = logs - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new project. If there is an existing project with the same name as the one specified - * in the request, will return the existing project unmodified - */ - override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): Project = + // post /v1/project + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): Project = + // get /v1/project/{project_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): Project = + // patch /v1/project/{project_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: ProjectListParams, requestOptions: RequestOptions): ProjectListPage = + // get /v1/project + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): Project = + // delete /v1/project/{project_id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val logs: LogService.WithRawResponse by lazy { + LogServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun logs(): LogService.WithRawResponse = logs + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a project object by its id */ - override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a project object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ - override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all projects. The projects are sorted by creation date, with the most - * recently-created projects coming first - */ - override fun list(params: ProjectListParams, requestOptions: RequestOptions): ProjectListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ProjectListPage.of(ProjectServiceImpl(clientOptions), params, it) } } - .let { ProjectListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a project object by its id */ - override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index c4a3174a..4bfaa198 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface ProjectTagService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new project_tag. If there is an existing project_tag in the project with the same * name as the one specified in the request, will return the existing project_tag unmodified @@ -78,4 +85,82 @@ interface ProjectTagService { params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTag + + /** A view of [ProjectTagService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as + * [ProjectTagService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise + * the same as [ProjectTagService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as + * [ProjectTagService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ProjectTagListParams = ProjectTagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as + * [ProjectTagService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ProjectTagListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as + * [ProjectTagService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 027be6d7..54f18c7d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -25,175 +27,219 @@ import com.braintrustdata.api.models.ProjectTagUpdateParams class ProjectTagServiceImpl internal constructor(private val clientOptions: ClientOptions) : ProjectTagService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ProjectTagService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ProjectTagService.WithRawResponse = withRawResponse - /** - * Create a new project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will return the existing project_tag unmodified - */ override fun create( params: ProjectTagCreateParams, requestOptions: RequestOptions, - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): ProjectTag = + // post /v1/project_tag + withRawResponse().create(params, requestOptions).parse() - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a project_tag object by its id */ override fun retrieve( params: ProjectTagRetrieveParams, requestOptions: RequestOptions, - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): ProjectTag = + // get /v1/project_tag/{project_tag_id} + withRawResponse().retrieve(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: ProjectTagUpdateParams, requestOptions: RequestOptions, - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): ProjectTag = + // patch /v1/project_tag/{project_tag_id} + withRawResponse().update(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first - */ override fun list( params: ProjectTagListParams, requestOptions: RequestOptions, - ): ProjectTagListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectTagListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): ProjectTagListPage = + // get /v1/project_tag + withRawResponse().list(params, requestOptions).parse() - /** Delete a project_tag object by its id */ override fun delete( params: ProjectTagDeleteParams, requestOptions: RequestOptions, - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): ProjectTag = + // delete /v1/project_tag/{project_tag_id} + withRawResponse().delete(params, requestOptions).parse() - /** - * Create or replace project_tag. If there is an existing project_tag in the project with the - * same name as the one specified in the request, will replace the existing project_tag with the - * provided fields - */ override fun replace( params: ProjectTagReplaceParams, requestOptions: RequestOptions, - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): ProjectTag = + // put /v1/project_tag + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectTagService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ProjectTagListPage.of(ProjectTagServiceImpl(clientOptions), params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index 0dde79aa..b9459255 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface PromptService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new prompt. If there is an existing prompt in the project with the same slug as the * one specified in the request, will return the existing prompt unmodified @@ -77,4 +84,82 @@ interface PromptService { params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): Prompt + + /** A view of [PromptService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/prompt`, but is otherwise the same as + * [PromptService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: PromptCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same + * as [PromptService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same + * as [PromptService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as + * [PromptService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: PromptListParams = PromptListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as + * [PromptService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(PromptListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the + * same as [PromptService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as + * [PromptService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index ac344b1b..59b6e64d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -25,156 +27,201 @@ import com.braintrustdata.api.models.PromptUpdateParams class PromptServiceImpl internal constructor(private val clientOptions: ClientOptions) : PromptService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified - */ - override fun create(params: PromptCreateParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: PromptService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a prompt object by its id */ - override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun withRawResponse(): PromptService.WithRawResponse = withRawResponse + + override fun create(params: PromptCreateParams, requestOptions: RequestOptions): Prompt = + // post /v1/prompt + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): Prompt = + // get /v1/prompt/{prompt_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): Prompt = + // patch /v1/prompt/{prompt_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: PromptListParams, requestOptions: RequestOptions): PromptListPage = + // get /v1/prompt + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): Prompt = + // delete /v1/prompt/{prompt_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): Prompt = + // put /v1/prompt + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PromptService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: PromptCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a prompt object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ - override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first - */ - override fun list(params: PromptListParams, requestOptions: RequestOptions): PromptListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - .let { PromptListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a prompt object by its id */ - override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: PromptListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { PromptListPage.of(PromptServiceImpl(clientOptions), params, it) } } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as - * the one specified in the request, will replace the existing prompt with the provided fields - */ - override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index 33f3942d..8c0db8ce 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface RoleService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new role. If there is an existing role with the same name as the one specified in * the request, will return the existing role unmodified @@ -77,4 +84,82 @@ interface RoleService { params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): Role + + /** A view of [RoleService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/role`, but is otherwise the same as + * [RoleService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as + * [RoleService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as + * [RoleService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as + * [RoleService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as + * [RoleService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(RoleListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as + * [RoleService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as + * [RoleService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 74660aff..b8f1e52c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -24,155 +26,201 @@ import com.braintrustdata.api.models.RoleUpdateParams class RoleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RoleService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified - */ - override fun create(params: RoleCreateParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: RoleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a role object by its id */ - override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun withRawResponse(): RoleService.WithRawResponse = withRawResponse + + override fun create(params: RoleCreateParams, requestOptions: RequestOptions): Role = + // post /v1/role + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): Role = + // get /v1/role/{role_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): Role = + // patch /v1/role/{role_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: RoleListParams, requestOptions: RequestOptions): RoleListPage = + // get /v1/role + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): Role = + // delete /v1/role/{role_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): Role = + // put /v1/role + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoleService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. - */ - override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * List out all roles. The roles are sorted by creation date, with the most recently-created - * roles coming first - */ - override fun list(params: RoleListParams, requestOptions: RequestOptions): RoleListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - .let { RoleListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a role object by its id */ - override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoleListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { RoleListPage.of(RoleServiceImpl(clientOptions), params, it) } } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create or replace role. If there is an existing role with the same name as the one specified - * in the request, will replace the existing role with the provided fields - */ - override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt index 804df013..8a4d51f7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.SpanIFrame import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface SpanIframeService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new span_iframe. If there is an existing span_iframe with the same name as the one * specified in the request, will return the existing span_iframe unmodified @@ -77,4 +84,82 @@ interface SpanIframeService { params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): SpanIFrame + + /** A view of [SpanIframeService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as + * [SpanIframeService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise + * the same as [SpanIframeService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as + * [SpanIframeService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: SpanIframeListParams = SpanIframeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as + * [SpanIframeService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(SpanIframeListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as + * [SpanIframeService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt index 6d9ece08..03fd59f0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -25,174 +27,219 @@ import com.braintrustdata.api.models.SpanIframeUpdateParams class SpanIframeServiceImpl internal constructor(private val clientOptions: ClientOptions) : SpanIframeService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SpanIframeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): SpanIframeService.WithRawResponse = withRawResponse - /** - * Create a new span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will return the existing span_iframe unmodified - */ override fun create( params: SpanIframeCreateParams, requestOptions: RequestOptions, - ): SpanIFrame { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): SpanIFrame = + // post /v1/span_iframe + withRawResponse().create(params, requestOptions).parse() - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a span_iframe object by its id */ override fun retrieve( params: SpanIframeRetrieveParams, requestOptions: RequestOptions, - ): SpanIFrame { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): SpanIFrame = + // get /v1/span_iframe/{span_iframe_id} + withRawResponse().retrieve(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a span_iframe object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. - */ override fun update( params: SpanIframeUpdateParams, requestOptions: RequestOptions, - ): SpanIFrame { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): SpanIFrame = + // patch /v1/span_iframe/{span_iframe_id} + withRawResponse().update(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first - */ override fun list( params: SpanIframeListParams, requestOptions: RequestOptions, - ): SpanIframeListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { SpanIframeListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): SpanIframeListPage = + // get /v1/span_iframe + withRawResponse().list(params, requestOptions).parse() - /** Delete a span_iframe object by its id */ override fun delete( params: SpanIframeDeleteParams, requestOptions: RequestOptions, - ): SpanIFrame { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): SpanIFrame = + // delete /v1/span_iframe/{span_iframe_id} + withRawResponse().delete(params, requestOptions).parse() - /** - * Create or replace span_iframe. If there is an existing span_iframe with the same name as the - * one specified in the request, will replace the existing span_iframe with the provided fields - */ override fun replace( params: SpanIframeReplaceParams, requestOptions: RequestOptions, - ): SpanIFrame { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): SpanIFrame = + // put /v1/span_iframe + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SpanIframeService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { SpanIframeListPage.of(SpanIframeServiceImpl(clientOptions), params, it) } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index aca20acc..12190a7e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -5,10 +5,17 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.TopLevelHelloWorldParams +import com.google.errorprone.annotations.MustBeClosed interface TopLevelService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ @JvmOverloads fun helloWorld( @@ -19,4 +26,27 @@ interface TopLevelService { /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ fun helloWorld(requestOptions: RequestOptions): String = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + + /** A view of [TopLevelService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /v1`, but is otherwise the same as + * [TopLevelService.helloWorld]. + */ + @JvmOverloads + @MustBeClosed + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1`, but is otherwise the same as + * [TopLevelService.helloWorld]. + */ + @MustBeClosed + fun helloWorld(requestOptions: RequestOptions): HttpResponseFor = + helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 3a1825e3..2bee0c27 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams @@ -17,23 +19,40 @@ import com.braintrustdata.api.models.TopLevelHelloWorldParams class TopLevelServiceImpl internal constructor(private val clientOptions: ClientOptions) : TopLevelService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TopLevelService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) + override fun withRawResponse(): TopLevelService.WithRawResponse = withRawResponse - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ override fun helloWorld( params: TopLevelHelloWorldParams, requestOptions: RequestOptions, - ): String { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.use { helloWorldHandler.handle(it) } + ): String = + // get /v1 + withRawResponse().helloWorld(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val helloWorldHandler: Handler = + stringHandler().withErrorHandler(errorHandler) + + override fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { response.use { helloWorldHandler.handle(it) } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index 5ca8da21..b38cfab6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -5,13 +5,20 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams +import com.google.errorprone.annotations.MustBeClosed interface UserService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Get a user object by its id */ @JvmOverloads fun retrieve( @@ -35,4 +42,38 @@ interface UserService { */ fun list(requestOptions: RequestOptions): UserListPage = list(UserListParams.none(), requestOptions) + + /** A view of [UserService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as + * [UserService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as + * [UserService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: UserListParams = UserListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as + * [UserService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(UserListParams.none(), requestOptions) + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 0163c4db..08e5047d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.User @@ -19,53 +21,77 @@ import com.braintrustdata.api.models.UserRetrieveParams class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: UserService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UserService.WithRawResponse = withRawResponse + + override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): User = + // get /v1/user/{user_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: UserListParams, requestOptions: RequestOptions): UserListPage = + // get /v1/user + withRawResponse().list(params, requestOptions).parse() - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UserService.WithRawResponse { - /** Get a user object by its id */ - override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): User { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - /** - * List out all users. The users are sorted by creation date, with the most recently-created - * users coming first - */ - override fun list(params: UserListParams, requestOptions: RequestOptions): UserListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun list( + params: UserListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { UserListPage.of(UserServiceImpl(clientOptions), params, it) } } - .let { UserListPage.of(this, params, it) } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index 73aa6d7c..bb508305 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -13,9 +14,15 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams +import com.google.errorprone.annotations.MustBeClosed interface ViewService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Create a new view. If there is an existing view with the same name as the one specified in * the request, will return the existing view unmodified @@ -70,4 +77,74 @@ interface ViewService { params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), ): View + + /** A view of [ViewService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/view`, but is otherwise the same as + * [ViewService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as + * [ViewService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as + * [ViewService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as + * [ViewService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as + * [ViewService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as + * [ViewService.replace]. + */ + @JvmOverloads + @MustBeClosed + fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 6c50ed16..4d0c0c1b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -24,155 +26,201 @@ import com.braintrustdata.api.models.ViewUpdateParams class ViewServiceImpl internal constructor(private val clientOptions: ClientOptions) : ViewService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified - */ - override fun create(params: ViewCreateParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + private val withRawResponse: ViewService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get a view object by its id */ - override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + override fun withRawResponse(): ViewService.WithRawResponse = withRawResponse + + override fun create(params: ViewCreateParams, requestOptions: RequestOptions): View = + // post /v1/view + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): View = + // get /v1/view/{view_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): View = + // patch /v1/view/{view_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: ViewListParams, requestOptions: RequestOptions): ViewListPage = + // get /v1/view + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): View = + // delete /v1/view/{view_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): View = + // put /v1/view + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ViewService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. - */ - override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * List out all views. The views are sorted by creation date, with the most recently-created - * views coming first - */ - override fun list(params: ViewListParams, requestOptions: RequestOptions): ViewListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - .let { ViewListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete a view object by its id */ - override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ViewListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ViewListPage.of(ViewServiceImpl(clientOptions), params, it) } } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create or replace view. If there is an existing view with the same name as the one specified - * in the request, will replace the existing view with the provided fields - */ - override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt index 84092a5d..dbc32b7a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -5,11 +5,18 @@ package com.braintrustdata.api.services.blocking.organizations import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput +import com.google.errorprone.annotations.MustBeClosed interface MemberService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Modify organization membership */ @JvmOverloads fun update( @@ -20,4 +27,29 @@ interface MemberService { /** Modify organization membership */ fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none(), requestOptions) + + /** A view of [MemberService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the + * same as [MemberService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the + * same as [MemberService.update]. + */ + @MustBeClosed + fun update( + requestOptions: RequestOptions + ): HttpResponseFor = + update(OrganizationMemberUpdateParams.none(), requestOptions) + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index c9d028ee..b82ddb2b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -19,32 +21,50 @@ import com.braintrustdata.api.models.PatchOrganizationMembersOutput class MemberServiceImpl internal constructor(private val clientOptions: ClientOptions) : MemberService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: MemberService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): MemberService.WithRawResponse = withRawResponse - /** Modify organization membership */ override fun update( params: OrganizationMemberUpdateParams, requestOptions: RequestOptions, - ): PatchOrganizationMembersOutput { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): PatchOrganizationMembersOutput = + // patch /v1/organization/members + withRawResponse().update(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index e8b51534..2fa18b03 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse import com.braintrustdata.api.models.InsertEventsResponse @@ -12,9 +13,15 @@ import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.google.errorprone.annotations.MustBeClosed interface LogService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Log feedback for a set of project logs events */ @JvmOverloads fun feedback( @@ -50,4 +57,52 @@ interface LogService { params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none(), ): InsertEventsResponse + + /** A view of [LogService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is + * otherwise the same as [LogService.feedback]. + */ + @JvmOverloads + @MustBeClosed + fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is + * otherwise the same as [LogService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is + * otherwise the same as [LogService.fetchPost]. + */ + @JvmOverloads + @MustBeClosed + fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is + * otherwise the same as [LogService.insert]. + */ + @JvmOverloads + @MustBeClosed + fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index e86556ea..b60fd281 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -10,6 +10,8 @@ import com.braintrustdata.api.core.handlers.withErrorHandler import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError @@ -23,118 +25,154 @@ import com.braintrustdata.api.models.ProjectLogInsertParams class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: LogService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): LogService.WithRawResponse = withRawResponse - /** Log feedback for a set of project logs events */ override fun feedback( params: ProjectLogFeedbackParams, requestOptions: RequestOptions, - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): FeedbackResponseSchema = + // post /v1/project_logs/{project_id}/feedback + withRawResponse().feedback(params, requestOptions).parse() - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. - */ override fun fetch( params: ProjectLogFetchParams, requestOptions: RequestOptions, - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): FetchProjectLogsEventsResponse = + // get /v1/project_logs/{project_id}/fetch + withRawResponse().fetch(params, requestOptions).parse() - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. - */ override fun fetchPost( params: ProjectLogFetchPostParams, requestOptions: RequestOptions, - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + ): FetchProjectLogsEventsResponse = + // post /v1/project_logs/{project_id}/fetch + withRawResponse().fetchPost(params, requestOptions).parse() - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Insert a set of events into the project logs */ override fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions, - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } + ): InsertEventsResponse = + // post /v1/project_logs/{project_id}/insert + withRawResponse().insert(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LogService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } From a32b7113952189d2624dcbb534a6da5dc36a3224 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 08:55:15 +0000 Subject: [PATCH 62/87] chore(client)!: refactor multipart formdata impl (#132) chore(internal): move `HttpRequestBodies` file chore(internal): extract function for checking for lists in json fields # Migration 1. Builder methods that used to take `contentType` and `filename` as positional parameters after the main argument now no longer do. To set a custom `contentType` or `filename`, pass `MultipartField`, which can be constructed via `MultipartField.builder()`. 2. It's unlikely you were referencing it, but `MultipartFormValue` is now called `MultipartField` if you were. --- .../com/braintrustdata/api/core/Check.kt | 12 ++ .../api/core/HttpRequestBodies.kt | 108 --------------- .../com/braintrustdata/api/core/Values.kt | 127 +++++++++--------- .../api/core/http/HttpRequestBodies.kt | 114 ++++++++++++++++ .../api/models/AclBatchUpdateParams.kt | 21 +-- .../api/models/AclBatchUpdateResponse.kt | 21 +-- .../braintrustdata/api/models/DatasetEvent.kt | 12 +- .../api/models/DatasetFeedbackParams.kt | 11 +- .../api/models/DatasetInsertParams.kt | 11 +- .../api/models/EnvVarListResponse.kt | 11 +- .../api/models/EvalCreateParams.kt | 21 +-- .../api/models/ExperimentEvent.kt | 22 +-- .../api/models/ExperimentFeedbackParams.kt | 11 +- .../api/models/ExperimentInsertParams.kt | 11 +- .../api/models/FeedbackDatasetItem.kt | 12 +- .../api/models/FeedbackExperimentItem.kt | 12 +- .../api/models/FeedbackProjectLogsItem.kt | 12 +- .../api/models/FetchDatasetEventsResponse.kt | 11 +- .../models/FetchExperimentEventsResponse.kt | 11 +- .../models/FetchProjectLogsEventsResponse.kt | 11 +- .../com/braintrustdata/api/models/Function.kt | 12 +- .../api/models/FunctionCreateParams.kt | 11 +- .../api/models/FunctionInvokeParams.kt | 21 +-- .../api/models/FunctionReplaceParams.kt | 11 +- .../api/models/FunctionUpdateParams.kt | 11 +- .../com/braintrustdata/api/models/Group.kt | 21 +-- .../api/models/GroupCreateParams.kt | 21 +-- .../api/models/GroupReplaceParams.kt | 21 +-- .../api/models/GroupUpdateParams.kt | 41 ++---- .../api/models/InsertDatasetEvent.kt | 32 +---- .../api/models/InsertEventsResponse.kt | 11 +- .../api/models/InsertExperimentEvent.kt | 32 +---- .../api/models/InsertProjectLogsEvent.kt | 32 +---- .../api/models/OnlineScoreConfig.kt | 21 +-- .../models/OrganizationMemberUpdateParams.kt | 63 ++------- .../api/models/ProjectLogFeedbackParams.kt | 11 +- .../api/models/ProjectLogInsertParams.kt | 11 +- .../api/models/ProjectLogsEvent.kt | 22 +-- .../com/braintrustdata/api/models/Prompt.kt | 12 +- .../api/models/PromptCreateParams.kt | 11 +- .../braintrustdata/api/models/PromptData.kt | 31 +---- .../api/models/PromptOptions.kt | 21 +-- .../api/models/PromptReplaceParams.kt | 11 +- .../api/models/PromptUpdateParams.kt | 11 +- .../com/braintrustdata/api/models/Role.kt | 21 +-- .../api/models/RoleCreateParams.kt | 21 +-- .../api/models/RoleReplaceParams.kt | 21 +-- .../api/models/RoleUpdateParams.kt | 41 ++---- .../api/models/ViewDataSearch.kt | 41 ++---- .../braintrustdata/api/models/ViewOptions.kt | 11 +- .../api/services/async/AclServiceAsyncImpl.kt | 2 +- .../async/AiSecretServiceAsyncImpl.kt | 2 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 2 +- .../services/async/DatasetServiceAsyncImpl.kt | 2 +- .../services/async/EnvVarServiceAsyncImpl.kt | 2 +- .../services/async/EvalServiceAsyncImpl.kt | 2 +- .../async/ExperimentServiceAsyncImpl.kt | 2 +- .../async/FunctionServiceAsyncImpl.kt | 2 +- .../services/async/GroupServiceAsyncImpl.kt | 2 +- .../async/OrganizationServiceAsyncImpl.kt | 2 +- .../async/ProjectScoreServiceAsyncImpl.kt | 2 +- .../services/async/ProjectServiceAsyncImpl.kt | 2 +- .../async/ProjectTagServiceAsyncImpl.kt | 2 +- .../services/async/PromptServiceAsyncImpl.kt | 2 +- .../services/async/RoleServiceAsyncImpl.kt | 2 +- .../async/SpanIframeServiceAsyncImpl.kt | 2 +- .../services/async/ViewServiceAsyncImpl.kt | 2 +- .../organizations/MemberServiceAsyncImpl.kt | 2 +- .../async/projects/LogServiceAsyncImpl.kt | 2 +- .../api/services/blocking/AclServiceImpl.kt | 2 +- .../services/blocking/AiSecretServiceImpl.kt | 2 +- .../services/blocking/ApiKeyServiceImpl.kt | 2 +- .../services/blocking/DatasetServiceImpl.kt | 2 +- .../services/blocking/EnvVarServiceImpl.kt | 2 +- .../api/services/blocking/EvalServiceImpl.kt | 2 +- .../blocking/ExperimentServiceImpl.kt | 2 +- .../services/blocking/FunctionServiceImpl.kt | 2 +- .../api/services/blocking/GroupServiceImpl.kt | 2 +- .../blocking/OrganizationServiceImpl.kt | 2 +- .../blocking/ProjectScoreServiceImpl.kt | 2 +- .../services/blocking/ProjectServiceImpl.kt | 2 +- .../blocking/ProjectTagServiceImpl.kt | 2 +- .../services/blocking/PromptServiceImpl.kt | 2 +- .../api/services/blocking/RoleServiceImpl.kt | 2 +- .../blocking/SpanIframeServiceImpl.kt | 2 +- .../api/services/blocking/ViewServiceImpl.kt | 2 +- .../organizations/MemberServiceImpl.kt | 2 +- .../blocking/projects/LogServiceImpl.kt | 2 +- 88 files changed, 415 insertions(+), 901 deletions(-) delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Check.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Check.kt index da8f235b..4a2305ea 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Check.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Check.kt @@ -5,6 +5,18 @@ package com.braintrustdata.api.core fun checkRequired(name: String, value: T?): T = checkNotNull(value) { "`$name` is required, but was not set" } +@JvmSynthetic +internal fun checkKnown(name: String, value: JsonField): T = + value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkKnown(name: String, value: MultipartField): T = + value.value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + @JvmSynthetic internal fun checkLength(name: String, value: String, length: Int): String = value.also { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt deleted file mode 100644 index 6cadab0b..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/HttpRequestBodies.kt +++ /dev/null @@ -1,108 +0,0 @@ -@file:JvmName("HttpRequestBodies") - -package com.braintrustdata.api.core - -import com.braintrustdata.api.core.http.HttpRequestBody -import com.braintrustdata.api.errors.BraintrustException -import com.fasterxml.jackson.databind.json.JsonMapper -import java.io.ByteArrayOutputStream -import java.io.OutputStream -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder - -@JvmSynthetic -internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody { - return object : HttpRequestBody { - private var cachedBytes: ByteArray? = null - - private fun serialize(): ByteArray { - if (cachedBytes != null) return cachedBytes!! - - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, value) - cachedBytes = buffer.toByteArray() - return cachedBytes!! - } catch (e: Exception) { - throw BraintrustException("Error writing request", e) - } - } - - override fun writeTo(outputStream: OutputStream) { - outputStream.write(serialize()) - } - - override fun contentType(): String = "application/json" - - override fun contentLength(): Long { - return serialize().size.toLong() - } - - override fun repeatable(): Boolean = true - - override fun close() {} - } -} - -@JvmSynthetic -internal fun multipartFormData( - jsonMapper: JsonMapper, - parts: Array?>, -): HttpRequestBody { - val builder = MultipartEntityBuilder.create() - parts.forEach { part -> - if (part?.value != null) { - when (part.value) { - is JsonValue -> { - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, part.value) - } catch (e: Exception) { - throw BraintrustException("Error serializing value to json", e) - } - builder.addBinaryBody( - part.name, - buffer.toByteArray(), - part.contentType, - part.filename, - ) - } - is Boolean -> - builder.addTextBody( - part.name, - if (part.value) "true" else "false", - part.contentType, - ) - is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is ByteArray -> - builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) - is String -> builder.addTextBody(part.name, part.value, part.contentType) - is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - else -> - throw IllegalArgumentException( - "Unsupported content type: ${part.value::class.java.simpleName}" - ) - } - } - } - val entity = builder.build() - - return object : HttpRequestBody { - override fun writeTo(outputStream: OutputStream) { - try { - return entity.writeTo(outputStream) - } catch (e: Exception) { - throw BraintrustException("Error writing request", e) - } - } - - override fun contentType(): String = entity.contentType - - override fun contentLength(): Long = -1 - - override fun repeatable(): Boolean = entity.isRepeatable - - override fun close() = entity.close() - } -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 190a13fb..ad616e28 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -27,10 +27,8 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer -import java.nio.charset.Charset import java.util.Objects import java.util.Optional -import org.apache.hc.core5.http.ContentType @JsonDeserialize(using = JsonField.Deserializer::class) sealed class JsonField { @@ -287,12 +285,12 @@ private constructor( return true } - return other is KnownValue<*> && value == other.value + return other is KnownValue<*> && value contentEquals other.value } - override fun hashCode() = value.hashCode() + override fun hashCode() = contentHash(value) - override fun toString() = value.toString() + override fun toString() = value.contentToString() companion object { @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) @@ -462,15 +460,63 @@ annotation class ExcludeMissing ) annotation class NoAutoDetect -class MultipartFormValue -internal constructor( - val name: String, - val value: T, - val contentType: ContentType, - val filename: String? = null, +class MultipartField +private constructor( + @get:JvmName("value") val value: JsonField, + @get:JvmName("contentType") val contentType: String, + private val filename: String?, ) { - private val hashCode: Int by lazy { contentHash(name, value, contentType, filename) } + companion object { + + @JvmStatic fun of(value: T?) = builder().value(value).build() + + @JvmStatic fun of(value: JsonField) = builder().value(value).build() + + @JvmStatic fun builder() = Builder() + } + + fun filename(): Optional = Optional.ofNullable(filename) + + @JvmSynthetic + internal fun map(transform: (T) -> R): MultipartField = + MultipartField.builder() + .value(value.map(transform)) + .contentType(contentType) + .filename(filename) + .build() + + /** A builder for [MultipartField]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var contentType: String? = null + private var filename: String? = null + + fun value(value: JsonField) = apply { this.value = value } + + fun value(value: T?) = value(JsonField.ofNullable(value)) + + fun contentType(contentType: String) = apply { this.contentType = contentType } + + fun filename(filename: String?) = apply { this.filename = filename } + + fun filename(filename: Optional) = filename(filename.orElse(null)) + + fun build(): MultipartField { + val value = checkRequired("value", value) + return MultipartField( + value, + contentType + ?: if (value is KnownValue && value.value is ByteArray) + "application/octet-stream" + else "text/plain; charset=utf-8", + filename, + ) + } + } + + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } override fun hashCode(): Int = hashCode @@ -479,63 +525,12 @@ internal constructor( return true } - return other is MultipartFormValue<*> && - name == other.name && - value contentEquals other.value && + return other is MultipartField<*> && + value == other.value && contentType == other.contentType && filename == other.filename } override fun toString(): String = - "MultipartFormValue{name=$name, contentType=$contentType, filename=$filename, value=${valueToString()}}" - - private fun valueToString(): String = - when (value) { - is ByteArray -> "ByteArray of size ${value.size}" - else -> value.toString() - } - - companion object { - internal fun fromString( - name: String, - value: String, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromBoolean( - name: String, - value: Boolean, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromLong( - name: String, - value: Long, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromDouble( - name: String, - value: Double, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromEnum( - name: String, - value: T, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromByteArray( - name: String, - value: ByteArray, - contentType: ContentType, - filename: String? = null, - ): MultipartFormValue = MultipartFormValue(name, value, contentType, filename) - } -} - -internal object ContentTypes { - val DefaultText = ContentType.create(ContentType.TEXT_PLAIN.mimeType, Charset.forName("UTF-8")) - val DefaultBinary = ContentType.DEFAULT_BINARY + "MultipartField{value=$value, contentType=$contentType, filename=$filename}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt new file mode 100644 index 00000000..a14ed462 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("HttpRequestBodies") + +package com.braintrustdata.api.core.http + +import com.braintrustdata.api.core.MultipartField +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.node.JsonNodeType +import java.io.OutputStream +import kotlin.jvm.optionals.getOrNull +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.apache.hc.core5.http.ContentType +import org.apache.hc.core5.http.HttpEntity + +@JvmSynthetic +internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = + object : HttpRequestBody { + private val bytes: ByteArray by lazy { jsonMapper.writeValueAsBytes(value) } + + override fun writeTo(outputStream: OutputStream) = outputStream.write(bytes) + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long = bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + fields: Map>, +): HttpRequestBody = + object : HttpRequestBody { + private val entity: HttpEntity by lazy { + MultipartEntityBuilder.create() + .apply { + fields.forEach { (name, field) -> + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node).forEach { (name, bytes) -> + addBinaryBody( + name, + bytes, + ContentType.parseLenient(field.contentType), + field.filename().getOrNull(), + ) + } + } + } + .build() + } + + private fun serializePart(name: String, node: JsonNode): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().toByteArray()) + JsonNodeType.BOOLEAN -> + sequenceOf(name to node.booleanValue().toString().toByteArray()) + JsonNodeType.NUMBER -> + sequenceOf(name to node.numberValue().toString().toByteArray()) + JsonNodeType.ARRAY -> + sequenceOf( + name to + node + .elements() + .asSequence() + .mapNotNull { element -> + when (element.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> null + JsonNodeType.STRING -> node.textValue() + JsonNodeType.BOOLEAN -> node.booleanValue().toString() + JsonNodeType.NUMBER -> node.numberValue().toString() + null, + JsonNodeType.BINARY, + JsonNodeType.ARRAY, + JsonNodeType.OBJECT, + JsonNodeType.POJO -> + throw BraintrustInvalidDataException( + "Unexpected JsonNode type in array: ${node.nodeType}" + ) + } + } + .joinToString(",") + .toByteArray() + ) + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> + throw BraintrustInvalidDataException( + "Unexpected JsonNode type: ${node.nodeType}" + ) + } + + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = entity.contentLength + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } 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 e244101b..a9cf0ffa 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 @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -249,14 +250,8 @@ private constructor( */ fun addAddAcl(addAcl: AddAcl) = apply { addAcls = - (addAcls ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addAcl) + (addAcls ?: JsonField.of(mutableListOf())).also { + checkKnown("addAcls", it).add(addAcl) } } @@ -316,14 +311,8 @@ private constructor( */ fun addRemoveAcl(removeAcl: RemoveAcl) = apply { removeAcls = - (removeAcls ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removeAcl) + (removeAcls ?: JsonField.of(mutableListOf())).also { + checkKnown("removeAcls", it).add(removeAcl) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index f31e08fe..fd62e90f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -154,14 +155,8 @@ private constructor( */ fun addAddedAcl(addedAcl: Acl) = apply { addedAcls = - (addedAcls ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addedAcl) + (addedAcls ?: JsonField.of(mutableListOf())).also { + checkKnown("addedAcls", it).add(addedAcl) } } @@ -203,14 +198,8 @@ private constructor( */ fun addRemovedAcl(removedAcl: Acl) = apply { removedAcls = - (removedAcls ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removedAcl) + (removedAcls ?: JsonField.of(mutableListOf())).also { + checkKnown("removedAcls", it).add(removedAcl) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index ee04f29a..39279ff6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -374,16 +375,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 39b4e5cc..b4bd2f57 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -120,14 +121,8 @@ private constructor( /** A list of dataset feedback items */ fun addFeedback(feedback: FeedbackDatasetItem) = apply { this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(feedback) + (this.feedback ?: JsonField.of(mutableListOf())).also { + checkKnown("feedback", it).add(feedback) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 36e3bf88..b2e38b83 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -120,14 +121,8 @@ private constructor( /** A list of dataset events to insert */ fun addEvent(event: InsertDatasetEvent) = apply { events = - (events ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(event) + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 9228eebe..7a4dfb75 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -77,14 +78,8 @@ private constructor( /** A list of env_var objects */ fun addObject(object_: EnvVar) = apply { objects = - (objects ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(object_) + (objects ?: JsonField.of(mutableListOf())).also { + checkKnown("objects", it).add(object_) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index b05bd6d6..6891528d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers @@ -527,14 +528,8 @@ private constructor( /** The functions to score the eval on */ fun addScore(score: Score) = apply { scores = - (scores ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(score) + (scores ?: JsonField.of(mutableListOf())).also { + checkKnown("scores", it).add(score) } } @@ -4356,14 +4351,8 @@ private constructor( fun addField(field: Field) = apply { fields = - (fields ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(field) + (fields ?: JsonField.of(mutableListOf())).also { + checkKnown("fields", it).add(field) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index 515c67f6..3368df50 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -672,14 +673,8 @@ private constructor( */ fun addSpanParent(spanParent: String) = apply { spanParents = - (spanParents ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(spanParent) + (spanParents ?: JsonField.of(mutableListOf())).also { + checkKnown("spanParents", it).add(spanParent) } } @@ -696,16 +691,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index e451ff7f..081bb010 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -120,14 +121,8 @@ private constructor( /** A list of experiment feedback items */ fun addFeedback(feedback: FeedbackExperimentItem) = apply { this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(feedback) + (this.feedback ?: JsonField.of(mutableListOf())).also { + checkKnown("feedback", it).add(feedback) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 162cdf74..ece07b26 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -120,14 +121,8 @@ private constructor( /** A list of experiment events to insert */ fun addEvent(event: InsertExperimentEvent) = apply { events = - (events ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(event) + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 2d80ddb9..81e8578b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -193,16 +194,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index f3e3c234..6187446a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -244,16 +245,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index d928cf3b..948af7fe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -244,16 +245,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index f5b606e7..4ee4c0b6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -100,14 +101,8 @@ private constructor( /** A list of fetched events */ fun addEvent(event: DatasetEvent) = apply { events = - (events ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(event) + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 53fb6159..2c965a55 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -100,14 +101,8 @@ private constructor( /** A list of fetched events */ fun addEvent(event: ExperimentEvent) = apply { events = - (events ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(event) + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 9db30ae3..cb074a16 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -103,14 +104,8 @@ private constructor( /** A list of fetched events */ fun addEvent(event: ProjectLogsEvent) = apply { events = - (events ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(event) + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) } } 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 3d57ba98..07dc4a3f 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 @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.immutableEmptyMap @@ -404,16 +405,7 @@ private constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { 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 b7d04da2..926851bc 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 @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers @@ -374,15 +375,7 @@ private constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index c10b0dc4..7fb3c05d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers @@ -229,14 +230,8 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(message: Message) = apply { messages = - (messages ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(message) + (messages ?: JsonField.of(mutableListOf())).also { + checkKnown("messages", it).add(message) } } @@ -1709,14 +1704,8 @@ private constructor( fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { toolCalls = - (toolCalls ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(toolCall) + (toolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("toolCalls", it).add(toolCall) } } 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 a13c8b1d..7a5df65c 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 @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers @@ -374,15 +375,7 @@ private constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 3fb0cd5b..560d266f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.http.Headers @@ -264,15 +265,7 @@ private constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 9345bea8..5610244f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -280,14 +281,8 @@ private constructor( */ fun addMemberGroup(memberGroup: String) = apply { memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberGroup) + (memberGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("memberGroups", it).add(memberGroup) } } @@ -305,14 +300,8 @@ private constructor( /** Ids of users which belong to this group */ fun addMemberUser(memberUser: String) = apply { memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberUser) + (memberUsers ?: JsonField.of(mutableListOf())).also { + checkKnown("memberUsers", it).add(memberUser) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index f1ae10f4..9b8a20f1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -270,14 +271,8 @@ private constructor( */ fun addMemberGroup(memberGroup: String) = apply { memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberGroup) + (memberGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("memberGroups", it).add(memberGroup) } } @@ -297,14 +292,8 @@ private constructor( /** Ids of users which belong to this group */ fun addMemberUser(memberUser: String) = apply { memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberUser) + (memberUsers ?: JsonField.of(mutableListOf())).also { + checkKnown("memberUsers", it).add(memberUser) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index a89087da..a8ead186 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -270,14 +271,8 @@ private constructor( */ fun addMemberGroup(memberGroup: String) = apply { memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberGroup) + (memberGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("memberGroups", it).add(memberGroup) } } @@ -297,14 +292,8 @@ private constructor( /** Ids of users which belong to this group */ fun addMemberUser(memberUser: String) = apply { memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberUser) + (memberUsers ?: JsonField.of(mutableListOf())).also { + checkKnown("memberUsers", it).add(memberUser) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index c6387d5c..a7f2fd59 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -233,14 +234,8 @@ private constructor( /** A list of group IDs to add to the group's inheriting-from set */ fun addAddMemberGroup(addMemberGroup: String) = apply { addMemberGroups = - (addMemberGroups ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addMemberGroup) + (addMemberGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("addMemberGroups", it).add(addMemberGroup) } } @@ -260,14 +255,8 @@ private constructor( /** A list of user IDs to add to the group */ fun addAddMemberUser(addMemberUser: String) = apply { addMemberUsers = - (addMemberUsers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addMemberUser) + (addMemberUsers ?: JsonField.of(mutableListOf())).also { + checkKnown("addMemberUsers", it).add(addMemberUser) } } @@ -307,14 +296,8 @@ private constructor( /** A list of group IDs to remove from the group's inheriting-from set */ fun addRemoveMemberGroup(removeMemberGroup: String) = apply { removeMemberGroups = - (removeMemberGroups ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removeMemberGroup) + (removeMemberGroups ?: JsonField.of(mutableListOf())).also { + checkKnown("removeMemberGroups", it).add(removeMemberGroup) } } @@ -334,14 +317,8 @@ private constructor( /** A list of user IDs to remove from the group */ fun addRemoveMemberUser(removeMemberUser: String) = apply { removeMemberUsers = - (removeMemberUsers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removeMemberUser) + (removeMemberUsers ?: JsonField.of(mutableListOf())).also { + checkKnown("removeMemberUsers", it).add(removeMemberUser) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index ee1ad30e..801c91b3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -535,14 +536,8 @@ private constructor( */ fun addMergePath(mergePath: List) = apply { _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(mergePath) + (_mergePaths ?: JsonField.of(mutableListOf())).also { + checkKnown("_mergePaths", it).add(mergePath) } } @@ -862,14 +857,8 @@ private constructor( */ fun addSpanParent(spanParent: String) = apply { spanParents = - (spanParents ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(spanParent) + (spanParents ?: JsonField.of(mutableListOf())).also { + checkKnown("spanParents", it).add(spanParent) } } @@ -886,16 +875,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 37dfc296..d2b7ed54 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -90,14 +91,8 @@ private constructor( */ fun addRowId(rowId: String) = apply { rowIds = - (rowIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(rowId) + (rowIds ?: JsonField.of(mutableListOf())).also { + checkKnown("rowIds", it).add(rowId) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index a7befd2e..e878a0b9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -666,14 +667,8 @@ private constructor( */ fun addMergePath(mergePath: List) = apply { _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(mergePath) + (_mergePaths ?: JsonField.of(mutableListOf())).also { + checkKnown("_mergePaths", it).add(mergePath) } } @@ -1122,14 +1117,8 @@ private constructor( */ fun addSpanParent(spanParent: String) = apply { spanParents = - (spanParents ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(spanParent) + (spanParents ?: JsonField.of(mutableListOf())).also { + checkKnown("spanParents", it).add(spanParent) } } @@ -1146,16 +1135,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index 3974ac51..cc78505e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -640,14 +641,8 @@ private constructor( */ fun addMergePath(mergePath: List) = apply { _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(mergePath) + (_mergePaths ?: JsonField.of(mutableListOf())).also { + checkKnown("_mergePaths", it).add(mergePath) } } @@ -1071,14 +1066,8 @@ private constructor( */ fun addSpanParent(spanParent: String) = apply { spanParents = - (spanParents ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(spanParent) + (spanParents ?: JsonField.of(mutableListOf())).also { + checkKnown("spanParents", it).add(spanParent) } } @@ -1095,16 +1084,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 5a017ef4..a5f25109 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.immutableEmptyMap @@ -142,14 +143,8 @@ private constructor( /** The list of scorers to use for online scoring */ fun addScorer(scorer: Scorer) = apply { scorers = - (scorers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(scorer) + (scorers ?: JsonField.of(mutableListOf())).also { + checkKnown("scorers", it).add(scorer) } } @@ -192,14 +187,8 @@ private constructor( /** Trigger online scoring on any spans with a name in this list */ fun addApplyToSpanName(applyToSpanName: String) = apply { applyToSpanNames = - (applyToSpanNames ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(applyToSpanName) + (applyToSpanNames ?: JsonField.of(mutableListOf())).also { + checkKnown("applyToSpanNames", it).add(applyToSpanName) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 81801169..913794f5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import com.braintrustdata.api.core.immutableEmptyMap @@ -663,14 +664,8 @@ private constructor( /** Emails of users to invite */ fun addEmail(email: String) = apply { emails = - (emails ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(email) + (emails ?: JsonField.of(mutableListOf())).also { + checkKnown("emails", it).add(email) } } @@ -697,14 +692,8 @@ private constructor( /** Optional list of group ids to add newly-invited users to. */ fun addGroupId(groupId: String) = apply { groupIds = - (groupIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(groupId) + (groupIds ?: JsonField.of(mutableListOf())).also { + checkKnown("groupIds", it).add(groupId) } } @@ -731,14 +720,8 @@ private constructor( /** Optional list of group names to add newly-invited users to. */ fun addGroupName(groupName: String) = apply { groupNames = - (groupNames ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(groupName) + (groupNames ?: JsonField.of(mutableListOf())).also { + checkKnown("groupNames", it).add(groupName) } } @@ -755,16 +738,7 @@ private constructor( /** Ids of existing users to invite */ fun addId(id: String) = apply { - ids = - (ids ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(id) - } + ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } } /** If true, send invite emails to the users who wore actually added */ @@ -913,14 +887,8 @@ private constructor( /** Emails of users to remove */ fun addEmail(email: String) = apply { emails = - (emails ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(email) + (emails ?: JsonField.of(mutableListOf())).also { + checkKnown("emails", it).add(email) } } @@ -937,16 +905,7 @@ private constructor( /** Ids of users to remove */ fun addId(id: String) = apply { - ids = - (ids ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(id) - } + ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index c2ac0341..57c64fad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -120,14 +121,8 @@ private constructor( /** A list of project logs feedback items */ fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(feedback) + (this.feedback ?: JsonField.of(mutableListOf())).also { + checkKnown("feedback", it).add(feedback) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index ee64bbc9..05e4caf5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -120,14 +121,8 @@ private constructor( /** A list of project logs events to insert */ fun addEvent(event: InsertProjectLogsEvent) = apply { events = - (events ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(event) + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 171bcb19..6df8252d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -635,14 +636,8 @@ private constructor( */ fun addSpanParent(spanParent: String) = apply { spanParents = - (spanParents ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(spanParent) + (spanParents ?: JsonField.of(mutableListOf())).also { + checkKnown("spanParents", it).add(spanParent) } } @@ -659,16 +654,7 @@ private constructor( /** A list of tags to log */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index b5f8ede1..1c8acba4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -326,16 +327,7 @@ private constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 9e47c217..3a8d8c58 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -279,15 +280,7 @@ private constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 0effa429..2760eb8c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.immutableEmptyMap @@ -162,14 +163,8 @@ private constructor( fun addToolFunction(toolFunction: ToolFunction) = apply { toolFunctions = - (toolFunctions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(toolFunction) + (toolFunctions ?: JsonField.of(mutableListOf())).also { + checkKnown("toolFunctions", it).add(toolFunction) } } @@ -1088,14 +1083,8 @@ private constructor( fun addMessage(message: Message) = apply { messages = - (messages ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(message) + (messages ?: JsonField.of(mutableListOf())).also { + checkKnown("messages", it).add(message) } } @@ -2321,14 +2310,8 @@ private constructor( fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { toolCalls = - (toolCalls ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(toolCall) + (toolCalls ?: JsonField.of(mutableListOf())).also { + checkKnown("toolCalls", it).add(toolCall) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index f445cf18..17385b20 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.getOrThrow import com.braintrustdata.api.core.immutableEmptyMap @@ -585,14 +586,8 @@ private constructor( fun addStop(stop: String) = apply { this.stop = - (this.stop ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stop) + (this.stop ?: JsonField.of(mutableListOf())).also { + checkKnown("stop", it).add(stop) } } @@ -2908,14 +2903,8 @@ private constructor( fun addStopSequence(stopSequence: String) = apply { stopSequences = - (stopSequences ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(stopSequence) + (stopSequences ?: JsonField.of(mutableListOf())).also { + checkKnown("stopSequences", it).add(stopSequence) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index da342ba8..47b0e86e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -279,15 +280,7 @@ private constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index c0e63fa7..cc5f2d5c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -244,15 +245,7 @@ private constructor( /** A list of tags for the prompt */ fun addTag(tag: String) = apply { tags = - (tags ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { 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 3235cf51..fa4ccb76 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 @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable @@ -254,14 +255,8 @@ private constructor( /** (permission, restrict_object_type) tuples which belong to this role */ fun addMemberPermission(memberPermission: MemberPermission) = apply { memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberPermission) + (memberPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("memberPermissions", it).add(memberPermission) } } @@ -299,14 +294,8 @@ private constructor( */ fun addMemberRole(memberRole: String) = apply { memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberRole) + (memberRoles ?: JsonField.of(mutableListOf())).also { + checkKnown("memberRoles", it).add(memberRole) } } 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 1fb4e5f8..334d5f6e 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 @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -252,14 +253,8 @@ private constructor( /** (permission, restrict_object_type) tuples which belong to this role */ fun addMemberPermission(memberPermission: MemberPermission) = apply { memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberPermission) + (memberPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("memberPermissions", it).add(memberPermission) } } @@ -299,14 +294,8 @@ private constructor( */ fun addMemberRole(memberRole: String) = apply { memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberRole) + (memberRoles ?: JsonField.of(mutableListOf())).also { + checkKnown("memberRoles", it).add(memberRole) } } 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 87959e90..9c9be4e5 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 @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -252,14 +253,8 @@ private constructor( /** (permission, restrict_object_type) tuples which belong to this role */ fun addMemberPermission(memberPermission: MemberPermission) = apply { memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberPermission) + (memberPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("memberPermissions", it).add(memberPermission) } } @@ -299,14 +294,8 @@ private constructor( */ fun addMemberRole(memberRole: String) = apply { memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(memberRole) + (memberRoles ?: JsonField.of(mutableListOf())).also { + checkKnown("memberRoles", it).add(memberRole) } } 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 c7ee787e..fec75b35 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 @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams @@ -241,14 +242,8 @@ private constructor( /** A list of permissions to add to the role */ fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { addMemberPermissions = - (addMemberPermissions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addMemberPermission) + (addMemberPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("addMemberPermissions", it).add(addMemberPermission) } } @@ -268,14 +263,8 @@ private constructor( /** A list of role IDs to add to the role's inheriting-from set */ fun addAddMemberRole(addMemberRole: String) = apply { addMemberRoles = - (addMemberRoles ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addMemberRole) + (addMemberRoles ?: JsonField.of(mutableListOf())).also { + checkKnown("addMemberRoles", it).add(addMemberRole) } } @@ -318,14 +307,8 @@ private constructor( /** A list of permissions to remove from the role */ fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { removeMemberPermissions = - (removeMemberPermissions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removeMemberPermission) + (removeMemberPermissions ?: JsonField.of(mutableListOf())).also { + checkKnown("removeMemberPermissions", it).add(removeMemberPermission) } } @@ -345,14 +328,8 @@ private constructor( /** A list of role IDs to remove from the role's inheriting-from set */ fun addRemoveMemberRole(removeMemberRole: String) = apply { removeMemberRoles = - (removeMemberRoles ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removeMemberRole) + (removeMemberRoles ?: JsonField.of(mutableListOf())).also { + checkKnown("removeMemberRoles", it).add(removeMemberRole) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 1c403815..73f2ad4e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -104,14 +105,8 @@ private constructor( fun addFilter(filter: JsonValue) = apply { this.filter = - (this.filter ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(filter) + (this.filter ?: JsonField.of(mutableListOf())).also { + checkKnown("filter", it).add(filter) } } @@ -125,14 +120,8 @@ private constructor( fun addMatch(match: JsonValue) = apply { this.match = - (this.match ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(match) + (this.match ?: JsonField.of(mutableListOf())).also { + checkKnown("match", it).add(match) } } @@ -146,14 +135,8 @@ private constructor( fun addSort(sort: JsonValue) = apply { this.sort = - (this.sort ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(sort) + (this.sort ?: JsonField.of(mutableListOf())).also { + checkKnown("sort", it).add(sort) } } @@ -167,15 +150,7 @@ private constructor( fun addTag(tag: JsonValue) = apply { this.tag = - (this.tag ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(tag) - } + (this.tag ?: JsonField.of(mutableListOf())).also { checkKnown("tag", it).add(tag) } } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 7e9c92f4..6a4bb58c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -7,6 +7,7 @@ import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.checkKnown import com.braintrustdata.api.core.immutableEmptyMap import com.braintrustdata.api.core.toImmutable import com.fasterxml.jackson.annotation.JsonAnyGetter @@ -104,14 +105,8 @@ private constructor( fun addColumnOrder(columnOrder: String) = apply { this.columnOrder = - (this.columnOrder ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(columnOrder) + (this.columnOrder ?: JsonField.of(mutableListOf())).also { + checkKnown("columnOrder", it).add(columnOrder) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 72bda297..e99ec877 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index 09ca49bc..fbe03e82 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.AISecret diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index f92c27e3..ca00a3e4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index dddb4cb4..7a5002f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Dataset diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index de39c4c8..c4ed7f35 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EnvVar diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index 01666bf8..d0fc0019 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 5b558c55..432baacd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Experiment diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 926c1de4..27377950 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Function diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index a7a33d1e..db541802 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 6d5ca420..08667293 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index b79fafae..cde96d23 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index bbe1261b..dba161a5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index cc6de7ff..d12a821a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index a391785d..7772aa68 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index 80186773..f4809686 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt index b69e4def..6dd3a6b3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.SpanIFrame diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 424ddc4d..644bd149 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 2731fa30..ac1cca4a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index ed3de639..7c47266f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index c95ac329..39e18573 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index 3ee1d33c..8824fdce 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.AISecret diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index 1b1dac5f..cba100a5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 16fa5eed..033ed993 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Dataset diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index c69790bb..aa611b8f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EnvVar diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index a90a7553..e761eba5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 44e4226f..7ec0526e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Experiment diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 4fc5a880..cf7eb4ad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Function diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 9d16a2eb..84a146af 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index cd1846cc..b6af330b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index 590cb7e7..ec7b0393 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index b4e13de3..502035c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 54f18c7d..79f8d590 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index 59b6e64d..7736249d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index b8f1e52c..8c0a69cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt index 03fd59f0..33029900 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.SpanIFrame diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 4d0c0c1b..8c11e74f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index b82ddb2b..ffd783ac 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index b60fd281..d060fec8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -11,8 +11,8 @@ import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.core.http.HttpResponseFor +import com.braintrustdata.api.core.http.json import com.braintrustdata.api.core.http.parseable -import com.braintrustdata.api.core.json import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.FeedbackResponseSchema From 711d6554708df00be676d724775d090a8f1f5723 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 09:02:47 +0000 Subject: [PATCH 63/87] docs: add raw response readme documentation (#133) --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index ab6d77bb..a1c2025c 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,35 @@ CompletableFuture project = client.projects().create(params); The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. +## Raw responses + +The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body. + +To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: + +```java +import com.braintrustdata.api.core.http.Headers; +import com.braintrustdata.api.core.http.HttpResponseFor; +import com.braintrustdata.api.models.Project; +import com.braintrustdata.api.models.ProjectCreateParams; + +ProjectCreateParams params = ProjectCreateParams.builder() + .name("foobar") + .build(); +HttpResponseFor project = client.projects().withRawResponse().create(params); + +int statusCode = project.statusCode(); +Headers headers = project.headers(); +``` + +You can still deserialize the response into an instance of a Java class if needed: + +```java +import com.braintrustdata.api.models.Project; + +Project parsedProject = project.parse(); +``` + ## Error handling The SDK throws custom unchecked exception types: From c0d11e5cd44c38cb272cab21f18432e25dc204a0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 09:21:14 +0000 Subject: [PATCH 64/87] docs: note required fields in `builder` javadoc (#134) --- .../client/okhttp/BraintrustOkHttpClient.kt | 1 + .../okhttp/BraintrustOkHttpClientAsync.kt | 3 + .../braintrustdata/api/core/ClientOptions.kt | 8 + .../com/braintrustdata/api/core/Timeout.kt | 1 + .../api/errors/BraintrustError.kt | 1 + .../com/braintrustdata/api/models/AISecret.kt | 11 ++ .../com/braintrustdata/api/models/Acl.kt | 11 ++ .../api/models/AclBatchUpdateParams.kt | 20 +++ .../api/models/AclBatchUpdateResponse.kt | 9 + .../api/models/AclCreateParams.kt | 18 ++ .../api/models/AclDeleteParams.kt | 8 + .../api/models/AclFindAndDeleteParams.kt | 18 ++ .../braintrustdata/api/models/AclListPage.kt | 1 + .../api/models/AclListPageAsync.kt | 1 + .../api/models/AclListParams.kt | 9 + .../api/models/AclRetrieveParams.kt | 8 + .../api/models/AiSecretCreateParams.kt | 17 ++ .../api/models/AiSecretDeleteParams.kt | 8 + .../api/models/AiSecretFindAndDeleteParams.kt | 16 ++ .../api/models/AiSecretListPage.kt | 1 + .../api/models/AiSecretListPageAsync.kt | 3 + .../api/models/AiSecretListParams.kt | 1 + .../api/models/AiSecretReplaceParams.kt | 17 ++ .../api/models/AiSecretRetrieveParams.kt | 8 + .../api/models/AiSecretUpdateParams.kt | 10 ++ .../com/braintrustdata/api/models/ApiKey.kt | 10 ++ .../api/models/ApiKeyCreateParams.kt | 16 ++ .../api/models/ApiKeyDeleteParams.kt | 8 + .../api/models/ApiKeyListPage.kt | 1 + .../api/models/ApiKeyListPageAsync.kt | 1 + .../api/models/ApiKeyListParams.kt | 1 + .../api/models/ApiKeyRetrieveParams.kt | 8 + .../models/ChatCompletionContentPartImage.kt | 18 ++ .../models/ChatCompletionContentPartText.kt | 9 + .../models/ChatCompletionMessageToolCall.kt | 20 +++ .../braintrustdata/api/models/CodeBundle.kt | 55 ++++++ .../api/models/CreateApiKeyOutput.kt | 11 ++ .../api/models/CrossObjectInsertResponse.kt | 6 + .../braintrustdata/api/models/DataSummary.kt | 8 + .../com/braintrustdata/api/models/Dataset.kt | 11 ++ .../api/models/DatasetCreateParams.kt | 19 ++ .../api/models/DatasetDeleteParams.kt | 8 + .../braintrustdata/api/models/DatasetEvent.kt | 26 +++ .../api/models/DatasetFeedbackParams.kt | 17 ++ .../api/models/DatasetFetchParams.kt | 8 + .../api/models/DatasetFetchPostParams.kt | 9 + .../api/models/DatasetInsertParams.kt | 17 ++ .../api/models/DatasetListPage.kt | 1 + .../api/models/DatasetListPageAsync.kt | 1 + .../api/models/DatasetListParams.kt | 1 + .../api/models/DatasetRetrieveParams.kt | 8 + .../api/models/DatasetSummarizeParams.kt | 8 + .../api/models/DatasetUpdateParams.kt | 10 ++ .../com/braintrustdata/api/models/EnvVar.kt | 11 ++ .../api/models/EnvVarCreateParams.kt | 20 +++ .../api/models/EnvVarDeleteParams.kt | 8 + .../api/models/EnvVarListParams.kt | 1 + .../api/models/EnvVarListResponse.kt | 8 + .../api/models/EnvVarReplaceParams.kt | 20 +++ .../api/models/EnvVarRetrieveParams.kt | 8 + .../api/models/EnvVarUpdateParams.kt | 17 ++ .../api/models/EvalCreateParams.kt | 168 ++++++++++++++++++ .../braintrustdata/api/models/Experiment.kt | 12 ++ .../api/models/ExperimentCreateParams.kt | 17 ++ .../api/models/ExperimentDeleteParams.kt | 8 + .../api/models/ExperimentEvent.kt | 29 +++ .../api/models/ExperimentFeedbackParams.kt | 17 ++ .../api/models/ExperimentFetchParams.kt | 8 + .../api/models/ExperimentFetchPostParams.kt | 9 + .../api/models/ExperimentInsertParams.kt | 17 ++ .../api/models/ExperimentListPage.kt | 1 + .../api/models/ExperimentListPageAsync.kt | 3 + .../api/models/ExperimentListParams.kt | 1 + .../api/models/ExperimentRetrieveParams.kt | 8 + .../api/models/ExperimentSummarizeParams.kt | 8 + .../api/models/ExperimentUpdateParams.kt | 10 ++ .../api/models/FeedbackDatasetItem.kt | 9 + .../api/models/FeedbackExperimentItem.kt | 10 ++ .../api/models/FeedbackProjectLogsItem.kt | 10 ++ .../api/models/FeedbackResponseSchema.kt | 8 + .../api/models/FetchDatasetEventsResponse.kt | 8 + .../models/FetchExperimentEventsResponse.kt | 9 + .../models/FetchProjectLogsEventsResponse.kt | 9 + .../com/braintrustdata/api/models/Function.kt | 83 +++++++++ .../api/models/FunctionCreateParams.kt | 89 ++++++++++ .../api/models/FunctionDeleteParams.kt | 8 + .../api/models/FunctionInvokeParams.kt | 89 ++++++++++ .../api/models/FunctionInvokeResponse.kt | 1 + .../api/models/FunctionListPage.kt | 1 + .../api/models/FunctionListPageAsync.kt | 3 + .../api/models/FunctionListParams.kt | 1 + .../api/models/FunctionReplaceParams.kt | 89 ++++++++++ .../api/models/FunctionRetrieveParams.kt | 8 + .../api/models/FunctionUpdateParams.kt | 67 +++++++ .../com/braintrustdata/api/models/Group.kt | 10 ++ .../api/models/GroupCreateParams.kt | 16 ++ .../api/models/GroupDeleteParams.kt | 8 + .../api/models/GroupListPage.kt | 1 + .../api/models/GroupListPageAsync.kt | 1 + .../api/models/GroupListParams.kt | 1 + .../api/models/GroupReplaceParams.kt | 16 ++ .../api/models/GroupRetrieveParams.kt | 8 + .../api/models/GroupUpdateParams.kt | 9 + .../api/models/InsertDatasetEvent.kt | 2 + .../api/models/InsertEventsResponse.kt | 8 + .../api/models/InsertExperimentEvent.kt | 5 + .../api/models/InsertProjectLogsEvent.kt | 5 + .../api/models/MetricSummary.kt | 12 ++ .../api/models/OnlineScoreConfig.kt | 27 +++ .../braintrustdata/api/models/Organization.kt | 9 + .../api/models/OrganizationDeleteParams.kt | 8 + .../api/models/OrganizationListPage.kt | 1 + .../api/models/OrganizationListPageAsync.kt | 4 + .../api/models/OrganizationListParams.kt | 1 + .../models/OrganizationMemberUpdateParams.kt | 7 + .../api/models/OrganizationRetrieveParams.kt | 8 + .../api/models/OrganizationUpdateParams.kt | 9 + .../models/PatchOrganizationMembersOutput.kt | 10 ++ .../com/braintrustdata/api/models/Project.kt | 10 ++ .../api/models/ProjectCreateParams.kt | 16 ++ .../api/models/ProjectDeleteParams.kt | 8 + .../api/models/ProjectListPage.kt | 1 + .../api/models/ProjectListPageAsync.kt | 1 + .../api/models/ProjectListParams.kt | 1 + .../api/models/ProjectLogFeedbackParams.kt | 17 ++ .../api/models/ProjectLogFetchParams.kt | 8 + .../api/models/ProjectLogFetchPostParams.kt | 9 + .../api/models/ProjectLogInsertParams.kt | 17 ++ .../api/models/ProjectLogsEvent.kt | 30 ++++ .../api/models/ProjectRetrieveParams.kt | 8 + .../braintrustdata/api/models/ProjectScore.kt | 14 ++ .../api/models/ProjectScoreCategory.kt | 9 + .../api/models/ProjectScoreConfig.kt | 1 + .../api/models/ProjectScoreCreateParams.kt | 22 +++ .../api/models/ProjectScoreDeleteParams.kt | 8 + .../api/models/ProjectScoreListPage.kt | 1 + .../api/models/ProjectScoreListPageAsync.kt | 4 + .../api/models/ProjectScoreListParams.kt | 1 + .../api/models/ProjectScoreReplaceParams.kt | 22 +++ .../api/models/ProjectScoreRetrieveParams.kt | 8 + .../api/models/ProjectScoreUpdateParams.kt | 11 ++ .../api/models/ProjectSettings.kt | 1 + .../braintrustdata/api/models/ProjectTag.kt | 11 ++ .../api/models/ProjectTagCreateParams.kt | 18 ++ .../api/models/ProjectTagDeleteParams.kt | 8 + .../api/models/ProjectTagListPage.kt | 1 + .../api/models/ProjectTagListPageAsync.kt | 3 + .../api/models/ProjectTagListParams.kt | 1 + .../api/models/ProjectTagReplaceParams.kt | 18 ++ .../api/models/ProjectTagRetrieveParams.kt | 8 + .../api/models/ProjectTagUpdateParams.kt | 9 + .../api/models/ProjectUpdateParams.kt | 9 + .../com/braintrustdata/api/models/Prompt.kt | 15 ++ .../api/models/PromptCreateParams.kt | 20 +++ .../braintrustdata/api/models/PromptData.kt | 109 ++++++++++++ .../api/models/PromptDeleteParams.kt | 8 + .../api/models/PromptListPage.kt | 1 + .../api/models/PromptListPageAsync.kt | 1 + .../api/models/PromptListParams.kt | 1 + .../api/models/PromptOptions.kt | 90 ++++++++++ .../api/models/PromptReplaceParams.kt | 20 +++ .../api/models/PromptRetrieveParams.kt | 8 + .../api/models/PromptUpdateParams.kt | 9 + .../com/braintrustdata/api/models/RepoInfo.kt | 1 + .../com/braintrustdata/api/models/Role.kt | 17 ++ .../api/models/RoleCreateParams.kt | 24 +++ .../api/models/RoleDeleteParams.kt | 8 + .../braintrustdata/api/models/RoleListPage.kt | 1 + .../api/models/RoleListPageAsync.kt | 1 + .../api/models/RoleListParams.kt | 1 + .../api/models/RoleReplaceParams.kt | 24 +++ .../api/models/RoleRetrieveParams.kt | 8 + .../api/models/RoleUpdateParams.kt | 25 +++ .../braintrustdata/api/models/ScoreSummary.kt | 11 ++ .../api/models/SpanAttributes.kt | 1 + .../braintrustdata/api/models/SpanIFrame.kt | 11 ++ .../api/models/SpanIframeCreateParams.kt | 20 +++ .../api/models/SpanIframeDeleteParams.kt | 8 + .../api/models/SpanIframeListPage.kt | 1 + .../api/models/SpanIframeListPageAsync.kt | 3 + .../api/models/SpanIframeListParams.kt | 1 + .../api/models/SpanIframeReplaceParams.kt | 20 +++ .../api/models/SpanIframeRetrieveParams.kt | 8 + .../api/models/SpanIframeUpdateParams.kt | 9 + .../api/models/SummarizeDatasetResponse.kt | 11 ++ .../api/models/SummarizeExperimentResponse.kt | 13 ++ .../api/models/TopLevelHelloWorldParams.kt | 1 + .../com/braintrustdata/api/models/User.kt | 8 + .../braintrustdata/api/models/UserListPage.kt | 1 + .../api/models/UserListPageAsync.kt | 1 + .../api/models/UserListParams.kt | 1 + .../api/models/UserRetrieveParams.kt | 8 + .../com/braintrustdata/api/models/View.kt | 12 ++ .../api/models/ViewCreateParams.kt | 22 +++ .../com/braintrustdata/api/models/ViewData.kt | 1 + .../api/models/ViewDataSearch.kt | 1 + .../api/models/ViewDeleteParams.kt | 19 ++ .../braintrustdata/api/models/ViewListPage.kt | 1 + .../api/models/ViewListPageAsync.kt | 1 + .../api/models/ViewListParams.kt | 9 + .../braintrustdata/api/models/ViewOptions.kt | 3 + .../api/models/ViewReplaceParams.kt | 22 +++ .../api/models/ViewRetrieveParams.kt | 10 ++ .../api/models/ViewUpdateParams.kt | 19 ++ 204 files changed, 2585 insertions(+) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 376f0eef..f7e3b145 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -18,6 +18,7 @@ class BraintrustOkHttpClient private constructor() { companion object { + /** Returns a mutable builder for constructing an instance of [BraintrustOkHttpClient]. */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): BraintrustClient = builder().fromEnv().build() diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index 25473f9a..b52e5eba 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -18,6 +18,9 @@ class BraintrustOkHttpClientAsync private constructor() { companion object { + /** + * Returns a mutable builder for constructing an instance of [BraintrustOkHttpClientAsync]. + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): BraintrustClientAsync = builder().fromEnv().build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 9b5dc8d1..e294b689 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -32,6 +32,14 @@ private constructor( const val PRODUCTION_URL = "https://api.braintrust.dev" + /** + * Returns a mutable builder for constructing an instance of [ClientOptions]. + * + * The following fields are required: + * ```java + * .httpClient() + * ``` + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt index c5ffa5e7..c9cffc84 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt @@ -60,6 +60,7 @@ private constructor( @JvmStatic fun default() = builder().build() + /** Returns a mutable builder for constructing an instance of [Timeout]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index b1f14ed8..afcc62d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -27,6 +27,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [BraintrustError]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index f69ebc24..d7fe80d5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -102,6 +102,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AISecret]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .orgId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -236,6 +246,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } 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 2c19ed13..3680c622 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 @@ -177,6 +177,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Acl]. + * + * The following fields are required: + * ```java + * .id() + * ._objectOrgId() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 a9cf0ffa..27e31953 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 @@ -179,6 +179,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -367,6 +368,7 @@ private constructor( @JvmStatic fun none(): AclBatchUpdateParams = builder().build() + /** Returns a mutable builder for constructing an instance of [AclBatchUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -744,6 +746,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AddAcl]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1530,6 +1541,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RemoveAcl]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index fd62e90f..eec25147 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -100,6 +100,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AclBatchUpdateResponse]. + * + * The following fields are required: + * ```java + * .addedAcls() + * .removedAcls() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 323a03d3..25fe4f99 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 @@ -237,6 +237,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -425,6 +434,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AclCreateParams]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index da75bf13..53bbe12f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AclDeleteParams]. + * + * The following fields are required: + * ```java + * .aclId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 55efc0b7..53a2d0af 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 @@ -234,6 +234,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -422,6 +431,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AclFindAndDeleteParams]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index 98db6fd8..b4a78b20 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -126,6 +126,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [AclListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index ae704c5c..9d691383 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -129,6 +129,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [AclListPageAsync]. */ @JvmStatic fun builder() = Builder() } 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 8fad90f0..96d9754c 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 @@ -96,6 +96,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AclListParams]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 83dde98e..a91c07d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AclRetrieveParams]. + * + * The following fields are required: + * ```java + * .aclId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 52186b1d..172661bb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -169,6 +169,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -301,6 +309,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AiSecretCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -527,6 +543,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index 99869a1a..b62db648 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AiSecretDeleteParams]. + * + * The following fields are required: + * ```java + * .aiSecretId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 0ce64f06..977d03ca 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -114,6 +114,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -203,6 +211,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AiSecretFindAndDeleteParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index 5919487c..d64eca00 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -132,6 +132,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [AiSecretListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index ae18f256..09526724 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -138,6 +138,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AiSecretListPageAsync]. + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index d13575ca..76d81eba 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -98,6 +98,7 @@ private constructor( @JvmStatic fun none(): AiSecretListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [AiSecretListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 49d9681f..b9259306 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -169,6 +169,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -301,6 +309,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AiSecretReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -527,6 +543,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index a312db88..63959bb2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AiSecretRetrieveParams]. + * + * The following fields are required: + * ```java + * .aiSecretId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 12b710da..63dcf892 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -133,6 +133,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -226,6 +227,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AiSecretUpdateParams]. + * + * The following fields are required: + * ```java + * .aiSecretId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -428,6 +437,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index f70d6af1..7788eb64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -97,6 +97,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ApiKey]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .previewName() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index f806f2b0..87b6578c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -117,6 +117,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -206,6 +214,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ApiKeyCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index b52bc42e..f0404eda 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ApiKeyDeleteParams]. + * + * The following fields are required: + * ```java + * .apiKeyId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 0b1f6fef..d059a851 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -126,6 +126,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ApiKeyListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index 3220ac2f..86f19e49 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -129,6 +129,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ApiKeyListPageAsync]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 57f6f008..949cd97d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -94,6 +94,7 @@ private constructor( @JvmStatic fun none(): ApiKeyListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [ApiKeyListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 3680e5bb..50963e4d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ApiKeyRetrieveParams]. + * + * The following fields are required: + * ```java + * .apiKeyId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index a5b81c7c..fcb0d184 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -58,6 +58,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionContentPartImage]. + * + * The following fields are required: + * ```java + * .imageUrl() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -151,6 +161,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ImageUrl]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index effad23e..c4b1ce91 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -56,6 +56,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionContentPartText]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 2a8fda20..3ae3ad83 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -63,6 +63,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [ChatCompletionMessageToolCall]. + * + * The following fields are required: + * ```java + * .id() + * .function() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -164,6 +175,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .arguments() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index c3674b44..7a7b5568 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -90,6 +90,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CodeBundle]. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -355,6 +365,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Experiment]. + * + * The following fields are required: + * ```java + * .evalName() + * .position() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -591,6 +611,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Type]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -802,6 +830,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Scorer]. + * + * The following fields are required: + * ```java + * .index() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1135,6 +1172,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .index() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1348,6 +1394,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RuntimeContext]. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index b0407b94..1625c37a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -105,6 +105,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CreateApiKeyOutput]. + * + * The following fields are required: + * ```java + * .id() + * .key() + * .name() + * .previewName() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index fbba8639..ac924f38 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -77,6 +77,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CrossObjectInsertResponse]. + */ @JvmStatic fun builder() = Builder() } @@ -180,6 +183,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Dataset]. */ @JvmStatic fun builder() = Builder() } @@ -259,6 +263,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Experiment]. */ @JvmStatic fun builder() = Builder() } @@ -338,6 +343,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ProjectLogs]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index 59ba3a7c..25297bb3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -54,6 +54,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DataSummary]. + * + * The following fields are required: + * ```java + * .totalRecords() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index a128199b..05df6b61 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -123,6 +123,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Dataset]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -275,6 +285,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 461f22a5..cd64c351 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -136,6 +136,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -240,6 +249,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -440,6 +458,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 7e02f065..8f43631d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetDeleteParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 39279ff6..1c470602 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -199,6 +199,20 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetEvent]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .created() + * .datasetId() + * .projectId() + * .rootSpanId() + * .spanId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -449,6 +463,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -568,6 +583,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Origin]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index b4bd2f57..1b7d0197 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -95,6 +95,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .feedback() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -174,6 +182,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetFeedbackParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * .feedback() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index a059766e..dd174009 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -108,6 +108,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetFetchParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 9f7615ab..19ff1de8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -349,6 +349,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -635,6 +636,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetFetchPostParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index b2e38b83..043cce99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -95,6 +95,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -173,6 +181,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetInsertParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index df8d57fb..684b4947 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -132,6 +132,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [DatasetListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index 8a94e372..edf89d75 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -138,6 +138,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [DatasetListPageAsync]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 8ca6cb67..dae5ecf3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -104,6 +104,7 @@ private constructor( @JvmStatic fun none(): DatasetListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [DatasetListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index a436da98..a75b190a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetRetrieveParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index e9f018f2..a93df899 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetSummarizeParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 53eee982..531c404e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -132,6 +132,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -225,6 +226,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetUpdateParams]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -428,6 +437,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 68316f5b..dadbd453 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -103,6 +103,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EnvVar]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index c9d89fc3..0081c389 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -137,6 +137,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -238,6 +248,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EnvVarCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index d8742267..d9d09741 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EnvVarDeleteParams]. + * + * The following fields are required: + * ```java + * .envVarId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 f8bd3d69..a5444195 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 @@ -80,6 +80,7 @@ private constructor( @JvmStatic fun none(): EnvVarListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [EnvVarListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 7a4dfb75..014c0040 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -52,6 +52,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EnvVarListResponse]. + * + * The following fields are required: + * ```java + * .objects() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index d5fd3641..f26374ba 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -137,6 +137,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -238,6 +248,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EnvVarReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 689b946a..0e424916 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EnvVarRetrieveParams]. + * + * The following fields are required: + * ```java + * .envVarId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 03cd42ed..2906b107 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -113,6 +113,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -190,6 +198,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EnvVarUpdateParams]. + * + * The following fields are required: + * ```java + * .envVarId() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 6891528d..85999f1c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -455,6 +455,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .data() + * .projectId() + * .scores() + * .task() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -856,6 +867,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EvalCreateParams]. + * + * The following fields are required: + * ```java + * .data() + * .projectId() + * .scores() + * .task() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1465,6 +1487,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DatasetId]. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1578,6 +1608,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectDatasetName]. + * + * The following fields are required: + * ```java + * .datasetName() + * .projectName() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1957,6 +1996,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionId]. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2095,6 +2142,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectSlug]. + * + * The following fields are required: + * ```java + * .projectName() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2228,6 +2284,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GlobalFunction]. + * + * The following fields are required: + * ```java + * .globalFunction() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2367,6 +2431,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PromptSessionId]. + * + * The following fields are required: + * ```java + * .promptSessionFunctionId() + * .promptSessionId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2516,6 +2589,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InlineCode]. + * + * The following fields are required: + * ```java + * .code() + * .inlineContext() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2632,6 +2714,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InlineContext]. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2879,6 +2970,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InlinePrompt]. + * + * The following fields are required: + * ```java + * .inlinePrompt() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3266,6 +3365,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionId]. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3404,6 +3511,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectSlug]. + * + * The following fields are required: + * ```java + * .projectName() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3537,6 +3653,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GlobalFunction]. + * + * The following fields are required: + * ```java + * .globalFunction() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3676,6 +3800,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PromptSessionId]. + * + * The following fields are required: + * ```java + * .promptSessionFunctionId() + * .promptSessionId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3825,6 +3958,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InlineCode]. + * + * The following fields are required: + * ```java + * .code() + * .inlineContext() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3941,6 +4083,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InlineContext]. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -4188,6 +4339,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InlinePrompt]. + * + * The following fields are required: + * ```java + * .inlinePrompt() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -4322,6 +4481,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GitMetadataSettings]. + * + * The following fields are required: + * ```java + * .collect() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -4684,6 +4851,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index f125e24c..04bc09bf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -198,6 +198,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Experiment]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * .public_() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -444,6 +455,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 5b9bc375..35705ade 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -281,6 +281,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -519,6 +527,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentCreateParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -830,6 +846,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index ef78cc66..6239af74 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentDeleteParams]. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index 3368df50..f4054a24 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -337,6 +337,20 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentEvent]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .created() + * .experimentId() + * .projectId() + * .rootSpanId() + * .spanId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -810,6 +824,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Context]. */ @JvmStatic fun builder() = Builder() } @@ -950,6 +965,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -1133,6 +1149,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metrics]. */ @JvmStatic fun builder() = Builder() } @@ -1414,6 +1431,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Origin]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1672,6 +1700,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Scores]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 081bb010..b4b3324a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -95,6 +95,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .feedback() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -174,6 +182,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentFeedbackParams]. + * + * The following fields are required: + * ```java + * .experimentId() + * .feedback() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 85fe08a0..e24afa11 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -108,6 +108,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentFetchParams]. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 9df7026b..d8c69a40 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -349,6 +349,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -635,6 +636,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentFetchPostParams]. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index ece07b26..e04423cf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -95,6 +95,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -173,6 +181,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentInsertParams]. + * + * The following fields are required: + * ```java + * .experimentId() + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 53a6e31c..369d2b5e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -136,6 +136,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ExperimentListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index b4b530d3..a47c0c97 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -139,6 +139,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentListPageAsync]. + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 45ff6349..4a6e9faf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -104,6 +104,7 @@ private constructor( @JvmStatic fun none(): ExperimentListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [ExperimentListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 0da1e565..042891d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentRetrieveParams]. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 490d80a6..072b20ad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -63,6 +63,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentSummarizeParams]. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index a444d59d..a1a0b64e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -244,6 +244,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -440,6 +441,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ExperimentUpdateParams]. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -722,6 +731,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 81e8578b..3e229a97 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -107,6 +107,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FeedbackDatasetItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -258,6 +266,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index 6187446a..c07fcf07 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -130,6 +130,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FeedbackExperimentItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -311,6 +319,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -393,6 +402,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Scores]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 948af7fe..f3ee91d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -130,6 +130,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FeedbackProjectLogsItem]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -311,6 +319,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -393,6 +402,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Scores]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index a70ee246..d4e37e96 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -51,6 +51,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FeedbackResponseSchema]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 4ee4c0b6..cf339bb0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -73,6 +73,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FetchDatasetEventsResponse]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 2c965a55..68bacf3d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -73,6 +73,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [FetchExperimentEventsResponse]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index cb074a16..8c45bea6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -75,6 +75,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [FetchProjectLogsEventsResponse]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 07dc4a3f..06b62b9c 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 @@ -220,6 +220,21 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .functionData() + * .logId() + * .name() + * .orgId() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -641,6 +656,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Prompt]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -843,6 +866,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Code]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1125,6 +1157,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Bundle]. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1394,6 +1437,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Inline]. + * + * The following fields are required: + * ```java + * .code() + * .runtimeContext() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1507,6 +1560,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [RuntimeContext]. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1975,6 +2038,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Global]. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2276,6 +2348,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ @JvmStatic fun builder() = Builder() } @@ -2480,6 +2553,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -2596,6 +2670,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Origin]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 926851bc..e79890b5 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 @@ -245,6 +245,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .functionData() + * .name() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -435,6 +446,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionCreateParams]. + * + * The following fields are required: + * ```java + * .functionData() + * .name() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -859,6 +881,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Prompt]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1061,6 +1091,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Code]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1343,6 +1382,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Bundle]. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1612,6 +1662,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Inline]. + * + * The following fields are required: + * ```java + * .code() + * .runtimeContext() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1725,6 +1785,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [RuntimeContext]. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2193,6 +2263,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Global]. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2399,6 +2478,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ @JvmStatic fun builder() = Builder() } @@ -2640,6 +2720,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Origin]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index c017f44d..f2070a12 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionDeleteParams]. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 7fb3c05d..e12c06ec 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -191,6 +191,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -360,6 +361,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionInvokeParams]. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -866,6 +875,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [System]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1093,6 +1110,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [User]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1643,6 +1668,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Assistant]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1883,6 +1916,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionCall]. + * + * The following fields are required: + * ```java + * .arguments() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2029,6 +2071,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Tool]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2258,6 +2308,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .name() + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2477,6 +2536,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Fallback]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2962,6 +3029,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SpanParentStruct]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3181,6 +3257,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PropagatedEvent]. + */ @JvmStatic fun builder() = Builder() } @@ -3297,6 +3376,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RowIds]. + * + * The following fields are required: + * ```java + * .id() + * .rootSpanId() + * .spanId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 602cdae8..3320310c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -37,6 +37,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [FunctionInvokeResponse]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index cbc7dd3b..370a4b99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -132,6 +132,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [FunctionListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index fae52ba9..4b4eebea 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -138,6 +138,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionListPageAsync]. + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 4eeb55b7..8d644404 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -119,6 +119,7 @@ private constructor( @JvmStatic fun none(): FunctionListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [FunctionListParams]. */ @JvmStatic fun builder() = Builder() } 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 7a5df65c..8c45c8d8 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 @@ -245,6 +245,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .functionData() + * .name() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -435,6 +446,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionReplaceParams]. + * + * The following fields are required: + * ```java + * .functionData() + * .name() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -859,6 +881,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Prompt]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1061,6 +1091,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Code]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1343,6 +1382,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Bundle]. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1612,6 +1662,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Inline]. + * + * The following fields are required: + * ```java + * .code() + * .runtimeContext() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1725,6 +1785,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [RuntimeContext]. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2193,6 +2263,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Global]. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2399,6 +2478,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ @JvmStatic fun builder() = Builder() } @@ -2640,6 +2720,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Origin]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index 76d7beb1..a1ec37a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionRetrieveParams]. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 560d266f..2b6a7549 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -180,6 +180,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -320,6 +321,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [FunctionUpdateParams]. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -740,6 +749,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Prompt]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -942,6 +959,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Code]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1224,6 +1250,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Bundle]. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1493,6 +1530,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Inline]. + * + * The following fields are required: + * ```java + * .code() + * .runtimeContext() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1606,6 +1653,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [RuntimeContext]. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2074,6 +2131,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Global]. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2270,6 +2336,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 5610244f..c1a8afba 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -161,6 +161,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Group]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .orgId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 9b8a20f1..8944c4df 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -195,6 +195,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -370,6 +378,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GroupCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 85a98d4f..52f95360 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GroupDeleteParams]. + * + * The following fields are required: + * ```java + * .groupId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 6c40d306..838f3c35 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -126,6 +126,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [GroupListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index 8aaa5521..5a17d75a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -129,6 +129,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [GroupListPageAsync]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index f3fc3721..677c1f83 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -94,6 +94,7 @@ private constructor( @JvmStatic fun none(): GroupListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [GroupListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index a8ead186..907b645b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -195,6 +195,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -370,6 +378,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GroupReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index 6dd1c211..a3aece35 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GroupRetrieveParams]. + * + * The following fields are required: + * ```java + * .groupId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index a7f2fd59..829c2f57 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -193,6 +193,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -375,6 +376,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GroupUpdateParams]. + * + * The following fields are required: + * ```java + * .groupId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index 801c91b3..ea86460a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -358,6 +358,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [InsertDatasetEvent]. */ @JvmStatic fun builder() = Builder() } @@ -949,6 +950,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index d2b7ed54..099bcb9a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -56,6 +56,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InsertEventsResponse]. + * + * The following fields are required: + * ```java + * .rowIds() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index e878a0b9..78a8b93d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -475,6 +475,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [InsertExperimentEvent]. */ @JvmStatic fun builder() = Builder() } @@ -1253,6 +1254,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Context]. */ @JvmStatic fun builder() = Builder() } @@ -1393,6 +1395,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -1576,6 +1579,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metrics]. */ @JvmStatic fun builder() = Builder() } @@ -1825,6 +1829,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Scores]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index cc78505e..828f46ee 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -451,6 +451,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [InsertProjectLogsEvent]. */ @JvmStatic fun builder() = Builder() } @@ -1201,6 +1202,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Context]. */ @JvmStatic fun builder() = Builder() } @@ -1341,6 +1343,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -1524,6 +1527,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metrics]. */ @JvmStatic fun builder() = Builder() } @@ -1773,6 +1777,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Scores]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index ca31c473..a7fa4c4d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -99,6 +99,18 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MetricSummary]. + * + * The following fields are required: + * ```java + * .improvements() + * .metric() + * .name() + * .regressions() + * .unit() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index a5f25109..14c1d67c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -103,6 +103,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [OnlineScoreConfig]. + * + * The following fields are required: + * ```java + * .samplingRate() + * .scorers() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -396,6 +405,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -608,6 +626,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Global]. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 59ea25d6..1835c195 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -107,6 +107,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Organization]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index f6fa9f62..ba3170a9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [OrganizationDeleteParams]. + * + * The following fields are required: + * ```java + * .organizationId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index 57326a65..eac7c40a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -136,6 +136,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [OrganizationListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index 6fea0dce..cdc6536a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -139,6 +139,10 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [OrganizationListPageAsync]. + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index a132ae03..71aa262a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -89,6 +89,7 @@ private constructor( @JvmStatic fun none(): OrganizationListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [OrganizationListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 913794f5..9c8650c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -168,6 +168,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -310,6 +311,10 @@ private constructor( @JvmStatic fun none(): OrganizationMemberUpdateParams = builder().build() + /** + * Returns a mutable builder for constructing an instance of + * [OrganizationMemberUpdateParams]. + */ @JvmStatic fun builder() = Builder() } @@ -623,6 +628,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [InviteUsers]. */ @JvmStatic fun builder() = Builder() } @@ -856,6 +862,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [RemoveUsers]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 09c14c35..3d45ef35 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [OrganizationRetrieveParams]. + * + * The following fields are required: + * ```java + * .organizationId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 9d6505d4..51a92676 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -151,6 +151,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -268,6 +269,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [OrganizationUpdateParams]. + * + * The following fields are required: + * ```java + * .organizationId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 53a0f32d..1124f53f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -79,6 +79,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [PatchOrganizationMembersOutput]. + * + * The following fields are required: + * ```java + * .orgId() + * .status() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 6f4e6f16..ac3cadcc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -109,6 +109,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Project]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .orgId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 09283740..19f07848 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -117,6 +117,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -206,6 +214,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index c63758e3..969df0a9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectDeleteParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index a7870a50..3f97dbd2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -132,6 +132,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ProjectListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 1318884a..2ef21803 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -138,6 +138,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ProjectListPageAsync]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index f6c51805..985b4332 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -94,6 +94,7 @@ private constructor( @JvmStatic fun none(): ProjectListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [ProjectListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 57c64fad..ea2b6b82 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -95,6 +95,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .feedback() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -174,6 +182,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectLogFeedbackParams]. + * + * The following fields are required: + * ```java + * .projectId() + * .feedback() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index c8eb1de7..d7cba0e0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -108,6 +108,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectLogFetchParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 46c79a30..818b7471 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -349,6 +349,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -635,6 +636,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectLogFetchPostParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 05e4caf5..00032977 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -95,6 +95,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -173,6 +181,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectLogInsertParams]. + * + * The following fields are required: + * ```java + * .projectId() + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 6df8252d..84805aa0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -317,6 +317,21 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectLogsEvent]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .created() + * .logId() + * .orgId() + * .projectId() + * .rootSpanId() + * .spanId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -868,6 +883,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Context]. */ @JvmStatic fun builder() = Builder() } @@ -1008,6 +1024,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -1191,6 +1208,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metrics]. */ @JvmStatic fun builder() = Builder() } @@ -1472,6 +1490,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Origin]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1730,6 +1759,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Scores]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 51adb840..6694a858 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectRetrieveParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 3671d969..8c2d7c74 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 @@ -152,6 +152,18 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectScore]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * .scoreType() + * .userId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -650,6 +662,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Weighted]. */ @JvmStatic fun builder() = Builder() } @@ -731,6 +744,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index 758c27a2..9637cd01 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -58,6 +58,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectScoreCategory]. + * + * The following fields are required: + * ```java + * .name() + * .value() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 469e2f5d..909e8b0c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -73,6 +73,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ProjectScoreConfig]. */ @JvmStatic fun builder() = Builder() } 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 5d3b4a60..17695ecb 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 @@ -185,6 +185,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .scoreType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -322,6 +332,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectScoreCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .scoreType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -869,6 +889,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Weighted]. */ @JvmStatic fun builder() = Builder() } @@ -950,6 +971,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index de63fd45..291b304d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectScoreDeleteParams]. + * + * The following fields are required: + * ```java + * .projectScoreId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index 8931ebb4..1779106a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -136,6 +136,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ProjectScoreListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index b6e95b97..f3328758 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -139,6 +139,10 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [ProjectScoreListPageAsync]. + */ @JvmStatic fun builder() = Builder() } 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 aa8094fe..51594ec6 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 @@ -112,6 +112,7 @@ private constructor( @JvmStatic fun none(): ProjectScoreListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [ProjectScoreListParams]. */ @JvmStatic fun builder() = Builder() } 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 e79be7dc..8297ebeb 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 @@ -186,6 +186,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .scoreType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -323,6 +333,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectScoreReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .scoreType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -870,6 +890,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Weighted]. */ @JvmStatic fun builder() = Builder() } @@ -951,6 +972,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 32de5bac..9521a052 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectScoreRetrieveParams]. + * + * The following fields are required: + * ```java + * .projectScoreId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 eade11e7..476ae96c 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 @@ -182,6 +182,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -316,6 +317,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectScoreUpdateParams]. + * + * The following fields are required: + * ```java + * .projectScoreId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -742,6 +751,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Weighted]. */ @JvmStatic fun builder() = Builder() } @@ -823,6 +833,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index 949f7a97..058f4fbb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -54,6 +54,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ProjectSettings]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 687292bc..39dbe262 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -110,6 +110,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectTag]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * .userId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 9a41823d..75097b60 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -136,6 +136,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -240,6 +249,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectTagCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index b9463ba3..1f3d8f1c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectTagDeleteParams]. + * + * The following fields are required: + * ```java + * .projectTagId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 9dfbf8e9..83e4378c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -136,6 +136,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ProjectTagListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 019068c8..885b7cbe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -139,6 +139,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectTagListPageAsync]. + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 8799826c..80fecc14 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -104,6 +104,7 @@ private constructor( @JvmStatic fun none(): ProjectTagListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [ProjectTagListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index 82151795..b708de00 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -137,6 +137,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -241,6 +250,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectTagReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 55c68bdd..90bd6349 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectTagRetrieveParams]. + * + * The following fields are required: + * ```java + * .projectTagId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 66b64560..d0b42595 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -132,6 +132,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -224,6 +225,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectTagUpdateParams]. + * + * The following fields are required: + * ```java + * .projectTagId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index 6632d7bb..c259f853 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -128,6 +128,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -216,6 +217,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ProjectUpdateParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 1c8acba4..1e7c08e1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -179,6 +179,20 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Prompt]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .logId() + * .name() + * .orgId() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -605,6 +619,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 3a8d8c58..2e7e1913 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -189,6 +189,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -337,6 +347,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PromptCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 2760eb8c..86eb51b5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -99,6 +99,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [PromptData]. */ @JvmStatic fun builder() = Builder() } @@ -257,6 +258,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Origin]. */ @JvmStatic fun builder() = Builder() } @@ -381,6 +383,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Parser]. + * + * The following fields are required: + * ```java + * .choiceScores() + * .type() + * .useCot() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -468,6 +480,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ChoiceScores]. */ @JvmStatic fun builder() = Builder() } @@ -834,6 +847,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Completion]. + * + * The following fields are required: + * ```java + * .content() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1056,6 +1078,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Chat]. + * + * The following fields are required: + * ```java + * .messages() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1420,6 +1451,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [System]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1655,6 +1694,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [User]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2245,6 +2292,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Assistant]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2494,6 +2549,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [FunctionCall]. + * + * The following fields are required: + * ```java + * .arguments() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2645,6 +2710,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Tool]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2882,6 +2955,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .name() + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3109,6 +3191,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Fallback]. + * + * The following fields are required: + * ```java + * .role() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3428,6 +3518,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ @JvmStatic fun builder() = Builder() } @@ -3662,6 +3753,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3874,6 +3974,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Global]. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 9d99c9b8..a76243f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PromptDeleteParams]. + * + * The following fields are required: + * ```java + * .promptId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index 7d805029..d13c70a7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -126,6 +126,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [PromptListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index f9a8ebf8..940430e6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -129,6 +129,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [PromptListPageAsync]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index fc81d66a..62a3e4cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -119,6 +119,7 @@ private constructor( @JvmStatic fun none(): PromptListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [PromptListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 17385b20..327ae6a8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -77,6 +77,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [PromptOptions]. */ @JvmStatic fun builder() = Builder() } @@ -489,6 +490,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [OpenAIModelParams]. + */ @JvmStatic fun builder() = Builder() } @@ -935,6 +939,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1228,6 +1240,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [JsonObject]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1440,6 +1460,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [JsonSchema]. + * + * The following fields are required: + * ```java + * .jsonSchema() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1567,6 +1596,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [InnerJsonSchema]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1677,6 +1715,10 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [Schema]. + */ @JvmStatic fun builder() = Builder() } @@ -1907,6 +1949,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Text]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2098,6 +2148,10 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NullableVariant]. + */ @JvmStatic fun builder() = Builder() } @@ -2452,6 +2506,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Function]. + * + * The following fields are required: + * ```java + * .function() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2545,6 +2608,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [InnerFunction]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2848,6 +2920,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AnthropicModelParams]. + * + * The following fields are required: + * ```java + * .maxTokens() + * .temperature() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3048,6 +3129,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GoogleModelParams]. + */ @JvmStatic fun builder() = Builder() } @@ -3203,6 +3287,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [WindowAiModelParams]. + */ @JvmStatic fun builder() = Builder() } @@ -3322,6 +3409,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [JsCompletionParams]. + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 47b0e86e..726e2ba8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -189,6 +189,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -337,6 +347,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PromptReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .slug() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 9aac0566..039b2d8a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PromptRetrieveParams]. + * + * The following fields are required: + * ```java + * .promptId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index cc5f2d5c..eee15e53 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -168,6 +168,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -300,6 +301,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PromptUpdateParams]. + * + * The following fields are required: + * ```java + * .promptId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index e39fcb69..95b541e7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -140,6 +140,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [RepoInfo]. */ @JvmStatic fun builder() = Builder() } 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 fa4ccb76..c75836f2 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 @@ -169,6 +169,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Role]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -431,6 +440,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MemberPermission]. + * + * The following fields are required: + * ```java + * .permission() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 334d5f6e..fdc5ad07 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 @@ -197,6 +197,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -372,6 +380,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RoleCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -659,6 +675,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MemberPermission]. + * + * The following fields are required: + * ```java + * .permission() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 078b4fca..1eae7094 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RoleDeleteParams]. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index 7d9463cb..659fbcb0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -126,6 +126,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [RoleListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index 68486075..baef96f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -129,6 +129,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [RoleListPageAsync]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index b83f7508..8cdb3354 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -94,6 +94,7 @@ private constructor( @JvmStatic fun none(): RoleListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [RoleListParams]. */ @JvmStatic fun builder() = Builder() } 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 9c9be4e5..3769e8bf 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 @@ -197,6 +197,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -372,6 +380,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RoleReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -663,6 +679,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MemberPermission]. + * + * The following fields are required: + * ```java + * .permission() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 350fabb7..70a23fdd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RoleRetrieveParams]. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 fec75b35..347bf045 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 @@ -199,6 +199,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -386,6 +387,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RoleUpdateParams]. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -689,6 +698,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AddMemberPermission]. + * + * The following fields are required: + * ```java + * .permission() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1149,6 +1166,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [RemoveMemberPermission]. + * + * The following fields are required: + * ```java + * .permission() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index 3f942703..ff05be5e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -89,6 +89,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ScoreSummary]. + * + * The following fields are required: + * ```java + * .improvements() + * .name() + * .regressions() + * .score() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 4e3c4b1d..7f734052 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 @@ -60,6 +60,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [SpanAttributes]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index 6bdb2fa0..476c9e6a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -140,6 +140,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SpanIFrame]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * .url() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 5fb0428d..af2eb652 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -165,6 +165,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .url() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -297,6 +307,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SpanIframeCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .url() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt index 101841eb..ca88a657 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SpanIframeDeleteParams]. + * + * The following fields are required: + * ```java + * .spanIframeId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index 99733ffb..ad9f8798 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -136,6 +136,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [SpanIframeListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt index ed0236e1..b851e390 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -139,6 +139,9 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SpanIframeListPageAsync]. + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 45d595ae..29cfffa8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -94,6 +94,7 @@ private constructor( @JvmStatic fun none(): SpanIframeListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [SpanIframeListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index abeb50c4..ef60764f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -165,6 +165,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .url() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -297,6 +307,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SpanIframeReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .url() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt index 14f9bad5..241438c1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SpanIframeRetrieveParams]. + * + * The following fields are required: + * ```java + * .spanIframeId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index db292a0f..e361d331 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -142,6 +142,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -251,6 +252,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SpanIframeUpdateParams]. + * + * The following fields are required: + * ```java + * .spanIframeId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 5b0db332..54a9b9df 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -100,6 +100,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SummarizeDatasetResponse]. + * + * The following fields are required: + * ```java + * .datasetName() + * .datasetUrl() + * .projectName() + * .projectUrl() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 862495e0..2c6af4bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -122,6 +122,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SummarizeExperimentResponse]. + * + * The following fields are required: + * ```java + * .experimentName() + * .experimentUrl() + * .projectName() + * .projectUrl() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -267,6 +278,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metrics]. */ @JvmStatic fun builder() = Builder() } @@ -346,6 +358,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Scores]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 494454d9..a3a17747 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -29,6 +29,7 @@ private constructor( @JvmStatic fun none(): TopLevelHelloWorldParams = builder().build() + /** Returns a mutable builder for constructing an instance of [TopLevelHelloWorldParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index de583017..0fdc6758 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -99,6 +99,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [User]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 296fd25e..12697ca2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -126,6 +126,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [UserListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 476c3745..82830d2e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -129,6 +129,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [UserListPageAsync]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index cf9d9627..41323443 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -113,6 +113,7 @@ private constructor( @JvmStatic fun none(): UserListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [UserListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index 1b67abb8..b5982ab9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [UserRetrieveParams]. + * + * The following fields are required: + * ```java + * .userId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 31cf4186..95dcc589 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 @@ -146,6 +146,18 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [View]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 96521ff2..c9868849 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 @@ -205,6 +205,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -356,6 +367,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ViewCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 3ea48703..ab8fcdc2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -50,6 +50,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ViewData]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 73f2ad4e..8238b323 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -74,6 +74,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ViewDataSearch]. */ @JvmStatic fun builder() = Builder() } 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 6ad63372..fa0585c3 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 @@ -112,6 +112,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -192,6 +201,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ViewDeleteParams]. + * + * The following fields are required: + * ```java + * .viewId() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index 51d70895..a845861b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -126,6 +126,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ViewListPage]. */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index e2984788..0a5f58fb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -129,6 +129,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ViewListPageAsync]. */ @JvmStatic fun builder() = Builder() } 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 ed674b48..6bdea64e 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 @@ -106,6 +106,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ViewListParams]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 6a4bb58c..edbaa607 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -76,6 +76,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ViewOptions]. */ @JvmStatic fun builder() = Builder() } @@ -184,6 +185,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ColumnSizing]. */ @JvmStatic fun builder() = Builder() } @@ -262,6 +264,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ColumnVisibility]. */ @JvmStatic fun builder() = Builder() } 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 647d092d..89eb1c50 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 @@ -205,6 +205,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -356,6 +367,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ViewReplaceParams]. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 2c64f30e..84f0af7c 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 @@ -57,6 +57,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ViewRetrieveParams]. + * + * The following fields are required: + * ```java + * .viewId() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 6b0bf9c9..349c88e5 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 @@ -197,6 +197,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -337,6 +346,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ViewUpdateParams]. + * + * The following fields are required: + * ```java + * .viewId() + * .objectId() + * .objectType() + * ``` + */ @JvmStatic fun builder() = Builder() } From bd8a24d41ddc414c3797a303c2b48ecd643d772b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 09:24:30 +0000 Subject: [PATCH 65/87] chore(client): expose `Optional`, not nullable, from `ClientOptions` (#135) --- .../main/kotlin/com/braintrustdata/api/core/ClientOptions.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index e294b689..1f1d5c23 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -23,9 +23,11 @@ private constructor( @get:JvmName("responseValidation") val responseValidation: Boolean, @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, - @get:JvmName("apiKey") val apiKey: String?, + private val apiKey: String?, ) { + fun apiKey(): Optional = Optional.ofNullable(apiKey) + fun toBuilder() = Builder().from(this) companion object { From 92073d0365dcb479ba2565a41305f56f882fecb3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Mar 2025 05:14:15 +0000 Subject: [PATCH 66/87] feat(client): accept `InputStream` and `Path` for file params (#136) --- .../braintrustdata/api/core/ObjectMappers.kt | 20 +++++++++++ .../com/braintrustdata/api/core/Values.kt | 6 +++- .../api/core/http/HttpRequestBodies.kt | 33 ++++++++++++++----- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt index 5b1f8ea1..37591779 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt @@ -3,19 +3,24 @@ package com.braintrustdata.api.core import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.SerializationFeature +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.cfg.CoercionAction.Fail import com.fasterxml.jackson.databind.cfg.CoercionInputShape.Integer import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder +import java.io.InputStream fun jsonMapper(): JsonMapper = jacksonMapperBuilder() .addModule(Jdk8Module()) .addModule(JavaTimeModule()) + .addModule(SimpleModule().addSerializer(InputStreamJsonSerializer)) .serializationInclusion(JsonInclude.Include.NON_ABSENT) .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) @@ -23,3 +28,18 @@ fun jsonMapper(): JsonMapper = .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) .withCoercionConfig(String::class.java) { it.setCoercion(Integer, Fail) } .build() + +private object InputStreamJsonSerializer : BaseSerializer(InputStream::class) { + + override fun serialize( + value: InputStream?, + gen: JsonGenerator?, + serializers: SerializerProvider?, + ) { + if (value == null) { + gen?.writeNull() + } else { + value.use { gen?.writeBinary(it.readBytes()) } + } + } +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index ad616e28..c25a05d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer +import java.io.InputStream import java.util.Objects import java.util.Optional @@ -508,7 +509,10 @@ private constructor( return MultipartField( value, contentType - ?: if (value is KnownValue && value.value is ByteArray) + ?: if ( + value is KnownValue && + (value.value is InputStream || value.value is ByteArray) + ) "application/octet-stream" else "text/plain; charset=utf-8", filename, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt index a14ed462..bb5b61ab 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt @@ -9,6 +9,8 @@ import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType +import java.io.ByteArrayInputStream +import java.io.InputStream import java.io.OutputStream import kotlin.jvm.optionals.getOrNull import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder @@ -41,8 +43,18 @@ internal fun multipartFormData( MultipartEntityBuilder.create() .apply { fields.forEach { (name, field) -> - val node = jsonMapper.valueToTree(field.value) - serializePart(name, node).forEach { (name, bytes) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> addBinaryBody( name, bytes, @@ -55,16 +67,19 @@ internal fun multipartFormData( .build() } - private fun serializePart(name: String, node: JsonNode): Sequence> = + private fun serializePart( + name: String, + node: JsonNode, + ): Sequence> = when (node.nodeType) { JsonNodeType.MISSING, JsonNodeType.NULL -> emptySequence() - JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue()) - JsonNodeType.STRING -> sequenceOf(name to node.textValue().toByteArray()) + JsonNodeType.BINARY -> sequenceOf(name to ByteArrayInputStream(node.binaryValue())) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().toInputStream()) JsonNodeType.BOOLEAN -> - sequenceOf(name to node.booleanValue().toString().toByteArray()) + sequenceOf(name to node.booleanValue().toString().toInputStream()) JsonNodeType.NUMBER -> - sequenceOf(name to node.numberValue().toString().toByteArray()) + sequenceOf(name to node.numberValue().toString().toInputStream()) JsonNodeType.ARRAY -> sequenceOf( name to @@ -89,7 +104,7 @@ internal fun multipartFormData( } } .joinToString(",") - .toByteArray() + .toInputStream() ) JsonNodeType.OBJECT -> node.fields().asSequence().flatMap { (key, value) -> @@ -102,6 +117,8 @@ internal fun multipartFormData( ) } + private fun String.toInputStream(): InputStream = ByteArrayInputStream(toByteArray()) + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) override fun contentType(): String = entity.contentType From de216b560305cb737647cbc34e7775d84ee0e11e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 7 Mar 2025 05:50:47 +0000 Subject: [PATCH 67/87] feat(client): detect binary incompatible jackson versions (#137) --- .../braintrustdata/api/core/ObjectMappers.kt | 39 +++++++++++++++++++ .../api/core/handlers/JsonHandler.kt | 9 ++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt index 37591779..588027c6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt @@ -2,6 +2,8 @@ package com.braintrustdata.api.core +import com.braintrustdata.api.errors.BraintrustException +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.DeserializationFeature @@ -9,6 +11,8 @@ import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.cfg.CoercionAction.Fail import com.fasterxml.jackson.databind.cfg.CoercionInputShape.Integer +import com.fasterxml.jackson.databind.exc.InvalidDefinitionException +import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.datatype.jdk8.Jdk8Module @@ -43,3 +47,38 @@ private object InputStreamJsonSerializer : BaseSerializer(InputStre } } } + +@JvmSynthetic +internal fun enhanceJacksonException(fallbackMessage: String, e: Exception): Exception { + // These exceptions should only happen if our code is wrong OR if the user is using a binary + // incompatible version of `com.fasterxml.jackson.core:jackson-databind`: + // https://javadoc.io/static/com.fasterxml.jackson.core/jackson-databind/2.18.1/index.html + val isUnexpectedException = + e is UnrecognizedPropertyException || e is InvalidDefinitionException + if (!isUnexpectedException) { + return BraintrustInvalidDataException(fallbackMessage, e) + } + + val jacksonVersion = JsonMapper::class.java.`package`.implementationVersion + if (jacksonVersion.isNullOrEmpty() || jacksonVersion == COMPILED_JACKSON_VERSION) { + return BraintrustInvalidDataException(fallbackMessage, e) + } + + return BraintrustException( + """ + Jackson threw an unexpected exception and its runtime version ($jacksonVersion) mismatches the version the SDK was compiled with ($COMPILED_JACKSON_VERSION). + + You may be using a version of `com.fasterxml.jackson.core:jackson-databind` that's not binary compatible with the SDK. + + This can happen if you are either: + 1. Directly depending on a different Jackson version + 2. Depending on some library that depends on a different Jackson version, potentially transitively + + Double-check that you are depending on a compatible Jackson version. + """ + .trimIndent(), + e, + ) +} + +const val COMPILED_JACKSON_VERSION = "2.18.1" diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt index 6db3e392..ae855a7b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt @@ -2,20 +2,19 @@ package com.braintrustdata.api.core.handlers +import com.braintrustdata.api.core.enhanceJacksonException import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustException import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = object : Handler { - override fun handle(response: HttpResponse): T { + override fun handle(response: HttpResponse): T = try { - return jsonMapper.readValue(response.body(), jacksonTypeRef()) + jsonMapper.readValue(response.body(), jacksonTypeRef()) } catch (e: Exception) { - throw BraintrustException("Error reading response", e) + throw enhanceJacksonException("Error reading response", e) } - } } From d9515531787d8f63c33c977118ea6c58378ee7f9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 8 Mar 2025 06:22:13 +0000 Subject: [PATCH 68/87] feat: generate and publish docs (#138) --- README.md | 3 ++- braintrust-java/build.gradle.kts | 21 +++++++++++++++++++ build.gradle.kts | 19 +++++++++++++++++ .../main/kotlin/braintrust.publish.gradle.kts | 8 +++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1c2025c..ce0fa6e1 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.braintrustdata.api/braintrust-java)](https://central.sonatype.com/artifact/com.braintrustdata.api/braintrust-java/0.7.0) +[![javadoc](https://javadoc.io/badge2/com.braintrustdata.api/braintrust-java/0.7.0/javadoc.svg)](https://javadoc.io/doc/com.braintrustdata.api/braintrust-java/0.7.0) @@ -12,7 +13,7 @@ The Braintrust Java SDK is similar to the Braintrust Kotlin SDK but with minor d It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec). +The REST API documentation can be found on [www.braintrustdata.com](https://www.braintrustdata.com/docs/api/spec). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.braintrustdata.api/braintrust-java/0.7.0). ## Installation diff --git a/braintrust-java/build.gradle.kts b/braintrust-java/build.gradle.kts index ccb65cda..2f936950 100755 --- a/braintrust-java/build.gradle.kts +++ b/braintrust-java/build.gradle.kts @@ -6,3 +6,24 @@ plugins { dependencies { api(project(":braintrust-java-client-okhttp")) } + +// Redefine `dokkaJavadoc` to: +// - Depend on the root project's task for merging the docs of all the projects +// - Forward that task's output to this task's output +tasks.named("dokkaJavadoc").configure { + actions.clear() + + val dokkaJavadocCollector = rootProject.tasks["dokkaJavadocCollector"] + dependsOn(dokkaJavadocCollector) + + val outputDirectory = project.layout.buildDirectory.dir("dokka/javadoc") + doLast { + copy { + from(dokkaJavadocCollector.outputs.files) + into(outputDirectory) + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } + } + + outputs.dir(outputDirectory) +} diff --git a/build.gradle.kts b/build.gradle.kts index 3fc50216..8954c1c2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,23 @@ +plugins { + id("org.jetbrains.dokka") version "2.0.0" +} + +repositories { + mavenCentral() +} + allprojects { group = "com.braintrustdata.api" version = "0.7.0" // x-release-please-version } + +subprojects { + apply(plugin = "org.jetbrains.dokka") +} + +// Avoid race conditions between `dokkaJavadocCollector` and `dokkaJavadocJar` tasks +tasks.named("dokkaJavadocCollector").configure { + subprojects.flatMap { it.tasks } + .filter { it.project.name != "braintrust-java" && it.name == "dokkaJavadocJar" } + .forEach { mustRunAfter(it) } +} diff --git a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts index 5f98590e..c96736ac 100755 --- a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts @@ -1,3 +1,5 @@ +import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinJvm import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost @@ -19,6 +21,12 @@ configure { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) coordinates(project.group.toString(), project.name, project.version.toString()) + configure( + KotlinJvm( + javadocJar = JavadocJar.Dokka("dokkaJavadoc"), + sourcesJar = true, + ) + ) pom { name.set("Braintrust API") From 1e4c3e584f71562c26dde78c3366c75e1e5dd8bb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 8 Mar 2025 06:33:06 +0000 Subject: [PATCH 69/87] chore(internal): add `.kotlin` to `.gitignore` (#139) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 39c31e3e..4e81838d 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .prism.log .gradle .idea +.kotlin build codegen.log kls_database.db From 1db71f8bc37728717ecbfcffb31f6b3afbe4380a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 8 Mar 2025 06:38:03 +0000 Subject: [PATCH 70/87] chore(internal): use `getOrNull` instead of `orElse(null)` (#140) --- .../client/okhttp/BraintrustOkHttpClient.kt | 3 +- .../okhttp/BraintrustOkHttpClientAsync.kt | 3 +- .../braintrustdata/api/core/ClientOptions.kt | 3 +- .../com/braintrustdata/api/core/Timeout.kt | 9 +-- .../com/braintrustdata/api/models/AISecret.kt | 9 +-- .../com/braintrustdata/api/models/Acl.kt | 13 ++-- .../api/models/AclBatchUpdateParams.kt | 29 ++++----- .../api/models/AclCreateParams.kt | 21 +++---- .../api/models/AclFindAndDeleteParams.kt | 21 +++---- .../braintrustdata/api/models/AclListPage.kt | 3 +- .../api/models/AclListParams.kt | 10 ++-- .../api/models/AiSecretCreateParams.kt | 17 +++--- .../api/models/AiSecretFindAndDeleteParams.kt | 5 +- .../api/models/AiSecretListPage.kt | 3 +- .../api/models/AiSecretListParams.kt | 16 ++--- .../api/models/AiSecretReplaceParams.kt | 17 +++--- .../api/models/AiSecretUpdateParams.kt | 17 +++--- .../com/braintrustdata/api/models/ApiKey.kt | 7 ++- .../api/models/ApiKeyCreateParams.kt | 5 +- .../api/models/ApiKeyListPage.kt | 3 +- .../api/models/ApiKeyListParams.kt | 14 ++--- .../braintrustdata/api/models/CodeBundle.kt | 3 +- .../api/models/CreateApiKeyOutput.kt | 7 ++- .../api/models/CrossObjectInsertResponse.kt | 7 ++- .../com/braintrustdata/api/models/Dataset.kt | 11 ++-- .../api/models/DatasetCreateParams.kt | 9 +-- .../braintrustdata/api/models/DatasetEvent.kt | 10 ++-- .../api/models/DatasetFetchParams.kt | 10 ++-- .../api/models/DatasetFetchPostParams.kt | 23 ++++---- .../api/models/DatasetListPage.kt | 3 +- .../api/models/DatasetListParams.kt | 18 +++--- .../api/models/DatasetSummarizeParams.kt | 4 +- .../api/models/DatasetUpdateParams.kt | 13 ++-- .../com/braintrustdata/api/models/EnvVar.kt | 5 +- .../api/models/EnvVarCreateParams.kt | 5 +- .../api/models/EnvVarListParams.kt | 12 ++-- .../api/models/EnvVarReplaceParams.kt | 5 +- .../api/models/EnvVarUpdateParams.kt | 5 +- .../api/models/EvalCreateParams.kt | 55 ++++++++--------- .../braintrustdata/api/models/Experiment.kt | 21 +++---- .../api/models/ExperimentCreateParams.kt | 42 ++++++------- .../api/models/ExperimentEvent.kt | 46 ++++++--------- .../api/models/ExperimentFetchParams.kt | 10 ++-- .../api/models/ExperimentFetchPostParams.kt | 23 ++++---- .../api/models/ExperimentListPage.kt | 3 +- .../api/models/ExperimentListParams.kt | 18 +++--- .../api/models/ExperimentSummarizeParams.kt | 6 +- .../api/models/ExperimentUpdateParams.kt | 35 ++++++----- .../api/models/FeedbackDatasetItem.kt | 9 +-- .../api/models/FeedbackExperimentItem.kt | 11 ++-- .../api/models/FeedbackProjectLogsItem.kt | 11 ++-- .../api/models/FetchDatasetEventsResponse.kt | 3 +- .../models/FetchExperimentEventsResponse.kt | 3 +- .../models/FetchProjectLogsEventsResponse.kt | 3 +- .../com/braintrustdata/api/models/Function.kt | 23 ++++---- .../api/models/FunctionCreateParams.kt | 31 +++++----- .../api/models/FunctionInvokeParams.kt | 25 ++++---- .../api/models/FunctionListPage.kt | 3 +- .../api/models/FunctionListParams.kt | 22 +++---- .../api/models/FunctionReplaceParams.kt | 31 +++++----- .../api/models/FunctionUpdateParams.kt | 19 +++--- .../com/braintrustdata/api/models/Group.kt | 13 ++-- .../api/models/GroupCreateParams.kt | 17 +++--- .../api/models/GroupListPage.kt | 3 +- .../api/models/GroupListParams.kt | 14 ++--- .../api/models/GroupReplaceParams.kt | 17 +++--- .../api/models/GroupUpdateParams.kt | 25 ++++---- .../api/models/InsertDatasetEvent.kt | 25 ++++---- .../api/models/InsertExperimentEvent.kt | 59 ++++++++----------- .../api/models/InsertProjectLogsEvent.kt | 57 ++++++++---------- .../api/models/OnlineScoreConfig.kt | 6 +- .../braintrustdata/api/models/Organization.kt | 12 ++-- .../api/models/OrganizationListPage.kt | 3 +- .../api/models/OrganizationListParams.kt | 12 ++-- .../models/OrganizationMemberUpdateParams.kt | 36 +++++------ .../api/models/OrganizationUpdateParams.kt | 23 ++++---- .../models/PatchOrganizationMembersOutput.kt | 3 +- .../com/braintrustdata/api/models/Project.kt | 9 +-- .../api/models/ProjectCreateParams.kt | 5 +- .../api/models/ProjectListPage.kt | 3 +- .../api/models/ProjectListParams.kt | 14 ++--- .../api/models/ProjectLogFetchParams.kt | 10 ++-- .../api/models/ProjectLogFetchPostParams.kt | 23 ++++---- .../api/models/ProjectLogsEvent.kt | 44 ++++++-------- .../braintrustdata/api/models/ProjectScore.kt | 9 +-- .../api/models/ProjectScoreConfig.kt | 9 ++- .../api/models/ProjectScoreCreateParams.kt | 9 +-- .../api/models/ProjectScoreListPage.kt | 3 +- .../api/models/ProjectScoreListParams.kt | 20 +++---- .../api/models/ProjectScoreReplaceParams.kt | 9 +-- .../api/models/ProjectScoreUpdateParams.kt | 17 +++--- .../api/models/ProjectSettings.kt | 3 +- .../braintrustdata/api/models/ProjectTag.kt | 7 ++- .../api/models/ProjectTagCreateParams.kt | 9 +-- .../api/models/ProjectTagListPage.kt | 3 +- .../api/models/ProjectTagListParams.kt | 18 +++--- .../api/models/ProjectTagReplaceParams.kt | 9 +-- .../api/models/ProjectTagUpdateParams.kt | 13 ++-- .../api/models/ProjectUpdateParams.kt | 9 +-- .../com/braintrustdata/api/models/Prompt.kt | 13 ++-- .../api/models/PromptCreateParams.kt | 17 +++--- .../braintrustdata/api/models/PromptData.kt | 19 +++--- .../api/models/PromptListPage.kt | 3 +- .../api/models/PromptListParams.kt | 22 +++---- .../api/models/PromptOptions.kt | 7 +-- .../api/models/PromptReplaceParams.kt | 17 +++--- .../api/models/PromptUpdateParams.kt | 21 +++---- .../com/braintrustdata/api/models/RepoInfo.kt | 20 +++---- .../com/braintrustdata/api/models/Role.kt | 17 +++--- .../api/models/RoleCreateParams.kt | 19 +++--- .../braintrustdata/api/models/RoleListPage.kt | 3 +- .../api/models/RoleListParams.kt | 14 ++--- .../api/models/RoleReplaceParams.kt | 19 +++--- .../api/models/RoleUpdateParams.kt | 29 ++++----- .../api/models/SpanAttributes.kt | 5 +- .../braintrustdata/api/models/SpanIFrame.kt | 13 ++-- .../api/models/SpanIframeCreateParams.kt | 13 ++-- .../api/models/SpanIframeListPage.kt | 3 +- .../api/models/SpanIframeListParams.kt | 14 ++--- .../api/models/SpanIframeReplaceParams.kt | 13 ++-- .../api/models/SpanIframeUpdateParams.kt | 17 +++--- .../api/models/SummarizeDatasetResponse.kt | 3 +- .../api/models/SummarizeExperimentResponse.kt | 7 ++- .../com/braintrustdata/api/models/User.kt | 11 ++-- .../braintrustdata/api/models/UserListPage.kt | 3 +- .../api/models/UserListParams.kt | 18 +++--- .../com/braintrustdata/api/models/View.kt | 13 ++-- .../api/models/ViewCreateParams.kt | 21 +++---- .../com/braintrustdata/api/models/ViewData.kt | 3 +- .../api/models/ViewDataSearch.kt | 9 +-- .../braintrustdata/api/models/ViewListPage.kt | 3 +- .../api/models/ViewListParams.kt | 14 ++--- .../braintrustdata/api/models/ViewOptions.kt | 7 ++- .../api/models/ViewReplaceParams.kt | 21 +++---- .../api/models/ViewUpdateParams.kt | 21 +++---- 135 files changed, 949 insertions(+), 934 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index f7e3b145..94c291ac 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -13,6 +13,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import kotlin.jvm.optionals.getOrNull class BraintrustOkHttpClient private constructor() { @@ -145,7 +146,7 @@ class BraintrustOkHttpClient private constructor() { fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } - fun apiKey(apiKey: Optional) = apiKey(apiKey.orElse(null)) + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) fun fromEnv() = apply { clientOptions.fromEnv() } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index b52e5eba..ffc88f5c 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -13,6 +13,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import kotlin.jvm.optionals.getOrNull class BraintrustOkHttpClientAsync private constructor() { @@ -147,7 +148,7 @@ class BraintrustOkHttpClientAsync private constructor() { fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } - fun apiKey(apiKey: Optional) = apiKey(apiKey.orElse(null)) + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) fun fromEnv() = apply { clientOptions.fromEnv() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 1f1d5c23..38dc1b87 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper import java.time.Clock import java.util.Optional +import kotlin.jvm.optionals.getOrNull class ClientOptions private constructor( @@ -93,7 +94,7 @@ private constructor( fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } - fun apiKey(apiKey: Optional) = apiKey(apiKey.orElse(null)) + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) fun headers(headers: Headers) = apply { this.headers.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt index c9cffc84..6a0cdcc7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt @@ -5,6 +5,7 @@ package com.braintrustdata.api.core import java.time.Duration import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** A class containing timeouts for various processing phases of a request. */ class Timeout @@ -96,7 +97,7 @@ private constructor( * * Defaults to `Duration.ofMinutes(1)`. */ - fun connect(connect: Optional) = connect(connect.orElse(null)) + fun connect(connect: Optional) = connect(connect.getOrNull()) /** * The maximum time allowed between two data packets when waiting for the server’s response. @@ -114,7 +115,7 @@ private constructor( * * Defaults to `request()`. */ - fun read(read: Optional) = read(read.orElse(null)) + fun read(read: Optional) = read(read.getOrNull()) /** * The maximum time allowed between two data packets when sending the request to the server. @@ -132,7 +133,7 @@ private constructor( * * Defaults to `request()`. */ - fun write(write: Optional) = write(write.orElse(null)) + fun write(write: Optional) = write(write.getOrNull()) /** * The maximum time allowed for a complete HTTP call, not including retries. @@ -156,7 +157,7 @@ private constructor( * * Defaults to `Duration.ofMinutes(1)`. */ - fun request(request: Optional) = request(request.orElse(null)) + fun request(request: Optional) = request(request.getOrNull()) fun build(): Timeout = Timeout(connect, read, write, request) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index d7fe80d5..baafa57f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class AISecret @@ -161,14 +162,14 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of AI secret creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of AI secret creation */ fun created(created: JsonField) = apply { this.created = created } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -176,7 +177,7 @@ private constructor( previewSecret(JsonField.ofNullable(previewSecret)) fun previewSecret(previewSecret: Optional) = - previewSecret(previewSecret.orElse(null)) + previewSecret(previewSecret.getOrNull()) fun previewSecret(previewSecret: JsonField) = apply { this.previewSecret = previewSecret @@ -184,7 +185,7 @@ private constructor( fun type(type: String?) = type(JsonField.ofNullable(type)) - fun type(type: Optional) = type(type.orElse(null)) + fun type(type: Optional) = type(type.getOrNull()) fun type(type: JsonField) = apply { this.type = type } 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 3680c622..f408b1d3 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 @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -251,7 +252,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of acl creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of acl creation */ fun created(created: JsonField) = apply { this.created = created } @@ -266,7 +267,7 @@ private constructor( * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -278,7 +279,7 @@ private constructor( fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Optional) = permission(permission.orElse(null)) + fun permission(permission: Optional) = permission(permission.getOrNull()) /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: JsonField) = apply { this.permission = permission } @@ -295,7 +296,7 @@ private constructor( * specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just the @@ -313,7 +314,7 @@ private constructor( /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -330,7 +331,7 @@ private constructor( * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be 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 27e31953..c7232bb9 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 @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Batch update acls. This operation is idempotent, so adding acls which already exist will have no @@ -221,7 +222,7 @@ private constructor( * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of * a role. */ - fun addAcls(addAcls: Optional>) = addAcls(addAcls.orElse(null)) + fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -282,7 +283,7 @@ private constructor( * a role. */ fun removeAcls(removeAcls: Optional>) = - removeAcls(removeAcls.orElse(null)) + removeAcls(removeAcls.getOrNull()) /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -409,7 +410,7 @@ private constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - fun addAcls(addAcls: Optional>) = addAcls(addAcls.orElse(null)) + fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -457,7 +458,7 @@ private constructor( * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. */ - fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.orElse(null)) + fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) /** * An ACL grants a certain permission or role to a certain user or group on an object. @@ -806,7 +807,7 @@ private constructor( * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -822,7 +823,7 @@ private constructor( /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Optional) = permission(permission.orElse(null)) + fun permission(permission: Optional) = permission(permission.getOrNull()) /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -843,7 +844,7 @@ private constructor( * the specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just @@ -863,7 +864,7 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -881,7 +882,7 @@ private constructor( * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -1601,7 +1602,7 @@ private constructor( * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -1617,7 +1618,7 @@ private constructor( /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Optional) = permission(permission.orElse(null)) + fun permission(permission: Optional) = permission(permission.getOrNull()) /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -1638,7 +1639,7 @@ private constructor( * the specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just @@ -1658,7 +1659,7 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -1676,7 +1677,7 @@ private constructor( * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be 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 25fe4f99..58566fc6 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 @@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new acl. If there is an existing acl with the same contents as the one specified in the @@ -297,7 +298,7 @@ private constructor( * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -313,7 +314,7 @@ private constructor( /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Optional) = permission(permission.orElse(null)) + fun permission(permission: Optional) = permission(permission.getOrNull()) /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -334,7 +335,7 @@ private constructor( * the specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just @@ -354,7 +355,7 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -372,7 +373,7 @@ private constructor( * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -483,7 +484,7 @@ private constructor( * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -495,7 +496,7 @@ private constructor( fun permission(permission: Permission?) = apply { body.permission(permission) } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Optional) = permission(permission.orElse(null)) + fun permission(permission: Optional) = permission(permission.getOrNull()) /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: JsonField) = apply { body.permission(permission) } @@ -513,7 +514,7 @@ private constructor( * specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just the @@ -531,7 +532,7 @@ private constructor( /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -548,7 +549,7 @@ private constructor( * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be 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 53a2d0af..43a401e5 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 @@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Delete a single acl */ class AclFindAndDeleteParams @@ -294,7 +295,7 @@ private constructor( * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -310,7 +311,7 @@ private constructor( /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Optional) = permission(permission.orElse(null)) + fun permission(permission: Optional) = permission(permission.getOrNull()) /** * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -331,7 +332,7 @@ private constructor( * the specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just @@ -351,7 +352,7 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -369,7 +370,7 @@ private constructor( * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -480,7 +481,7 @@ private constructor( * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be @@ -492,7 +493,7 @@ private constructor( fun permission(permission: Permission?) = apply { body.permission(permission) } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Optional) = permission(permission.orElse(null)) + fun permission(permission: Optional) = permission(permission.getOrNull()) /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: JsonField) = apply { body.permission(permission) } @@ -510,7 +511,7 @@ private constructor( * specified object type. Cannot be set alongside a `role_id`. */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** * When setting a permission directly, optionally restricts the permission grant to just the @@ -528,7 +529,7 @@ private constructor( /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: Optional) = roleId(roleId.orElse(null)) + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided @@ -545,7 +546,7 @@ private constructor( * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index b4a78b20..f265a4be 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all acls. The acls are sorted by creation date, with the most recently-created acls @@ -162,7 +163,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } 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 96d9754c..46304214 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 @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all acls. The acls are sorted by creation date, with the most recently-created acls @@ -155,7 +156,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -167,7 +168,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -188,8 +189,7 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * Pagination cursor id. @@ -208,7 +208,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 172661bb..4de28c65 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new ai_secret. If there is an existing ai_secret with the same name as the one specified @@ -208,7 +209,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -224,7 +225,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -243,7 +244,7 @@ private constructor( * Secret value. If omitted in a PUT request, the existing secret value will be left * intact, not replaced with null. */ - fun secret(secret: Optional) = secret(secret.orElse(null)) + fun secret(secret: Optional) = secret(secret.getOrNull()) /** * Secret value. If omitted in a PUT request, the existing secret value will be left @@ -253,7 +254,7 @@ private constructor( fun type(type: String?) = type(JsonField.ofNullable(type)) - fun type(type: Optional) = type(type.orElse(null)) + fun type(type: Optional) = type(type.getOrNull()) fun type(type: JsonField) = apply { this.type = type } @@ -343,7 +344,7 @@ private constructor( fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } @@ -359,7 +360,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -378,7 +379,7 @@ private constructor( * Secret value. If omitted in a PUT request, the existing secret value will be left intact, * not replaced with null. */ - fun secret(secret: Optional) = secret(secret.orElse(null)) + fun secret(secret: Optional) = secret(secret.getOrNull()) /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, @@ -388,7 +389,7 @@ private constructor( fun type(type: String?) = apply { body.type(type) } - fun type(type: Optional) = type(type.orElse(null)) + fun type(type: Optional) = type(type.getOrNull()) fun type(type: JsonField) = apply { body.type(type) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 977d03ca..09e2cfab 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Delete a single ai_secret */ class AiSecretFindAndDeleteParams @@ -157,7 +158,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -255,7 +256,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index d64eca00..31ca38f9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most @@ -168,7 +169,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 76d81eba..d41f9f78 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most @@ -133,12 +134,12 @@ private constructor( fun aiSecretName(aiSecretName: String?) = apply { this.aiSecretName = aiSecretName } /** Name of the ai_secret to search for */ - fun aiSecretName(aiSecretName: Optional) = aiSecretName(aiSecretName.orElse(null)) + fun aiSecretName(aiSecretName: Optional) = aiSecretName(aiSecretName.getOrNull()) fun aiSecretType(aiSecretType: AiSecretType?) = apply { this.aiSecretType = aiSecretType } fun aiSecretType(aiSecretType: Optional) = - aiSecretType(aiSecretType.orElse(null)) + aiSecretType(aiSecretType.getOrNull()) fun aiSecretType(string: String) = aiSecretType(AiSecretType.ofString(string)) @@ -161,7 +162,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -173,7 +174,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -194,14 +195,13 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * Pagination cursor id. @@ -220,7 +220,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index b9259306..30fafd07 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one @@ -208,7 +209,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -224,7 +225,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -243,7 +244,7 @@ private constructor( * Secret value. If omitted in a PUT request, the existing secret value will be left * intact, not replaced with null. */ - fun secret(secret: Optional) = secret(secret.orElse(null)) + fun secret(secret: Optional) = secret(secret.getOrNull()) /** * Secret value. If omitted in a PUT request, the existing secret value will be left @@ -253,7 +254,7 @@ private constructor( fun type(type: String?) = type(JsonField.ofNullable(type)) - fun type(type: Optional) = type(type.orElse(null)) + fun type(type: Optional) = type(type.getOrNull()) fun type(type: JsonField) = apply { this.type = type } @@ -343,7 +344,7 @@ private constructor( fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } @@ -359,7 +360,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -378,7 +379,7 @@ private constructor( * Secret value. If omitted in a PUT request, the existing secret value will be left intact, * not replaced with null. */ - fun secret(secret: Optional) = secret(secret.orElse(null)) + fun secret(secret: Optional) = secret(secret.getOrNull()) /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, @@ -388,7 +389,7 @@ private constructor( fun type(type: String?) = apply { body.type(type) } - fun type(type: Optional) = type(type.orElse(null)) + fun type(type: Optional) = type(type.getOrNull()) fun type(type: JsonField) = apply { body.type(type) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 63dcf892..a1146def 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update an ai_secret object. Specify the fields to update in the payload. Any @@ -157,7 +158,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -165,20 +166,20 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the AI secret */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the AI secret */ fun name(name: JsonField) = apply { this.name = name } fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) - fun secret(secret: Optional) = secret(secret.orElse(null)) + fun secret(secret: Optional) = secret(secret.getOrNull()) fun secret(secret: JsonField) = apply { this.secret = secret } fun type(type: String?) = type(JsonField.ofNullable(type)) - fun type(type: Optional) = type(type.orElse(null)) + fun type(type: Optional) = type(type.getOrNull()) fun type(type: JsonField) = apply { this.type = type } @@ -260,7 +261,7 @@ private constructor( fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } @@ -268,20 +269,20 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the AI secret */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the AI secret */ fun name(name: JsonField) = apply { body.name(name) } fun secret(secret: String?) = apply { body.secret(secret) } - fun secret(secret: Optional) = secret(secret.orElse(null)) + fun secret(secret: Optional) = secret(secret.getOrNull()) fun secret(secret: JsonField) = apply { body.secret(secret) } fun type(type: String?) = apply { body.type(type) } - fun type(type: Optional) = type(type.orElse(null)) + fun type(type: Optional) = type(type.getOrNull()) fun type(type: JsonField) = apply { body.type(type) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 7788eb64..0b88b229 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class ApiKey @@ -152,7 +153,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of api key creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of api key creation */ fun created(created: JsonField) = apply { this.created = created } @@ -161,7 +162,7 @@ private constructor( fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) + fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** Unique identifier for the organization */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } @@ -170,7 +171,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Unique identifier for the user */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Unique identifier for the user */ fun userId(userId: JsonField) = apply { this.userId = userId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 87b6578c..a66bf130 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new api_key. It is possible to have multiple API keys with the same name. There is no @@ -160,7 +161,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the API key belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -258,7 +259,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the API key belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index d059a851..0b0839e1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created @@ -162,7 +163,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 949cd97d..124f92d2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created @@ -127,7 +128,7 @@ private constructor( fun apiKeyName(apiKeyName: String?) = apply { this.apiKeyName = apiKeyName } /** Name of the api_key to search for */ - fun apiKeyName(apiKeyName: Optional) = apiKeyName(apiKeyName.orElse(null)) + fun apiKeyName(apiKeyName: Optional) = apiKeyName(apiKeyName.getOrNull()) /** * Pagination cursor id. @@ -145,7 +146,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -157,7 +158,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -178,14 +179,13 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * Pagination cursor id. @@ -204,7 +204,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index 7a7b5568..e5712817 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class CodeBundle @@ -144,7 +145,7 @@ private constructor( fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) /** A preview of the code */ - fun preview(preview: Optional) = preview(preview.orElse(null)) + fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ fun preview(preview: JsonField) = apply { this.preview = preview } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index 1625c37a..ba204bc6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class CreateApiKeyOutput @@ -169,7 +170,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of api key creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of api key creation */ fun created(created: JsonField) = apply { this.created = created } @@ -178,7 +179,7 @@ private constructor( fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) + fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** Unique identifier for the organization */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } @@ -187,7 +188,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Unique identifier for the user */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Unique identifier for the user */ fun userId(userId: JsonField) = apply { this.userId = userId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index ac924f38..b6a00359 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class CrossObjectInsertResponse @@ -103,7 +104,7 @@ private constructor( fun dataset(dataset: Dataset?) = dataset(JsonField.ofNullable(dataset)) /** A mapping from dataset id to row ids for inserted `events` */ - fun dataset(dataset: Optional) = dataset(dataset.orElse(null)) + fun dataset(dataset: Optional) = dataset(dataset.getOrNull()) /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(dataset: JsonField) = apply { this.dataset = dataset } @@ -112,7 +113,7 @@ private constructor( fun experiment(experiment: Experiment?) = experiment(JsonField.ofNullable(experiment)) /** A mapping from experiment id to row ids for inserted `events` */ - fun experiment(experiment: Optional) = experiment(experiment.orElse(null)) + fun experiment(experiment: Optional) = experiment(experiment.getOrNull()) /** A mapping from experiment id to row ids for inserted `events` */ fun experiment(experiment: JsonField) = apply { this.experiment = experiment } @@ -121,7 +122,7 @@ private constructor( fun projectLogs(projectLogs: ProjectLogs?) = projectLogs(JsonField.ofNullable(projectLogs)) /** A mapping from project id to row ids for inserted `events` */ - fun projectLogs(projectLogs: Optional) = projectLogs(projectLogs.orElse(null)) + fun projectLogs(projectLogs: Optional) = projectLogs(projectLogs.getOrNull()) /** A mapping from project id to row ids for inserted `events` */ fun projectLogs(projectLogs: JsonField) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 05df6b61..6a1818a9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class Dataset @@ -184,7 +185,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of dataset creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of dataset creation */ fun created(created: JsonField) = apply { this.created = created } @@ -193,7 +194,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of dataset deletion, or null if the dataset is still active */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } @@ -202,7 +203,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the dataset */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ fun description(description: JsonField) = apply { this.description = description } @@ -211,7 +212,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** User-controlled metadata about the dataset */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -220,7 +221,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the dataset */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the dataset */ fun userId(userId: JsonField) = apply { this.userId = userId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index cd64c351..be5669c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new dataset. If there is an existing dataset in the project with the same name as the @@ -182,7 +183,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the dataset */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ fun description(description: JsonField) = apply { @@ -193,7 +194,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** User-controlled metadata about the dataset */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -292,7 +293,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the dataset */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ fun description(description: JsonField) = apply { body.description(description) } @@ -301,7 +302,7 @@ private constructor( fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 1c470602..9552e3d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class DatasetEvent @@ -334,8 +335,7 @@ private constructor( fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) /** Whether this span is a root span */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isRoot(isRoot: Optional) = isRoot(isRoot.orElse(null) as Boolean?) + fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } @@ -356,7 +356,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -371,7 +371,7 @@ private constructor( fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ fun origin(origin: JsonField) = apply { this.origin = origin } @@ -380,7 +380,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index dd174009..e045595c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the @@ -194,8 +195,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -224,7 +224,7 @@ private constructor( * paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -252,7 +252,7 @@ private constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time @@ -268,7 +268,7 @@ private constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 19ff1de8..02ffad07 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the @@ -389,7 +390,7 @@ private constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * An opaque string to be used as a cursor for the next page of results, in order from @@ -449,8 +450,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events * containing traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched @@ -497,7 +497,7 @@ private constructor( * overview of paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -541,7 +541,7 @@ private constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -573,7 +573,7 @@ private constructor( * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact * fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time @@ -683,7 +683,7 @@ private constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * An opaque string to be used as a cursor for the next page of results, in order from @@ -743,8 +743,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched @@ -790,7 +789,7 @@ private constructor( * paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -834,7 +833,7 @@ private constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -864,7 +863,7 @@ private constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index 684b4947..ae489e32 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all datasets. The datasets are sorted by creation date, with the most recently-created @@ -168,7 +169,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index dae5ecf3..5ae454e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all datasets. The datasets are sorted by creation date, with the most recently-created @@ -141,7 +142,7 @@ private constructor( fun datasetName(datasetName: String?) = apply { this.datasetName = datasetName } /** Name of the dataset to search for */ - fun datasetName(datasetName: Optional) = datasetName(datasetName.orElse(null)) + fun datasetName(datasetName: Optional) = datasetName(datasetName.getOrNull()) /** * Pagination cursor id. @@ -159,7 +160,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -171,7 +172,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -192,26 +193,25 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** * Pagination cursor id. @@ -230,7 +230,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index a93df899..bea55242 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Summarize dataset */ class DatasetSummarizeParams @@ -93,9 +94,8 @@ private constructor( /** * Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun summarizeData(summarizeData: Optional) = - summarizeData(summarizeData.orElse(null) as Boolean?) + summarizeData(summarizeData.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index 531c404e..a125d34b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a dataset object. Specify the fields to update in the payload. Any object-type @@ -156,7 +157,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the dataset */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ fun description(description: JsonField) = apply { @@ -167,7 +168,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** User-controlled metadata about the dataset */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -176,7 +177,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: JsonField) = apply { this.name = name } @@ -261,7 +262,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the dataset */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ fun description(description: JsonField) = apply { body.description(description) } @@ -270,7 +271,7 @@ private constructor( fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } @@ -279,7 +280,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: JsonField) = apply { body.name(name) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index dadbd453..10a99c22 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class EnvVar @@ -167,7 +168,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of environment variable creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of environment variable creation */ fun created(created: JsonField) = apply { this.created = created } @@ -176,7 +177,7 @@ private constructor( fun used(used: OffsetDateTime?) = used(JsonField.ofNullable(used)) /** Date the environment variable was last used */ - fun used(used: Optional) = used(used.orElse(null)) + fun used(used: Optional) = used(used.getOrNull()) /** Date the environment variable was last used */ fun used(used: JsonField) = apply { this.used = used } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 0081c389..b088aebe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new env_var. If there is an existing env_var with the same name as the one specified in @@ -192,7 +193,7 @@ private constructor( fun value(value: String?) = value(JsonField.ofNullable(value)) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: Optional) = value(value.orElse(null)) + fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: JsonField) = apply { this.value = value } @@ -298,7 +299,7 @@ private constructor( fun value(value: String?) = apply { body.value(value) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: Optional) = value(value.orElse(null)) + fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: JsonField) = apply { body.value(value) } 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 a5444195..b0e9f3c4 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 @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all env_vars. The env_vars are sorted by creation date, with the most recently-created @@ -111,7 +112,7 @@ private constructor( fun envVarName(envVarName: String?) = apply { this.envVarName = envVarName } /** Name of the env_var to search for */ - fun envVarName(envVarName: Optional) = envVarName(envVarName.orElse(null)) + fun envVarName(envVarName: Optional) = envVarName(envVarName.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -123,7 +124,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -144,20 +145,19 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String?) = apply { this.objectId = objectId } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: Optional) = objectId(objectId.orElse(null)) + 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 } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: Optional) = objectType(objectType.orElse(null)) + fun objectType(objectType: Optional) = objectType(objectType.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index f26374ba..da9d9b85 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace env_var. If there is an existing env_var with the same name as the one @@ -192,7 +193,7 @@ private constructor( fun value(value: String?) = value(JsonField.ofNullable(value)) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: Optional) = value(value.orElse(null)) + fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: JsonField) = apply { this.value = value } @@ -298,7 +299,7 @@ private constructor( fun value(value: String?) = apply { body.value(value) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: Optional) = value(value.orElse(null)) + fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: JsonField) = apply { body.value(value) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 2906b107..11d4bded 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update an env_var object. Specify the fields to update in the payload. Any object-type @@ -148,7 +149,7 @@ private constructor( fun value(value: String?) = value(JsonField.ofNullable(value)) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: Optional) = value(value.orElse(null)) + fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: JsonField) = apply { this.value = value } @@ -240,7 +241,7 @@ private constructor( fun value(value: String?) = apply { body.value(value) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: Optional) = value(value.orElse(null)) + fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: JsonField) = apply { body.value(value) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 85999f1c..84bb86ae 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -32,6 +32,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into the @@ -604,7 +605,7 @@ private constructor( * summarized and compared to this experiment. */ fun baseExperimentId(baseExperimentId: Optional) = - baseExperimentId(baseExperimentId.orElse(null)) + baseExperimentId(baseExperimentId.getOrNull()) /** * An optional experiment id to use as a base. If specified, the new experiment will be @@ -626,7 +627,7 @@ private constructor( * be summarized and compared to this experiment. */ fun baseExperimentName(baseExperimentName: Optional) = - baseExperimentName(baseExperimentName.orElse(null)) + baseExperimentName(baseExperimentName.getOrNull()) /** * An optional experiment name to use as a base. If specified, the new experiment will @@ -663,7 +664,7 @@ private constructor( * metadata fields allowed in org-level settings. */ fun gitMetadataSettings(gitMetadataSettings: Optional) = - gitMetadataSettings(gitMetadataSettings.orElse(null)) + gitMetadataSettings(gitMetadataSettings.getOrNull()) /** * Optional settings for collecting git metadata. By default, will collect all git @@ -680,8 +681,7 @@ private constructor( fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) /** Whether the experiment should be public. Defaults to false. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isPublic(isPublic: Optional) = isPublic(isPublic.orElse(null) as Boolean?) + fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: JsonField) = apply { this.isPublic = isPublic } @@ -703,9 +703,8 @@ private constructor( * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun maxConcurrency(maxConcurrency: Optional) = - maxConcurrency(maxConcurrency.orElse(null) as Double?) + maxConcurrency(maxConcurrency.getOrNull()) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to @@ -731,7 +730,7 @@ private constructor( fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } @@ -766,8 +765,7 @@ private constructor( * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, * in which case there is no timeout. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun timeout(timeout: Optional) = timeout(timeout.orElse(null) as Double?) + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, @@ -794,9 +792,7 @@ private constructor( * applications that have non-deterministic behavior and gives you both a stronger * aggregate measure and a sense of the variance in the results. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun trialCount(trialCount: Optional) = - trialCount(trialCount.orElse(null) as Double?) + fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** * The number of times to run the evaluator per input. This is useful for evaluating @@ -982,7 +978,7 @@ private constructor( * summarized and compared to this experiment. */ fun baseExperimentId(baseExperimentId: Optional) = - baseExperimentId(baseExperimentId.orElse(null)) + baseExperimentId(baseExperimentId.getOrNull()) /** * An optional experiment id to use as a base. If specified, the new experiment will be @@ -1005,7 +1001,7 @@ private constructor( * summarized and compared to this experiment. */ fun baseExperimentName(baseExperimentName: Optional) = - baseExperimentName(baseExperimentName.orElse(null)) + baseExperimentName(baseExperimentName.getOrNull()) /** * An optional experiment name to use as a base. If specified, the new experiment will be @@ -1042,7 +1038,7 @@ private constructor( * fields allowed in org-level settings. */ fun gitMetadataSettings(gitMetadataSettings: Optional) = - gitMetadataSettings(gitMetadataSettings.orElse(null)) + gitMetadataSettings(gitMetadataSettings.getOrNull()) /** * Optional settings for collecting git metadata. By default, will collect all git metadata @@ -1059,8 +1055,7 @@ private constructor( fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) /** Whether the experiment should be public. Defaults to false. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isPublic(isPublic: Optional) = isPublic(isPublic.orElse(null) as Boolean?) + fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: JsonField) = apply { body.isPublic(isPublic) } @@ -1081,9 +1076,8 @@ private constructor( * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, * in which case there is no max concurrency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun maxConcurrency(maxConcurrency: Optional) = - maxConcurrency(maxConcurrency.orElse(null) as Double?) + maxConcurrency(maxConcurrency.getOrNull()) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, @@ -1109,7 +1103,7 @@ private constructor( fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } @@ -1144,8 +1138,7 @@ private constructor( * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in * which case there is no timeout. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun timeout(timeout: Optional) = timeout(timeout.orElse(null) as Double?) + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in @@ -1172,9 +1165,7 @@ private constructor( * applications that have non-deterministic behavior and gives you both a stronger aggregate * measure and a sense of the variance in the results. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun trialCount(trialCount: Optional) = - trialCount(trialCount.orElse(null) as Double?) + fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** * The number of times to run the evaluator per input. This is useful for evaluating @@ -2634,7 +2625,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name of the inline code function */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline code function */ fun name(name: JsonField) = apply { this.name = name } @@ -3001,7 +2992,7 @@ private constructor( /** The prompt, model, and its parameters */ fun inlinePrompt(inlinePrompt: Optional) = - inlinePrompt(inlinePrompt.orElse(null)) + inlinePrompt(inlinePrompt.getOrNull()) /** The prompt, model, and its parameters */ fun inlinePrompt(inlinePrompt: JsonField) = apply { @@ -3012,7 +3003,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name of the inline prompt */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline prompt */ fun name(name: JsonField) = apply { this.name = name } @@ -4003,7 +3994,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name of the inline code function */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline code function */ fun name(name: JsonField) = apply { this.name = name } @@ -4370,7 +4361,7 @@ private constructor( /** The prompt, model, and its parameters */ fun inlinePrompt(inlinePrompt: Optional) = - inlinePrompt(inlinePrompt.orElse(null)) + inlinePrompt(inlinePrompt.getOrNull()) /** The prompt, model, and its parameters */ fun inlinePrompt(inlinePrompt: JsonField) = apply { @@ -4381,7 +4372,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name of the inline prompt */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline prompt */ fun name(name: JsonField) = apply { this.name = name } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 04bc09bf..15cc8fb6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class Experiment @@ -284,7 +285,7 @@ private constructor( fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } @@ -293,7 +294,7 @@ private constructor( fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) /** Commit, taken directly from `repo_info.commit` */ - fun commit(commit: Optional) = commit(commit.orElse(null)) + fun commit(commit: Optional) = commit(commit.getOrNull()) /** Commit, taken directly from `repo_info.commit` */ fun commit(commit: JsonField) = apply { this.commit = commit } @@ -302,7 +303,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of experiment creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of experiment creation */ fun created(created: JsonField) = apply { this.created = created } @@ -315,7 +316,7 @@ private constructor( /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) + fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset @@ -334,7 +335,7 @@ private constructor( * reproduce the experiment after the dataset has been modified. */ fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.orElse(null)) + datasetVersion(datasetVersion.getOrNull()) /** * Version number of the linked dataset the experiment was run against. This can be used to @@ -348,7 +349,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of experiment deletion, or null if the experiment is still active */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } @@ -357,7 +358,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the experiment */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ fun description(description: JsonField) = apply { this.description = description } @@ -366,7 +367,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** User-controlled metadata about the experiment */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -375,7 +376,7 @@ private constructor( fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } @@ -384,7 +385,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the experiment */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the experiment */ fun userId(userId: JsonField) = apply { this.userId = userId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 35705ade..ae017556 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new experiment. If there is an existing experiment in the project with the same name as @@ -332,7 +333,7 @@ private constructor( fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } @@ -347,7 +348,7 @@ private constructor( * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) + fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** * Identifier of the linked dataset, or null if the experiment is not linked to a @@ -367,7 +368,7 @@ private constructor( * to reproduce the experiment after the dataset has been modified. */ fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.orElse(null)) + datasetVersion(datasetVersion.getOrNull()) /** * Version number of the linked dataset the experiment was run against. This can be used @@ -381,7 +382,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the experiment */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ fun description(description: JsonField) = apply { @@ -407,9 +408,7 @@ private constructor( * return the existing one un-modified. But if `ensure_new` is true, registration will * generate a new experiment with a unique name in case of a conflict. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun ensureNew(ensureNew: Optional) = - ensureNew(ensureNew.orElse(null) as Boolean?) + fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** * Normally, creating an experiment with the same name as an existing experiment will @@ -422,7 +421,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** User-controlled metadata about the experiment */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -431,7 +430,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: JsonField) = apply { this.name = name } @@ -452,8 +451,7 @@ private constructor( * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun public_(public_: Optional) = public_(public_.orElse(null) as Boolean?) + fun public_(public_: Optional) = public_(public_.getOrNull()) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody @@ -465,7 +463,7 @@ private constructor( fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } @@ -563,7 +561,7 @@ private constructor( fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } @@ -576,7 +574,7 @@ private constructor( /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) + fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset @@ -594,7 +592,7 @@ private constructor( * reproduce the experiment after the dataset has been modified. */ fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.orElse(null)) + datasetVersion(datasetVersion.getOrNull()) /** * Version number of the linked dataset the experiment was run against. This can be used to @@ -608,7 +606,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the experiment */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ fun description(description: JsonField) = apply { body.description(description) } @@ -632,8 +630,7 @@ private constructor( * the existing one un-modified. But if `ensure_new` is true, registration will generate a * new experiment with a unique name in case of a conflict. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.orElse(null) as Boolean?) + fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** * Normally, creating an experiment with the same name as an existing experiment will return @@ -646,7 +643,7 @@ private constructor( fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } @@ -655,7 +652,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: JsonField) = apply { body.name(name) } @@ -676,8 +673,7 @@ private constructor( * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun public_(public_: Optional) = public_(public_.orElse(null) as Boolean?) + fun public_(public_: Optional) = public_(public_.getOrNull()) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody @@ -689,7 +685,7 @@ private constructor( fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index f4054a24..e49339eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class ExperimentEvent @@ -484,7 +485,7 @@ private constructor( * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to * track the location in code which produced the experiment event */ - fun context(context: Optional) = context(context.orElse(null)) + fun context(context: Optional) = context(context.getOrNull()) /** * Context is additional information about the code that produced the experiment event. It @@ -505,7 +506,7 @@ private constructor( * experiment event is tied to */ fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.orElse(null)) + datasetRecordId(datasetRecordId.getOrNull()) /** * If the experiment is associated to a dataset, this is the event-level dataset id this @@ -543,8 +544,7 @@ private constructor( fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) /** Whether this span is a root span */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isRoot(isRoot: Optional) = isRoot(isRoot.orElse(null) as Boolean?) + fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } @@ -565,7 +565,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -588,7 +588,7 @@ private constructor( * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced */ - fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) + fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** * Metrics are numerical measurements tracking the execution of the code that produced the @@ -601,7 +601,7 @@ private constructor( fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ fun origin(origin: JsonField) = apply { this.origin = origin } @@ -635,7 +635,7 @@ private constructor( * determine whether the summarization was covering similar concepts or not. You can use * these scores to help you sort, filter, and compare experiments */ - fun scores(scores: Optional) = scores(scores.orElse(null)) + fun scores(scores: Optional) = scores(scores.getOrNull()) /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a @@ -654,7 +654,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.orElse(null)) + spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: JsonField) = apply { @@ -671,7 +671,7 @@ private constructor( * An array of the parent `span_ids` of this experiment event. This should be empty for the * root span of a trace, and should most often contain just one parent element for subspans */ - fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) + fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** * An array of the parent `span_ids` of this experiment event. This should be empty for the @@ -696,7 +696,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { @@ -850,7 +850,7 @@ private constructor( /** Name of the file in code where the experiment event was created */ fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.orElse(null)) + callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the experiment event was created */ fun callerFilename(callerFilename: JsonField) = apply { @@ -863,7 +863,7 @@ private constructor( /** The function in code which created the experiment event */ fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.orElse(null)) + callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the experiment event */ fun callerFunctionname(callerFunctionname: JsonField) = apply { @@ -877,9 +877,7 @@ private constructor( fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) /** Line of code where the experiment event was created */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun callerLineno(callerLineno: Optional) = - callerLineno(callerLineno.orElse(null) as Long?) + fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: JsonField) = apply { @@ -1210,9 +1208,8 @@ private constructor( * The number of tokens in the completion generated by the model (only set if this is an * LLM span) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.orElse(null) as Long?) + completionTokens(completionTokens.getOrNull()) /** * The number of tokens in the completion generated by the model (only set if this is an @@ -1238,8 +1235,7 @@ private constructor( * A unix timestamp recording when the section of code which produced the experiment * event finished */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun end(end: Optional) = end(end.orElse(null) as Double?) + fun end(end: Optional) = end(end.getOrNull()) /** * A unix timestamp recording when the section of code which produced the experiment @@ -1263,9 +1259,7 @@ private constructor( * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun promptTokens(promptTokens: Optional) = - promptTokens(promptTokens.orElse(null) as Long?) + fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** * The number of tokens in the prompt used to generate the experiment event (only set if @@ -1291,8 +1285,7 @@ private constructor( * A unix timestamp recording when the section of code which produced the experiment * event started */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun start(start: Optional) = start(start.orElse(null) as Double?) + fun start(start: Optional) = start(start.getOrNull()) /** * A unix timestamp recording when the section of code which produced the experiment @@ -1307,8 +1300,7 @@ private constructor( fun tokens(tokens: Long) = tokens(tokens as Long?) /** The total number of tokens in the input and output of the experiment event. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun tokens(tokens: Optional) = tokens(tokens.orElse(null) as Long?) + fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: JsonField) = apply { this.tokens = tokens } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index e24afa11..53ca3670 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the @@ -194,8 +195,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -224,7 +224,7 @@ private constructor( * paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -252,7 +252,7 @@ private constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time @@ -268,7 +268,7 @@ private constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index d8c69a40..b6cde61b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the @@ -389,7 +390,7 @@ private constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * An opaque string to be used as a cursor for the next page of results, in order from @@ -449,8 +450,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events * containing traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched @@ -497,7 +497,7 @@ private constructor( * overview of paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -541,7 +541,7 @@ private constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -573,7 +573,7 @@ private constructor( * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact * fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time @@ -683,7 +683,7 @@ private constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * An opaque string to be used as a cursor for the next page of results, in order from @@ -743,8 +743,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched @@ -790,7 +789,7 @@ private constructor( * paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -834,7 +833,7 @@ private constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -864,7 +863,7 @@ private constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 369d2b5e..246697bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all experiments. The experiments are sorted by creation date, with the most @@ -172,7 +173,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 4a6e9faf..2b4b05c0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all experiments. The experiments are sorted by creation date, with the most @@ -153,14 +154,14 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the experiment to search for */ fun experimentName(experimentName: String?) = apply { this.experimentName = experimentName } /** Name of the experiment to search for */ fun experimentName(experimentName: Optional) = - experimentName(experimentName.orElse(null)) + experimentName(experimentName.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -172,7 +173,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -193,26 +194,25 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** * Pagination cursor id. @@ -231,7 +231,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 072b20ad..c988c73a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Summarize experiment */ class ExperimentSummarizeParams @@ -113,7 +114,7 @@ private constructor( * to be used */ fun comparisonExperimentId(comparisonExperimentId: Optional) = - comparisonExperimentId(comparisonExperimentId.orElse(null)) + comparisonExperimentId(comparisonExperimentId.getOrNull()) /** * Whether to summarize the scores and metrics. If false (or omitted), only the metadata @@ -133,9 +134,8 @@ private constructor( * Whether to summarize the scores and metrics. If false (or omitted), only the metadata * will be returned. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun summarizeScores(summarizeScores: Optional) = - summarizeScores(summarizeScores.orElse(null) as Boolean?) + summarizeScores(summarizeScores.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index a1a0b64e..1f99550c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update an experiment object. Specify the fields to update in the payload. Any @@ -278,7 +279,7 @@ private constructor( fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } @@ -293,7 +294,7 @@ private constructor( * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) + fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** * Identifier of the linked dataset, or null if the experiment is not linked to a @@ -313,7 +314,7 @@ private constructor( * to reproduce the experiment after the dataset has been modified. */ fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.orElse(null)) + datasetVersion(datasetVersion.getOrNull()) /** * Version number of the linked dataset the experiment was run against. This can be used @@ -327,7 +328,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the experiment */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ fun description(description: JsonField) = apply { @@ -338,7 +339,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** User-controlled metadata about the experiment */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -347,7 +348,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: JsonField) = apply { this.name = name } @@ -368,8 +369,7 @@ private constructor( * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun public_(public_: Optional) = public_(public_.orElse(null) as Boolean?) + fun public_(public_: Optional) = public_(public_.getOrNull()) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody @@ -381,7 +381,7 @@ private constructor( fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } @@ -476,7 +476,7 @@ private constructor( fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.orElse(null)) + fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } @@ -489,7 +489,7 @@ private constructor( /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: Optional) = datasetId(datasetId.orElse(null)) + fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset @@ -507,7 +507,7 @@ private constructor( * reproduce the experiment after the dataset has been modified. */ fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.orElse(null)) + datasetVersion(datasetVersion.getOrNull()) /** * Version number of the linked dataset the experiment was run against. This can be used to @@ -521,7 +521,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the experiment */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ fun description(description: JsonField) = apply { body.description(description) } @@ -530,7 +530,7 @@ private constructor( fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } @@ -539,7 +539,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: JsonField) = apply { body.name(name) } @@ -560,8 +560,7 @@ private constructor( * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun public_(public_: Optional) = public_(public_.orElse(null) as Boolean?) + fun public_(public_: Optional) = public_(public_.getOrNull()) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody @@ -573,7 +572,7 @@ private constructor( fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.orElse(null)) + fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 3e229a97..887cdc58 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class FeedbackDatasetItem @@ -154,7 +155,7 @@ private constructor( fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) /** An optional comment string to log about the dataset event */ - fun comment(comment: Optional) = comment(comment.orElse(null)) + fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the dataset event */ fun comment(comment: JsonField) = apply { this.comment = comment } @@ -171,7 +172,7 @@ private constructor( * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can @@ -184,7 +185,7 @@ private constructor( fun source(source: Source?) = source(JsonField.ofNullable(source)) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: Optional) = source(source.orElse(null)) + fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: JsonField) = apply { this.source = source } @@ -193,7 +194,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index c07fcf07..a30bbcd2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class FeedbackExperimentItem @@ -181,7 +182,7 @@ private constructor( fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) /** An optional comment string to log about the experiment event */ - fun comment(comment: Optional) = comment(comment.orElse(null)) + fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the experiment event */ fun comment(comment: JsonField) = apply { this.comment = comment } @@ -204,7 +205,7 @@ private constructor( * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can @@ -223,7 +224,7 @@ private constructor( * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into * the existing scores for the experiment event */ - fun scores(scores: Optional) = scores(scores.orElse(null)) + fun scores(scores: Optional) = scores(scores.getOrNull()) /** * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into @@ -235,7 +236,7 @@ private constructor( fun source(source: Source?) = source(JsonField.ofNullable(source)) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: Optional) = source(source.orElse(null)) + fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: JsonField) = apply { this.source = source } @@ -244,7 +245,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index f3ee91d5..14572b2f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class FeedbackProjectLogsItem @@ -181,7 +182,7 @@ private constructor( fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) /** An optional comment string to log about the project logs event */ - fun comment(comment: Optional) = comment(comment.orElse(null)) + fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the project logs event */ fun comment(comment: JsonField) = apply { this.comment = comment } @@ -204,7 +205,7 @@ private constructor( * log it here and access it in the Braintrust UI. Note, this metadata does not correspond * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can @@ -223,7 +224,7 @@ private constructor( * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into * the existing scores for the project logs event */ - fun scores(scores: Optional) = scores(scores.orElse(null)) + fun scores(scores: Optional) = scores(scores.getOrNull()) /** * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into @@ -235,7 +236,7 @@ private constructor( fun source(source: Source?) = source(JsonField.ofNullable(source)) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: Optional) = source(source.orElse(null)) + fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: JsonField) = apply { this.source = source } @@ -244,7 +245,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index cf339bb0..93503c6a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class FetchDatasetEventsResponse @@ -128,7 +129,7 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 68bacf3d..23656816 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class FetchExperimentEventsResponse @@ -129,7 +130,7 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 8c45bea6..1fd8d53c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class FetchProjectLogsEventsResponse @@ -132,7 +133,7 @@ private constructor( * Pass this string directly as the `cursor` param to your next fetch request to get the * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor 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 06b62b9c..57056d70 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 @@ -30,6 +30,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class Function @@ -346,7 +347,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of prompt creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of prompt creation */ fun created(created: JsonField) = apply { this.created = created } @@ -355,7 +356,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { this.description = description } @@ -366,7 +367,7 @@ private constructor( /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.orElse(null)) + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: JsonField) = apply { @@ -377,7 +378,7 @@ private constructor( functionType(JsonField.ofNullable(functionType)) fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { this.functionType = functionType @@ -387,14 +388,14 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** User-controlled metadata about the prompt */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the prompt */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) fun origin(origin: JsonField) = apply { this.origin = origin } @@ -402,7 +403,7 @@ private constructor( fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } @@ -411,7 +412,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { @@ -1223,7 +1224,7 @@ private constructor( fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) /** A preview of the code */ - fun preview(preview: Optional) = preview(preview.orElse(null)) + fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ fun preview(preview: JsonField) = apply { this.preview = preview } @@ -2728,9 +2729,7 @@ private constructor( * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun internal_(internal_: Optional) = - internal_(internal_.orElse(null) as Boolean?) + fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** * The function exists for internal purposes and should not be displayed in the list of 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 e79890b5..16db9180 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 @@ -33,6 +33,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new function. If there is an existing function in the project with the same slug as the @@ -325,7 +326,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { @@ -338,7 +339,7 @@ private constructor( /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.orElse(null)) + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: JsonField) = apply { @@ -349,7 +350,7 @@ private constructor( functionType(JsonField.ofNullable(functionType)) fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { this.functionType = functionType @@ -357,7 +358,7 @@ private constructor( fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) fun origin(origin: JsonField) = apply { this.origin = origin } @@ -365,7 +366,7 @@ private constructor( fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { @@ -376,7 +377,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { @@ -509,7 +510,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { body.description(description) } @@ -521,7 +522,7 @@ private constructor( /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.orElse(null)) + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: JsonField) = apply { @@ -531,7 +532,7 @@ private constructor( fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { body.functionType(functionType) @@ -539,7 +540,7 @@ private constructor( fun origin(origin: Origin?) = apply { body.origin(origin) } - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) fun origin(origin: JsonField) = apply { body.origin(origin) } @@ -547,7 +548,7 @@ private constructor( fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } @@ -556,7 +557,7 @@ private constructor( fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { body.tags(tags) } @@ -1448,7 +1449,7 @@ private constructor( fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) /** A preview of the code */ - fun preview(preview: Optional) = preview(preview.orElse(null)) + fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ fun preview(preview: JsonField) = apply { this.preview = preview } @@ -2778,9 +2779,7 @@ private constructor( * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun internal_(internal_: Optional) = - internal_(internal_.orElse(null) as Boolean?) + fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** * The function exists for internal purposes and should not be displayed in the list of diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index e12c06ec..2792f617 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -32,6 +32,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Invoke a function. */ class FunctionInvokeParams @@ -259,7 +260,7 @@ private constructor( fun mode(mode: Mode?) = mode(JsonField.ofNullable(mode)) /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: Optional) = mode(mode.orElse(null)) + fun mode(mode: Optional) = mode(mode.getOrNull()) /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: JsonField) = apply { this.mode = mode } @@ -293,8 +294,7 @@ private constructor( * Whether to stream the response. If true, results will be returned in the Braintrust * SSE format. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun stream(stream: Optional) = stream(stream.orElse(null) as Boolean?) + fun stream(stream: Optional) = stream(stream.getOrNull()) /** * Whether to stream the response. If true, results will be returned in the Braintrust @@ -426,7 +426,7 @@ private constructor( fun mode(mode: Mode?) = apply { body.mode(mode) } /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: Optional) = mode(mode.orElse(null)) + fun mode(mode: Optional) = mode(mode.getOrNull()) /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: JsonField) = apply { body.mode(mode) } @@ -461,8 +461,7 @@ private constructor( * Whether to stream the response. If true, results will be returned in the Braintrust SSE * format. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun stream(stream: Optional) = stream(stream.orElse(null) as Boolean?) + fun stream(stream: Optional) = stream(stream.getOrNull()) /** * Whether to stream the response. If true, results will be returned in the Braintrust SSE @@ -1705,7 +1704,7 @@ private constructor( fun content(content: String?) = content(JsonField.ofNullable(content)) - fun content(content: Optional) = content(content.orElse(null)) + fun content(content: Optional) = content(content.getOrNull()) fun content(content: JsonField) = apply { this.content = content } @@ -1713,7 +1712,7 @@ private constructor( functionCall(JsonField.ofNullable(functionCall)) fun functionCall(functionCall: Optional) = - functionCall(functionCall.orElse(null)) + functionCall(functionCall.getOrNull()) fun functionCall(functionCall: JsonField) = apply { this.functionCall = functionCall @@ -1721,7 +1720,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) fun name(name: JsonField) = apply { this.name = name } @@ -1729,7 +1728,7 @@ private constructor( toolCalls(JsonField.ofNullable(toolCalls)) fun toolCalls(toolCalls: Optional>) = - toolCalls(toolCalls.orElse(null)) + toolCalls(toolCalls.getOrNull()) fun toolCalls(toolCalls: JsonField>) = apply { this.toolCalls = toolCalls.map { it.toMutableList() } @@ -2567,7 +2566,7 @@ private constructor( fun content(content: String?) = content(JsonField.ofNullable(content)) - fun content(content: Optional) = content(content.orElse(null)) + fun content(content: Optional) = content(content.getOrNull()) fun content(content: JsonField) = apply { this.content = content } @@ -3077,7 +3076,7 @@ private constructor( /** Include these properties in every span created under this parent */ fun propagatedEvent(propagatedEvent: Optional) = - propagatedEvent(propagatedEvent.orElse(null)) + propagatedEvent(propagatedEvent.getOrNull()) /** Include these properties in every span created under this parent */ fun propagatedEvent(propagatedEvent: JsonField) = apply { @@ -3088,7 +3087,7 @@ private constructor( fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) /** Identifiers for the row to to log a subspan under */ - fun rowIds(rowIds: Optional) = rowIds(rowIds.orElse(null)) + fun rowIds(rowIds: Optional) = rowIds(rowIds.getOrNull()) /** Identifiers for the row to to log a subspan under */ fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 370a4b99..1ed3037c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all functions. The functions are sorted by creation date, with the most recently-created @@ -168,7 +169,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 8d644404..aaf2b9ca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all functions. The functions are sorted by creation date, with the most recently-created @@ -172,13 +173,13 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the function to search for */ fun functionName(functionName: String?) = apply { this.functionName = functionName } /** Name of the function to search for */ - fun functionName(functionName: Optional) = functionName(functionName.orElse(null)) + fun functionName(functionName: Optional) = functionName(functionName.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -190,7 +191,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -211,32 +212,31 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Retrieve prompt with a specific slug */ fun slug(slug: String?) = apply { this.slug = slug } /** Retrieve prompt with a specific slug */ - fun slug(slug: Optional) = slug(slug.orElse(null)) + fun slug(slug: Optional) = slug(slug.getOrNull()) /** * Pagination cursor id. @@ -255,7 +255,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) /** * Retrieve prompt at a specific version. @@ -271,7 +271,7 @@ private constructor( * The version id can either be a transaction id (e.g. '1000192656880881099') or a version * identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() 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 8c45c8d8..bd9be34c 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 @@ -33,6 +33,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace function. If there is an existing function in the project with the same slug as @@ -325,7 +326,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { @@ -338,7 +339,7 @@ private constructor( /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.orElse(null)) + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: JsonField) = apply { @@ -349,7 +350,7 @@ private constructor( functionType(JsonField.ofNullable(functionType)) fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { this.functionType = functionType @@ -357,7 +358,7 @@ private constructor( fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) fun origin(origin: JsonField) = apply { this.origin = origin } @@ -365,7 +366,7 @@ private constructor( fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { @@ -376,7 +377,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { @@ -509,7 +510,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { body.description(description) } @@ -521,7 +522,7 @@ private constructor( /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.orElse(null)) + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: JsonField) = apply { @@ -531,7 +532,7 @@ private constructor( fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { body.functionType(functionType) @@ -539,7 +540,7 @@ private constructor( fun origin(origin: Origin?) = apply { body.origin(origin) } - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) fun origin(origin: JsonField) = apply { body.origin(origin) } @@ -547,7 +548,7 @@ private constructor( fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } @@ -556,7 +557,7 @@ private constructor( fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { body.tags(tags) } @@ -1448,7 +1449,7 @@ private constructor( fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) /** A preview of the code */ - fun preview(preview: Optional) = preview(preview.orElse(null)) + fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ fun preview(preview: JsonField) = apply { this.preview = preview } @@ -2778,9 +2779,7 @@ private constructor( * The function exists for internal purposes and should not be displayed in the list of * functions. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun internal_(internal_: Optional) = - internal_(internal_.orElse(null) as Boolean?) + fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** * The function exists for internal purposes and should not be displayed in the list of diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 2b6a7549..1f55b477 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -33,6 +33,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a function object. Specify the fields to update in the payload. Any object-type @@ -208,7 +209,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { @@ -236,7 +237,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the prompt */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ fun name(name: JsonField) = apply { this.name = name } @@ -245,7 +246,7 @@ private constructor( fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { @@ -256,7 +257,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { @@ -356,7 +357,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { body.description(description) } @@ -381,7 +382,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ fun name(name: JsonField) = apply { body.name(name) } @@ -390,7 +391,7 @@ private constructor( fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } @@ -399,7 +400,7 @@ private constructor( fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { body.tags(tags) } @@ -1316,7 +1317,7 @@ private constructor( fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) /** A preview of the code */ - fun preview(preview: Optional) = preview(preview.orElse(null)) + fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ fun preview(preview: JsonField) = apply { this.preview = preview } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index c1a8afba..2dc72265 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * A group is a collection of users which can be assigned an ACL @@ -232,7 +233,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of group creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of group creation */ fun created(created: JsonField) = apply { this.created = created } @@ -241,7 +242,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of group deletion, or null if the group is still active */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } @@ -250,7 +251,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the group */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ fun description(description: JsonField) = apply { this.description = description } @@ -271,7 +272,7 @@ private constructor( * their inherited users */ fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.orElse(null)) + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from @@ -300,7 +301,7 @@ private constructor( fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.orElse(null)) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ fun memberUsers(memberUsers: JsonField>) = apply { @@ -319,7 +320,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the group */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the group */ fun userId(userId: JsonField) = apply { this.userId = userId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 8944c4df..492a36c7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new group. If there is an existing group with the same name as the one specified in the @@ -236,7 +237,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the group */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ fun description(description: JsonField) = apply { @@ -259,7 +260,7 @@ private constructor( * of their inherited users */ fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.orElse(null)) + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from @@ -290,7 +291,7 @@ private constructor( /** Ids of users which belong to this group */ fun memberUsers(memberUsers: Optional>) = - memberUsers(memberUsers.orElse(null)) + memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ fun memberUsers(memberUsers: JsonField>) = apply { @@ -317,7 +318,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -414,7 +415,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the group */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ fun description(description: JsonField) = apply { body.description(description) } @@ -434,7 +435,7 @@ private constructor( * their inherited users */ fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.orElse(null)) + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from @@ -458,7 +459,7 @@ private constructor( fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.orElse(null)) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ fun memberUsers(memberUsers: JsonField>) = apply { @@ -480,7 +481,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 838f3c35..b0123cdf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all groups. The groups are sorted by creation date, with the most recently-created @@ -162,7 +163,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 677c1f83..d63abcd7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all groups. The groups are sorted by creation date, with the most recently-created @@ -139,13 +140,13 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the group to search for */ fun groupName(groupName: String?) = apply { this.groupName = groupName } /** Name of the group to search for */ - fun groupName(groupName: Optional) = groupName(groupName.orElse(null)) + fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -157,7 +158,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -178,14 +179,13 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * Pagination cursor id. @@ -204,7 +204,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 907b645b..add7d123 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace group. If there is an existing group with the same name as the one specified in @@ -236,7 +237,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the group */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ fun description(description: JsonField) = apply { @@ -259,7 +260,7 @@ private constructor( * of their inherited users */ fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.orElse(null)) + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from @@ -290,7 +291,7 @@ private constructor( /** Ids of users which belong to this group */ fun memberUsers(memberUsers: Optional>) = - memberUsers(memberUsers.orElse(null)) + memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ fun memberUsers(memberUsers: JsonField>) = apply { @@ -317,7 +318,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -414,7 +415,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the group */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ fun description(description: JsonField) = apply { body.description(description) } @@ -434,7 +435,7 @@ private constructor( * their inherited users */ fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.orElse(null)) + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from @@ -458,7 +459,7 @@ private constructor( fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.orElse(null)) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ fun memberUsers(memberUsers: JsonField>) = apply { @@ -480,7 +481,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 829c2f57..5945b26a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a group object. Specify the fields to update in the payload. Any object-type @@ -225,7 +226,7 @@ private constructor( /** A list of group IDs to add to the group's inheriting-from set */ fun addMemberGroups(addMemberGroups: Optional>) = - addMemberGroups(addMemberGroups.orElse(null)) + addMemberGroups(addMemberGroups.getOrNull()) /** A list of group IDs to add to the group's inheriting-from set */ fun addMemberGroups(addMemberGroups: JsonField>) = apply { @@ -246,7 +247,7 @@ private constructor( /** A list of user IDs to add to the group */ fun addMemberUsers(addMemberUsers: Optional>) = - addMemberUsers(addMemberUsers.orElse(null)) + addMemberUsers(addMemberUsers.getOrNull()) /** A list of user IDs to add to the group */ fun addMemberUsers(addMemberUsers: JsonField>) = apply { @@ -265,7 +266,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the group */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ fun description(description: JsonField) = apply { @@ -276,7 +277,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the group */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the group */ fun name(name: JsonField) = apply { this.name = name } @@ -287,7 +288,7 @@ private constructor( /** A list of group IDs to remove from the group's inheriting-from set */ fun removeMemberGroups(removeMemberGroups: Optional>) = - removeMemberGroups(removeMemberGroups.orElse(null)) + removeMemberGroups(removeMemberGroups.getOrNull()) /** A list of group IDs to remove from the group's inheriting-from set */ fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { @@ -308,7 +309,7 @@ private constructor( /** A list of user IDs to remove from the group */ fun removeMemberUsers(removeMemberUsers: Optional>) = - removeMemberUsers(removeMemberUsers.orElse(null)) + removeMemberUsers(removeMemberUsers.getOrNull()) /** A list of user IDs to remove from the group */ fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { @@ -414,7 +415,7 @@ private constructor( /** A list of group IDs to add to the group's inheriting-from set */ fun addMemberGroups(addMemberGroups: Optional>) = - addMemberGroups(addMemberGroups.orElse(null)) + addMemberGroups(addMemberGroups.getOrNull()) /** A list of group IDs to add to the group's inheriting-from set */ fun addMemberGroups(addMemberGroups: JsonField>) = apply { @@ -433,7 +434,7 @@ private constructor( /** A list of user IDs to add to the group */ fun addMemberUsers(addMemberUsers: Optional>) = - addMemberUsers(addMemberUsers.orElse(null)) + addMemberUsers(addMemberUsers.getOrNull()) /** A list of user IDs to add to the group */ fun addMemberUsers(addMemberUsers: JsonField>) = apply { @@ -447,7 +448,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the group */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ fun description(description: JsonField) = apply { body.description(description) } @@ -456,7 +457,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the group */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the group */ fun name(name: JsonField) = apply { body.name(name) } @@ -468,7 +469,7 @@ private constructor( /** A list of group IDs to remove from the group's inheriting-from set */ fun removeMemberGroups(removeMemberGroups: Optional>) = - removeMemberGroups(removeMemberGroups.orElse(null)) + removeMemberGroups(removeMemberGroups.getOrNull()) /** A list of group IDs to remove from the group's inheriting-from set */ fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { @@ -487,7 +488,7 @@ private constructor( /** A list of user IDs to remove from the group */ fun removeMemberUsers(removeMemberUsers: Optional>) = - removeMemberUsers(removeMemberUsers.orElse(null)) + removeMemberUsers(removeMemberUsers.getOrNull()) /** A list of user IDs to remove from the group */ fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index ea86460a..c726e52b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** A dataset event */ @NoAutoDetect @@ -408,7 +409,7 @@ private constructor( * A unique identifier for the dataset event. If you don't provide one, BrainTrust will * generate one for you */ - fun id(id: Optional) = id(id.orElse(null)) + fun id(id: Optional) = id(id.getOrNull()) /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will @@ -456,8 +457,7 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.orElse(null) as Boolean?) + fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** * The `_is_merge` field controls how the row is merged with any existing row with the same @@ -503,7 +503,7 @@ private constructor( * deep-merged `input` and `input.c`. */ fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.orElse(null)) + _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when @@ -559,9 +559,8 @@ private constructor( * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not * show up in subsequent fetches for this dataset */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.orElse(null) as Boolean?) + _objectDelete(_objectDelete.getOrNull()) /** * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not @@ -601,7 +600,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: Optional) = _parentId(_parentId.orElse(null)) + fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking @@ -623,7 +622,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** The timestamp the dataset event was created */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the dataset event was created */ fun created(created: JsonField) = apply { this.created = created } @@ -655,7 +654,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -702,7 +701,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.orElse(null)) + fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -759,7 +758,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: Optional) = spanId(spanId.orElse(null)) + fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -816,7 +815,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) + fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -867,7 +866,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 78a8b93d..3b414e84 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** An experiment event */ @NoAutoDetect @@ -539,7 +540,7 @@ private constructor( * A unique identifier for the experiment event. If you don't provide one, BrainTrust will * generate one for you */ - fun id(id: Optional) = id(id.orElse(null)) + fun id(id: Optional) = id(id.getOrNull()) /** * A unique identifier for the experiment event. If you don't provide one, BrainTrust will @@ -587,8 +588,7 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.orElse(null) as Boolean?) + fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** * The `_is_merge` field controls how the row is merged with any existing row with the same @@ -634,7 +634,7 @@ private constructor( * deep-merged `input` and `input.c`. */ fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.orElse(null)) + _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when @@ -690,9 +690,8 @@ private constructor( * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not * show up in subsequent fetches for this experiment */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.orElse(null) as Boolean?) + _objectDelete(_objectDelete.getOrNull()) /** * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not @@ -732,7 +731,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: Optional) = _parentId(_parentId.orElse(null)) + fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking @@ -762,7 +761,7 @@ private constructor( * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to * track the location in code which produced the experiment event */ - fun context(context: Optional) = context(context.orElse(null)) + fun context(context: Optional) = context(context.getOrNull()) /** * Context is additional information about the code that produced the experiment event. It @@ -775,7 +774,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** The timestamp the experiment event was created */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the experiment event was created */ fun created(created: JsonField) = apply { this.created = created } @@ -792,7 +791,7 @@ private constructor( * experiment event is tied to */ fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.orElse(null)) + datasetRecordId(datasetRecordId.getOrNull()) /** * If the experiment is associated to a dataset, this is the event-level dataset id this @@ -839,7 +838,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -862,7 +861,7 @@ private constructor( * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced */ - fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) + fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** * Metrics are numerical measurements tracking the execution of the code that produced the @@ -916,7 +915,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.orElse(null)) + fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -957,7 +956,7 @@ private constructor( * determine whether the summarization was covering similar concepts or not. You can use * these scores to help you sort, filter, and compare experiments */ - fun scores(scores: Optional) = scores(scores.orElse(null)) + fun scores(scores: Optional) = scores(scores.getOrNull()) /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a @@ -976,7 +975,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.orElse(null)) + spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: JsonField) = apply { @@ -1019,7 +1018,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: Optional) = spanId(spanId.orElse(null)) + fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -1076,7 +1075,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) + fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -1127,7 +1126,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { @@ -1280,7 +1279,7 @@ private constructor( /** Name of the file in code where the experiment event was created */ fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.orElse(null)) + callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the experiment event was created */ fun callerFilename(callerFilename: JsonField) = apply { @@ -1293,7 +1292,7 @@ private constructor( /** The function in code which created the experiment event */ fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.orElse(null)) + callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the experiment event */ fun callerFunctionname(callerFunctionname: JsonField) = apply { @@ -1307,9 +1306,7 @@ private constructor( fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) /** Line of code where the experiment event was created */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun callerLineno(callerLineno: Optional) = - callerLineno(callerLineno.orElse(null) as Long?) + fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: JsonField) = apply { @@ -1640,9 +1637,8 @@ private constructor( * The number of tokens in the completion generated by the model (only set if this is an * LLM span) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.orElse(null) as Long?) + completionTokens(completionTokens.getOrNull()) /** * The number of tokens in the completion generated by the model (only set if this is an @@ -1668,8 +1664,7 @@ private constructor( * A unix timestamp recording when the section of code which produced the experiment * event finished */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun end(end: Optional) = end(end.orElse(null) as Double?) + fun end(end: Optional) = end(end.getOrNull()) /** * A unix timestamp recording when the section of code which produced the experiment @@ -1693,9 +1688,7 @@ private constructor( * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun promptTokens(promptTokens: Optional) = - promptTokens(promptTokens.orElse(null) as Long?) + fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** * The number of tokens in the prompt used to generate the experiment event (only set if @@ -1721,8 +1714,7 @@ private constructor( * A unix timestamp recording when the section of code which produced the experiment * event started */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun start(start: Optional) = start(start.orElse(null) as Double?) + fun start(start: Optional) = start(start.getOrNull()) /** * A unix timestamp recording when the section of code which produced the experiment @@ -1737,8 +1729,7 @@ private constructor( fun tokens(tokens: Long) = tokens(tokens as Long?) /** The total number of tokens in the input and output of the experiment event. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun tokens(tokens: Optional) = tokens(tokens.orElse(null) as Long?) + fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: JsonField) = apply { this.tokens = tokens } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index 828f46ee..abf02697 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** A project logs event */ @NoAutoDetect @@ -513,7 +514,7 @@ private constructor( * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you */ - fun id(id: Optional) = id(id.orElse(null)) + fun id(id: Optional) = id(id.getOrNull()) /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will @@ -561,8 +562,7 @@ private constructor( * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.orElse(null) as Boolean?) + fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** * The `_is_merge` field controls how the row is merged with any existing row with the same @@ -608,7 +608,7 @@ private constructor( * deep-merged `input` and `input.c`. */ fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.orElse(null)) + _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when @@ -664,9 +664,8 @@ private constructor( * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will * not show up in subsequent fetches for this project logs */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.orElse(null) as Boolean?) + _objectDelete(_objectDelete.getOrNull()) /** * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will @@ -706,7 +705,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: Optional) = _parentId(_parentId.orElse(null)) + fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking @@ -736,7 +735,7 @@ private constructor( * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to * track the location in code which produced the project logs event */ - fun context(context: Optional) = context(context.orElse(null)) + fun context(context: Optional) = context(context.getOrNull()) /** * Context is additional information about the code that produced the project logs event. It @@ -749,7 +748,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** The timestamp the project logs event was created */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the project logs event was created */ fun created(created: JsonField) = apply { this.created = created } @@ -788,7 +787,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -811,7 +810,7 @@ private constructor( * project logs event. Use "start" and "end" to track the time span over which the project * logs event was produced */ - fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) + fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** * Metrics are numerical measurements tracking the execution of the code that produced the @@ -865,7 +864,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.orElse(null)) + fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -906,7 +905,7 @@ private constructor( * determine whether the summarization was covering similar concepts or not. You can use * these scores to help you sort, filter, and compare logs. */ - fun scores(scores: Optional) = scores(scores.orElse(null)) + fun scores(scores: Optional) = scores(scores.getOrNull()) /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a @@ -925,7 +924,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.orElse(null)) + spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: JsonField) = apply { @@ -968,7 +967,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: Optional) = spanId(spanId.orElse(null)) + fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -1025,7 +1024,7 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) + fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to @@ -1076,7 +1075,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { @@ -1228,7 +1227,7 @@ private constructor( /** Name of the file in code where the project logs event was created */ fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.orElse(null)) + callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the project logs event was created */ fun callerFilename(callerFilename: JsonField) = apply { @@ -1241,7 +1240,7 @@ private constructor( /** The function in code which created the project logs event */ fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.orElse(null)) + callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the project logs event */ fun callerFunctionname(callerFunctionname: JsonField) = apply { @@ -1255,9 +1254,7 @@ private constructor( fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) /** Line of code where the project logs event was created */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun callerLineno(callerLineno: Optional) = - callerLineno(callerLineno.orElse(null) as Long?) + fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: JsonField) = apply { @@ -1588,9 +1585,8 @@ private constructor( * The number of tokens in the completion generated by the model (only set if this is an * LLM span) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.orElse(null) as Long?) + completionTokens(completionTokens.getOrNull()) /** * The number of tokens in the completion generated by the model (only set if this is an @@ -1616,8 +1612,7 @@ private constructor( * A unix timestamp recording when the section of code which produced the project logs * event finished */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun end(end: Optional) = end(end.orElse(null) as Double?) + fun end(end: Optional) = end(end.getOrNull()) /** * A unix timestamp recording when the section of code which produced the project logs @@ -1641,9 +1636,7 @@ private constructor( * The number of tokens in the prompt used to generate the project logs event (only set * if this is an LLM span) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun promptTokens(promptTokens: Optional) = - promptTokens(promptTokens.orElse(null) as Long?) + fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** * The number of tokens in the prompt used to generate the project logs event (only set @@ -1669,8 +1662,7 @@ private constructor( * A unix timestamp recording when the section of code which produced the project logs * event started */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun start(start: Optional) = start(start.orElse(null) as Double?) + fun start(start: Optional) = start(start.getOrNull()) /** * A unix timestamp recording when the section of code which produced the project logs @@ -1685,8 +1677,7 @@ private constructor( fun tokens(tokens: Long) = tokens(tokens as Long?) /** The total number of tokens in the input and output of the project logs event. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun tokens(tokens: Optional) = tokens(tokens.orElse(null) as Long?) + fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: JsonField) = apply { this.tokens = tokens } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 14c1d67c..6eb781e8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class OnlineScoreConfig @@ -171,9 +172,8 @@ private constructor( fun applyToRootSpan(applyToRootSpan: Boolean) = applyToRootSpan(applyToRootSpan as Boolean?) /** Whether to trigger online scoring on the root span of each trace */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun applyToRootSpan(applyToRootSpan: Optional) = - applyToRootSpan(applyToRootSpan.orElse(null) as Boolean?) + applyToRootSpan(applyToRootSpan.getOrNull()) /** Whether to trigger online scoring on the root span of each trace */ fun applyToRootSpan(applyToRootSpan: JsonField) = apply { @@ -186,7 +186,7 @@ private constructor( /** Trigger online scoring on any spans with a name in this list */ fun applyToSpanNames(applyToSpanNames: Optional>) = - applyToSpanNames(applyToSpanNames.orElse(null)) + applyToSpanNames(applyToSpanNames.getOrNull()) /** Trigger online scoring on any spans with a name in this list */ fun applyToSpanNames(applyToSpanNames: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 1835c195..584931b5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class Organization @@ -157,7 +158,7 @@ private constructor( fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) - fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.orElse(null)) + fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } @@ -165,7 +166,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of organization creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of organization creation */ fun created(created: JsonField) = apply { this.created = created } @@ -175,9 +176,8 @@ private constructor( fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.orElse(null) as Boolean?) + isUniversalApi(isUniversalApi.getOrNull()) fun isUniversalApi(isUniversalApi: JsonField) = apply { this.isUniversalApi = isUniversalApi @@ -185,13 +185,13 @@ private constructor( fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) - fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.orElse(null)) + fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) - fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.orElse(null)) + fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index eac7c40a..8bff63be 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all organizations. The organizations are sorted by creation date, with the most @@ -172,7 +173,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 71aa262a..d01ebbf0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all organizations. The organizations are sorted by creation date, with the most @@ -132,7 +133,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -144,7 +145,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -165,14 +166,13 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * Pagination cursor id. @@ -191,7 +191,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 9c8650c5..f75b1abe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Modify organization membership */ class OrganizationMemberUpdateParams @@ -196,7 +197,7 @@ private constructor( /** Users to invite to the organization */ fun inviteUsers(inviteUsers: Optional) = - inviteUsers(inviteUsers.orElse(null)) + inviteUsers(inviteUsers.getOrNull()) /** Users to invite to the organization */ fun inviteUsers(inviteUsers: JsonField) = apply { @@ -217,7 +218,7 @@ private constructor( * assert the organization you are modifying, you may specify the id of the * organization. */ - fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) + fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -241,7 +242,7 @@ private constructor( * assert the organization you are modifying, you may specify the name of the * organization. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -257,7 +258,7 @@ private constructor( /** Users to remove from the organization */ fun removeUsers(removeUsers: Optional) = - removeUsers(removeUsers.orElse(null)) + removeUsers(removeUsers.getOrNull()) /** Users to remove from the organization */ fun removeUsers(removeUsers: JsonField) = apply { @@ -337,7 +338,7 @@ private constructor( fun inviteUsers(inviteUsers: InviteUsers?) = apply { body.inviteUsers(inviteUsers) } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.orElse(null)) + fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) /** Users to invite to the organization */ fun inviteUsers(inviteUsers: JsonField) = apply { @@ -356,7 +357,7 @@ private constructor( * your API key belongs to multiple organizations, or in case you want to explicitly assert * the organization you are modifying, you may specify the id of the organization. */ - fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) + fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -377,7 +378,7 @@ private constructor( * your API key belongs to multiple organizations, or in case you want to explicitly assert * the organization you are modifying, you may specify the name of the organization. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -390,7 +391,7 @@ private constructor( fun removeUsers(removeUsers: RemoveUsers?) = apply { body.removeUsers(removeUsers) } /** Users to remove from the organization */ - fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.orElse(null)) + fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) /** Users to remove from the organization */ fun removeUsers(removeUsers: JsonField) = apply { @@ -660,7 +661,7 @@ private constructor( fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) /** Emails of users to invite */ - fun emails(emails: Optional>) = emails(emails.orElse(null)) + fun emails(emails: Optional>) = emails(emails.getOrNull()) /** Emails of users to invite */ fun emails(emails: JsonField>) = apply { @@ -679,7 +680,7 @@ private constructor( fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** Singular form of group_ids */ - fun groupId(groupId: Optional) = groupId(groupId.orElse(null)) + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** Singular form of group_ids */ fun groupId(groupId: JsonField) = apply { this.groupId = groupId } @@ -688,7 +689,7 @@ private constructor( fun groupIds(groupIds: List?) = groupIds(JsonField.ofNullable(groupIds)) /** Optional list of group ids to add newly-invited users to. */ - fun groupIds(groupIds: Optional>) = groupIds(groupIds.orElse(null)) + fun groupIds(groupIds: Optional>) = groupIds(groupIds.getOrNull()) /** Optional list of group ids to add newly-invited users to. */ fun groupIds(groupIds: JsonField>) = apply { @@ -707,7 +708,7 @@ private constructor( fun groupName(groupName: String?) = groupName(JsonField.ofNullable(groupName)) /** Singular form of group_names */ - fun groupName(groupName: Optional) = groupName(groupName.orElse(null)) + fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** Singular form of group_names */ fun groupName(groupName: JsonField) = apply { this.groupName = groupName } @@ -716,7 +717,7 @@ private constructor( fun groupNames(groupNames: List?) = groupNames(JsonField.ofNullable(groupNames)) /** Optional list of group names to add newly-invited users to. */ - fun groupNames(groupNames: Optional>) = groupNames(groupNames.orElse(null)) + fun groupNames(groupNames: Optional>) = groupNames(groupNames.getOrNull()) /** Optional list of group names to add newly-invited users to. */ fun groupNames(groupNames: JsonField>) = apply { @@ -735,7 +736,7 @@ private constructor( fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) /** Ids of existing users to invite */ - fun ids(ids: Optional>) = ids(ids.orElse(null)) + fun ids(ids: Optional>) = ids(ids.getOrNull()) /** Ids of existing users to invite */ fun ids(ids: JsonField>) = apply { @@ -756,9 +757,8 @@ private constructor( sendInviteEmails(sendInviteEmails as Boolean?) /** If true, send invite emails to the users who wore actually added */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun sendInviteEmails(sendInviteEmails: Optional) = - sendInviteEmails(sendInviteEmails.orElse(null) as Boolean?) + sendInviteEmails(sendInviteEmails.getOrNull()) /** If true, send invite emails to the users who wore actually added */ fun sendInviteEmails(sendInviteEmails: JsonField) = apply { @@ -884,7 +884,7 @@ private constructor( fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) /** Emails of users to remove */ - fun emails(emails: Optional>) = emails(emails.orElse(null)) + fun emails(emails: Optional>) = emails(emails.getOrNull()) /** Emails of users to remove */ fun emails(emails: JsonField>) = apply { @@ -903,7 +903,7 @@ private constructor( fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) /** Ids of users to remove */ - fun ids(ids: Optional>) = ids(ids.orElse(null)) + fun ids(ids: Optional>) = ids(ids.getOrNull()) /** Ids of users to remove */ fun ids(ids: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 51a92676..83efeac1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update an organization object. Specify the fields to update in the payload. Any @@ -177,7 +178,7 @@ private constructor( fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) - fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.orElse(null)) + fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } @@ -186,9 +187,8 @@ private constructor( fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.orElse(null) as Boolean?) + isUniversalApi(isUniversalApi.getOrNull()) fun isUniversalApi(isUniversalApi: JsonField) = apply { this.isUniversalApi = isUniversalApi @@ -198,20 +198,20 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the organization */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the organization */ fun name(name: JsonField) = apply { this.name = name } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) - fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.orElse(null)) + fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) - fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.orElse(null)) + fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl @@ -302,7 +302,7 @@ private constructor( fun apiUrl(apiUrl: String?) = apply { body.apiUrl(apiUrl) } - fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.orElse(null)) + fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) fun apiUrl(apiUrl: JsonField) = apply { body.apiUrl(apiUrl) } @@ -310,9 +310,8 @@ private constructor( fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.orElse(null) as Boolean?) + isUniversalApi(isUniversalApi.getOrNull()) fun isUniversalApi(isUniversalApi: JsonField) = apply { body.isUniversalApi(isUniversalApi) @@ -322,20 +321,20 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the organization */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the organization */ fun name(name: JsonField) = apply { body.name(name) } fun proxyUrl(proxyUrl: String?) = apply { body.proxyUrl(proxyUrl) } - fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.orElse(null)) + fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) fun proxyUrl(proxyUrl: JsonField) = apply { body.proxyUrl(proxyUrl) } fun realtimeUrl(realtimeUrl: String?) = apply { body.realtimeUrl(realtimeUrl) } - fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.orElse(null)) + fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) fun realtimeUrl(realtimeUrl: JsonField) = apply { body.realtimeUrl(realtimeUrl) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 1124f53f..c1bb28cb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class PatchOrganizationMembersOutput @@ -131,7 +132,7 @@ private constructor( * but we will return an error message here */ fun sendEmailError(sendEmailError: Optional) = - sendEmailError(sendEmailError.orElse(null)) + sendEmailError(sendEmailError.getOrNull()) /** * If invite emails failed to send for some reason, the patch operation will still complete, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index ac3cadcc..8da4413e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class Project @@ -168,7 +169,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of project creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of project creation */ fun created(created: JsonField) = apply { this.created = created } @@ -177,14 +178,14 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of project deletion, or null if the project is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of project deletion, or null if the project is still active */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) - fun settings(settings: Optional) = settings(settings.orElse(null)) + fun settings(settings: Optional) = settings(settings.getOrNull()) fun settings(settings: JsonField) = apply { this.settings = settings } @@ -192,7 +193,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the project */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the project */ fun userId(userId: JsonField) = apply { this.userId = userId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 19f07848..6d92a603 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new project. If there is an existing project with the same name as the one specified in @@ -160,7 +161,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the project belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -258,7 +259,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the project belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index 3f97dbd2..d970247c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all projects. The projects are sorted by creation date, with the most recently-created @@ -168,7 +169,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 985b4332..c011f50b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all projects. The projects are sorted by creation date, with the most recently-created @@ -139,7 +140,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -151,7 +152,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -172,20 +173,19 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** * Pagination cursor id. @@ -204,7 +204,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index d7cba0e0..1d82f560 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -9,6 +9,7 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with the @@ -194,8 +195,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -224,7 +224,7 @@ private constructor( * paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -252,7 +252,7 @@ private constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time @@ -268,7 +268,7 @@ private constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 818b7471..4eb11877 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the @@ -389,7 +390,7 @@ private constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * An opaque string to be used as a cursor for the next page of results, in order from @@ -449,8 +450,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events * containing traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched @@ -497,7 +497,7 @@ private constructor( * overview of paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -541,7 +541,7 @@ private constructor( * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an * overview of paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor @@ -573,7 +573,7 @@ private constructor( * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact * fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time @@ -683,7 +683,7 @@ private constructor( * The string can be obtained directly from the `cursor` property of the previous fetch * query */ - fun cursor(cursor: Optional) = cursor(cursor.orElse(null)) + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * An opaque string to be used as a cursor for the next page of results, in order from @@ -743,8 +743,7 @@ private constructor( * with more individual rows than the specified limit if you are fetching events containing * traces. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched @@ -790,7 +789,7 @@ private constructor( * paginating fetch queries. */ fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.orElse(null)) + maxRootSpanId(maxRootSpanId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -834,7 +833,7 @@ private constructor( * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. */ - fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.orElse(null)) + fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of @@ -864,7 +863,7 @@ private constructor( * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 84805aa0..94a6ee65 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class ProjectLogsEvent @@ -469,7 +470,7 @@ private constructor( * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to * track the location in code which produced the project logs event */ - fun context(context: Optional) = context(context.orElse(null)) + fun context(context: Optional) = context(context.getOrNull()) /** * Context is additional information about the code that produced the project logs event. It @@ -503,8 +504,7 @@ private constructor( fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) /** Whether this span is a root span */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isRoot(isRoot: Optional) = isRoot(isRoot.orElse(null) as Boolean?) + fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } @@ -525,7 +525,7 @@ private constructor( * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, * but its keys must be strings */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** * A dictionary with additional data about the test example, model outputs, or just about @@ -548,7 +548,7 @@ private constructor( * project logs event. Use "start" and "end" to track the time span over which the project * logs event was produced */ - fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) + fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** * Metrics are numerical measurements tracking the execution of the code that produced the @@ -561,7 +561,7 @@ private constructor( fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ fun origin(origin: JsonField) = apply { this.origin = origin } @@ -595,7 +595,7 @@ private constructor( * determine whether the summarization was covering similar concepts or not. You can use * these scores to help you sort, filter, and compare logs. */ - fun scores(scores: Optional) = scores(scores.orElse(null)) + fun scores(scores: Optional) = scores(scores.getOrNull()) /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a @@ -614,7 +614,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.orElse(null)) + spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ fun spanAttributes(spanAttributes: JsonField) = apply { @@ -633,7 +633,7 @@ private constructor( * the root span of a trace, and should most often contain just one parent element for * subspans */ - fun spanParents(spanParents: Optional>) = spanParents(spanParents.orElse(null)) + fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** * An array of the parent `span_ids` of this project logs event. This should be empty for @@ -660,7 +660,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags to log */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ fun tags(tags: JsonField>) = apply { @@ -909,7 +909,7 @@ private constructor( /** Name of the file in code where the project logs event was created */ fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.orElse(null)) + callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the project logs event was created */ fun callerFilename(callerFilename: JsonField) = apply { @@ -922,7 +922,7 @@ private constructor( /** The function in code which created the project logs event */ fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.orElse(null)) + callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the project logs event */ fun callerFunctionname(callerFunctionname: JsonField) = apply { @@ -936,9 +936,7 @@ private constructor( fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) /** Line of code where the project logs event was created */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun callerLineno(callerLineno: Optional) = - callerLineno(callerLineno.orElse(null) as Long?) + fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: JsonField) = apply { @@ -1269,9 +1267,8 @@ private constructor( * The number of tokens in the completion generated by the model (only set if this is an * LLM span) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.orElse(null) as Long?) + completionTokens(completionTokens.getOrNull()) /** * The number of tokens in the completion generated by the model (only set if this is an @@ -1297,8 +1294,7 @@ private constructor( * A unix timestamp recording when the section of code which produced the project logs * event finished */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun end(end: Optional) = end(end.orElse(null) as Double?) + fun end(end: Optional) = end(end.getOrNull()) /** * A unix timestamp recording when the section of code which produced the project logs @@ -1322,9 +1318,7 @@ private constructor( * The number of tokens in the prompt used to generate the project logs event (only set * if this is an LLM span) */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun promptTokens(promptTokens: Optional) = - promptTokens(promptTokens.orElse(null) as Long?) + fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** * The number of tokens in the prompt used to generate the project logs event (only set @@ -1350,8 +1344,7 @@ private constructor( * A unix timestamp recording when the section of code which produced the project logs * event started */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun start(start: Optional) = start(start.orElse(null) as Double?) + fun start(start: Optional) = start(start.getOrNull()) /** * A unix timestamp recording when the section of code which produced the project logs @@ -1366,8 +1359,7 @@ private constructor( fun tokens(tokens: Long) = tokens(tokens as Long?) /** The total number of tokens in the input and output of the project logs event. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun tokens(tokens: Optional) = tokens(tokens.orElse(null) as Long?) + fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: JsonField) = apply { this.tokens = tokens } 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 8c2d7c74..6144049c 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 @@ -29,6 +29,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** A project score is a user-configured score, which can be manually-labeled through the UI */ @NoAutoDetect @@ -247,7 +248,7 @@ private constructor( fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) - fun config(config: Optional) = config(config.orElse(null)) + fun config(config: Optional) = config(config.getOrNull()) fun config(config: JsonField) = apply { this.config = config } @@ -255,7 +256,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of project score creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of project score creation */ fun created(created: JsonField) = apply { this.created = created } @@ -264,7 +265,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project score */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ fun description(description: JsonField) = apply { this.description = description } @@ -273,7 +274,7 @@ private constructor( fun position(position: String?) = position(JsonField.ofNullable(position)) /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - fun position(position: Optional) = position(position.orElse(null)) + fun position(position: Optional) = position(position.getOrNull()) /** An optional LexoRank-based string that sets the sort position for the score in the UI */ fun position(position: JsonField) = apply { this.position = position } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 909e8b0c..82cf7754 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class ProjectScoreConfig @@ -95,7 +96,7 @@ private constructor( fun destination(destination: Destination?) = destination(JsonField.ofNullable(destination)) - fun destination(destination: Optional) = destination(destination.orElse(null)) + fun destination(destination: Optional) = destination(destination.getOrNull()) fun destination(destination: JsonField) = apply { this.destination = destination @@ -105,15 +106,13 @@ private constructor( fun multiSelect(multiSelect: Boolean) = multiSelect(multiSelect as Boolean?) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun multiSelect(multiSelect: Optional) = - multiSelect(multiSelect.orElse(null) as Boolean?) + fun multiSelect(multiSelect: Optional) = multiSelect(multiSelect.getOrNull()) fun multiSelect(multiSelect: JsonField) = apply { this.multiSelect = multiSelect } fun online(online: OnlineScoreConfig?) = online(JsonField.ofNullable(online)) - fun online(online: Optional) = online(online.orElse(null)) + fun online(online: Optional) = online(online.getOrNull()) fun online(online: JsonField) = apply { this.online = online } 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 17695ecb..49401ff2 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 @@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new project_score. If there is an existing project_score in the project with the same @@ -264,7 +265,7 @@ private constructor( fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) - fun config(config: Optional) = config(config.orElse(null)) + fun config(config: Optional) = config(config.getOrNull()) fun config(config: JsonField) = apply { this.config = config } @@ -272,7 +273,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project score */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ fun description(description: JsonField) = apply { @@ -402,7 +403,7 @@ private constructor( fun config(config: ProjectScoreConfig?) = apply { body.config(config) } - fun config(config: Optional) = config(config.orElse(null)) + fun config(config: Optional) = config(config.getOrNull()) fun config(config: JsonField) = apply { body.config(config) } @@ -410,7 +411,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the project score */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ fun description(description: JsonField) = apply { body.description(description) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index 1779106a..f0864a38 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all project_scores. The project_scores are sorted by creation date, with the most @@ -172,7 +173,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } 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 51594ec6..6f86bc5e 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 @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all project_scores. The project_scores are sorted by creation date, with the most @@ -163,7 +164,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -175,7 +176,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -196,26 +197,25 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_score to search for */ fun projectScoreName(projectScoreName: String?) = apply { @@ -224,13 +224,13 @@ private constructor( /** Name of the project_score to search for */ fun projectScoreName(projectScoreName: Optional) = - projectScoreName(projectScoreName.orElse(null)) + projectScoreName(projectScoreName.getOrNull()) /** The type of the configured score */ fun scoreType(scoreType: ScoreType?) = apply { this.scoreType = scoreType } /** The type of the configured score */ - fun scoreType(scoreType: Optional) = scoreType(scoreType.orElse(null)) + fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) /** The type of the configured score */ fun scoreType(project: ScoreType.ProjectScoreType) = scoreType(ScoreType.ofProject(project)) @@ -256,7 +256,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() 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 8297ebeb..8373825d 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 @@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace project_score. If there is an existing project_score in the project with the @@ -265,7 +266,7 @@ private constructor( fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) - fun config(config: Optional) = config(config.orElse(null)) + fun config(config: Optional) = config(config.getOrNull()) fun config(config: JsonField) = apply { this.config = config } @@ -273,7 +274,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project score */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ fun description(description: JsonField) = apply { @@ -403,7 +404,7 @@ private constructor( fun config(config: ProjectScoreConfig?) = apply { body.config(config) } - fun config(config: Optional) = config(config.orElse(null)) + fun config(config: Optional) = config(config.getOrNull()) fun config(config: JsonField) = apply { body.config(config) } @@ -411,7 +412,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the project score */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ fun description(description: JsonField) = apply { body.description(description) } 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 476ae96c..4784736c 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 @@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a project_score object. Specify the fields to update in the payload. Any @@ -232,7 +233,7 @@ private constructor( fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) - fun config(config: Optional) = config(config.orElse(null)) + fun config(config: Optional) = config(config.getOrNull()) fun config(config: JsonField) = apply { this.config = config } @@ -240,7 +241,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project score */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ fun description(description: JsonField) = apply { @@ -251,7 +252,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the project score */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the project score */ fun name(name: JsonField) = apply { this.name = name } @@ -260,7 +261,7 @@ private constructor( fun scoreType(scoreType: ScoreType?) = scoreType(JsonField.ofNullable(scoreType)) /** The type of the configured score */ - fun scoreType(scoreType: Optional) = scoreType(scoreType.orElse(null)) + fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) /** The type of the configured score */ fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } @@ -372,7 +373,7 @@ private constructor( fun config(config: ProjectScoreConfig?) = apply { body.config(config) } - fun config(config: Optional) = config(config.orElse(null)) + fun config(config: Optional) = config(config.getOrNull()) fun config(config: JsonField) = apply { body.config(config) } @@ -380,7 +381,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the project score */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ fun description(description: JsonField) = apply { body.description(description) } @@ -389,7 +390,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the project score */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the project score */ fun name(name: JsonField) = apply { body.name(name) } @@ -398,7 +399,7 @@ private constructor( fun scoreType(scoreType: ScoreType?) = apply { body.scoreType(scoreType) } /** The type of the configured score */ - fun scoreType(scoreType: Optional) = scoreType(scoreType.orElse(null)) + fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) /** The type of the configured score */ fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index 058f4fbb..9c9bfe47 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class ProjectSettings @@ -76,7 +77,7 @@ private constructor( /** The key used to join two experiments (defaults to `input`). */ fun comparisonKey(comparisonKey: Optional) = - comparisonKey(comparisonKey.orElse(null)) + comparisonKey(comparisonKey.getOrNull()) /** The key used to join two experiments (defaults to `input`). */ fun comparisonKey(comparisonKey: JsonField) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 39dbe262..69a309f6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * A project tag is a user-configured tag for tracking and filtering your experiments, logs, and @@ -174,7 +175,7 @@ private constructor( fun color(color: String?) = color(JsonField.ofNullable(color)) /** Color of the tag for the UI */ - fun color(color: Optional) = color(color.orElse(null)) + fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ fun color(color: JsonField) = apply { this.color = color } @@ -183,7 +184,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of project tag creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of project tag creation */ fun created(created: JsonField) = apply { this.created = created } @@ -192,7 +193,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project tag */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ fun description(description: JsonField) = apply { this.description = description } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 75097b60..1944b66e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new project_tag. If there is an existing project_tag in the project with the same name @@ -182,7 +183,7 @@ private constructor( fun color(color: String?) = color(JsonField.ofNullable(color)) /** Color of the tag for the UI */ - fun color(color: Optional) = color(color.orElse(null)) + fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ fun color(color: JsonField) = apply { this.color = color } @@ -191,7 +192,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project tag */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ fun description(description: JsonField) = apply { @@ -292,7 +293,7 @@ private constructor( fun color(color: String?) = apply { body.color(color) } /** Color of the tag for the UI */ - fun color(color: Optional) = color(color.orElse(null)) + fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ fun color(color: JsonField) = apply { body.color(color) } @@ -301,7 +302,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the project tag */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ fun description(description: JsonField) = apply { body.description(description) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 83e4378c..3fdf0ee1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all project_tags. The project_tags are sorted by creation date, with the most @@ -172,7 +173,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 80fecc14..431a8583 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all project_tags. The project_tags are sorted by creation date, with the most @@ -153,7 +154,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -165,7 +166,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -186,33 +187,32 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_tag to search for */ fun projectTagName(projectTagName: String?) = apply { this.projectTagName = projectTagName } /** Name of the project_tag to search for */ fun projectTagName(projectTagName: Optional) = - projectTagName(projectTagName.orElse(null)) + projectTagName(projectTagName.getOrNull()) /** * Pagination cursor id. @@ -231,7 +231,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index b708de00..ab167ca1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace project_tag. If there is an existing project_tag in the project with the same @@ -183,7 +184,7 @@ private constructor( fun color(color: String?) = color(JsonField.ofNullable(color)) /** Color of the tag for the UI */ - fun color(color: Optional) = color(color.orElse(null)) + fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ fun color(color: JsonField) = apply { this.color = color } @@ -192,7 +193,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project tag */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ fun description(description: JsonField) = apply { @@ -293,7 +294,7 @@ private constructor( fun color(color: String?) = apply { body.color(color) } /** Color of the tag for the UI */ - fun color(color: Optional) = color(color.orElse(null)) + fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ fun color(color: JsonField) = apply { body.color(color) } @@ -302,7 +303,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the project tag */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ fun description(description: JsonField) = apply { body.description(description) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index d0b42595..8a93825d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a project_tag object. Specify the fields to update in the payload. Any @@ -156,7 +157,7 @@ private constructor( fun color(color: String?) = color(JsonField.ofNullable(color)) /** Color of the tag for the UI */ - fun color(color: Optional) = color(color.orElse(null)) + fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ fun color(color: JsonField) = apply { this.color = color } @@ -165,7 +166,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the project tag */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ fun description(description: JsonField) = apply { @@ -176,7 +177,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the project tag */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the project tag */ fun name(name: JsonField) = apply { this.name = name } @@ -260,7 +261,7 @@ private constructor( fun color(color: String?) = apply { body.color(color) } /** Color of the tag for the UI */ - fun color(color: Optional) = color(color.orElse(null)) + fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ fun color(color: JsonField) = apply { body.color(color) } @@ -269,7 +270,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the project tag */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ fun description(description: JsonField) = apply { body.description(description) } @@ -278,7 +279,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the project tag */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the project tag */ fun name(name: JsonField) = apply { body.name(name) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index c259f853..f47cf5da 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a project object. Specify the fields to update in the payload. Any object-type @@ -150,7 +151,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the project */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the project */ fun name(name: JsonField) = apply { this.name = name } @@ -165,7 +166,7 @@ private constructor( * Project settings. Patch operations replace all settings, so make sure you include all * settings you want to keep. */ - fun settings(settings: Optional) = settings(settings.orElse(null)) + fun settings(settings: Optional) = settings(settings.getOrNull()) /** * Project settings. Patch operations replace all settings, so make sure you include all @@ -252,7 +253,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the project */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the project */ fun name(name: JsonField) = apply { body.name(name) } @@ -267,7 +268,7 @@ private constructor( * Project settings. Patch operations replace all settings, so make sure you include all * settings you want to keep. */ - fun settings(settings: Optional) = settings(settings.orElse(null)) + fun settings(settings: Optional) = settings(settings.getOrNull()) /** * Project settings. Patch operations replace all settings, so make sure you include all diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 1e7c08e1..5e093784 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class Prompt @@ -286,7 +287,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of prompt creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of prompt creation */ fun created(created: JsonField) = apply { this.created = created } @@ -295,7 +296,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { this.description = description } @@ -304,7 +305,7 @@ private constructor( functionType(JsonField.ofNullable(functionType)) fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { this.functionType = functionType @@ -314,7 +315,7 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** User-controlled metadata about the prompt */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the prompt */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -323,7 +324,7 @@ private constructor( fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } @@ -332,7 +333,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 2e7e1913..3eee9b8f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new prompt. If there is an existing prompt in the project with the same slug as the one @@ -248,7 +249,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { @@ -259,7 +260,7 @@ private constructor( functionType(JsonField.ofNullable(functionType)) fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { this.functionType = functionType @@ -269,7 +270,7 @@ private constructor( fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { @@ -280,7 +281,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { @@ -397,7 +398,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { body.description(description) } @@ -405,7 +406,7 @@ private constructor( fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { body.functionType(functionType) @@ -415,7 +416,7 @@ private constructor( fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } @@ -424,7 +425,7 @@ private constructor( fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { body.tags(tags) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 86eb51b5..c9faaa96 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** The prompt, model, and its parameters */ @NoAutoDetect @@ -125,19 +126,19 @@ private constructor( fun options(options: PromptOptions?) = options(JsonField.ofNullable(options)) - fun options(options: Optional) = options(options.orElse(null)) + fun options(options: Optional) = options(options.getOrNull()) fun options(options: JsonField) = apply { this.options = options } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) - fun origin(origin: Optional) = origin(origin.orElse(null)) + fun origin(origin: Optional) = origin(origin.getOrNull()) fun origin(origin: JsonField) = apply { this.origin = origin } fun parser(parser: Parser?) = parser(JsonField.ofNullable(parser)) - fun parser(parser: Optional) = parser(parser.orElse(null)) + fun parser(parser: Optional) = parser(parser.getOrNull()) fun parser(parser: JsonField) = apply { this.parser = parser } @@ -156,7 +157,7 @@ private constructor( toolFunctions(JsonField.ofNullable(toolFunctions)) fun toolFunctions(toolFunctions: Optional>) = - toolFunctions(toolFunctions.orElse(null)) + toolFunctions(toolFunctions.getOrNull()) fun toolFunctions(toolFunctions: JsonField>) = apply { this.toolFunctions = toolFunctions.map { it.toMutableList() } @@ -2332,7 +2333,7 @@ private constructor( fun content(content: String?) = content(JsonField.ofNullable(content)) - fun content(content: Optional) = content(content.orElse(null)) + fun content(content: Optional) = content(content.getOrNull()) fun content(content: JsonField) = apply { this.content = content } @@ -2340,7 +2341,7 @@ private constructor( functionCall(JsonField.ofNullable(functionCall)) fun functionCall(functionCall: Optional) = - functionCall(functionCall.orElse(null)) + functionCall(functionCall.getOrNull()) fun functionCall(functionCall: JsonField) = apply { this.functionCall = functionCall @@ -2348,7 +2349,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) fun name(name: JsonField) = apply { this.name = name } @@ -2356,7 +2357,7 @@ private constructor( toolCalls(JsonField.ofNullable(toolCalls)) fun toolCalls(toolCalls: Optional>) = - toolCalls(toolCalls.orElse(null)) + toolCalls(toolCalls.getOrNull()) fun toolCalls(toolCalls: JsonField>) = apply { @@ -3223,7 +3224,7 @@ private constructor( fun content(content: String?) = content(JsonField.ofNullable(content)) - fun content(content: Optional) = content(content.orElse(null)) + fun content(content: Optional) = content(content.getOrNull()) fun content(content: JsonField) = apply { this.content = content } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index d13c70a7..a54dbe4f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all prompts. The prompts are sorted by creation date, with the most recently-created @@ -162,7 +163,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 62a3e4cb..ab888cab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all prompts. The prompts are sorted by creation date, with the most recently-created @@ -172,7 +173,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -184,7 +185,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -205,38 +206,37 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ - fun projectId(projectId: Optional) = projectId(projectId.orElse(null)) + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ - fun projectName(projectName: Optional) = projectName(projectName.orElse(null)) + fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the prompt to search for */ fun promptName(promptName: String?) = apply { this.promptName = promptName } /** Name of the prompt to search for */ - fun promptName(promptName: Optional) = promptName(promptName.orElse(null)) + fun promptName(promptName: Optional) = promptName(promptName.getOrNull()) /** Retrieve prompt with a specific slug */ fun slug(slug: String?) = apply { this.slug = slug } /** Retrieve prompt with a specific slug */ - fun slug(slug: Optional) = slug(slug.orElse(null)) + fun slug(slug: Optional) = slug(slug.getOrNull()) /** * Pagination cursor id. @@ -255,7 +255,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) /** * Retrieve prompt at a specific version. @@ -271,7 +271,7 @@ private constructor( * The version id can either be a transaction id (e.g. '1000192656880881099') or a version * identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: Optional) = version(version.orElse(null)) + fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 327ae6a8..5ac95496 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class PromptOptions @@ -1647,11 +1648,7 @@ private constructor( fun strict(strict: Boolean) = strict(strict as Boolean?) - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun strict(strict: Optional) = - strict(strict.orElse(null) as Boolean?) + fun strict(strict: Optional) = strict(strict.getOrNull()) fun strict(strict: JsonField) = apply { this.strict = strict } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 726e2ba8..cf0797b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace prompt. If there is an existing prompt in the project with the same slug as the @@ -248,7 +249,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { @@ -259,7 +260,7 @@ private constructor( functionType(JsonField.ofNullable(functionType)) fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { this.functionType = functionType @@ -269,7 +270,7 @@ private constructor( fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { @@ -280,7 +281,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { @@ -397,7 +398,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { body.description(description) } @@ -405,7 +406,7 @@ private constructor( fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } fun functionType(functionType: Optional) = - functionType(functionType.orElse(null)) + functionType(functionType.getOrNull()) fun functionType(functionType: JsonField) = apply { body.functionType(functionType) @@ -415,7 +416,7 @@ private constructor( fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } @@ -424,7 +425,7 @@ private constructor( fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { body.tags(tags) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index eee15e53..d8447483 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a prompt object. Specify the fields to update in the payload. Any object-type @@ -196,7 +197,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { @@ -207,7 +208,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the prompt */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ fun name(name: JsonField) = apply { this.name = name } @@ -216,7 +217,7 @@ private constructor( fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { @@ -227,7 +228,7 @@ private constructor( fun slug(slug: String?) = slug(JsonField.ofNullable(slug)) /** Unique identifier for the prompt */ - fun slug(slug: Optional) = slug(slug.orElse(null)) + fun slug(slug: Optional) = slug(slug.getOrNull()) /** Unique identifier for the prompt */ fun slug(slug: JsonField) = apply { this.slug = slug } @@ -236,7 +237,7 @@ private constructor( fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { @@ -336,7 +337,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ fun description(description: JsonField) = apply { body.description(description) } @@ -345,7 +346,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ fun name(name: JsonField) = apply { body.name(name) } @@ -354,7 +355,7 @@ private constructor( fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ - fun promptData(promptData: Optional) = promptData(promptData.orElse(null)) + fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } @@ -363,7 +364,7 @@ private constructor( fun slug(slug: String?) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: Optional) = slug(slug.orElse(null)) + fun slug(slug: Optional) = slug(slug.getOrNull()) /** Unique identifier for the prompt */ fun slug(slug: JsonField) = apply { body.slug(slug) } @@ -372,7 +373,7 @@ private constructor( fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun tags(tags: Optional>) = tags(tags.orElse(null)) + fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ fun tags(tags: JsonField>) = apply { body.tags(tags) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index 95b541e7..a938b801 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Metadata about the state of the repo when the experiment was created */ @NoAutoDetect @@ -176,7 +177,7 @@ private constructor( fun authorEmail(authorEmail: String?) = authorEmail(JsonField.ofNullable(authorEmail)) /** Email of the author of the most recent commit */ - fun authorEmail(authorEmail: Optional) = authorEmail(authorEmail.orElse(null)) + fun authorEmail(authorEmail: Optional) = authorEmail(authorEmail.getOrNull()) /** Email of the author of the most recent commit */ fun authorEmail(authorEmail: JsonField) = apply { this.authorEmail = authorEmail } @@ -185,7 +186,7 @@ private constructor( fun authorName(authorName: String?) = authorName(JsonField.ofNullable(authorName)) /** Name of the author of the most recent commit */ - fun authorName(authorName: Optional) = authorName(authorName.orElse(null)) + fun authorName(authorName: Optional) = authorName(authorName.getOrNull()) /** Name of the author of the most recent commit */ fun authorName(authorName: JsonField) = apply { this.authorName = authorName } @@ -194,7 +195,7 @@ private constructor( fun branch(branch: String?) = branch(JsonField.ofNullable(branch)) /** Name of the branch the most recent commit belongs to */ - fun branch(branch: Optional) = branch(branch.orElse(null)) + fun branch(branch: Optional) = branch(branch.getOrNull()) /** Name of the branch the most recent commit belongs to */ fun branch(branch: JsonField) = apply { this.branch = branch } @@ -203,7 +204,7 @@ private constructor( fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) /** SHA of most recent commit */ - fun commit(commit: Optional) = commit(commit.orElse(null)) + fun commit(commit: Optional) = commit(commit.getOrNull()) /** SHA of most recent commit */ fun commit(commit: JsonField) = apply { this.commit = commit } @@ -214,7 +215,7 @@ private constructor( /** Most recent commit message */ fun commitMessage(commitMessage: Optional) = - commitMessage(commitMessage.orElse(null)) + commitMessage(commitMessage.getOrNull()) /** Most recent commit message */ fun commitMessage(commitMessage: JsonField) = apply { @@ -225,7 +226,7 @@ private constructor( fun commitTime(commitTime: String?) = commitTime(JsonField.ofNullable(commitTime)) /** Time of the most recent commit */ - fun commitTime(commitTime: Optional) = commitTime(commitTime.orElse(null)) + fun commitTime(commitTime: Optional) = commitTime(commitTime.getOrNull()) /** Time of the most recent commit */ fun commitTime(commitTime: JsonField) = apply { this.commitTime = commitTime } @@ -237,8 +238,7 @@ private constructor( fun dirty(dirty: Boolean) = dirty(dirty as Boolean?) /** Whether or not the repo had uncommitted changes when snapshotted */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun dirty(dirty: Optional) = dirty(dirty.orElse(null) as Boolean?) + fun dirty(dirty: Optional) = dirty(dirty.getOrNull()) /** Whether or not the repo had uncommitted changes when snapshotted */ fun dirty(dirty: JsonField) = apply { this.dirty = dirty } @@ -253,7 +253,7 @@ private constructor( * If the repo was dirty when run, this includes the diff between the current state of the * repo and the most recent commit. */ - fun gitDiff(gitDiff: Optional) = gitDiff(gitDiff.orElse(null)) + fun gitDiff(gitDiff: Optional) = gitDiff(gitDiff.getOrNull()) /** * If the repo was dirty when run, this includes the diff between the current state of the @@ -265,7 +265,7 @@ private constructor( fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) /** Name of the tag on the most recent commit */ - fun tag(tag: Optional) = tag(tag.orElse(null)) + fun tag(tag: Optional) = tag(tag.getOrNull()) /** Name of the tag on the most recent commit */ fun tag(tag: JsonField) = apply { this.tag = tag } 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 c75836f2..3af60e1a 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 @@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * A role is a collection of permissions which can be granted as part of an ACL @@ -225,7 +226,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of role creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of role creation */ fun created(created: JsonField) = apply { this.created = created } @@ -234,7 +235,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } @@ -243,7 +244,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the role */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ fun description(description: JsonField) = apply { this.description = description } @@ -254,7 +255,7 @@ private constructor( /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.orElse(null)) + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: JsonField>) = apply { @@ -283,7 +284,7 @@ private constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.orElse(null)) + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from @@ -326,7 +327,7 @@ private constructor( * * It is forbidden to change the org after creating a role */ - fun orgId(orgId: Optional) = orgId(orgId.orElse(null)) + fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** * Unique id for the organization that the role belongs under @@ -342,7 +343,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the role */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the role */ fun userId(userId: JsonField) = apply { this.userId = userId } @@ -489,7 +490,7 @@ private constructor( /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: JsonField) = apply { 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 fdc5ad07..9e08f6e4 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 @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new role. If there is an existing role with the same name as the one specified in the @@ -238,7 +239,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the role */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ fun description(description: JsonField) = apply { @@ -251,7 +252,7 @@ private constructor( /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.orElse(null)) + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: JsonField>) = apply { @@ -282,7 +283,7 @@ private constructor( * all of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = - memberRoles(memberRoles.orElse(null)) + memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from @@ -319,7 +320,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -416,7 +417,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the role */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ fun description(description: JsonField) = apply { body.description(description) } @@ -428,7 +429,7 @@ private constructor( /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.orElse(null)) + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: JsonField>) = apply { @@ -454,7 +455,7 @@ private constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.orElse(null)) + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from @@ -486,7 +487,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -724,7 +725,7 @@ private constructor( /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: JsonField) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index 659fbcb0..f0957758 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all roles. The roles are sorted by creation date, with the most recently-created roles @@ -162,7 +163,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 8cdb3354..df21940e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all roles. The roles are sorted by creation date, with the most recently-created roles @@ -139,7 +140,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -151,7 +152,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -172,20 +173,19 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the role to search for */ fun roleName(roleName: String?) = apply { this.roleName = roleName } /** Name of the role to search for */ - fun roleName(roleName: Optional) = roleName(roleName.orElse(null)) + fun roleName(roleName: Optional) = roleName(roleName.getOrNull()) /** * Pagination cursor id. @@ -204,7 +204,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() 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 3769e8bf..8b9e78ad 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 @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace role. If there is an existing role with the same name as the one specified in @@ -238,7 +239,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the role */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ fun description(description: JsonField) = apply { @@ -251,7 +252,7 @@ private constructor( /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.orElse(null)) + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: JsonField>) = apply { @@ -282,7 +283,7 @@ private constructor( * all of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = - memberRoles(memberRoles.orElse(null)) + memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from @@ -319,7 +320,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -416,7 +417,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the role */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ fun description(description: JsonField) = apply { body.description(description) } @@ -428,7 +429,7 @@ private constructor( /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.orElse(null)) + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: JsonField>) = apply { @@ -454,7 +455,7 @@ private constructor( * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.orElse(null)) + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from @@ -486,7 +487,7 @@ private constructor( * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that @@ -728,7 +729,7 @@ private constructor( /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: JsonField) = apply { 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 347bf045..ac99a23e 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 @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a role object. Specify the fields to update in the payload. Any object-type @@ -232,7 +233,7 @@ private constructor( /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: Optional>) = - addMemberPermissions(addMemberPermissions.orElse(null)) + addMemberPermissions(addMemberPermissions.getOrNull()) /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: JsonField>) = @@ -254,7 +255,7 @@ private constructor( /** A list of role IDs to add to the role's inheriting-from set */ fun addMemberRoles(addMemberRoles: Optional>) = - addMemberRoles(addMemberRoles.orElse(null)) + addMemberRoles(addMemberRoles.getOrNull()) /** A list of role IDs to add to the role's inheriting-from set */ fun addMemberRoles(addMemberRoles: JsonField>) = apply { @@ -273,7 +274,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the role */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ fun description(description: JsonField) = apply { @@ -284,7 +285,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the role */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the role */ fun name(name: JsonField) = apply { this.name = name } @@ -296,7 +297,7 @@ private constructor( /** A list of permissions to remove from the role */ fun removeMemberPermissions( removeMemberPermissions: Optional> - ) = removeMemberPermissions(removeMemberPermissions.orElse(null)) + ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) /** A list of permissions to remove from the role */ fun removeMemberPermissions( @@ -319,7 +320,7 @@ private constructor( /** A list of role IDs to remove from the role's inheriting-from set */ fun removeMemberRoles(removeMemberRoles: Optional>) = - removeMemberRoles(removeMemberRoles.orElse(null)) + removeMemberRoles(removeMemberRoles.getOrNull()) /** A list of role IDs to remove from the role's inheriting-from set */ fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { @@ -425,7 +426,7 @@ private constructor( /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: Optional>) = - addMemberPermissions(addMemberPermissions.orElse(null)) + addMemberPermissions(addMemberPermissions.getOrNull()) /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: JsonField>) = @@ -445,7 +446,7 @@ private constructor( /** A list of role IDs to add to the role's inheriting-from set */ fun addMemberRoles(addMemberRoles: Optional>) = - addMemberRoles(addMemberRoles.orElse(null)) + addMemberRoles(addMemberRoles.getOrNull()) /** A list of role IDs to add to the role's inheriting-from set */ fun addMemberRoles(addMemberRoles: JsonField>) = apply { @@ -459,7 +460,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the role */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ fun description(description: JsonField) = apply { body.description(description) } @@ -468,7 +469,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the role */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the role */ fun name(name: JsonField) = apply { body.name(name) } @@ -482,7 +483,7 @@ private constructor( /** A list of permissions to remove from the role */ fun removeMemberPermissions( removeMemberPermissions: Optional> - ) = removeMemberPermissions(removeMemberPermissions.orElse(null)) + ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) /** A list of permissions to remove from the role */ fun removeMemberPermissions( @@ -501,7 +502,7 @@ private constructor( /** A list of role IDs to remove from the role's inheriting-from set */ fun removeMemberRoles(removeMemberRoles: Optional>) = - removeMemberRoles(removeMemberRoles.orElse(null)) + removeMemberRoles(removeMemberRoles.getOrNull()) /** A list of role IDs to remove from the role's inheriting-from set */ fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { @@ -747,7 +748,7 @@ private constructor( /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: JsonField) = apply { @@ -1215,7 +1216,7 @@ private constructor( /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.orElse(null)) + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ fun restrictObjectType(restrictObjectType: JsonField) = apply { 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 7f734052..c7177997 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 @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Human-identifying attributes of the span, such as name, type, etc. */ @NoAutoDetect @@ -82,7 +83,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the span, for display purposes only */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the span, for display purposes only */ fun name(name: JsonField) = apply { this.name = name } @@ -91,7 +92,7 @@ private constructor( fun type(type: Type?) = type(JsonField.ofNullable(type)) /** Type of the span, for display purposes only */ - fun type(type: Optional) = type(type.orElse(null)) + fun type(type: Optional) = type(type.getOrNull()) /** Type of the span, for display purposes only */ fun type(type: JsonField) = apply { this.type = type } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index 476c9e6a..ab9266fa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class SpanIFrame @@ -210,7 +211,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of span iframe creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of span iframe creation */ fun created(created: JsonField) = apply { this.created = created } @@ -219,7 +220,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of span iframe deletion, or null if the span iframe is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of span iframe deletion, or null if the span iframe is still active */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } @@ -228,7 +229,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the span iframe */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ fun description(description: JsonField) = apply { this.description = description } @@ -249,9 +250,7 @@ private constructor( * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun postMessage(postMessage: Optional) = - postMessage(postMessage.orElse(null) as Boolean?) + fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** * Whether to post messages to the iframe containing the span's data. This is useful when @@ -263,7 +262,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the span iframe */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the span iframe */ fun userId(userId: JsonField) = apply { this.userId = userId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index af2eb652..9f81c14e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new span_iframe. If there is an existing span_iframe with the same name as the one @@ -220,7 +221,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the span iframe */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ fun description(description: JsonField) = apply { @@ -243,9 +244,7 @@ private constructor( * Whether to post messages to the iframe containing the span's data. This is useful * when you want to render more data than fits in the URL. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun postMessage(postMessage: Optional) = - postMessage(postMessage.orElse(null) as Boolean?) + fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** * Whether to post messages to the iframe containing the span's data. This is useful @@ -357,7 +356,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the span iframe */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ fun description(description: JsonField) = apply { body.description(description) } @@ -378,9 +377,7 @@ private constructor( * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun postMessage(postMessage: Optional) = - postMessage(postMessage.orElse(null) as Boolean?) + fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** * Whether to post messages to the iframe containing the span's data. This is useful when diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index ad9f8798..26329957 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all span_iframes. The span_iframes are sorted by creation date, with the most @@ -172,7 +173,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 29cfffa8..87ccce77 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all span_iframes. The span_iframes are sorted by creation date, with the most @@ -139,7 +140,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -151,7 +152,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -172,21 +173,20 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the span_iframe to search for */ fun spanIframeName(spanIframeName: String?) = apply { this.spanIframeName = spanIframeName } /** Name of the span_iframe to search for */ fun spanIframeName(spanIframeName: Optional) = - spanIframeName(spanIframeName.orElse(null)) + spanIframeName(spanIframeName.getOrNull()) /** * Pagination cursor id. @@ -205,7 +205,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index ef60764f..d3dc8f16 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace span_iframe. If there is an existing span_iframe with the same name as the one @@ -220,7 +221,7 @@ private constructor( fun description(description: String?) = description(JsonField.ofNullable(description)) /** Textual description of the span iframe */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ fun description(description: JsonField) = apply { @@ -243,9 +244,7 @@ private constructor( * Whether to post messages to the iframe containing the span's data. This is useful * when you want to render more data than fits in the URL. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun postMessage(postMessage: Optional) = - postMessage(postMessage.orElse(null) as Boolean?) + fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** * Whether to post messages to the iframe containing the span's data. This is useful @@ -357,7 +356,7 @@ private constructor( fun description(description: String?) = apply { body.description(description) } /** Textual description of the span iframe */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ fun description(description: JsonField) = apply { body.description(description) } @@ -378,9 +377,7 @@ private constructor( * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun postMessage(postMessage: Optional) = - postMessage(postMessage.orElse(null) as Boolean?) + fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** * Whether to post messages to the iframe containing the span's data. This is useful when diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index e361d331..50735234 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a span_iframe object. Specify the fields to update in the payload. Any @@ -166,7 +167,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the span iframe */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the span iframe */ fun name(name: JsonField) = apply { this.name = name } @@ -187,9 +188,7 @@ private constructor( * Whether to post messages to the iframe containing the span's data. This is useful * when you want to render more data than fits in the URL. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun postMessage(postMessage: Optional) = - postMessage(postMessage.orElse(null) as Boolean?) + fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** * Whether to post messages to the iframe containing the span's data. This is useful @@ -203,7 +202,7 @@ private constructor( fun url(url: String?) = url(JsonField.ofNullable(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: Optional) = url(url.orElse(null)) + fun url(url: Optional) = url(url.getOrNull()) /** URL to embed the project viewer in an iframe */ fun url(url: JsonField) = apply { this.url = url } @@ -287,7 +286,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the span iframe */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the span iframe */ fun name(name: JsonField) = apply { body.name(name) } @@ -308,9 +307,7 @@ private constructor( * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun postMessage(postMessage: Optional) = - postMessage(postMessage.orElse(null) as Boolean?) + fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** * Whether to post messages to the iframe containing the span's data. This is useful when @@ -322,7 +319,7 @@ private constructor( fun url(url: String?) = apply { body.url(url) } /** URL to embed the project viewer in an iframe */ - fun url(url: Optional) = url(url.orElse(null)) + fun url(url: Optional) = url(url.getOrNull()) /** URL to embed the project viewer in an iframe */ fun url(url: JsonField) = apply { body.url(url) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 54a9b9df..949d6300 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -16,6 +16,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Summary of a dataset */ @NoAutoDetect @@ -162,7 +163,7 @@ private constructor( fun dataSummary(dataSummary: DataSummary?) = dataSummary(JsonField.ofNullable(dataSummary)) /** Summary of a dataset's data */ - fun dataSummary(dataSummary: Optional) = dataSummary(dataSummary.orElse(null)) + fun dataSummary(dataSummary: Optional) = dataSummary(dataSummary.getOrNull()) /** Summary of a dataset's data */ fun dataSummary(dataSummary: JsonField) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 2c6af4bc..b23ca9e9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -16,6 +16,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Summary of an experiment */ @NoAutoDetect @@ -194,7 +195,7 @@ private constructor( /** The experiment which scores are baselined against */ fun comparisonExperimentName(comparisonExperimentName: Optional) = - comparisonExperimentName(comparisonExperimentName.orElse(null)) + comparisonExperimentName(comparisonExperimentName.getOrNull()) /** The experiment which scores are baselined against */ fun comparisonExperimentName(comparisonExperimentName: JsonField) = apply { @@ -205,7 +206,7 @@ private constructor( fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** Summary of the experiment's metrics */ - fun metrics(metrics: Optional) = metrics(metrics.orElse(null)) + fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** Summary of the experiment's metrics */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } @@ -214,7 +215,7 @@ private constructor( fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** Summary of the experiment's scores */ - fun scores(scores: Optional) = scores(scores.orElse(null)) + fun scores(scores: Optional) = scores(scores.getOrNull()) /** Summary of the experiment's scores */ fun scores(scores: JsonField) = apply { this.scores = scores } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index 0fdc6758..b064f7aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class User @@ -142,7 +143,7 @@ private constructor( fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) /** URL of the user's Avatar image */ - fun avatarUrl(avatarUrl: Optional) = avatarUrl(avatarUrl.orElse(null)) + fun avatarUrl(avatarUrl: Optional) = avatarUrl(avatarUrl.getOrNull()) /** URL of the user's Avatar image */ fun avatarUrl(avatarUrl: JsonField) = apply { this.avatarUrl = avatarUrl } @@ -151,7 +152,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of user creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of user creation */ fun created(created: JsonField) = apply { this.created = created } @@ -160,7 +161,7 @@ private constructor( fun email(email: String?) = email(JsonField.ofNullable(email)) /** The user's email */ - fun email(email: Optional) = email(email.orElse(null)) + fun email(email: Optional) = email(email.getOrNull()) /** The user's email */ fun email(email: JsonField) = apply { this.email = email } @@ -169,7 +170,7 @@ private constructor( fun familyName(familyName: String?) = familyName(JsonField.ofNullable(familyName)) /** Family name of the user */ - fun familyName(familyName: Optional) = familyName(familyName.orElse(null)) + fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) /** Family name of the user */ fun familyName(familyName: JsonField) = apply { this.familyName = familyName } @@ -178,7 +179,7 @@ private constructor( fun givenName(givenName: String?) = givenName(JsonField.ofNullable(givenName)) /** Given name of the user */ - fun givenName(givenName: Optional) = givenName(givenName.orElse(null)) + fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) /** Given name of the user */ fun givenName(givenName: JsonField) = apply { this.givenName = givenName } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 12697ca2..c02d5269 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all users. The users are sorted by creation date, with the most recently-created users @@ -162,7 +163,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 41323443..d259099e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all users. The users are sorted by creation date, with the most recently-created users @@ -156,7 +157,7 @@ private constructor( * Email of the user to search for. You may pass the param multiple times to filter for more * than one email */ - fun email(email: Optional) = email(email.orElse(null)) + fun email(email: Optional) = email(email.getOrNull()) /** * Email of the user to search for. You may pass the param multiple times to filter for more @@ -186,7 +187,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Family name of the user to search for. You may pass the param multiple times to filter @@ -198,7 +199,7 @@ private constructor( * Family name of the user to search for. You may pass the param multiple times to filter * for more than one family name */ - fun familyName(familyName: Optional) = familyName(familyName.orElse(null)) + fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) /** * Family name of the user to search for. You may pass the param multiple times to filter @@ -222,7 +223,7 @@ private constructor( * Given name of the user to search for. You may pass the param multiple times to filter for * more than one given name */ - fun givenName(givenName: Optional) = givenName(givenName.orElse(null)) + fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) /** * Given name of the user to search for. You may pass the param multiple times to filter for @@ -246,7 +247,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -267,14 +268,13 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ - fun orgName(orgName: Optional) = orgName(orgName.orElse(null)) + fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** * Pagination cursor id. @@ -293,7 +293,7 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() 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 95dcc589..a8bb266f 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 @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class View @@ -219,7 +220,7 @@ private constructor( fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) /** Type of table that the view corresponds to. */ - fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: JsonField) = apply { this.viewType = viewType } @@ -228,7 +229,7 @@ private constructor( fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** Date of view creation */ - fun created(created: Optional) = created(created.orElse(null)) + fun created(created: Optional) = created(created.getOrNull()) /** Date of view creation */ fun created(created: JsonField) = apply { this.created = created } @@ -237,7 +238,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } @@ -246,7 +247,7 @@ private constructor( fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) /** Options for the view in the app */ - fun options(options: Optional) = options(options.orElse(null)) + fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ fun options(options: JsonField) = apply { this.options = options } @@ -255,7 +256,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the view */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ fun userId(userId: JsonField) = apply { this.userId = userId } @@ -264,7 +265,7 @@ private constructor( fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) /** The view definition */ - fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ fun viewData(viewData: JsonField) = apply { this.viewData = viewData } 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 c9868849..0597fc32 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 @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create a new view. If there is an existing view with the same name as the one specified in the @@ -269,7 +270,7 @@ private constructor( fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) /** Type of table that the view corresponds to. */ - fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: JsonField) = apply { this.viewType = viewType } @@ -278,7 +279,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: JsonField) = apply { @@ -289,7 +290,7 @@ private constructor( fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) /** Options for the view in the app */ - fun options(options: Optional) = options(options.orElse(null)) + fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ fun options(options: JsonField) = apply { this.options = options } @@ -298,7 +299,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the view */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ fun userId(userId: JsonField) = apply { this.userId = userId } @@ -307,7 +308,7 @@ private constructor( fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) /** The view definition */ - fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ fun viewData(viewData: JsonField) = apply { this.viewData = viewData } @@ -418,7 +419,7 @@ private constructor( fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } /** Type of table that the view corresponds to. */ - fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } @@ -427,7 +428,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } @@ -436,7 +437,7 @@ private constructor( fun options(options: ViewOptions?) = apply { body.options(options) } /** Options for the view in the app */ - fun options(options: Optional) = options(options.orElse(null)) + fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ fun options(options: JsonField) = apply { body.options(options) } @@ -445,7 +446,7 @@ private constructor( fun userId(userId: String?) = apply { body.userId(userId) } /** Identifies the user who created the view */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ fun userId(userId: JsonField) = apply { body.userId(userId) } @@ -454,7 +455,7 @@ private constructor( fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } /** The view definition */ - fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index ab8fcdc2..70d0d8ce 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -15,6 +15,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** The view definition */ @NoAutoDetect @@ -68,7 +69,7 @@ private constructor( fun search(search: ViewDataSearch?) = search(JsonField.ofNullable(search)) - fun search(search: Optional) = search(search.orElse(null)) + fun search(search: Optional) = search(search.getOrNull()) fun search(search: JsonField) = apply { this.search = search } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 8238b323..6d12484b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -16,6 +16,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull @NoAutoDetect class ViewDataSearch @@ -98,7 +99,7 @@ private constructor( fun filter(filter: List?) = filter(JsonField.ofNullable(filter)) - fun filter(filter: Optional>) = filter(filter.orElse(null)) + fun filter(filter: Optional>) = filter(filter.getOrNull()) fun filter(filter: JsonField>) = apply { this.filter = filter.map { it.toMutableList() } @@ -113,7 +114,7 @@ private constructor( fun match(match: List?) = match(JsonField.ofNullable(match)) - fun match(match: Optional>) = match(match.orElse(null)) + fun match(match: Optional>) = match(match.getOrNull()) fun match(match: JsonField>) = apply { this.match = match.map { it.toMutableList() } @@ -128,7 +129,7 @@ private constructor( fun sort(sort: List?) = sort(JsonField.ofNullable(sort)) - fun sort(sort: Optional>) = sort(sort.orElse(null)) + fun sort(sort: Optional>) = sort(sort.getOrNull()) fun sort(sort: JsonField>) = apply { this.sort = sort.map { it.toMutableList() } @@ -143,7 +144,7 @@ private constructor( fun tag(tag: List?) = tag(JsonField.ofNullable(tag)) - fun tag(tag: Optional>) = tag(tag.orElse(null)) + fun tag(tag: Optional>) = tag(tag.getOrNull()) fun tag(tag: JsonField>) = apply { this.tag = tag.map { it.toMutableList() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index a845861b..fde4f5ac 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -18,6 +18,7 @@ import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrNull /** * List out all views. The views are sorted by creation date, with the most recently-created views @@ -162,7 +163,7 @@ private constructor( while (index < page.objects().size) { yield(page.objects()[index++]) } - page = page.getNextPage().orElse(null) ?: break + page = page.getNextPage().getOrNull() ?: break index = 0 } } 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 6bdea64e..3dd24391 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 @@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * List out all views. The views are sorted by creation date, with the most recently-created views @@ -169,7 +170,7 @@ private constructor( * `ending_before=foo` to fetch the previous page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.orElse(null)) + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -181,7 +182,7 @@ private constructor( * Filter search results to a particular set of object IDs. To specify a list of IDs, * include the query param multiple times */ - fun ids(ids: Optional) = ids(ids.orElse(null)) + fun ids(ids: Optional) = ids(ids.getOrNull()) /** * Filter search results to a particular set of object IDs. To specify a list of IDs, @@ -202,8 +203,7 @@ private constructor( fun limit(limit: Long) = limit(limit as Long?) /** Limit the number of objects to return */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) + fun limit(limit: Optional) = limit(limit.getOrNull()) /** * Pagination cursor id. @@ -222,19 +222,19 @@ private constructor( * `starting_after` and `ending_before` */ fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.orElse(null)) + startingAfter(startingAfter.getOrNull()) /** Name of the view to search for */ fun viewName(viewName: String?) = apply { this.viewName = viewName } /** Name of the view to search for */ - fun viewName(viewName: Optional) = viewName(viewName.orElse(null)) + fun viewName(viewName: Optional) = viewName(viewName.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = apply { this.viewType = viewType } /** Type of table that the view corresponds to. */ - fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index edbaa607..731eab40 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -16,6 +16,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Options for the view in the app */ @NoAutoDetect @@ -98,7 +99,7 @@ private constructor( fun columnOrder(columnOrder: List?) = columnOrder(JsonField.ofNullable(columnOrder)) - fun columnOrder(columnOrder: Optional>) = columnOrder(columnOrder.orElse(null)) + fun columnOrder(columnOrder: Optional>) = columnOrder(columnOrder.getOrNull()) fun columnOrder(columnOrder: JsonField>) = apply { this.columnOrder = columnOrder.map { it.toMutableList() } @@ -115,7 +116,7 @@ private constructor( columnSizing(JsonField.ofNullable(columnSizing)) fun columnSizing(columnSizing: Optional) = - columnSizing(columnSizing.orElse(null)) + columnSizing(columnSizing.getOrNull()) fun columnSizing(columnSizing: JsonField) = apply { this.columnSizing = columnSizing @@ -125,7 +126,7 @@ private constructor( columnVisibility(JsonField.ofNullable(columnVisibility)) fun columnVisibility(columnVisibility: Optional) = - columnVisibility(columnVisibility.orElse(null)) + columnVisibility(columnVisibility.getOrNull()) fun columnVisibility(columnVisibility: JsonField) = apply { this.columnVisibility = columnVisibility 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 89eb1c50..d99f4f94 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 @@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Create or replace view. If there is an existing view with the same name as the one specified in @@ -269,7 +270,7 @@ private constructor( fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) /** Type of table that the view corresponds to. */ - fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: JsonField) = apply { this.viewType = viewType } @@ -278,7 +279,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: JsonField) = apply { @@ -289,7 +290,7 @@ private constructor( fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) /** Options for the view in the app */ - fun options(options: Optional) = options(options.orElse(null)) + fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ fun options(options: JsonField) = apply { this.options = options } @@ -298,7 +299,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the view */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ fun userId(userId: JsonField) = apply { this.userId = userId } @@ -307,7 +308,7 @@ private constructor( fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) /** The view definition */ - fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ fun viewData(viewData: JsonField) = apply { this.viewData = viewData } @@ -418,7 +419,7 @@ private constructor( fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } /** Type of table that the view corresponds to. */ - fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } @@ -427,7 +428,7 @@ private constructor( fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.orElse(null)) + fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } @@ -436,7 +437,7 @@ private constructor( fun options(options: ViewOptions?) = apply { body.options(options) } /** Options for the view in the app */ - fun options(options: Optional) = options(options.orElse(null)) + fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ fun options(options: JsonField) = apply { body.options(options) } @@ -445,7 +446,7 @@ private constructor( fun userId(userId: String?) = apply { body.userId(userId) } /** Identifies the user who created the view */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ fun userId(userId: JsonField) = apply { body.userId(userId) } @@ -454,7 +455,7 @@ private constructor( fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } /** The view definition */ - fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } 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 349c88e5..368c4698 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 @@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Partially update a view object. Specify the fields to update in the payload. Any object-type @@ -251,7 +252,7 @@ private constructor( fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the view */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the view */ fun name(name: JsonField) = apply { this.name = name } @@ -260,7 +261,7 @@ private constructor( fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) /** Options for the view in the app */ - fun options(options: Optional) = options(options.orElse(null)) + fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ fun options(options: JsonField) = apply { this.options = options } @@ -269,7 +270,7 @@ private constructor( fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Identifies the user who created the view */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ fun userId(userId: JsonField) = apply { this.userId = userId } @@ -278,7 +279,7 @@ private constructor( fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) /** The view definition */ - fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ fun viewData(viewData: JsonField) = apply { this.viewData = viewData } @@ -287,7 +288,7 @@ private constructor( fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) /** Type of table that the view corresponds to. */ - fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: JsonField) = apply { this.viewType = viewType } @@ -395,7 +396,7 @@ private constructor( fun name(name: String?) = apply { body.name(name) } /** Name of the view */ - fun name(name: Optional) = name(name.orElse(null)) + fun name(name: Optional) = name(name.getOrNull()) /** Name of the view */ fun name(name: JsonField) = apply { body.name(name) } @@ -404,7 +405,7 @@ private constructor( fun options(options: ViewOptions?) = apply { body.options(options) } /** Options for the view in the app */ - fun options(options: Optional) = options(options.orElse(null)) + fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ fun options(options: JsonField) = apply { body.options(options) } @@ -413,7 +414,7 @@ private constructor( fun userId(userId: String?) = apply { body.userId(userId) } /** Identifies the user who created the view */ - fun userId(userId: Optional) = userId(userId.orElse(null)) + fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ fun userId(userId: JsonField) = apply { body.userId(userId) } @@ -422,7 +423,7 @@ private constructor( fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } /** The view definition */ - fun viewData(viewData: Optional) = viewData(viewData.orElse(null)) + fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } @@ -431,7 +432,7 @@ private constructor( fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } /** Type of table that the view corresponds to. */ - fun viewType(viewType: Optional) = viewType(viewType.orElse(null)) + fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } From 84daad738819f265ff28ab6c351008a7018e0340 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 8 Mar 2025 06:40:26 +0000 Subject: [PATCH 71/87] chore(internal): reenable warnings as errors (#141) chore(internal): don't use `JvmOverloads` in interfaces --- .../api/core/http/HttpClient.kt | 9 +- .../api/services/async/AclServiceAsync.kt | 90 ++++++++--- .../services/async/AiSecretServiceAsync.kt | 102 +++++++++--- .../api/services/async/ApiKeyServiceAsync.kt | 69 ++++++--- .../api/services/async/DatasetServiceAsync.kt | 143 +++++++++++++---- .../api/services/async/EnvVarServiceAsync.kt | 89 ++++++++--- .../api/services/async/EvalServiceAsync.kt | 15 +- .../services/async/ExperimentServiceAsync.kt | 146 ++++++++++++++---- .../services/async/FunctionServiceAsync.kt | 102 +++++++++--- .../api/services/async/GroupServiceAsync.kt | 89 ++++++++--- .../async/OrganizationServiceAsync.kt | 71 ++++++--- .../async/ProjectScoreServiceAsync.kt | 95 +++++++++--- .../api/services/async/ProjectServiceAsync.kt | 78 +++++++--- .../services/async/ProjectTagServiceAsync.kt | 91 ++++++++--- .../api/services/async/PromptServiceAsync.kt | 89 ++++++++--- .../api/services/async/RoleServiceAsync.kt | 88 ++++++++--- .../services/async/SpanIframeServiceAsync.kt | 91 ++++++++--- .../services/async/TopLevelServiceAsync.kt | 30 ++-- .../api/services/async/UserServiceAsync.kt | 44 ++++-- .../api/services/async/ViewServiceAsync.kt | 68 ++++++-- .../async/organizations/MemberServiceAsync.kt | 32 ++-- .../async/projects/LogServiceAsync.kt | 55 +++++-- .../api/services/blocking/AclService.kt | 84 +++++++--- .../api/services/blocking/AiSecretService.kt | 92 ++++++++--- .../api/services/blocking/ApiKeyService.kt | 61 +++++--- .../api/services/blocking/DatasetService.kt | 125 +++++++++++---- .../api/services/blocking/EnvVarService.kt | 81 +++++++--- .../api/services/blocking/EvalService.kt | 13 +- .../services/blocking/ExperimentService.kt | 129 ++++++++++++---- .../api/services/blocking/FunctionService.kt | 93 ++++++++--- .../api/services/blocking/GroupService.kt | 79 +++++++--- .../services/blocking/OrganizationService.kt | 64 +++++--- .../services/blocking/ProjectScoreService.kt | 86 ++++++++--- .../api/services/blocking/ProjectService.kt | 70 ++++++--- .../services/blocking/ProjectTagService.kt | 83 +++++++--- .../api/services/blocking/PromptService.kt | 80 +++++++--- .../api/services/blocking/RoleService.kt | 79 +++++++--- .../services/blocking/SpanIframeService.kt | 83 +++++++--- .../api/services/blocking/TopLevelService.kt | 28 ++-- .../api/services/blocking/UserService.kt | 39 +++-- .../api/services/blocking/ViewService.kt | 62 ++++++-- .../blocking/organizations/MemberService.kt | 30 ++-- .../services/blocking/projects/LogService.kt | 48 ++++-- .../main/kotlin/braintrust.kotlin.gradle.kts | 9 +- 44 files changed, 2396 insertions(+), 808 deletions(-) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt index 1a8a3910..5941bacd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt @@ -1,5 +1,3 @@ -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.core.http import com.braintrustdata.api.core.RequestOptions @@ -8,18 +6,21 @@ import java.util.concurrent.CompletableFuture interface HttpClient : AutoCloseable { - @JvmOverloads fun execute( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - @JvmOverloads + fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + fun executeAsync( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + fun executeAsync(request: HttpRequest): CompletableFuture = + executeAsync(request, RequestOptions.none()) + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ override fun close() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 3ad05814..5138c220 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -29,14 +27,20 @@ interface AclServiceAsync { * Create a new acl. If there is an existing acl with the same contents as the one specified in * the request, will return the existing acl unmodified */ - @JvmOverloads + fun create(params: AclCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an acl object by its id */ - @JvmOverloads + fun retrieve(params: AclRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,14 +50,20 @@ interface AclServiceAsync { * List out all acls. The acls are sorted by creation date, with the most recently-created acls * coming first */ - @JvmOverloads + fun list(params: AclListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: AclListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete an acl object by its id */ - @JvmOverloads + fun delete(params: AclDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -63,21 +73,29 @@ interface AclServiceAsync { * Batch update acls. This operation is idempotent, so adding acls which already exist will have * no effect, and removing acls which do not exist will have no effect. */ - @JvmOverloads + fun batchUpdate(): CompletableFuture = + batchUpdate(AclBatchUpdateParams.none()) + + /** @see [batchUpdate] */ fun batchUpdate( params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. - */ + /** @see [batchUpdate] */ + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): CompletableFuture = batchUpdate(params, RequestOptions.none()) + + /** @see [batchUpdate] */ fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** Delete a single acl */ - @JvmOverloads + fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture = + findAndDelete(params, RequestOptions.none()) + + /** @see [findAndDelete] */ fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -90,7 +108,11 @@ interface AclServiceAsync { * Returns a raw HTTP response for `post /v1/acl`, but is otherwise the same as * [AclServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: AclCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: AclCreateParams, @@ -101,7 +123,11 @@ interface AclServiceAsync { * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as * [AclServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: AclRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: AclRetrieveParams, @@ -112,7 +138,11 @@ interface AclServiceAsync { * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as * [AclServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(params: AclListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( params: AclListParams, @@ -123,7 +153,11 @@ interface AclServiceAsync { * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as * [AclServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: AclDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: AclDeleteParams, @@ -134,17 +168,25 @@ interface AclServiceAsync { * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as * [AclServiceAsync.batchUpdate]. */ - @JvmOverloads + @MustBeClosed + fun batchUpdate(): CompletableFuture> = + batchUpdate(AclBatchUpdateParams.none()) + + /** @see [batchUpdate] */ @MustBeClosed fun batchUpdate( params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclServiceAsync.batchUpdate]. - */ + /** @see [batchUpdate] */ + @MustBeClosed + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): CompletableFuture> = + batchUpdate(params, RequestOptions.none()) + + /** @see [batchUpdate] */ @MustBeClosed fun batchUpdate( requestOptions: RequestOptions @@ -155,7 +197,11 @@ interface AclServiceAsync { * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as * [AclServiceAsync.findAndDelete]. */ - @JvmOverloads + @MustBeClosed + fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture> = + findAndDelete(params, RequestOptions.none()) + + /** @see [findAndDelete] */ @MustBeClosed fun findAndDelete( params: AclFindAndDeleteParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt index 6cd0cd07..dc90a38c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -29,14 +27,20 @@ interface AiSecretServiceAsync { * Create a new ai_secret. If there is an existing ai_secret with the same name as the one * specified in the request, will return the existing ai_secret unmodified */ - @JvmOverloads + fun create(params: AiSecretCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an ai_secret object by its id */ - @JvmOverloads + fun retrieve(params: AiSecretRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -47,7 +51,10 @@ interface AiSecretServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: AiSecretUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -57,28 +64,38 @@ interface AiSecretServiceAsync { * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most * recently-created ai_secrets coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(AiSecretListParams.none()) + + /** @see [list] */ fun list( params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first - */ + /** @see [list] */ + fun list( + params: AiSecretListParams = AiSecretListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(AiSecretListParams.none(), requestOptions) /** Delete an ai_secret object by its id */ - @JvmOverloads + fun delete(params: AiSecretDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a single ai_secret */ - @JvmOverloads + fun findAndDelete(params: AiSecretFindAndDeleteParams): CompletableFuture = + findAndDelete(params, RequestOptions.none()) + + /** @see [findAndDelete] */ fun findAndDelete( params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -88,7 +105,10 @@ interface AiSecretServiceAsync { * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one * specified in the request, will replace the existing ai_secret with the provided fields */ - @JvmOverloads + fun replace(params: AiSecretReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -103,7 +123,11 @@ interface AiSecretServiceAsync { * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as * [AiSecretServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: AiSecretCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: AiSecretCreateParams, @@ -114,7 +138,11 @@ interface AiSecretServiceAsync { * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the * same as [AiSecretServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: AiSecretRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: AiSecretRetrieveParams, @@ -125,7 +153,11 @@ interface AiSecretServiceAsync { * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise * the same as [AiSecretServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: AiSecretUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: AiSecretUpdateParams, @@ -136,17 +168,25 @@ interface AiSecretServiceAsync { * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as * [AiSecretServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(AiSecretListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: AiSecretListParams = AiSecretListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -157,7 +197,11 @@ interface AiSecretServiceAsync { * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise * the same as [AiSecretServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: AiSecretDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: AiSecretDeleteParams, @@ -168,7 +212,13 @@ interface AiSecretServiceAsync { * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as * [AiSecretServiceAsync.findAndDelete]. */ - @JvmOverloads + @MustBeClosed + fun findAndDelete( + params: AiSecretFindAndDeleteParams + ): CompletableFuture> = + findAndDelete(params, RequestOptions.none()) + + /** @see [findAndDelete] */ @MustBeClosed fun findAndDelete( params: AiSecretFindAndDeleteParams, @@ -179,7 +229,11 @@ interface AiSecretServiceAsync { * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as * [AiSecretServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: AiSecretReplaceParams): CompletableFuture> = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: AiSecretReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index fde34650..94e69910 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -27,14 +25,20 @@ interface ApiKeyServiceAsync { * Create a new api_key. It is possible to have multiple API keys with the same name. There is * no de-duplication */ - @JvmOverloads + fun create(params: ApiKeyCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an api_key object by its id */ - @JvmOverloads + fun retrieve(params: ApiKeyRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -44,21 +48,28 @@ interface ApiKeyServiceAsync { * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(ApiKeyListParams.none()) + + /** @see [list] */ fun list( params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first - */ + /** @see [list] */ + fun list( + params: ApiKeyListParams = ApiKeyListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(ApiKeyListParams.none(), requestOptions) /** Delete an api_key object by its id */ - @JvmOverloads + fun delete(params: ApiKeyDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -73,7 +84,13 @@ interface ApiKeyServiceAsync { * Returns a raw HTTP response for `post /v1/api_key`, but is otherwise the same as * [ApiKeyServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create( + params: ApiKeyCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ApiKeyCreateParams, @@ -84,7 +101,11 @@ interface ApiKeyServiceAsync { * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same * as [ApiKeyServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ApiKeyRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ApiKeyRetrieveParams, @@ -95,17 +116,25 @@ interface ApiKeyServiceAsync { * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as * [ApiKeyServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(ApiKeyListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as - * [ApiKeyServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ApiKeyListParams = ApiKeyListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -116,7 +145,11 @@ interface ApiKeyServiceAsync { * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the * same as [ApiKeyServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ApiKeyDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ApiKeyDeleteParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index c415943b..a6d7c52c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -36,14 +34,20 @@ interface DatasetServiceAsync { * Create a new dataset. If there is an existing dataset in the project with the same name as * the one specified in the request, will return the existing dataset unmodified */ - @JvmOverloads + fun create(params: DatasetCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a dataset object by its id */ - @JvmOverloads + fun retrieve(params: DatasetRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -54,7 +58,10 @@ interface DatasetServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: DatasetUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -64,28 +71,38 @@ interface DatasetServiceAsync { * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(DatasetListParams.none()) + + /** @see [list] */ fun list( params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all datasets. The datasets are sorted by creation date, with the most - * recently-created datasets coming first - */ + /** @see [list] */ + fun list( + params: DatasetListParams = DatasetListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(DatasetListParams.none(), requestOptions) /** Delete a dataset object by its id */ - @JvmOverloads + fun delete(params: DatasetDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Log feedback for a set of dataset events */ - @JvmOverloads + fun feedback(params: DatasetFeedbackParams): CompletableFuture = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ fun feedback( params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -96,7 +113,10 @@ interface DatasetServiceAsync { * parameters in the URL query rather than in the request body. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetch(params: DatasetFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ fun fetch( params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -107,21 +127,30 @@ interface DatasetServiceAsync { * parameters in the request body rather than in the URL query. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetchPost(params: DatasetFetchPostParams): CompletableFuture = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ fun fetchPost( params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Insert a set of events into the dataset */ - @JvmOverloads + fun insert(params: DatasetInsertParams): CompletableFuture = + insert(params, RequestOptions.none()) + + /** @see [insert] */ fun insert( params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Summarize dataset */ - @JvmOverloads + fun summarize(params: DatasetSummarizeParams): CompletableFuture = + summarize(params, RequestOptions.none()) + + /** @see [summarize] */ fun summarize( params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -136,7 +165,11 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `post /v1/dataset`, but is otherwise the same as * [DatasetServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: DatasetCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: DatasetCreateParams, @@ -147,7 +180,11 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same * as [DatasetServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: DatasetRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: DatasetRetrieveParams, @@ -158,7 +195,11 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the * same as [DatasetServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: DatasetUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: DatasetUpdateParams, @@ -169,17 +210,25 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as * [DatasetServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(DatasetListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as - * [DatasetServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: DatasetListParams = DatasetListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -190,7 +239,11 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the * same as [DatasetServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: DatasetDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: DatasetDeleteParams, @@ -201,7 +254,13 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is * otherwise the same as [DatasetServiceAsync.feedback]. */ - @JvmOverloads + @MustBeClosed + fun feedback( + params: DatasetFeedbackParams + ): CompletableFuture> = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ @MustBeClosed fun feedback( params: DatasetFeedbackParams, @@ -212,7 +271,13 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise * the same as [DatasetServiceAsync.fetch]. */ - @JvmOverloads + @MustBeClosed + fun fetch( + params: DatasetFetchParams + ): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ @MustBeClosed fun fetch( params: DatasetFetchParams, @@ -223,7 +288,13 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise * the same as [DatasetServiceAsync.fetchPost]. */ - @JvmOverloads + @MustBeClosed + fun fetchPost( + params: DatasetFetchPostParams + ): CompletableFuture> = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ @MustBeClosed fun fetchPost( params: DatasetFetchPostParams, @@ -234,7 +305,13 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise * the same as [DatasetServiceAsync.insert]. */ - @JvmOverloads + @MustBeClosed + fun insert( + params: DatasetInsertParams + ): CompletableFuture> = + insert(params, RequestOptions.none()) + + /** @see [insert] */ @MustBeClosed fun insert( params: DatasetInsertParams, @@ -245,7 +322,13 @@ interface DatasetServiceAsync { * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is * otherwise the same as [DatasetServiceAsync.summarize]. */ - @JvmOverloads + @MustBeClosed + fun summarize( + params: DatasetSummarizeParams + ): CompletableFuture> = + summarize(params, RequestOptions.none()) + + /** @see [summarize] */ @MustBeClosed fun summarize( params: DatasetSummarizeParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt index 9a8d57ff..49a3693f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,20 @@ interface EnvVarServiceAsync { * Create a new env_var. If there is an existing env_var with the same name as the one specified * in the request, will return the existing env_var unmodified */ - @JvmOverloads + fun create(params: EnvVarCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an env_var object by its id */ - @JvmOverloads + fun retrieve(params: EnvVarRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +50,10 @@ interface EnvVarServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: EnvVarUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,21 +63,28 @@ interface EnvVarServiceAsync { * List out all env_vars. The env_vars are sorted by creation date, with the most * recently-created env_vars coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(EnvVarListParams.none()) + + /** @see [list] */ fun list( params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all env_vars. The env_vars are sorted by creation date, with the most - * recently-created env_vars coming first - */ + /** @see [list] */ + fun list( + params: EnvVarListParams = EnvVarListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(EnvVarListParams.none(), requestOptions) /** Delete an env_var object by its id */ - @JvmOverloads + fun delete(params: EnvVarDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -80,7 +94,10 @@ interface EnvVarServiceAsync { * Create or replace env_var. If there is an existing env_var with the same name as the one * specified in the request, will replace the existing env_var with the provided fields */ - @JvmOverloads + fun replace(params: EnvVarReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -95,7 +112,11 @@ interface EnvVarServiceAsync { * Returns a raw HTTP response for `post /v1/env_var`, but is otherwise the same as * [EnvVarServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: EnvVarCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: EnvVarCreateParams, @@ -106,7 +127,11 @@ interface EnvVarServiceAsync { * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same * as [EnvVarServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: EnvVarRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: EnvVarRetrieveParams, @@ -117,7 +142,11 @@ interface EnvVarServiceAsync { * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the * same as [EnvVarServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: EnvVarUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: EnvVarUpdateParams, @@ -128,17 +157,25 @@ interface EnvVarServiceAsync { * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as * [EnvVarServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(EnvVarListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as - * [EnvVarServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: EnvVarListParams = EnvVarListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -149,7 +186,11 @@ interface EnvVarServiceAsync { * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the * same as [EnvVarServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: EnvVarDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: EnvVarDeleteParams, @@ -160,7 +201,11 @@ interface EnvVarServiceAsync { * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as * [EnvVarServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: EnvVarReplaceParams): CompletableFuture> = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: EnvVarReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt index 26b58d6f..69b6f45c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -25,7 +23,10 @@ interface EvalServiceAsync { * results along with a link to the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ - @JvmOverloads + fun create(params: EvalCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -38,7 +39,13 @@ interface EvalServiceAsync { * Returns a raw HTTP response for `post /v1/eval`, but is otherwise the same as * [EvalServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create( + params: EvalCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: EvalCreateParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index a4566fea..e10046e6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -36,14 +34,20 @@ interface ExperimentServiceAsync { * Create a new experiment. If there is an existing experiment in the project with the same name * as the one specified in the request, will return the existing experiment unmodified */ - @JvmOverloads + fun create(params: ExperimentCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get an experiment object by its id */ - @JvmOverloads + fun retrieve(params: ExperimentRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -54,7 +58,10 @@ interface ExperimentServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: ExperimentUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -64,28 +71,38 @@ interface ExperimentServiceAsync { * List out all experiments. The experiments are sorted by creation date, with the most * recently-created experiments coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(ExperimentListParams.none()) + + /** @see [list] */ fun list( params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first - */ + /** @see [list] */ + fun list( + params: ExperimentListParams = ExperimentListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(ExperimentListParams.none(), requestOptions) /** Delete an experiment object by its id */ - @JvmOverloads + fun delete(params: ExperimentDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Log feedback for a set of experiment events */ - @JvmOverloads + fun feedback(params: ExperimentFeedbackParams): CompletableFuture = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ fun feedback( params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -96,7 +113,10 @@ interface ExperimentServiceAsync { * parameters in the URL query rather than in the request body. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetch(params: ExperimentFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ fun fetch( params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -107,21 +127,32 @@ interface ExperimentServiceAsync { * parameters in the request body rather than in the URL query. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetchPost( + params: ExperimentFetchPostParams + ): CompletableFuture = fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ fun fetchPost( params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Insert a set of events into the experiment */ - @JvmOverloads + fun insert(params: ExperimentInsertParams): CompletableFuture = + insert(params, RequestOptions.none()) + + /** @see [insert] */ fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Summarize experiment */ - @JvmOverloads + fun summarize( + params: ExperimentSummarizeParams + ): CompletableFuture = summarize(params, RequestOptions.none()) + + /** @see [summarize] */ fun summarize( params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -137,7 +168,11 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as * [ExperimentServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ExperimentCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ExperimentCreateParams, @@ -148,7 +183,12 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise * the same as [ExperimentServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve( + params: ExperimentRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ExperimentRetrieveParams, @@ -159,7 +199,11 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise * the same as [ExperimentServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ExperimentUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ExperimentUpdateParams, @@ -170,17 +214,25 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as * [ExperimentServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(ExperimentListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as - * [ExperimentServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ExperimentListParams = ExperimentListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -191,7 +243,11 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise * the same as [ExperimentServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ExperimentDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ExperimentDeleteParams, @@ -202,7 +258,13 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is * otherwise the same as [ExperimentServiceAsync.feedback]. */ - @JvmOverloads + @MustBeClosed + fun feedback( + params: ExperimentFeedbackParams + ): CompletableFuture> = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ @MustBeClosed fun feedback( params: ExperimentFeedbackParams, @@ -213,7 +275,13 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is * otherwise the same as [ExperimentServiceAsync.fetch]. */ - @JvmOverloads + @MustBeClosed + fun fetch( + params: ExperimentFetchParams + ): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ @MustBeClosed fun fetch( params: ExperimentFetchParams, @@ -224,7 +292,13 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is * otherwise the same as [ExperimentServiceAsync.fetchPost]. */ - @JvmOverloads + @MustBeClosed + fun fetchPost( + params: ExperimentFetchPostParams + ): CompletableFuture> = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ @MustBeClosed fun fetchPost( params: ExperimentFetchPostParams, @@ -235,7 +309,13 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is * otherwise the same as [ExperimentServiceAsync.insert]. */ - @JvmOverloads + @MustBeClosed + fun insert( + params: ExperimentInsertParams + ): CompletableFuture> = + insert(params, RequestOptions.none()) + + /** @see [insert] */ @MustBeClosed fun insert( params: ExperimentInsertParams, @@ -246,7 +326,13 @@ interface ExperimentServiceAsync { * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is * otherwise the same as [ExperimentServiceAsync.summarize]. */ - @JvmOverloads + @MustBeClosed + fun summarize( + params: ExperimentSummarizeParams + ): CompletableFuture> = + summarize(params, RequestOptions.none()) + + /** @see [summarize] */ @MustBeClosed fun summarize( params: ExperimentSummarizeParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index 503ca793..b625969e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -31,14 +29,20 @@ interface FunctionServiceAsync { * Create a new function. If there is an existing function in the project with the same slug as * the one specified in the request, will return the existing function unmodified */ - @JvmOverloads + fun create(params: FunctionCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a function object by its id */ - @JvmOverloads + fun retrieve(params: FunctionRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -49,7 +53,10 @@ interface FunctionServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: FunctionUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -59,28 +66,38 @@ interface FunctionServiceAsync { * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(FunctionListParams.none()) + + /** @see [list] */ fun list( params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all functions. The functions are sorted by creation date, with the most - * recently-created functions coming first - */ + /** @see [list] */ + fun list( + params: FunctionListParams = FunctionListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(FunctionListParams.none(), requestOptions) /** Delete a function object by its id */ - @JvmOverloads + fun delete(params: FunctionDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Invoke a function. */ - @JvmOverloads + fun invoke(params: FunctionInvokeParams): CompletableFuture> = + invoke(params, RequestOptions.none()) + + /** @see [invoke] */ fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -91,7 +108,10 @@ interface FunctionServiceAsync { * slug as the one specified in the request, will replace the existing function with the * provided fields */ - @JvmOverloads + fun replace(params: FunctionReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -106,7 +126,11 @@ interface FunctionServiceAsync { * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as * [FunctionServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: FunctionCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: FunctionCreateParams, @@ -117,7 +141,11 @@ interface FunctionServiceAsync { * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the * same as [FunctionServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: FunctionRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: FunctionRetrieveParams, @@ -128,7 +156,11 @@ interface FunctionServiceAsync { * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the * same as [FunctionServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: FunctionUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: FunctionUpdateParams, @@ -139,17 +171,25 @@ interface FunctionServiceAsync { * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as * [FunctionServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(FunctionListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as - * [FunctionServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: FunctionListParams = FunctionListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -160,7 +200,11 @@ interface FunctionServiceAsync { * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the * same as [FunctionServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: FunctionDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: FunctionDeleteParams, @@ -171,7 +215,13 @@ interface FunctionServiceAsync { * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is * otherwise the same as [FunctionServiceAsync.invoke]. */ - @JvmOverloads + @MustBeClosed + fun invoke( + params: FunctionInvokeParams + ): CompletableFuture>> = + invoke(params, RequestOptions.none()) + + /** @see [invoke] */ @MustBeClosed fun invoke( params: FunctionInvokeParams, @@ -182,7 +232,11 @@ interface FunctionServiceAsync { * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as * [FunctionServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: FunctionReplaceParams): CompletableFuture> = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: FunctionReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index dbe777cc..9c172789 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,20 @@ interface GroupServiceAsync { * Create a new group. If there is an existing group with the same name as the one specified in * the request, will return the existing group unmodified */ - @JvmOverloads + fun create(params: GroupCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a group object by its id */ - @JvmOverloads + fun retrieve(params: GroupRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +50,10 @@ interface GroupServiceAsync { * fields will be deep-merged with existing content. Currently we do not support removing fields * or setting them to null. */ - @JvmOverloads + fun update(params: GroupUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,21 +63,28 @@ interface GroupServiceAsync { * List out all groups. The groups are sorted by creation date, with the most recently-created * groups coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(GroupListParams.none()) + + /** @see [list] */ fun list( params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first - */ + /** @see [list] */ + fun list( + params: GroupListParams = GroupListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(GroupListParams.none(), requestOptions) /** Delete a group object by its id */ - @JvmOverloads + fun delete(params: GroupDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -80,7 +94,10 @@ interface GroupServiceAsync { * Create or replace group. If there is an existing group with the same name as the one * specified in the request, will replace the existing group with the provided fields */ - @JvmOverloads + fun replace(params: GroupReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -93,7 +110,11 @@ interface GroupServiceAsync { * Returns a raw HTTP response for `post /v1/group`, but is otherwise the same as * [GroupServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: GroupCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: GroupCreateParams, @@ -104,7 +125,11 @@ interface GroupServiceAsync { * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as * [GroupServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: GroupRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: GroupRetrieveParams, @@ -115,7 +140,11 @@ interface GroupServiceAsync { * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same * as [GroupServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: GroupUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: GroupUpdateParams, @@ -126,17 +155,25 @@ interface GroupServiceAsync { * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as * [GroupServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(GroupListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as - * [GroupServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: GroupListParams = GroupListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -147,7 +184,11 @@ interface GroupServiceAsync { * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same * as [GroupServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: GroupDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: GroupDeleteParams, @@ -158,7 +199,11 @@ interface GroupServiceAsync { * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as * [GroupServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: GroupReplaceParams): CompletableFuture> = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: GroupReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index 7306e462..a224dbd9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -26,7 +24,10 @@ interface OrganizationServiceAsync { fun members(): MemberServiceAsync /** Get an organization object by its id */ - @JvmOverloads + fun retrieve(params: OrganizationRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -37,7 +38,10 @@ interface OrganizationServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: OrganizationUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -47,21 +51,28 @@ interface OrganizationServiceAsync { * List out all organizations. The organizations are sorted by creation date, with the most * recently-created organizations coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(OrganizationListParams.none()) + + /** @see [list] */ fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first - */ + /** @see [list] */ + fun list( + params: OrganizationListParams = OrganizationListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(OrganizationListParams.none(), requestOptions) /** Delete an organization object by its id */ - @JvmOverloads + fun delete(params: OrganizationDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -79,7 +90,13 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `get /v1/organization/{organization_id}`, but is * otherwise the same as [OrganizationServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve( + params: OrganizationRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: OrganizationRetrieveParams, @@ -90,7 +107,12 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is * otherwise the same as [OrganizationServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update( + params: OrganizationUpdateParams + ): CompletableFuture> = update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: OrganizationUpdateParams, @@ -101,17 +123,25 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as * [OrganizationServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(OrganizationListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as - * [OrganizationServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: OrganizationListParams = OrganizationListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -122,7 +152,12 @@ interface OrganizationServiceAsync { * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is * otherwise the same as [OrganizationServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete( + params: OrganizationDeleteParams + ): CompletableFuture> = delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: OrganizationDeleteParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index 45be3a4c..beca7a59 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -29,14 +27,20 @@ interface ProjectScoreServiceAsync { * same name as the one specified in the request, will return the existing project_score * unmodified */ - @JvmOverloads + fun create(params: ProjectScoreCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a project_score object by its id */ - @JvmOverloads + fun retrieve(params: ProjectScoreRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -47,7 +51,10 @@ interface ProjectScoreServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: ProjectScoreUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -57,21 +64,28 @@ interface ProjectScoreServiceAsync { * List out all project_scores. The project_scores are sorted by creation date, with the most * recently-created project_scores coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(ProjectScoreListParams.none()) + + /** @see [list] */ fun list( params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first - */ + /** @see [list] */ + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectScoreListParams.none(), requestOptions) /** Delete a project_score object by its id */ - @JvmOverloads + fun delete(params: ProjectScoreDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -82,7 +96,10 @@ interface ProjectScoreServiceAsync { * the same name as the one specified in the request, will replace the existing project_score * with the provided fields */ - @JvmOverloads + fun replace(params: ProjectScoreReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -98,7 +115,12 @@ interface ProjectScoreServiceAsync { * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as * [ProjectScoreServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create( + params: ProjectScoreCreateParams + ): CompletableFuture> = create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ProjectScoreCreateParams, @@ -109,7 +131,13 @@ interface ProjectScoreServiceAsync { * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is * otherwise the same as [ProjectScoreServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve( + params: ProjectScoreRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ProjectScoreRetrieveParams, @@ -120,7 +148,12 @@ interface ProjectScoreServiceAsync { * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is * otherwise the same as [ProjectScoreServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update( + params: ProjectScoreUpdateParams + ): CompletableFuture> = update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ProjectScoreUpdateParams, @@ -131,17 +164,25 @@ interface ProjectScoreServiceAsync { * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as * [ProjectScoreServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(ProjectScoreListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as - * [ProjectScoreServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -152,7 +193,12 @@ interface ProjectScoreServiceAsync { * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is * otherwise the same as [ProjectScoreServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete( + params: ProjectScoreDeleteParams + ): CompletableFuture> = delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ProjectScoreDeleteParams, @@ -163,7 +209,12 @@ interface ProjectScoreServiceAsync { * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as * [ProjectScoreServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace( + params: ProjectScoreReplaceParams + ): CompletableFuture> = replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: ProjectScoreReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index 33de4a97..c1c67326 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -30,14 +28,20 @@ interface ProjectServiceAsync { * Create a new project. If there is an existing project with the same name as the one specified * in the request, will return the existing project unmodified */ - @JvmOverloads + fun create(params: ProjectCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a project object by its id */ - @JvmOverloads + fun retrieve(params: ProjectRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -48,7 +52,10 @@ interface ProjectServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: ProjectUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -58,21 +65,28 @@ interface ProjectServiceAsync { * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(ProjectListParams.none()) + + /** @see [list] */ fun list( params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all projects. The projects are sorted by creation date, with the most - * recently-created projects coming first - */ + /** @see [list] */ + fun list( + params: ProjectListParams = ProjectListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectListParams.none(), requestOptions) /** Delete a project object by its id */ - @JvmOverloads + fun delete(params: ProjectDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -89,7 +103,11 @@ interface ProjectServiceAsync { * Returns a raw HTTP response for `post /v1/project`, but is otherwise the same as * [ProjectServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ProjectCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ProjectCreateParams, @@ -100,7 +118,11 @@ interface ProjectServiceAsync { * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same * as [ProjectServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ProjectRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ProjectRetrieveParams, @@ -111,7 +133,11 @@ interface ProjectServiceAsync { * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the * same as [ProjectServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ProjectUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ProjectUpdateParams, @@ -122,17 +148,25 @@ interface ProjectServiceAsync { * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as * [ProjectServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(ProjectListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as - * [ProjectServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectListParams = ProjectListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -143,7 +177,11 @@ interface ProjectServiceAsync { * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the * same as [ProjectServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ProjectDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ProjectDeleteParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index 487570f1..6d681309 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,20 @@ interface ProjectTagServiceAsync { * Create a new project_tag. If there is an existing project_tag in the project with the same * name as the one specified in the request, will return the existing project_tag unmodified */ - @JvmOverloads + fun create(params: ProjectTagCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a project_tag object by its id */ - @JvmOverloads + fun retrieve(params: ProjectTagRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +50,10 @@ interface ProjectTagServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: ProjectTagUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,21 +63,28 @@ interface ProjectTagServiceAsync { * List out all project_tags. The project_tags are sorted by creation date, with the most * recently-created project_tags coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(ProjectTagListParams.none()) + + /** @see [list] */ fun list( params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first - */ + /** @see [list] */ + fun list( + params: ProjectTagListParams = ProjectTagListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectTagListParams.none(), requestOptions) /** Delete a project_tag object by its id */ - @JvmOverloads + fun delete(params: ProjectTagDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -81,7 +95,10 @@ interface ProjectTagServiceAsync { * same name as the one specified in the request, will replace the existing project_tag with the * provided fields */ - @JvmOverloads + fun replace(params: ProjectTagReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -97,7 +114,11 @@ interface ProjectTagServiceAsync { * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as * [ProjectTagServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ProjectTagCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ProjectTagCreateParams, @@ -108,7 +129,12 @@ interface ProjectTagServiceAsync { * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise * the same as [ProjectTagServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve( + params: ProjectTagRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ProjectTagRetrieveParams, @@ -119,7 +145,11 @@ interface ProjectTagServiceAsync { * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is * otherwise the same as [ProjectTagServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ProjectTagUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ProjectTagUpdateParams, @@ -130,17 +160,25 @@ interface ProjectTagServiceAsync { * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as * [ProjectTagServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(ProjectTagListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as - * [ProjectTagServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectTagListParams = ProjectTagListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -151,7 +189,11 @@ interface ProjectTagServiceAsync { * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is * otherwise the same as [ProjectTagServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ProjectTagDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ProjectTagDeleteParams, @@ -162,7 +204,12 @@ interface ProjectTagServiceAsync { * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as * [ProjectTagServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace( + params: ProjectTagReplaceParams + ): CompletableFuture> = replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: ProjectTagReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index 7ccef6e9..afb7a900 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,20 @@ interface PromptServiceAsync { * Create a new prompt. If there is an existing prompt in the project with the same slug as the * one specified in the request, will return the existing prompt unmodified */ - @JvmOverloads + fun create(params: PromptCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a prompt object by its id */ - @JvmOverloads + fun retrieve(params: PromptRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +50,10 @@ interface PromptServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: PromptUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,21 +63,28 @@ interface PromptServiceAsync { * List out all prompts. The prompts are sorted by creation date, with the most recently-created * prompts coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(PromptListParams.none()) + + /** @see [list] */ fun list( params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first - */ + /** @see [list] */ + fun list( + params: PromptListParams = PromptListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(PromptListParams.none(), requestOptions) /** Delete a prompt object by its id */ - @JvmOverloads + fun delete(params: PromptDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -80,7 +94,10 @@ interface PromptServiceAsync { * Create or replace prompt. If there is an existing prompt in the project with the same slug as * the one specified in the request, will replace the existing prompt with the provided fields */ - @JvmOverloads + fun replace(params: PromptReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -95,7 +112,11 @@ interface PromptServiceAsync { * Returns a raw HTTP response for `post /v1/prompt`, but is otherwise the same as * [PromptServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: PromptCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: PromptCreateParams, @@ -106,7 +127,11 @@ interface PromptServiceAsync { * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same * as [PromptServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: PromptRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: PromptRetrieveParams, @@ -117,7 +142,11 @@ interface PromptServiceAsync { * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same * as [PromptServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: PromptUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: PromptUpdateParams, @@ -128,17 +157,25 @@ interface PromptServiceAsync { * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as * [PromptServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(PromptListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as - * [PromptServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: PromptListParams = PromptListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -149,7 +186,11 @@ interface PromptServiceAsync { * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the * same as [PromptServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: PromptDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: PromptDeleteParams, @@ -160,7 +201,11 @@ interface PromptServiceAsync { * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as * [PromptServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: PromptReplaceParams): CompletableFuture> = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: PromptReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index 7ed61a5e..988acc47 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,20 @@ interface RoleServiceAsync { * Create a new role. If there is an existing role with the same name as the one specified in * the request, will return the existing role unmodified */ - @JvmOverloads + fun create(params: RoleCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a role object by its id */ - @JvmOverloads + fun retrieve(params: RoleRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +50,10 @@ interface RoleServiceAsync { * fields will be deep-merged with existing content. Currently we do not support removing fields * or setting them to null. */ - @JvmOverloads + fun update(params: RoleUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,21 +63,27 @@ interface RoleServiceAsync { * List out all roles. The roles are sorted by creation date, with the most recently-created * roles coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(RoleListParams.none()) + + /** @see [list] */ fun list( params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all roles. The roles are sorted by creation date, with the most recently-created - * roles coming first - */ + /** @see [list] */ + fun list(params: RoleListParams = RoleListParams.none()): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(RoleListParams.none(), requestOptions) /** Delete a role object by its id */ - @JvmOverloads + fun delete(params: RoleDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -80,7 +93,10 @@ interface RoleServiceAsync { * Create or replace role. If there is an existing role with the same name as the one specified * in the request, will replace the existing role with the provided fields */ - @JvmOverloads + fun replace(params: RoleReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -93,7 +109,11 @@ interface RoleServiceAsync { * Returns a raw HTTP response for `post /v1/role`, but is otherwise the same as * [RoleServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: RoleCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: RoleCreateParams, @@ -104,7 +124,11 @@ interface RoleServiceAsync { * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as * [RoleServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: RoleRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: RoleRetrieveParams, @@ -115,7 +139,11 @@ interface RoleServiceAsync { * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as * [RoleServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: RoleUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: RoleUpdateParams, @@ -126,17 +154,25 @@ interface RoleServiceAsync { * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as * [RoleServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(RoleListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as - * [RoleServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: RoleListParams = RoleListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -147,7 +183,11 @@ interface RoleServiceAsync { * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as * [RoleServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: RoleDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: RoleDeleteParams, @@ -158,7 +198,11 @@ interface RoleServiceAsync { * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as * [RoleServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: RoleReplaceParams): CompletableFuture> = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: RoleReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt index d1d9f896..442357ea 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,20 @@ interface SpanIframeServiceAsync { * Create a new span_iframe. If there is an existing span_iframe with the same name as the one * specified in the request, will return the existing span_iframe unmodified */ - @JvmOverloads + fun create(params: SpanIframeCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a span_iframe object by its id */ - @JvmOverloads + fun retrieve(params: SpanIframeRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +50,10 @@ interface SpanIframeServiceAsync { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: SpanIframeUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,21 +63,28 @@ interface SpanIframeServiceAsync { * List out all span_iframes. The span_iframes are sorted by creation date, with the most * recently-created span_iframes coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(SpanIframeListParams.none()) + + /** @see [list] */ fun list( params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first - */ + /** @see [list] */ + fun list( + params: SpanIframeListParams = SpanIframeListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(SpanIframeListParams.none(), requestOptions) /** Delete a span_iframe object by its id */ - @JvmOverloads + fun delete(params: SpanIframeDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -80,7 +94,10 @@ interface SpanIframeServiceAsync { * Create or replace span_iframe. If there is an existing span_iframe with the same name as the * one specified in the request, will replace the existing span_iframe with the provided fields */ - @JvmOverloads + fun replace(params: SpanIframeReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -96,7 +113,11 @@ interface SpanIframeServiceAsync { * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as * [SpanIframeServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: SpanIframeCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: SpanIframeCreateParams, @@ -107,7 +128,12 @@ interface SpanIframeServiceAsync { * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise * the same as [SpanIframeServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve( + params: SpanIframeRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: SpanIframeRetrieveParams, @@ -118,7 +144,11 @@ interface SpanIframeServiceAsync { * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is * otherwise the same as [SpanIframeServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: SpanIframeUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: SpanIframeUpdateParams, @@ -129,17 +159,25 @@ interface SpanIframeServiceAsync { * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as * [SpanIframeServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(SpanIframeListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as - * [SpanIframeServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: SpanIframeListParams = SpanIframeListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions @@ -150,7 +188,11 @@ interface SpanIframeServiceAsync { * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is * otherwise the same as [SpanIframeServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: SpanIframeDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: SpanIframeDeleteParams, @@ -161,7 +203,12 @@ interface SpanIframeServiceAsync { * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as * [SpanIframeServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace( + params: SpanIframeReplaceParams + ): CompletableFuture> = replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: SpanIframeReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index 7e84352b..5411c270 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -18,13 +16,20 @@ interface TopLevelServiceAsync { fun withRawResponse(): WithRawResponse /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ - @JvmOverloads + fun helloWorld(): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none()) + + /** @see [helloWorld] */ fun helloWorld( params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + /** @see [helloWorld] */ + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() + ): CompletableFuture = helloWorld(params, RequestOptions.none()) + + /** @see [helloWorld] */ fun helloWorld(requestOptions: RequestOptions): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) @@ -37,17 +42,24 @@ interface TopLevelServiceAsync { * Returns a raw HTTP response for `get /v1`, but is otherwise the same as * [TopLevelServiceAsync.helloWorld]. */ - @JvmOverloads + @MustBeClosed + fun helloWorld(): CompletableFuture> = + helloWorld(TopLevelHelloWorldParams.none()) + + /** @see [helloWorld] */ @MustBeClosed fun helloWorld( params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1`, but is otherwise the same as - * [TopLevelServiceAsync.helloWorld]. - */ + /** @see [helloWorld] */ + @MustBeClosed + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() + ): CompletableFuture> = helloWorld(params, RequestOptions.none()) + + /** @see [helloWorld] */ @MustBeClosed fun helloWorld(requestOptions: RequestOptions): CompletableFuture> = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index 2da46b60..2bf974c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -21,7 +19,10 @@ interface UserServiceAsync { fun withRawResponse(): WithRawResponse /** Get a user object by its id */ - @JvmOverloads + fun retrieve(params: UserRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -31,16 +32,19 @@ interface UserServiceAsync { * List out all users. The users are sorted by creation date, with the most recently-created * users coming first */ - @JvmOverloads + fun list(): CompletableFuture = list(UserListParams.none()) + + /** @see [list] */ fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * List out all users. The users are sorted by creation date, with the most recently-created - * users coming first - */ + /** @see [list] */ + fun list(params: UserListParams = UserListParams.none()): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): CompletableFuture = list(UserListParams.none(), requestOptions) @@ -51,7 +55,11 @@ interface UserServiceAsync { * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as * [UserServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: UserRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: UserRetrieveParams, @@ -62,17 +70,25 @@ interface UserServiceAsync { * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as * [UserServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): CompletableFuture> = + list(UserListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as - * [UserServiceAsync.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: UserListParams = UserListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( requestOptions: RequestOptions diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index f3615339..f70248e9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,20 @@ interface ViewServiceAsync { * Create a new view. If there is an existing view with the same name as the one specified in * the request, will return the existing view unmodified */ - @JvmOverloads + fun create(params: ViewCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Get a view object by its id */ - @JvmOverloads + fun retrieve(params: ViewRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +50,10 @@ interface ViewServiceAsync { * fields will be deep-merged with existing content. Currently we do not support removing fields * or setting them to null. */ - @JvmOverloads + fun update(params: ViewUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,14 +63,20 @@ interface ViewServiceAsync { * List out all views. The views are sorted by creation date, with the most recently-created * views coming first */ - @JvmOverloads + fun list(params: ViewListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete a view object by its id */ - @JvmOverloads + fun delete(params: ViewDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -73,7 +86,10 @@ interface ViewServiceAsync { * Create or replace view. If there is an existing view with the same name as the one specified * in the request, will replace the existing view with the provided fields */ - @JvmOverloads + fun replace(params: ViewReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -86,7 +102,11 @@ interface ViewServiceAsync { * Returns a raw HTTP response for `post /v1/view`, but is otherwise the same as * [ViewServiceAsync.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ViewCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ViewCreateParams, @@ -97,7 +117,11 @@ interface ViewServiceAsync { * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as * [ViewServiceAsync.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ViewRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ViewRetrieveParams, @@ -108,7 +132,11 @@ interface ViewServiceAsync { * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as * [ViewServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ViewUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ViewUpdateParams, @@ -119,7 +147,11 @@ interface ViewServiceAsync { * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as * [ViewServiceAsync.list]. */ - @JvmOverloads + @MustBeClosed + fun list(params: ViewListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ViewListParams, @@ -130,7 +162,11 @@ interface ViewServiceAsync { * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as * [ViewServiceAsync.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ViewDeleteParams): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ViewDeleteParams, @@ -141,7 +177,11 @@ interface ViewServiceAsync { * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as * [ViewServiceAsync.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: ViewReplaceParams): CompletableFuture> = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: ViewReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt index cf80d652..78042415 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async.organizations import com.braintrustdata.api.core.RequestOptions @@ -19,13 +17,21 @@ interface MemberServiceAsync { fun withRawResponse(): WithRawResponse /** Modify organization membership */ - @JvmOverloads + fun update(): CompletableFuture = + update(OrganizationMemberUpdateParams.none()) + + /** @see [update] */ fun update( params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Modify organization membership */ + /** @see [update] */ + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() + ): CompletableFuture = update(params, RequestOptions.none()) + + /** @see [update] */ fun update(requestOptions: RequestOptions): CompletableFuture = update(OrganizationMemberUpdateParams.none(), requestOptions) @@ -38,17 +44,25 @@ interface MemberServiceAsync { * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the * same as [MemberServiceAsync.update]. */ - @JvmOverloads + @MustBeClosed + fun update(): CompletableFuture> = + update(OrganizationMemberUpdateParams.none()) + + /** @see [update] */ @MustBeClosed fun update( params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the - * same as [MemberServiceAsync.update]. - */ + /** @see [update] */ + @MustBeClosed + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( requestOptions: RequestOptions diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index 6d9e1663..b1d19e58 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.async.projects import com.braintrustdata.api.core.RequestOptions @@ -24,7 +22,10 @@ interface LogServiceAsync { fun withRawResponse(): WithRawResponse /** Log feedback for a set of project logs events */ - @JvmOverloads + fun feedback(params: ProjectLogFeedbackParams): CompletableFuture = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ fun feedback( params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -35,7 +36,10 @@ interface LogServiceAsync { * the parameters in the URL query rather than in the request body. For more complex queries, * use the `POST /btql` endpoint. */ - @JvmOverloads + fun fetch(params: ProjectLogFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ fun fetch( params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,14 +50,21 @@ interface LogServiceAsync { * parameters in the request body rather than in the URL query. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetchPost( + params: ProjectLogFetchPostParams + ): CompletableFuture = fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ fun fetchPost( params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Insert a set of events into the project logs */ - @JvmOverloads + fun insert(params: ProjectLogInsertParams): CompletableFuture = + insert(params, RequestOptions.none()) + + /** @see [insert] */ fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -66,7 +77,13 @@ interface LogServiceAsync { * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is * otherwise the same as [LogServiceAsync.feedback]. */ - @JvmOverloads + @MustBeClosed + fun feedback( + params: ProjectLogFeedbackParams + ): CompletableFuture> = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ @MustBeClosed fun feedback( params: ProjectLogFeedbackParams, @@ -77,7 +94,13 @@ interface LogServiceAsync { * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is * otherwise the same as [LogServiceAsync.fetch]. */ - @JvmOverloads + @MustBeClosed + fun fetch( + params: ProjectLogFetchParams + ): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ @MustBeClosed fun fetch( params: ProjectLogFetchParams, @@ -88,7 +111,13 @@ interface LogServiceAsync { * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is * otherwise the same as [LogServiceAsync.fetchPost]. */ - @JvmOverloads + @MustBeClosed + fun fetchPost( + params: ProjectLogFetchPostParams + ): CompletableFuture> = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ @MustBeClosed fun fetchPost( params: ProjectLogFetchPostParams, @@ -99,7 +128,13 @@ interface LogServiceAsync { * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is * otherwise the same as [LogServiceAsync.insert]. */ - @JvmOverloads + @MustBeClosed + fun insert( + params: ProjectLogInsertParams + ): CompletableFuture> = + insert(params, RequestOptions.none()) + + /** @see [insert] */ @MustBeClosed fun insert( params: ProjectLogInsertParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index 5d570404..5d4a4de6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -28,11 +26,15 @@ interface AclService { * Create a new acl. If there is an existing acl with the same contents as the one specified in * the request, will return the existing acl unmodified */ - @JvmOverloads + fun create(params: AclCreateParams): Acl = create(params, RequestOptions.none()) + + /** @see [create] */ fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** Get an acl object by its id */ - @JvmOverloads + fun retrieve(params: AclRetrieveParams): Acl = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -42,35 +44,46 @@ interface AclService { * List out all acls. The acls are sorted by creation date, with the most recently-created acls * coming first */ - @JvmOverloads + fun list(params: AclListParams): AclListPage = list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: AclListParams, requestOptions: RequestOptions = RequestOptions.none(), ): AclListPage /** Delete an acl object by its id */ - @JvmOverloads + fun delete(params: AclDeleteParams): Acl = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** * Batch update acls. This operation is idempotent, so adding acls which already exist will have * no effect, and removing acls which do not exist will have no effect. */ - @JvmOverloads + fun batchUpdate(): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none()) + + /** @see [batchUpdate] */ fun batchUpdate( params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AclBatchUpdateResponse - /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. - */ + /** @see [batchUpdate] */ + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): AclBatchUpdateResponse = batchUpdate(params, RequestOptions.none()) + + /** @see [batchUpdate] */ fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** Delete a single acl */ - @JvmOverloads + fun findAndDelete(params: AclFindAndDeleteParams): Acl = + findAndDelete(params, RequestOptions.none()) + + /** @see [findAndDelete] */ fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -83,7 +96,11 @@ interface AclService { * Returns a raw HTTP response for `post /v1/acl`, but is otherwise the same as * [AclService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: AclCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: AclCreateParams, @@ -94,7 +111,11 @@ interface AclService { * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as * [AclService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: AclRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: AclRetrieveParams, @@ -105,7 +126,11 @@ interface AclService { * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as * [AclService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(params: AclListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( params: AclListParams, @@ -116,7 +141,11 @@ interface AclService { * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as * [AclService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: AclDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: AclDeleteParams, @@ -127,17 +156,24 @@ interface AclService { * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as * [AclService.batchUpdate]. */ - @JvmOverloads + @MustBeClosed + fun batchUpdate(): HttpResponseFor = + batchUpdate(AclBatchUpdateParams.none()) + + /** @see [batchUpdate] */ @MustBeClosed fun batchUpdate( params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclService.batchUpdate]. - */ + /** @see [batchUpdate] */ + @MustBeClosed + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): HttpResponseFor = batchUpdate(params, RequestOptions.none()) + + /** @see [batchUpdate] */ @MustBeClosed fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = batchUpdate(AclBatchUpdateParams.none(), requestOptions) @@ -146,7 +182,11 @@ interface AclService { * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as * [AclService.findAndDelete]. */ - @JvmOverloads + @MustBeClosed + fun findAndDelete(params: AclFindAndDeleteParams): HttpResponseFor = + findAndDelete(params, RequestOptions.none()) + + /** @see [findAndDelete] */ @MustBeClosed fun findAndDelete( params: AclFindAndDeleteParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt index d49fd448..867aab8c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,18 @@ interface AiSecretService { * Create a new ai_secret. If there is an existing ai_secret with the same name as the one * specified in the request, will return the existing ai_secret unmodified */ - @JvmOverloads + fun create(params: AiSecretCreateParams): AISecret = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): AISecret /** Get an ai_secret object by its id */ - @JvmOverloads + fun retrieve(params: AiSecretRetrieveParams): AISecret = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +48,9 @@ interface AiSecretService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: AiSecretUpdateParams): AISecret = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,28 +60,36 @@ interface AiSecretService { * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most * recently-created ai_secrets coming first */ - @JvmOverloads + fun list(): AiSecretListPage = list(AiSecretListParams.none()) + + /** @see [list] */ fun list( params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): AiSecretListPage - /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first - */ + /** @see [list] */ + fun list(params: AiSecretListParams = AiSecretListParams.none()): AiSecretListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): AiSecretListPage = list(AiSecretListParams.none(), requestOptions) /** Delete an ai_secret object by its id */ - @JvmOverloads + fun delete(params: AiSecretDeleteParams): AISecret = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): AISecret /** Delete a single ai_secret */ - @JvmOverloads + fun findAndDelete(params: AiSecretFindAndDeleteParams): AISecret = + findAndDelete(params, RequestOptions.none()) + + /** @see [findAndDelete] */ fun findAndDelete( params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -87,7 +99,9 @@ interface AiSecretService { * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one * specified in the request, will replace the existing ai_secret with the provided fields */ - @JvmOverloads + fun replace(params: AiSecretReplaceParams): AISecret = replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -100,7 +114,11 @@ interface AiSecretService { * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as * [AiSecretService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: AiSecretCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: AiSecretCreateParams, @@ -111,7 +129,11 @@ interface AiSecretService { * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the * same as [AiSecretService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: AiSecretRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: AiSecretRetrieveParams, @@ -122,7 +144,11 @@ interface AiSecretService { * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise * the same as [AiSecretService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: AiSecretUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: AiSecretUpdateParams, @@ -133,17 +159,23 @@ interface AiSecretService { * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as * [AiSecretService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): HttpResponseFor = list(AiSecretListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: AiSecretListParams = AiSecretListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(AiSecretListParams.none(), requestOptions) @@ -152,7 +184,11 @@ interface AiSecretService { * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise * the same as [AiSecretService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: AiSecretDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: AiSecretDeleteParams, @@ -163,7 +199,11 @@ interface AiSecretService { * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as * [AiSecretService.findAndDelete]. */ - @JvmOverloads + @MustBeClosed + fun findAndDelete(params: AiSecretFindAndDeleteParams): HttpResponseFor = + findAndDelete(params, RequestOptions.none()) + + /** @see [findAndDelete] */ @MustBeClosed fun findAndDelete( params: AiSecretFindAndDeleteParams, @@ -174,7 +214,11 @@ interface AiSecretService { * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as * [AiSecretService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: AiSecretReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: AiSecretReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index b7bbe672..7f07d4a8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -26,14 +24,19 @@ interface ApiKeyService { * Create a new api_key. It is possible to have multiple API keys with the same name. There is * no de-duplication */ - @JvmOverloads + fun create(params: ApiKeyCreateParams): CreateApiKeyOutput = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CreateApiKeyOutput /** Get an api_key object by its id */ - @JvmOverloads + fun retrieve(params: ApiKeyRetrieveParams): ApiKey = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -43,21 +46,26 @@ interface ApiKeyService { * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ - @JvmOverloads + fun list(): ApiKeyListPage = list(ApiKeyListParams.none()) + + /** @see [list] */ fun list( params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ApiKeyListPage - /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first - */ + /** @see [list] */ + fun list(params: ApiKeyListParams = ApiKeyListParams.none()): ApiKeyListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): ApiKeyListPage = list(ApiKeyListParams.none(), requestOptions) /** Delete an api_key object by its id */ - @JvmOverloads + fun delete(params: ApiKeyDeleteParams): ApiKey = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -70,7 +78,11 @@ interface ApiKeyService { * Returns a raw HTTP response for `post /v1/api_key`, but is otherwise the same as * [ApiKeyService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ApiKeyCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ApiKeyCreateParams, @@ -81,7 +93,11 @@ interface ApiKeyService { * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same * as [ApiKeyService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ApiKeyRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ApiKeyRetrieveParams, @@ -92,17 +108,22 @@ interface ApiKeyService { * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as * [ApiKeyService.list]. */ - @JvmOverloads + @MustBeClosed fun list(): HttpResponseFor = list(ApiKeyListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as - * [ApiKeyService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ApiKeyListParams = ApiKeyListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(ApiKeyListParams.none(), requestOptions) @@ -111,7 +132,11 @@ interface ApiKeyService { * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the * same as [ApiKeyService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ApiKeyDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ApiKeyDeleteParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index da17f213..91a18478 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -35,14 +33,18 @@ interface DatasetService { * Create a new dataset. If there is an existing dataset in the project with the same name as * the one specified in the request, will return the existing dataset unmodified */ - @JvmOverloads + fun create(params: DatasetCreateParams): Dataset = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): Dataset /** Get a dataset object by its id */ - @JvmOverloads + fun retrieve(params: DatasetRetrieveParams): Dataset = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -53,7 +55,9 @@ interface DatasetService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: DatasetUpdateParams): Dataset = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -63,28 +67,36 @@ interface DatasetService { * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ - @JvmOverloads + fun list(): DatasetListPage = list(DatasetListParams.none()) + + /** @see [list] */ fun list( params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): DatasetListPage - /** - * List out all datasets. The datasets are sorted by creation date, with the most - * recently-created datasets coming first - */ + /** @see [list] */ + fun list(params: DatasetListParams = DatasetListParams.none()): DatasetListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): DatasetListPage = list(DatasetListParams.none(), requestOptions) /** Delete a dataset object by its id */ - @JvmOverloads + fun delete(params: DatasetDeleteParams): Dataset = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): Dataset /** Log feedback for a set of dataset events */ - @JvmOverloads + fun feedback(params: DatasetFeedbackParams): FeedbackResponseSchema = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ fun feedback( params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -95,7 +107,10 @@ interface DatasetService { * parameters in the URL query rather than in the request body. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetch(params: DatasetFetchParams): FetchDatasetEventsResponse = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ fun fetch( params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -106,21 +121,30 @@ interface DatasetService { * parameters in the request body rather than in the URL query. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetchPost(params: DatasetFetchPostParams): FetchDatasetEventsResponse = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ fun fetchPost( params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none(), ): FetchDatasetEventsResponse /** Insert a set of events into the dataset */ - @JvmOverloads + fun insert(params: DatasetInsertParams): InsertEventsResponse = + insert(params, RequestOptions.none()) + + /** @see [insert] */ fun insert( params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none(), ): InsertEventsResponse /** Summarize dataset */ - @JvmOverloads + fun summarize(params: DatasetSummarizeParams): SummarizeDatasetResponse = + summarize(params, RequestOptions.none()) + + /** @see [summarize] */ fun summarize( params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -133,7 +157,11 @@ interface DatasetService { * Returns a raw HTTP response for `post /v1/dataset`, but is otherwise the same as * [DatasetService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: DatasetCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: DatasetCreateParams, @@ -144,7 +172,11 @@ interface DatasetService { * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same * as [DatasetService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: DatasetRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: DatasetRetrieveParams, @@ -155,7 +187,11 @@ interface DatasetService { * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the * same as [DatasetService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: DatasetUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: DatasetUpdateParams, @@ -166,17 +202,22 @@ interface DatasetService { * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as * [DatasetService.list]. */ - @JvmOverloads + @MustBeClosed fun list(): HttpResponseFor = list(DatasetListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as - * [DatasetService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: DatasetListParams = DatasetListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(DatasetListParams.none(), requestOptions) @@ -185,7 +226,11 @@ interface DatasetService { * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the * same as [DatasetService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: DatasetDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: DatasetDeleteParams, @@ -196,7 +241,11 @@ interface DatasetService { * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is * otherwise the same as [DatasetService.feedback]. */ - @JvmOverloads + @MustBeClosed + fun feedback(params: DatasetFeedbackParams): HttpResponseFor = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ @MustBeClosed fun feedback( params: DatasetFeedbackParams, @@ -207,7 +256,11 @@ interface DatasetService { * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise * the same as [DatasetService.fetch]. */ - @JvmOverloads + @MustBeClosed + fun fetch(params: DatasetFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ @MustBeClosed fun fetch( params: DatasetFetchParams, @@ -218,7 +271,11 @@ interface DatasetService { * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise * the same as [DatasetService.fetchPost]. */ - @JvmOverloads + @MustBeClosed + fun fetchPost(params: DatasetFetchPostParams): HttpResponseFor = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ @MustBeClosed fun fetchPost( params: DatasetFetchPostParams, @@ -229,7 +286,11 @@ interface DatasetService { * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise * the same as [DatasetService.insert]. */ - @JvmOverloads + @MustBeClosed + fun insert(params: DatasetInsertParams): HttpResponseFor = + insert(params, RequestOptions.none()) + + /** @see [insert] */ @MustBeClosed fun insert( params: DatasetInsertParams, @@ -240,7 +301,11 @@ interface DatasetService { * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is * otherwise the same as [DatasetService.summarize]. */ - @JvmOverloads + @MustBeClosed + fun summarize(params: DatasetSummarizeParams): HttpResponseFor = + summarize(params, RequestOptions.none()) + + /** @see [summarize] */ @MustBeClosed fun summarize( params: DatasetSummarizeParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt index 8f8610be..843a4762 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -27,14 +25,18 @@ interface EnvVarService { * Create a new env_var. If there is an existing env_var with the same name as the one specified * in the request, will return the existing env_var unmodified */ - @JvmOverloads + fun create(params: EnvVarCreateParams): EnvVar = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): EnvVar /** Get an env_var object by its id */ - @JvmOverloads + fun retrieve(params: EnvVarRetrieveParams): EnvVar = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -45,7 +47,9 @@ interface EnvVarService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: EnvVarUpdateParams): EnvVar = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -55,21 +59,26 @@ interface EnvVarService { * List out all env_vars. The env_vars are sorted by creation date, with the most * recently-created env_vars coming first */ - @JvmOverloads + fun list(): EnvVarListResponse = list(EnvVarListParams.none()) + + /** @see [list] */ fun list( params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): EnvVarListResponse - /** - * List out all env_vars. The env_vars are sorted by creation date, with the most - * recently-created env_vars coming first - */ + /** @see [list] */ + fun list(params: EnvVarListParams = EnvVarListParams.none()): EnvVarListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): EnvVarListResponse = list(EnvVarListParams.none(), requestOptions) /** Delete an env_var object by its id */ - @JvmOverloads + fun delete(params: EnvVarDeleteParams): EnvVar = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -79,7 +88,9 @@ interface EnvVarService { * Create or replace env_var. If there is an existing env_var with the same name as the one * specified in the request, will replace the existing env_var with the provided fields */ - @JvmOverloads + fun replace(params: EnvVarReplaceParams): EnvVar = replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -92,7 +103,11 @@ interface EnvVarService { * Returns a raw HTTP response for `post /v1/env_var`, but is otherwise the same as * [EnvVarService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: EnvVarCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: EnvVarCreateParams, @@ -103,7 +118,11 @@ interface EnvVarService { * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same * as [EnvVarService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: EnvVarRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: EnvVarRetrieveParams, @@ -114,7 +133,11 @@ interface EnvVarService { * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the * same as [EnvVarService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: EnvVarUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: EnvVarUpdateParams, @@ -125,17 +148,23 @@ interface EnvVarService { * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as * [EnvVarService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): HttpResponseFor = list(EnvVarListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as - * [EnvVarService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: EnvVarListParams = EnvVarListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(EnvVarListParams.none(), requestOptions) @@ -144,7 +173,11 @@ interface EnvVarService { * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the * same as [EnvVarService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: EnvVarDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: EnvVarDeleteParams, @@ -155,7 +188,11 @@ interface EnvVarService { * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as * [EnvVarService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: EnvVarReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: EnvVarReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt index 3941bf02..fa1bcc99 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -24,7 +22,10 @@ interface EvalService { * results along with a link to the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ - @JvmOverloads + fun create(params: EvalCreateParams): SummarizeExperimentResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -37,7 +38,11 @@ interface EvalService { * Returns a raw HTTP response for `post /v1/eval`, but is otherwise the same as * [EvalService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: EvalCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: EvalCreateParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index c3231496..17bc351f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -35,14 +33,19 @@ interface ExperimentService { * Create a new experiment. If there is an existing experiment in the project with the same name * as the one specified in the request, will return the existing experiment unmodified */ - @JvmOverloads + fun create(params: ExperimentCreateParams): Experiment = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): Experiment /** Get an experiment object by its id */ - @JvmOverloads + fun retrieve(params: ExperimentRetrieveParams): Experiment = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -53,7 +56,9 @@ interface ExperimentService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: ExperimentUpdateParams): Experiment = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -63,28 +68,36 @@ interface ExperimentService { * List out all experiments. The experiments are sorted by creation date, with the most * recently-created experiments coming first */ - @JvmOverloads + fun list(): ExperimentListPage = list(ExperimentListParams.none()) + + /** @see [list] */ fun list( params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ExperimentListPage - /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first - */ + /** @see [list] */ + fun list(params: ExperimentListParams = ExperimentListParams.none()): ExperimentListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): ExperimentListPage = list(ExperimentListParams.none(), requestOptions) /** Delete an experiment object by its id */ - @JvmOverloads + fun delete(params: ExperimentDeleteParams): Experiment = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): Experiment /** Log feedback for a set of experiment events */ - @JvmOverloads + fun feedback(params: ExperimentFeedbackParams): FeedbackResponseSchema = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ fun feedback( params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -95,7 +108,10 @@ interface ExperimentService { * parameters in the URL query rather than in the request body. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetch(params: ExperimentFetchParams): FetchExperimentEventsResponse = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ fun fetch( params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -106,21 +122,30 @@ interface ExperimentService { * parameters in the request body rather than in the URL query. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetchPost(params: ExperimentFetchPostParams): FetchExperimentEventsResponse = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ fun fetchPost( params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none(), ): FetchExperimentEventsResponse /** Insert a set of events into the experiment */ - @JvmOverloads + fun insert(params: ExperimentInsertParams): InsertEventsResponse = + insert(params, RequestOptions.none()) + + /** @see [insert] */ fun insert( params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none(), ): InsertEventsResponse /** Summarize experiment */ - @JvmOverloads + fun summarize(params: ExperimentSummarizeParams): SummarizeExperimentResponse = + summarize(params, RequestOptions.none()) + + /** @see [summarize] */ fun summarize( params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -133,7 +158,11 @@ interface ExperimentService { * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as * [ExperimentService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ExperimentCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ExperimentCreateParams, @@ -144,7 +173,11 @@ interface ExperimentService { * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise * the same as [ExperimentService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ExperimentRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ExperimentRetrieveParams, @@ -155,7 +188,11 @@ interface ExperimentService { * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise * the same as [ExperimentService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ExperimentUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ExperimentUpdateParams, @@ -166,17 +203,23 @@ interface ExperimentService { * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as * [ExperimentService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): HttpResponseFor = list(ExperimentListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as - * [ExperimentService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ExperimentListParams = ExperimentListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(ExperimentListParams.none(), requestOptions) @@ -185,7 +228,11 @@ interface ExperimentService { * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise * the same as [ExperimentService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ExperimentDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ExperimentDeleteParams, @@ -196,7 +243,11 @@ interface ExperimentService { * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is * otherwise the same as [ExperimentService.feedback]. */ - @JvmOverloads + @MustBeClosed + fun feedback(params: ExperimentFeedbackParams): HttpResponseFor = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ @MustBeClosed fun feedback( params: ExperimentFeedbackParams, @@ -207,7 +258,11 @@ interface ExperimentService { * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is * otherwise the same as [ExperimentService.fetch]. */ - @JvmOverloads + @MustBeClosed + fun fetch(params: ExperimentFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ @MustBeClosed fun fetch( params: ExperimentFetchParams, @@ -218,7 +273,12 @@ interface ExperimentService { * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is * otherwise the same as [ExperimentService.fetchPost]. */ - @JvmOverloads + @MustBeClosed + fun fetchPost( + params: ExperimentFetchPostParams + ): HttpResponseFor = fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ @MustBeClosed fun fetchPost( params: ExperimentFetchPostParams, @@ -229,7 +289,11 @@ interface ExperimentService { * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is * otherwise the same as [ExperimentService.insert]. */ - @JvmOverloads + @MustBeClosed + fun insert(params: ExperimentInsertParams): HttpResponseFor = + insert(params, RequestOptions.none()) + + /** @see [insert] */ @MustBeClosed fun insert( params: ExperimentInsertParams, @@ -240,7 +304,12 @@ interface ExperimentService { * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is * otherwise the same as [ExperimentService.summarize]. */ - @JvmOverloads + @MustBeClosed + fun summarize( + params: ExperimentSummarizeParams + ): HttpResponseFor = summarize(params, RequestOptions.none()) + + /** @see [summarize] */ @MustBeClosed fun summarize( params: ExperimentSummarizeParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index c39c68c2..2002b104 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -30,14 +28,18 @@ interface FunctionService { * Create a new function. If there is an existing function in the project with the same slug as * the one specified in the request, will return the existing function unmodified */ - @JvmOverloads + fun create(params: FunctionCreateParams): Function = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): Function /** Get a function object by its id */ - @JvmOverloads + fun retrieve(params: FunctionRetrieveParams): Function = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -48,7 +50,9 @@ interface FunctionService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: FunctionUpdateParams): Function = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -58,28 +62,36 @@ interface FunctionService { * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ - @JvmOverloads + fun list(): FunctionListPage = list(FunctionListParams.none()) + + /** @see [list] */ fun list( params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): FunctionListPage - /** - * List out all functions. The functions are sorted by creation date, with the most - * recently-created functions coming first - */ + /** @see [list] */ + fun list(params: FunctionListParams = FunctionListParams.none()): FunctionListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): FunctionListPage = list(FunctionListParams.none(), requestOptions) /** Delete a function object by its id */ - @JvmOverloads + fun delete(params: FunctionDeleteParams): Function = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): Function /** Invoke a function. */ - @JvmOverloads + fun invoke(params: FunctionInvokeParams): Optional = + invoke(params, RequestOptions.none()) + + /** @see [invoke] */ fun invoke( params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -90,7 +102,9 @@ interface FunctionService { * slug as the one specified in the request, will replace the existing function with the * provided fields */ - @JvmOverloads + fun replace(params: FunctionReplaceParams): Function = replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -103,7 +117,11 @@ interface FunctionService { * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as * [FunctionService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: FunctionCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: FunctionCreateParams, @@ -114,7 +132,11 @@ interface FunctionService { * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the * same as [FunctionService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: FunctionRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: FunctionRetrieveParams, @@ -125,7 +147,11 @@ interface FunctionService { * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the * same as [FunctionService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: FunctionUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: FunctionUpdateParams, @@ -136,17 +162,23 @@ interface FunctionService { * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as * [FunctionService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): HttpResponseFor = list(FunctionListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as - * [FunctionService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: FunctionListParams = FunctionListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(FunctionListParams.none(), requestOptions) @@ -155,7 +187,11 @@ interface FunctionService { * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the * same as [FunctionService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: FunctionDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: FunctionDeleteParams, @@ -166,7 +202,12 @@ interface FunctionService { * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is * otherwise the same as [FunctionService.invoke]. */ - @JvmOverloads + @MustBeClosed + fun invoke( + params: FunctionInvokeParams + ): HttpResponseFor> = invoke(params, RequestOptions.none()) + + /** @see [invoke] */ @MustBeClosed fun invoke( params: FunctionInvokeParams, @@ -177,7 +218,11 @@ interface FunctionService { * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as * [FunctionService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: FunctionReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: FunctionReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index ab46545e..5249cbc6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -27,14 +25,18 @@ interface GroupService { * Create a new group. If there is an existing group with the same name as the one specified in * the request, will return the existing group unmodified */ - @JvmOverloads + fun create(params: GroupCreateParams): Group = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): Group /** Get a group object by its id */ - @JvmOverloads + fun retrieve(params: GroupRetrieveParams): Group = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -45,7 +47,9 @@ interface GroupService { * fields will be deep-merged with existing content. Currently we do not support removing fields * or setting them to null. */ - @JvmOverloads + fun update(params: GroupUpdateParams): Group = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -55,21 +59,26 @@ interface GroupService { * List out all groups. The groups are sorted by creation date, with the most recently-created * groups coming first */ - @JvmOverloads + fun list(): GroupListPage = list(GroupListParams.none()) + + /** @see [list] */ fun list( params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): GroupListPage - /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first - */ + /** @see [list] */ + fun list(params: GroupListParams = GroupListParams.none()): GroupListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): GroupListPage = list(GroupListParams.none(), requestOptions) /** Delete a group object by its id */ - @JvmOverloads + fun delete(params: GroupDeleteParams): Group = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -79,7 +88,9 @@ interface GroupService { * Create or replace group. If there is an existing group with the same name as the one * specified in the request, will replace the existing group with the provided fields */ - @JvmOverloads + fun replace(params: GroupReplaceParams): Group = replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -92,7 +103,11 @@ interface GroupService { * Returns a raw HTTP response for `post /v1/group`, but is otherwise the same as * [GroupService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: GroupCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: GroupCreateParams, @@ -103,7 +118,11 @@ interface GroupService { * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as * [GroupService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: GroupRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: GroupRetrieveParams, @@ -114,7 +133,11 @@ interface GroupService { * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same * as [GroupService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: GroupUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: GroupUpdateParams, @@ -125,17 +148,21 @@ interface GroupService { * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as * [GroupService.list]. */ - @JvmOverloads + @MustBeClosed fun list(): HttpResponseFor = list(GroupListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as - * [GroupService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list(params: GroupListParams = GroupListParams.none()): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(GroupListParams.none(), requestOptions) @@ -144,7 +171,11 @@ interface GroupService { * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same * as [GroupService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: GroupDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: GroupDeleteParams, @@ -155,7 +186,11 @@ interface GroupService { * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as * [GroupService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: GroupReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: GroupReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index 4020d4c3..b2ddae2c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -25,7 +23,10 @@ interface OrganizationService { fun members(): MemberService /** Get an organization object by its id */ - @JvmOverloads + fun retrieve(params: OrganizationRetrieveParams): Organization = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -36,7 +37,10 @@ interface OrganizationService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: OrganizationUpdateParams): Organization = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,21 +50,27 @@ interface OrganizationService { * List out all organizations. The organizations are sorted by creation date, with the most * recently-created organizations coming first */ - @JvmOverloads + fun list(): OrganizationListPage = list(OrganizationListParams.none()) + + /** @see [list] */ fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): OrganizationListPage - /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first - */ + /** @see [list] */ + fun list(params: OrganizationListParams = OrganizationListParams.none()): OrganizationListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): OrganizationListPage = list(OrganizationListParams.none(), requestOptions) /** Delete an organization object by its id */ - @JvmOverloads + fun delete(params: OrganizationDeleteParams): Organization = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -77,7 +87,11 @@ interface OrganizationService { * Returns a raw HTTP response for `get /v1/organization/{organization_id}`, but is * otherwise the same as [OrganizationService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: OrganizationRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: OrganizationRetrieveParams, @@ -88,7 +102,11 @@ interface OrganizationService { * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is * otherwise the same as [OrganizationService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: OrganizationUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: OrganizationUpdateParams, @@ -99,17 +117,23 @@ interface OrganizationService { * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as * [OrganizationService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): HttpResponseFor = list(OrganizationListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as - * [OrganizationService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: OrganizationListParams = OrganizationListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(OrganizationListParams.none(), requestOptions) @@ -118,7 +142,11 @@ interface OrganizationService { * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is * otherwise the same as [OrganizationService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: OrganizationDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: OrganizationDeleteParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index 72a97f3e..5f9df9bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -28,14 +26,20 @@ interface ProjectScoreService { * same name as the one specified in the request, will return the existing project_score * unmodified */ - @JvmOverloads + fun create(params: ProjectScoreCreateParams): ProjectScore = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScore /** Get a project_score object by its id */ - @JvmOverloads + fun retrieve(params: ProjectScoreRetrieveParams): ProjectScore = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -46,7 +50,10 @@ interface ProjectScoreService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: ProjectScoreUpdateParams): ProjectScore = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -56,21 +63,27 @@ interface ProjectScoreService { * List out all project_scores. The project_scores are sorted by creation date, with the most * recently-created project_scores coming first */ - @JvmOverloads + fun list(): ProjectScoreListPage = list(ProjectScoreListParams.none()) + + /** @see [list] */ fun list( params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ProjectScoreListPage - /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first - */ + /** @see [list] */ + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): ProjectScoreListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): ProjectScoreListPage = list(ProjectScoreListParams.none(), requestOptions) /** Delete a project_score object by its id */ - @JvmOverloads + fun delete(params: ProjectScoreDeleteParams): ProjectScore = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -81,7 +94,10 @@ interface ProjectScoreService { * the same name as the one specified in the request, will replace the existing project_score * with the provided fields */ - @JvmOverloads + fun replace(params: ProjectScoreReplaceParams): ProjectScore = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -96,7 +112,11 @@ interface ProjectScoreService { * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as * [ProjectScoreService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ProjectScoreCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ProjectScoreCreateParams, @@ -107,7 +127,11 @@ interface ProjectScoreService { * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is * otherwise the same as [ProjectScoreService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ProjectScoreRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ProjectScoreRetrieveParams, @@ -118,7 +142,11 @@ interface ProjectScoreService { * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is * otherwise the same as [ProjectScoreService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ProjectScoreUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ProjectScoreUpdateParams, @@ -129,17 +157,23 @@ interface ProjectScoreService { * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as * [ProjectScoreService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): HttpResponseFor = list(ProjectScoreListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as - * [ProjectScoreService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectScoreListParams.none(), requestOptions) @@ -148,7 +182,11 @@ interface ProjectScoreService { * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is * otherwise the same as [ProjectScoreService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ProjectScoreDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ProjectScoreDeleteParams, @@ -159,7 +197,11 @@ interface ProjectScoreService { * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as * [ProjectScoreService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: ProjectScoreReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: ProjectScoreReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index bd67e60e..197931d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -29,14 +27,18 @@ interface ProjectService { * Create a new project. If there is an existing project with the same name as the one specified * in the request, will return the existing project unmodified */ - @JvmOverloads + fun create(params: ProjectCreateParams): Project = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): Project /** Get a project object by its id */ - @JvmOverloads + fun retrieve(params: ProjectRetrieveParams): Project = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -47,7 +49,9 @@ interface ProjectService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: ProjectUpdateParams): Project = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -57,21 +61,26 @@ interface ProjectService { * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ - @JvmOverloads + fun list(): ProjectListPage = list(ProjectListParams.none()) + + /** @see [list] */ fun list( params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ProjectListPage - /** - * List out all projects. The projects are sorted by creation date, with the most - * recently-created projects coming first - */ + /** @see [list] */ + fun list(params: ProjectListParams = ProjectListParams.none()): ProjectListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): ProjectListPage = list(ProjectListParams.none(), requestOptions) /** Delete a project object by its id */ - @JvmOverloads + fun delete(params: ProjectDeleteParams): Project = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -86,7 +95,11 @@ interface ProjectService { * Returns a raw HTTP response for `post /v1/project`, but is otherwise the same as * [ProjectService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ProjectCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ProjectCreateParams, @@ -97,7 +110,11 @@ interface ProjectService { * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same * as [ProjectService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ProjectRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ProjectRetrieveParams, @@ -108,7 +125,11 @@ interface ProjectService { * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the * same as [ProjectService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ProjectUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ProjectUpdateParams, @@ -119,17 +140,22 @@ interface ProjectService { * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as * [ProjectService.list]. */ - @JvmOverloads + @MustBeClosed fun list(): HttpResponseFor = list(ProjectListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as - * [ProjectService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectListParams = ProjectListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectListParams.none(), requestOptions) @@ -138,7 +164,11 @@ interface ProjectService { * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the * same as [ProjectService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ProjectDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ProjectDeleteParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index 4bfaa198..d06930e4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -27,14 +25,19 @@ interface ProjectTagService { * Create a new project_tag. If there is an existing project_tag in the project with the same * name as the one specified in the request, will return the existing project_tag unmodified */ - @JvmOverloads + fun create(params: ProjectTagCreateParams): ProjectTag = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTag /** Get a project_tag object by its id */ - @JvmOverloads + fun retrieve(params: ProjectTagRetrieveParams): ProjectTag = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -45,7 +48,9 @@ interface ProjectTagService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: ProjectTagUpdateParams): ProjectTag = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -55,21 +60,26 @@ interface ProjectTagService { * List out all project_tags. The project_tags are sorted by creation date, with the most * recently-created project_tags coming first */ - @JvmOverloads + fun list(): ProjectTagListPage = list(ProjectTagListParams.none()) + + /** @see [list] */ fun list( params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): ProjectTagListPage - /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first - */ + /** @see [list] */ + fun list(params: ProjectTagListParams = ProjectTagListParams.none()): ProjectTagListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): ProjectTagListPage = list(ProjectTagListParams.none(), requestOptions) /** Delete a project_tag object by its id */ - @JvmOverloads + fun delete(params: ProjectTagDeleteParams): ProjectTag = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -80,7 +90,10 @@ interface ProjectTagService { * same name as the one specified in the request, will replace the existing project_tag with the * provided fields */ - @JvmOverloads + fun replace(params: ProjectTagReplaceParams): ProjectTag = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -93,7 +106,11 @@ interface ProjectTagService { * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as * [ProjectTagService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ProjectTagCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ProjectTagCreateParams, @@ -104,7 +121,11 @@ interface ProjectTagService { * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise * the same as [ProjectTagService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ProjectTagRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ProjectTagRetrieveParams, @@ -115,7 +136,11 @@ interface ProjectTagService { * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is * otherwise the same as [ProjectTagService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ProjectTagUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ProjectTagUpdateParams, @@ -126,17 +151,23 @@ interface ProjectTagService { * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as * [ProjectTagService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): HttpResponseFor = list(ProjectTagListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as - * [ProjectTagService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectTagListParams = ProjectTagListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectTagListParams.none(), requestOptions) @@ -145,7 +176,11 @@ interface ProjectTagService { * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is * otherwise the same as [ProjectTagService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ProjectTagDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ProjectTagDeleteParams, @@ -156,7 +191,11 @@ interface ProjectTagService { * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as * [ProjectTagService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: ProjectTagReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: ProjectTagReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index b9459255..e3d04a03 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -27,14 +25,18 @@ interface PromptService { * Create a new prompt. If there is an existing prompt in the project with the same slug as the * one specified in the request, will return the existing prompt unmodified */ - @JvmOverloads + fun create(params: PromptCreateParams): Prompt = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): Prompt /** Get a prompt object by its id */ - @JvmOverloads + fun retrieve(params: PromptRetrieveParams): Prompt = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -45,7 +47,9 @@ interface PromptService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: PromptUpdateParams): Prompt = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -55,21 +59,26 @@ interface PromptService { * List out all prompts. The prompts are sorted by creation date, with the most recently-created * prompts coming first */ - @JvmOverloads + fun list(): PromptListPage = list(PromptListParams.none()) + + /** @see [list] */ fun list( params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): PromptListPage - /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first - */ + /** @see [list] */ + fun list(params: PromptListParams = PromptListParams.none()): PromptListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): PromptListPage = list(PromptListParams.none(), requestOptions) /** Delete a prompt object by its id */ - @JvmOverloads + fun delete(params: PromptDeleteParams): Prompt = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -79,7 +88,9 @@ interface PromptService { * Create or replace prompt. If there is an existing prompt in the project with the same slug as * the one specified in the request, will replace the existing prompt with the provided fields */ - @JvmOverloads + fun replace(params: PromptReplaceParams): Prompt = replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -92,7 +103,11 @@ interface PromptService { * Returns a raw HTTP response for `post /v1/prompt`, but is otherwise the same as * [PromptService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: PromptCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: PromptCreateParams, @@ -103,7 +118,11 @@ interface PromptService { * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same * as [PromptService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: PromptRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: PromptRetrieveParams, @@ -114,7 +133,11 @@ interface PromptService { * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same * as [PromptService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: PromptUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: PromptUpdateParams, @@ -125,17 +148,22 @@ interface PromptService { * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as * [PromptService.list]. */ - @JvmOverloads + @MustBeClosed fun list(): HttpResponseFor = list(PromptListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as - * [PromptService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: PromptListParams = PromptListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(PromptListParams.none(), requestOptions) @@ -144,7 +172,11 @@ interface PromptService { * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the * same as [PromptService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: PromptDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: PromptDeleteParams, @@ -155,7 +187,11 @@ interface PromptService { * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as * [PromptService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: PromptReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: PromptReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index 8c0db8ce..a913ecca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -27,14 +25,18 @@ interface RoleService { * Create a new role. If there is an existing role with the same name as the one specified in * the request, will return the existing role unmodified */ - @JvmOverloads + fun create(params: RoleCreateParams): Role = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): Role /** Get a role object by its id */ - @JvmOverloads + fun retrieve(params: RoleRetrieveParams): Role = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -45,7 +47,9 @@ interface RoleService { * fields will be deep-merged with existing content. Currently we do not support removing fields * or setting them to null. */ - @JvmOverloads + fun update(params: RoleUpdateParams): Role = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -55,21 +59,26 @@ interface RoleService { * List out all roles. The roles are sorted by creation date, with the most recently-created * roles coming first */ - @JvmOverloads + fun list(): RoleListPage = list(RoleListParams.none()) + + /** @see [list] */ fun list( params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): RoleListPage - /** - * List out all roles. The roles are sorted by creation date, with the most recently-created - * roles coming first - */ + /** @see [list] */ + fun list(params: RoleListParams = RoleListParams.none()): RoleListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): RoleListPage = list(RoleListParams.none(), requestOptions) /** Delete a role object by its id */ - @JvmOverloads + fun delete(params: RoleDeleteParams): Role = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -79,7 +88,9 @@ interface RoleService { * Create or replace role. If there is an existing role with the same name as the one specified * in the request, will replace the existing role with the provided fields */ - @JvmOverloads + fun replace(params: RoleReplaceParams): Role = replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -92,7 +103,11 @@ interface RoleService { * Returns a raw HTTP response for `post /v1/role`, but is otherwise the same as * [RoleService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: RoleCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: RoleCreateParams, @@ -103,7 +118,11 @@ interface RoleService { * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as * [RoleService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: RoleRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: RoleRetrieveParams, @@ -114,7 +133,11 @@ interface RoleService { * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as * [RoleService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: RoleUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: RoleUpdateParams, @@ -125,17 +148,21 @@ interface RoleService { * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as * [RoleService.list]. */ - @JvmOverloads + @MustBeClosed fun list(): HttpResponseFor = list(RoleListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as - * [RoleService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list(params: RoleListParams = RoleListParams.none()): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(RoleListParams.none(), requestOptions) @@ -144,7 +171,11 @@ interface RoleService { * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as * [RoleService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: RoleDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: RoleDeleteParams, @@ -155,7 +186,11 @@ interface RoleService { * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as * [RoleService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: RoleReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: RoleReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt index 8a4d51f7..f8630cc6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -27,14 +25,19 @@ interface SpanIframeService { * Create a new span_iframe. If there is an existing span_iframe with the same name as the one * specified in the request, will return the existing span_iframe unmodified */ - @JvmOverloads + fun create(params: SpanIframeCreateParams): SpanIFrame = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): SpanIFrame /** Get a span_iframe object by its id */ - @JvmOverloads + fun retrieve(params: SpanIframeRetrieveParams): SpanIFrame = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -45,7 +48,9 @@ interface SpanIframeService { * object-type fields will be deep-merged with existing content. Currently we do not support * removing fields or setting them to null. */ - @JvmOverloads + fun update(params: SpanIframeUpdateParams): SpanIFrame = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -55,21 +60,26 @@ interface SpanIframeService { * List out all span_iframes. The span_iframes are sorted by creation date, with the most * recently-created span_iframes coming first */ - @JvmOverloads + fun list(): SpanIframeListPage = list(SpanIframeListParams.none()) + + /** @see [list] */ fun list( params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): SpanIframeListPage - /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first - */ + /** @see [list] */ + fun list(params: SpanIframeListParams = SpanIframeListParams.none()): SpanIframeListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): SpanIframeListPage = list(SpanIframeListParams.none(), requestOptions) /** Delete a span_iframe object by its id */ - @JvmOverloads + fun delete(params: SpanIframeDeleteParams): SpanIFrame = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -79,7 +89,10 @@ interface SpanIframeService { * Create or replace span_iframe. If there is an existing span_iframe with the same name as the * one specified in the request, will replace the existing span_iframe with the provided fields */ - @JvmOverloads + fun replace(params: SpanIframeReplaceParams): SpanIFrame = + replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -92,7 +105,11 @@ interface SpanIframeService { * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as * [SpanIframeService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: SpanIframeCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: SpanIframeCreateParams, @@ -103,7 +120,11 @@ interface SpanIframeService { * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise * the same as [SpanIframeService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: SpanIframeRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: SpanIframeRetrieveParams, @@ -114,7 +135,11 @@ interface SpanIframeService { * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is * otherwise the same as [SpanIframeService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: SpanIframeUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: SpanIframeUpdateParams, @@ -125,17 +150,23 @@ interface SpanIframeService { * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as * [SpanIframeService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(): HttpResponseFor = list(SpanIframeListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as - * [SpanIframeService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list( + params: SpanIframeListParams = SpanIframeListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(SpanIframeListParams.none(), requestOptions) @@ -144,7 +175,11 @@ interface SpanIframeService { * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is * otherwise the same as [SpanIframeService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: SpanIframeDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: SpanIframeDeleteParams, @@ -155,7 +190,11 @@ interface SpanIframeService { * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as * [SpanIframeService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: SpanIframeReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: SpanIframeReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index 12190a7e..f7d77d83 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -17,13 +15,19 @@ interface TopLevelService { fun withRawResponse(): WithRawResponse /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ - @JvmOverloads + fun helloWorld(): String = helloWorld(TopLevelHelloWorldParams.none()) + + /** @see [helloWorld] */ fun helloWorld( params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): String - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + /** @see [helloWorld] */ + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): String = + helloWorld(params, RequestOptions.none()) + + /** @see [helloWorld] */ fun helloWorld(requestOptions: RequestOptions): String = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) @@ -34,17 +38,23 @@ interface TopLevelService { * Returns a raw HTTP response for `get /v1`, but is otherwise the same as * [TopLevelService.helloWorld]. */ - @JvmOverloads + @MustBeClosed + fun helloWorld(): HttpResponseFor = helloWorld(TopLevelHelloWorldParams.none()) + + /** @see [helloWorld] */ @MustBeClosed fun helloWorld( params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1`, but is otherwise the same as - * [TopLevelService.helloWorld]. - */ + /** @see [helloWorld] */ + @MustBeClosed + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() + ): HttpResponseFor = helloWorld(params, RequestOptions.none()) + + /** @see [helloWorld] */ @MustBeClosed fun helloWorld(requestOptions: RequestOptions): HttpResponseFor = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index b38cfab6..8a297070 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -20,7 +18,9 @@ interface UserService { fun withRawResponse(): WithRawResponse /** Get a user object by its id */ - @JvmOverloads + fun retrieve(params: UserRetrieveParams): User = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -30,16 +30,19 @@ interface UserService { * List out all users. The users are sorted by creation date, with the most recently-created * users coming first */ - @JvmOverloads + fun list(): UserListPage = list(UserListParams.none()) + + /** @see [list] */ fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): UserListPage - /** - * List out all users. The users are sorted by creation date, with the most recently-created - * users coming first - */ + /** @see [list] */ + fun list(params: UserListParams = UserListParams.none()): UserListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list(requestOptions: RequestOptions): UserListPage = list(UserListParams.none(), requestOptions) @@ -50,7 +53,11 @@ interface UserService { * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as * [UserService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: UserRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: UserRetrieveParams, @@ -61,17 +68,21 @@ interface UserService { * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as * [UserService.list]. */ - @JvmOverloads + @MustBeClosed fun list(): HttpResponseFor = list(UserListParams.none()) + + /** @see [list] */ @MustBeClosed fun list( params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as - * [UserService.list]. - */ + /** @see [list] */ + @MustBeClosed + fun list(params: UserListParams = UserListParams.none()): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list(requestOptions: RequestOptions): HttpResponseFor = list(UserListParams.none(), requestOptions) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index bb508305..f997b1b2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions @@ -27,14 +25,18 @@ interface ViewService { * Create a new view. If there is an existing view with the same name as the one specified in * the request, will return the existing view unmodified */ - @JvmOverloads + fun create(params: ViewCreateParams): View = create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none(), ): View /** Get a view object by its id */ - @JvmOverloads + fun retrieve(params: ViewRetrieveParams): View = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -45,7 +47,9 @@ interface ViewService { * fields will be deep-merged with existing content. Currently we do not support removing fields * or setting them to null. */ - @JvmOverloads + fun update(params: ViewUpdateParams): View = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -55,14 +59,18 @@ interface ViewService { * List out all views. The views are sorted by creation date, with the most recently-created * views coming first */ - @JvmOverloads + fun list(params: ViewListParams): ViewListPage = list(params, RequestOptions.none()) + + /** @see [list] */ fun list( params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none(), ): ViewListPage /** Delete a view object by its id */ - @JvmOverloads + fun delete(params: ViewDeleteParams): View = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -72,7 +80,9 @@ interface ViewService { * Create or replace view. If there is an existing view with the same name as the one specified * in the request, will replace the existing view with the provided fields */ - @JvmOverloads + fun replace(params: ViewReplaceParams): View = replace(params, RequestOptions.none()) + + /** @see [replace] */ fun replace( params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -85,7 +95,11 @@ interface ViewService { * Returns a raw HTTP response for `post /v1/view`, but is otherwise the same as * [ViewService.create]. */ - @JvmOverloads + @MustBeClosed + fun create(params: ViewCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ @MustBeClosed fun create( params: ViewCreateParams, @@ -96,7 +110,11 @@ interface ViewService { * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as * [ViewService.retrieve]. */ - @JvmOverloads + @MustBeClosed + fun retrieve(params: ViewRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ @MustBeClosed fun retrieve( params: ViewRetrieveParams, @@ -107,7 +125,11 @@ interface ViewService { * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as * [ViewService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(params: ViewUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( params: ViewUpdateParams, @@ -118,7 +140,11 @@ interface ViewService { * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as * [ViewService.list]. */ - @JvmOverloads + @MustBeClosed + fun list(params: ViewListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ @MustBeClosed fun list( params: ViewListParams, @@ -129,7 +155,11 @@ interface ViewService { * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as * [ViewService.delete]. */ - @JvmOverloads + @MustBeClosed + fun delete(params: ViewDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see [delete] */ @MustBeClosed fun delete( params: ViewDeleteParams, @@ -140,7 +170,11 @@ interface ViewService { * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as * [ViewService.replace]. */ - @JvmOverloads + @MustBeClosed + fun replace(params: ViewReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see [replace] */ @MustBeClosed fun replace( params: ViewReplaceParams, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt index dbc32b7a..d6298636 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking.organizations import com.braintrustdata.api.core.RequestOptions @@ -18,13 +16,20 @@ interface MemberService { fun withRawResponse(): WithRawResponse /** Modify organization membership */ - @JvmOverloads + fun update(): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none()) + + /** @see [update] */ fun update( params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): PatchOrganizationMembersOutput - /** Modify organization membership */ + /** @see [update] */ + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() + ): PatchOrganizationMembersOutput = update(params, RequestOptions.none()) + + /** @see [update] */ fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none(), requestOptions) @@ -35,17 +40,24 @@ interface MemberService { * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the * same as [MemberService.update]. */ - @JvmOverloads + @MustBeClosed + fun update(): HttpResponseFor = + update(OrganizationMemberUpdateParams.none()) + + /** @see [update] */ @MustBeClosed fun update( params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the - * same as [MemberService.update]. - */ + /** @see [update] */ + @MustBeClosed + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() + ): HttpResponseFor = update(params, RequestOptions.none()) + + /** @see [update] */ @MustBeClosed fun update( requestOptions: RequestOptions diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index 2fa18b03..3289dca2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -1,7 +1,5 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.braintrustdata.api.services.blocking.projects import com.braintrustdata.api.core.RequestOptions @@ -23,7 +21,10 @@ interface LogService { fun withRawResponse(): WithRawResponse /** Log feedback for a set of project logs events */ - @JvmOverloads + fun feedback(params: ProjectLogFeedbackParams): FeedbackResponseSchema = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ fun feedback( params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -34,7 +35,10 @@ interface LogService { * the parameters in the URL query rather than in the request body. For more complex queries, * use the `POST /btql` endpoint. */ - @JvmOverloads + fun fetch(params: ProjectLogFetchParams): FetchProjectLogsEventsResponse = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ fun fetch( params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -45,14 +49,20 @@ interface LogService { * parameters in the request body rather than in the URL query. For more complex queries, use * the `POST /btql` endpoint. */ - @JvmOverloads + fun fetchPost(params: ProjectLogFetchPostParams): FetchProjectLogsEventsResponse = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ fun fetchPost( params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none(), ): FetchProjectLogsEventsResponse /** Insert a set of events into the project logs */ - @JvmOverloads + fun insert(params: ProjectLogInsertParams): InsertEventsResponse = + insert(params, RequestOptions.none()) + + /** @see [insert] */ fun insert( params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -65,7 +75,11 @@ interface LogService { * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is * otherwise the same as [LogService.feedback]. */ - @JvmOverloads + @MustBeClosed + fun feedback(params: ProjectLogFeedbackParams): HttpResponseFor = + feedback(params, RequestOptions.none()) + + /** @see [feedback] */ @MustBeClosed fun feedback( params: ProjectLogFeedbackParams, @@ -76,7 +90,11 @@ interface LogService { * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is * otherwise the same as [LogService.fetch]. */ - @JvmOverloads + @MustBeClosed + fun fetch(params: ProjectLogFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ @MustBeClosed fun fetch( params: ProjectLogFetchParams, @@ -87,7 +105,13 @@ interface LogService { * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is * otherwise the same as [LogService.fetchPost]. */ - @JvmOverloads + @MustBeClosed + fun fetchPost( + params: ProjectLogFetchPostParams + ): HttpResponseFor = + fetchPost(params, RequestOptions.none()) + + /** @see [fetchPost] */ @MustBeClosed fun fetchPost( params: ProjectLogFetchPostParams, @@ -98,7 +122,11 @@ interface LogService { * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is * otherwise the same as [LogService.insert]. */ - @JvmOverloads + @MustBeClosed + fun insert(params: ProjectLogInsertParams): HttpResponseFor = + insert(params, RequestOptions.none()) + + /** @see [insert] */ @MustBeClosed fun insert( params: ProjectLogInsertParams, diff --git a/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts b/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts index 322e94ff..ff8a82d8 100755 --- a/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.kotlin.gradle.kts @@ -22,11 +22,12 @@ configure { tasks.withType().configureEach { compilerOptions { + allWarningsAsErrors = true freeCompilerArgs = listOf( - "-Xjvm-default=all", - "-Xjdk-release=1.8", - // Suppress deprecation warnings because we may still reference and test deprecated members. - "-Xsuppress-warning=DEPRECATION" + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + "-Xsuppress-warning=DEPRECATION" ) jvmTarget.set(JvmTarget.JVM_1_8) } From e8882a710bff95c91accdcd7bd293f24a724fb7f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 8 Mar 2025 06:46:57 +0000 Subject: [PATCH 72/87] chore(internal): update variable names in tests (#142) --- .../braintrustdata/api/models/AISecretTest.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt index 59e99875..693b9866 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt @@ -11,7 +11,7 @@ class AISecretTest { @Test fun createAISecret() { - val aISecret = + val aiSecret = AISecret.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") @@ -25,18 +25,18 @@ class AISecretTest { .previewSecret("preview_secret") .type("type") .build() - assertThat(aISecret).isNotNull - assertThat(aISecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(aISecret.name()).isEqualTo("name") - assertThat(aISecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(aISecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(aISecret.metadata()) + assertThat(aiSecret).isNotNull + assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aiSecret.name()).isEqualTo("name") + assertThat(aiSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aiSecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(aiSecret.metadata()) .contains( AISecret.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - assertThat(aISecret.previewSecret()).contains("preview_secret") - assertThat(aISecret.type()).contains("type") + assertThat(aiSecret.previewSecret()).contains("preview_secret") + assertThat(aiSecret.type()).contains("type") } } From 0a06490b643d90b0666d2f3505dd20e8d519251c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 09:55:10 +0000 Subject: [PATCH 73/87] docs: revise readme docs about nested params (#143) --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ce0fa6e1..cc16ef46 100644 --- a/README.md +++ b/README.md @@ -373,7 +373,23 @@ ProjectCreateParams params = ProjectCreateParams.builder() .build(); ``` -These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. You can also set undocumented parameters on nested headers, query params, or body classes using the `putAdditionalProperty` method. These properties can be accessed on the built object later using the `_additionalProperties()` method. +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. + +To set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class: + +```java +import com.braintrustdata.api.core.JsonValue; +import com.braintrustdata.api.models.ProjectSettings; +import com.braintrustdata.api.models.ProjectUpdateParams; + +ProjectUpdateParams params = ProjectUpdateParams.builder() + .settings(ProjectSettings.builder() + .putAdditionalProperty("secretProperty", JsonValue.from("42")) + .build()) + .build(); +``` + +These properties can be accessed on the nested built object later using the `_additionalProperties()` method. To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/JsonValue.kt) object to its setter: From 33fa7ab33b83c408b14fc770b451ac9bb10bd1ca Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 09:57:23 +0000 Subject: [PATCH 74/87] docs: document `JsonValue` construction in readme (#144) --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cc16ef46..2212fe0a 100644 --- a/README.md +++ b/README.md @@ -391,7 +391,7 @@ ProjectUpdateParams params = ProjectUpdateParams.builder() These properties can be accessed on the nested built object later using the `_additionalProperties()` method. -To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/JsonValue.kt) object to its setter: +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt) object to its setter: ```java import com.braintrustdata.api.core.JsonValue; @@ -402,6 +402,45 @@ ProjectCreateParams params = ProjectCreateParams.builder() .build(); ``` +The most straightforward way to create a [`JsonValue`](braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt) is using its `from(...)` method: + +```java +import com.braintrustdata.api.core.JsonValue; +import java.util.List; +import java.util.Map; + +// Create primitive JSON values +JsonValue nullValue = JsonValue.from(null); +JsonValue booleanValue = JsonValue.from(true); +JsonValue numberValue = JsonValue.from(42); +JsonValue stringValue = JsonValue.from("Hello World!"); + +// Create a JSON array value equivalent to `["Hello", "World"]` +JsonValue arrayValue = JsonValue.from(List.of( + "Hello", "World" +)); + +// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` +JsonValue objectValue = JsonValue.from(Map.of( + "a", 1, + "b", 2 +)); + +// Create an arbitrarily nested JSON equivalent to: +// { +// "a": [1, 2], +// "b": [3, 4] +// } +JsonValue complexValue = JsonValue.from(Map.of( + "a", List.of( + 1, 2 + ), + "b", List.of( + 3, 4 + ) +)); +``` + ### Response properties To access undocumented response properties, call the `_additionalProperties()` method: From 23f0da4fecedf41ae2a2f573ed0f8e25938057cf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 03:40:11 +0000 Subject: [PATCH 75/87] chore(internal): codegen related update (#145) --- .../client/okhttp/BraintrustOkHttpClient.kt | 306 +- .../okhttp/BraintrustOkHttpClientAsync.kt | 304 +- .../api/client/okhttp/OkHttpClient.kt | 54 +- .../api/client/BraintrustClient.kt | 46 +- .../api/client/BraintrustClientAsync.kt | 44 +- .../api/client/BraintrustClientAsyncImpl.kt | 157 +- .../api/client/BraintrustClientImpl.kt | 133 +- .../api/core/BaseDeserializer.kt | 20 +- .../braintrustdata/api/core/ClientOptions.kt | 317 +- .../braintrustdata/api/core/ObjectMappers.kt | 4 +- .../com/braintrustdata/api/core/Params.kt | 5 +- .../braintrustdata/api/core/PrepareRequest.kt | 10 +- .../com/braintrustdata/api/core/Properties.kt | 12 +- .../braintrustdata/api/core/RequestOptions.kt | 10 +- .../com/braintrustdata/api/core/Timeout.kt | 92 +- .../com/braintrustdata/api/core/Utils.kt | 21 +- .../com/braintrustdata/api/core/Values.kt | 74 +- .../api/core/handlers/ErrorHandler.kt | 5 +- .../api/core/handlers/JsonHandler.kt | 5 +- .../braintrustdata/api/core/http/Headers.kt | 5 +- .../api/core/http/HttpClient.kt | 5 +- .../api/core/http/HttpRequest.kt | 202 +- .../api/core/http/HttpRequestBodies.kt | 10 +- .../api/core/http/HttpRequestBody.kt | 7 +- .../http/PhantomReachableClosingHttpClient.kt | 2 +- .../api/core/http/QueryParams.kt | 7 +- .../api/core/http/RetryingHttpClient.kt | 181 +- .../api/errors/BadRequestException.kt | 7 +- .../api/errors/BraintrustError.kt | 74 +- .../errors/BraintrustInvalidDataException.kt | 3 +- .../api/errors/BraintrustIoException.kt | 3 +- .../api/errors/BraintrustServiceException.kt | 12 +- .../api/errors/InternalServerException.kt | 8 +- .../api/errors/NotFoundException.kt | 7 +- .../api/errors/PermissionDeniedException.kt | 7 +- .../api/errors/RateLimitException.kt | 7 +- .../api/errors/UnauthorizedException.kt | 7 +- .../errors/UnexpectedStatusCodeException.kt | 8 +- .../errors/UnprocessableEntityException.kt | 7 +- .../com/braintrustdata/api/models/AISecret.kt | 291 +- .../com/braintrustdata/api/models/Acl.kt | 595 +-- .../api/models/AclBatchUpdateParams.kt | 1697 ++++--- .../api/models/AclBatchUpdateResponse.kt | 288 +- .../api/models/AclCreateParams.kt | 948 ++-- .../api/models/AclDeleteParams.kt | 246 +- .../api/models/AclFindAndDeleteParams.kt | 947 ++-- .../braintrustdata/api/models/AclListPage.kt | 134 +- .../api/models/AclListPageAsync.kt | 167 +- .../api/models/AclListParams.kt | 493 +- .../api/models/AclRetrieveParams.kt | 209 +- .../api/models/AiSecretCreateParams.kt | 653 +-- .../api/models/AiSecretDeleteParams.kt | 249 +- .../api/models/AiSecretFindAndDeleteParams.kt | 438 +- .../api/models/AiSecretListPage.kt | 140 +- .../api/models/AiSecretListPageAsync.kt | 181 +- .../api/models/AiSecretListParams.kt | 524 ++- .../api/models/AiSecretReplaceParams.kt | 654 +-- .../api/models/AiSecretRetrieveParams.kt | 212 +- .../api/models/AiSecretUpdateParams.kt | 540 ++- .../com/braintrustdata/api/models/ApiKey.kt | 191 +- .../api/models/ApiKeyCreateParams.kt | 439 +- .../api/models/ApiKeyDeleteParams.kt | 246 +- .../api/models/ApiKeyListPage.kt | 134 +- .../api/models/ApiKeyListPageAsync.kt | 167 +- .../api/models/ApiKeyListParams.kt | 427 +- .../api/models/ApiKeyRetrieveParams.kt | 212 +- .../models/ChatCompletionContentPartImage.kt | 346 +- .../models/ChatCompletionContentPartText.kt | 172 +- .../models/ChatCompletionMessageToolCall.kt | 327 +- .../braintrustdata/api/models/CodeBundle.kt | 1212 ++--- .../api/models/CreateApiKeyOutput.kt | 208 +- .../api/models/CrossObjectInsertResponse.kt | 388 +- .../braintrustdata/api/models/DataSummary.kt | 103 +- .../com/braintrustdata/api/models/Dataset.kt | 313 +- .../api/models/DatasetCreateParams.kt | 525 ++- .../api/models/DatasetDeleteParams.kt | 246 +- .../braintrustdata/api/models/DatasetEvent.kt | 757 +-- .../api/models/DatasetFeedbackParams.kt | 380 +- .../api/models/DatasetFetchParams.kt | 466 +- .../api/models/DatasetFetchPostParams.kt | 1175 ++--- .../api/models/DatasetInsertParams.kt | 372 +- .../api/models/DatasetListPage.kt | 140 +- .../api/models/DatasetListPageAsync.kt | 183 +- .../api/models/DatasetListParams.kt | 457 +- .../api/models/DatasetRetrieveParams.kt | 212 +- .../api/models/DatasetSummarizeParams.kt | 250 +- .../api/models/DatasetUpdateParams.kt | 510 ++- .../com/braintrustdata/api/models/EnvVar.kt | 251 +- .../api/models/EnvVarCreateParams.kt | 503 +- .../api/models/EnvVarDeleteParams.kt | 246 +- .../api/models/EnvVarListParams.kt | 441 +- .../api/models/EnvVarListResponse.kt | 117 +- .../api/models/EnvVarReplaceParams.kt | 504 +- .../api/models/EnvVarRetrieveParams.kt | 212 +- .../api/models/EnvVarUpdateParams.kt | 400 +- .../api/models/EvalCreateParams.kt | 4065 +++++++++-------- .../braintrustdata/api/models/Experiment.kt | 491 +- .../api/models/ExperimentCreateParams.kt | 917 ++-- .../api/models/ExperimentDeleteParams.kt | 250 +- .../api/models/ExperimentEvent.kt | 1729 +++---- .../api/models/ExperimentFeedbackParams.kt | 380 +- .../api/models/ExperimentFetchParams.kt | 469 +- .../api/models/ExperimentFetchPostParams.kt | 1175 ++--- .../api/models/ExperimentInsertParams.kt | 375 +- .../api/models/ExperimentListPage.kt | 148 +- .../api/models/ExperimentListPageAsync.kt | 184 +- .../api/models/ExperimentListParams.kt | 465 +- .../api/models/ExperimentRetrieveParams.kt | 212 +- .../api/models/ExperimentSummarizeParams.kt | 299 +- .../api/models/ExperimentUpdateParams.kt | 787 ++-- .../api/models/FeedbackDatasetItem.kt | 384 +- .../api/models/FeedbackExperimentItem.kt | 535 ++- .../api/models/FeedbackProjectLogsItem.kt | 535 ++- .../api/models/FeedbackResponseSchema.kt | 163 +- .../api/models/FetchDatasetEventsResponse.kt | 160 +- .../models/FetchExperimentEventsResponse.kt | 157 +- .../models/FetchProjectLogsEventsResponse.kt | 154 +- .../com/braintrustdata/api/models/Function.kt | 2273 ++++----- .../api/models/FunctionCreateParams.kt | 2383 +++++----- .../api/models/FunctionDeleteParams.kt | 249 +- .../api/models/FunctionInvokeParams.kt | 2775 +++++------ .../api/models/FunctionInvokeResponse.kt | 93 +- .../api/models/FunctionListPage.kt | 140 +- .../api/models/FunctionListPageAsync.kt | 181 +- .../api/models/FunctionListParams.kt | 499 +- .../api/models/FunctionReplaceParams.kt | 2383 +++++----- .../api/models/FunctionRetrieveParams.kt | 212 +- .../api/models/FunctionUpdateParams.kt | 1937 ++++---- .../com/braintrustdata/api/models/Group.kt | 305 +- .../api/models/GroupCreateParams.kt | 622 +-- .../api/models/GroupDeleteParams.kt | 246 +- .../api/models/GroupListPage.kt | 134 +- .../api/models/GroupListPageAsync.kt | 167 +- .../api/models/GroupListParams.kt | 427 +- .../api/models/GroupReplaceParams.kt | 623 +-- .../api/models/GroupRetrieveParams.kt | 209 +- .../api/models/GroupUpdateParams.kt | 628 +-- .../api/models/InsertDatasetEvent.kt | 1242 ++--- .../api/models/InsertEventsResponse.kt | 138 +- .../api/models/InsertExperimentEvent.kt | 2135 +++++---- .../api/models/InsertProjectLogsEvent.kt | 2077 +++++---- .../api/models/MetricSummary.kt | 195 +- .../api/models/OnlineScoreConfig.kt | 603 +-- .../braintrustdata/api/models/Organization.kt | 222 +- .../api/models/OrganizationDeleteParams.kt | 250 +- .../api/models/OrganizationListPage.kt | 153 +- .../api/models/OrganizationListPageAsync.kt | 181 +- .../api/models/OrganizationListParams.kt | 417 +- .../models/OrganizationMemberUpdateParams.kt | 1013 ++-- .../api/models/OrganizationRetrieveParams.kt | 212 +- .../api/models/OrganizationUpdateParams.kt | 500 +- .../models/PatchOrganizationMembersOutput.kt | 225 +- .../com/braintrustdata/api/models/Project.kt | 216 +- .../api/models/ProjectCreateParams.kt | 439 +- .../api/models/ProjectDeleteParams.kt | 246 +- .../api/models/ProjectListPage.kt | 140 +- .../api/models/ProjectListPageAsync.kt | 183 +- .../api/models/ProjectListParams.kt | 427 +- .../api/models/ProjectLogFeedbackParams.kt | 380 +- .../api/models/ProjectLogFetchParams.kt | 469 +- .../api/models/ProjectLogFetchPostParams.kt | 1175 ++--- .../api/models/ProjectLogInsertParams.kt | 375 +- .../api/models/ProjectLogsEvent.kt | 1753 +++---- .../api/models/ProjectRetrieveParams.kt | 212 +- .../braintrustdata/api/models/ProjectScore.kt | 648 +-- .../api/models/ProjectScoreCategory.kt | 124 +- .../api/models/ProjectScoreConfig.kt | 202 +- .../api/models/ProjectScoreCreateParams.kt | 872 ++-- .../api/models/ProjectScoreDeleteParams.kt | 250 +- .../api/models/ProjectScoreListPage.kt | 153 +- .../api/models/ProjectScoreListPageAsync.kt | 181 +- .../api/models/ProjectScoreListParams.kt | 671 +-- .../api/models/ProjectScoreReplaceParams.kt | 873 ++-- .../api/models/ProjectScoreRetrieveParams.kt | 212 +- .../api/models/ProjectScoreUpdateParams.kt | 859 ++-- .../api/models/ProjectSettings.kt | 112 +- .../braintrustdata/api/models/ProjectTag.kt | 223 +- .../api/models/ProjectTagCreateParams.kt | 444 +- .../api/models/ProjectTagDeleteParams.kt | 250 +- .../api/models/ProjectTagListPage.kt | 148 +- .../api/models/ProjectTagListPageAsync.kt | 184 +- .../api/models/ProjectTagListParams.kt | 465 +- .../api/models/ProjectTagReplaceParams.kt | 445 +- .../api/models/ProjectTagRetrieveParams.kt | 212 +- .../api/models/ProjectTagUpdateParams.kt | 432 +- .../api/models/ProjectUpdateParams.kt | 439 +- .../com/braintrustdata/api/models/Prompt.kt | 581 ++- .../api/models/PromptCreateParams.kt | 628 +-- .../braintrustdata/api/models/PromptData.kt | 3351 +++++++------- .../api/models/PromptDeleteParams.kt | 246 +- .../api/models/PromptListPage.kt | 134 +- .../api/models/PromptListPageAsync.kt | 167 +- .../api/models/PromptListParams.kt | 499 +- .../api/models/PromptOptions.kt | 2929 ++++++------ .../api/models/PromptReplaceParams.kt | 628 +-- .../api/models/PromptRetrieveParams.kt | 212 +- .../api/models/PromptUpdateParams.kt | 503 +- .../com/braintrustdata/api/models/RepoInfo.kt | 275 +- .../com/braintrustdata/api/models/Role.kt | 555 +-- .../api/models/RoleCreateParams.kt | 858 ++-- .../api/models/RoleDeleteParams.kt | 246 +- .../braintrustdata/api/models/RoleListPage.kt | 134 +- .../api/models/RoleListPageAsync.kt | 167 +- .../api/models/RoleListParams.kt | 427 +- .../api/models/RoleReplaceParams.kt | 859 ++-- .../api/models/RoleRetrieveParams.kt | 209 +- .../api/models/RoleUpdateParams.kt | 1101 ++--- .../braintrustdata/api/models/ScoreSummary.kt | 174 +- .../api/models/SpanAttributes.kt | 168 +- .../braintrustdata/api/models/SpanIFrame.kt | 279 +- .../api/models/SpanIframeCreateParams.kt | 520 ++- .../api/models/SpanIframeDeleteParams.kt | 250 +- .../api/models/SpanIframeListPage.kt | 148 +- .../api/models/SpanIframeListPageAsync.kt | 184 +- .../api/models/SpanIframeListParams.kt | 435 +- .../api/models/SpanIframeReplaceParams.kt | 520 ++- .../api/models/SpanIframeRetrieveParams.kt | 212 +- .../api/models/SpanIframeUpdateParams.kt | 476 +- .../api/models/SummarizeDatasetResponse.kt | 186 +- .../api/models/SummarizeExperimentResponse.kt | 388 +- .../api/models/TopLevelHelloWorldParams.kt | 202 +- .../com/braintrustdata/api/models/User.kt | 195 +- .../braintrustdata/api/models/UserListPage.kt | 134 +- .../api/models/UserListPageAsync.kt | 167 +- .../api/models/UserListParams.kt | 756 +-- .../api/models/UserRetrieveParams.kt | 209 +- .../com/braintrustdata/api/models/View.kt | 394 +- .../api/models/ViewCreateParams.kt | 688 +-- .../com/braintrustdata/api/models/ViewData.kt | 105 +- .../api/models/ViewDataSearch.kt | 204 +- .../api/models/ViewDeleteParams.kt | 458 +- .../braintrustdata/api/models/ViewListPage.kt | 134 +- .../api/models/ViewListPageAsync.kt | 167 +- .../api/models/ViewListParams.kt | 589 ++- .../braintrustdata/api/models/ViewOptions.kt | 304 +- .../api/models/ViewReplaceParams.kt | 689 +-- .../api/models/ViewRetrieveParams.kt | 313 +- .../api/models/ViewUpdateParams.kt | 675 +-- .../api/services/async/AclServiceAsync.kt | 162 +- .../api/services/async/AclServiceAsyncImpl.kt | 357 +- .../services/async/AiSecretServiceAsync.kt | 201 +- .../async/AiSecretServiceAsyncImpl.kt | 416 +- .../api/services/async/ApiKeyServiceAsync.kt | 112 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 248 +- .../api/services/async/DatasetServiceAsync.kt | 271 +- .../services/async/DatasetServiceAsyncImpl.kt | 585 +-- .../api/services/async/EnvVarServiceAsync.kt | 159 +- .../services/async/EnvVarServiceAsyncImpl.kt | 348 +- .../api/services/async/EvalServiceAsync.kt | 39 +- .../services/async/EvalServiceAsyncImpl.kt | 71 +- .../services/async/ExperimentServiceAsync.kt | 301 +- .../async/ExperimentServiceAsyncImpl.kt | 585 +-- .../services/async/FunctionServiceAsync.kt | 187 +- .../async/FunctionServiceAsyncImpl.kt | 417 +- .../api/services/async/GroupServiceAsync.kt | 165 +- .../services/async/GroupServiceAsyncImpl.kt | 360 +- .../async/OrganizationServiceAsync.kt | 129 +- .../async/OrganizationServiceAsyncImpl.kt | 252 +- .../async/ProjectScoreServiceAsync.kt | 195 +- .../async/ProjectScoreServiceAsyncImpl.kt | 360 +- .../api/services/async/ProjectServiceAsync.kt | 136 +- .../services/async/ProjectServiceAsyncImpl.kt | 308 +- .../services/async/ProjectTagServiceAsync.kt | 180 +- .../async/ProjectTagServiceAsyncImpl.kt | 360 +- .../api/services/async/PromptServiceAsync.kt | 164 +- .../services/async/PromptServiceAsyncImpl.kt | 360 +- .../api/services/async/RoleServiceAsync.kt | 162 +- .../services/async/RoleServiceAsyncImpl.kt | 360 +- .../services/async/SpanIframeServiceAsync.kt | 179 +- .../async/SpanIframeServiceAsyncImpl.kt | 360 +- .../services/async/TopLevelServiceAsync.kt | 44 +- .../async/TopLevelServiceAsyncImpl.kt | 57 +- .../api/services/async/UserServiceAsync.kt | 67 +- .../services/async/UserServiceAsyncImpl.kt | 132 +- .../api/services/async/ViewServiceAsync.kt | 147 +- .../services/async/ViewServiceAsyncImpl.kt | 360 +- .../async/organizations/MemberServiceAsync.kt | 49 +- .../organizations/MemberServiceAsyncImpl.kt | 71 +- .../async/projects/LogServiceAsync.kt | 127 +- .../async/projects/LogServiceAsyncImpl.kt | 242 +- .../api/services/blocking/AclService.kt | 150 +- .../api/services/blocking/AclServiceImpl.kt | 321 +- .../api/services/blocking/AiSecretService.kt | 195 +- .../services/blocking/AiSecretServiceImpl.kt | 375 +- .../api/services/blocking/ApiKeyService.kt | 106 +- .../services/blocking/ApiKeyServiceImpl.kt | 218 +- .../api/services/blocking/DatasetService.kt | 251 +- .../services/blocking/DatasetServiceImpl.kt | 533 +-- .../api/services/blocking/EnvVarService.kt | 157 +- .../services/blocking/EnvVarServiceImpl.kt | 311 +- .../api/services/blocking/EvalService.kt | 35 +- .../api/services/blocking/EvalServiceImpl.kt | 68 +- .../services/blocking/ExperimentService.kt | 273 +- .../blocking/ExperimentServiceImpl.kt | 558 ++- .../api/services/blocking/FunctionService.kt | 184 +- .../services/blocking/FunctionServiceImpl.kt | 362 +- .../api/services/blocking/GroupService.kt | 161 +- .../api/services/blocking/GroupServiceImpl.kt | 311 +- .../services/blocking/OrganizationService.kt | 109 +- .../blocking/OrganizationServiceImpl.kt | 239 +- .../services/blocking/ProjectScoreService.kt | 169 +- .../blocking/ProjectScoreServiceImpl.kt | 343 +- .../api/services/blocking/ProjectService.kt | 136 +- .../services/blocking/ProjectServiceImpl.kt | 266 +- .../services/blocking/ProjectTagService.kt | 169 +- .../blocking/ProjectTagServiceImpl.kt | 341 +- .../api/services/blocking/PromptService.kt | 165 +- .../services/blocking/PromptServiceImpl.kt | 311 +- .../api/services/blocking/RoleService.kt | 161 +- .../api/services/blocking/RoleServiceImpl.kt | 310 +- .../services/blocking/SpanIframeService.kt | 168 +- .../blocking/SpanIframeServiceImpl.kt | 341 +- .../api/services/blocking/TopLevelService.kt | 40 +- .../services/blocking/TopLevelServiceImpl.kt | 55 +- .../api/services/blocking/UserService.kt | 62 +- .../api/services/blocking/UserServiceImpl.kt | 110 +- .../api/services/blocking/ViewService.kt | 153 +- .../api/services/blocking/ViewServiceImpl.kt | 310 +- .../blocking/organizations/MemberService.kt | 47 +- .../organizations/MemberServiceImpl.kt | 69 +- .../services/blocking/projects/LogService.kt | 112 +- .../blocking/projects/LogServiceImpl.kt | 233 +- .../braintrustdata/api/TestServerExtension.kt | 10 +- .../api/core/PhantomReachableTest.kt | 8 +- .../com/braintrustdata/api/core/ValuesTest.kt | 22 +- .../api/core/http/HeadersTest.kt | 67 +- .../api/core/http/QueryParamsTest.kt | 53 +- .../api/core/http/RetryingHttpClientTest.kt | 26 +- .../api/core/http/SerializerTest.kt | 31 +- .../braintrustdata/api/models/AISecretTest.kt | 48 +- .../api/models/AclBatchUpdateParamsTest.kt | 155 +- .../api/models/AclBatchUpdateResponseTest.kt | 113 +- .../api/models/AclCreateParamsTest.kt | 77 +- .../api/models/AclDeleteParamsTest.kt | 18 +- .../api/models/AclFindAndDeleteParamsTest.kt | 77 +- .../api/models/AclListParamsTest.kt | 69 +- .../api/models/AclRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/AclTest.kt | 47 +- .../api/models/AiSecretCreateParamsTest.kt | 76 +- .../api/models/AiSecretDeleteParamsTest.kt | 21 +- .../models/AiSecretFindAndDeleteParamsTest.kt | 28 +- .../api/models/AiSecretListParamsTest.kt | 67 +- .../api/models/AiSecretReplaceParamsTest.kt | 76 +- .../api/models/AiSecretRetrieveParamsTest.kt | 21 +- .../api/models/AiSecretUpdateParamsTest.kt | 88 +- .../api/models/ApiKeyCreateParamsTest.kt | 28 +- .../api/models/ApiKeyDeleteParamsTest.kt | 19 +- .../api/models/ApiKeyListParamsTest.kt | 58 +- .../api/models/ApiKeyRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/ApiKeyTest.kt | 31 +- .../ChatCompletionContentPartImageTest.kt | 33 +- .../ChatCompletionContentPartTextTest.kt | 16 +- .../ChatCompletionMessageToolCallTest.kt | 37 +- .../api/models/CodeBundleTest.kt | 75 +- .../api/models/CreateApiKeyOutputTest.kt | 36 +- .../models/CrossObjectInsertResponseTest.kt | 76 +- .../api/models/DataSummaryTest.kt | 8 +- .../api/models/DatasetCreateParamsTest.kt | 77 +- .../api/models/DatasetDeleteParamsTest.kt | 19 +- .../api/models/DatasetEventTest.kt | 98 +- .../api/models/DatasetFeedbackParamsTest.kt | 127 +- .../api/models/DatasetFetchParamsTest.kt | 65 +- .../api/models/DatasetFetchPostParamsTest.kt | 75 +- .../api/models/DatasetInsertParamsTest.kt | 168 +- .../api/models/DatasetListParamsTest.kt | 70 +- .../api/models/DatasetRetrieveParamsTest.kt | 21 +- .../api/models/DatasetSummarizeParamsTest.kt | 51 +- .../braintrustdata/api/models/DatasetTest.kt | 52 +- .../api/models/DatasetUpdateParamsTest.kt | 78 +- .../api/models/EnvVarCreateParamsTest.kt | 66 +- .../api/models/EnvVarDeleteParamsTest.kt | 19 +- .../api/models/EnvVarListParamsTest.kt | 52 +- .../api/models/EnvVarListResponseTest.kt | 44 +- .../api/models/EnvVarReplaceParamsTest.kt | 66 +- .../api/models/EnvVarRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/EnvVarTest.kt | 31 +- .../api/models/EnvVarUpdateParamsTest.kt | 67 +- .../api/models/EvalCreateParamsTest.kt | 339 +- .../api/models/ExperimentCreateParamsTest.kt | 172 +- .../api/models/ExperimentDeleteParamsTest.kt | 23 +- .../api/models/ExperimentEventTest.kt | 214 +- .../models/ExperimentFeedbackParamsTest.kt | 157 +- .../api/models/ExperimentFetchParamsTest.kt | 69 +- .../models/ExperimentFetchPostParamsTest.kt | 75 +- .../api/models/ExperimentInsertParamsTest.kt | 339 +- .../api/models/ExperimentListParamsTest.kt | 70 +- .../models/ExperimentRetrieveParamsTest.kt | 23 +- .../models/ExperimentSummarizeParamsTest.kt | 57 +- .../api/models/ExperimentTest.kt | 122 +- .../api/models/ExperimentUpdateParamsTest.kt | 179 +- .../api/models/FeedbackDatasetItemTest.kt | 40 +- .../api/models/FeedbackExperimentItemTest.kt | 62 +- .../api/models/FeedbackProjectLogsItemTest.kt | 62 +- .../api/models/FeedbackResponseSchemaTest.kt | 9 +- .../models/FetchDatasetEventsResponseTest.kt | 112 +- .../FetchExperimentEventsResponseTest.kt | 229 +- .../FetchProjectLogsEventsResponseTest.kt | 229 +- .../api/models/FunctionCreateParamsTest.kt | 533 +-- .../api/models/FunctionDeleteParamsTest.kt | 21 +- .../api/models/FunctionInvokeParamsTest.kt | 209 +- .../api/models/FunctionListParamsTest.kt | 82 +- .../api/models/FunctionReplaceParamsTest.kt | 533 +-- .../api/models/FunctionRetrieveParamsTest.kt | 21 +- .../braintrustdata/api/models/FunctionTest.kt | 366 +- .../api/models/FunctionUpdateParamsTest.kt | 439 +- .../api/models/GroupCreateParamsTest.kt | 57 +- .../api/models/GroupDeleteParamsTest.kt | 19 +- .../api/models/GroupListParamsTest.kt | 58 +- .../api/models/GroupReplaceParamsTest.kt | 57 +- .../api/models/GroupRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/GroupTest.kt | 45 +- .../api/models/GroupUpdateParamsTest.kt | 79 +- .../api/models/InsertDatasetEventTest.kt | 73 +- .../api/models/InsertEventsResponseTest.kt | 8 +- .../api/models/InsertExperimentEventTest.kt | 186 +- .../api/models/InsertProjectLogsEventTest.kt | 182 +- .../api/models/MetricSummaryTest.kt | 31 +- .../api/models/OnlineScoreConfigTest.kt | 42 +- .../models/OrganizationDeleteParamsTest.kt | 23 +- .../api/models/OrganizationListParamsTest.kt | 52 +- .../OrganizationMemberUpdateParamsTest.kt | 123 +- .../models/OrganizationRetrieveParamsTest.kt | 23 +- .../api/models/OrganizationTest.kt | 36 +- .../models/OrganizationUpdateParamsTest.kt | 75 +- .../PatchOrganizationMembersOutputTest.kt | 20 +- .../api/models/ProjectCreateParamsTest.kt | 28 +- .../api/models/ProjectDeleteParamsTest.kt | 19 +- .../api/models/ProjectListParamsTest.kt | 58 +- .../models/ProjectLogFeedbackParamsTest.kt | 157 +- .../api/models/ProjectLogFetchParamsTest.kt | 69 +- .../models/ProjectLogFetchPostParamsTest.kt | 75 +- .../api/models/ProjectLogInsertParamsTest.kt | 333 +- .../api/models/ProjectLogsEventTest.kt | 214 +- .../api/models/ProjectRetrieveParamsTest.kt | 21 +- .../api/models/ProjectScoreCategoryTest.kt | 11 +- .../api/models/ProjectScoreConfigTest.kt | 61 +- .../models/ProjectScoreCreateParamsTest.kt | 179 +- .../models/ProjectScoreDeleteParamsTest.kt | 23 +- .../api/models/ProjectScoreListParamsTest.kt | 82 +- .../models/ProjectScoreReplaceParamsTest.kt | 179 +- .../models/ProjectScoreRetrieveParamsTest.kt | 23 +- .../api/models/ProjectScoreTest.kt | 122 +- .../models/ProjectScoreUpdateParamsTest.kt | 184 +- .../api/models/ProjectSettingsTest.kt | 8 +- .../api/models/ProjectTagCreateParamsTest.kt | 58 +- .../api/models/ProjectTagDeleteParamsTest.kt | 23 +- .../api/models/ProjectTagListParamsTest.kt | 70 +- .../api/models/ProjectTagReplaceParamsTest.kt | 58 +- .../models/ProjectTagRetrieveParamsTest.kt | 23 +- .../api/models/ProjectTagTest.kt | 35 +- .../api/models/ProjectTagUpdateParamsTest.kt | 67 +- .../braintrustdata/api/models/ProjectTest.kt | 40 +- .../api/models/ProjectUpdateParamsTest.kt | 64 +- .../api/models/PromptCreateParamsTest.kt | 419 +- .../api/models/PromptDataTest.kt | 227 +- .../api/models/PromptDeleteParamsTest.kt | 19 +- .../api/models/PromptListParamsTest.kt | 82 +- .../api/models/PromptOptionsTest.kt | 104 +- .../api/models/PromptReplaceParamsTest.kt | 419 +- .../api/models/PromptRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/PromptTest.kt | 301 +- .../api/models/PromptUpdateParamsTest.kt | 414 +- .../braintrustdata/api/models/RepoInfoTest.kt | 43 +- .../api/models/RoleCreateParamsTest.kt | 90 +- .../api/models/RoleDeleteParamsTest.kt | 19 +- .../api/models/RoleListParamsTest.kt | 58 +- .../api/models/RoleReplaceParamsTest.kt | 90 +- .../api/models/RoleRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/RoleTest.kt | 60 +- .../api/models/RoleUpdateParamsTest.kt | 144 +- .../api/models/ScoreSummaryTest.kt | 27 +- .../api/models/SpanAttributesTest.kt | 12 +- .../api/models/SpanIFrameTest.kt | 44 +- .../api/models/SpanIframeCreateParamsTest.kt | 72 +- .../api/models/SpanIframeDeleteParamsTest.kt | 23 +- .../api/models/SpanIframeListParamsTest.kt | 58 +- .../api/models/SpanIframeReplaceParamsTest.kt | 72 +- .../models/SpanIframeRetrieveParamsTest.kt | 23 +- .../api/models/SpanIframeUpdateParamsTest.kt | 67 +- .../models/SummarizeDatasetResponseTest.kt | 32 +- .../models/SummarizeExperimentResponseTest.kt | 134 +- .../models/TopLevelHelloWorldParamsTest.kt | 2 +- .../api/models/UserListParamsTest.kt | 70 +- .../api/models/UserRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/UserTest.kt | 31 +- .../api/models/ViewCreateParamsTest.kt | 208 +- .../api/models/ViewDataSearchTest.kt | 26 +- .../braintrustdata/api/models/ViewDataTest.kt | 36 +- .../api/models/ViewDeleteParamsTest.kt | 69 +- .../api/models/ViewListParamsTest.kt | 81 +- .../api/models/ViewOptionsTest.kt | 45 +- .../api/models/ViewReplaceParamsTest.kt | 208 +- .../api/models/ViewRetrieveParamsTest.kt | 69 +- .../com/braintrustdata/api/models/ViewTest.kt | 129 +- .../api/models/ViewUpdateParamsTest.kt | 221 +- .../api/services/ErrorHandlingTest.kt | 343 +- .../api/services/ServiceParamsTest.kt | 45 +- .../api/services/async/AclServiceAsyncTest.kt | 232 +- .../async/AiSecretServiceAsyncTest.kt | 227 +- .../services/async/ApiKeyServiceAsyncTest.kt | 89 +- .../services/async/DatasetServiceAsyncTest.kt | 374 +- .../services/async/EnvVarServiceAsyncTest.kt | 192 +- .../services/async/EvalServiceAsyncTest.kt | 106 +- .../async/ExperimentServiceAsyncTest.kt | 510 +-- .../async/FunctionServiceAsyncTest.kt | 664 ++- .../services/async/GroupServiceAsyncTest.kt | 184 +- .../async/OrganizationServiceAsyncTest.kt | 100 +- .../async/ProjectScoreServiceAsyncTest.kt | 293 +- .../services/async/ProjectServiceAsyncTest.kt | 135 +- .../async/ProjectTagServiceAsyncTest.kt | 176 +- .../services/async/PromptServiceAsyncTest.kt | 537 +-- .../services/async/RoleServiceAsyncTest.kt | 223 +- .../async/SpanIframeServiceAsyncTest.kt | 180 +- .../async/TopLevelServiceAsyncTest.kt | 16 +- .../services/async/UserServiceAsyncTest.kt | 44 +- .../services/async/ViewServiceAsyncTest.kt | 340 +- .../organizations/MemberServiceAsyncTest.kt | 56 +- .../async/projects/LogServiceAsyncTest.kt | 240 +- .../api/services/blocking/AclServiceTest.kt | 220 +- .../services/blocking/AiSecretServiceTest.kt | 213 +- .../services/blocking/ApiKeyServiceTest.kt | 81 +- .../services/blocking/DatasetServiceTest.kt | 354 +- .../services/blocking/EnvVarServiceTest.kt | 180 +- .../api/services/blocking/EvalServiceTest.kt | 104 +- .../blocking/ExperimentServiceTest.kt | 490 +- .../services/blocking/FunctionServiceTest.kt | 650 +-- .../api/services/blocking/GroupServiceTest.kt | 172 +- .../blocking/OrganizationServiceTest.kt | 92 +- .../blocking/ProjectScoreServiceTest.kt | 281 +- .../services/blocking/ProjectServiceTest.kt | 125 +- .../blocking/ProjectTagServiceTest.kt | 164 +- .../services/blocking/PromptServiceTest.kt | 517 +-- .../api/services/blocking/RoleServiceTest.kt | 211 +- .../blocking/SpanIframeServiceTest.kt | 168 +- .../services/blocking/TopLevelServiceTest.kt | 14 +- .../api/services/blocking/UserServiceTest.kt | 40 +- .../api/services/blocking/ViewServiceTest.kt | 328 +- .../organizations/MemberServiceTest.kt | 54 +- .../blocking/projects/LogServiceTest.kt | 232 +- 539 files changed, 77745 insertions(+), 71080 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 94c291ac..84c8fb9c 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -19,10 +19,15 @@ class BraintrustOkHttpClient private constructor() { companion object { - /** Returns a mutable builder for constructing an instance of [BraintrustOkHttpClient]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [BraintrustOkHttpClient]. + */ + @JvmStatic + fun builder() = Builder() - @JvmStatic fun fromEnv(): BraintrustClient = builder().fromEnv().build() + @JvmStatic + fun fromEnv(): BraintrustClient = builder().fromEnv().build() } /** A builder for [BraintrustOkHttpClient]. */ @@ -33,99 +38,163 @@ class BraintrustOkHttpClient private constructor() { private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } - - fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } - - fun clock(clock: Clock) = apply { clientOptions.clock(clock) } - - fun headers(headers: Headers) = apply { clientOptions.headers(headers) } - - fun headers(headers: Map>) = apply { - clientOptions.headers(headers) - } - - fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } - - fun putHeaders(name: String, values: Iterable) = apply { - clientOptions.putHeaders(name, values) - } - - fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } - - fun putAllHeaders(headers: Map>) = apply { - clientOptions.putAllHeaders(headers) - } - - fun replaceHeaders(name: String, value: String) = apply { - clientOptions.replaceHeaders(name, value) - } - - fun replaceHeaders(name: String, values: Iterable) = apply { - clientOptions.replaceHeaders(name, values) - } - - fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } - - fun replaceAllHeaders(headers: Map>) = apply { - clientOptions.replaceAllHeaders(headers) - } - - fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } - - fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } - - fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } - - fun queryParams(queryParams: Map>) = apply { - clientOptions.queryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = apply { - clientOptions.putQueryParam(key, value) - } - - fun putQueryParams(key: String, values: Iterable) = apply { - clientOptions.putQueryParams(key, values) - } - - fun putAllQueryParams(queryParams: QueryParams) = apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = apply { - clientOptions.replaceQueryParams(key, value) - } - - fun replaceQueryParams(key: String, values: Iterable) = apply { - clientOptions.replaceQueryParams(key, values) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } - - fun removeAllQueryParams(keys: Set) = apply { - clientOptions.removeAllQueryParams(keys) - } - - fun timeout(timeout: Timeout) = apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } + fun baseUrl(baseUrl: String) = + apply { + clientOptions.baseUrl(baseUrl) + this.baseUrl = baseUrl + } + + fun jsonMapper(jsonMapper: JsonMapper) = + apply { + clientOptions.jsonMapper(jsonMapper) + } + + fun clock(clock: Clock) = + apply { + clientOptions.clock(clock) + } + + fun headers(headers: Headers) = + apply { + clientOptions.headers(headers) + } + + fun headers(headers: Map>) = + apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = + apply { + clientOptions.putHeader( + name, value + ) + } + + fun putHeaders(name: String, values: Iterable) = + apply { + clientOptions.putHeaders( + name, values + ) + } + + fun putAllHeaders(headers: Headers) = + apply { + clientOptions.putAllHeaders(headers) + } + + fun putAllHeaders(headers: Map>) = + apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = + apply { + clientOptions.replaceHeaders( + name, value + ) + } + + fun replaceHeaders(name: String, values: Iterable) = + apply { + clientOptions.replaceHeaders( + name, values + ) + } + + fun replaceAllHeaders(headers: Headers) = + apply { + clientOptions.replaceAllHeaders(headers) + } + + fun replaceAllHeaders(headers: Map>) = + apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = + apply { + clientOptions.removeHeaders(name) + } + + fun removeAllHeaders(names: Set) = + apply { + clientOptions.removeAllHeaders(names) + } + + fun queryParams(queryParams: QueryParams) = + apply { + clientOptions.queryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = + apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = + apply { + clientOptions.putQueryParam( + key, value + ) + } + + fun putQueryParams(key: String, values: Iterable) = + apply { + clientOptions.putQueryParams( + key, values + ) + } + + fun putAllQueryParams(queryParams: QueryParams) = + apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = + apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = + apply { + clientOptions.replaceQueryParams( + key, value + ) + } + + fun replaceQueryParams(key: String, values: Iterable) = + apply { + clientOptions.replaceQueryParams( + key, values + ) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = + apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = + apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = + apply { + clientOptions.removeQueryParams(key) + } + + fun removeAllQueryParams(keys: Set) = + apply { + clientOptions.removeAllQueryParams(keys) + } + + fun timeout(timeout: Timeout) = + apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } /** * Sets the maximum time allowed for a complete HTTP call, not including retries. @@ -136,31 +205,40 @@ class BraintrustOkHttpClient private constructor() { */ fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + fun maxRetries(maxRetries: Int) = + apply { + clientOptions.maxRetries(maxRetries) + } - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } + fun proxy(proxy: Proxy) = + apply { + this.proxy = proxy + } - fun responseValidation(responseValidation: Boolean) = apply { - clientOptions.responseValidation(responseValidation) - } + fun responseValidation(responseValidation: Boolean) = + apply { + clientOptions.responseValidation(responseValidation) + } - fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: String?) = + apply { + clientOptions.apiKey(apiKey) + } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun fromEnv() = apply { clientOptions.fromEnv() } + fun fromEnv() = + apply { + clientOptions.fromEnv() + } fun build(): BraintrustClient = - BraintrustClientImpl( - clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(baseUrl) - .timeout(timeout) - .proxy(proxy) - .build() - ) - .build() - ) + BraintrustClientImpl(clientOptions + .httpClient(OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build()) + .build()) } } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index ffc88f5c..51d97cb3 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -20,11 +20,14 @@ class BraintrustOkHttpClientAsync private constructor() { companion object { /** - * Returns a mutable builder for constructing an instance of [BraintrustOkHttpClientAsync]. + * Returns a mutable builder for constructing an instance of + * [BraintrustOkHttpClientAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() - @JvmStatic fun fromEnv(): BraintrustClientAsync = builder().fromEnv().build() + @JvmStatic + fun fromEnv(): BraintrustClientAsync = builder().fromEnv().build() } /** A builder for [BraintrustOkHttpClientAsync]. */ @@ -35,99 +38,163 @@ class BraintrustOkHttpClientAsync private constructor() { private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } - - fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } - - fun clock(clock: Clock) = apply { clientOptions.clock(clock) } - - fun headers(headers: Headers) = apply { clientOptions.headers(headers) } - - fun headers(headers: Map>) = apply { - clientOptions.headers(headers) - } - - fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } - - fun putHeaders(name: String, values: Iterable) = apply { - clientOptions.putHeaders(name, values) - } - - fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } - - fun putAllHeaders(headers: Map>) = apply { - clientOptions.putAllHeaders(headers) - } - - fun replaceHeaders(name: String, value: String) = apply { - clientOptions.replaceHeaders(name, value) - } - - fun replaceHeaders(name: String, values: Iterable) = apply { - clientOptions.replaceHeaders(name, values) - } - - fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } - - fun replaceAllHeaders(headers: Map>) = apply { - clientOptions.replaceAllHeaders(headers) - } - - fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } - - fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } - - fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } - - fun queryParams(queryParams: Map>) = apply { - clientOptions.queryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = apply { - clientOptions.putQueryParam(key, value) - } - - fun putQueryParams(key: String, values: Iterable) = apply { - clientOptions.putQueryParams(key, values) - } - - fun putAllQueryParams(queryParams: QueryParams) = apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = apply { - clientOptions.replaceQueryParams(key, value) - } - - fun replaceQueryParams(key: String, values: Iterable) = apply { - clientOptions.replaceQueryParams(key, values) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } - - fun removeAllQueryParams(keys: Set) = apply { - clientOptions.removeAllQueryParams(keys) - } - - fun timeout(timeout: Timeout) = apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } + fun baseUrl(baseUrl: String) = + apply { + clientOptions.baseUrl(baseUrl) + this.baseUrl = baseUrl + } + + fun jsonMapper(jsonMapper: JsonMapper) = + apply { + clientOptions.jsonMapper(jsonMapper) + } + + fun clock(clock: Clock) = + apply { + clientOptions.clock(clock) + } + + fun headers(headers: Headers) = + apply { + clientOptions.headers(headers) + } + + fun headers(headers: Map>) = + apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = + apply { + clientOptions.putHeader( + name, value + ) + } + + fun putHeaders(name: String, values: Iterable) = + apply { + clientOptions.putHeaders( + name, values + ) + } + + fun putAllHeaders(headers: Headers) = + apply { + clientOptions.putAllHeaders(headers) + } + + fun putAllHeaders(headers: Map>) = + apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = + apply { + clientOptions.replaceHeaders( + name, value + ) + } + + fun replaceHeaders(name: String, values: Iterable) = + apply { + clientOptions.replaceHeaders( + name, values + ) + } + + fun replaceAllHeaders(headers: Headers) = + apply { + clientOptions.replaceAllHeaders(headers) + } + + fun replaceAllHeaders(headers: Map>) = + apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = + apply { + clientOptions.removeHeaders(name) + } + + fun removeAllHeaders(names: Set) = + apply { + clientOptions.removeAllHeaders(names) + } + + fun queryParams(queryParams: QueryParams) = + apply { + clientOptions.queryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = + apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = + apply { + clientOptions.putQueryParam( + key, value + ) + } + + fun putQueryParams(key: String, values: Iterable) = + apply { + clientOptions.putQueryParams( + key, values + ) + } + + fun putAllQueryParams(queryParams: QueryParams) = + apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = + apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = + apply { + clientOptions.replaceQueryParams( + key, value + ) + } + + fun replaceQueryParams(key: String, values: Iterable) = + apply { + clientOptions.replaceQueryParams( + key, values + ) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = + apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = + apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = + apply { + clientOptions.removeQueryParams(key) + } + + fun removeAllQueryParams(keys: Set) = + apply { + clientOptions.removeAllQueryParams(keys) + } + + fun timeout(timeout: Timeout) = + apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } /** * Sets the maximum time allowed for a complete HTTP call, not including retries. @@ -138,31 +205,40 @@ class BraintrustOkHttpClientAsync private constructor() { */ fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + fun maxRetries(maxRetries: Int) = + apply { + clientOptions.maxRetries(maxRetries) + } - fun proxy(proxy: Proxy) = apply { this.proxy = proxy } + fun proxy(proxy: Proxy) = + apply { + this.proxy = proxy + } - fun responseValidation(responseValidation: Boolean) = apply { - clientOptions.responseValidation(responseValidation) - } + fun responseValidation(responseValidation: Boolean) = + apply { + clientOptions.responseValidation(responseValidation) + } - fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: String?) = + apply { + clientOptions.apiKey(apiKey) + } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun fromEnv() = apply { clientOptions.fromEnv() } + fun fromEnv() = + apply { + clientOptions.fromEnv() + } fun build(): BraintrustClientAsync = - BraintrustClientAsyncImpl( - clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(baseUrl) - .timeout(timeout) - .proxy(proxy) - .build() - ) - .build() - ) + BraintrustClientAsyncImpl(clientOptions + .httpClient(OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build()) + .build()) } } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index 49a5df68..fff41a7f 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -5,26 +5,27 @@ import com.braintrustdata.api.core.Timeout import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpClient -import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpRequestBody import com.braintrustdata.api.core.http.HttpResponse +import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.errors.BraintrustIoException import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CompletableFuture +import java.util.concurrent.TimeUnit import okhttp3.Call import okhttp3.Callback import okhttp3.HttpUrl -import okhttp3.HttpUrl.Companion.toHttpUrl -import okhttp3.MediaType -import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Response import okhttp3.Request import okhttp3.RequestBody +import okhttp3.MediaType +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType.Companion.toMediaType import okhttp3.RequestBody.Companion.toRequestBody -import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink @@ -32,7 +33,10 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { val call = newCall(request, requestOptions) return try { @@ -52,18 +56,16 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } - newCall(request, requestOptions) - .enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + newCall(request, requestOptions).enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(BraintrustIoException("Request failed", e)) - } + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(BraintrustIoException("Request failed", e)) } - ) + }) return future } @@ -85,7 +87,11 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } if (logLevel != null) { clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + HttpLoggingInterceptor() + .setLevel(logLevel) + .apply { + redactHeader("Authorization") + } ) } @@ -112,18 +118,16 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val headers.values(name).forEach { builder.header(name, it) } } - if ( - !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 - ) { + if (!headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0) { builder.header( "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString() ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { builder.header( "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString() ) } @@ -183,9 +187,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun okhttp3.Headers.toHeaders(): Headers { - val headersBuilder = Headers.builder() - forEach { (name, value) -> headersBuilder.put(name, value) } - return headersBuilder.build() + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index bc327480..98b6a055 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -23,31 +23,33 @@ import com.braintrustdata.api.services.blocking.UserService import com.braintrustdata.api.services.blocking.ViewService /** - * A client for interacting with the Braintrust REST API synchronously. You can also switch to - * asynchronous execution via the [async] method. + * A client for interacting with the Braintrust REST API synchronously. You can + * also switch to asynchronous execution via the [async] method. * - * This client performs best when you create a single instance and reuse it for all interactions - * with the REST API. This is because each client holds its own connection pool and thread pools. - * Reusing connections and threads reduces latency and saves memory. The client also handles rate - * limiting per client. This means that creating and using multiple instances at the same time will - * not respect rate limits. + * This client performs best when you create a single instance and reuse it for all + * interactions with the REST API. This is because each client holds its own + * connection pool and thread pools. Reusing connections and threads reduces + * latency and saves memory. The client also handles rate limiting per client. This + * means that creating and using multiple instances at the same time will not + * respect rate limits. * - * The threads and connections that are held will be released automatically if they remain idle. But - * if you are writing an application that needs to aggressively release unused resources, then you - * may call [close]. + * The threads and connections that are held will be released automatically if they + * remain idle. But if you are writing an application that needs to aggressively + * release unused resources, then you may call [close]. */ interface BraintrustClient { /** * Returns a version of this client that uses asynchronous execution. * - * The returned client shares its resources, like its connection pool and thread pools, with - * this client. + * The returned client shares its resources, like its connection pool and thread + * pools, with this client. */ fun async(): BraintrustClientAsync /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -92,17 +94,21 @@ interface BraintrustClient { /** * Closes this client, relinquishing any underlying resources. * - * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and - * usually should not be synchronously closed via try-with-resources. + * This is purposefully not inherited from [AutoCloseable] because the client is + * long-lived and usually should not be synchronously closed via + * try-with-resources. * - * It's also usually not necessary to call this method at all. the default HTTP client - * automatically releases threads and connections if they remain idle, but if you are writing an - * application that needs to aggressively release unused resources, then you may call this - * method. + * It's also usually not necessary to call this method at all. the default HTTP + * client automatically releases threads and connections if they remain idle, but + * if you are writing an application that needs to aggressively release unused + * resources, then you may call this method. */ fun close() - /** A view of [BraintrustClient] that provides access to raw HTTP responses for each method. */ + /** + * A view of [BraintrustClient] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { fun topLevel(): TopLevelService.WithRawResponse diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index 24ed3368..56e174fe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -23,31 +23,33 @@ import com.braintrustdata.api.services.async.UserServiceAsync import com.braintrustdata.api.services.async.ViewServiceAsync /** - * A client for interacting with the Braintrust REST API asynchronously. You can also switch to - * synchronous execution via the [sync] method. + * A client for interacting with the Braintrust REST API asynchronously. You can + * also switch to synchronous execution via the [sync] method. * - * This client performs best when you create a single instance and reuse it for all interactions - * with the REST API. This is because each client holds its own connection pool and thread pools. - * Reusing connections and threads reduces latency and saves memory. The client also handles rate - * limiting per client. This means that creating and using multiple instances at the same time will - * not respect rate limits. + * This client performs best when you create a single instance and reuse it for all + * interactions with the REST API. This is because each client holds its own + * connection pool and thread pools. Reusing connections and threads reduces + * latency and saves memory. The client also handles rate limiting per client. This + * means that creating and using multiple instances at the same time will not + * respect rate limits. * - * The threads and connections that are held will be released automatically if they remain idle. But - * if you are writing an application that needs to aggressively release unused resources, then you - * may call [close]. + * The threads and connections that are held will be released automatically if they + * remain idle. But if you are writing an application that needs to aggressively + * release unused resources, then you may call [close]. */ interface BraintrustClientAsync { /** * Returns a version of this client that uses synchronous execution. * - * The returned client shares its resources, like its connection pool and thread pools, with - * this client. + * The returned client shares its resources, like its connection pool and thread + * pools, with this client. */ fun sync(): BraintrustClient /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -92,18 +94,20 @@ interface BraintrustClientAsync { /** * Closes this client, relinquishing any underlying resources. * - * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and - * usually should not be synchronously closed via try-with-resources. + * This is purposefully not inherited from [AutoCloseable] because the client is + * long-lived and usually should not be synchronously closed via + * try-with-resources. * - * It's also usually not necessary to call this method at all. the default HTTP client - * automatically releases threads and connections if they remain idle, but if you are writing an - * application that needs to aggressively release unused resources, then you may call this - * method. + * It's also usually not necessary to call this method at all. the default HTTP + * client automatically releases threads and connections if they remain idle, but + * if you are writing an application that needs to aggressively release unused + * resources, then you may call this method. */ fun close() /** - * A view of [BraintrustClientAsync] that provides access to raw HTTP responses for each method. + * A view of [BraintrustClientAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index e945466b..87e33418 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -43,86 +43,57 @@ import com.braintrustdata.api.services.async.UserServiceAsyncImpl import com.braintrustdata.api.services.async.ViewServiceAsync import com.braintrustdata.api.services.async.ViewServiceAsyncImpl -class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : BraintrustClientAsync { +class BraintrustClientAsyncImpl( + private val clientOptions: ClientOptions, + +) : BraintrustClientAsync { private val clientOptionsWithUserAgent = - if (clientOptions.headers.names().contains("User-Agent")) clientOptions - else - clientOptions - .toBuilder() - .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") - .build() + + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + + else clientOptions.toBuilder().putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}").build() // Pass the original clientOptions so that this client sets its own User-Agent. private val sync: BraintrustClient by lazy { BraintrustClientImpl(clientOptions) } - private val withRawResponse: BraintrustClientAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } + private val withRawResponse: BraintrustClientAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - private val topLevel: TopLevelServiceAsync by lazy { - TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) } - private val projects: ProjectServiceAsync by lazy { - ProjectServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptionsWithUserAgent) } - private val experiments: ExperimentServiceAsync by lazy { - ExperimentServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val experiments: ExperimentServiceAsync by lazy { ExperimentServiceAsyncImpl(clientOptionsWithUserAgent) } - private val datasets: DatasetServiceAsync by lazy { - DatasetServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptionsWithUserAgent) } - private val prompts: PromptServiceAsync by lazy { - PromptServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val prompts: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptionsWithUserAgent) } private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptionsWithUserAgent) } - private val groups: GroupServiceAsync by lazy { - GroupServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val groups: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptionsWithUserAgent) } private val acls: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptionsWithUserAgent) } private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptionsWithUserAgent) } - private val projectScores: ProjectScoreServiceAsync by lazy { - ProjectScoreServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val projectScores: ProjectScoreServiceAsync by lazy { ProjectScoreServiceAsyncImpl(clientOptionsWithUserAgent) } - private val projectTags: ProjectTagServiceAsync by lazy { - ProjectTagServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val projectTags: ProjectTagServiceAsync by lazy { ProjectTagServiceAsyncImpl(clientOptionsWithUserAgent) } - private val spanIframes: SpanIframeServiceAsync by lazy { - SpanIframeServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val spanIframes: SpanIframeServiceAsync by lazy { SpanIframeServiceAsyncImpl(clientOptionsWithUserAgent) } - private val functions: FunctionServiceAsync by lazy { - FunctionServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val functions: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptionsWithUserAgent) } private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptionsWithUserAgent) } - private val organizations: OrganizationServiceAsync by lazy { - OrganizationServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val organizations: OrganizationServiceAsync by lazy { OrganizationServiceAsyncImpl(clientOptionsWithUserAgent) } - private val apiKeys: ApiKeyServiceAsync by lazy { - ApiKeyServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptionsWithUserAgent) } - private val aiSecrets: AiSecretServiceAsync by lazy { - AiSecretServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val aiSecrets: AiSecretServiceAsync by lazy { AiSecretServiceAsyncImpl(clientOptionsWithUserAgent) } - private val envVars: EnvVarServiceAsync by lazy { - EnvVarServiceAsyncImpl(clientOptionsWithUserAgent) - } + private val envVars: EnvVarServiceAsync by lazy { EnvVarServiceAsyncImpl(clientOptionsWithUserAgent) } private val evals: EvalServiceAsync by lazy { EvalServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -170,84 +141,48 @@ class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : Brai override fun close() = clientOptions.httpClient.close() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BraintrustClientAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : BraintrustClientAsync.WithRawResponse { - private val topLevel: TopLevelServiceAsync.WithRawResponse by lazy { - TopLevelServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val topLevel: TopLevelServiceAsync.WithRawResponse by lazy { TopLevelServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val projects: ProjectServiceAsync.WithRawResponse by lazy { - ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val projects: ProjectServiceAsync.WithRawResponse by lazy { ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val experiments: ExperimentServiceAsync.WithRawResponse by lazy { - ExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val experiments: ExperimentServiceAsync.WithRawResponse by lazy { ExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val datasets: DatasetServiceAsync.WithRawResponse by lazy { - DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val datasets: DatasetServiceAsync.WithRawResponse by lazy { DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val prompts: PromptServiceAsync.WithRawResponse by lazy { - PromptServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val prompts: PromptServiceAsync.WithRawResponse by lazy { PromptServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val roles: RoleServiceAsync.WithRawResponse by lazy { - RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val roles: RoleServiceAsync.WithRawResponse by lazy { RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val groups: GroupServiceAsync.WithRawResponse by lazy { - GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val groups: GroupServiceAsync.WithRawResponse by lazy { GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val acls: AclServiceAsync.WithRawResponse by lazy { - AclServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val acls: AclServiceAsync.WithRawResponse by lazy { AclServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val users: UserServiceAsync.WithRawResponse by lazy { - UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val users: UserServiceAsync.WithRawResponse by lazy { UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val projectScores: ProjectScoreServiceAsync.WithRawResponse by lazy { - ProjectScoreServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val projectScores: ProjectScoreServiceAsync.WithRawResponse by lazy { ProjectScoreServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val projectTags: ProjectTagServiceAsync.WithRawResponse by lazy { - ProjectTagServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val projectTags: ProjectTagServiceAsync.WithRawResponse by lazy { ProjectTagServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val spanIframes: SpanIframeServiceAsync.WithRawResponse by lazy { - SpanIframeServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val spanIframes: SpanIframeServiceAsync.WithRawResponse by lazy { SpanIframeServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val functions: FunctionServiceAsync.WithRawResponse by lazy { - FunctionServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val functions: FunctionServiceAsync.WithRawResponse by lazy { FunctionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val views: ViewServiceAsync.WithRawResponse by lazy { - ViewServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val views: ViewServiceAsync.WithRawResponse by lazy { ViewServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val organizations: OrganizationServiceAsync.WithRawResponse by lazy { - OrganizationServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val organizations: OrganizationServiceAsync.WithRawResponse by lazy { OrganizationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val apiKeys: ApiKeyServiceAsync.WithRawResponse by lazy { - ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val apiKeys: ApiKeyServiceAsync.WithRawResponse by lazy { ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val aiSecrets: AiSecretServiceAsync.WithRawResponse by lazy { - AiSecretServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val aiSecrets: AiSecretServiceAsync.WithRawResponse by lazy { AiSecretServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val envVars: EnvVarServiceAsync.WithRawResponse by lazy { - EnvVarServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val envVars: EnvVarServiceAsync.WithRawResponse by lazy { EnvVarServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val evals: EvalServiceAsync.WithRawResponse by lazy { - EvalServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val evals: EvalServiceAsync.WithRawResponse by lazy { EvalServiceAsyncImpl.WithRawResponseImpl(clientOptions) } override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index 3eecd3cb..ef76e148 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -43,32 +43,27 @@ import com.braintrustdata.api.services.blocking.UserServiceImpl import com.braintrustdata.api.services.blocking.ViewService import com.braintrustdata.api.services.blocking.ViewServiceImpl -class BraintrustClientImpl(private val clientOptions: ClientOptions) : BraintrustClient { +class BraintrustClientImpl( + private val clientOptions: ClientOptions, + +) : BraintrustClient { private val clientOptionsWithUserAgent = - if (clientOptions.headers.names().contains("User-Agent")) clientOptions - else - clientOptions - .toBuilder() - .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") - .build() + + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + + else clientOptions.toBuilder().putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}").build() // Pass the original clientOptions so that this client sets its own User-Agent. private val async: BraintrustClientAsync by lazy { BraintrustClientAsyncImpl(clientOptions) } - private val withRawResponse: BraintrustClient.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } + private val withRawResponse: BraintrustClient.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - private val topLevel: TopLevelService by lazy { - TopLevelServiceImpl(clientOptionsWithUserAgent) - } + private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptionsWithUserAgent) } private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) } - private val experiments: ExperimentService by lazy { - ExperimentServiceImpl(clientOptionsWithUserAgent) - } + private val experiments: ExperimentService by lazy { ExperimentServiceImpl(clientOptionsWithUserAgent) } private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptionsWithUserAgent) } @@ -82,33 +77,21 @@ class BraintrustClientImpl(private val clientOptions: ClientOptions) : Braintrus private val users: UserService by lazy { UserServiceImpl(clientOptionsWithUserAgent) } - private val projectScores: ProjectScoreService by lazy { - ProjectScoreServiceImpl(clientOptionsWithUserAgent) - } + private val projectScores: ProjectScoreService by lazy { ProjectScoreServiceImpl(clientOptionsWithUserAgent) } - private val projectTags: ProjectTagService by lazy { - ProjectTagServiceImpl(clientOptionsWithUserAgent) - } + private val projectTags: ProjectTagService by lazy { ProjectTagServiceImpl(clientOptionsWithUserAgent) } - private val spanIframes: SpanIframeService by lazy { - SpanIframeServiceImpl(clientOptionsWithUserAgent) - } + private val spanIframes: SpanIframeService by lazy { SpanIframeServiceImpl(clientOptionsWithUserAgent) } - private val functions: FunctionService by lazy { - FunctionServiceImpl(clientOptionsWithUserAgent) - } + private val functions: FunctionService by lazy { FunctionServiceImpl(clientOptionsWithUserAgent) } private val views: ViewService by lazy { ViewServiceImpl(clientOptionsWithUserAgent) } - private val organizations: OrganizationService by lazy { - OrganizationServiceImpl(clientOptionsWithUserAgent) - } + private val organizations: OrganizationService by lazy { OrganizationServiceImpl(clientOptionsWithUserAgent) } private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptionsWithUserAgent) } - private val aiSecrets: AiSecretService by lazy { - AiSecretServiceImpl(clientOptionsWithUserAgent) - } + private val aiSecrets: AiSecretService by lazy { AiSecretServiceImpl(clientOptionsWithUserAgent) } private val envVars: EnvVarService by lazy { EnvVarServiceImpl(clientOptionsWithUserAgent) } @@ -158,84 +141,48 @@ class BraintrustClientImpl(private val clientOptions: ClientOptions) : Braintrus override fun close() = clientOptions.httpClient.close() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BraintrustClient.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : BraintrustClient.WithRawResponse { - private val topLevel: TopLevelService.WithRawResponse by lazy { - TopLevelServiceImpl.WithRawResponseImpl(clientOptions) - } + private val topLevel: TopLevelService.WithRawResponse by lazy { TopLevelServiceImpl.WithRawResponseImpl(clientOptions) } - private val projects: ProjectService.WithRawResponse by lazy { - ProjectServiceImpl.WithRawResponseImpl(clientOptions) - } + private val projects: ProjectService.WithRawResponse by lazy { ProjectServiceImpl.WithRawResponseImpl(clientOptions) } - private val experiments: ExperimentService.WithRawResponse by lazy { - ExperimentServiceImpl.WithRawResponseImpl(clientOptions) - } + private val experiments: ExperimentService.WithRawResponse by lazy { ExperimentServiceImpl.WithRawResponseImpl(clientOptions) } - private val datasets: DatasetService.WithRawResponse by lazy { - DatasetServiceImpl.WithRawResponseImpl(clientOptions) - } + private val datasets: DatasetService.WithRawResponse by lazy { DatasetServiceImpl.WithRawResponseImpl(clientOptions) } - private val prompts: PromptService.WithRawResponse by lazy { - PromptServiceImpl.WithRawResponseImpl(clientOptions) - } + private val prompts: PromptService.WithRawResponse by lazy { PromptServiceImpl.WithRawResponseImpl(clientOptions) } - private val roles: RoleService.WithRawResponse by lazy { - RoleServiceImpl.WithRawResponseImpl(clientOptions) - } + private val roles: RoleService.WithRawResponse by lazy { RoleServiceImpl.WithRawResponseImpl(clientOptions) } - private val groups: GroupService.WithRawResponse by lazy { - GroupServiceImpl.WithRawResponseImpl(clientOptions) - } + private val groups: GroupService.WithRawResponse by lazy { GroupServiceImpl.WithRawResponseImpl(clientOptions) } - private val acls: AclService.WithRawResponse by lazy { - AclServiceImpl.WithRawResponseImpl(clientOptions) - } + private val acls: AclService.WithRawResponse by lazy { AclServiceImpl.WithRawResponseImpl(clientOptions) } - private val users: UserService.WithRawResponse by lazy { - UserServiceImpl.WithRawResponseImpl(clientOptions) - } + private val users: UserService.WithRawResponse by lazy { UserServiceImpl.WithRawResponseImpl(clientOptions) } - private val projectScores: ProjectScoreService.WithRawResponse by lazy { - ProjectScoreServiceImpl.WithRawResponseImpl(clientOptions) - } + private val projectScores: ProjectScoreService.WithRawResponse by lazy { ProjectScoreServiceImpl.WithRawResponseImpl(clientOptions) } - private val projectTags: ProjectTagService.WithRawResponse by lazy { - ProjectTagServiceImpl.WithRawResponseImpl(clientOptions) - } + private val projectTags: ProjectTagService.WithRawResponse by lazy { ProjectTagServiceImpl.WithRawResponseImpl(clientOptions) } - private val spanIframes: SpanIframeService.WithRawResponse by lazy { - SpanIframeServiceImpl.WithRawResponseImpl(clientOptions) - } + private val spanIframes: SpanIframeService.WithRawResponse by lazy { SpanIframeServiceImpl.WithRawResponseImpl(clientOptions) } - private val functions: FunctionService.WithRawResponse by lazy { - FunctionServiceImpl.WithRawResponseImpl(clientOptions) - } + private val functions: FunctionService.WithRawResponse by lazy { FunctionServiceImpl.WithRawResponseImpl(clientOptions) } - private val views: ViewService.WithRawResponse by lazy { - ViewServiceImpl.WithRawResponseImpl(clientOptions) - } + private val views: ViewService.WithRawResponse by lazy { ViewServiceImpl.WithRawResponseImpl(clientOptions) } - private val organizations: OrganizationService.WithRawResponse by lazy { - OrganizationServiceImpl.WithRawResponseImpl(clientOptions) - } + private val organizations: OrganizationService.WithRawResponse by lazy { OrganizationServiceImpl.WithRawResponseImpl(clientOptions) } - private val apiKeys: ApiKeyService.WithRawResponse by lazy { - ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) - } + private val apiKeys: ApiKeyService.WithRawResponse by lazy { ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) } - private val aiSecrets: AiSecretService.WithRawResponse by lazy { - AiSecretServiceImpl.WithRawResponseImpl(clientOptions) - } + private val aiSecrets: AiSecretService.WithRawResponse by lazy { AiSecretServiceImpl.WithRawResponseImpl(clientOptions) } - private val envVars: EnvVarService.WithRawResponse by lazy { - EnvVarServiceImpl.WithRawResponseImpl(clientOptions) - } + private val envVars: EnvVarService.WithRawResponse by lazy { EnvVarServiceImpl.WithRawResponseImpl(clientOptions) } - private val evals: EvalService.WithRawResponse by lazy { - EvalServiceImpl.WithRawResponseImpl(clientOptions) - } + private val evals: EvalService.WithRawResponse by lazy { EvalServiceImpl.WithRawResponseImpl(clientOptions) } override fun topLevel(): TopLevelService.WithRawResponse = topLevel diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt index 64d8a5b3..a197b7fe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt @@ -13,13 +13,9 @@ import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer import kotlin.reflect.KClass -abstract class BaseDeserializer(type: KClass) : - StdDeserializer(type.java), ContextualDeserializer { +abstract class BaseDeserializer(type: KClass) : StdDeserializer(type.java), ContextualDeserializer { - override fun createContextual( - context: DeserializationContext, - property: BeanProperty?, - ): JsonDeserializer { + override fun createContextual(context: DeserializationContext, property: BeanProperty?): JsonDeserializer { return this } @@ -29,11 +25,7 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: TypeReference, - validate: (T) -> Unit = {}, - ): T? { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference, validate: (T) -> Unit = {}): T? { return try { readValue(treeAsTokens(node), type).apply(validate) } catch (e: JsonMappingException) { @@ -43,11 +35,7 @@ abstract class BaseDeserializer(type: KClass) : } } - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: JavaType, - validate: (T) -> Unit = {}, - ): T? { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType, validate: (T) -> Unit = {}): T? { return try { readValue(treeAsTokens(node), type).apply(validate) } catch (e: JsonMappingException) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 38dc1b87..4e3c5177 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -12,8 +12,7 @@ import java.time.Clock import java.util.Optional import kotlin.jvm.optionals.getOrNull -class ClientOptions -private constructor( +class ClientOptions private constructor( private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @@ -25,6 +24,7 @@ private constructor( @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, private val apiKey: String?, + ) { fun apiKey(): Optional = Optional.ofNullable(apiKey) @@ -39,13 +39,16 @@ private constructor( * Returns a mutable builder for constructing an instance of [ClientOptions]. * * The following fields are required: + * * ```java * .httpClient() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() - @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() + @JvmStatic + fun fromEnv(): ClientOptions = builder().fromEnv().build() } /** A builder for [ClientOptions]. */ @@ -63,160 +66,232 @@ private constructor( private var apiKey: String? = null @JvmSynthetic - internal fun from(clientOptions: ClientOptions) = apply { - httpClient = clientOptions.originalHttpClient - jsonMapper = clientOptions.jsonMapper - clock = clientOptions.clock - baseUrl = clientOptions.baseUrl - headers = clientOptions.headers.toBuilder() - queryParams = clientOptions.queryParams.toBuilder() - responseValidation = clientOptions.responseValidation - timeout = clientOptions.timeout - maxRetries = clientOptions.maxRetries - apiKey = clientOptions.apiKey - } + internal fun from(clientOptions: ClientOptions) = + apply { + httpClient = clientOptions.originalHttpClient + jsonMapper = clientOptions.jsonMapper + clock = clientOptions.clock + baseUrl = clientOptions.baseUrl + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() + responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout + maxRetries = clientOptions.maxRetries + apiKey = clientOptions.apiKey + } - fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun httpClient(httpClient: HttpClient) = + apply { + this.httpClient = httpClient + } - fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + fun jsonMapper(jsonMapper: JsonMapper) = + apply { + this.jsonMapper = jsonMapper + } - fun clock(clock: Clock) = apply { this.clock = clock } + fun clock(clock: Clock) = + apply { + this.clock = clock + } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String) = + apply { + this.baseUrl = baseUrl + } - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation - } + fun responseValidation(responseValidation: Boolean) = + apply { + this.responseValidation = responseValidation + } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = + apply { + this.timeout = timeout + } - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + fun maxRetries(maxRetries: Int) = + apply { + this.maxRetries = maxRetries + } - fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } + fun apiKey(apiKey: String?) = + apply { + this.apiKey = apiKey + } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun headers(headers: Headers) = apply { - this.headers.clear() - putAllHeaders(headers) - } - - fun headers(headers: Map>) = apply { - this.headers.clear() - putAllHeaders(headers) - } + fun headers(headers: Headers) = + apply { + this.headers.clear() + putAllHeaders(headers) + } - fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + fun headers(headers: Map>) = + apply { + this.headers.clear() + putAllHeaders(headers) + } - fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + fun putHeader(name: String, value: String) = + apply { + headers.put(name, value) + } - fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + fun putHeaders(name: String, values: Iterable) = + apply { + headers.put(name, values) + } - fun putAllHeaders(headers: Map>) = apply { - this.headers.putAll(headers) - } + fun putAllHeaders(headers: Headers) = + apply { + this.headers.putAll(headers) + } - fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + fun putAllHeaders(headers: Map>) = + apply { + this.headers.putAll(headers) + } - fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replace(name, values) - } + fun replaceHeaders(name: String, value: String) = + apply { + headers.replace(name, value) + } - fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + fun replaceHeaders(name: String, values: Iterable) = + apply { + headers.replace(name, values) + } - fun replaceAllHeaders(headers: Map>) = apply { - this.headers.replaceAll(headers) - } + fun replaceAllHeaders(headers: Headers) = + apply { + this.headers.replaceAll(headers) + } - fun removeHeaders(name: String) = apply { headers.remove(name) } + fun replaceAllHeaders(headers: Map>) = + apply { + this.headers.replaceAll(headers) + } - fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + fun removeHeaders(name: String) = + apply { + headers.remove(name) + } - fun queryParams(queryParams: QueryParams) = apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } + fun removeAllHeaders(names: Set) = + apply { + headers.removeAll(names) + } - fun queryParams(queryParams: Map>) = apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } + fun queryParams(queryParams: QueryParams) = + apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } - fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + fun queryParams(queryParams: Map>) = + apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } - fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.put(key, values) - } + fun putQueryParam(key: String, value: String) = + apply { + queryParams.put(key, value) + } - fun putAllQueryParams(queryParams: QueryParams) = apply { - this.queryParams.putAll(queryParams) - } + fun putQueryParams(key: String, values: Iterable) = + apply { + queryParams.put(key, values) + } - fun putAllQueryParams(queryParams: Map>) = apply { - this.queryParams.putAll(queryParams) - } + fun putAllQueryParams(queryParams: QueryParams) = + apply { + this.queryParams.putAll(queryParams) + } - fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replace(key, value) - } + fun putAllQueryParams(queryParams: Map>) = + apply { + this.queryParams.putAll(queryParams) + } - fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replace(key, values) - } + fun replaceQueryParams(key: String, value: String) = + apply { + queryParams.replace(key, value) + } - fun replaceAllQueryParams(queryParams: QueryParams) = apply { - this.queryParams.replaceAll(queryParams) - } + fun replaceQueryParams(key: String, values: Iterable) = + apply { + queryParams.replace(key, values) + } - fun replaceAllQueryParams(queryParams: Map>) = apply { - this.queryParams.replaceAll(queryParams) - } + fun replaceAllQueryParams(queryParams: QueryParams) = + apply { + this.queryParams.replaceAll(queryParams) + } - fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + fun replaceAllQueryParams(queryParams: Map>) = + apply { + this.queryParams.replaceAll(queryParams) + } - fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + fun removeQueryParams(key: String) = + apply { + queryParams.remove(key) + } - fun fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } } + fun removeAllQueryParams(keys: Set) = + apply { + queryParams.removeAll(keys) + } - fun build(): ClientOptions { - val httpClient = checkRequired("httpClient", httpClient) - - val headers = Headers.builder() - val queryParams = QueryParams.builder() - headers.put("X-Stainless-Lang", "java") - headers.put("X-Stainless-Arch", getOsArch()) - headers.put("X-Stainless-OS", getOsName()) - headers.put("X-Stainless-OS-Version", getOsVersion()) - headers.put("X-Stainless-Package-Version", getPackageVersion()) - headers.put("X-Stainless-Runtime", "JRE") - headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - apiKey?.let { - if (!it.isEmpty()) { - headers.put("Authorization", "Bearer $it") + fun fromEnv() = + apply { + System.getenv("BRAINTRUST_API_KEY")?.let { + apiKey(it) } } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) - - return ClientOptions( - httpClient, - PhantomReachableClosingHttpClient( - RetryingHttpClient.builder() - .httpClient(httpClient) - .clock(clock) - .maxRetries(maxRetries) - .build() - ), - jsonMapper, - clock, - baseUrl, - headers.build(), - queryParams.build(), - responseValidation, - timeout, - maxRetries, - apiKey, - ) + + fun build(): ClientOptions { + val httpClient = checkRequired( + "httpClient", httpClient + ) + + val headers = Headers.builder() + val queryParams = QueryParams.builder() + headers.put("X-Stainless-Lang", "java") + headers.put("X-Stainless-Arch", getOsArch()) + headers.put("X-Stainless-OS", getOsName()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime", "JRE") + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + apiKey?.let { + if (!it.isEmpty()) { + headers.put("Authorization", "Bearer $it") + } + } + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) + + return ClientOptions( + httpClient, + PhantomReachableClosingHttpClient(RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build()), + jsonMapper, + clock, + baseUrl, + headers.build(), + queryParams.build(), + responseValidation, + timeout, + maxRetries, + apiKey, + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt index 588027c6..048e0759 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt @@ -2,8 +2,6 @@ package com.braintrustdata.api.core -import com.braintrustdata.api.errors.BraintrustException -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.DeserializationFeature @@ -18,6 +16,8 @@ import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder +import com.braintrustdata.api.errors.BraintrustException +import com.braintrustdata.api.errors.BraintrustInvalidDataException import java.io.InputStream fun jsonMapper(): JsonMapper = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt index f98bf142..9c89c69c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt @@ -8,9 +8,6 @@ interface Params { /** The full set of headers in the parameters, including both fixed and additional headers. */ fun _headers(): Headers - /** - * The full set of query params in the parameters, including both fixed and additional query - * params. - */ + /** The full set of query params in the parameters, including both fixed and additional query params. */ fun _queryParams(): QueryParams } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt index e9aaadff..74b30572 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt @@ -6,7 +6,10 @@ import com.braintrustdata.api.core.http.HttpRequest import java.util.concurrent.CompletableFuture @JvmSynthetic -internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = +internal fun HttpRequest.prepare( + clientOptions: ClientOptions, + params: Params +): HttpRequest = toBuilder() .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params._queryParams()) @@ -17,8 +20,7 @@ internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): @JvmSynthetic internal fun HttpRequest.prepareAsync( clientOptions: ClientOptions, - params: Params, + params: Params ): CompletableFuture = - // This async version exists to make it easier to add async specific preparation logic in the - // future. + // This async version exists to make it easier to add async specific preparation logic in the future. CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt index a0924603..4c80349e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt @@ -9,12 +9,9 @@ fun getOsArch(): String { return when (osArch) { null -> "unknown" - "i386", - "x32", - "x86" -> "x32" - "amd64", - "x86_64" -> "x64" - "arm" -> "arm" + "i386", "x32", "x86" -> "x32" + "amd64", "x86_64" -> "x64" + "arm"-> "arm" "aarch64" -> "arm64" else -> "other:${osArch}" } @@ -36,7 +33,6 @@ fun getOsName(): String { fun getOsVersion(): String = System.getProperty("os.version", "unknown") -fun getPackageVersion(): String = - Properties::class.java.`package`.implementationVersion ?: "unknown" +fun getPackageVersion(): String = Properties::class.java.`package`.implementationVersion ?: "unknown" fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt index fe7c8372..d68148e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt @@ -2,7 +2,11 @@ package com.braintrustdata.api.core import java.time.Duration -class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { +class RequestOptions +private constructor( + val responseValidation: Boolean?, + val timeout: Timeout?, +) { companion object { @@ -37,7 +41,9 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t this.responseValidation = responseValidation } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + this.timeout = timeout + } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt index 6a0cdcc7..d07f5d3c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt @@ -8,12 +8,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** A class containing timeouts for various processing phases of a request. */ -class Timeout -private constructor( +class Timeout private constructor( private val connect: Duration?, private val read: Duration?, private val write: Duration?, private val request: Duration?, + ) { /** @@ -26,7 +26,8 @@ private constructor( fun connect(): Duration = connect ?: Duration.ofMinutes(1) /** - * The maximum time allowed between two data packets when waiting for the server’s response. + * The maximum time allowed between two data packets when waiting for the server’s + * response. * * A value of [Duration.ZERO] means there's no timeout. * @@ -35,7 +36,8 @@ private constructor( fun read(): Duration = read ?: request() /** - * The maximum time allowed between two data packets when sending the request to the server. + * The maximum time allowed between two data packets when sending the request to + * the server. * * A value of [Duration.ZERO] means there's no timeout. * @@ -46,8 +48,8 @@ private constructor( /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server processing, as well - * as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server + * processing, as well as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * @@ -59,10 +61,12 @@ private constructor( companion object { - @JvmStatic fun default() = builder().build() + @JvmStatic + fun default() = builder().build() /** Returns a mutable builder for constructing an instance of [Timeout]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Timeout]. */ @@ -74,12 +78,13 @@ private constructor( private var request: Duration? = null @JvmSynthetic - internal fun from(timeout: Timeout) = apply { - connect = timeout.connect - read = timeout.read - write = timeout.write - request = timeout.request - } + internal fun from(timeout: Timeout) = + apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } /** * The maximum time allowed to establish a connection with a host. @@ -88,7 +93,10 @@ private constructor( * * Defaults to `Duration.ofMinutes(1)`. */ - fun connect(connect: Duration?) = apply { this.connect = connect } + fun connect(connect: Duration?) = + apply { + this.connect = connect + } /** * The maximum time allowed to establish a connection with a host. @@ -100,16 +108,21 @@ private constructor( fun connect(connect: Optional) = connect(connect.getOrNull()) /** - * The maximum time allowed between two data packets when waiting for the server’s response. + * The maximum time allowed between two data packets when waiting for the server’s + * response. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `request()`. */ - fun read(read: Duration?) = apply { this.read = read } + fun read(read: Duration?) = + apply { + this.read = read + } /** - * The maximum time allowed between two data packets when waiting for the server’s response. + * The maximum time allowed between two data packets when waiting for the server’s + * response. * * A value of [Duration.ZERO] means there's no timeout. * @@ -118,16 +131,21 @@ private constructor( fun read(read: Optional) = read(read.getOrNull()) /** - * The maximum time allowed between two data packets when sending the request to the server. + * The maximum time allowed between two data packets when sending the request to + * the server. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `request()`. */ - fun write(write: Duration?) = apply { this.write = write } + fun write(write: Duration?) = + apply { + this.write = write + } /** - * The maximum time allowed between two data packets when sending the request to the server. + * The maximum time allowed between two data packets when sending the request to + * the server. * * A value of [Duration.ZERO] means there's no timeout. * @@ -138,20 +156,23 @@ private constructor( /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server processing, as - * well as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server + * processing, as well as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `Duration.ofMinutes(1)`. */ - fun request(request: Duration?) = apply { this.request = request } + fun request(request: Duration?) = + apply { + this.request = request + } /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server processing, as - * well as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server + * processing, as well as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * @@ -159,7 +180,13 @@ private constructor( */ fun request(request: Optional) = request(request.getOrNull()) - fun build(): Timeout = Timeout(connect, read, write, request) + fun build(): Timeout = + Timeout( + connect, + read, + write, + request, + ) } @JvmSynthetic @@ -175,15 +202,14 @@ private constructor( .build() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ - override fun toString() = - "Timeout{connect=$connect, read=$read, write=$write, request=$request}" + override fun toString() = "Timeout{connect=$connect, read=$read, write=$write, request=$request}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 6761ce6a..57ab7e19 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -18,7 +18,8 @@ internal fun List.toImmutable(): List = internal fun Map.toImmutable(): Map = if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) -@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() +@JvmSynthetic +internal fun immutableEmptyMap(): Map = Collections.emptyMap() @JvmSynthetic internal fun , V> SortedMap.toImmutable(): SortedMap = @@ -28,26 +29,26 @@ internal fun , V> SortedMap.toImmutable(): SortedMap { } /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API - * then this method will return an empty `Optional`, otherwise the returned `Optional` is given - * a `JsonValue`. + * If the "known" value (i.e. matching the type that the SDK expects) is returned + * by the API then this method will return an empty `Optional`, otherwise the + * returned `Optional` is given a `JsonValue`. */ fun asUnknown(): Optional = when (this) { @@ -88,8 +88,7 @@ sealed class JsonField { try { JsonValue.from(it) } catch (e: IllegalArgumentException) { - // The known value is a list, but not all values are convertible to - // `JsonValue`. + // The known value is a list, but not all values are convertible to `JsonValue`. return Optional.empty() } } @@ -112,8 +111,7 @@ sealed class JsonField { try { JsonValue.from(value) } catch (e: IllegalArgumentException) { - // The known value is a map, but not all items are convertible - // to `JsonValue`. + // The known value is a map, but not all items are convertible to `JsonValue`. return Optional.empty() } @@ -149,7 +147,8 @@ sealed class JsonField { is JsonValue -> this } - @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + @JvmSynthetic + fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) fun accept(visitor: Visitor): R = when (this) { @@ -157,12 +156,13 @@ sealed class JsonField { is JsonValue -> accept(visitor as JsonValue.Visitor) } - interface Visitor : JsonValue.Visitor { + interface Visitor: JsonValue.Visitor { fun visitKnown(value: T): R = visitDefault() } companion object { - @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + @JvmStatic + fun of(value: T): JsonField = KnownValue.of(value) @JvmStatic fun ofNullable(value: T?): JsonField = @@ -173,9 +173,8 @@ sealed class JsonField { } /** - * This class is a Jackson filter that can be used to exclude missing properties from objects. - * This filter should not be used directly and should instead use the @ExcludeMissing - * annotation. + * This class is a Jackson filter that can be used to exclude missing properties from objects. This filter + * should not be used directly and should instead use the @ExcludeMissing annotation. */ class IsMissing { override fun equals(other: Any?): Boolean = other is JsonMissing @@ -200,11 +199,11 @@ sealed class JsonField { } @JsonDeserialize(using = JsonValue.Deserializer::class) -sealed class JsonValue : JsonField() { +sealed class JsonValue: JsonField() { - fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) - fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) fun accept(visitor: Visitor): R = when (this) { @@ -219,19 +218,12 @@ sealed class JsonValue : JsonField() { interface Visitor { fun visitNull(): R = visitDefault() - fun visitMissing(): R = visitDefault() - fun visitBoolean(value: Boolean): R = visitDefault() - fun visitNumber(value: Number): R = visitDefault() - fun visitString(value: String): R = visitDefault() - fun visitArray(values: List): R = visitDefault() - fun visitObject(values: Map): R = visitDefault() - fun visitDefault(): R { throw RuntimeException("Unexpected value") } @@ -257,12 +249,8 @@ sealed class JsonValue : JsonField() { BOOLEAN -> JsonBoolean.of(node.booleanValue()) NUMBER -> JsonNumber.of(node.numberValue()) STRING -> JsonString.of(node.textValue()) - ARRAY -> - JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) - OBJECT -> - JsonObject.of( - node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap() - ) + ARRAY -> JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) + OBJECT -> JsonObject.of(node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap()) BINARY, POJO, null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") @@ -309,14 +297,11 @@ class JsonMissing : JsonValue() { @JvmStatic fun of() = INSTANCE } - class Serializer : BaseSerializer(JsonMissing::class) { - override fun serialize( - value: JsonMissing, - generator: JsonGenerator, - provider: SerializerProvider, - ) { + class Serializer: BaseSerializer(JsonMissing::class) { + override fun serialize(value: JsonMissing, generator: JsonGenerator, provider: SerializerProvider) { throw RuntimeException("JsonMissing cannot be serialized") } + } } @@ -417,7 +402,9 @@ private constructor( override fun toString() = values.toString() companion object { - @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) + @JsonCreator + @JvmStatic + fun of(values: List) = JsonArray(values.toImmutable()) } } @@ -448,7 +435,10 @@ private constructor( } @JacksonAnnotationsInside -@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) +@JsonInclude( + JsonInclude.Include.CUSTOM, + valueFilter = JsonField.IsMissing::class, +) annotation class ExcludeMissing @JacksonAnnotationsInside @@ -457,8 +447,7 @@ annotation class ExcludeMissing isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE, -) + fieldVisibility = Visibility.NONE) annotation class NoAutoDetect class MultipartField @@ -509,10 +498,7 @@ private constructor( return MultipartField( value, contentType - ?: if ( - value is KnownValue && - (value.value is InputStream || value.value is ByteArray) - ) + ?: if (value is KnownValue && (value.value is InputStream || value.value is ByteArray)) "application/octet-stream" else "text/plain; charset=utf-8", filename, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt index 12cfc384..28b08bfe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt @@ -2,19 +2,20 @@ package com.braintrustdata.api.core.handlers +import com.fasterxml.jackson.databind.json.JsonMapper import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BadRequestException -import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.errors.InternalServerException import com.braintrustdata.api.errors.NotFoundException import com.braintrustdata.api.errors.PermissionDeniedException import com.braintrustdata.api.errors.RateLimitException +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.errors.BraintrustException import com.braintrustdata.api.errors.UnauthorizedException import com.braintrustdata.api.errors.UnexpectedStatusCodeException import com.braintrustdata.api.errors.UnprocessableEntityException -import com.fasterxml.jackson.databind.json.JsonMapper import java.io.ByteArrayInputStream import java.io.InputStream diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt index ae855a7b..041ed543 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt @@ -2,11 +2,12 @@ package com.braintrustdata.api.core.handlers +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.braintrustdata.api.core.enhanceJacksonException import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.braintrustdata.api.errors.BraintrustException @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt index 6d37e804..5530338e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt @@ -1,12 +1,13 @@ package com.braintrustdata.api.core.http import com.braintrustdata.api.core.toImmutable +import java.util.Collections import java.util.TreeMap class Headers private constructor( private val map: Map>, - @get:JvmName("size") val size: Int, + @get:JvmName("size") val size: Int ) { fun isEmpty(): Boolean = map.isEmpty() @@ -74,7 +75,7 @@ private constructor( values.toImmutable() } .toImmutable(), - size, + size ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt index 5941bacd..b797df53 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt @@ -1,8 +1,8 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.core.RequestOptions import java.lang.AutoCloseable import java.util.concurrent.CompletableFuture +import com.braintrustdata.api.core.RequestOptions interface HttpClient : AutoCloseable { @@ -11,7 +11,8 @@ interface HttpClient : AutoCloseable { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + fun execute(request: HttpRequest): HttpResponse = + execute(request, RequestOptions.none()) fun executeAsync( request: HttpRequest, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index 1105f7d4..3ab2cb24 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -51,85 +51,129 @@ private constructor( this.pathSegments.addAll(pathSegments) } - fun headers(headers: Headers) = apply { - this.headers.clear() - putAllHeaders(headers) - } - - fun headers(headers: Map>) = apply { - this.headers.clear() - putAllHeaders(headers) - } - - fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - - fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } - - fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } - - fun putAllHeaders(headers: Map>) = apply { - this.headers.putAll(headers) - } - - fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } - - fun replaceHeaders(name: String, values: Iterable) = apply { - headers.replace(name, values) - } - - fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } - - fun replaceAllHeaders(headers: Map>) = apply { - this.headers.replaceAll(headers) - } - - fun removeHeaders(name: String) = apply { headers.remove(name) } - - fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } - - fun queryParams(queryParams: QueryParams) = apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } - - fun queryParams(queryParams: Map>) = apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } - - fun putQueryParams(key: String, values: Iterable) = apply { - queryParams.put(key, values) - } - - fun putAllQueryParams(queryParams: QueryParams) = apply { - this.queryParams.putAll(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = apply { - this.queryParams.putAll(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = apply { - queryParams.replace(key, value) - } - - fun replaceQueryParams(key: String, values: Iterable) = apply { - queryParams.replace(key, values) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = apply { - this.queryParams.replaceAll(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = apply { - this.queryParams.replaceAll(queryParams) - } - - fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - - fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + fun headers(headers: Headers) = + apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = + apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = + apply { + headers.put(name, value) + } + + fun putHeaders(name: String, values: Iterable) = + apply { + headers.put(name, values) + } + + fun putAllHeaders(headers: Headers) = + apply { + this.headers.putAll(headers) + } + + fun putAllHeaders(headers: Map>) = + apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = + apply { + headers.replace(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = + apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = + apply { + this.headers.replaceAll(headers) + } + + fun replaceAllHeaders(headers: Map>) = + apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = + apply { + headers.remove(name) + } + + fun removeAllHeaders(names: Set) = + apply { + headers.removeAll(names) + } + + fun queryParams(queryParams: QueryParams) = + apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = + apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = + apply { + queryParams.put(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = + apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = + apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = + apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = + apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = + apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = + apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = + apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = + apply { + queryParams.remove(key) + } + + fun removeAllQueryParams(keys: Set) = + apply { + queryParams.removeAll(keys) + } fun body(body: HttpRequestBody) = apply { this.body = body } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt index bb5b61ab..125e268b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt @@ -67,10 +67,7 @@ internal fun multipartFormData( .build() } - private fun serializePart( - name: String, - node: JsonNode, - ): Sequence> = + private fun serializePart(name: String, node: JsonNode): Sequence> = when (node.nodeType) { JsonNodeType.MISSING, JsonNodeType.NULL -> emptySequence() @@ -111,10 +108,7 @@ internal fun multipartFormData( serializePart("$name[$key]", value) } JsonNodeType.POJO, - null -> - throw BraintrustInvalidDataException( - "Unexpected JsonNode type: ${node.nodeType}" - ) + null -> throw BraintrustInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") } private fun String.toInputStream(): InputStream = ByteArrayInputStream(toByteArray()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt index ebf2b4d5..fae4bf81 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt @@ -12,11 +12,10 @@ interface HttpRequestBody : AutoCloseable { fun contentLength(): Long /** - * Determines if a request can be repeated in a meaningful way, for example before doing a - * retry. + * Determines if a request can be repeated in a meaningful way, for example before doing a retry. * - * The most typical case when a request can't be retried is if the request body is being - * streamed. In this case the body data isn't available on subsequent attempts. + * The most typical case when a request can't be retried is if the request body is being streamed. In this case the + * body data isn't available on subsequent attempts. */ fun repeatable(): Boolean diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt index e766e040..efd180a9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt @@ -19,7 +19,7 @@ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpCli override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions, + requestOptions: RequestOptions ): CompletableFuture = httpClient.executeAsync(request, requestOptions) override fun close() = httpClient.close() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt index 215eea16..2f2252b4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt @@ -5,7 +5,7 @@ import com.braintrustdata.api.core.toImmutable class QueryParams private constructor( private val map: Map>, - @get:JvmName("size") val size: Int, + @get:JvmName("size") val size: Int ) { fun isEmpty(): Boolean = map.isEmpty() @@ -69,7 +69,10 @@ private constructor( } fun build() = - QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size) + QueryParams( + map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), + size + ) } override fun hashCode(): Int = map.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 56bdac87..61d75ca3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -1,8 +1,8 @@ package com.braintrustdata.api.core.http +import com.braintrustdata.api.errors.BraintrustIoException import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.checkRequired -import com.braintrustdata.api.errors.BraintrustIoException import java.io.IOException import java.time.Clock import java.time.Duration @@ -22,13 +22,16 @@ import kotlin.math.pow class RetryingHttpClient private constructor( - private val httpClient: HttpClient, - private val clock: Clock, - private val maxRetries: Int, - private val idempotencyHeader: String?, + private val httpClient: HttpClient, + private val clock: Clock, + private val maxRetries: Int, + private val idempotencyHeader: String?, ) : HttpClient { - override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) } @@ -47,20 +50,20 @@ private constructor( } val response = - try { - val response = httpClient.execute(modifiedRequest, requestOptions) - if (++retries > maxRetries || !shouldRetry(response)) { - return response - } + try { + val response = httpClient.execute(modifiedRequest, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } - response - } catch (throwable: Throwable) { - if (++retries > maxRetries || !shouldRetry(throwable)) { - throw throwable - } + response + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable + } - null - } + null + } val backoffMillis = getRetryBackoffMillis(retries, response) // All responses must be closed, so close the failed one before retrying. @@ -70,8 +73,8 @@ private constructor( } override fun executeAsync( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): CompletableFuture { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.executeAsync(request, requestOptions) @@ -86,43 +89,42 @@ private constructor( var retries = 0 fun executeWithRetries( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): CompletableFuture { val requestWithRetryCount = if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request - return httpClient - .executeAsync(requestWithRetryCount, requestOptions) - .handleAsync( - fun( - response: HttpResponse?, - throwable: Throwable?, - ): CompletableFuture { - if (response != null) { - if (++retries > maxRetries || !shouldRetry(response)) { - return CompletableFuture.completedFuture(response) - } - } else { - if (++retries > maxRetries || !shouldRetry(throwable!!)) { - val failedFuture = CompletableFuture() - failedFuture.completeExceptionally(throwable) - return failedFuture - } - } - - val backoffMillis = getRetryBackoffMillis(retries, response) - // All responses must be closed, so close the failed one before retrying. - response?.close() - return sleepAsync(backoffMillis.toMillis()).thenCompose { - executeWithRetries(requestWithRetryCount, requestOptions) - } + return httpClient.executeAsync(requestWithRetryCount, requestOptions) + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable? + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + return sleepAsync(backoffMillis.toMillis()).thenCompose { + executeWithRetries(requestWithRetryCount, requestOptions) + } + }, + ) { + // Run in the same thread. + it.run() } - ) { - // Run in the same thread. - it.run() - } - .thenCompose(Function.identity()) + .thenCompose(Function.identity()) } return executeWithRetries(modifiedRequest, requestOptions) @@ -182,38 +184,30 @@ private constructor( private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After - response - ?.headers() - ?.let { headers -> - headers - .values("Retry-After-Ms") - .getOrNull(0) - ?.toFloatOrNull() - ?.times(TimeUnit.MILLISECONDS.toNanos(1)) + response?.headers()?.let { headers -> + headers.values("Retry-After-Ms").getOrNull(0)?.toFloatOrNull()?.times(TimeUnit.MILLISECONDS.toNanos(1)) ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) - ?: try { - ChronoUnit.MILLIS.between( - OffsetDateTime.now(clock), - OffsetDateTime.parse( - retryAfter, - DateTimeFormatter.RFC_1123_DATE_TIME, - ), - ) - } catch (e: DateTimeParseException) { - null - } + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME + ) + ) + } catch (e: DateTimeParseException) { + null + } } + }?.let { retryAfterNanos -> + // If the API asks us to wait a certain amount of time (and it's a reasonable amount), just + // do what it says. + val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) + if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { + return retryAfter } - ?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable - // amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter - } - } + } // Apply exponential backoff, but not more than the max. val backoffSeconds = min(0.5 * 2.0.pow(retries - 1), 8.0) @@ -231,17 +225,18 @@ private constructor( private fun sleepAsync(millis: Long): CompletableFuture { val future = CompletableFuture() TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis, + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + millis ) return future } - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder internal constructor() { @@ -260,11 +255,11 @@ private constructor( fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } fun build(): HttpClient = - RetryingHttpClient( - checkRequired("httpClient", httpClient), - clock, - maxRetries, - idempotencyHeader, - ) + RetryingHttpClient( + checkRequired("httpClient", httpClient), + clock, + maxRetries, + idempotencyHeader, + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt index b8c65254..83ec706e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class BadRequestException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(400, headers, body, error) +class BadRequestException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(400, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index afcc62d2..d2e399b6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -13,14 +13,9 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects @NoAutoDetect -class BraintrustError -@JsonCreator -private constructor( - @JsonAnyGetter - @ExcludeMissing - @JsonAnySetter - @get:JvmName("additionalProperties") - val additionalProperties: Map = immutableEmptyMap() +class BraintrustError @JsonCreator private constructor( + @JsonAnyGetter @ExcludeMissing @JsonAnySetter @get:JvmName("additionalProperties") val additionalProperties: Map = immutableEmptyMap(), + ) { fun toBuilder() = Builder().from(this) @@ -28,7 +23,8 @@ private constructor( companion object { /** Returns a mutable builder for constructing an instance of [BraintrustError]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [BraintrustError]. */ @@ -37,38 +33,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(braintrustError: BraintrustError) = apply { - additionalProperties = braintrustError.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(braintrustError: BraintrustError) = + apply { + additionalProperties = braintrustError.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): BraintrustError = BraintrustError(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt index d1fdfdee..78a326db 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt @@ -2,5 +2,4 @@ package com.braintrustdata.api.errors class BraintrustInvalidDataException @JvmOverloads -constructor(message: String? = null, cause: Throwable? = null) : - BraintrustException(message, cause) +constructor(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt index 6fb793a1..b7e0d934 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt @@ -2,5 +2,4 @@ package com.braintrustdata.api.errors class BraintrustIoException @JvmOverloads -constructor(message: String? = null, cause: Throwable? = null) : - BraintrustException(message, cause) +constructor(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt index 728ac6bd..fb883c12 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt @@ -5,12 +5,12 @@ import com.braintrustdata.api.core.http.Headers abstract class BraintrustServiceException @JvmOverloads constructor( - private val statusCode: Int, - private val headers: Headers, - private val body: String, - private val error: BraintrustError, - message: String = "$statusCode: $error", - cause: Throwable? = null, + private val statusCode: Int, + private val headers: Headers, + private val body: String, + private val error: BraintrustError, + message: String = "$statusCode: $error", + cause: Throwable? = null ) : BraintrustException(message, cause) { fun statusCode(): Int = statusCode diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt index 36cc4432..b2eadeb8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt @@ -3,8 +3,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers class InternalServerException( - statusCode: Int, - headers: Headers, - body: String, - error: BraintrustError, + statusCode: Int, + headers: Headers, + body: String, + error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt index ecc1a307..cd43aa64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class NotFoundException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(404, headers, body, error) +class NotFoundException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(404, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt index 27380e3e..72fb9d36 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class PermissionDeniedException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(403, headers, body, error) +class PermissionDeniedException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(403, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt index a9352a3a..be083e9c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class RateLimitException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(429, headers, body, error) +class RateLimitException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(429, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt index 57f9242f..d5541528 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class UnauthorizedException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(401, headers, body, error) +class UnauthorizedException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(401, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt index 7aa10d9b..c460ecad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt @@ -3,8 +3,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers class UnexpectedStatusCodeException( - statusCode: Int, - headers: Headers, - body: String, - error: BraintrustError, + statusCode: Int, + headers: Headers, + body: String, + error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt index 6e216b4e..b3d59795 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt @@ -2,5 +2,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class UnprocessableEntityException(headers: Headers, body: String, error: BraintrustError) : - BraintrustServiceException(422, headers, body, error) +class UnprocessableEntityException( + headers: Headers, + body: String, + error: BraintrustError, +) : BraintrustServiceException(422, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index baafa57f..7da801b6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -20,23 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class AISecret -@JsonCreator -private constructor( +class AISecret @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("preview_secret") - @ExcludeMissing - private val previewSecret: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("preview_secret") @ExcludeMissing private val previewSecret: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the AI secret */ @@ -53,30 +46,41 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - fun previewSecret(): Optional = - Optional.ofNullable(previewSecret.getNullable("preview_secret")) + fun previewSecret(): Optional = Optional.ofNullable(previewSecret.getNullable("preview_secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Unique identifier for the AI secret */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Date of AI secret creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonProperty("preview_secret") @ExcludeMissing fun _previewSecret(): JsonField = previewSecret - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -84,20 +88,21 @@ private constructor( private var validated: Boolean = false - fun validate(): AISecret = apply { - if (validated) { - return@apply - } + fun validate(): AISecret = + apply { + if (validated) { + return@apply + } - id() - name() - orgId() - created() - metadata().ifPresent { it.validate() } - previewSecret() - type() - validated = true - } + id() + name() + orgId() + created() + metadata().ifPresent { it.validate() } + previewSecret() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -107,13 +112,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [AISecret]. * * The following fields are required: + * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AISecret]. */ @@ -129,34 +136,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecret: AISecret) = apply { - id = aiSecret.id - name = aiSecret.name - orgId = aiSecret.orgId - created = aiSecret.created - metadata = aiSecret.metadata - previewSecret = aiSecret.previewSecret - type = aiSecret.type - additionalProperties = aiSecret.additionalProperties.toMutableMap() - } + internal fun from(aiSecret: AISecret) = + apply { + id = aiSecret.id + name = aiSecret.name + orgId = aiSecret.orgId + created = aiSecret.created + metadata = aiSecret.metadata + previewSecret = aiSecret.previewSecret + type = aiSecret.type + additionalProperties = aiSecret.additionalProperties.toMutableMap() + } /** Unique identifier for the AI secret */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the AI secret */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Date of AI secret creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -165,68 +182,87 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of AI secret creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } - fun previewSecret(previewSecret: String?) = - previewSecret(JsonField.ofNullable(previewSecret)) + fun previewSecret(previewSecret: String?) = previewSecret(JsonField.ofNullable(previewSecret)) - fun previewSecret(previewSecret: Optional) = - previewSecret(previewSecret.getOrNull()) + fun previewSecret(previewSecret: Optional) = previewSecret(previewSecret.getOrNull()) - fun previewSecret(previewSecret: JsonField) = apply { - this.previewSecret = previewSecret - } + fun previewSecret(previewSecret: JsonField) = + apply { + this.previewSecret = previewSecret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AISecret = AISecret( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("orgId", orgId), - created, - metadata, - previewSecret, - type, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + created, + metadata, + previewSecret, + type, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -235,20 +271,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -257,38 +295,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -301,11 +347,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -314,6 +360,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" } 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..0eb35bf2 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 @@ -22,48 +22,31 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on - * a project, they will also have read permissions on any experiment, dataset, etc. created within - * that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect -class Acl -@JsonCreator -private constructor( +class Acl @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_object_org_id") - @ExcludeMissing - private val _objectOrgId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("_object_org_id") @ExcludeMissing private val _objectOrgId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the acl */ @@ -82,31 +65,39 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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 = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the acl */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** The organization the ACL's referred object belongs to */ @JsonProperty("_object_org_id") @@ -114,7 +105,9 @@ private constructor( fun __objectOrgId(): JsonField = _objectOrgId /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -122,33 +115,49 @@ private constructor( fun _objectType(): JsonField = objectType /** Date of acl creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing 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 + /** + * 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 /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -156,23 +165,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Acl = apply { - if (validated) { - return@apply - } + fun validate(): Acl = + apply { + if (validated) { + return@apply + } - id() - _objectOrgId() - objectId() - objectType() - created() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } + id() + _objectOrgId() + objectId() + objectType() + created() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -182,6 +192,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Acl]. * * The following fields are required: + * * ```java * .id() * ._objectOrgId() @@ -189,7 +200,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Acl]. */ @@ -208,45 +220,56 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(acl: Acl) = apply { - id = acl.id - _objectOrgId = acl._objectOrgId - objectId = acl.objectId - objectType = acl.objectType - created = acl.created - groupId = acl.groupId - permission = acl.permission - restrictObjectType = acl.restrictObjectType - roleId = acl.roleId - userId = acl.userId - additionalProperties = acl.additionalProperties.toMutableMap() - } + internal fun from(acl: Acl) = + apply { + id = acl.id + _objectOrgId = acl._objectOrgId + objectId = acl.objectId + objectType = acl.objectType + created = acl.created + groupId = acl.groupId + permission = acl.permission + restrictObjectType = acl.restrictObjectType + roleId = acl.roleId + userId = acl.userId + additionalProperties = acl.additionalProperties.toMutableMap() + } /** Unique identifier for the acl */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the acl */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** The organization the ACL's referred object belongs to */ fun _objectOrgId(_objectOrgId: String) = _objectOrgId(JsonField.of(_objectOrgId)) /** The organization the ACL's referred object belongs to */ - fun _objectOrgId(_objectOrgId: JsonField) = apply { - this._objectOrgId = _objectOrgId - } + fun _objectOrgId(_objectOrgId: JsonField) = + apply { + this._objectOrgId = _objectOrgId + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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)) @@ -255,137 +278,182 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of acl creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = apply { this.permission = permission } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = 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`. + * 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) = - restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Acl = Acl( - checkRequired("id", id), - checkRequired("_objectOrgId", _objectOrgId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - created, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_objectOrgId", _objectOrgId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + created, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -433,9 +501,11 @@ private constructor( * 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 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 { @@ -451,17 +521,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -482,11 +553,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -507,23 +578,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -531,18 +599,25 @@ private constructor( 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 { + /** + * 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -581,9 +656,11 @@ private constructor( * 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 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 { @@ -596,17 +673,18 @@ private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -624,11 +702,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -646,23 +724,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -671,22 +746,24 @@ 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -731,12 +808,16 @@ private constructor( } /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. + * 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. * - * 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 { @@ -752,18 +833,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -784,11 +865,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -809,23 +890,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -834,11 +912,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Acl && id == other.id && _objectOrgId == other._objectOrgId && objectId == other.objectId && objectType == other.objectType && created == other.created && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Acl && id == other.id && _objectOrgId == other._objectOrgId && objectId == other.objectId && objectType == other.objectType && created == other.created && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -847,6 +925,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Acl{id=$id, _objectOrgId=$_objectOrgId, objectId=$objectId, objectType=$objectType, created=$created, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Acl{id=$id, _objectOrgId=$_objectOrgId, objectId=$objectId, objectType=$objectType, created=$created, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } 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..bf9e92e9 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 @@ -25,61 +25,70 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have no - * effect, and removing acls which do not exist will have no effect. + * Batch update acls. This operation is idempotent, so adding acls which already + * exist will have no effect, and removing acls which do not exist will have no + * effect. */ -class AclBatchUpdateParams -private constructor( +class AclBatchUpdateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(): Optional> = body.addAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun removeAcls(): Optional> = body.removeAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun _addAcls(): JsonField> = body._addAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun _removeAcls(): JsonField> = body._removeAcls() @@ -89,72 +98,76 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("add_acls") - @ExcludeMissing - private val addAcls: JsonField> = JsonMissing.of(), - @JsonProperty("remove_acls") - @ExcludeMissing - private val removeAcls: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("add_acls") @ExcludeMissing private val addAcls: JsonField> = JsonMissing.of(), + @JsonProperty("remove_acls") @ExcludeMissing private val removeAcls: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(): Optional> = Optional.ofNullable(addAcls.getNullable("add_acls")) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(): Optional> = - Optional.ofNullable(removeAcls.getNullable("remove_acls")) + fun removeAcls(): Optional> = Optional.ofNullable(removeAcls.getNullable("remove_acls")) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - @JsonProperty("add_acls") @ExcludeMissing fun _addAcls(): JsonField> = addAcls + @JsonProperty("add_acls") + @ExcludeMissing + fun _addAcls(): JsonField> = addAcls /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @JsonProperty("remove_acls") @ExcludeMissing @@ -166,22 +179,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - addAcls().ifPresent { it.forEach { it.validate() } } - removeAcls().ifPresent { it.forEach { it.validate() } } - validated = true - } + addAcls().ifPresent { it.forEach { it.validate() } } + removeAcls().ifPresent { it.forEach { it.validate() } } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -192,165 +207,181 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - addAcls = body.addAcls.map { it.toMutableList() } - removeAcls = body.removeAcls.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + addAcls = body.addAcls.map { it.toMutableList() } + removeAcls = body.removeAcls.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(addAcls: List?) = addAcls(JsonField.ofNullable(addAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAcls(addAcls: JsonField>) = apply { - this.addAcls = addAcls.map { it.toMutableList() } - } + fun addAcls(addAcls: JsonField>) = + apply { + this.addAcls = addAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAddAcl(addAcl: AddAcl) = apply { - addAcls = - (addAcls ?: JsonField.of(mutableListOf())).also { + fun addAddAcl(addAcl: AddAcl) = + apply { + addAcls = (addAcls ?: JsonField.of(mutableListOf())).also { checkKnown("addAcls", it).add(addAcl) } - } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: List?) = - removeAcls(JsonField.ofNullable(removeAcls)) + fun removeAcls(removeAcls: List?) = removeAcls(JsonField.ofNullable(removeAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: Optional>) = - removeAcls(removeAcls.getOrNull()) + fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: JsonField>) = apply { - this.removeAcls = removeAcls.map { it.toMutableList() } - } + fun removeAcls(removeAcls: JsonField>) = + apply { + this.removeAcls = removeAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { - removeAcls = - (removeAcls ?: JsonField.of(mutableListOf())).also { + fun addRemoveAcl(removeAcl: RemoveAcl) = + apply { + removeAcls = (removeAcls ?: JsonField.of(mutableListOf())).also { checkKnown("removeAcls", it).add(removeAcl) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, - (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, + (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -359,18 +390,22 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" + override fun toString() = "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): AclBatchUpdateParams = builder().build() + @JvmStatic + fun none(): AclBatchUpdateParams = builder().build() - /** Returns a mutable builder for constructing an instance of [AclBatchUpdateParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [AclBatchUpdateParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [AclBatchUpdateParams]. */ @@ -382,272 +417,325 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { - body = aclBatchUpdateParams.body.toBuilder() - additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = + apply { + body = aclBatchUpdateParams.body.toBuilder() + additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAcls(addAcls: List?) = apply { body.addAcls(addAcls) } + fun addAcls(addAcls: List?) = + apply { + body.addAcls(addAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAcls(addAcls: JsonField>) = apply { body.addAcls(addAcls) } + fun addAcls(addAcls: JsonField>) = + apply { + body.addAcls(addAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAddAcl(addAcl: AddAcl) = apply { body.addAddAcl(addAcl) } + fun addAddAcl(addAcl: AddAcl) = + apply { + body.addAddAcl(addAcl) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: List?) = apply { body.removeAcls(removeAcls) } + fun removeAcls(removeAcls: List?) = + apply { + body.removeAcls(removeAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removeAcls(removeAcls: JsonField>) = apply { - body.removeAcls(removeAcls) - } + fun removeAcls(removeAcls: JsonField>) = + apply { + body.removeAcls(removeAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { body.addRemoveAcl(removeAcl) } + fun addRemoveAcl(removeAcl: RemoveAcl) = + apply { + body.addRemoveAcl(removeAcl) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclBatchUpdateParams = AclBatchUpdateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect - class AddAcl - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class AddAcl @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the ACL applies to */ @@ -657,35 +745,39 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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 = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -693,34 +785,44 @@ private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * 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 + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -728,20 +830,21 @@ private constructor( private var validated: Boolean = false - fun validate(): AddAcl = apply { - if (validated) { - return@apply - } + fun validate(): AddAcl = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -751,12 +854,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [AddAcl]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AddAcl]. */ @@ -772,87 +877,98 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addAcl: AddAcl) = apply { - objectId = addAcl.objectId - objectType = addAcl.objectType - groupId = addAcl.groupId - permission = addAcl.permission - restrictObjectType = addAcl.restrictObjectType - roleId = addAcl.roleId - userId = addAcl.userId - additionalProperties = addAcl.additionalProperties.toMutableMap() - } + internal fun from(addAcl: AddAcl) = + apply { + objectId = addAcl.objectId + objectType = addAcl.objectType + groupId = addAcl.groupId + permission = addAcl.permission + restrictObjectType = addAcl.restrictObjectType + roleId = addAcl.roleId + userId = addAcl.userId + additionalProperties = addAcl.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * 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?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = 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`. + * 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) = - restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -870,71 +986,91 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AddAcl = AddAcl( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -982,9 +1118,11 @@ private constructor( * 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 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 { @@ -1010,8 +1148,8 @@ private constructor( * 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. + * 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) { @@ -1036,7 +1174,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1060,20 +1198,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1081,19 +1216,25 @@ private constructor( 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 { + /** + * 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1132,9 +1273,11 @@ private constructor( * 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 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 { @@ -1157,8 +1300,8 @@ private constructor( * 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. + * 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) { @@ -1180,7 +1323,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1201,20 +1344,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1223,22 +1363,24 @@ 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1288,9 +1430,11 @@ private constructor( * * 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 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 { @@ -1316,8 +1460,8 @@ private constructor( * 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. + * 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) { @@ -1342,7 +1486,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1357,8 +1501,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1367,20 +1510,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1389,11 +1529,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1402,47 +1542,32 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect - class RemoveAcl - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RemoveAcl @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the ACL applies to */ @@ -1452,35 +1577,39 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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 = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -1488,34 +1617,44 @@ private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * 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 + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -1523,20 +1662,21 @@ private constructor( private var validated: Boolean = false - fun validate(): RemoveAcl = apply { - if (validated) { - return@apply - } + fun validate(): RemoveAcl = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1546,12 +1686,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [RemoveAcl]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RemoveAcl]. */ @@ -1567,87 +1709,98 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeAcl: RemoveAcl) = apply { - objectId = removeAcl.objectId - objectType = removeAcl.objectType - groupId = removeAcl.groupId - permission = removeAcl.permission - restrictObjectType = removeAcl.restrictObjectType - roleId = removeAcl.roleId - userId = removeAcl.userId - additionalProperties = removeAcl.additionalProperties.toMutableMap() - } + internal fun from(removeAcl: RemoveAcl) = + apply { + objectId = removeAcl.objectId + objectType = removeAcl.objectType + groupId = removeAcl.groupId + permission = removeAcl.permission + restrictObjectType = removeAcl.restrictObjectType + roleId = removeAcl.roleId + userId = removeAcl.userId + additionalProperties = removeAcl.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * 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?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = 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`. + * 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) = - restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -1665,71 +1818,91 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveAcl = RemoveAcl( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1777,9 +1950,11 @@ private constructor( * 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 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 { @@ -1805,8 +1980,8 @@ private constructor( * 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. + * 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) { @@ -1831,7 +2006,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1855,20 +2030,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1876,19 +2048,25 @@ private constructor( 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 { + /** + * 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1927,9 +2105,11 @@ private constructor( * 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 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 { @@ -1952,8 +2132,8 @@ private constructor( * 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. + * 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) { @@ -1975,7 +2155,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1996,20 +2176,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2018,22 +2195,24 @@ 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2083,9 +2262,11 @@ private constructor( * * 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 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 { @@ -2111,8 +2292,8 @@ private constructor( * 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. + * 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) { @@ -2137,7 +2318,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2152,8 +2333,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -2162,20 +2342,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2184,11 +2361,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2197,20 +2374,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index eec25147..6c708b70 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -18,63 +18,68 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class AclBatchUpdateResponse -@JsonCreator -private constructor( - @JsonProperty("added_acls") - @ExcludeMissing - private val addedAcls: JsonField> = JsonMissing.of(), - @JsonProperty("removed_acls") - @ExcludeMissing - private val removedAcls: JsonField> = JsonMissing.of(), +class AclBatchUpdateResponse @JsonCreator private constructor( + @JsonProperty("added_acls") @ExcludeMissing private val addedAcls: JsonField> = JsonMissing.of(), + @JsonProperty("removed_acls") @ExcludeMissing private val removedAcls: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addedAcls(): List = addedAcls.getRequired("added_acls") /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun removedAcls(): List = removedAcls.getRequired("removed_acls") /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - @JsonProperty("added_acls") @ExcludeMissing fun _addedAcls(): JsonField> = addedAcls + @JsonProperty("added_acls") + @ExcludeMissing + fun _addedAcls(): JsonField> = addedAcls /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @JsonProperty("removed_acls") @ExcludeMissing @@ -86,30 +91,34 @@ private constructor( private var validated: Boolean = false - fun validate(): AclBatchUpdateResponse = apply { - if (validated) { - return@apply - } + fun validate(): AclBatchUpdateResponse = + apply { + if (validated) { + return@apply + } - addedAcls().forEach { it.validate() } - removedAcls().forEach { it.validate() } - validated = true - } + addedAcls().forEach { it.validate() } + removedAcls().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [AclBatchUpdateResponse]. + * Returns a mutable builder for constructing an instance of + * [AclBatchUpdateResponse]. * * The following fields are required: + * * ```java * .addedAcls() * .removedAcls() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclBatchUpdateResponse]. */ @@ -120,131 +129,157 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclBatchUpdateResponse: AclBatchUpdateResponse) = apply { - addedAcls = aclBatchUpdateResponse.addedAcls.map { it.toMutableList() } - removedAcls = aclBatchUpdateResponse.removedAcls.map { it.toMutableList() } - additionalProperties = aclBatchUpdateResponse.additionalProperties.toMutableMap() - } + internal fun from(aclBatchUpdateResponse: AclBatchUpdateResponse) = + apply { + addedAcls = aclBatchUpdateResponse.addedAcls.map { it.toMutableList() } + removedAcls = aclBatchUpdateResponse.removedAcls.map { it.toMutableList() } + additionalProperties = aclBatchUpdateResponse.additionalProperties.toMutableMap() + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun addedAcls(addedAcls: List) = addedAcls(JsonField.of(addedAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addedAcls(addedAcls: JsonField>) = apply { - this.addedAcls = addedAcls.map { it.toMutableList() } - } + fun addedAcls(addedAcls: JsonField>) = + apply { + this.addedAcls = addedAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addAddedAcl(addedAcl: Acl) = apply { - addedAcls = - (addedAcls ?: JsonField.of(mutableListOf())).also { + fun addAddedAcl(addedAcl: Acl) = + apply { + addedAcls = (addedAcls ?: JsonField.of(mutableListOf())).also { checkKnown("addedAcls", it).add(addedAcl) } - } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ fun removedAcls(removedAcls: List) = removedAcls(JsonField.of(removedAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun removedAcls(removedAcls: JsonField>) = apply { - this.removedAcls = removedAcls.map { it.toMutableList() } - } + fun removedAcls(removedAcls: JsonField>) = + apply { + this.removedAcls = removedAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ - fun addRemovedAcl(removedAcl: Acl) = apply { - removedAcls = - (removedAcls ?: JsonField.of(mutableListOf())).also { + fun addRemovedAcl(removedAcl: Acl) = + apply { + removedAcls = (removedAcls ?: JsonField.of(mutableListOf())).also { checkKnown("removedAcls", it).add(removedAcl) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AclBatchUpdateResponse = AclBatchUpdateResponse( - checkRequired("addedAcls", addedAcls).map { it.toImmutable() }, - checkRequired("removedAcls", removedAcls).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "addedAcls", addedAcls + ).map { it.toImmutable() }, + checkRequired( + "removedAcls", removedAcls + ).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclBatchUpdateResponse && addedAcls == other.addedAcls && removedAcls == other.removedAcls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateResponse && addedAcls == other.addedAcls && removedAcls == other.removedAcls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -253,6 +288,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" + override fun toString() = "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" } 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..5cb6f558 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 @@ -24,14 +24,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in the - * request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one + * specified in the request, will return the existing acl unmodified */ -class AclCreateParams -private constructor( +class AclCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The id of the object the ACL applies to */ @@ -41,24 +41,32 @@ private constructor( fun objectType(): ObjectType = body.objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = body.groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(): Optional = body.permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun roleId(): Optional = body.roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = body.userId() @@ -69,24 +77,32 @@ private constructor( fun _objectType(): JsonField = body._objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun _groupId(): JsonField = body._groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun _permission(): JsonField = body._permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun _roleId(): JsonField = body._roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun _userId(): JsonField = body._userId() @@ -96,49 +112,36 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the ACL applies to */ @@ -148,35 +151,39 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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 = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -184,34 +191,44 @@ private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * 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 + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -219,21 +236,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true } - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -242,12 +260,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -263,87 +283,98 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - objectId = body.objectId - objectType = body.objectType - groupId = body.groupId - permission = body.permission - restrictObjectType = body.restrictObjectType - roleId = body.roleId - userId = body.userId - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + objectId = body.objectId + objectType = body.objectType + groupId = body.groupId + permission = body.permission + restrictObjectType = body.restrictObjectType + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * 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?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = 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`. + * 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) = - restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -361,64 +392,81 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -427,8 +475,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -439,12 +486,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [AclCreateParams]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclCreateParams]. */ @@ -456,240 +505,332 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclCreateParams: AclCreateParams) = apply { - body = aclCreateParams.body.toBuilder() - additionalHeaders = aclCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = aclCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(aclCreateParams: AclCreateParams) = + apply { + body = aclCreateParams.body.toBuilder() + additionalHeaders = aclCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclCreateParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + 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: ObjectType) = + 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 - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: String?) = apply { body.groupId(groupId) } + fun groupId(groupId: String?) = + apply { + body.groupId(groupId) + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } + fun groupId(groupId: JsonField) = + apply { + body.groupId(groupId) + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission?) = apply { body.permission(permission) } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: Permission?) = + apply { + body.permission(permission) + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = apply { body.permission(permission) } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: JsonField) = + apply { + body.permission(permission) + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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 { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + apply { + body.restrictObjectType(restrictObjectType) + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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) = - restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + body.restrictObjectType(restrictObjectType) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: String?) = apply { body.roleId(roleId) } + fun roleId(roleId: String?) = + apply { + body.roleId(roleId) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } + fun roleId(roleId: JsonField) = + apply { + body.roleId(roleId) + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclCreateParams = - AclCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -737,9 +878,11 @@ private constructor( * 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 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 { @@ -755,17 +898,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -786,11 +930,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -811,23 +955,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -835,18 +976,25 @@ private constructor( 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 { + /** + * 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -885,9 +1033,11 @@ private constructor( * 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 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 { @@ -900,17 +1050,18 @@ private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -928,11 +1079,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -950,23 +1101,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -975,22 +1123,24 @@ 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1035,12 +1185,16 @@ private constructor( } /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. + * 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. * - * 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 { @@ -1056,18 +1210,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -1088,11 +1242,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1113,23 +1267,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1138,15 +1289,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 53bbe12f..91337103 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an acl object by its id */ -class AclDeleteParams -private constructor( +class AclDeleteParams private constructor( private val aclId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Acl id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [AclDeleteParams]. * * The following fields are required: + * * ```java * .aclId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclDeleteParams: AclDeleteParams) = apply { - aclId = aclDeleteParams.aclId - additionalHeaders = aclDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aclDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aclDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(aclDeleteParams: AclDeleteParams) = + apply { + aclId = aclDeleteParams.aclId + additionalHeaders = aclDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aclDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aclDeleteParams.additionalBodyProperties.toMutableMap() + } /** Acl id */ - fun aclId(aclId: String) = apply { this.aclId = aclId } + fun aclId(aclId: String) = + apply { + this.aclId = aclId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): AclDeleteParams = AclDeleteParams( - checkRequired("aclId", aclId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "aclId", aclId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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..7281b052 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 @@ -24,11 +24,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Delete a single acl */ -class AclFindAndDeleteParams -private constructor( +class AclFindAndDeleteParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The id of the object the ACL applies to */ @@ -38,24 +38,32 @@ private constructor( fun objectType(): ObjectType = body.objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = body.groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(): Optional = body.permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun roleId(): Optional = body.roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = body.userId() @@ -66,24 +74,32 @@ private constructor( fun _objectType(): JsonField = body._objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun _groupId(): JsonField = body._groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun _permission(): JsonField = body._permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun _roleId(): JsonField = body._roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun _userId(): JsonField = body._userId() @@ -93,49 +109,36 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * An ACL grants a certain permission or role to a certain user or group on an + * object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has + * read permissions on a project, they will also have read permissions on any + * experiment, dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as + * part of a role. */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the ACL applies to */ @@ -145,35 +148,39 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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 = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -181,34 +188,44 @@ private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to + * just the specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * 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 + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -216,21 +233,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true } - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -239,12 +257,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -260,87 +280,98 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - objectId = body.objectId - objectType = body.objectType - groupId = body.groupId - permission = body.permission - restrictObjectType = body.restrictObjectType - roleId = body.roleId - userId = body.userId - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + objectId = body.objectId + objectType = body.objectType + groupId = body.groupId + permission = body.permission + restrictObjectType = body.restrictObjectType + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to just - * the specified object type. Cannot be set alongside a `role_id`. + * 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?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = 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`. + * 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) = - restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -358,64 +389,81 @@ private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = + apply { + this.roleId = roleId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -424,8 +472,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -433,15 +480,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AclFindAndDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [AclFindAndDeleteParams]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclFindAndDeleteParams]. */ @@ -453,244 +503,332 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclFindAndDeleteParams: AclFindAndDeleteParams) = apply { - body = aclFindAndDeleteParams.body.toBuilder() - additionalHeaders = aclFindAndDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aclFindAndDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(aclFindAndDeleteParams: AclFindAndDeleteParams) = + apply { + body = aclFindAndDeleteParams.body.toBuilder() + additionalHeaders = aclFindAndDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aclFindAndDeleteParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + 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: ObjectType) = + 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 - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: String?) = apply { body.groupId(groupId) } + fun groupId(groupId: String?) = + apply { + body.groupId(groupId) + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } + fun groupId(groupId: JsonField) = + apply { + body.groupId(groupId) + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission?) = apply { body.permission(permission) } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: Permission?) = + apply { + body.permission(permission) + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = apply { body.permission(permission) } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: JsonField) = + apply { + body.permission(permission) + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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 { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + apply { + body.restrictObjectType(restrictObjectType) + } /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * 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) = - restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + body.restrictObjectType(restrictObjectType) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: String?) = apply { body.roleId(roleId) } + fun roleId(roleId: String?) = + apply { + body.roleId(roleId) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided */ - fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } + fun roleId(roleId: JsonField) = + apply { + body.roleId(roleId) + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclFindAndDeleteParams = AclFindAndDeleteParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -738,9 +876,11 @@ private constructor( * 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 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 { @@ -756,17 +896,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -787,11 +928,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -812,23 +953,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -836,18 +974,25 @@ private constructor( 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 { + /** + * 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -886,9 +1031,11 @@ private constructor( * 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 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 { @@ -901,17 +1048,18 @@ private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -929,11 +1077,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -951,23 +1099,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -976,22 +1121,24 @@ 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1036,12 +1183,16 @@ private constructor( } /** - * An enum containing [RestrictObjectType]'s known values, as well as an [_UNKNOWN] member. + * 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. * - * 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 { @@ -1057,18 +1208,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -1089,11 +1240,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1114,23 +1265,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1139,15 +1287,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index f265a4be..e4cc0a07 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.AclService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ -class AclListPage -private constructor( +class AclListPage private constructor( private val aclsService: AclService, private val params: AclListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListPage && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AclListPage && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ - override fun toString() = - "AclListPage{aclsService=$aclsService, params=$params, response=$response}" + override fun toString() = "AclListPage{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - AclListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - AclListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(AclListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(AclListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { aclsService.list(it) } + return getNextPageParams().map { aclsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(aclsService: AclService, params: AclListParams, response: Response) = - AclListPage(aclsService, params, response) + AclListPage( + aclsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AclListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: AclListPage) : Iterable { + class AutoPager( + private val firstPage: AclListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index 9d691383..e5906d51 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.AclServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ -class AclListPageAsync -private constructor( +class AclListPageAsync private constructor( private val aclsService: AclServiceAsync, private val params: AclListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListPageAsync && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AclListPageAsync && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ - override fun toString() = - "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" + override fun toString() = "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - AclListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - AclListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(AclListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(AclListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { aclsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + aclsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(aclsService: AclServiceAsync, params: AclListParams, response: Response) = - AclListPageAsync(aclsService, params, response) + AclListPageAsync( + aclsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AclListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: AclListPageAsync) { + class AutoPager( + private val firstPage: AclListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Acl) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Acl) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } 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..2a622bec 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 @@ -27,11 +27,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ -class AclListParams -private constructor( +class AclListParams private constructor( private val objectId: String, private val objectType: ObjectType, private val endingBefore: String?, @@ -40,6 +39,7 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The id of the object the ACL applies to */ @@ -51,15 +51,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -69,9 +69,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -82,15 +82,39 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { + queryParams.put( + "object_id", listOf(it.toString()) + ) + } + this.objectType.let { + queryParams.put( + "object_type", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) @@ -101,12 +125,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [AclListParams]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclListParams]. */ @@ -123,67 +149,83 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclListParams: AclListParams) = apply { - objectId = aclListParams.objectId - objectType = aclListParams.objectType - endingBefore = aclListParams.endingBefore - ids = aclListParams.ids - limit = aclListParams.limit - startingAfter = aclListParams.startingAfter - additionalHeaders = aclListParams.additionalHeaders.toBuilder() - additionalQueryParams = aclListParams.additionalQueryParams.toBuilder() - } + internal fun from(aclListParams: AclListParams) = + apply { + objectId = aclListParams.objectId + objectType = aclListParams.objectType + endingBefore = aclListParams.endingBefore + ids = aclListParams.ids + limit = aclListParams.limit + startingAfter = aclListParams.startingAfter + additionalHeaders = aclListParams.additionalHeaders.toBuilder() + additionalQueryParams = aclListParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + 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: ObjectType) = + apply { + this.objectType = objectType + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -194,145 +236,181 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclListParams = AclListParams( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - endingBefore, - ids, - limit, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + endingBefore, + ids, + limit, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -380,9 +458,11 @@ private constructor( * 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 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 { @@ -398,17 +478,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -429,11 +510,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -454,23 +535,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -479,16 +557,16 @@ private constructor( } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -506,19 +584,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -533,12 +611,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -548,60 +631,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index a91c07d2..edd1a180 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an acl object by its id */ -class AclRetrieveParams -private constructor( +class AclRetrieveParams private constructor( private val aclId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Acl id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,11 +43,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [AclRetrieveParams]. * * The following fields are required: + * * ```java * .aclId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AclRetrieveParams]. */ @@ -59,131 +61,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclRetrieveParams: AclRetrieveParams) = apply { - aclId = aclRetrieveParams.aclId - additionalHeaders = aclRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = aclRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(aclRetrieveParams: AclRetrieveParams) = + apply { + aclId = aclRetrieveParams.aclId + additionalHeaders = aclRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = aclRetrieveParams.additionalQueryParams.toBuilder() + } /** Acl id */ - fun aclId(aclId: String) = apply { this.aclId = aclId } + fun aclId(aclId: String) = + apply { + this.aclId = aclId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclRetrieveParams = AclRetrieveParams( - checkRequired("aclId", aclId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "aclId", aclId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 4de28c65..a8215c3d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -22,14 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as the one specified - * in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as + * the one specified in the request, will return the existing ai_secret unmodified */ -class AiSecretCreateParams -private constructor( +class AiSecretCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the AI secret */ @@ -38,15 +38,15 @@ private constructor( fun metadata(): Optional = body.metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = body.orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(): Optional = body.secret() @@ -58,15 +58,15 @@ private constructor( fun _metadata(): JsonField = body._metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun _secret(): JsonField = body._secret() @@ -78,33 +78,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("secret") - @ExcludeMissing - private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the AI secret */ @@ -113,39 +102,49 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + @JsonProperty("secret") + @ExcludeMissing + fun _secret(): JsonField = secret - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -153,19 +152,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + metadata().ifPresent { it.validate() } + orgName() + secret() + type() + validated = true } - name() - metadata().ifPresent { it.validate() } - orgName() - secret() - type() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -174,11 +174,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -192,108 +194,133 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - metadata = body.metadata - orgName = body.orgName - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + metadata = body.metadata + orgName = body.orgName + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: JsonField) = apply { this.secret = secret } + fun secret(secret: JsonField) = + apply { + this.secret = secret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = + apply { + this.type = type + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - metadata, - orgName, - secret, - type, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + metadata, + orgName, + secret, + type, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -302,8 +329,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -311,14 +337,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretCreateParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretCreateParams]. */ @@ -330,200 +359,263 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretCreateParams: AiSecretCreateParams) = apply { - body = aiSecretCreateParams.body.toBuilder() - additionalHeaders = aiSecretCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretCreateParams: AiSecretCreateParams) = + apply { + body = aiSecretCreateParams.body.toBuilder() + additionalHeaders = aiSecretCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretCreateParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the AI secret */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: String?) = apply { body.secret(secret) } + fun secret(secret: String?) = + apply { + body.secret(secret) + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: JsonField) = apply { body.secret(secret) } + fun secret(secret: JsonField) = + apply { + body.secret(secret) + } - fun type(type: String?) = apply { body.type(type) } + fun type(type: String?) = + apply { + body.type(type) + } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { body.type(type) } + fun type(type: JsonField) = + apply { + body.type(type) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretCreateParams = AiSecretCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -532,20 +624,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -554,38 +648,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -598,15 +700,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index b62db648..3cbf2d45 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an ai_secret object by its id */ -class AiSecretDeleteParams -private constructor( +class AiSecretDeleteParams private constructor( private val aiSecretId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** AiSecret id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretDeleteParams]. * * The following fields are required: + * * ```java * .aiSecretId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretDeleteParams]. */ @@ -70,155 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecretDeleteParams: AiSecretDeleteParams) = apply { - aiSecretId = aiSecretDeleteParams.aiSecretId - additionalHeaders = aiSecretDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aiSecretDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(aiSecretDeleteParams: AiSecretDeleteParams) = + apply { + aiSecretId = aiSecretDeleteParams.aiSecretId + additionalHeaders = aiSecretDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aiSecretDeleteParams.additionalBodyProperties.toMutableMap() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } + fun aiSecretId(aiSecretId: String) = + apply { + this.aiSecretId = aiSecretId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): AiSecretDeleteParams = AiSecretDeleteParams( - checkRequired("aiSecretId", aiSecretId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "aiSecretId", aiSecretId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 09e2cfab..ffce1c86 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -22,20 +22,20 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Delete a single ai_secret */ -class AiSecretFindAndDeleteParams -private constructor( +class AiSecretFindAndDeleteParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the AI secret */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = body.orgName() @@ -43,9 +43,9 @@ private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -55,45 +55,44 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the AI secret */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -101,15 +100,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - orgName() - validated = true - } + name() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -119,11 +119,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -134,68 +136,88 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) + Body( + checkRequired( + "name", name + ), + orgName, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -204,8 +226,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -213,14 +234,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretFindAndDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretFindAndDeleteParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretFindAndDeleteParams]. */ @@ -232,174 +256,220 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = apply { - body = aiSecretFindAndDeleteParams.body.toBuilder() - additionalHeaders = aiSecretFindAndDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretFindAndDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = + apply { + body = aiSecretFindAndDeleteParams.body.toBuilder() + additionalHeaders = aiSecretFindAndDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretFindAndDeleteParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the AI secret */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretFindAndDeleteParams = AiSecretFindAndDeleteParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index 31ca38f9..cb07762e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.AiSecretService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ -class AiSecretListPage -private constructor( +class AiSecretListPage private constructor( private val aiSecretsService: AiSecretService, private val params: AiSecretListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListPage && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AiSecretListPage && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ - override fun toString() = - "AiSecretListPage{aiSecretsService=$aiSecretsService, params=$params, response=$response}" + override fun toString() = "AiSecretListPage{aiSecretsService=$aiSecretsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - AiSecretListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - AiSecretListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(AiSecretListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(AiSecretListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { aiSecretsService.list(it) } + return getNextPageParams().map { aiSecretsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -84,16 +74,18 @@ private constructor( @JvmStatic fun of(aiSecretsService: AiSecretService, params: AiSecretListParams, response: Response) = - AiSecretListPage(aiSecretsService, params, response) + AiSecretListPage( + aiSecretsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -107,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AiSecretListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -143,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: AiSecretListPage) : Iterable { + class AutoPager( + private val firstPage: AiSecretListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 09526724..0808cf83 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.AiSecretServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ -class AiSecretListPageAsync -private constructor( +class AiSecretListPageAsync private constructor( private val aiSecretsService: AiSecretServiceAsync, private val params: AiSecretListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListPageAsync && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AiSecretListPageAsync && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ - override fun toString() = - "AiSecretListPageAsync{aiSecretsService=$aiSecretsService, params=$params, response=$response}" + override fun toString() = "AiSecretListPageAsync{aiSecretsService=$aiSecretsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - AiSecretListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - AiSecretListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(AiSecretListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(AiSecretListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { aiSecretsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + aiSecretsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,20 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - aiSecretsService: AiSecretServiceAsync, - params: AiSecretListParams, - response: Response, - ) = AiSecretListPageAsync(aiSecretsService, params, response) + fun of(aiSecretsService: AiSecretServiceAsync, params: AiSecretListParams, response: Response) = + AiSecretListPageAsync( + aiSecretsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -112,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [AiSecretListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -150,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: AiSecretListPageAsync) { + class AutoPager( + private val firstPage: AiSecretListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (AISecret) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (AISecret) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index d41f9f78..34a3b048 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ -class AiSecretListParams -private constructor( +class AiSecretListParams private constructor( private val aiSecretName: String?, private val aiSecretType: AiSecretType?, private val endingBefore: String?, @@ -37,6 +36,7 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the ai_secret to search for */ @@ -47,15 +47,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -68,9 +68,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -81,26 +81,56 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.aiSecretName?.let { queryParams.put("ai_secret_name", listOf(it.toString())) } - this.aiSecretType?.let { queryParams.put("ai_secret_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.aiSecretName?.let { + queryParams.put( + "ai_secret_name", listOf(it.toString()) + ) + } + this.aiSecretType?.let { + queryParams.put( + "ai_secret_type", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): AiSecretListParams = builder().build() + @JvmStatic + fun none(): AiSecretListParams = builder().build() /** Returns a mutable builder for constructing an instance of [AiSecretListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretListParams]. */ @@ -118,78 +148,92 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretListParams: AiSecretListParams) = apply { - aiSecretName = aiSecretListParams.aiSecretName - aiSecretType = aiSecretListParams.aiSecretType - endingBefore = aiSecretListParams.endingBefore - ids = aiSecretListParams.ids - limit = aiSecretListParams.limit - orgName = aiSecretListParams.orgName - startingAfter = aiSecretListParams.startingAfter - additionalHeaders = aiSecretListParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretListParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretListParams: AiSecretListParams) = + apply { + aiSecretName = aiSecretListParams.aiSecretName + aiSecretType = aiSecretListParams.aiSecretType + endingBefore = aiSecretListParams.endingBefore + ids = aiSecretListParams.ids + limit = aiSecretListParams.limit + orgName = aiSecretListParams.orgName + startingAfter = aiSecretListParams.startingAfter + additionalHeaders = aiSecretListParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretListParams.additionalQueryParams.toBuilder() + } /** Name of the ai_secret to search for */ - fun aiSecretName(aiSecretName: String?) = apply { this.aiSecretName = aiSecretName } + fun aiSecretName(aiSecretName: String?) = + apply { + this.aiSecretName = aiSecretName + } /** Name of the ai_secret to search for */ fun aiSecretName(aiSecretName: Optional) = aiSecretName(aiSecretName.getOrNull()) - fun aiSecretType(aiSecretType: AiSecretType?) = apply { this.aiSecretType = aiSecretType } + fun aiSecretType(aiSecretType: AiSecretType?) = + apply { + this.aiSecretType = aiSecretType + } - fun aiSecretType(aiSecretType: Optional) = - aiSecretType(aiSecretType.getOrNull()) + fun aiSecretType(aiSecretType: Optional) = aiSecretType(aiSecretType.getOrNull()) fun aiSecretType(string: String) = aiSecretType(AiSecretType.ofString(string)) - fun aiSecretTypeOfStrings(strings: List) = - aiSecretType(AiSecretType.ofStrings(strings)) + fun aiSecretTypeOfStrings(strings: List) = aiSecretType(AiSecretType.ofStrings(strings)) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -198,7 +242,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -206,141 +253,169 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretListParams = AiSecretListParams( - aiSecretName, - aiSecretType, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + aiSecretName, + aiSecretType, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = AiSecretType.Deserializer::class) @JsonSerialize(using = AiSecretType.Serializer::class) - class AiSecretType - private constructor( + class AiSecretType private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -358,19 +433,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretType && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is AiSecretType && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -385,14 +460,16 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = AiSecretType(string = string) + @JvmStatic + fun ofString(string: String) = AiSecretType(string = string) - @JvmStatic fun ofStrings(strings: List) = AiSecretType(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = AiSecretType(strings = strings) } /** - * An interface that defines how to map each variant of [AiSecretType] to a value of type - * [T]. + * An interface that defines how to map each variant of [AiSecretType] to a value + * of type [T]. */ interface Visitor { @@ -403,62 +480,58 @@ private constructor( /** * Maps an unknown variant of [AiSecretType] to a value of type [T]. * - * An instance of [AiSecretType] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [AiSecretType] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown AiSecretType: $json") + throw BraintrustInvalidDataException("Unknown AiSecretType: $json") } } internal class Deserializer : BaseDeserializer(AiSecretType::class) { override fun ObjectCodec.deserialize(node: JsonNode): AiSecretType { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return AiSecretType(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return AiSecretType(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return AiSecretType(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return AiSecretType(strings = it, _json = json) + } - return AiSecretType(_json = json) + return AiSecretType(_json = json) } } internal class Serializer : BaseSerializer(AiSecretType::class) { - override fun serialize( - value: AiSecretType, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid AiSecretType") - } + override fun serialize(value: AiSecretType, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AiSecretType") + } } } } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -476,19 +549,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -503,12 +576,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -518,60 +596,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 30fafd07..2f6d1f04 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will replace the existing ai_secret with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same + * name as the one specified in the request, will replace the existing ai_secret + * with the provided fields */ -class AiSecretReplaceParams -private constructor( +class AiSecretReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the AI secret */ @@ -38,15 +39,15 @@ private constructor( fun metadata(): Optional = body.metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = body.orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(): Optional = body.secret() @@ -58,15 +59,15 @@ private constructor( fun _metadata(): JsonField = body._metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun _secret(): JsonField = body._secret() @@ -78,33 +79,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("secret") - @ExcludeMissing - private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the AI secret */ @@ -113,39 +103,49 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + @JsonProperty("secret") + @ExcludeMissing + fun _secret(): JsonField = secret - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -153,19 +153,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + metadata().ifPresent { it.validate() } + orgName() + secret() + type() + validated = true } - name() - metadata().ifPresent { it.validate() } - orgName() - secret() - type() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -174,11 +175,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -192,108 +195,133 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - metadata = body.metadata - orgName = body.orgName - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + metadata = body.metadata + orgName = body.orgName + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: JsonField) = apply { this.secret = secret } + fun secret(secret: JsonField) = + apply { + this.secret = secret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = + apply { + this.type = type + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - metadata, - orgName, - secret, - type, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + metadata, + orgName, + secret, + type, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -302,8 +330,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -311,14 +338,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretReplaceParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretReplaceParams]. */ @@ -330,200 +360,263 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretReplaceParams: AiSecretReplaceParams) = apply { - body = aiSecretReplaceParams.body.toBuilder() - additionalHeaders = aiSecretReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretReplaceParams: AiSecretReplaceParams) = + apply { + body = aiSecretReplaceParams.body.toBuilder() + additionalHeaders = aiSecretReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the AI secret */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: String?) = apply { body.secret(secret) } + fun secret(secret: String?) = + apply { + body.secret(secret) + } /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be + * left intact, not replaced with null. */ - fun secret(secret: JsonField) = apply { body.secret(secret) } + fun secret(secret: JsonField) = + apply { + body.secret(secret) + } - fun type(type: String?) = apply { body.type(type) } + fun type(type: String?) = + apply { + body.type(type) + } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { body.type(type) } + fun type(type: JsonField) = + apply { + body.type(type) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretReplaceParams = AiSecretReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -532,20 +625,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -554,38 +649,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -598,15 +701,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index 63959bb2..4319dc92 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an ai_secret object by its id */ -class AiSecretRetrieveParams -private constructor( +class AiSecretRetrieveParams private constructor( private val aiSecretId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** AiSecret id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretRetrieveParams]. * * The following fields are required: + * * ```java * .aiSecretId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = apply { - aiSecretId = aiSecretRetrieveParams.aiSecretId - additionalHeaders = aiSecretRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = + apply { + aiSecretId = aiSecretRetrieveParams.aiSecretId + additionalHeaders = aiSecretRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretRetrieveParams.additionalQueryParams.toBuilder() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } + fun aiSecretId(aiSecretId: String) = + apply { + this.aiSecretId = aiSecretId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( - checkRequired("aiSecretId", aiSecretId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "aiSecretId", aiSecretId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index a1146def..50a0c389 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an ai_secret object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class AiSecretUpdateParams -private constructor( +class AiSecretUpdateParams private constructor( private val aiSecretId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** AiSecret id */ @@ -61,37 +61,28 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("secret") - @ExcludeMissing - private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -103,14 +94,22 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Name of the AI secret */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + @JsonProperty("secret") + @ExcludeMissing + fun _secret(): JsonField = secret - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -118,24 +117,26 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + metadata().ifPresent { it.validate() } + name() + secret() + type() + validated = true } - metadata().ifPresent { it.validate() } - name() - secret() - type() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -148,19 +149,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - metadata = body.metadata - name = body.name - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + metadata = body.metadata + name = body.name + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Name of the AI secret */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -169,49 +174,71 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the AI secret */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) fun secret(secret: Optional) = secret(secret.getOrNull()) - fun secret(secret: JsonField) = apply { this.secret = secret } + fun secret(secret: JsonField) = + apply { + this.secret = secret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = + apply { + this.type = type + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(metadata, name, secret, type, additionalProperties.toImmutable()) + Body( + metadata, + name, + secret, + type, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -220,8 +247,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Body{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -229,14 +255,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AiSecretUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [AiSecretUpdateParams]. * * The following fields are required: + * * ```java * .aiSecretId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AiSecretUpdateParams]. */ @@ -249,175 +278,237 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretUpdateParams: AiSecretUpdateParams) = apply { - aiSecretId = aiSecretUpdateParams.aiSecretId - body = aiSecretUpdateParams.body.toBuilder() - additionalHeaders = aiSecretUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretUpdateParams: AiSecretUpdateParams) = + apply { + aiSecretId = aiSecretUpdateParams.aiSecretId + body = aiSecretUpdateParams.body.toBuilder() + additionalHeaders = aiSecretUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretUpdateParams.additionalQueryParams.toBuilder() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } + fun aiSecretId(aiSecretId: String) = + apply { + this.aiSecretId = aiSecretId + } - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Name of the AI secret */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the AI secret */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the AI secret */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun secret(secret: String?) = apply { body.secret(secret) } + fun secret(secret: String?) = + apply { + body.secret(secret) + } fun secret(secret: Optional) = secret(secret.getOrNull()) - fun secret(secret: JsonField) = apply { body.secret(secret) } + fun secret(secret: JsonField) = + apply { + body.secret(secret) + } - fun type(type: String?) = apply { body.type(type) } + fun type(type: String?) = + apply { + body.type(type) + } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = apply { body.type(type) } + fun type(type: JsonField) = + apply { + body.type(type) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretUpdateParams = AiSecretUpdateParams( - checkRequired("aiSecretId", aiSecretId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "aiSecretId", aiSecretId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -426,20 +517,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -448,38 +541,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -492,15 +593,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "AiSecretUpdateParams{aiSecretId=$aiSecretId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "AiSecretUpdateParams{aiSecretId=$aiSecretId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 0b88b229..b36d8cef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -20,22 +20,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ApiKey -@JsonCreator -private constructor( +class ApiKey @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("preview_name") - @ExcludeMissing - private val previewName: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("preview_name") @ExcludeMissing private val previewName: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the api key */ @@ -56,23 +49,33 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("preview_name") @ExcludeMissing fun _previewName(): JsonField = previewName /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -80,20 +83,21 @@ private constructor( private var validated: Boolean = false - fun validate(): ApiKey = apply { - if (validated) { - return@apply + fun validate(): ApiKey = + apply { + if (validated) { + return@apply + } + + id() + name() + previewName() + created() + orgId() + userId() + validated = true } - id() - name() - previewName() - created() - orgId() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -102,13 +106,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [ApiKey]. * * The following fields are required: + * * ```java * .id() * .name() * .previewName() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKey]. */ @@ -123,31 +129,41 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKey: ApiKey) = apply { - id = apiKey.id - name = apiKey.name - previewName = apiKey.previewName - created = apiKey.created - orgId = apiKey.orgId - userId = apiKey.userId - additionalProperties = apiKey.additionalProperties.toMutableMap() - } + internal fun from(apiKey: ApiKey) = + apply { + id = apiKey.id + name = apiKey.name + previewName = apiKey.previewName + created = apiKey.created + orgId = apiKey.orgId + userId = apiKey.userId + additionalProperties = apiKey.additionalProperties.toMutableMap() + } /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - fun previewName(previewName: JsonField) = apply { this.previewName = previewName } + fun previewName(previewName: JsonField) = + apply { + this.previewName = previewName + } /** Date of api key creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -156,7 +172,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of api key creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Unique identifier for the organization */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) @@ -165,7 +184,10 @@ private constructor( fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the user */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -174,45 +196,61 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Unique identifier for the user */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ApiKey = ApiKey( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("previewName", previewName), - created, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "previewName", previewName + ), + created, + orgId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKey && id == other.id && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ApiKey && id == other.id && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -221,6 +259,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ApiKey{id=$id, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "ApiKey{id=$id, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index a66bf130..bcde02a6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -22,23 +22,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is no - * de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same + * name. There is no de-duplication */ -class ApiKeyCreateParams -private constructor( +class ApiKeyCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the api key. Does not have to be unique */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(): Optional = body.orgName() @@ -46,9 +46,9 @@ private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -58,45 +58,44 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the api key. Does not have to be unique */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -104,15 +103,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - orgName() - validated = true - } + name() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -122,11 +122,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -137,68 +139,88 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the api key. Does not have to be unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key. Does not have to be unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) + Body( + checkRequired( + "name", name + ), + orgName, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -207,8 +229,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -219,11 +240,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ApiKeyCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKeyCreateParams]. */ @@ -235,174 +258,220 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { - body = apiKeyCreateParams.body.toBuilder() - additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = + apply { + body = apiKeyCreateParams.body.toBuilder() + additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() + } /** Name of the api key. Does not have to be unique */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the api key. Does not have to be unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the API key belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyCreateParams = ApiKeyCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ApiKeyCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ApiKeyCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index f0404eda..d1089b96 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an api_key object by its id */ -class ApiKeyDeleteParams -private constructor( +class ApiKeyDeleteParams private constructor( private val apiKeyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** ApiKey id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ApiKeyDeleteParams]. * * The following fields are required: + * * ```java * .apiKeyId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKeyDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = apply { - apiKeyId = apiKeyDeleteParams.apiKeyId - additionalHeaders = apiKeyDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = apiKeyDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = + apply { + apiKeyId = apiKeyDeleteParams.apiKeyId + additionalHeaders = apiKeyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = apiKeyDeleteParams.additionalBodyProperties.toMutableMap() + } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } + fun apiKeyId(apiKeyId: String) = + apply { + this.apiKeyId = apiKeyId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( - checkRequired("apiKeyId", apiKeyId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "apiKeyId", apiKeyId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 0b0839e1..9f5c298c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.ApiKeyService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created - * api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most + * recently-created api_keys coming first */ -class ApiKeyListPage -private constructor( +class ApiKeyListPage private constructor( private val apiKeysService: ApiKeyService, private val params: ApiKeyListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListPage && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ApiKeyListPage && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ - override fun toString() = - "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" + override fun toString() = "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { apiKeysService.list(it) } + return getNextPageParams().map { apiKeysService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(apiKeysService: ApiKeyService, params: ApiKeyListParams, response: Response) = - ApiKeyListPage(apiKeysService, params, response) + ApiKeyListPage( + apiKeysService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ApiKeyListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ApiKeyListPage) : Iterable { + class AutoPager( + private val firstPage: ApiKeyListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index 86f19e49..4d1e49f6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.ApiKeyServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created - * api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most + * recently-created api_keys coming first */ -class ApiKeyListPageAsync -private constructor( +class ApiKeyListPageAsync private constructor( private val apiKeysService: ApiKeyServiceAsync, private val params: ApiKeyListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListPageAsync && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ApiKeyListPageAsync && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ - override fun toString() = - "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" + override fun toString() = "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { apiKeysService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + apiKeysService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(apiKeysService: ApiKeyServiceAsync, params: ApiKeyListParams, response: Response) = - ApiKeyListPageAsync(apiKeysService, params, response) + ApiKeyListPageAsync( + apiKeysService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ApiKeyListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ApiKeyListPageAsync) { + class AutoPager( + private val firstPage: ApiKeyListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (ApiKey) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (ApiKey) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 124f92d2..fdf434a9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created - * api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most + * recently-created api_keys coming first */ -class ApiKeyListParams -private constructor( +class ApiKeyListParams private constructor( private val apiKeyName: String?, private val endingBefore: String?, private val ids: Ids?, @@ -36,6 +35,7 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the api_key to search for */ @@ -44,15 +44,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,51 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.apiKeyName?.let { queryParams.put("api_key_name", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.apiKeyName?.let { + queryParams.put( + "api_key_name", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ApiKeyListParams = builder().build() + @JvmStatic + fun none(): ApiKeyListParams = builder().build() /** Returns a mutable builder for constructing an instance of [ApiKeyListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKeyListParams]. */ @@ -113,19 +139,23 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyListParams: ApiKeyListParams) = apply { - apiKeyName = apiKeyListParams.apiKeyName - endingBefore = apiKeyListParams.endingBefore - ids = apiKeyListParams.ids - limit = apiKeyListParams.limit - orgName = apiKeyListParams.orgName - startingAfter = apiKeyListParams.startingAfter - additionalHeaders = apiKeyListParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyListParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyListParams: ApiKeyListParams) = + apply { + apiKeyName = apiKeyListParams.apiKeyName + endingBefore = apiKeyListParams.endingBefore + ids = apiKeyListParams.ids + limit = apiKeyListParams.limit + orgName = apiKeyListParams.orgName + startingAfter = apiKeyListParams.startingAfter + additionalHeaders = apiKeyListParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyListParams.additionalQueryParams.toBuilder() + } /** Name of the api_key to search for */ - fun apiKeyName(apiKeyName: String?) = apply { this.apiKeyName = apiKeyName } + fun apiKeyName(apiKeyName: String?) = + apply { + this.apiKeyName = apiKeyName + } /** Name of the api_key to search for */ fun apiKeyName(apiKeyName: Optional) = apiKeyName(apiKeyName.getOrNull()) @@ -133,47 +163,56 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -182,7 +221,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -190,144 +232,172 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyListParams = ApiKeyListParams( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + apiKeyName, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -345,19 +415,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -372,12 +442,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -387,60 +462,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 50963e4d..59821a4f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an api_key object by its id */ -class ApiKeyRetrieveParams -private constructor( +class ApiKeyRetrieveParams private constructor( private val apiKeyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ApiKey id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ApiKeyRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ApiKeyRetrieveParams]. * * The following fields are required: + * * ```java * .apiKeyId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ApiKeyRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = apply { - apiKeyId = apiKeyRetrieveParams.apiKeyId - additionalHeaders = apiKeyRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = + apply { + apiKeyId = apiKeyRetrieveParams.apiKeyId + additionalHeaders = apiKeyRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyRetrieveParams.additionalQueryParams.toBuilder() + } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } + fun apiKeyId(apiKeyId: String) = + apply { + this.apiKeyId = apiKeyId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( - checkRequired("apiKeyId", apiKeyId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "apiKeyId", apiKeyId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index fcb0d184..f69a09f1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -20,23 +20,24 @@ import java.util.Objects import java.util.Optional @NoAutoDetect -class ChatCompletionContentPartImage -@JsonCreator -private constructor( - @JsonProperty("image_url") - @ExcludeMissing - private val imageUrl: JsonField = JsonMissing.of(), +class ChatCompletionContentPartImage @JsonCreator private constructor( + @JsonProperty("image_url") @ExcludeMissing private val imageUrl: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") fun type(): Type = type.getRequired("type") - @JsonProperty("image_url") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl + @JsonProperty("image_url") + @ExcludeMissing + fun _imageUrl(): JsonField = imageUrl - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -44,15 +45,16 @@ private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionContentPartImage = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPartImage = + apply { + if (validated) { + return@apply + } - imageUrl().validate() - type() - validated = true - } + imageUrl().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -63,12 +65,14 @@ private constructor( * [ChatCompletionContentPartImage]. * * The following fields are required: + * * ```java * .imageUrl() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ChatCompletionContentPartImage]. */ @@ -79,67 +83,84 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionContentPartImage: ChatCompletionContentPartImage) = apply { - imageUrl = chatCompletionContentPartImage.imageUrl - type = chatCompletionContentPartImage.type - additionalProperties = - chatCompletionContentPartImage.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionContentPartImage: ChatCompletionContentPartImage) = + apply { + imageUrl = chatCompletionContentPartImage.imageUrl + type = chatCompletionContentPartImage.type + additionalProperties = chatCompletionContentPartImage.additionalProperties.toMutableMap() + } fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) - fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl } + fun imageUrl(imageUrl: JsonField) = + apply { + this.imageUrl = imageUrl + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionContentPartImage = ChatCompletionContentPartImage( - checkRequired("imageUrl", imageUrl), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "imageUrl", imageUrl + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ImageUrl - @JsonCreator - private constructor( + class ImageUrl @JsonCreator private constructor( @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("detail") - @ExcludeMissing - private val detail: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("detail") @ExcludeMissing private val detail: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun url(): String = url.getRequired("url") fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url - @JsonProperty("detail") @ExcludeMissing fun _detail(): JsonField = detail + @JsonProperty("detail") + @ExcludeMissing + fun _detail(): JsonField = detail @JsonAnyGetter @ExcludeMissing @@ -147,15 +168,16 @@ private constructor( private var validated: Boolean = false - fun validate(): ImageUrl = apply { - if (validated) { - return@apply - } + fun validate(): ImageUrl = + apply { + if (validated) { + return@apply + } - url() - detail() - validated = true - } + url() + detail() + validated = true + } fun toBuilder() = Builder().from(this) @@ -165,11 +187,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ImageUrl]. * * The following fields are required: + * * ```java * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ImageUrl]. */ @@ -180,54 +204,78 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(imageUrl: ImageUrl) = apply { - url = imageUrl.url - detail = imageUrl.detail - additionalProperties = imageUrl.additionalProperties.toMutableMap() - } + internal fun from(imageUrl: ImageUrl) = + apply { + url = imageUrl.url + detail = imageUrl.detail + additionalProperties = imageUrl.additionalProperties.toMutableMap() + } fun url(url: String) = url(JsonField.of(url)) - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = + apply { + this.url = url + } fun detail(detail: Detail) = detail(JsonField.of(detail)) - fun detail(detail: JsonField) = apply { this.detail = detail } + fun detail(detail: JsonField) = + apply { + this.detail = detail + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ImageUrl = - ImageUrl(checkRequired("url", url), detail, additionalProperties.toImmutable()) + ImageUrl( + checkRequired( + "url", url + ), + detail, + additionalProperties.toImmutable(), + ) } - class Detail @JsonCreator private constructor(private val value: JsonField) : Enum { + class Detail @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -251,18 +299,18 @@ private constructor( * An enum containing [Detail]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Detail] 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 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 { AUTO, LOW, HIGH, - /** - * An enum member indicating that [Detail] was instantiated with an unknown value. - */ + /** An enum member indicating that [Detail] was instantiated with an unknown value. */ _UNKNOWN, } @@ -270,8 +318,8 @@ private constructor( * 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. + * 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) { @@ -288,7 +336,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -304,20 +352,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ + return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -326,11 +371,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ImageUrl && url == other.url && detail == other.detail && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ImageUrl && url == other.url && detail == other.detail && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -339,21 +384,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -364,16 +412,18 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - IMAGE_URL + IMAGE_URL, } /** * 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 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 { @@ -383,11 +433,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -398,11 +448,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -413,23 +463,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -438,11 +485,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPartImage && imageUrl == other.imageUrl && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartImage && imageUrl == other.imageUrl && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -451,6 +498,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index c4b1ce91..444bd3c7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -20,21 +20,24 @@ import java.util.Objects import java.util.Optional @NoAutoDetect -class ChatCompletionContentPartText -@JsonCreator -private constructor( +class ChatCompletionContentPartText @JsonCreator private constructor( @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") fun text(): Optional = Optional.ofNullable(text.getNullable("text")) - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + @JsonProperty("text") + @ExcludeMissing + fun _text(): JsonField = text @JsonAnyGetter @ExcludeMissing @@ -42,15 +45,16 @@ private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionContentPartText = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPartText = + apply { + if (validated) { + return@apply + } - type() - text() - validated = true - } + type() + text() + validated = true + } fun toBuilder() = Builder().from(this) @@ -61,11 +65,13 @@ private constructor( * [ChatCompletionContentPartText]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ChatCompletionContentPartText]. */ @@ -76,58 +82,78 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionContentPartText: ChatCompletionContentPartText) = apply { - type = chatCompletionContentPartText.type - text = chatCompletionContentPartText.text - additionalProperties = chatCompletionContentPartText.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionContentPartText: ChatCompletionContentPartText) = + apply { + type = chatCompletionContentPartText.type + text = chatCompletionContentPartText.text + additionalProperties = chatCompletionContentPartText.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun text(text: String) = text(JsonField.of(text)) - fun text(text: JsonField) = apply { this.text = text } + fun text(text: JsonField) = + apply { + this.text = text + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionContentPartText = ChatCompletionContentPartText( - checkRequired("type", type), - text, - additionalProperties.toImmutable(), + checkRequired( + "type", type + ), + text, + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -138,16 +164,18 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - TEXT + TEXT, } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. + * + * - It was 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 { @@ -157,11 +185,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -172,11 +200,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -187,23 +215,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -212,11 +237,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPartText && type == other.type && text == other.text && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartText && type == other.type && text == other.text && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -225,6 +250,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ChatCompletionContentPartText{type=$type, text=$text, additionalProperties=$additionalProperties}" + override fun toString() = "ChatCompletionContentPartText{type=$type, text=$text, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 3ae3ad83..66d851d6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -19,15 +19,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class ChatCompletionMessageToolCall -@JsonCreator -private constructor( +class ChatCompletionMessageToolCall @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("function") - @ExcludeMissing - private val function: JsonField = JsonMissing.of(), + @JsonProperty("function") @ExcludeMissing private val function: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun id(): String = id.getRequired("id") @@ -36,11 +33,17 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id - @JsonProperty("function") @ExcludeMissing fun _function(): JsonField = function + @JsonProperty("function") + @ExcludeMissing + fun _function(): JsonField = function - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -48,16 +51,17 @@ private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionMessageToolCall = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionMessageToolCall = + apply { + if (validated) { + return@apply + } - id() - function().validate() - type() - validated = true - } + id() + function().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -68,13 +72,15 @@ private constructor( * [ChatCompletionMessageToolCall]. * * The following fields are required: + * * ```java * .id() * .function() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ChatCompletionMessageToolCall]. */ @@ -86,74 +92,95 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionMessageToolCall: ChatCompletionMessageToolCall) = apply { - id = chatCompletionMessageToolCall.id - function = chatCompletionMessageToolCall.function - type = chatCompletionMessageToolCall.type - additionalProperties = chatCompletionMessageToolCall.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionMessageToolCall: ChatCompletionMessageToolCall) = + apply { + id = chatCompletionMessageToolCall.id + function = chatCompletionMessageToolCall.function + type = chatCompletionMessageToolCall.type + additionalProperties = chatCompletionMessageToolCall.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } fun function(function: Function) = function(JsonField.of(function)) - fun function(function: JsonField) = apply { this.function = function } + fun function(function: JsonField) = + apply { + this.function = function + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionMessageToolCall = ChatCompletionMessageToolCall( - checkRequired("id", id), - checkRequired("function", function), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "function", function + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("arguments") - @ExcludeMissing - private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") - @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonField = arguments + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -161,15 +188,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - arguments() - name() - validated = true - } + arguments() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -179,12 +207,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .arguments() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -195,53 +225,71 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - arguments = function.arguments - name = function.name - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + arguments = function.arguments + name = function.name + additionalProperties = function.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = apply { this.arguments = arguments } + fun arguments(arguments: JsonField) = + apply { + this.arguments = arguments + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun name(name: JsonField) = + apply { + this.name = name + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("arguments", arguments), - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "arguments", arguments + ), + checkRequired( + "name", name + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -250,21 +298,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -275,16 +326,18 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * 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 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 { @@ -294,11 +347,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -309,11 +362,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -324,23 +377,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -349,11 +399,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionMessageToolCall && id == other.id && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionMessageToolCall && id == other.id && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -362,6 +412,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index e5712817..d0ec91d3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -31,22 +31,13 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CodeBundle -@JsonCreator -private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), +class CodeBundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") @@ -58,16 +49,22 @@ private constructor( /** A preview of the code */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId + @JsonProperty("bundle_id") + @ExcludeMissing + fun _bundleId(): JsonField = bundleId - @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview(): JsonField = preview @JsonAnyGetter @ExcludeMissing @@ -75,17 +72,18 @@ private constructor( private var validated: Boolean = false - fun validate(): CodeBundle = apply { - if (validated) { - return@apply - } + fun validate(): CodeBundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + validated = true + } fun toBuilder() = Builder().from(this) @@ -95,13 +93,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [CodeBundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() * .runtimeContext() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [CodeBundle]. */ @@ -114,32 +114,39 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(codeBundle: CodeBundle) = apply { - bundleId = codeBundle.bundleId - location = codeBundle.location - runtimeContext = codeBundle.runtimeContext - preview = codeBundle.preview - additionalProperties = codeBundle.additionalProperties.toMutableMap() - } + internal fun from(codeBundle: CodeBundle) = + apply { + bundleId = codeBundle.bundleId + location = codeBundle.location + runtimeContext = codeBundle.runtimeContext + preview = codeBundle.preview + additionalProperties = codeBundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } fun location(location: Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { this.location = location } + fun location(location: JsonField) = + apply { + this.location = location + } fun location(experiment: Location.Experiment) = location(Location.ofExperiment(experiment)) fun location(function: Location.Function) = location(Location.ofFunction(function)) - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } /** A preview of the code */ fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) @@ -148,44 +155,60 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CodeBundle = CodeBundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Location.Deserializer::class) @JsonSerialize(using = Location.Serializer::class) - class Location - private constructor( + class Location private constructor( private val experiment: Experiment? = null, private val function: Function? = null, private val _json: JsonValue? = null, + ) { fun experiment(): Optional = Optional.ofNullable(experiment) @@ -203,40 +226,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - experiment != null -> visitor.visitExperiment(experiment) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + experiment != null -> visitor.visitExperiment(experiment) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Location = apply { - if (validated) { - return@apply - } + fun validate(): Location = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitExperiment(experiment: Experiment) { - experiment.validate() + experiment.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Location && experiment == other.experiment && function == other.function /* spotless:on */ + return /* spotless:off */ other is Location && experiment == other.experiment && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experiment, function) /* spotless:on */ @@ -251,13 +273,16 @@ private constructor( companion object { - @JvmStatic fun ofExperiment(experiment: Experiment) = Location(experiment = experiment) + @JvmStatic + fun ofExperiment(experiment: Experiment) = Location(experiment = experiment) - @JvmStatic fun ofFunction(function: Function) = Location(function = function) + @JvmStatic + fun ofFunction(function: Function) = Location(function = function) } /** - * An interface that defines how to map each variant of [Location] to a value of type [T]. + * An interface that defines how to map each variant of [Location] to a value of + * type [T]. */ interface Visitor { @@ -268,67 +293,53 @@ private constructor( /** * Maps an unknown variant of [Location] to a value of type [T]. * - * An instance of [Location] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Location] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Location: $json") + throw BraintrustInvalidDataException("Unknown Location: $json") } } internal class Deserializer : BaseDeserializer(Location::class) { override fun ObjectCodec.deserialize(node: JsonNode): Location { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Location(experiment = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Location(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Location(experiment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Location(function = it, _json = json) + } - return Location(_json = json) + return Location(_json = json) } } internal class Serializer : BaseSerializer(Location::class) { - override fun serialize( - value: Location, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.experiment != null -> generator.writeObject(value.experiment) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Location") - } + override fun serialize(value: Location, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.experiment != null -> generator.writeObject(value.experiment) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Location") + } } } @NoAutoDetect - class Experiment - @JsonCreator - private constructor( - @JsonProperty("eval_name") - @ExcludeMissing - private val evalName: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Experiment @JsonCreator private constructor( + @JsonProperty("eval_name") @ExcludeMissing private val evalName: JsonField = JsonMissing.of(), + @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun evalName(): String = evalName.getRequired("eval_name") @@ -337,13 +348,17 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("eval_name") @ExcludeMissing fun _evalName(): JsonField = evalName + @JsonProperty("eval_name") + @ExcludeMissing + fun _evalName(): JsonField = evalName @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -351,16 +366,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Experiment = apply { - if (validated) { - return@apply - } + fun validate(): Experiment = + apply { + if (validated) { + return@apply + } - evalName() - position().validate() - type() - validated = true - } + evalName() + position().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -370,13 +386,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Experiment]. * * The following fields are required: + * * ```java * .evalName() * .position() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -388,20 +406,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = apply { - evalName = experiment.evalName - position = experiment.position - type = experiment.type - additionalProperties = experiment.additionalProperties.toMutableMap() - } + internal fun from(experiment: Experiment) = + apply { + evalName = experiment.evalName + position = experiment.position + type = experiment.type + additionalProperties = experiment.additionalProperties.toMutableMap() + } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) - fun evalName(evalName: JsonField) = apply { this.evalName = evalName } + fun evalName(evalName: JsonField) = + apply { + this.evalName = evalName + } fun position(position: Position) = position(JsonField.of(position)) - fun position(position: JsonField) = apply { this.position = position } + fun position(position: JsonField) = + apply { + this.position = position + } fun position(type: Position.Type) = position(Position.ofType(type)) @@ -409,46 +434,59 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment( - checkRequired("evalName", evalName), - checkRequired("position", position), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "evalName", evalName + ), + checkRequired( + "position", position + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position - private constructor( + class Position private constructor( private val type: Type? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, + ) { fun type(): Optional = Optional.ofNullable(type) @@ -466,40 +504,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - scorer != null -> visitor.visitScorer(scorer) - else -> visitor.unknown(_json) - } + return when { + type != null -> visitor.visitType(type) + scorer != null -> visitor.visitScorer(scorer) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Position = apply { - if (validated) { - return@apply - } + fun validate(): Position = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitType(type: Type) { - type.validate() + type.validate() } override fun visitScorer(scorer: Scorer) { - scorer.validate() + scorer.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Position && type == other.type && scorer == other.scorer /* spotless:on */ + return /* spotless:off */ other is Position && type == other.type && scorer == other.scorer /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(type, scorer) /* spotless:on */ @@ -514,9 +551,11 @@ private constructor( companion object { - @JvmStatic fun ofType(type: Type) = Position(type = type) + @JvmStatic + fun ofType(type: Type) = Position(type = type) - @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + @JvmStatic + fun ofScorer(scorer: Scorer) = Position(scorer = scorer) } /** @@ -532,66 +571,58 @@ private constructor( /** * Maps an unknown variant of [Position] to a value of type [T]. * - * An instance of [Position] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * An instance of [Position] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } internal class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(scorer = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Position(type = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Position(scorer = it, _json = json) + } - return Position(_json = json) + return Position(_json = json) } } internal class Serializer : BaseSerializer(Position::class) { - override fun serialize( - value: Position, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.type != null -> generator.writeObject(value.type) - value.scorer != null -> generator.writeObject(value.scorer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + override fun serialize(value: Position, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.type != null -> generator.writeObject(value.type) + value.scorer != null -> generator.writeObject(value.scorer) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } } } @NoAutoDetect - class Type - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Type @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): InnerType = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -599,14 +630,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Type = apply { - if (validated) { - return@apply - } + fun validate(): Type = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -616,29 +648,34 @@ private constructor( * Returns a mutable builder for constructing an instance of [Type]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Type]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties = type.additionalProperties.toMutableMap() - } + internal fun from(type: Type) = + apply { + this.type = type.type + additionalProperties = type.additionalProperties.toMutableMap() + } fun type(type: InnerType) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -646,37 +683,46 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Type = - Type(checkRequired("type", type), additionalProperties.toImmutable()) + Type( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class InnerType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class InnerType @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. + * 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 @@ -690,25 +736,25 @@ private constructor( /** An enum containing [InnerType]'s known values. */ enum class Known { - TASK + TASK, } /** - * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InnerType] can contain an unknown value in a couple of cases: * - * An instance of [InnerType] 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. + * 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 { TASK, /** - * An enum member indicating that [InnerType] was instantiated with an - * unknown value. + * An enum member indicating that [InnerType] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -717,8 +763,8 @@ private constructor( * 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. + * 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) { @@ -729,41 +775,35 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown InnerType: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown InnerType: $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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerType && value == other.value /* spotless:on */ + return /* spotless:off */ other is InnerType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -772,11 +812,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Type && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -785,31 +825,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Scorer - @JsonCreator - private constructor( - @JsonProperty("index") - @ExcludeMissing - private val index: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Scorer @JsonCreator private constructor( + @JsonProperty("index") @ExcludeMissing private val index: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun index(): Long = index.getRequired("index") fun type(): Type = type.getRequired("type") - @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + @JsonProperty("index") + @ExcludeMissing + fun _index(): JsonField = index - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -817,15 +854,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Scorer = apply { - if (validated) { - return@apply - } + fun validate(): Scorer = + apply { + if (validated) { + return@apply + } - index() - type() - validated = true - } + index() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -835,12 +873,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Scorer]. * * The following fields are required: + * * ```java * .index() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scorer]. */ @@ -848,23 +888,29 @@ private constructor( private var index: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scorer: Scorer) = apply { - index = scorer.index - type = scorer.type - additionalProperties = scorer.additionalProperties.toMutableMap() - } + internal fun from(scorer: Scorer) = + apply { + index = scorer.index + type = scorer.type + additionalProperties = scorer.additionalProperties.toMutableMap() + } fun index(index: Long) = index(JsonField.of(index)) - fun index(index: JsonField) = apply { this.index = index } + fun index(index: JsonField) = + apply { + this.index = index + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -872,41 +918,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scorer = Scorer( - checkRequired("index", index), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "index", index + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -920,25 +975,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - SCORER + SCORER, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { SCORER, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -946,8 +999,8 @@ private constructor( * 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. + * 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) { @@ -958,11 +1011,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -973,23 +1026,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -998,11 +1048,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scorer && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scorer && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1011,13 +1061,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Scorer{index=$index, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Scorer{index=$index, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1027,7 +1078,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1038,23 +1090,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - EXPERIMENT + EXPERIMENT, } /** * 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 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 { EXPERIMENT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1078,7 +1130,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1093,19 +1145,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1114,11 +1163,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && evalName == other.evalName && position == other.position && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && evalName == other.evalName && position == other.position && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1127,31 +1176,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Experiment{evalName=$evalName, position=$position, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Experiment{evalName=$evalName, position=$position, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("index") - @ExcludeMissing - private val index: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("index") @ExcludeMissing private val index: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun index(): Long = index.getRequired("index") fun type(): Type = type.getRequired("type") - @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + @JsonProperty("index") + @ExcludeMissing + fun _index(): JsonField = index - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1159,15 +1205,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - index() - type() - validated = true - } + index() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1177,12 +1224,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .index() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -1193,52 +1242,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - index = function.index - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + index = function.index + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun index(index: Long) = index(JsonField.of(index)) - fun index(index: JsonField) = apply { this.index = index } + fun index(index: JsonField) = + apply { + this.index = index + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("index", index), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "index", index + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1248,7 +1314,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1259,23 +1326,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * 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 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 { FUNCTION, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1299,7 +1366,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1314,19 +1381,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1335,11 +1399,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1348,32 +1412,29 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{index=$index, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Function{index=$index, type=$type, additionalProperties=$additionalProperties}" } } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1381,15 +1442,16 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1399,12 +1461,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1415,59 +1479,80 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { this.runtime = runtime } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Runtime @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1488,17 +1573,17 @@ private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] 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 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 { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an unknown value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1506,8 +1591,8 @@ private constructor( * 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. + * 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) { @@ -1523,7 +1608,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1538,20 +1623,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1560,11 +1642,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1573,16 +1655,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CodeBundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CodeBundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1591,6 +1672,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "CodeBundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, additionalProperties=$additionalProperties}" + override fun toString() = "CodeBundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index ba204bc6..e27dc4bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -20,23 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CreateApiKeyOutput -@JsonCreator -private constructor( +class CreateApiKeyOutput @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("key") @ExcludeMissing private val key: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("preview_name") - @ExcludeMissing - private val previewName: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("preview_name") @ExcludeMissing private val previewName: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the api key */ @@ -60,26 +53,38 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** The raw API key. It will only be exposed this one time */ - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + @JsonProperty("key") + @ExcludeMissing + fun _key(): JsonField = key /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("preview_name") @ExcludeMissing fun _previewName(): JsonField = previewName /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -87,21 +92,22 @@ private constructor( private var validated: Boolean = false - fun validate(): CreateApiKeyOutput = apply { - if (validated) { - return@apply + fun validate(): CreateApiKeyOutput = + apply { + if (validated) { + return@apply + } + + id() + key() + name() + previewName() + created() + orgId() + userId() + validated = true } - id() - key() - name() - previewName() - created() - orgId() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -110,6 +116,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [CreateApiKeyOutput]. * * The following fields are required: + * * ```java * .id() * .key() @@ -117,7 +124,8 @@ private constructor( * .previewName() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [CreateApiKeyOutput]. */ @@ -133,38 +141,51 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(createApiKeyOutput: CreateApiKeyOutput) = apply { - id = createApiKeyOutput.id - key = createApiKeyOutput.key - name = createApiKeyOutput.name - previewName = createApiKeyOutput.previewName - created = createApiKeyOutput.created - orgId = createApiKeyOutput.orgId - userId = createApiKeyOutput.userId - additionalProperties = createApiKeyOutput.additionalProperties.toMutableMap() - } + internal fun from(createApiKeyOutput: CreateApiKeyOutput) = + apply { + id = createApiKeyOutput.id + key = createApiKeyOutput.key + name = createApiKeyOutput.name + previewName = createApiKeyOutput.previewName + created = createApiKeyOutput.created + orgId = createApiKeyOutput.orgId + userId = createApiKeyOutput.userId + additionalProperties = createApiKeyOutput.additionalProperties.toMutableMap() + } /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** The raw API key. It will only be exposed this one time */ fun key(key: String) = key(JsonField.of(key)) /** The raw API key. It will only be exposed this one time */ - fun key(key: JsonField) = apply { this.key = key } + fun key(key: JsonField) = + apply { + this.key = key + } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - fun previewName(previewName: JsonField) = apply { this.previewName = previewName } + fun previewName(previewName: JsonField) = + apply { + this.previewName = previewName + } /** Date of api key creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -173,7 +194,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of api key creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Unique identifier for the organization */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) @@ -182,7 +206,10 @@ private constructor( fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the user */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -191,46 +218,64 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Unique identifier for the user */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CreateApiKeyOutput = CreateApiKeyOutput( - checkRequired("id", id), - checkRequired("key", key), - checkRequired("name", name), - checkRequired("previewName", previewName), - created, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "key", key + ), + checkRequired( + "name", name + ), + checkRequired( + "previewName", previewName + ), + created, + orgId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && key == other.key && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && key == other.key && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -239,6 +284,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "CreateApiKeyOutput{id=$id, key=$key, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "CreateApiKeyOutput{id=$id, key=$key, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index b6a00359..d2255c0a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -18,34 +18,27 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CrossObjectInsertResponse -@JsonCreator -private constructor( - @JsonProperty("dataset") - @ExcludeMissing - private val dataset: JsonField = JsonMissing.of(), - @JsonProperty("experiment") - @ExcludeMissing - private val experiment: JsonField = JsonMissing.of(), - @JsonProperty("project_logs") - @ExcludeMissing - private val projectLogs: JsonField = JsonMissing.of(), +class CrossObjectInsertResponse @JsonCreator private constructor( + @JsonProperty("dataset") @ExcludeMissing private val dataset: JsonField = JsonMissing.of(), + @JsonProperty("experiment") @ExcludeMissing private val experiment: JsonField = JsonMissing.of(), + @JsonProperty("project_logs") @ExcludeMissing private val projectLogs: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(): Optional = Optional.ofNullable(dataset.getNullable("dataset")) /** A mapping from experiment id to row ids for inserted `events` */ - fun experiment(): Optional = - Optional.ofNullable(experiment.getNullable("experiment")) + fun experiment(): Optional = Optional.ofNullable(experiment.getNullable("experiment")) /** A mapping from project id to row ids for inserted `events` */ - fun projectLogs(): Optional = - Optional.ofNullable(projectLogs.getNullable("project_logs")) + fun projectLogs(): Optional = Optional.ofNullable(projectLogs.getNullable("project_logs")) /** A mapping from dataset id to row ids for inserted `events` */ - @JsonProperty("dataset") @ExcludeMissing fun _dataset(): JsonField = dataset + @JsonProperty("dataset") + @ExcludeMissing + fun _dataset(): JsonField = dataset /** A mapping from experiment id to row ids for inserted `events` */ @JsonProperty("experiment") @@ -63,25 +56,28 @@ private constructor( private var validated: Boolean = false - fun validate(): CrossObjectInsertResponse = apply { - if (validated) { - return@apply - } + fun validate(): CrossObjectInsertResponse = + apply { + if (validated) { + return@apply + } - dataset().ifPresent { it.validate() } - experiment().ifPresent { it.validate() } - projectLogs().ifPresent { it.validate() } - validated = true - } + dataset().ifPresent { it.validate() } + experiment().ifPresent { it.validate() } + projectLogs().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [CrossObjectInsertResponse]. + * Returns a mutable builder for constructing an instance of + * [CrossObjectInsertResponse]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [CrossObjectInsertResponse]. */ @@ -93,12 +89,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(crossObjectInsertResponse: CrossObjectInsertResponse) = apply { - dataset = crossObjectInsertResponse.dataset - experiment = crossObjectInsertResponse.experiment - projectLogs = crossObjectInsertResponse.projectLogs - additionalProperties = crossObjectInsertResponse.additionalProperties.toMutableMap() - } + internal fun from(crossObjectInsertResponse: CrossObjectInsertResponse) = + apply { + dataset = crossObjectInsertResponse.dataset + experiment = crossObjectInsertResponse.experiment + projectLogs = crossObjectInsertResponse.projectLogs + additionalProperties = crossObjectInsertResponse.additionalProperties.toMutableMap() + } /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(dataset: Dataset?) = dataset(JsonField.ofNullable(dataset)) @@ -107,7 +104,10 @@ private constructor( fun dataset(dataset: Optional) = dataset(dataset.getOrNull()) /** A mapping from dataset id to row ids for inserted `events` */ - fun dataset(dataset: JsonField) = apply { this.dataset = dataset } + fun dataset(dataset: JsonField) = + apply { + this.dataset = dataset + } /** A mapping from experiment id to row ids for inserted `events` */ fun experiment(experiment: Experiment?) = experiment(JsonField.ofNullable(experiment)) @@ -116,7 +116,10 @@ private constructor( fun experiment(experiment: Optional) = experiment(experiment.getOrNull()) /** A mapping from experiment id to row ids for inserted `events` */ - fun experiment(experiment: JsonField) = apply { this.experiment = experiment } + fun experiment(experiment: JsonField) = + apply { + this.experiment = experiment + } /** A mapping from project id to row ids for inserted `events` */ fun projectLogs(projectLogs: ProjectLogs?) = projectLogs(JsonField.ofNullable(projectLogs)) @@ -125,45 +128,51 @@ private constructor( fun projectLogs(projectLogs: Optional) = projectLogs(projectLogs.getOrNull()) /** A mapping from project id to row ids for inserted `events` */ - fun projectLogs(projectLogs: JsonField) = apply { - this.projectLogs = projectLogs - } + fun projectLogs(projectLogs: JsonField) = + apply { + this.projectLogs = projectLogs + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CrossObjectInsertResponse = CrossObjectInsertResponse( - dataset, - experiment, - projectLogs, - additionalProperties.toImmutable(), + dataset, + experiment, + projectLogs, + additionalProperties.toImmutable(), ) } /** A mapping from dataset id to row ids for inserted `events` */ @NoAutoDetect - class Dataset - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Dataset @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -172,20 +181,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Dataset = apply { - if (validated) { - return@apply - } + fun validate(): Dataset = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Dataset]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Dataset]. */ @@ -194,38 +205,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataset: Dataset) = apply { - additionalProperties = dataset.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(dataset: Dataset) = + apply { + additionalProperties = dataset.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Dataset = Dataset(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Dataset && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -239,11 +258,9 @@ private constructor( /** A mapping from experiment id to row ids for inserted `events` */ @NoAutoDetect - class Experiment - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Experiment @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -252,20 +269,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Experiment = apply { - if (validated) { - return@apply - } + fun validate(): Experiment = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Experiment]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -274,38 +293,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = apply { - additionalProperties = experiment.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(experiment: Experiment) = + apply { + additionalProperties = experiment.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -319,11 +346,9 @@ private constructor( /** A mapping from project id to row ids for inserted `events` */ @NoAutoDetect - class ProjectLogs - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class ProjectLogs @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -332,20 +357,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectLogs = apply { - if (validated) { - return@apply - } + fun validate(): ProjectLogs = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectLogs]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogs]. */ @@ -354,38 +381,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogs: ProjectLogs) = apply { - additionalProperties = projectLogs.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(projectLogs: ProjectLogs) = + apply { + additionalProperties = projectLogs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectLogs = ProjectLogs(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogs && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -398,11 +433,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CrossObjectInsertResponse && dataset == other.dataset && experiment == other.experiment && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CrossObjectInsertResponse && dataset == other.dataset && experiment == other.experiment && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -411,6 +446,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "CrossObjectInsertResponse{dataset=$dataset, experiment=$experiment, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" + override fun toString() = "CrossObjectInsertResponse{dataset=$dataset, experiment=$experiment, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index 25297bb3..fc846ec3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -18,13 +18,10 @@ import java.util.Objects /** Summary of a dataset's data */ @NoAutoDetect -class DataSummary -@JsonCreator -private constructor( - @JsonProperty("total_records") - @ExcludeMissing - private val totalRecords: JsonField = JsonMissing.of(), +class DataSummary @JsonCreator private constructor( + @JsonProperty("total_records") @ExcludeMissing private val totalRecords: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Total number of records in the dataset */ @@ -41,14 +38,15 @@ private constructor( private var validated: Boolean = false - fun validate(): DataSummary = apply { - if (validated) { - return@apply - } + fun validate(): DataSummary = + apply { + if (validated) { + return@apply + } - totalRecords() - validated = true - } + totalRecords() + validated = true + } fun toBuilder() = Builder().from(this) @@ -58,11 +56,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DataSummary]. * * The following fields are required: + * * ```java * .totalRecords() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DataSummary]. */ @@ -72,49 +72,61 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataSummary: DataSummary) = apply { - totalRecords = dataSummary.totalRecords - additionalProperties = dataSummary.additionalProperties.toMutableMap() - } + internal fun from(dataSummary: DataSummary) = + apply { + totalRecords = dataSummary.totalRecords + additionalProperties = dataSummary.additionalProperties.toMutableMap() + } /** Total number of records in the dataset */ fun totalRecords(totalRecords: Long) = totalRecords(JsonField.of(totalRecords)) /** Total number of records in the dataset */ - fun totalRecords(totalRecords: JsonField) = apply { this.totalRecords = totalRecords } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun totalRecords(totalRecords: JsonField) = + apply { + this.totalRecords = totalRecords + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DataSummary = DataSummary( - checkRequired("totalRecords", totalRecords), - additionalProperties.toImmutable(), + checkRequired( + "totalRecords", totalRecords + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DataSummary && totalRecords == other.totalRecords && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DataSummary && totalRecords == other.totalRecords && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -123,6 +135,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" + override fun toString() = "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 6a1818a9..6a36285e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -20,30 +20,17 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Dataset -@JsonCreator -private constructor( +class Dataset @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the dataset */ @@ -59,12 +46,10 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the dataset */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -73,16 +58,24 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the dataset */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Date of dataset creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of dataset deletion, or null if the dataset is still active */ @JsonProperty("deleted_at") @@ -90,13 +83,19 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the dataset */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Identifies the user who created the dataset */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -104,21 +103,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Dataset = apply { - if (validated) { - return@apply - } + fun validate(): Dataset = + apply { + if (validated) { + return@apply + } - id() - name() - projectId() - created() - deletedAt() - description() - metadata().ifPresent { it.validate() } - userId() - validated = true - } + id() + name() + projectId() + created() + deletedAt() + description() + metadata().ifPresent { it.validate() } + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -128,13 +128,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Dataset]. * * The following fields are required: + * * ```java * .id() * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Dataset]. */ @@ -151,35 +153,45 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataset: Dataset) = apply { - id = dataset.id - name = dataset.name - projectId = dataset.projectId - created = dataset.created - deletedAt = dataset.deletedAt - description = dataset.description - metadata = dataset.metadata - userId = dataset.userId - additionalProperties = dataset.additionalProperties.toMutableMap() - } + internal fun from(dataset: Dataset) = + apply { + id = dataset.id + name = dataset.name + projectId = dataset.projectId + created = dataset.created + deletedAt = dataset.deletedAt + description = dataset.description + metadata = dataset.metadata + userId = dataset.userId + additionalProperties = dataset.additionalProperties.toMutableMap() + } /** Unique identifier for the dataset */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the dataset */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Date of dataset creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -188,7 +200,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of dataset creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of dataset deletion, or null if the dataset is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -197,7 +212,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -206,7 +224,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -215,7 +236,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Identifies the user who created the dataset */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -224,48 +248,62 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the dataset */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Dataset = Dataset( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - created, - deletedAt, - description, - metadata, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + created, + deletedAt, + description, + metadata, + userId, + additionalProperties.toImmutable(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -274,20 +312,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -296,38 +336,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -340,11 +388,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Dataset && id == other.id && name == other.name && projectId == other.projectId && created == other.created && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && id == other.id && name == other.name && projectId == other.projectId && created == other.created && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -353,6 +401,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Dataset{id=$id, name=$name, projectId=$projectId, created=$created, deletedAt=$deletedAt, description=$description, metadata=$metadata, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Dataset{id=$id, name=$name, projectId=$projectId, created=$created, deletedAt=$deletedAt, description=$description, metadata=$metadata, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index be5669c3..7930ddda 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new dataset. If there is an existing dataset in the project with the same name as the - * one specified in the request, will return the existing dataset unmodified + * Create a new dataset. If there is an existing dataset in the project with the + * same name as the one specified in the request, will return the existing dataset + * unmodified */ -class DatasetCreateParams -private constructor( +class DatasetCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the dataset. Within a project, dataset names are unique */ @@ -62,30 +63,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the dataset. Within a project, dataset names are unique */ @@ -95,17 +87,20 @@ private constructor( fun projectId(): String = projectId.getRequired("project_id") /** Textual description of the dataset */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Textual description of the dataset */ @JsonProperty("description") @@ -113,7 +108,9 @@ private constructor( fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing @@ -121,18 +118,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + description() + metadata().ifPresent { it.validate() } + validated = true } - name() - projectId() - description() - metadata().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -141,12 +139,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -159,25 +159,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - description = body.description - metadata = body.metadata - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + description = body.description + metadata = body.metadata + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -186,9 +193,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -197,43 +205,57 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - description, - metadata, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + description, + metadata, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -242,8 +264,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -254,12 +275,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetCreateParams]. */ @@ -271,174 +294,231 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetCreateParams: DatasetCreateParams) = apply { - body = datasetCreateParams.body.toBuilder() - additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetCreateParams: DatasetCreateParams) = + apply { + body = datasetCreateParams.body.toBuilder() + additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() + } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Textual description of the dataset */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the dataset */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetCreateParams = DatasetCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -447,20 +527,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -469,38 +551,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -513,15 +603,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 8f43631d..708741d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a dataset object by its id */ -class DatasetDeleteParams -private constructor( +class DatasetDeleteParams private constructor( private val datasetId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Dataset id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetDeleteParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetDeleteParams: DatasetDeleteParams) = apply { - datasetId = datasetDeleteParams.datasetId - additionalHeaders = datasetDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = datasetDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(datasetDeleteParams: DatasetDeleteParams) = + apply { + datasetId = datasetDeleteParams.datasetId + additionalHeaders = datasetDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetDeleteParams.additionalBodyProperties.toMutableMap() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): DatasetDeleteParams = DatasetDeleteParams( - checkRequired("datasetId", datasetId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "datasetId", datasetId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 9552e3d7..65781e58 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -23,55 +23,35 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class DatasetEvent -@JsonCreator -private constructor( +class DatasetEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") - @ExcludeMissing - private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the dataset (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the dataset (see the `version` + * parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -88,30 +68,38 @@ private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -122,54 +110,78 @@ private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the dataset (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the dataset (see the `version` + * parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** A unique identifier for the trace this dataset event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") + @ExcludeMissing + fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -177,24 +189,25 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetEvent = apply { - if (validated) { - return@apply - } + fun validate(): DatasetEvent = + apply { + if (validated) { + return@apply + } - id() - _xactId() - created() - datasetId() - projectId() - rootSpanId() - spanId() - isRoot() - metadata().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - tags() - validated = true - } + id() + _xactId() + created() + datasetId() + projectId() + rootSpanId() + spanId() + isRoot() + metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -204,6 +217,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetEvent]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -214,7 +228,8 @@ private constructor( * .spanId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetEvent]. */ @@ -236,97 +251,130 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetEvent: DatasetEvent) = apply { - id = datasetEvent.id - _xactId = datasetEvent._xactId - created = datasetEvent.created - datasetId = datasetEvent.datasetId - projectId = datasetEvent.projectId - rootSpanId = datasetEvent.rootSpanId - spanId = datasetEvent.spanId - expected = datasetEvent.expected - input = datasetEvent.input - isRoot = datasetEvent.isRoot - metadata = datasetEvent.metadata - origin = datasetEvent.origin - tags = datasetEvent.tags.map { it.toMutableList() } - additionalProperties = datasetEvent.additionalProperties.toMutableMap() - } + internal fun from(datasetEvent: DatasetEvent) = + apply { + id = datasetEvent.id + _xactId = datasetEvent._xactId + created = datasetEvent.created + datasetId = datasetEvent.datasetId + projectId = datasetEvent.projectId + rootSpanId = datasetEvent.rootSpanId + spanId = datasetEvent.spanId + expected = datasetEvent.expected + input = datasetEvent.input + isRoot = datasetEvent.isRoot + metadata = datasetEvent.metadata + origin = datasetEvent.origin + tags = datasetEvent.tags.map { it.toMutableList() } + additionalProperties = datasetEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the dataset (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the dataset (see the `version` + * parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the dataset (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the dataset (see the `version` + * parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the dataset event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Unique identifier for the dataset */ fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) /** Unique identifier for the dataset */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** A unique identifier for the trace this dataset event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this dataset event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + * The argument that uniquely define an input case (an arbitrary, JSON serializable + * object) */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -338,34 +386,40 @@ private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + fun isRoot(isRoot: JsonField) = + apply { + this.isRoot = isRoot + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -374,7 +428,10 @@ private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -383,66 +440,89 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DatasetEvent = DatasetEvent( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("created", created), - checkRequired("datasetId", datasetId), - checkRequired("projectId", projectId), - checkRequired("rootSpanId", rootSpanId), - checkRequired("spanId", spanId), - expected, - input, - isRoot, - metadata, - origin, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "created", created + ), + checkRequired( + "datasetId", datasetId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "rootSpanId", rootSpanId + ), + checkRequired( + "spanId", spanId + ), + expected, + input, + isRoot, + metadata, + origin, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -451,20 +531,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -473,38 +555,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -518,21 +608,13 @@ private constructor( /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin - @JsonCreator - private constructor( + class Origin @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** ID of the original event. */ @@ -548,13 +630,19 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -567,17 +655,18 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - id() - _xactId() - objectId() - objectType() - validated = true - } + id() + _xactId() + objectId() + objectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -587,6 +676,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -594,7 +684,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -607,82 +698,111 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -715,9 +835,11 @@ private constructor( * 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 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 { @@ -738,8 +860,8 @@ private constructor( * 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. + * 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) { @@ -759,7 +881,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -778,20 +900,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -800,11 +919,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -813,16 +932,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && datasetId == other.datasetId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && origin == other.origin && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && datasetId == other.datasetId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && origin == other.origin && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -831,6 +949,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, datasetId=$datasetId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, origin=$origin, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, datasetId=$datasetId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, origin=$origin, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 1b7d0197..fe58a5b8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of dataset events */ -class DatasetFeedbackParams -private constructor( +class DatasetFeedbackParams private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("feedback") - @ExcludeMissing - private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of dataset feedback items */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - feedback().forEach { it.validate() } - validated = true - } + feedback().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of dataset feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of dataset feedback items */ - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = + apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of dataset feedback items */ - fun addFeedback(feedback: FeedbackDatasetItem) = apply { - this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackDatasetItem) = + apply { + this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "feedback", feedback + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -174,8 +184,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -183,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DatasetFeedbackParams]. + * Returns a mutable builder for constructing an instance of + * [DatasetFeedbackParams]. * * The following fields are required: + * * ```java * .datasetId() * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetFeedbackParams]. */ @@ -204,163 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = apply { - datasetId = datasetFeedbackParams.datasetId - body = datasetFeedbackParams.body.toBuilder() - additionalHeaders = datasetFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = + apply { + datasetId = datasetFeedbackParams.datasetId + body = datasetFeedbackParams.body.toBuilder() + additionalHeaders = datasetFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFeedbackParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** A list of dataset feedback items */ - fun feedback(feedback: List) = apply { body.feedback(feedback) } + fun feedback(feedback: List) = + apply { + body.feedback(feedback) + } /** A list of dataset feedback items */ - fun feedback(feedback: JsonField>) = apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = + apply { + body.feedback(feedback) + } /** A list of dataset feedback items */ - fun addFeedback(feedback: FeedbackDatasetItem) = apply { body.addFeedback(feedback) } + fun addFeedback(feedback: FeedbackDatasetItem) = + apply { + body.addFeedback(feedback) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFeedbackParams = DatasetFeedbackParams( - checkRequired("datasetId", datasetId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetFeedbackParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetFeedbackParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index e045595c..a1612e8b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -12,12 +12,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but + * with the parameters in the URL query rather than in the request body. For more + * complex queries, use the `POST /btql` endpoint. */ -class DatasetFetchParams -private constructor( +class DatasetFetchParams private constructor( private val datasetId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -25,6 +24,7 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -33,52 +33,55 @@ private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -89,20 +92,36 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.maxRootSpanId?.let { + queryParams.put( + "max_root_span_id", listOf(it.toString()) + ) + } + this.maxXactId?.let { + queryParams.put( + "max_xact_id", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -113,11 +132,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetFetchParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetFetchParams]. */ @@ -133,263 +154,310 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFetchParams: DatasetFetchParams) = apply { - datasetId = datasetFetchParams.datasetId - limit = datasetFetchParams.limit - maxRootSpanId = datasetFetchParams.maxRootSpanId - maxXactId = datasetFetchParams.maxXactId - version = datasetFetchParams.version - additionalHeaders = datasetFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFetchParams: DatasetFetchParams) = + apply { + datasetId = datasetFetchParams.datasetId + limit = datasetFetchParams.limit + maxRootSpanId = datasetFetchParams.maxRootSpanId + maxXactId = datasetFetchParams.maxXactId + version = datasetFetchParams.version + additionalHeaders = datasetFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFetchParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String?) = + apply { + this.maxXactId = maxXactId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFetchParams = DatasetFetchParams( - checkRequired("datasetId", datasetId), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 02ffad07..d0c8d415 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -22,138 +22,146 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but + * with the parameters in the request body rather than in the URL query. For more + * complex queries, use the `POST /btql` endpoint. */ -class DatasetFetchPostParams -private constructor( +class DatasetFetchPostParams private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ fun datasetId(): String = datasetId /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun _version(): JsonField = body._version() @@ -163,169 +171,168 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") - @ExcludeMissing - private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") - @ExcludeMissing - private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") - @ExcludeMissing - private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(): Optional = - Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(): Optional = - Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + @JsonProperty("limit") + @ExcludeMissing + fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") + @ExcludeMissing + fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -333,25 +340,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true } - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -365,261 +374,284 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { this.limit = limit } + fun limit(limit: JsonField) = + apply { + this.limit = limit + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = + apply { + this.maxXactId = maxXactId + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = + apply { + this.version = version + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,8 +660,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -637,14 +668,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DatasetFetchPostParams]. + * Returns a mutable builder for constructing an instance of + * [DatasetFetchPostParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetFetchPostParams]. */ @@ -657,358 +691,431 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = apply { - datasetId = datasetFetchPostParams.datasetId - body = datasetFetchPostParams.body.toBuilder() - additionalHeaders = datasetFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = + apply { + datasetId = datasetFetchPostParams.datasetId + body = datasetFetchPostParams.body.toBuilder() + additionalHeaders = datasetFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFetchPostParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: String?) = apply { body.cursor(cursor) } + fun cursor(cursor: String?) = + apply { + body.cursor(cursor) + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } + fun cursor(cursor: JsonField) = + apply { + body.cursor(cursor) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { body.limit(limit) } + fun limit(limit: Long?) = + apply { + body.limit(limit) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { body.limit(limit) } + fun limit(limit: JsonField) = + apply { + body.limit(limit) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: String?) = + apply { + body.maxXactId(maxXactId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: JsonField) = + apply { + body.maxXactId(maxXactId) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { body.version(version) } + fun version(version: String?) = + apply { + body.version(version) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { body.version(version) } + fun version(version: JsonField) = + apply { + body.version(version) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFetchPostParams = DatasetFetchPostParams( - checkRequired("datasetId", datasetId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetFetchPostParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 043cce99..dc6fca8e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the dataset */ -class DatasetInsertParams -private constructor( +class DatasetInsertParams private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of dataset events to insert */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - validated = true - } + events().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of dataset events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of dataset events to insert */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of dataset events to insert */ - fun addEvent(event: InsertDatasetEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertDatasetEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -185,12 +195,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetInsertParams]. * * The following fields are required: + * * ```java * .datasetId() * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetInsertParams]. */ @@ -203,161 +215,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetInsertParams: DatasetInsertParams) = apply { - datasetId = datasetInsertParams.datasetId - body = datasetInsertParams.body.toBuilder() - additionalHeaders = datasetInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetInsertParams: DatasetInsertParams) = + apply { + datasetId = datasetInsertParams.datasetId + body = datasetInsertParams.body.toBuilder() + additionalHeaders = datasetInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetInsertParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** A list of dataset events to insert */ - fun events(events: List) = apply { body.events(events) } + fun events(events: List) = + apply { + body.events(events) + } /** A list of dataset events to insert */ - fun events(events: JsonField>) = apply { body.events(events) } + fun events(events: JsonField>) = + apply { + body.events(events) + } /** A list of dataset events to insert */ - fun addEvent(event: InsertDatasetEvent) = apply { body.addEvent(event) } + fun addEvent(event: InsertDatasetEvent) = + apply { + body.addEvent(event) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetInsertParams = DatasetInsertParams( - checkRequired("datasetId", datasetId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetInsertParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetInsertParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index ae489e32..6218008e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.DatasetService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all datasets. The datasets are sorted by creation date, with the most recently-created - * datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most + * recently-created datasets coming first */ -class DatasetListPage -private constructor( +class DatasetListPage private constructor( private val datasetsService: DatasetService, private val params: DatasetListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListPage && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is DatasetListPage && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ - override fun toString() = - "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" + override fun toString() = "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - DatasetListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - DatasetListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { datasetsService.list(it) } + return getNextPageParams().map { datasetsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -84,16 +74,18 @@ private constructor( @JvmStatic fun of(datasetsService: DatasetService, params: DatasetListParams, response: Response) = - DatasetListPage(datasetsService, params, response) + DatasetListPage( + datasetsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -107,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [DatasetListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -143,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: DatasetListPage) : Iterable { + class AutoPager( + private val firstPage: DatasetListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index edf89d75..574330d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.DatasetServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all datasets. The datasets are sorted by creation date, with the most recently-created - * datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most + * recently-created datasets coming first */ -class DatasetListPageAsync -private constructor( +class DatasetListPageAsync private constructor( private val datasetsService: DatasetServiceAsync, private val params: DatasetListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListPageAsync && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is DatasetListPageAsync && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ - override fun toString() = - "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" + override fun toString() = "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - DatasetListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - DatasetListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { datasetsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + datasetsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,20 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - datasetsService: DatasetServiceAsync, - params: DatasetListParams, - response: Response, - ) = DatasetListPageAsync(datasetsService, params, response) + fun of(datasetsService: DatasetServiceAsync, params: DatasetListParams, response: Response) = + DatasetListPageAsync( + datasetsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -112,34 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** Returns a mutable builder for constructing an instance of [DatasetListPageAsync]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [DatasetListPageAsync]. + */ + @JvmStatic + fun builder() = Builder() } class Builder { @@ -148,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: DatasetListPageAsync) { + class AutoPager( + private val firstPage: DatasetListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Dataset) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Dataset) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 5ae454e3..63b098eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all datasets. The datasets are sorted by creation date, with the most recently-created - * datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most + * recently-created datasets coming first */ -class DatasetListParams -private constructor( +class DatasetListParams private constructor( private val datasetName: String?, private val endingBefore: String?, private val ids: Ids?, @@ -38,6 +37,7 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the dataset to search for */ @@ -46,15 +46,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,27 +86,61 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.datasetName?.let { queryParams.put("dataset_name", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.datasetName?.let { + queryParams.put( + "dataset_name", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): DatasetListParams = builder().build() + @JvmStatic + fun none(): DatasetListParams = builder().build() /** Returns a mutable builder for constructing an instance of [DatasetListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetListParams]. */ @@ -125,21 +159,25 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetListParams: DatasetListParams) = apply { - datasetName = datasetListParams.datasetName - endingBefore = datasetListParams.endingBefore - ids = datasetListParams.ids - limit = datasetListParams.limit - orgName = datasetListParams.orgName - projectId = datasetListParams.projectId - projectName = datasetListParams.projectName - startingAfter = datasetListParams.startingAfter - additionalHeaders = datasetListParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetListParams: DatasetListParams) = + apply { + datasetName = datasetListParams.datasetName + endingBefore = datasetListParams.endingBefore + ids = datasetListParams.ids + limit = datasetListParams.limit + orgName = datasetListParams.orgName + projectId = datasetListParams.projectId + projectName = datasetListParams.projectName + startingAfter = datasetListParams.startingAfter + additionalHeaders = datasetListParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() + } /** Name of the dataset to search for */ - fun datasetName(datasetName: String?) = apply { this.datasetName = datasetName } + fun datasetName(datasetName: String?) = + apply { + this.datasetName = datasetName + } /** Name of the dataset to search for */ fun datasetName(datasetName: Optional) = datasetName(datasetName.getOrNull()) @@ -147,47 +185,56 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -196,19 +243,28 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -216,146 +272,174 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetListParams = DatasetListParams( - datasetName, - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + datasetName, + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -373,19 +457,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -400,12 +484,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -415,60 +504,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index a75b190a..96f02be2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a dataset object by its id */ -class DatasetRetrieveParams -private constructor( +class DatasetRetrieveParams private constructor( private val datasetId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DatasetRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [DatasetRetrieveParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = apply { - datasetId = datasetRetrieveParams.datasetId - additionalHeaders = datasetRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = + apply { + datasetId = datasetRetrieveParams.datasetId + additionalHeaders = datasetRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetRetrieveParams = DatasetRetrieveParams( - checkRequired("datasetId", datasetId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index bea55242..b1a3a575 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -12,18 +12,21 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Summarize dataset */ -class DatasetSummarizeParams -private constructor( +class DatasetSummarizeParams private constructor( private val datasetId: String, private val summarizeData: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ fun datasetId(): String = datasetId - /** Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ + /** + * Whether to summarize the data. If false (or omitted), only the metadata will be + * returned. + */ fun summarizeData(): Optional = Optional.ofNullable(summarizeData) fun _additionalHeaders(): Headers = additionalHeaders @@ -33,17 +36,21 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.summarizeData?.let { queryParams.put("summarize_data", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.summarizeData?.let { + queryParams.put( + "summarize_data", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -51,14 +58,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DatasetSummarizeParams]. + * Returns a mutable builder for constructing an instance of + * [DatasetSummarizeParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetSummarizeParams]. */ @@ -71,149 +81,185 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = apply { - datasetId = datasetSummarizeParams.datasetId - summarizeData = datasetSummarizeParams.summarizeData - additionalHeaders = datasetSummarizeParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetSummarizeParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = + apply { + datasetId = datasetSummarizeParams.datasetId + summarizeData = datasetSummarizeParams.summarizeData + additionalHeaders = datasetSummarizeParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetSummarizeParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** - * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be + * returned. */ - fun summarizeData(summarizeData: Boolean?) = apply { this.summarizeData = summarizeData } + fun summarizeData(summarizeData: Boolean?) = + apply { + this.summarizeData = summarizeData + } /** - * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be + * returned. */ fun summarizeData(summarizeData: Boolean) = summarizeData(summarizeData as Boolean?) /** - * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be + * returned. */ - fun summarizeData(summarizeData: Optional) = - summarizeData(summarizeData.getOrNull()) + fun summarizeData(summarizeData: Optional) = summarizeData(summarizeData.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetSummarizeParams = DatasetSummarizeParams( - checkRequired("datasetId", datasetId), - summarizeData, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + summarizeData, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index a125d34b..dc748441 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a dataset object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class DatasetUpdateParams -private constructor( +class DatasetUpdateParams private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Dataset id */ @@ -61,39 +61,31 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Textual description of the dataset */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -107,10 +99,14 @@ private constructor( fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -118,23 +114,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + description() + metadata().ifPresent { it.validate() } + name() + validated = true } - description() - metadata().ifPresent { it.validate() } - name() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -146,12 +144,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - description = body.description - metadata = body.metadata - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + description = body.description + metadata = body.metadata + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -160,9 +159,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -171,7 +171,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -180,37 +183,52 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun name(name: JsonField) = + apply { + this.name = name + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(description, metadata, name, additionalProperties.toImmutable()) + Body( + description, + metadata, + name, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -219,8 +237,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Body{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -231,11 +248,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetUpdateParams]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetUpdateParams]. */ @@ -248,176 +267,232 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetUpdateParams: DatasetUpdateParams) = apply { - datasetId = datasetUpdateParams.datasetId - body = datasetUpdateParams.body.toBuilder() - additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetUpdateParams: DatasetUpdateParams) = + apply { + datasetId = datasetUpdateParams.datasetId + body = datasetUpdateParams.body.toBuilder() + additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = + apply { + this.datasetId = datasetId + } /** Textual description of the dataset */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the dataset */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetUpdateParams = DatasetUpdateParams( - checkRequired("datasetId", datasetId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "datasetId", datasetId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -426,20 +501,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -448,38 +525,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -492,15 +577,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "DatasetUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "DatasetUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 10a99c22..7cf44815 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -22,24 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class EnvVar -@JsonCreator -private constructor( +class EnvVar @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("used") - @ExcludeMissing - private val used: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("used") @ExcludeMissing private val used: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the environment variable */ @@ -61,13 +52,19 @@ private constructor( fun used(): Optional = Optional.ofNullable(used.getNullable("used")) /** Unique identifier for the environment variable */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -75,10 +72,14 @@ private constructor( fun _objectType(): JsonField = objectType /** Date of environment variable creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date the environment variable was last used */ - @JsonProperty("used") @ExcludeMissing fun _used(): JsonField = used + @JsonProperty("used") + @ExcludeMissing + fun _used(): JsonField = used @JsonAnyGetter @ExcludeMissing @@ -86,19 +87,20 @@ private constructor( private var validated: Boolean = false - fun validate(): EnvVar = apply { - if (validated) { - return@apply - } + fun validate(): EnvVar = + apply { + if (validated) { + return@apply + } - id() - name() - objectId() - objectType() - created() - used() - validated = true - } + id() + name() + objectId() + objectType() + created() + used() + validated = true + } fun toBuilder() = Builder().from(this) @@ -108,6 +110,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVar]. * * The following fields are required: + * * ```java * .id() * .name() @@ -115,7 +118,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVar]. */ @@ -130,39 +134,52 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVar: EnvVar) = apply { - id = envVar.id - name = envVar.name - objectId = envVar.objectId - objectType = envVar.objectType - created = envVar.created - used = envVar.used - additionalProperties = envVar.additionalProperties.toMutableMap() - } + internal fun from(envVar: EnvVar) = + apply { + id = envVar.id + name = envVar.name + objectId = envVar.objectId + objectType = envVar.objectType + created = envVar.created + used = envVar.used + additionalProperties = envVar.additionalProperties.toMutableMap() + } /** Unique identifier for the environment variable */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the environment variable */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Date of environment variable creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -171,7 +188,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of environment variable creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date the environment variable was last used */ fun used(used: OffsetDateTime?) = used(JsonField.ofNullable(used)) @@ -180,51 +200,73 @@ private constructor( fun used(used: Optional) = used(used.getOrNull()) /** Date the environment variable was last used */ - fun used(used: JsonField) = apply { this.used = used } + fun used(used: JsonField) = + apply { + this.used = used + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): EnvVar = EnvVar( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - created, - used, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + created, + used, + additionalProperties.toImmutable(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -248,9 +290,11 @@ private constructor( * 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 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 { @@ -258,17 +302,18 @@ private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -281,11 +326,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -298,23 +343,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -323,11 +365,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVar && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVar && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -336,6 +378,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "EnvVar{id=$id, name=$name, objectId=$objectId, objectType=$objectType, created=$created, used=$used, additionalProperties=$additionalProperties}" + override fun toString() = "EnvVar{id=$id, name=$name, objectId=$objectId, objectType=$objectType, created=$created, used=$used, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index b088aebe..2861902e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -24,14 +24,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new env_var. If there is an existing env_var with the same name as the one specified in - * the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the + * one specified in the request, will return the existing env_var unmodified */ -class EnvVarCreateParams -private constructor( +class EnvVarCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The name of the environment variable */ @@ -64,30 +64,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the environment variable */ @@ -103,10 +94,14 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -114,7 +109,9 @@ private constructor( fun _objectType(): JsonField = objectType /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -122,18 +119,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + value() + validated = true } - name() - objectId() - objectType() - value() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -142,13 +140,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -161,33 +161,41 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -196,43 +204,59 @@ private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = + apply { + this.value = value + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - value, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + value, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -241,8 +265,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -253,13 +276,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarCreateParams]. * * The following fields are required: + * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarCreateParams]. */ @@ -271,176 +296,239 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarCreateParams: EnvVarCreateParams) = apply { - body = envVarCreateParams.body.toBuilder() - additionalHeaders = envVarCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarCreateParams: EnvVarCreateParams) = + apply { + body = envVarCreateParams.body.toBuilder() + additionalHeaders = envVarCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarCreateParams.additionalQueryParams.toBuilder() + } /** The name of the environment variable */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** The name of the environment variable */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = apply { body.value(value) } + fun value(value: String?) = + apply { + body.value(value) + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { body.value(value) } + fun value(value: JsonField) = + apply { + body.value(value) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarCreateParams = EnvVarCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -464,9 +552,11 @@ private constructor( * 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 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 { @@ -474,17 +564,18 @@ private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -497,11 +588,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -514,23 +605,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -539,15 +627,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index d9d09741..2d714d22 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an env_var object by its id */ -class EnvVarDeleteParams -private constructor( +class EnvVarDeleteParams private constructor( private val envVarId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** EnvVar id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarDeleteParams]. * * The following fields are required: + * * ```java * .envVarId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarDeleteParams: EnvVarDeleteParams) = apply { - envVarId = envVarDeleteParams.envVarId - additionalHeaders = envVarDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = envVarDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(envVarDeleteParams: EnvVarDeleteParams) = + apply { + envVarId = envVarDeleteParams.envVarId + additionalHeaders = envVarDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = envVarDeleteParams.additionalBodyProperties.toMutableMap() + } /** EnvVar id */ - fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } + fun envVarId(envVarId: String) = + apply { + this.envVarId = envVarId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): EnvVarDeleteParams = EnvVarDeleteParams( - checkRequired("envVarId", envVarId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "envVarId", envVarId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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..53e139bb 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 @@ -26,11 +26,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all env_vars. The env_vars are sorted by creation date, with the most recently-created - * env_vars coming first + * List out all env_vars. The env_vars are sorted by creation date, with the most + * recently-created env_vars coming first */ -class EnvVarListParams -private constructor( +class EnvVarListParams private constructor( private val envVarName: String?, private val ids: Ids?, private val limit: Long?, @@ -38,14 +37,15 @@ private constructor( private val objectType: ObjectType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the env_var to search for */ fun envVarName(): Optional = Optional.ofNullable(envVarName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,24 +65,46 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.envVarName?.let { queryParams.put("env_var_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.objectId?.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType?.let { queryParams.put("object_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.envVarName?.let { + queryParams.put( + "env_var_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.objectId?.let { + queryParams.put( + "object_id", listOf(it.toString()) + ) + } + this.objectType?.let { + queryParams.put( + "object_type", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): EnvVarListParams = builder().build() + @JvmStatic + fun none(): EnvVarListParams = builder().build() /** Returns a mutable builder for constructing an instance of [EnvVarListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarListParams]. */ @@ -98,48 +120,58 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarListParams: EnvVarListParams) = apply { - envVarName = envVarListParams.envVarName - ids = envVarListParams.ids - limit = envVarListParams.limit - objectId = envVarListParams.objectId - objectType = envVarListParams.objectType - additionalHeaders = envVarListParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarListParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarListParams: EnvVarListParams) = + apply { + envVarName = envVarListParams.envVarName + ids = envVarListParams.ids + limit = envVarListParams.limit + objectId = envVarListParams.objectId + objectType = envVarListParams.objectType + additionalHeaders = envVarListParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarListParams.additionalQueryParams.toBuilder() + } /** Name of the env_var to search for */ - fun envVarName(envVarName: String?) = apply { this.envVarName = envVarName } + fun envVarName(envVarName: String?) = + apply { + this.envVarName = envVarName + } /** Name of the env_var to search for */ fun envVarName(envVarName: Optional) = envVarName(envVarName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -148,138 +180,170 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String?) = apply { this.objectId = objectId } + fun objectId(objectId: String?) = + apply { + this.objectId = objectId + } /** The id of the object the environment variable is scoped for */ 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: ObjectType?) = + apply { + this.objectType = objectType + } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: Optional) = objectType(objectType.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarListParams = EnvVarListParams( - envVarName, - ids, - limit, - objectId, - objectType, - additionalHeaders.build(), - additionalQueryParams.build(), + envVarName, + ids, + limit, + objectId, + objectType, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -297,19 +361,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -324,12 +388,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -339,62 +408,63 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -418,9 +488,11 @@ private constructor( * 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 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 { @@ -428,17 +500,18 @@ private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -451,11 +524,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -468,23 +541,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -493,15 +563,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 014c0040..405f6428 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -18,20 +18,19 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class EnvVarListResponse -@JsonCreator -private constructor( - @JsonProperty("objects") - @ExcludeMissing - private val objects: JsonField> = JsonMissing.of(), +class EnvVarListResponse @JsonCreator private constructor( + @JsonProperty("objects") @ExcludeMissing private val objects: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of env_var objects */ fun objects(): List = objects.getRequired("objects") /** A list of env_var objects */ - @JsonProperty("objects") @ExcludeMissing fun _objects(): JsonField> = objects + @JsonProperty("objects") + @ExcludeMissing + fun _objects(): JsonField> = objects @JsonAnyGetter @ExcludeMissing @@ -39,14 +38,15 @@ private constructor( private var validated: Boolean = false - fun validate(): EnvVarListResponse = apply { - if (validated) { - return@apply - } + fun validate(): EnvVarListResponse = + apply { + if (validated) { + return@apply + } - objects().forEach { it.validate() } - validated = true - } + objects().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -56,11 +56,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarListResponse]. * * The following fields are required: + * * ```java * .objects() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarListResponse]. */ @@ -70,59 +72,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarListResponse: EnvVarListResponse) = apply { - objects = envVarListResponse.objects.map { it.toMutableList() } - additionalProperties = envVarListResponse.additionalProperties.toMutableMap() - } + internal fun from(envVarListResponse: EnvVarListResponse) = + apply { + objects = envVarListResponse.objects.map { it.toMutableList() } + additionalProperties = envVarListResponse.additionalProperties.toMutableMap() + } /** A list of env_var objects */ fun objects(objects: List) = objects(JsonField.of(objects)) /** A list of env_var objects */ - fun objects(objects: JsonField>) = apply { - this.objects = objects.map { it.toMutableList() } - } + fun objects(objects: JsonField>) = + apply { + this.objects = objects.map { it.toMutableList() } + } /** A list of env_var objects */ - fun addObject(object_: EnvVar) = apply { - objects = - (objects ?: JsonField.of(mutableListOf())).also { + fun addObject(object_: EnvVar) = + apply { + objects = (objects ?: JsonField.of(mutableListOf())).also { checkKnown("objects", it).add(object_) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): EnvVarListResponse = EnvVarListResponse( - checkRequired("objects", objects).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "objects", objects + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarListResponse && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarListResponse && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -131,6 +143,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index da9d9b85..38c2e079 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -24,14 +24,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace env_var. If there is an existing env_var with the same name as the one - * specified in the request, will replace the existing env_var with the provided fields + * Create or replace env_var. If there is an existing env_var with the same name as + * the one specified in the request, will replace the existing env_var with the + * provided fields */ -class EnvVarReplaceParams -private constructor( +class EnvVarReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The name of the environment variable */ @@ -64,30 +65,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the environment variable */ @@ -103,10 +95,14 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -114,7 +110,9 @@ private constructor( fun _objectType(): JsonField = objectType /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -122,18 +120,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + value() + validated = true } - name() - objectId() - objectType() - value() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -142,13 +141,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -161,33 +162,41 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -196,43 +205,59 @@ private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = + apply { + this.value = value + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - value, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + value, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -241,8 +266,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -253,13 +277,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarReplaceParams]. * * The following fields are required: + * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarReplaceParams]. */ @@ -271,176 +297,239 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarReplaceParams: EnvVarReplaceParams) = apply { - body = envVarReplaceParams.body.toBuilder() - additionalHeaders = envVarReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarReplaceParams: EnvVarReplaceParams) = + apply { + body = envVarReplaceParams.body.toBuilder() + additionalHeaders = envVarReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarReplaceParams.additionalQueryParams.toBuilder() + } /** The name of the environment variable */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** The name of the environment variable */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + fun objectId(objectId: JsonField) = + apply { + body.objectId(objectId) + } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } + fun objectType(objectType: ObjectType) = + apply { + body.objectType(objectType) + } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } + fun objectType(objectType: JsonField) = + apply { + body.objectType(objectType) + } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = apply { body.value(value) } + fun value(value: String?) = + apply { + body.value(value) + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { body.value(value) } + fun value(value: JsonField) = + apply { + body.value(value) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarReplaceParams = EnvVarReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -464,9 +553,11 @@ private constructor( * 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 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 { @@ -474,17 +565,18 @@ private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -497,11 +589,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -514,23 +606,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -539,15 +628,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 0e424916..ef2d0266 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an env_var object by its id */ -class EnvVarRetrieveParams -private constructor( +class EnvVarRetrieveParams private constructor( private val envVarId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** EnvVar id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EnvVarRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [EnvVarRetrieveParams]. * * The following fields are required: + * * ```java * .envVarId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = apply { - envVarId = envVarRetrieveParams.envVarId - additionalHeaders = envVarRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = + apply { + envVarId = envVarRetrieveParams.envVarId + additionalHeaders = envVarRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarRetrieveParams.additionalQueryParams.toBuilder() + } /** EnvVar id */ - fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } + fun envVarId(envVarId: String) = + apply { + this.envVarId = envVarId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( - checkRequired("envVarId", envVarId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "envVarId", envVarId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 11d4bded..a937e768 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an env_var object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class EnvVarUpdateParams -private constructor( +class EnvVarUpdateParams private constructor( private val envVarId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** EnvVar id */ @@ -55,31 +55,26 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the environment variable */ @@ -89,10 +84,14 @@ private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -100,15 +99,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - value() - validated = true - } + name() + value() + validated = true + } fun toBuilder() = Builder().from(this) @@ -118,11 +118,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -133,17 +135,21 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -152,37 +158,53 @@ private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = + apply { + this.value = value + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(checkRequired("name", name), value, additionalProperties.toImmutable()) + Body( + checkRequired( + "name", name + ), + value, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -191,8 +213,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -203,12 +224,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [EnvVarUpdateParams]. * * The following fields are required: + * * ```java * .envVarId() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EnvVarUpdateParams]. */ @@ -221,167 +244,218 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarUpdateParams: EnvVarUpdateParams) = apply { - envVarId = envVarUpdateParams.envVarId - body = envVarUpdateParams.body.toBuilder() - additionalHeaders = envVarUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarUpdateParams: EnvVarUpdateParams) = + apply { + envVarId = envVarUpdateParams.envVarId + body = envVarUpdateParams.body.toBuilder() + additionalHeaders = envVarUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarUpdateParams.additionalQueryParams.toBuilder() + } /** EnvVar id */ - fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } + fun envVarId(envVarId: String) = + apply { + this.envVarId = envVarId + } /** The name of the environment variable */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** The name of the environment variable */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = apply { body.value(value) } + fun value(value: String?) = + apply { + body.value(value) + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = apply { body.value(value) } + fun value(value: JsonField) = + apply { + body.value(value) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarUpdateParams = EnvVarUpdateParams( - checkRequired("envVarId", envVarId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "envVarId", envVarId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EnvVarUpdateParams{envVarId=$envVarId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EnvVarUpdateParams{envVarId=$envVarId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 84bb86ae..63803002 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -35,17 +35,18 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into the - * Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and scoring - * functions. The API will then run the evaluation, create an experiment, and return the results - * along with a link to the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is + * built into the Braintrust SDK. In the Eval API, you provide pointers to a + * dataset, task function, and scoring functions. The API will then run the + * evaluation, create an experiment, and return the results along with a link to + * the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ -class EvalCreateParams -private constructor( +class EvalCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The dataset to use */ @@ -61,26 +62,26 @@ private constructor( fun task(): Task = body.task() /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ fun baseExperimentId(): Optional = body.baseExperimentId() /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ fun baseExperimentName(): Optional = body.baseExperimentName() /** - * An optional name for the experiment created by this eval. If it conflicts with an existing - * experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ fun experimentName(): Optional = body.experimentName() /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ fun gitMetadataSettings(): Optional = body.gitMetadataSettings() @@ -88,14 +89,14 @@ private constructor( fun isPublic(): Optional = body.isPublic() /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in - * which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ fun maxConcurrency(): Optional = body.maxConcurrency() /** - * Optional experiment-level metadata to store about the evaluation. You can later use this to - * slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ fun metadata(): Optional = body.metadata() @@ -103,22 +104,22 @@ private constructor( fun repoInfo(): Optional = body.repoInfo() /** - * Whether to stream the results of the eval. If true, the request will return two events: one - * to indicate the experiment has started, and another upon completion. If false, the request - * will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ fun stream(): Optional = body.stream() /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which - * case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(): Optional = body.timeout() /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(): Optional = body.trialCount() @@ -135,26 +136,26 @@ private constructor( fun _task(): JsonField = body._task() /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ fun _baseExperimentId(): JsonField = body._baseExperimentId() /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ fun _baseExperimentName(): JsonField = body._baseExperimentName() /** - * An optional name for the experiment created by this eval. If it conflicts with an existing - * experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ fun _experimentName(): JsonField = body._experimentName() /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ fun _gitMetadataSettings(): JsonField = body._gitMetadataSettings() @@ -162,14 +163,14 @@ private constructor( fun _isPublic(): JsonField = body._isPublic() /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in - * which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ fun _maxConcurrency(): JsonField = body._maxConcurrency() /** - * Optional experiment-level metadata to store about the evaluation. You can later use this to - * slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ fun _metadata(): JsonField = body._metadata() @@ -177,22 +178,22 @@ private constructor( fun _repoInfo(): JsonField = body._repoInfo() /** - * Whether to stream the results of the eval. If true, the request will return two events: one - * to indicate the experiment has started, and another upon completion. If false, the request - * will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ fun _stream(): JsonField = body._stream() /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which - * case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun _timeout(): JsonField = body._timeout() /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun _trialCount(): JsonField = body._trialCount() @@ -202,59 +203,32 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( + class Body @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField> = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField> = JsonMissing.of(), @JsonProperty("task") @ExcludeMissing private val task: JsonField = JsonMissing.of(), - @JsonProperty("base_experiment_id") - @ExcludeMissing - private val baseExperimentId: JsonField = JsonMissing.of(), - @JsonProperty("base_experiment_name") - @ExcludeMissing - private val baseExperimentName: JsonField = JsonMissing.of(), - @JsonProperty("experiment_name") - @ExcludeMissing - private val experimentName: JsonField = JsonMissing.of(), - @JsonProperty("git_metadata_settings") - @ExcludeMissing - private val gitMetadataSettings: JsonField = JsonMissing.of(), - @JsonProperty("is_public") - @ExcludeMissing - private val isPublic: JsonField = JsonMissing.of(), - @JsonProperty("max_concurrency") - @ExcludeMissing - private val maxConcurrency: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") - @ExcludeMissing - private val repoInfo: JsonField = JsonMissing.of(), - @JsonProperty("stream") - @ExcludeMissing - private val stream: JsonField = JsonMissing.of(), - @JsonProperty("timeout") - @ExcludeMissing - private val timeout: JsonField = JsonMissing.of(), - @JsonProperty("trial_count") - @ExcludeMissing - private val trialCount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("base_experiment_id") @ExcludeMissing private val baseExperimentId: JsonField = JsonMissing.of(), + @JsonProperty("base_experiment_name") @ExcludeMissing private val baseExperimentName: JsonField = JsonMissing.of(), + @JsonProperty("experiment_name") @ExcludeMissing private val experimentName: JsonField = JsonMissing.of(), + @JsonProperty("git_metadata_settings") @ExcludeMissing private val gitMetadataSettings: JsonField = JsonMissing.of(), + @JsonProperty("is_public") @ExcludeMissing private val isPublic: JsonField = JsonMissing.of(), + @JsonProperty("max_concurrency") @ExcludeMissing private val maxConcurrency: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), + @JsonProperty("stream") @ExcludeMissing private val stream: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing private val timeout: JsonField = JsonMissing.of(), + @JsonProperty("trial_count") @ExcludeMissing private val trialCount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The dataset to use */ @@ -270,46 +244,41 @@ private constructor( fun task(): Task = task.getRequired("task") /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(): Optional = - Optional.ofNullable(baseExperimentId.getNullable("base_experiment_id")) + fun baseExperimentId(): Optional = Optional.ofNullable(baseExperimentId.getNullable("base_experiment_id")) /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(): Optional = - Optional.ofNullable(baseExperimentName.getNullable("base_experiment_name")) + fun baseExperimentName(): Optional = Optional.ofNullable(baseExperimentName.getNullable("base_experiment_name")) /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(): Optional = - Optional.ofNullable(experimentName.getNullable("experiment_name")) + fun experimentName(): Optional = Optional.ofNullable(experimentName.getNullable("experiment_name")) /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(): Optional = - Optional.ofNullable(gitMetadataSettings.getNullable("git_metadata_settings")) + fun gitMetadataSettings(): Optional = Optional.ofNullable(gitMetadataSettings.getNullable("git_metadata_settings")) /** Whether the experiment should be public. Defaults to false. */ fun isPublic(): Optional = Optional.ofNullable(isPublic.getNullable("is_public")) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(): Optional = - Optional.ofNullable(maxConcurrency.getNullable("max_concurrency")) + fun maxConcurrency(): Optional = Optional.ofNullable(maxConcurrency.getNullable("max_concurrency")) /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -317,107 +286,124 @@ private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(): Optional = Optional.ofNullable(timeout.getNullable("timeout")) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ - fun trialCount(): Optional = - Optional.ofNullable(trialCount.getNullable("trial_count")) + fun trialCount(): Optional = Optional.ofNullable(trialCount.getNullable("trial_count")) /** The dataset to use */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data /** Unique identifier for the project to run the eval in */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** The functions to score the eval on */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField> = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField> = scores /** The function to evaluate */ - @JsonProperty("task") @ExcludeMissing fun _task(): JsonField = task + @JsonProperty("task") + @ExcludeMissing + fun _task(): JsonField = task /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ @JsonProperty("base_experiment_id") @ExcludeMissing fun _baseExperimentId(): JsonField = baseExperimentId /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ @JsonProperty("base_experiment_name") @ExcludeMissing fun _baseExperimentName(): JsonField = baseExperimentName /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName(): JsonField = experimentName /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ @JsonProperty("git_metadata_settings") @ExcludeMissing fun _gitMetadataSettings(): JsonField = gitMetadataSettings /** Whether the experiment should be public. Defaults to false. */ - @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField = isPublic + @JsonProperty("is_public") + @ExcludeMissing + fun _isPublic(): JsonField = isPublic /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ @JsonProperty("max_concurrency") @ExcludeMissing fun _maxConcurrency(): JsonField = maxConcurrency /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo(): JsonField = repoInfo /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ - @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream + @JsonProperty("stream") + @ExcludeMissing + fun _stream(): JsonField = stream /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ - @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + @JsonProperty("timeout") + @ExcludeMissing + fun _timeout(): JsonField = timeout /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ @JsonProperty("trial_count") @ExcludeMissing @@ -429,28 +415,29 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } - - data().validate() - projectId() - scores().forEach { it.validate() } - task().validate() - baseExperimentId() - baseExperimentName() - experimentName() - gitMetadataSettings().ifPresent { it.validate() } - isPublic() - maxConcurrency() - metadata().ifPresent { it.validate() } - repoInfo().ifPresent { it.validate() } - stream() - timeout() - trialCount() - validated = true - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + data().validate() + projectId() + scores().forEach { it.validate() } + task().validate() + baseExperimentId() + baseExperimentName() + experimentName() + gitMetadataSettings().ifPresent { it.validate() } + isPublic() + maxConcurrency() + metadata().ifPresent { it.validate() } + repoInfo().ifPresent { it.validate() } + stream() + timeout() + trialCount() + validated = true + } fun toBuilder() = Builder().from(this) @@ -460,6 +447,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .data() * .projectId() @@ -467,7 +455,8 @@ private constructor( * .task() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -491,87 +480,93 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - data = body.data - projectId = body.projectId - scores = body.scores.map { it.toMutableList() } - task = body.task - baseExperimentId = body.baseExperimentId - baseExperimentName = body.baseExperimentName - experimentName = body.experimentName - gitMetadataSettings = body.gitMetadataSettings - isPublic = body.isPublic - maxConcurrency = body.maxConcurrency - metadata = body.metadata - repoInfo = body.repoInfo - stream = body.stream - timeout = body.timeout - trialCount = body.trialCount - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + data = body.data + projectId = body.projectId + scores = body.scores.map { it.toMutableList() } + task = body.task + baseExperimentId = body.baseExperimentId + baseExperimentName = body.baseExperimentName + experimentName = body.experimentName + gitMetadataSettings = body.gitMetadataSettings + isPublic = body.isPublic + maxConcurrency = body.maxConcurrency + metadata = body.metadata + repoInfo = body.repoInfo + stream = body.stream + timeout = body.timeout + trialCount = body.trialCount + additionalProperties = body.additionalProperties.toMutableMap() + } /** The dataset to use */ fun data(data: Data) = data(JsonField.of(data)) /** The dataset to use */ - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } /** Dataset id */ fun data(datasetId: Data.DatasetId) = data(Data.ofDatasetId(datasetId)) /** Project and dataset name */ - fun data(projectDatasetName: Data.ProjectDatasetName) = - data(Data.ofProjectDatasetName(projectDatasetName)) + fun data(projectDatasetName: Data.ProjectDatasetName) = data(Data.ofProjectDatasetName(projectDatasetName)) /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** The functions to score the eval on */ fun scores(scores: List) = scores(JsonField.of(scores)) /** The functions to score the eval on */ - fun scores(scores: JsonField>) = apply { - this.scores = scores.map { it.toMutableList() } - } + fun scores(scores: JsonField>) = + apply { + this.scores = scores.map { it.toMutableList() } + } /** The functions to score the eval on */ - fun addScore(score: Score) = apply { - scores = - (scores ?: JsonField.of(mutableListOf())).also { + fun addScore(score: Score) = + apply { + scores = (scores ?: JsonField.of(mutableListOf())).also { checkKnown("scores", it).add(score) } - } + } /** Function id */ fun addScore(functionId: Score.FunctionId) = addScore(Score.ofFunctionId(functionId)) /** Project name and slug */ - fun addScore(projectSlug: Score.ProjectSlug) = - addScore(Score.ofProjectSlug(projectSlug)) + fun addScore(projectSlug: Score.ProjectSlug) = addScore(Score.ofProjectSlug(projectSlug)) /** Global function name */ - fun addScore(globalFunction: Score.GlobalFunction) = - addScore(Score.ofGlobalFunction(globalFunction)) + fun addScore(globalFunction: Score.GlobalFunction) = addScore(Score.ofGlobalFunction(globalFunction)) /** Prompt session id */ - fun addScore(promptSessionId: Score.PromptSessionId) = - addScore(Score.ofPromptSessionId(promptSessionId)) + fun addScore(promptSessionId: Score.PromptSessionId) = addScore(Score.ofPromptSessionId(promptSessionId)) /** Inline code function */ fun addScore(inlineCode: Score.InlineCode) = addScore(Score.ofInlineCode(inlineCode)) /** Inline prompt definition */ - fun addScore(inlinePrompt: Score.InlinePrompt) = - addScore(Score.ofInlinePrompt(inlinePrompt)) + fun addScore(inlinePrompt: Score.InlinePrompt) = addScore(Score.ofInlinePrompt(inlinePrompt)) /** The function to evaluate */ fun task(task: Task) = task(JsonField.of(task)) /** The function to evaluate */ - fun task(task: JsonField) = apply { this.task = task } + fun task(task: JsonField) = + apply { + this.task = task + } /** Function id */ fun task(functionId: Task.FunctionId) = task(Task.ofFunctionId(functionId)) @@ -580,12 +575,10 @@ private constructor( fun task(projectSlug: Task.ProjectSlug) = task(Task.ofProjectSlug(projectSlug)) /** Global function name */ - fun task(globalFunction: Task.GlobalFunction) = - task(Task.ofGlobalFunction(globalFunction)) + fun task(globalFunction: Task.GlobalFunction) = task(Task.ofGlobalFunction(globalFunction)) /** Prompt session id */ - fun task(promptSessionId: Task.PromptSessionId) = - task(Task.ofPromptSessionId(promptSessionId)) + fun task(promptSessionId: Task.PromptSessionId) = task(Task.ofPromptSessionId(promptSessionId)) /** Inline code function */ fun task(inlineCode: Task.InlineCode) = task(Task.ofInlineCode(inlineCode)) @@ -594,85 +587,82 @@ private constructor( fun task(inlinePrompt: Task.InlinePrompt) = task(Task.ofInlinePrompt(inlinePrompt)) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: String?) = - baseExperimentId(JsonField.ofNullable(baseExperimentId)) + fun baseExperimentId(baseExperimentId: String?) = baseExperimentId(JsonField.ofNullable(baseExperimentId)) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: Optional) = - baseExperimentId(baseExperimentId.getOrNull()) + fun baseExperimentId(baseExperimentId: Optional) = baseExperimentId(baseExperimentId.getOrNull()) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: JsonField) = apply { - this.baseExperimentId = baseExperimentId - } + fun baseExperimentId(baseExperimentId: JsonField) = + apply { + this.baseExperimentId = baseExperimentId + } /** - * An optional experiment name to use as a base. If specified, the new experiment will - * be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: String?) = - baseExperimentName(JsonField.ofNullable(baseExperimentName)) + fun baseExperimentName(baseExperimentName: String?) = baseExperimentName(JsonField.ofNullable(baseExperimentName)) /** - * An optional experiment name to use as a base. If specified, the new experiment will - * be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: Optional) = - baseExperimentName(baseExperimentName.getOrNull()) + fun baseExperimentName(baseExperimentName: Optional) = baseExperimentName(baseExperimentName.getOrNull()) /** - * An optional experiment name to use as a base. If specified, the new experiment will - * be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: JsonField) = apply { - this.baseExperimentName = baseExperimentName - } + fun baseExperimentName(baseExperimentName: JsonField) = + apply { + this.baseExperimentName = baseExperimentName + } /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: String) = - experimentName(JsonField.of(experimentName)) + fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: JsonField) = apply { - this.experimentName = experimentName - } + fun experimentName(experimentName: JsonField) = + apply { + this.experimentName = experimentName + } /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = - gitMetadataSettings(JsonField.ofNullable(gitMetadataSettings)) + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = gitMetadataSettings(JsonField.ofNullable(gitMetadataSettings)) /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: Optional) = - gitMetadataSettings(gitMetadataSettings.getOrNull()) + fun gitMetadataSettings(gitMetadataSettings: Optional) = gitMetadataSettings(gitMetadataSettings.getOrNull()) /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { - this.gitMetadataSettings = gitMetadataSettings - } + fun gitMetadataSettings(gitMetadataSettings: JsonField) = + apply { + this.gitMetadataSettings = gitMetadataSettings + } /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: Boolean?) = isPublic(JsonField.ofNullable(isPublic)) @@ -684,14 +674,16 @@ private constructor( fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: JsonField) = apply { this.isPublic = isPublic } + fun isPublic(isPublic: JsonField) = + apply { + this.isPublic = isPublic + } /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Double?) = - maxConcurrency(JsonField.ofNullable(maxConcurrency)) + fun maxConcurrency(maxConcurrency: Double?) = maxConcurrency(JsonField.ofNullable(maxConcurrency)) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to @@ -703,28 +695,31 @@ private constructor( * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Optional) = - maxConcurrency(maxConcurrency.getOrNull()) + fun maxConcurrency(maxConcurrency: Optional) = maxConcurrency(maxConcurrency.getOrNull()) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: JsonField) = apply { - this.maxConcurrency = maxConcurrency - } + fun maxConcurrency(maxConcurrency: JsonField) = + apply { + this.maxConcurrency = maxConcurrency + } /** - * Optional experiment-level metadata to store about the evaluation. You can later use - * this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * Optional experiment-level metadata to store about the evaluation. You can later use - * this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -733,120 +728,147 @@ private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: JsonField) = + apply { + this.repoInfo = repoInfo + } /** * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. If - * false, the request will return the evaluation's summary upon completion. + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ fun stream(stream: Boolean) = stream(JsonField.of(stream)) /** * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. If - * false, the request will return the evaluation's summary upon completion. + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ - fun stream(stream: JsonField) = apply { this.stream = stream } + fun stream(stream: JsonField) = + apply { + this.stream = stream + } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Double) = timeout(timeout as Double?) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ - fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + fun timeout(timeout: JsonField) = + apply { + this.timeout = timeout + } /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double?) = trialCount(JsonField.ofNullable(trialCount)) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ - fun trialCount(trialCount: JsonField) = apply { this.trialCount = trialCount } + fun trialCount(trialCount: JsonField) = + apply { + this.trialCount = trialCount + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("data", data), - checkRequired("projectId", projectId), - checkRequired("scores", scores).map { it.toImmutable() }, - checkRequired("task", task), - baseExperimentId, - baseExperimentName, - experimentName, - gitMetadataSettings, - isPublic, - maxConcurrency, - metadata, - repoInfo, - stream, - timeout, - trialCount, - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "scores", scores + ).map { it.toImmutable() }, + checkRequired( + "task", task + ), + baseExperimentId, + baseExperimentName, + experimentName, + gitMetadataSettings, + isPublic, + maxConcurrency, + metadata, + repoInfo, + stream, + timeout, + trialCount, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -855,8 +877,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" + override fun toString() = "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -867,6 +888,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [EvalCreateParams]. * * The following fields are required: + * * ```java * .data() * .projectId() @@ -874,7 +896,8 @@ private constructor( * .task() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [EvalCreateParams]. */ @@ -886,170 +909,246 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(evalCreateParams: EvalCreateParams) = apply { - body = evalCreateParams.body.toBuilder() - additionalHeaders = evalCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = evalCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(evalCreateParams: EvalCreateParams) = + apply { + body = evalCreateParams.body.toBuilder() + additionalHeaders = evalCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = evalCreateParams.additionalQueryParams.toBuilder() + } /** The dataset to use */ - fun data(data: Data) = apply { body.data(data) } + fun data(data: Data) = + apply { + body.data(data) + } /** The dataset to use */ - fun data(data: JsonField) = apply { body.data(data) } + fun data(data: JsonField) = + apply { + body.data(data) + } /** Dataset id */ - fun data(datasetId: Data.DatasetId) = apply { body.data(datasetId) } + fun data(datasetId: Data.DatasetId) = + apply { + body.data(datasetId) + } /** Project and dataset name */ - fun data(projectDatasetName: Data.ProjectDatasetName) = apply { - body.data(projectDatasetName) - } + fun data(projectDatasetName: Data.ProjectDatasetName) = + apply { + body.data(projectDatasetName) + } /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** The functions to score the eval on */ - fun scores(scores: List) = apply { body.scores(scores) } + fun scores(scores: List) = + apply { + body.scores(scores) + } /** The functions to score the eval on */ - fun scores(scores: JsonField>) = apply { body.scores(scores) } + fun scores(scores: JsonField>) = + apply { + body.scores(scores) + } /** The functions to score the eval on */ - fun addScore(score: Score) = apply { body.addScore(score) } + fun addScore(score: Score) = + apply { + body.addScore(score) + } /** Function id */ - fun addScore(functionId: Score.FunctionId) = apply { body.addScore(functionId) } + fun addScore(functionId: Score.FunctionId) = + apply { + body.addScore(functionId) + } /** Project name and slug */ - fun addScore(projectSlug: Score.ProjectSlug) = apply { body.addScore(projectSlug) } + fun addScore(projectSlug: Score.ProjectSlug) = + apply { + body.addScore(projectSlug) + } /** Global function name */ - fun addScore(globalFunction: Score.GlobalFunction) = apply { body.addScore(globalFunction) } + fun addScore(globalFunction: Score.GlobalFunction) = + apply { + body.addScore(globalFunction) + } /** Prompt session id */ - fun addScore(promptSessionId: Score.PromptSessionId) = apply { - body.addScore(promptSessionId) - } + fun addScore(promptSessionId: Score.PromptSessionId) = + apply { + body.addScore(promptSessionId) + } /** Inline code function */ - fun addScore(inlineCode: Score.InlineCode) = apply { body.addScore(inlineCode) } + fun addScore(inlineCode: Score.InlineCode) = + apply { + body.addScore(inlineCode) + } /** Inline prompt definition */ - fun addScore(inlinePrompt: Score.InlinePrompt) = apply { body.addScore(inlinePrompt) } + fun addScore(inlinePrompt: Score.InlinePrompt) = + apply { + body.addScore(inlinePrompt) + } /** The function to evaluate */ - fun task(task: Task) = apply { body.task(task) } + fun task(task: Task) = + apply { + body.task(task) + } /** The function to evaluate */ - fun task(task: JsonField) = apply { body.task(task) } + fun task(task: JsonField) = + apply { + body.task(task) + } /** Function id */ - fun task(functionId: Task.FunctionId) = apply { body.task(functionId) } + fun task(functionId: Task.FunctionId) = + apply { + body.task(functionId) + } /** Project name and slug */ - fun task(projectSlug: Task.ProjectSlug) = apply { body.task(projectSlug) } + fun task(projectSlug: Task.ProjectSlug) = + apply { + body.task(projectSlug) + } /** Global function name */ - fun task(globalFunction: Task.GlobalFunction) = apply { body.task(globalFunction) } + fun task(globalFunction: Task.GlobalFunction) = + apply { + body.task(globalFunction) + } /** Prompt session id */ - fun task(promptSessionId: Task.PromptSessionId) = apply { body.task(promptSessionId) } + fun task(promptSessionId: Task.PromptSessionId) = + apply { + body.task(promptSessionId) + } /** Inline code function */ - fun task(inlineCode: Task.InlineCode) = apply { body.task(inlineCode) } + fun task(inlineCode: Task.InlineCode) = + apply { + body.task(inlineCode) + } /** Inline prompt definition */ - fun task(inlinePrompt: Task.InlinePrompt) = apply { body.task(inlinePrompt) } + fun task(inlinePrompt: Task.InlinePrompt) = + apply { + body.task(inlinePrompt) + } /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: String?) = apply { - body.baseExperimentId(baseExperimentId) - } + fun baseExperimentId(baseExperimentId: String?) = + apply { + body.baseExperimentId(baseExperimentId) + } /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: Optional) = - baseExperimentId(baseExperimentId.getOrNull()) + fun baseExperimentId(baseExperimentId: Optional) = baseExperimentId(baseExperimentId.getOrNull()) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: JsonField) = apply { - body.baseExperimentId(baseExperimentId) - } + fun baseExperimentId(baseExperimentId: JsonField) = + apply { + body.baseExperimentId(baseExperimentId) + } /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: String?) = apply { - body.baseExperimentName(baseExperimentName) - } + fun baseExperimentName(baseExperimentName: String?) = + apply { + body.baseExperimentName(baseExperimentName) + } /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: Optional) = - baseExperimentName(baseExperimentName.getOrNull()) + fun baseExperimentName(baseExperimentName: Optional) = baseExperimentName(baseExperimentName.getOrNull()) /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment + * will be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: JsonField) = apply { - body.baseExperimentName(baseExperimentName) - } + fun baseExperimentName(baseExperimentName: JsonField) = + apply { + body.baseExperimentName(baseExperimentName) + } /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: String) = apply { body.experimentName(experimentName) } + fun experimentName(experimentName: String) = + apply { + body.experimentName(experimentName) + } /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with + * an existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: JsonField) = apply { - body.experimentName(experimentName) - } + fun experimentName(experimentName: JsonField) = + apply { + body.experimentName(experimentName) + } /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = apply { - body.gitMetadataSettings(gitMetadataSettings) - } + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = + apply { + body.gitMetadataSettings(gitMetadataSettings) + } /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: Optional) = - gitMetadataSettings(gitMetadataSettings.getOrNull()) + fun gitMetadataSettings(gitMetadataSettings: Optional) = gitMetadataSettings(gitMetadataSettings.getOrNull()) /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { - body.gitMetadataSettings(gitMetadataSettings) - } + fun gitMetadataSettings(gitMetadataSettings: JsonField) = + apply { + body.gitMetadataSettings(gitMetadataSettings) + } /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: Boolean?) = apply { body.isPublic(isPublic) } + fun isPublic(isPublic: Boolean?) = + apply { + body.isPublic(isPublic) + } /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) @@ -1058,259 +1157,332 @@ private constructor( fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: JsonField) = apply { body.isPublic(isPublic) } + fun isPublic(isPublic: JsonField) = + apply { + body.isPublic(isPublic) + } /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Double?) = apply { body.maxConcurrency(maxConcurrency) } + fun maxConcurrency(maxConcurrency: Double?) = + apply { + body.maxConcurrency(maxConcurrency) + } /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ fun maxConcurrency(maxConcurrency: Double) = maxConcurrency(maxConcurrency as Double?) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Optional) = - maxConcurrency(maxConcurrency.getOrNull()) + fun maxConcurrency(maxConcurrency: Optional) = maxConcurrency(maxConcurrency.getOrNull()) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to + * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: JsonField) = apply { - body.maxConcurrency(maxConcurrency) - } + fun maxConcurrency(maxConcurrency: JsonField) = + apply { + body.maxConcurrency(maxConcurrency) + } /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ - fun metadata(metadata: Metadata) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata) = + apply { + body.metadata(metadata) + } /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: RepoInfo?) = + apply { + body.repoInfo(repoInfo) + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: JsonField) = + apply { + body.repoInfo(repoInfo) + } /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ - fun stream(stream: Boolean) = apply { body.stream(stream) } + fun stream(stream: Boolean) = + apply { + body.stream(stream) + } /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two + * events: one to indicate the experiment has started, and another upon completion. + * If false, the request will return the evaluation's summary upon completion. */ - fun stream(stream: JsonField) = apply { body.stream(stream) } + fun stream(stream: JsonField) = + apply { + body.stream(stream) + } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ - fun timeout(timeout: Double?) = apply { body.timeout(timeout) } + fun timeout(timeout: Double?) = + apply { + body.timeout(timeout) + } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Double) = timeout(timeout as Double?) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to + * undefined, in which case there is no timeout. */ - fun timeout(timeout: JsonField) = apply { body.timeout(timeout) } + fun timeout(timeout: JsonField) = + apply { + body.timeout(timeout) + } /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ - fun trialCount(trialCount: Double?) = apply { body.trialCount(trialCount) } + fun trialCount(trialCount: Double?) = + apply { + body.trialCount(trialCount) + } /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for + * evaluating applications that have non-deterministic behavior and gives you both + * a stronger aggregate measure and a sense of the variance in the results. */ - fun trialCount(trialCount: JsonField) = apply { body.trialCount(trialCount) } + fun trialCount(trialCount: JsonField) = + apply { + body.trialCount(trialCount) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + fun putAdditionalQueryParam(key: String, value: String) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) + additionalQueryParams.put(key, value) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): EvalCreateParams = - EvalCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + EvalCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) } /** The dataset to use */ @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val datasetId: DatasetId? = null, private val projectDatasetName: ProjectDatasetName? = null, private val _json: JsonValue? = null, + ) { /** Dataset id */ fun datasetId(): Optional = Optional.ofNullable(datasetId) /** Project and dataset name */ - fun projectDatasetName(): Optional = - Optional.ofNullable(projectDatasetName) + fun projectDatasetName(): Optional = Optional.ofNullable(projectDatasetName) fun isDatasetId(): Boolean = datasetId != null @@ -1320,46 +1492,44 @@ private constructor( fun asDatasetId(): DatasetId = datasetId.getOrThrow("datasetId") /** Project and dataset name */ - fun asProjectDatasetName(): ProjectDatasetName = - projectDatasetName.getOrThrow("projectDatasetName") + fun asProjectDatasetName(): ProjectDatasetName = projectDatasetName.getOrThrow("projectDatasetName") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - datasetId != null -> visitor.visitDatasetId(datasetId) - projectDatasetName != null -> visitor.visitProjectDatasetName(projectDatasetName) - else -> visitor.unknown(_json) - } + return when { + datasetId != null -> visitor.visitDatasetId(datasetId) + projectDatasetName != null -> visitor.visitProjectDatasetName(projectDatasetName) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitDatasetId(datasetId: DatasetId) { - datasetId.validate() + datasetId.validate() } override fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName) { - projectDatasetName.validate() + projectDatasetName.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ + return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, projectDatasetName) /* spotless:on */ @@ -1375,15 +1545,18 @@ private constructor( companion object { /** Dataset id */ - @JvmStatic fun ofDatasetId(datasetId: DatasetId) = Data(datasetId = datasetId) + @JvmStatic + fun ofDatasetId(datasetId: DatasetId) = Data(datasetId = datasetId) /** Project and dataset name */ @JvmStatic - fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = - Data(projectDatasetName = projectDatasetName) + fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = Data(projectDatasetName = projectDatasetName) } - /** An interface that defines how to map each variant of [Data] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Data] to a value of type + * [T]. + */ interface Visitor { /** Dataset id */ @@ -1395,62 +1568,52 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(datasetId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(projectDatasetName = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(datasetId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(projectDatasetName = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.datasetId != null -> generator.writeObject(value.datasetId) - value.projectDatasetName != null -> - generator.writeObject(value.projectDatasetName) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.datasetId != null -> generator.writeObject(value.datasetId) + value.projectDatasetName != null -> generator.writeObject(value.projectDatasetName) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } /** Dataset id */ @NoAutoDetect - class DatasetId - @JsonCreator - private constructor( - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class DatasetId @JsonCreator private constructor( + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun datasetId(): String = datasetId.getRequired("dataset_id") @@ -1465,14 +1628,15 @@ private constructor( private var validated: Boolean = false - fun validate(): DatasetId = apply { - if (validated) { - return@apply - } + fun validate(): DatasetId = + apply { + if (validated) { + return@apply + } - datasetId() - validated = true - } + datasetId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1482,11 +1646,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [DatasetId]. * * The following fields are required: + * * ```java * .datasetId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [DatasetId]. */ @@ -1496,50 +1662,59 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetId: DatasetId) = apply { - this.datasetId = datasetId.datasetId - additionalProperties = datasetId.additionalProperties.toMutableMap() - } + internal fun from(datasetId: DatasetId) = + apply { + this.datasetId = datasetId.datasetId + additionalProperties = datasetId.additionalProperties.toMutableMap() + } fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DatasetId = DatasetId( - checkRequired("datasetId", datasetId), - additionalProperties.toImmutable(), + checkRequired( + "datasetId", datasetId + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1548,23 +1723,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" } /** Project and dataset name */ @NoAutoDetect - class ProjectDatasetName - @JsonCreator - private constructor( - @JsonProperty("dataset_name") - @ExcludeMissing - private val datasetName: JsonField = JsonMissing.of(), - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class ProjectDatasetName @JsonCreator private constructor( + @JsonProperty("dataset_name") @ExcludeMissing private val datasetName: JsonField = JsonMissing.of(), + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun datasetName(): String = datasetName.getRequired("dataset_name") @@ -1585,15 +1753,16 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectDatasetName = apply { - if (validated) { - return@apply - } + fun validate(): ProjectDatasetName = + apply { + if (validated) { + return@apply + } - datasetName() - projectName() - validated = true - } + datasetName() + projectName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1603,12 +1772,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectDatasetName]. * * The following fields are required: + * * ```java * .datasetName() * .projectName() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectDatasetName]. */ @@ -1619,60 +1790,71 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectDatasetName: ProjectDatasetName) = apply { - datasetName = projectDatasetName.datasetName - projectName = projectDatasetName.projectName - additionalProperties = projectDatasetName.additionalProperties.toMutableMap() - } + internal fun from(projectDatasetName: ProjectDatasetName) = + apply { + datasetName = projectDatasetName.datasetName + projectName = projectDatasetName.projectName + additionalProperties = projectDatasetName.additionalProperties.toMutableMap() + } fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) - fun datasetName(datasetName: JsonField) = apply { - this.datasetName = datasetName - } + fun datasetName(datasetName: JsonField) = + apply { + this.datasetName = datasetName + } fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectDatasetName = ProjectDatasetName( - checkRequired("datasetName", datasetName), - checkRequired("projectName", projectName), - additionalProperties.toImmutable(), + checkRequired( + "datasetName", datasetName + ), + checkRequired( + "projectName", projectName + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1681,16 +1863,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" } } /** The function to evaluate */ @JsonDeserialize(using = Score.Deserializer::class) @JsonSerialize(using = Score.Serializer::class) - class Score - private constructor( + class Score private constructor( private val functionId: FunctionId? = null, private val projectSlug: ProjectSlug? = null, private val globalFunction: GlobalFunction? = null, @@ -1698,6 +1878,7 @@ private constructor( private val inlineCode: InlineCode? = null, private val inlinePrompt: InlinePrompt? = null, private val _json: JsonValue? = null, + ) { /** Function id */ @@ -1751,60 +1932,59 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - functionId != null -> visitor.visitFunctionId(functionId) - projectSlug != null -> visitor.visitProjectSlug(projectSlug) - globalFunction != null -> visitor.visitGlobalFunction(globalFunction) - promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) - inlineCode != null -> visitor.visitInlineCode(inlineCode) - inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) - else -> visitor.unknown(_json) - } + return when { + functionId != null -> visitor.visitFunctionId(functionId) + projectSlug != null -> visitor.visitProjectSlug(projectSlug) + globalFunction != null -> visitor.visitGlobalFunction(globalFunction) + promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) + inlineCode != null -> visitor.visitInlineCode(inlineCode) + inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Score = apply { - if (validated) { - return@apply - } + fun validate(): Score = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitFunctionId(functionId: FunctionId) { - functionId.validate() + functionId.validate() } override fun visitProjectSlug(projectSlug: ProjectSlug) { - projectSlug.validate() + projectSlug.validate() } override fun visitGlobalFunction(globalFunction: GlobalFunction) { - globalFunction.validate() + globalFunction.validate() } override fun visitPromptSessionId(promptSessionId: PromptSessionId) { - promptSessionId.validate() + promptSessionId.validate() } override fun visitInlineCode(inlineCode: InlineCode) { - inlineCode.validate() + inlineCode.validate() } override fun visitInlinePrompt(inlinePrompt: InlinePrompt) { - inlinePrompt.validate() + inlinePrompt.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Score && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ + return /* spotless:off */ other is Score && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ @@ -1824,7 +2004,8 @@ private constructor( companion object { /** Function id */ - @JvmStatic fun ofFunctionId(functionId: FunctionId) = Score(functionId = functionId) + @JvmStatic + fun ofFunctionId(functionId: FunctionId) = Score(functionId = functionId) /** Project name and slug */ @JvmStatic @@ -1832,23 +2013,25 @@ private constructor( /** Global function name */ @JvmStatic - fun ofGlobalFunction(globalFunction: GlobalFunction) = - Score(globalFunction = globalFunction) + fun ofGlobalFunction(globalFunction: GlobalFunction) = Score(globalFunction = globalFunction) /** Prompt session id */ @JvmStatic - fun ofPromptSessionId(promptSessionId: PromptSessionId) = - Score(promptSessionId = promptSessionId) + fun ofPromptSessionId(promptSessionId: PromptSessionId) = Score(promptSessionId = promptSessionId) /** Inline code function */ - @JvmStatic fun ofInlineCode(inlineCode: InlineCode) = Score(inlineCode = inlineCode) + @JvmStatic + fun ofInlineCode(inlineCode: InlineCode) = Score(inlineCode = inlineCode) /** Inline prompt definition */ @JvmStatic fun ofInlinePrompt(inlinePrompt: InlinePrompt) = Score(inlinePrompt = inlinePrompt) } - /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Score] to a value of type + * [T]. + */ interface Visitor { /** Function id */ @@ -1872,85 +2055,69 @@ private constructor( /** * Maps an unknown variant of [Score] to a value of type [T]. * - * An instance of [Score] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Score] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Score: $json") + throw BraintrustInvalidDataException("Unknown Score: $json") } } internal class Deserializer : BaseDeserializer(Score::class) { override fun ObjectCodec.deserialize(node: JsonNode): Score { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(functionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(projectSlug = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(globalFunction = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(promptSessionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(inlineCode = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Score(inlinePrompt = it, _json = json) - } - - return Score(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(functionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(projectSlug = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(globalFunction = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(promptSessionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(inlineCode = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Score(inlinePrompt = it, _json = json) + } + + return Score(_json = json) } } internal class Serializer : BaseSerializer(Score::class) { - override fun serialize( - value: Score, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.functionId != null -> generator.writeObject(value.functionId) - value.projectSlug != null -> generator.writeObject(value.projectSlug) - value.globalFunction != null -> generator.writeObject(value.globalFunction) - value.promptSessionId != null -> generator.writeObject(value.promptSessionId) - value.inlineCode != null -> generator.writeObject(value.inlineCode) - value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Score") - } + override fun serialize(value: Score, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.functionId != null -> generator.writeObject(value.functionId) + value.projectSlug != null -> generator.writeObject(value.projectSlug) + value.globalFunction != null -> generator.writeObject(value.globalFunction) + value.promptSessionId != null -> generator.writeObject(value.promptSessionId) + value.inlineCode != null -> generator.writeObject(value.inlineCode) + value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Score") + } } } /** Function id */ @NoAutoDetect - class FunctionId - @JsonCreator - private constructor( - @JsonProperty("function_id") - @ExcludeMissing - private val functionId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class FunctionId @JsonCreator private constructor( + @JsonProperty("function_id") @ExcludeMissing private val functionId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The ID of the function */ @@ -1965,7 +2132,9 @@ private constructor( fun _functionId(): JsonField = functionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1973,15 +2142,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionId = apply { - if (validated) { - return@apply - } + fun validate(): FunctionId = + apply { + if (validated) { + return@apply + } - functionId() - version() - validated = true - } + functionId() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1991,11 +2161,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [FunctionId]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionId]. */ @@ -2006,62 +2178,73 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionId: FunctionId) = apply { - this.functionId = functionId.functionId - version = functionId.version - additionalProperties = functionId.additionalProperties.toMutableMap() - } + internal fun from(functionId: FunctionId) = + apply { + this.functionId = functionId.functionId + version = functionId.version + additionalProperties = functionId.additionalProperties.toMutableMap() + } /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) /** The ID of the function */ - fun functionId(functionId: JsonField) = apply { - this.functionId = functionId - } + fun functionId(functionId: JsonField) = + apply { + this.functionId = functionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionId = FunctionId( - checkRequired("functionId", functionId), - version, - additionalProperties.toImmutable(), + checkRequired( + "functionId", functionId + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2070,26 +2253,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" } /** Project name and slug */ @NoAutoDetect - class ProjectSlug - @JsonCreator - private constructor( - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class ProjectSlug @JsonCreator private constructor( + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the project containing the function */ @@ -2107,10 +2281,14 @@ private constructor( fun _projectName(): JsonField = projectName /** The slug of the function */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2118,16 +2296,17 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectSlug = apply { - if (validated) { - return@apply - } + fun validate(): ProjectSlug = + apply { + if (validated) { + return@apply + } - projectName() - slug() - version() - validated = true - } + projectName() + slug() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2137,12 +2316,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectSlug]. * * The following fields are required: + * * ```java * .projectName() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectSlug]. */ @@ -2154,70 +2335,86 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSlug: ProjectSlug) = apply { - projectName = projectSlug.projectName - slug = projectSlug.slug - version = projectSlug.version - additionalProperties = projectSlug.additionalProperties.toMutableMap() - } + internal fun from(projectSlug: ProjectSlug) = + apply { + projectName = projectSlug.projectName + slug = projectSlug.slug + version = projectSlug.version + additionalProperties = projectSlug.additionalProperties.toMutableMap() + } /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** The name of the project containing the function */ - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } /** The slug of the function */ fun slug(slug: String) = slug(JsonField.of(slug)) /** The slug of the function */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSlug = ProjectSlug( - checkRequired("projectName", projectName), - checkRequired("slug", slug), - version, - additionalProperties.toImmutable(), + checkRequired( + "projectName", projectName + ), + checkRequired( + "slug", slug + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2226,20 +2423,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" } /** Global function name */ @NoAutoDetect - class GlobalFunction - @JsonCreator - private constructor( - @JsonProperty("global_function") - @ExcludeMissing - private val globalFunction: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class GlobalFunction @JsonCreator private constructor( + @JsonProperty("global_function") @ExcludeMissing private val globalFunction: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** @@ -2262,14 +2454,15 @@ private constructor( private var validated: Boolean = false - fun validate(): GlobalFunction = apply { - if (validated) { - return@apply - } + fun validate(): GlobalFunction = + apply { + if (validated) { + return@apply + } - globalFunction() - validated = true - } + globalFunction() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2279,11 +2472,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GlobalFunction]. * * The following fields are required: + * * ```java * .globalFunction() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GlobalFunction]. */ @@ -2293,61 +2488,67 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(globalFunction: GlobalFunction) = apply { - this.globalFunction = globalFunction.globalFunction - additionalProperties = globalFunction.additionalProperties.toMutableMap() - } + internal fun from(globalFunction: GlobalFunction) = + apply { + this.globalFunction = globalFunction.globalFunction + additionalProperties = globalFunction.additionalProperties.toMutableMap() + } /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: String) = - globalFunction(JsonField.of(globalFunction)) + fun globalFunction(globalFunction: String) = globalFunction(JsonField.of(globalFunction)) /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: JsonField) = apply { - this.globalFunction = globalFunction - } + fun globalFunction(globalFunction: JsonField) = + apply { + this.globalFunction = globalFunction + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GlobalFunction = GlobalFunction( - checkRequired("globalFunction", globalFunction), - additionalProperties.toImmutable(), + checkRequired( + "globalFunction", globalFunction + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2356,31 +2557,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" + override fun toString() = "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" } /** Prompt session id */ @NoAutoDetect - class PromptSessionId - @JsonCreator - private constructor( - @JsonProperty("prompt_session_function_id") - @ExcludeMissing - private val promptSessionFunctionId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_session_id") - @ExcludeMissing - private val promptSessionId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class PromptSessionId @JsonCreator private constructor( + @JsonProperty("prompt_session_function_id") @ExcludeMissing private val promptSessionFunctionId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_session_id") @ExcludeMissing private val promptSessionId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(): String = - promptSessionFunctionId.getRequired("prompt_session_function_id") + fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") /** The ID of the prompt session */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") @@ -2399,7 +2590,9 @@ private constructor( fun _promptSessionId(): JsonField = promptSessionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2407,16 +2600,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptSessionId = apply { - if (validated) { - return@apply - } + fun validate(): PromptSessionId = + apply { + if (validated) { + return@apply + } - promptSessionFunctionId() - promptSessionId() - version() - validated = true - } + promptSessionFunctionId() + promptSessionId() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2426,12 +2620,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptSessionId]. * * The following fields are required: + * * ```java * .promptSessionFunctionId() * .promptSessionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptSessionId]. */ @@ -2443,74 +2639,86 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptSessionId: PromptSessionId) = apply { - promptSessionFunctionId = promptSessionId.promptSessionFunctionId - this.promptSessionId = promptSessionId.promptSessionId - version = promptSessionId.version - additionalProperties = promptSessionId.additionalProperties.toMutableMap() - } + internal fun from(promptSessionId: PromptSessionId) = + apply { + promptSessionFunctionId = promptSessionId.promptSessionFunctionId + this.promptSessionId = promptSessionId.promptSessionId + version = promptSessionId.version + additionalProperties = promptSessionId.additionalProperties.toMutableMap() + } /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: String) = - promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) + fun promptSessionFunctionId(promptSessionFunctionId: String) = promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { - this.promptSessionFunctionId = promptSessionFunctionId - } + fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = + apply { + this.promptSessionFunctionId = promptSessionFunctionId + } /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: String) = - promptSessionId(JsonField.of(promptSessionId)) + fun promptSessionId(promptSessionId: String) = promptSessionId(JsonField.of(promptSessionId)) /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: JsonField) = apply { - this.promptSessionId = promptSessionId - } + fun promptSessionId(promptSessionId: JsonField) = + apply { + this.promptSessionId = promptSessionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptSessionId = PromptSessionId( - checkRequired("promptSessionFunctionId", promptSessionFunctionId), - checkRequired("promptSessionId", promptSessionId), - version, - additionalProperties.toImmutable(), + checkRequired( + "promptSessionFunctionId", promptSessionFunctionId + ), + checkRequired( + "promptSessionId", promptSessionId + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2519,26 +2727,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ @NoAutoDetect - class InlineCode - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("inline_context") - @ExcludeMissing - private val inlineContext: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlineCode @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("inline_context") @ExcludeMissing private val inlineContext: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The inline code to execute */ @@ -2550,14 +2749,18 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The inline code to execute */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext(): JsonField = inlineContext /** The name of the inline code function */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2565,16 +2768,17 @@ private constructor( private var validated: Boolean = false - fun validate(): InlineCode = apply { - if (validated) { - return@apply - } + fun validate(): InlineCode = + apply { + if (validated) { + return@apply + } - code() - inlineContext().validate() - name() - validated = true - } + code() + inlineContext().validate() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2584,12 +2788,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlineCode]. * * The following fields are required: + * * ```java * .code() * .inlineContext() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlineCode]. */ @@ -2601,25 +2807,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineCode: InlineCode) = apply { - code = inlineCode.code - inlineContext = inlineCode.inlineContext - name = inlineCode.name - additionalProperties = inlineCode.additionalProperties.toMutableMap() - } + internal fun from(inlineCode: InlineCode) = + apply { + code = inlineCode.code + inlineContext = inlineCode.inlineContext + name = inlineCode.name + additionalProperties = inlineCode.additionalProperties.toMutableMap() + } /** The inline code to execute */ fun code(code: String) = code(JsonField.of(code)) /** The inline code to execute */ - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun inlineContext(inlineContext: InlineContext) = - inlineContext(JsonField.of(inlineContext)) + fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) - fun inlineContext(inlineContext: JsonField) = apply { - this.inlineContext = inlineContext - } + fun inlineContext(inlineContext: JsonField) = + apply { + this.inlineContext = inlineContext + } /** The name of the inline code function */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -2628,51 +2838,56 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline code function */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineCode = InlineCode( - checkRequired("code", code), - checkRequired("inlineContext", inlineContext), - name, - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "inlineContext", inlineContext + ), + name, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InlineContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlineContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -2683,7 +2898,9 @@ private constructor( @ExcludeMissing fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2691,15 +2908,16 @@ private constructor( private var validated: Boolean = false - fun validate(): InlineContext = apply { - if (validated) { - return@apply - } + fun validate(): InlineContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2709,12 +2927,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlineContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlineContext]. */ @@ -2725,61 +2945,77 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineContext: InlineContext) = apply { - runtime = inlineContext.runtime - version = inlineContext.version - additionalProperties = inlineContext.additionalProperties.toMutableMap() - } + internal fun from(inlineContext: InlineContext) = + apply { + runtime = inlineContext.runtime + version = inlineContext.version + additionalProperties = inlineContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { this.runtime = runtime } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineContext = InlineContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @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. + * 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 @@ -2803,18 +3039,17 @@ private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] 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 { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an unknown - * value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2822,8 +3057,8 @@ private constructor( * 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. + * 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) { @@ -2835,11 +3070,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2854,20 +3089,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2876,11 +3108,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2889,16 +3121,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2907,28 +3138,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ @NoAutoDetect - class InlinePrompt - @JsonCreator - private constructor( - @JsonProperty("inline_prompt") - @ExcludeMissing - private val inlinePrompt: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlinePrompt @JsonCreator private constructor( + @JsonProperty("inline_prompt") @ExcludeMissing private val inlinePrompt: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The prompt, model, and its parameters */ - fun inlinePrompt(): Optional = - Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) + fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) /** The name of the inline prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -2939,7 +3162,9 @@ private constructor( fun _inlinePrompt(): JsonField = inlinePrompt /** The name of the inline prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2947,15 +3172,16 @@ private constructor( private var validated: Boolean = false - fun validate(): InlinePrompt = apply { - if (validated) { - return@apply - } + fun validate(): InlinePrompt = + apply { + if (validated) { + return@apply + } - inlinePrompt().ifPresent { it.validate() } - name() - validated = true - } + inlinePrompt().ifPresent { it.validate() } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2965,11 +3191,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlinePrompt]. * * The following fields are required: + * * ```java * .inlinePrompt() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlinePrompt]. */ @@ -2980,24 +3208,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlinePrompt: InlinePrompt) = apply { - this.inlinePrompt = inlinePrompt.inlinePrompt - name = inlinePrompt.name - additionalProperties = inlinePrompt.additionalProperties.toMutableMap() - } + internal fun from(inlinePrompt: InlinePrompt) = + apply { + this.inlinePrompt = inlinePrompt.inlinePrompt + name = inlinePrompt.name + additionalProperties = inlinePrompt.additionalProperties.toMutableMap() + } /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: PromptData?) = - inlinePrompt(JsonField.ofNullable(inlinePrompt)) + fun inlinePrompt(inlinePrompt: PromptData?) = inlinePrompt(JsonField.ofNullable(inlinePrompt)) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: Optional) = - inlinePrompt(inlinePrompt.getOrNull()) + fun inlinePrompt(inlinePrompt: Optional) = inlinePrompt(inlinePrompt.getOrNull()) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: JsonField) = apply { - this.inlinePrompt = inlinePrompt - } + fun inlinePrompt(inlinePrompt: JsonField) = + apply { + this.inlinePrompt = inlinePrompt + } /** The name of the inline prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -3006,44 +3234,53 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlinePrompt = InlinePrompt( - checkRequired("inlinePrompt", inlinePrompt), - name, - additionalProperties.toImmutable(), + checkRequired( + "inlinePrompt", inlinePrompt + ), + name, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3052,16 +3289,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" } } /** The function to evaluate */ @JsonDeserialize(using = Task.Deserializer::class) @JsonSerialize(using = Task.Serializer::class) - class Task - private constructor( + class Task private constructor( private val functionId: FunctionId? = null, private val projectSlug: ProjectSlug? = null, private val globalFunction: GlobalFunction? = null, @@ -3069,6 +3304,7 @@ private constructor( private val inlineCode: InlineCode? = null, private val inlinePrompt: InlinePrompt? = null, private val _json: JsonValue? = null, + ) { /** Function id */ @@ -3122,60 +3358,59 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - functionId != null -> visitor.visitFunctionId(functionId) - projectSlug != null -> visitor.visitProjectSlug(projectSlug) - globalFunction != null -> visitor.visitGlobalFunction(globalFunction) - promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) - inlineCode != null -> visitor.visitInlineCode(inlineCode) - inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) - else -> visitor.unknown(_json) - } + return when { + functionId != null -> visitor.visitFunctionId(functionId) + projectSlug != null -> visitor.visitProjectSlug(projectSlug) + globalFunction != null -> visitor.visitGlobalFunction(globalFunction) + promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) + inlineCode != null -> visitor.visitInlineCode(inlineCode) + inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Task = apply { - if (validated) { - return@apply - } + fun validate(): Task = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitFunctionId(functionId: FunctionId) { - functionId.validate() + functionId.validate() } override fun visitProjectSlug(projectSlug: ProjectSlug) { - projectSlug.validate() + projectSlug.validate() } override fun visitGlobalFunction(globalFunction: GlobalFunction) { - globalFunction.validate() + globalFunction.validate() } override fun visitPromptSessionId(promptSessionId: PromptSessionId) { - promptSessionId.validate() + promptSessionId.validate() } override fun visitInlineCode(inlineCode: InlineCode) { - inlineCode.validate() + inlineCode.validate() } override fun visitInlinePrompt(inlinePrompt: InlinePrompt) { - inlinePrompt.validate() + inlinePrompt.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Task && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ + return /* spotless:off */ other is Task && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ @@ -3195,30 +3430,34 @@ private constructor( companion object { /** Function id */ - @JvmStatic fun ofFunctionId(functionId: FunctionId) = Task(functionId = functionId) + @JvmStatic + fun ofFunctionId(functionId: FunctionId) = Task(functionId = functionId) /** Project name and slug */ - @JvmStatic fun ofProjectSlug(projectSlug: ProjectSlug) = Task(projectSlug = projectSlug) + @JvmStatic + fun ofProjectSlug(projectSlug: ProjectSlug) = Task(projectSlug = projectSlug) /** Global function name */ @JvmStatic - fun ofGlobalFunction(globalFunction: GlobalFunction) = - Task(globalFunction = globalFunction) + fun ofGlobalFunction(globalFunction: GlobalFunction) = Task(globalFunction = globalFunction) /** Prompt session id */ @JvmStatic - fun ofPromptSessionId(promptSessionId: PromptSessionId) = - Task(promptSessionId = promptSessionId) + fun ofPromptSessionId(promptSessionId: PromptSessionId) = Task(promptSessionId = promptSessionId) /** Inline code function */ - @JvmStatic fun ofInlineCode(inlineCode: InlineCode) = Task(inlineCode = inlineCode) + @JvmStatic + fun ofInlineCode(inlineCode: InlineCode) = Task(inlineCode = inlineCode) /** Inline prompt definition */ @JvmStatic fun ofInlinePrompt(inlinePrompt: InlinePrompt) = Task(inlinePrompt = inlinePrompt) } - /** An interface that defines how to map each variant of [Task] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Task] to a value of type + * [T]. + */ interface Visitor { /** Function id */ @@ -3242,84 +3481,69 @@ private constructor( /** * Maps an unknown variant of [Task] to a value of type [T]. * - * An instance of [Task] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Task] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Task: $json") + throw BraintrustInvalidDataException("Unknown Task: $json") } } internal class Deserializer : BaseDeserializer(Task::class) { override fun ObjectCodec.deserialize(node: JsonNode): Task { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(functionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(projectSlug = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(globalFunction = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(promptSessionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(inlineCode = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Task(inlinePrompt = it, _json = json) - } - - return Task(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(functionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(projectSlug = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(globalFunction = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(promptSessionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(inlineCode = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Task(inlinePrompt = it, _json = json) + } + + return Task(_json = json) } } internal class Serializer : BaseSerializer(Task::class) { - override fun serialize( - value: Task, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.functionId != null -> generator.writeObject(value.functionId) - value.projectSlug != null -> generator.writeObject(value.projectSlug) - value.globalFunction != null -> generator.writeObject(value.globalFunction) - value.promptSessionId != null -> generator.writeObject(value.promptSessionId) - value.inlineCode != null -> generator.writeObject(value.inlineCode) - value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Task") - } + override fun serialize(value: Task, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.functionId != null -> generator.writeObject(value.functionId) + value.projectSlug != null -> generator.writeObject(value.projectSlug) + value.globalFunction != null -> generator.writeObject(value.globalFunction) + value.promptSessionId != null -> generator.writeObject(value.promptSessionId) + value.inlineCode != null -> generator.writeObject(value.inlineCode) + value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Task") + } } } /** Function id */ @NoAutoDetect - class FunctionId - @JsonCreator - private constructor( - @JsonProperty("function_id") - @ExcludeMissing - private val functionId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class FunctionId @JsonCreator private constructor( + @JsonProperty("function_id") @ExcludeMissing private val functionId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The ID of the function */ @@ -3334,7 +3558,9 @@ private constructor( fun _functionId(): JsonField = functionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -3342,15 +3568,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionId = apply { - if (validated) { - return@apply - } + fun validate(): FunctionId = + apply { + if (validated) { + return@apply + } - functionId() - version() - validated = true - } + functionId() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3360,11 +3587,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [FunctionId]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionId]. */ @@ -3375,62 +3604,73 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionId: FunctionId) = apply { - this.functionId = functionId.functionId - version = functionId.version - additionalProperties = functionId.additionalProperties.toMutableMap() - } + internal fun from(functionId: FunctionId) = + apply { + this.functionId = functionId.functionId + version = functionId.version + additionalProperties = functionId.additionalProperties.toMutableMap() + } /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) /** The ID of the function */ - fun functionId(functionId: JsonField) = apply { - this.functionId = functionId - } + fun functionId(functionId: JsonField) = + apply { + this.functionId = functionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionId = FunctionId( - checkRequired("functionId", functionId), - version, - additionalProperties.toImmutable(), + checkRequired( + "functionId", functionId + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3439,26 +3679,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" } /** Project name and slug */ @NoAutoDetect - class ProjectSlug - @JsonCreator - private constructor( - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class ProjectSlug @JsonCreator private constructor( + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The name of the project containing the function */ @@ -3476,10 +3707,14 @@ private constructor( fun _projectName(): JsonField = projectName /** The slug of the function */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -3487,16 +3722,17 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectSlug = apply { - if (validated) { - return@apply - } + fun validate(): ProjectSlug = + apply { + if (validated) { + return@apply + } - projectName() - slug() - version() - validated = true - } + projectName() + slug() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3506,12 +3742,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectSlug]. * * The following fields are required: + * * ```java * .projectName() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectSlug]. */ @@ -3523,70 +3761,86 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSlug: ProjectSlug) = apply { - projectName = projectSlug.projectName - slug = projectSlug.slug - version = projectSlug.version - additionalProperties = projectSlug.additionalProperties.toMutableMap() - } + internal fun from(projectSlug: ProjectSlug) = + apply { + projectName = projectSlug.projectName + slug = projectSlug.slug + version = projectSlug.version + additionalProperties = projectSlug.additionalProperties.toMutableMap() + } /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** The name of the project containing the function */ - fun projectName(projectName: JsonField) = apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } /** The slug of the function */ fun slug(slug: String) = slug(JsonField.of(slug)) /** The slug of the function */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSlug = ProjectSlug( - checkRequired("projectName", projectName), - checkRequired("slug", slug), - version, - additionalProperties.toImmutable(), + checkRequired( + "projectName", projectName + ), + checkRequired( + "slug", slug + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3595,20 +3849,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" } /** Global function name */ @NoAutoDetect - class GlobalFunction - @JsonCreator - private constructor( - @JsonProperty("global_function") - @ExcludeMissing - private val globalFunction: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class GlobalFunction @JsonCreator private constructor( + @JsonProperty("global_function") @ExcludeMissing private val globalFunction: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** @@ -3631,14 +3880,15 @@ private constructor( private var validated: Boolean = false - fun validate(): GlobalFunction = apply { - if (validated) { - return@apply - } + fun validate(): GlobalFunction = + apply { + if (validated) { + return@apply + } - globalFunction() - validated = true - } + globalFunction() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3648,11 +3898,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GlobalFunction]. * * The following fields are required: + * * ```java * .globalFunction() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GlobalFunction]. */ @@ -3662,61 +3914,67 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(globalFunction: GlobalFunction) = apply { - this.globalFunction = globalFunction.globalFunction - additionalProperties = globalFunction.additionalProperties.toMutableMap() - } + internal fun from(globalFunction: GlobalFunction) = + apply { + this.globalFunction = globalFunction.globalFunction + additionalProperties = globalFunction.additionalProperties.toMutableMap() + } /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: String) = - globalFunction(JsonField.of(globalFunction)) + fun globalFunction(globalFunction: String) = globalFunction(JsonField.of(globalFunction)) /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: JsonField) = apply { - this.globalFunction = globalFunction - } + fun globalFunction(globalFunction: JsonField) = + apply { + this.globalFunction = globalFunction + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GlobalFunction = GlobalFunction( - checkRequired("globalFunction", globalFunction), - additionalProperties.toImmutable(), + checkRequired( + "globalFunction", globalFunction + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3725,31 +3983,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" + override fun toString() = "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" } /** Prompt session id */ @NoAutoDetect - class PromptSessionId - @JsonCreator - private constructor( - @JsonProperty("prompt_session_function_id") - @ExcludeMissing - private val promptSessionFunctionId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_session_id") - @ExcludeMissing - private val promptSessionId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class PromptSessionId @JsonCreator private constructor( + @JsonProperty("prompt_session_function_id") @ExcludeMissing private val promptSessionFunctionId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_session_id") @ExcludeMissing private val promptSessionId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(): String = - promptSessionFunctionId.getRequired("prompt_session_function_id") + fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") /** The ID of the prompt session */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") @@ -3768,7 +4016,9 @@ private constructor( fun _promptSessionId(): JsonField = promptSessionId /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -3776,16 +4026,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptSessionId = apply { - if (validated) { - return@apply - } + fun validate(): PromptSessionId = + apply { + if (validated) { + return@apply + } - promptSessionFunctionId() - promptSessionId() - version() - validated = true - } + promptSessionFunctionId() + promptSessionId() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3795,12 +4046,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptSessionId]. * * The following fields are required: + * * ```java * .promptSessionFunctionId() * .promptSessionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptSessionId]. */ @@ -3812,74 +4065,86 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptSessionId: PromptSessionId) = apply { - promptSessionFunctionId = promptSessionId.promptSessionFunctionId - this.promptSessionId = promptSessionId.promptSessionId - version = promptSessionId.version - additionalProperties = promptSessionId.additionalProperties.toMutableMap() - } + internal fun from(promptSessionId: PromptSessionId) = + apply { + promptSessionFunctionId = promptSessionId.promptSessionFunctionId + this.promptSessionId = promptSessionId.promptSessionId + version = promptSessionId.version + additionalProperties = promptSessionId.additionalProperties.toMutableMap() + } /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: String) = - promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) + fun promptSessionFunctionId(promptSessionFunctionId: String) = promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { - this.promptSessionFunctionId = promptSessionFunctionId - } + fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = + apply { + this.promptSessionFunctionId = promptSessionFunctionId + } /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: String) = - promptSessionId(JsonField.of(promptSessionId)) + fun promptSessionId(promptSessionId: String) = promptSessionId(JsonField.of(promptSessionId)) /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: JsonField) = apply { - this.promptSessionId = promptSessionId - } + fun promptSessionId(promptSessionId: JsonField) = + apply { + this.promptSessionId = promptSessionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptSessionId = PromptSessionId( - checkRequired("promptSessionFunctionId", promptSessionFunctionId), - checkRequired("promptSessionId", promptSessionId), - version, - additionalProperties.toImmutable(), + checkRequired( + "promptSessionFunctionId", promptSessionFunctionId + ), + checkRequired( + "promptSessionId", promptSessionId + ), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3888,26 +4153,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ @NoAutoDetect - class InlineCode - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("inline_context") - @ExcludeMissing - private val inlineContext: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlineCode @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("inline_context") @ExcludeMissing private val inlineContext: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The inline code to execute */ @@ -3919,14 +4175,18 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The inline code to execute */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext(): JsonField = inlineContext /** The name of the inline code function */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -3934,16 +4194,17 @@ private constructor( private var validated: Boolean = false - fun validate(): InlineCode = apply { - if (validated) { - return@apply - } + fun validate(): InlineCode = + apply { + if (validated) { + return@apply + } - code() - inlineContext().validate() - name() - validated = true - } + code() + inlineContext().validate() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3953,12 +4214,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlineCode]. * * The following fields are required: + * * ```java * .code() * .inlineContext() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlineCode]. */ @@ -3970,25 +4233,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineCode: InlineCode) = apply { - code = inlineCode.code - inlineContext = inlineCode.inlineContext - name = inlineCode.name - additionalProperties = inlineCode.additionalProperties.toMutableMap() - } + internal fun from(inlineCode: InlineCode) = + apply { + code = inlineCode.code + inlineContext = inlineCode.inlineContext + name = inlineCode.name + additionalProperties = inlineCode.additionalProperties.toMutableMap() + } /** The inline code to execute */ fun code(code: String) = code(JsonField.of(code)) /** The inline code to execute */ - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun inlineContext(inlineContext: InlineContext) = - inlineContext(JsonField.of(inlineContext)) + fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) - fun inlineContext(inlineContext: JsonField) = apply { - this.inlineContext = inlineContext - } + fun inlineContext(inlineContext: JsonField) = + apply { + this.inlineContext = inlineContext + } /** The name of the inline code function */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -3997,51 +4264,56 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline code function */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineCode = InlineCode( - checkRequired("code", code), - checkRequired("inlineContext", inlineContext), - name, - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "inlineContext", inlineContext + ), + name, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InlineContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlineContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -4052,7 +4324,9 @@ private constructor( @ExcludeMissing fun _runtime(): JsonField = runtime - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -4060,15 +4334,16 @@ private constructor( private var validated: Boolean = false - fun validate(): InlineContext = apply { - if (validated) { - return@apply - } + fun validate(): InlineContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) @@ -4078,12 +4353,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlineContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlineContext]. */ @@ -4094,61 +4371,77 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineContext: InlineContext) = apply { - runtime = inlineContext.runtime - version = inlineContext.version - additionalProperties = inlineContext.additionalProperties.toMutableMap() - } + internal fun from(inlineContext: InlineContext) = + apply { + runtime = inlineContext.runtime + version = inlineContext.version + additionalProperties = inlineContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { this.runtime = runtime } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineContext = InlineContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @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. + * 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 @@ -4172,18 +4465,17 @@ private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] 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 { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an unknown - * value. - */ + /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4191,8 +4483,8 @@ private constructor( * 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. + * 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) { @@ -4204,11 +4496,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -4223,20 +4515,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4245,11 +4534,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4258,16 +4547,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4276,28 +4564,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ @NoAutoDetect - class InlinePrompt - @JsonCreator - private constructor( - @JsonProperty("inline_prompt") - @ExcludeMissing - private val inlinePrompt: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InlinePrompt @JsonCreator private constructor( + @JsonProperty("inline_prompt") @ExcludeMissing private val inlinePrompt: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The prompt, model, and its parameters */ - fun inlinePrompt(): Optional = - Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) + fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) /** The name of the inline prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -4308,7 +4588,9 @@ private constructor( fun _inlinePrompt(): JsonField = inlinePrompt /** The name of the inline prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -4316,15 +4598,16 @@ private constructor( private var validated: Boolean = false - fun validate(): InlinePrompt = apply { - if (validated) { - return@apply - } + fun validate(): InlinePrompt = + apply { + if (validated) { + return@apply + } - inlinePrompt().ifPresent { it.validate() } - name() - validated = true - } + inlinePrompt().ifPresent { it.validate() } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -4334,11 +4617,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [InlinePrompt]. * * The following fields are required: + * * ```java * .inlinePrompt() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InlinePrompt]. */ @@ -4349,24 +4634,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlinePrompt: InlinePrompt) = apply { - this.inlinePrompt = inlinePrompt.inlinePrompt - name = inlinePrompt.name - additionalProperties = inlinePrompt.additionalProperties.toMutableMap() - } + internal fun from(inlinePrompt: InlinePrompt) = + apply { + this.inlinePrompt = inlinePrompt.inlinePrompt + name = inlinePrompt.name + additionalProperties = inlinePrompt.additionalProperties.toMutableMap() + } /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: PromptData?) = - inlinePrompt(JsonField.ofNullable(inlinePrompt)) + fun inlinePrompt(inlinePrompt: PromptData?) = inlinePrompt(JsonField.ofNullable(inlinePrompt)) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: Optional) = - inlinePrompt(inlinePrompt.getOrNull()) + fun inlinePrompt(inlinePrompt: Optional) = inlinePrompt(inlinePrompt.getOrNull()) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: JsonField) = apply { - this.inlinePrompt = inlinePrompt - } + fun inlinePrompt(inlinePrompt: JsonField) = + apply { + this.inlinePrompt = inlinePrompt + } /** The name of the inline prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -4375,44 +4660,53 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlinePrompt = InlinePrompt( - checkRequired("inlinePrompt", inlinePrompt), - name, - additionalProperties.toImmutable(), + checkRequired( + "inlinePrompt", inlinePrompt + ), + name, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4421,36 +4715,33 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" } } /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git + * metadata fields allowed in org-level settings. */ @NoAutoDetect - class GitMetadataSettings - @JsonCreator - private constructor( - @JsonProperty("collect") - @ExcludeMissing - private val collect: JsonField = JsonMissing.of(), - @JsonProperty("fields") - @ExcludeMissing - private val fields: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class GitMetadataSettings @JsonCreator private constructor( + @JsonProperty("collect") @ExcludeMissing private val collect: JsonField = JsonMissing.of(), + @JsonProperty("fields") @ExcludeMissing private val fields: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun collect(): Collect = collect.getRequired("collect") fun fields(): Optional> = Optional.ofNullable(fields.getNullable("fields")) - @JsonProperty("collect") @ExcludeMissing fun _collect(): JsonField = collect + @JsonProperty("collect") + @ExcludeMissing + fun _collect(): JsonField = collect - @JsonProperty("fields") @ExcludeMissing fun _fields(): JsonField> = fields + @JsonProperty("fields") + @ExcludeMissing + fun _fields(): JsonField> = fields @JsonAnyGetter @ExcludeMissing @@ -4458,15 +4749,16 @@ private constructor( private var validated: Boolean = false - fun validate(): GitMetadataSettings = apply { - if (validated) { - return@apply - } + fun validate(): GitMetadataSettings = + apply { + if (validated) { + return@apply + } - collect() - fields() - validated = true - } + collect() + fields() + validated = true + } fun toBuilder() = Builder().from(this) @@ -4476,11 +4768,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GitMetadataSettings]. * * The following fields are required: + * * ```java * .collect() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GitMetadataSettings]. */ @@ -4491,68 +4785,85 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(gitMetadataSettings: GitMetadataSettings) = apply { - collect = gitMetadataSettings.collect - fields = gitMetadataSettings.fields.map { it.toMutableList() } - additionalProperties = gitMetadataSettings.additionalProperties.toMutableMap() - } + internal fun from(gitMetadataSettings: GitMetadataSettings) = + apply { + collect = gitMetadataSettings.collect + fields = gitMetadataSettings.fields.map { it.toMutableList() } + additionalProperties = gitMetadataSettings.additionalProperties.toMutableMap() + } fun collect(collect: Collect) = collect(JsonField.of(collect)) - fun collect(collect: JsonField) = apply { this.collect = collect } + fun collect(collect: JsonField) = + apply { + this.collect = collect + } fun fields(fields: List) = fields(JsonField.of(fields)) - fun fields(fields: JsonField>) = apply { - this.fields = fields.map { it.toMutableList() } - } + fun fields(fields: JsonField>) = + apply { + this.fields = fields.map { it.toMutableList() } + } - fun addField(field: Field) = apply { - fields = - (fields ?: JsonField.of(mutableListOf())).also { + fun addField(field: Field) = + apply { + fields = (fields ?: JsonField.of(mutableListOf())).also { checkKnown("fields", it).add(field) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GitMetadataSettings = GitMetadataSettings( - checkRequired("collect", collect), - (fields ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "collect", collect + ), + (fields ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Collect @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Collect @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -4576,18 +4887,18 @@ private constructor( * An enum containing [Collect]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Collect] 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 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 { ALL, NONE, SOME, - /** - * An enum member indicating that [Collect] was instantiated with an unknown value. - */ + /** An enum member indicating that [Collect] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4595,8 +4906,8 @@ private constructor( * 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. + * 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) { @@ -4613,7 +4924,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -4629,20 +4940,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ + return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4650,17 +4958,21 @@ private constructor( override fun toString() = value.toString() } - class Field @JsonCreator private constructor(private val value: JsonField) : Enum { + class Field @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -4702,9 +5014,11 @@ private constructor( * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Field] 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 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 { @@ -4717,9 +5031,7 @@ private constructor( COMMIT_MESSAGE, COMMIT_TIME, GIT_DIFF, - /** - * An enum member indicating that [Field] was instantiated with an unknown value. - */ + /** An enum member indicating that [Field] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4727,8 +5039,8 @@ private constructor( * 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. + * 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) { @@ -4751,7 +5063,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -4773,20 +5085,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Field && value == other.value /* spotless:on */ + return /* spotless:off */ other is Field && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4795,11 +5104,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GitMetadataSettings && collect == other.collect && fields == other.fields && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GitMetadataSettings && collect == other.collect && fields == other.fields && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4808,20 +5117,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "GitMetadataSettings{collect=$collect, fields=$fields, additionalProperties=$additionalProperties}" + override fun toString() = "GitMetadataSettings{collect=$collect, fields=$fields, additionalProperties=$additionalProperties}" } /** - * Optional experiment-level metadata to store about the evaluation. You can later use this to - * slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later + * use this to slice & dice across experiments. */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -4830,20 +5136,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -4852,38 +5160,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4896,15 +5212,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EvalCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EvalCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "EvalCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "EvalCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 15cc8fb6..8fd15406 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -20,48 +20,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Experiment -@JsonCreator -private constructor( +class Experiment @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("public") - @ExcludeMissing - private val public_: JsonField = JsonMissing.of(), - @JsonProperty("base_exp_id") - @ExcludeMissing - private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("commit") - @ExcludeMissing - private val commit: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") - @ExcludeMissing - private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") - @ExcludeMissing - private val repoInfo: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), + @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing private val commit: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the experiment */ @@ -74,8 +49,8 @@ private constructor( fun projectId(): String = projectId.getRequired("project_id") /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Boolean = public_.getRequired("public") @@ -88,23 +63,23 @@ private constructor( /** Date of experiment creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = - Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the experiment */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -116,35 +91,54 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the experiment */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ + @JsonProperty("public") + @ExcludeMissing + fun _public_(): JsonField = public_ /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") + @ExcludeMissing + fun _baseExpId(): JsonField = baseExpId /** Commit, taken directly from `repo_info.commit` */ - @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + @JsonProperty("commit") + @ExcludeMissing + fun _commit(): JsonField = commit /** Date of experiment creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -156,16 +150,24 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the experiment */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo(): JsonField = repoInfo /** Identifies the user who created the experiment */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -173,27 +175,28 @@ private constructor( private var validated: Boolean = false - fun validate(): Experiment = apply { - if (validated) { - return@apply - } + fun validate(): Experiment = + apply { + if (validated) { + return@apply + } - id() - name() - projectId() - public_() - baseExpId() - commit() - created() - datasetId() - datasetVersion() - deletedAt() - description() - metadata().ifPresent { it.validate() } - repoInfo().ifPresent { it.validate() } - userId() - validated = true - } + id() + name() + projectId() + public_() + baseExpId() + commit() + created() + datasetId() + datasetVersion() + deletedAt() + description() + metadata().ifPresent { it.validate() } + repoInfo().ifPresent { it.validate() } + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -203,6 +206,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Experiment]. * * The following fields are required: + * * ```java * .id() * .name() @@ -210,7 +214,8 @@ private constructor( * .public_() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -233,53 +238,66 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = apply { - id = experiment.id - name = experiment.name - projectId = experiment.projectId - public_ = experiment.public_ - baseExpId = experiment.baseExpId - commit = experiment.commit - created = experiment.created - datasetId = experiment.datasetId - datasetVersion = experiment.datasetVersion - deletedAt = experiment.deletedAt - description = experiment.description - metadata = experiment.metadata - repoInfo = experiment.repoInfo - userId = experiment.userId - additionalProperties = experiment.additionalProperties.toMutableMap() - } + internal fun from(experiment: Experiment) = + apply { + id = experiment.id + name = experiment.name + projectId = experiment.projectId + public_ = experiment.public_ + baseExpId = experiment.baseExpId + commit = experiment.commit + created = experiment.created + datasetId = experiment.datasetId + datasetVersion = experiment.datasetVersion + deletedAt = experiment.deletedAt + description = experiment.description + metadata = experiment.metadata + repoInfo = experiment.repoInfo + userId = experiment.userId + additionalProperties = experiment.additionalProperties.toMutableMap() + } /** Unique identifier for the experiment */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the experiment */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(JsonField.of(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = + apply { + this.public_ = public_ + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -288,7 +306,10 @@ private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: JsonField) = + apply { + this.baseExpId = baseExpId + } /** Commit, taken directly from `repo_info.commit` */ fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) @@ -297,7 +318,10 @@ private constructor( fun commit(commit: Optional) = commit(commit.getOrNull()) /** Commit, taken directly from `repo_info.commit` */ - fun commit(commit: JsonField) = apply { this.commit = commit } + fun commit(commit: JsonField) = + apply { + this.commit = commit + } /** Date of experiment creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -306,44 +330,52 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of experiment creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = - datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + this.datasetVersion = datasetVersion + } /** Date of experiment deletion, or null if the experiment is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -352,7 +384,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -361,7 +396,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -370,7 +408,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -379,7 +420,10 @@ private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: JsonField) = + apply { + this.repoInfo = repoInfo + } /** Identifies the user who created the experiment */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -388,54 +432,70 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the experiment */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("public_", public_), - baseExpId, - commit, - created, - datasetId, - datasetVersion, - deletedAt, - description, - metadata, - repoInfo, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "public_", public_ + ), + baseExpId, + commit, + created, + datasetId, + datasetVersion, + deletedAt, + description, + metadata, + repoInfo, + userId, + additionalProperties.toImmutable(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -444,20 +504,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -466,38 +528,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -510,11 +580,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && id == other.id && name == other.name && projectId == other.projectId && public_ == other.public_ && baseExpId == other.baseExpId && commit == other.commit && created == other.created && datasetId == other.datasetId && datasetVersion == other.datasetVersion && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && repoInfo == other.repoInfo && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && id == other.id && name == other.name && projectId == other.projectId && public_ == other.public_ && baseExpId == other.baseExpId && commit == other.commit && created == other.created && datasetId == other.datasetId && datasetVersion == other.datasetVersion && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && repoInfo == other.repoInfo && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -523,6 +593,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Experiment{id=$id, name=$name, projectId=$projectId, public_=$public_, baseExpId=$baseExpId, commit=$commit, created=$created, datasetId=$datasetId, datasetVersion=$datasetVersion, deletedAt=$deletedAt, description=$description, metadata=$metadata, repoInfo=$repoInfo, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Experiment{id=$id, name=$name, projectId=$projectId, public_=$public_, baseExpId=$baseExpId, commit=$commit, created=$created, datasetId=$datasetId, datasetVersion=$datasetVersion, deletedAt=$deletedAt, description=$description, metadata=$metadata, repoInfo=$repoInfo, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index ae017556..8a9b0ec5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new experiment. If there is an existing experiment in the project with the same name as - * the one specified in the request, will return the existing experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with + * the same name as the one specified in the request, will return the existing + * experiment unmodified */ -class ExperimentCreateParams -private constructor( +class ExperimentCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Unique identifier for the project that the experiment belongs under */ @@ -38,12 +39,15 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(): Optional = body.baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun datasetId(): Optional = body.datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ fun datasetVersion(): Optional = body.datasetVersion() @@ -51,9 +55,10 @@ private constructor( fun description(): Optional = body.description() /** - * Normally, creating an experiment with the same name as an existing experiment will return the - * existing one un-modified. But if `ensure_new` is true, registration will generate a new - * experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(): Optional = body.ensureNew() @@ -64,8 +69,8 @@ private constructor( fun name(): Optional = body.name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Optional = body.public_() @@ -78,12 +83,15 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun _baseExpId(): JsonField = body._baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun _datasetId(): JsonField = body._datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ fun _datasetVersion(): JsonField = body._datasetVersion() @@ -91,9 +99,10 @@ private constructor( fun _description(): JsonField = body._description() /** - * Normally, creating an experiment with the same name as an existing experiment will return the - * existing one un-modified. But if `ensure_new` is true, registration will generate a new - * experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun _ensureNew(): JsonField = body._ensureNew() @@ -104,8 +113,8 @@ private constructor( fun _name(): JsonField = body._name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun _public_(): JsonField = body._public_() @@ -118,80 +127,57 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("base_exp_id") - @ExcludeMissing - private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") - @ExcludeMissing - private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ensure_new") - @ExcludeMissing - private val ensureNew: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("public") - @ExcludeMissing - private val public_: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") - @ExcludeMissing - private val repoInfo: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("ensure_new") @ExcludeMissing private val ensureNew: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the project that the experiment belongs under */ fun projectId(): String = projectId.getRequired("project_id") /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): Optional = - Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = - Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Textual description of the experiment */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - fun ensureNew(): Optional = - Optional.ofNullable(ensureNew.getNullable("ensure_new")) + fun ensureNew(): Optional = Optional.ofNullable(ensureNew.getNullable("ensure_new")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -200,8 +186,8 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) @@ -209,19 +195,26 @@ private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") + @ExcludeMissing + fun _baseExpId(): JsonField = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -233,26 +226,37 @@ private constructor( fun _description(): JsonField = description /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - @JsonProperty("ensure_new") @ExcludeMissing fun _ensureNew(): JsonField = ensureNew + @JsonProperty("ensure_new") + @ExcludeMissing + fun _ensureNew(): JsonField = ensureNew /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ + @JsonProperty("public") + @ExcludeMissing + fun _public_(): JsonField = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @ExcludeMissing @@ -260,23 +264,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } - - projectId() - baseExpId() - datasetId() - datasetVersion() - description() - ensureNew() - metadata().ifPresent { it.validate() } - name() - public_() - repoInfo().ifPresent { it.validate() } - validated = true - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + projectId() + baseExpId() + datasetId() + datasetVersion() + description() + ensureNew() + metadata().ifPresent { it.validate() } + name() + public_() + repoInfo().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -286,11 +291,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -309,25 +316,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - projectId = body.projectId - baseExpId = body.baseExpId - datasetId = body.datasetId - datasetVersion = body.datasetVersion - description = body.description - ensureNew = body.ensureNew - metadata = body.metadata - name = body.name - public_ = body.public_ - repoInfo = body.repoInfo - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + projectId = body.projectId + baseExpId = body.baseExpId + datasetId = body.datasetId + datasetVersion = body.datasetVersion + description = body.description + ensureNew = body.ensureNew + metadata = body.metadata + name = body.name + public_ = body.public_ + repoInfo = body.repoInfo + additionalProperties = body.additionalProperties.toMutableMap() + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -336,7 +347,10 @@ private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: JsonField) = + apply { + this.baseExpId = baseExpId + } /** * Identifier of the linked dataset, or null if the experiment is not linked to a @@ -354,29 +368,31 @@ private constructor( * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = - datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + this.datasetVersion = datasetVersion + } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -385,37 +401,45 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Boolean?) = ensureNew(JsonField.ofNullable(ensureNew)) /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - fun ensureNew(ensureNew: JsonField) = apply { this.ensureNew = ensureNew } + fun ensureNew(ensureNew: JsonField) = + apply { + this.ensureNew = ensureNew + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -424,7 +448,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -433,31 +460,37 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = + apply { + this.public_ = public_ + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -466,49 +499,61 @@ private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun repoInfo(repoInfo: JsonField) = + apply { + this.repoInfo = repoInfo + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("projectId", projectId), - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties.toImmutable(), + checkRequired( + "projectId", projectId + ), + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -517,8 +562,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = "Body{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -526,14 +570,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentCreateParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentCreateParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentCreateParams]. */ @@ -545,283 +592,380 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentCreateParams: ExperimentCreateParams) = apply { - body = experimentCreateParams.body.toBuilder() - additionalHeaders = experimentCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentCreateParams: ExperimentCreateParams) = + apply { + body = experimentCreateParams.body.toBuilder() + additionalHeaders = experimentCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentCreateParams.additionalQueryParams.toBuilder() + } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } + fun baseExpId(baseExpId: String?) = + apply { + body.baseExpId(baseExpId) + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } + fun baseExpId(baseExpId: JsonField) = + apply { + body.baseExpId(baseExpId) + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + fun datasetId(datasetId: String?) = + apply { + body.datasetId(datasetId) + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } + fun datasetId(datasetId: JsonField) = + apply { + body.datasetId(datasetId) + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } + fun datasetVersion(datasetVersion: String?) = + apply { + body.datasetVersion(datasetVersion) + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - body.datasetVersion(datasetVersion) - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + body.datasetVersion(datasetVersion) + } /** Textual description of the experiment */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the experiment */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - fun ensureNew(ensureNew: Boolean?) = apply { body.ensureNew(ensureNew) } + fun ensureNew(ensureNew: Boolean?) = + apply { + body.ensureNew(ensureNew) + } /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Normally, creating an experiment with the same name as an existing experiment + * will return the existing one un-modified. But if `ensure_new` is true, + * registration will generate a new experiment with a unique name in case of a + * conflict. */ - fun ensureNew(ensureNew: JsonField) = apply { body.ensureNew(ensureNew) } + fun ensureNew(ensureNew: JsonField) = + apply { + body.ensureNew(ensureNew) + } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: Boolean?) = apply { body.public_(public_) } + fun public_(public_: Boolean?) = + apply { + body.public_(public_) + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { body.public_(public_) } + fun public_(public_: JsonField) = + apply { + body.public_(public_) + } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: RepoInfo?) = + apply { + body.repoInfo(repoInfo) + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: JsonField) = + apply { + body.repoInfo(repoInfo) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentCreateParams = ExperimentCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -830,20 +974,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -852,38 +998,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -896,15 +1050,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 6239af74..15fd2523 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an experiment object by its id */ -class ExperimentDeleteParams -private constructor( +class ExperimentDeleteParams private constructor( private val experimentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Experiment id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentDeleteParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentDeleteParams: ExperimentDeleteParams) = apply { - experimentId = experimentDeleteParams.experimentId - additionalHeaders = experimentDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - experimentDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(experimentDeleteParams: ExperimentDeleteParams) = + apply { + experimentId = experimentDeleteParams.experimentId + additionalHeaders = experimentDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = experimentDeleteParams.additionalBodyProperties.toMutableMap() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ExperimentDeleteParams = ExperimentDeleteParams( - checkRequired("experimentId", experimentId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "experimentId", experimentId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index e49339eb..e764766b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -23,75 +23,43 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ExperimentEvent -@JsonCreator -private constructor( +class ExperimentEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("experiment_id") - @ExcludeMissing - private val experimentId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - private val context: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") - @ExcludeMissing - private val datasetRecordId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("experiment_id") @ExcludeMissing private val experimentId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), + @JsonProperty("dataset_record_id") @ExcludeMissing private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") - @ExcludeMissing - private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") - @ExcludeMissing - private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the experiment (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the experiment (see the + * `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -108,63 +76,72 @@ private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different experiment events together as part of + * a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -172,54 +149,63 @@ private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonValue = output /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the root - * span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the experiment (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the experiment (see the + * `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Unique identifier for the experiment */ @JsonProperty("experiment_id") @@ -227,65 +213,86 @@ private constructor( fun _experimentId(): JsonField = experimentId /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** A unique identifier for the trace this experiment event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different experiment events together as part of + * a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId(): JsonField = datasetRecordId /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") + @ExcludeMissing + fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -293,15 +300,18 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the root - * span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -309,30 +319,31 @@ private constructor( private var validated: Boolean = false - fun validate(): ExperimentEvent = apply { - if (validated) { - return@apply - } + fun validate(): ExperimentEvent = + apply { + if (validated) { + return@apply + } - id() - _xactId() - created() - experimentId() - projectId() - rootSpanId() - spanId() - context().ifPresent { it.validate() } - datasetRecordId() - isRoot() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanParents() - tags() - validated = true - } + id() + _xactId() + created() + experimentId() + projectId() + rootSpanId() + spanId() + context().ifPresent { it.validate() } + datasetRecordId() + isRoot() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -342,6 +353,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ExperimentEvent]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -352,7 +364,8 @@ private constructor( * .spanId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentEvent]. */ @@ -382,160 +395,200 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentEvent: ExperimentEvent) = apply { - id = experimentEvent.id - _xactId = experimentEvent._xactId - created = experimentEvent.created - experimentId = experimentEvent.experimentId - projectId = experimentEvent.projectId - rootSpanId = experimentEvent.rootSpanId - spanId = experimentEvent.spanId - context = experimentEvent.context - datasetRecordId = experimentEvent.datasetRecordId - error = experimentEvent.error - expected = experimentEvent.expected - input = experimentEvent.input - isRoot = experimentEvent.isRoot - metadata = experimentEvent.metadata - metrics = experimentEvent.metrics - origin = experimentEvent.origin - output = experimentEvent.output - scores = experimentEvent.scores - spanAttributes = experimentEvent.spanAttributes - spanParents = experimentEvent.spanParents.map { it.toMutableList() } - tags = experimentEvent.tags.map { it.toMutableList() } - additionalProperties = experimentEvent.additionalProperties.toMutableMap() - } + internal fun from(experimentEvent: ExperimentEvent) = + apply { + id = experimentEvent.id + _xactId = experimentEvent._xactId + created = experimentEvent.created + experimentId = experimentEvent.experimentId + projectId = experimentEvent.projectId + rootSpanId = experimentEvent.rootSpanId + spanId = experimentEvent.spanId + context = experimentEvent.context + datasetRecordId = experimentEvent.datasetRecordId + error = experimentEvent.error + expected = experimentEvent.expected + input = experimentEvent.input + isRoot = experimentEvent.isRoot + metadata = experimentEvent.metadata + metrics = experimentEvent.metrics + origin = experimentEvent.origin + output = experimentEvent.output + scores = experimentEvent.scores + spanAttributes = experimentEvent.spanAttributes + spanParents = experimentEvent.spanParents.map { it.toMutableList() } + tags = experimentEvent.tags.map { it.toMutableList() } + additionalProperties = experimentEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the experiment (see the + * `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the experiment (see the + * `version` parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the experiment event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Unique identifier for the experiment */ fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) /** Unique identifier for the experiment */ - fun experimentId(experimentId: JsonField) = apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: JsonField) = + apply { + this.experimentId = experimentId + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** A unique identifier for the trace this experiment event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this experiment event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different experiment events together as part of + * a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different experiment events together as part of + * a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = + apply { + this.context = context + } /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String?) = - datasetRecordId(JsonField.ofNullable(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String?) = datasetRecordId(JsonField.ofNullable(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.getOrNull()) + fun datasetRecordId(datasetRecordId: Optional) = datasetRecordId(datasetRecordId.getOrNull()) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } + fun datasetRecordId(datasetRecordId: JsonField) = + apply { + this.datasetRecordId = datasetRecordId + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = + apply { + this.error = error + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -547,55 +600,64 @@ private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + fun isRoot(isRoot: JsonField) = + apply { + this.isRoot = isRoot + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -604,93 +666,109 @@ private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = + apply { + this.output = output + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = - spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = + apply { + this.spanAttributes = spanAttributes + } /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty + * for the root span of a trace, and should most often contain just one parent + * element for subspans */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -699,94 +777,109 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ExperimentEvent = ExperimentEvent( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("created", created), - checkRequired("experimentId", experimentId), - checkRequired("projectId", projectId), - checkRequired("rootSpanId", rootSpanId), - checkRequired("spanId", spanId), - context, - datasetRecordId, - error, - expected, - input, - isRoot, - metadata, - metrics, - origin, - output, - scores, - spanAttributes, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "created", created + ), + checkRequired( + "experimentId", experimentId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "rootSpanId", rootSpanId + ), + checkRequired( + "spanId", spanId + ), + context, + datasetRecordId, + error, + expected, + input, + isRoot, + metadata, + metrics, + origin, + output, + scores, + spanAttributes, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ @NoAutoDetect - class Context - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Context @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -809,23 +902,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Context = apply { - if (validated) { - return@apply - } + fun validate(): Context = + apply { + if (validated) { + return@apply + } - callerFilename() - callerFunctionname() - callerLineno() - validated = true - } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Context]. */ @@ -837,38 +932,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = + apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String?) = - callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = + apply { + this.callerFilename = callerFilename + } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String?) = - callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = + apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -880,44 +974,52 @@ private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = + apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -926,23 +1028,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -951,20 +1050,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -973,38 +1074,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1017,38 +1126,22 @@ private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - private val completionTokens: JsonField = JsonMissing.of(), + class Metrics @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") - @ExcludeMissing - private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") - @ExcludeMissing - private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** This metric is deprecated */ @@ -1062,31 +1155,31 @@ private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1094,35 +1187,41 @@ private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ - @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + @JsonProperty("end") + @ExcludeMissing + fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + @JsonProperty("start") + @ExcludeMissing + fun _start(): JsonField = start /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1130,25 +1229,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true - } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1165,133 +1266,144 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = + apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = + apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = + apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun callerLineno(callerLineno: JsonValue) = + apply { + this.callerLineno = callerLineno + } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long?) = - completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long) = - completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = + apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ - fun end(end: JsonField) = apply { this.end = end } + fun end(end: JsonField) = + apply { + this.end = end + } /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = + apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = + apply { + this.start = start + } /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1303,47 +1415,57 @@ private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = + apply { + this.tokens = tokens + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1352,27 +1474,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin - @JsonCreator - private constructor( + class Origin @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** ID of the original event. */ @@ -1388,13 +1501,19 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -1407,17 +1526,18 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - id() - _xactId() - objectId() - objectType() - validated = true - } + id() + _xactId() + objectId() + objectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1427,6 +1547,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -1434,7 +1555,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -1447,82 +1569,111 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1555,9 +1706,11 @@ private constructor( * 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 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 { @@ -1578,8 +1731,8 @@ private constructor( * 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. + * 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) { @@ -1599,7 +1752,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1618,20 +1771,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1640,11 +1790,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1653,25 +1803,23 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1680,20 +1828,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1702,38 +1852,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1746,11 +1904,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1759,6 +1917,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index b4b3324a..4aba5528 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of experiment events */ -class ExperimentFeedbackParams -private constructor( +class ExperimentFeedbackParams private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("feedback") - @ExcludeMissing - private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of experiment feedback items */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - feedback().forEach { it.validate() } - validated = true - } + feedback().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of experiment feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of experiment feedback items */ - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = + apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of experiment feedback items */ - fun addFeedback(feedback: FeedbackExperimentItem) = apply { - this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackExperimentItem) = + apply { + this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "feedback", feedback + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -174,8 +184,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -183,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentFeedbackParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentFeedbackParams]. * * The following fields are required: + * * ```java * .experimentId() * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentFeedbackParams]. */ @@ -204,163 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = apply { - experimentId = experimentFeedbackParams.experimentId - body = experimentFeedbackParams.body.toBuilder() - additionalHeaders = experimentFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = + apply { + experimentId = experimentFeedbackParams.experimentId + body = experimentFeedbackParams.body.toBuilder() + additionalHeaders = experimentFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFeedbackParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** A list of experiment feedback items */ - fun feedback(feedback: List) = apply { body.feedback(feedback) } + fun feedback(feedback: List) = + apply { + body.feedback(feedback) + } /** A list of experiment feedback items */ - fun feedback(feedback: JsonField>) = apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = + apply { + body.feedback(feedback) + } /** A list of experiment feedback items */ - fun addFeedback(feedback: FeedbackExperimentItem) = apply { body.addFeedback(feedback) } + fun addFeedback(feedback: FeedbackExperimentItem) = + apply { + body.addFeedback(feedback) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( - checkRequired("experimentId", experimentId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentFeedbackParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentFeedbackParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 53ca3670..611e5817 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -12,12 +12,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, + * but with the parameters in the URL query rather than in the request body. For + * more complex queries, use the `POST /btql` endpoint. */ -class ExperimentFetchParams -private constructor( +class ExperimentFetchParams private constructor( private val experimentId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -25,6 +24,7 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -33,52 +33,55 @@ private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -89,20 +92,36 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.maxRootSpanId?.let { + queryParams.put( + "max_root_span_id", listOf(it.toString()) + ) + } + this.maxXactId?.let { + queryParams.put( + "max_xact_id", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -110,14 +129,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentFetchParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentFetchParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentFetchParams]. */ @@ -133,263 +155,310 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFetchParams: ExperimentFetchParams) = apply { - experimentId = experimentFetchParams.experimentId - limit = experimentFetchParams.limit - maxRootSpanId = experimentFetchParams.maxRootSpanId - maxXactId = experimentFetchParams.maxXactId - version = experimentFetchParams.version - additionalHeaders = experimentFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFetchParams: ExperimentFetchParams) = + apply { + experimentId = experimentFetchParams.experimentId + limit = experimentFetchParams.limit + maxRootSpanId = experimentFetchParams.maxRootSpanId + maxXactId = experimentFetchParams.maxXactId + version = experimentFetchParams.version + additionalHeaders = experimentFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFetchParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String?) = + apply { + this.maxXactId = maxXactId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFetchParams = ExperimentFetchParams( - checkRequired("experimentId", experimentId), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index b6cde61b..a1838a8c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -22,138 +22,146 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ -class ExperimentFetchPostParams -private constructor( +class ExperimentFetchPostParams private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ fun experimentId(): String = experimentId /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun _version(): JsonField = body._version() @@ -163,169 +171,168 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") - @ExcludeMissing - private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") - @ExcludeMissing - private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") - @ExcludeMissing - private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(): Optional = - Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(): Optional = - Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + @JsonProperty("limit") + @ExcludeMissing + fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") + @ExcludeMissing + fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -333,25 +340,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true } - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -365,261 +374,284 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { this.limit = limit } + fun limit(limit: JsonField) = + apply { + this.limit = limit + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = + apply { + this.maxXactId = maxXactId + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = + apply { + this.version = version + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,8 +660,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -637,14 +668,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentFetchPostParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentFetchPostParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentFetchPostParams]. */ @@ -657,358 +691,431 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = apply { - experimentId = experimentFetchPostParams.experimentId - body = experimentFetchPostParams.body.toBuilder() - additionalHeaders = experimentFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = + apply { + experimentId = experimentFetchPostParams.experimentId + body = experimentFetchPostParams.body.toBuilder() + additionalHeaders = experimentFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFetchPostParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: String?) = apply { body.cursor(cursor) } + fun cursor(cursor: String?) = + apply { + body.cursor(cursor) + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } + fun cursor(cursor: JsonField) = + apply { + body.cursor(cursor) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { body.limit(limit) } + fun limit(limit: Long?) = + apply { + body.limit(limit) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { body.limit(limit) } + fun limit(limit: JsonField) = + apply { + body.limit(limit) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: String?) = + apply { + body.maxXactId(maxXactId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: JsonField) = + apply { + body.maxXactId(maxXactId) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { body.version(version) } + fun version(version: String?) = + apply { + body.version(version) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { body.version(version) } + fun version(version: JsonField) = + apply { + body.version(version) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFetchPostParams = ExperimentFetchPostParams( - checkRequired("experimentId", experimentId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentFetchPostParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index e04423cf..5dc9dc79 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the experiment */ -class ExperimentInsertParams -private constructor( +class ExperimentInsertParams private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of experiment events to insert */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - validated = true - } + events().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of experiment events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of experiment events to insert */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of experiment events to insert */ - fun addEvent(event: InsertExperimentEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertExperimentEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -182,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentInsertParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentInsertParams]. * * The following fields are required: + * * ```java * .experimentId() * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentInsertParams]. */ @@ -203,161 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentInsertParams: ExperimentInsertParams) = apply { - experimentId = experimentInsertParams.experimentId - body = experimentInsertParams.body.toBuilder() - additionalHeaders = experimentInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentInsertParams: ExperimentInsertParams) = + apply { + experimentId = experimentInsertParams.experimentId + body = experimentInsertParams.body.toBuilder() + additionalHeaders = experimentInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentInsertParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** A list of experiment events to insert */ - fun events(events: List) = apply { body.events(events) } + fun events(events: List) = + apply { + body.events(events) + } /** A list of experiment events to insert */ - fun events(events: JsonField>) = apply { body.events(events) } + fun events(events: JsonField>) = + apply { + body.events(events) + } /** A list of experiment events to insert */ - fun addEvent(event: InsertExperimentEvent) = apply { body.addEvent(event) } + fun addEvent(event: InsertExperimentEvent) = + apply { + body.addEvent(event) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentInsertParams = ExperimentInsertParams( - checkRequired("experimentId", experimentId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentInsertParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentInsertParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 246697bc..78769b47 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.ExperimentService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ -class ExperimentListPage -private constructor( +class ExperimentListPage private constructor( private val experimentsService: ExperimentService, private val params: ExperimentListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListPage && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ExperimentListPage && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ - override fun toString() = - "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" + override fun toString() = "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ExperimentListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ExperimentListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { experimentsService.list(it) } + return getNextPageParams().map { experimentsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - experimentsService: ExperimentService, - params: ExperimentListParams, - response: Response, - ) = ExperimentListPage(experimentsService, params, response) + fun of(experimentsService: ExperimentService, params: ExperimentListParams, response: Response) = + ExperimentListPage( + experimentsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ExperimentListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ExperimentListPage) : Iterable { + class AutoPager( + private val firstPage: ExperimentListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index a47c0c97..05812b0f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.ExperimentServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ -class ExperimentListPageAsync -private constructor( +class ExperimentListPageAsync private constructor( private val experimentsService: ExperimentServiceAsync, private val params: ExperimentListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListPageAsync && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ExperimentListPageAsync && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ - override fun toString() = - "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" + override fun toString() = "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ExperimentListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ExperimentListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { experimentsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + experimentsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - experimentsService: ExperimentServiceAsync, - params: ExperimentListParams, - response: Response, - ) = ExperimentListPageAsync(experimentsService, params, response) + fun of(experimentsService: ExperimentServiceAsync, params: ExperimentListParams, response: Response) = + ExperimentListPageAsync( + experimentsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [ExperimentListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -151,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ExperimentListPageAsync) { + class AutoPager( + private val firstPage: ExperimentListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Experiment) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Experiment) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 2b4b05c0..e52715df 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ -class ExperimentListParams -private constructor( +class ExperimentListParams private constructor( private val endingBefore: String?, private val experimentName: String?, private val ids: Ids?, @@ -38,14 +37,15 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -53,8 +53,8 @@ private constructor( fun experimentName(): Optional = Optional.ofNullable(experimentName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,27 +86,64 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.experimentName?.let { queryParams.put("experiment_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.experimentName?.let { + queryParams.put( + "experiment_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ExperimentListParams = builder().build() + @JvmStatic + fun none(): ExperimentListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [ExperimentListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ExperimentListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentListParams]. */ @@ -125,70 +162,82 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentListParams: ExperimentListParams) = apply { - endingBefore = experimentListParams.endingBefore - experimentName = experimentListParams.experimentName - ids = experimentListParams.ids - limit = experimentListParams.limit - orgName = experimentListParams.orgName - projectId = experimentListParams.projectId - projectName = experimentListParams.projectName - startingAfter = experimentListParams.startingAfter - additionalHeaders = experimentListParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentListParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentListParams: ExperimentListParams) = + apply { + endingBefore = experimentListParams.endingBefore + experimentName = experimentListParams.experimentName + ids = experimentListParams.ids + limit = experimentListParams.limit + orgName = experimentListParams.orgName + projectId = experimentListParams.projectId + projectName = experimentListParams.projectName + startingAfter = experimentListParams.startingAfter + additionalHeaders = experimentListParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the experiment to search for */ - fun experimentName(experimentName: String?) = apply { this.experimentName = experimentName } + fun experimentName(experimentName: String?) = + apply { + this.experimentName = experimentName + } /** Name of the experiment to search for */ - fun experimentName(experimentName: Optional) = - experimentName(experimentName.getOrNull()) + fun experimentName(experimentName: Optional) = experimentName(experimentName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -197,19 +246,28 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -217,146 +275,174 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentListParams = ExperimentListParams( - endingBefore, - experimentName, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + experimentName, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -374,19 +460,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -401,12 +487,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -416,60 +507,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 042891d4..bf3d01fd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an experiment object by its id */ -class ExperimentRetrieveParams -private constructor( +class ExperimentRetrieveParams private constructor( private val experimentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentRetrieveParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = apply { - experimentId = experimentRetrieveParams.experimentId - additionalHeaders = experimentRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = + apply { + experimentId = experimentRetrieveParams.experimentId + additionalHeaders = experimentRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentRetrieveParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( - checkRequired("experimentId", experimentId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index c988c73a..663d7cd0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -12,28 +12,29 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Summarize experiment */ -class ExperimentSummarizeParams -private constructor( +class ExperimentSummarizeParams private constructor( private val experimentId: String, private val comparisonExperimentId: String?, private val summarizeScores: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ fun experimentId(): String = experimentId /** - * The experiment to compare against, if summarizing scores and metrics. If omitted, will fall - * back to the `base_exp_id` stored in the experiment metadata, and then to the most recent - * experiment run in the same project. Must pass `summarize_scores=true` for this id to be used + * The experiment to compare against, if summarizing scores and metrics. If + * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, + * and then to the most recent experiment run in the same project. Must pass + * `summarize_scores=true` for this id to be used */ fun comparisonExperimentId(): Optional = Optional.ofNullable(comparisonExperimentId) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata will be - * returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the + * metadata will be returned. */ fun summarizeScores(): Optional = Optional.ofNullable(summarizeScores) @@ -44,20 +45,26 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.comparisonExperimentId?.let { - queryParams.put("comparison_experiment_id", listOf(it.toString())) - } - this.summarizeScores?.let { queryParams.put("summarize_scores", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.comparisonExperimentId?.let { + queryParams.put( + "comparison_experiment_id", listOf(it.toString()) + ) + } + this.summarizeScores?.let { + queryParams.put( + "summarize_scores", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -65,14 +72,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentSummarizeParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentSummarizeParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentSummarizeParams]. */ @@ -86,175 +96,206 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = apply { - experimentId = experimentSummarizeParams.experimentId - comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId - summarizeScores = experimentSummarizeParams.summarizeScores - additionalHeaders = experimentSummarizeParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentSummarizeParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = + apply { + experimentId = experimentSummarizeParams.experimentId + comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId + summarizeScores = experimentSummarizeParams.summarizeScores + additionalHeaders = experimentSummarizeParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentSummarizeParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** - * The experiment to compare against, if summarizing scores and metrics. If omitted, will - * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most - * recent experiment run in the same project. Must pass `summarize_scores=true` for this id - * to be used + * The experiment to compare against, if summarizing scores and metrics. If + * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, + * and then to the most recent experiment run in the same project. Must pass + * `summarize_scores=true` for this id to be used */ - fun comparisonExperimentId(comparisonExperimentId: String?) = apply { - this.comparisonExperimentId = comparisonExperimentId - } + fun comparisonExperimentId(comparisonExperimentId: String?) = + apply { + this.comparisonExperimentId = comparisonExperimentId + } /** - * The experiment to compare against, if summarizing scores and metrics. If omitted, will - * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most - * recent experiment run in the same project. Must pass `summarize_scores=true` for this id - * to be used + * The experiment to compare against, if summarizing scores and metrics. If + * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, + * and then to the most recent experiment run in the same project. Must pass + * `summarize_scores=true` for this id to be used */ - fun comparisonExperimentId(comparisonExperimentId: Optional) = - comparisonExperimentId(comparisonExperimentId.getOrNull()) + fun comparisonExperimentId(comparisonExperimentId: Optional) = comparisonExperimentId(comparisonExperimentId.getOrNull()) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata - * will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the + * metadata will be returned. */ - fun summarizeScores(summarizeScores: Boolean?) = apply { - this.summarizeScores = summarizeScores - } + fun summarizeScores(summarizeScores: Boolean?) = + apply { + this.summarizeScores = summarizeScores + } /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata - * will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the + * metadata will be returned. */ fun summarizeScores(summarizeScores: Boolean) = summarizeScores(summarizeScores as Boolean?) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata - * will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the + * metadata will be returned. */ - fun summarizeScores(summarizeScores: Optional) = - summarizeScores(summarizeScores.getOrNull()) + fun summarizeScores(summarizeScores: Optional) = summarizeScores(summarizeScores.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( - checkRequired("experimentId", experimentId), - comparisonExperimentId, - summarizeScores, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + comparisonExperimentId, + summarizeScores, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 1f99550c..eca783dd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class ExperimentUpdateParams -private constructor( +class ExperimentUpdateParams private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Experiment id */ @@ -40,12 +40,15 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(): Optional = body.baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun datasetId(): Optional = body.datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ fun datasetVersion(): Optional = body.datasetVersion() @@ -59,8 +62,8 @@ private constructor( fun name(): Optional = body.name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Optional = body.public_() @@ -70,12 +73,15 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun _baseExpId(): JsonField = body._baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ fun _datasetId(): JsonField = body._datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ fun _datasetVersion(): JsonField = body._datasetVersion() @@ -89,8 +95,8 @@ private constructor( fun _name(): JsonField = body._name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun _public_(): JsonField = body._public_() @@ -103,70 +109,51 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("base_exp_id") - @ExcludeMissing - private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") - @ExcludeMissing - private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") - @ExcludeMissing - private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("public") - @ExcludeMissing - private val public_: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") - @ExcludeMissing - private val repoInfo: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): Optional = - Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = - Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Textual description of the experiment */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -175,8 +162,8 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) @@ -184,16 +171,21 @@ private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") + @ExcludeMissing + fun _baseExpId(): JsonField = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -205,19 +197,27 @@ private constructor( fun _description(): JsonField = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ + @JsonProperty("public") + @ExcludeMissing + fun _public_(): JsonField = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @ExcludeMissing @@ -225,28 +225,30 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + baseExpId() + datasetId() + datasetVersion() + description() + metadata().ifPresent { it.validate() } + name() + public_() + repoInfo().ifPresent { it.validate() } + validated = true } - baseExpId() - datasetId() - datasetVersion() - description() - metadata().ifPresent { it.validate() } - name() - public_() - repoInfo().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -263,17 +265,18 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - baseExpId = body.baseExpId - datasetId = body.datasetId - datasetVersion = body.datasetVersion - description = body.description - metadata = body.metadata - name = body.name - public_ = body.public_ - repoInfo = body.repoInfo - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + baseExpId = body.baseExpId + datasetId = body.datasetId + datasetVersion = body.datasetVersion + description = body.description + metadata = body.metadata + name = body.name + public_ = body.public_ + repoInfo = body.repoInfo + additionalProperties = body.additionalProperties.toMutableMap() + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -282,7 +285,10 @@ private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: JsonField) = + apply { + this.baseExpId = baseExpId + } /** * Identifier of the linked dataset, or null if the experiment is not linked to a @@ -300,29 +306,31 @@ private constructor( * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = + apply { + this.datasetId = datasetId + } /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = - datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + this.datasetVersion = datasetVersion + } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -331,9 +339,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -342,7 +351,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -351,31 +363,37 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = + apply { + this.public_ = public_ + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -384,47 +402,57 @@ private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun repoInfo(repoInfo: JsonField) = + apply { + this.repoInfo = repoInfo + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalProperties.toImmutable(), + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -433,8 +461,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = "Body{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -442,14 +469,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ExperimentUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [ExperimentUpdateParams]. * * The following fields are required: + * * ```java * .experimentId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ExperimentUpdateParams]. */ @@ -462,254 +492,340 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentUpdateParams: ExperimentUpdateParams) = apply { - experimentId = experimentUpdateParams.experimentId - body = experimentUpdateParams.body.toBuilder() - additionalHeaders = experimentUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentUpdateParams: ExperimentUpdateParams) = + apply { + experimentId = experimentUpdateParams.experimentId + body = experimentUpdateParams.body.toBuilder() + additionalHeaders = experimentUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentUpdateParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = + apply { + this.experimentId = experimentId + } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } + fun baseExpId(baseExpId: String?) = + apply { + body.baseExpId(baseExpId) + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } + fun baseExpId(baseExpId: JsonField) = + apply { + body.baseExpId(baseExpId) + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } + fun datasetId(datasetId: String?) = + apply { + body.datasetId(datasetId) + } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset */ - fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } + fun datasetId(datasetId: JsonField) = + apply { + body.datasetId(datasetId) + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } + fun datasetVersion(datasetVersion: String?) = + apply { + body.datasetVersion(datasetVersion) + } /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = - datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be + * used to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = apply { - body.datasetVersion(datasetVersion) - } + fun datasetVersion(datasetVersion: JsonField) = + apply { + body.datasetVersion(datasetVersion) + } /** Textual description of the experiment */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the experiment */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + fun metadata(metadata: Metadata?) = + apply { + body.metadata(metadata) + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + fun metadata(metadata: JsonField) = + apply { + body.metadata(metadata) + } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: Boolean?) = apply { body.public_(public_) } + fun public_(public_: Boolean?) = + apply { + body.public_(public_) + } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by + * anybody inside or outside the organization */ - fun public_(public_: JsonField) = apply { body.public_(public_) } + fun public_(public_: JsonField) = + apply { + body.public_(public_) + } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: RepoInfo?) = + apply { + body.repoInfo(repoInfo) + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } + fun repoInfo(repoInfo: JsonField) = + apply { + body.repoInfo(repoInfo) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentUpdateParams = ExperimentUpdateParams( - checkRequired("experimentId", experimentId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "experimentId", experimentId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -718,20 +834,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -740,38 +858,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -784,15 +910,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ExperimentUpdateParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ExperimentUpdateParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 887cdc58..1181a618 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -22,28 +22,19 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackDatasetItem -@JsonCreator -private constructor( +class FeedbackDatasetItem @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") - @ExcludeMissing - private val comment: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ fun id(): String = id.getRequired("id") @@ -51,9 +42,10 @@ private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -64,26 +56,37 @@ private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + @JsonProperty("comment") + @ExcludeMissing + fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + @JsonProperty("source") + @ExcludeMissing + fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -91,18 +94,19 @@ private constructor( private var validated: Boolean = false - fun validate(): FeedbackDatasetItem = apply { - if (validated) { - return@apply - } + fun validate(): FeedbackDatasetItem = + apply { + if (validated) { + return@apply + } - id() - comment() - metadata().ifPresent { it.validate() } - source() - tags() - validated = true - } + id() + comment() + metadata().ifPresent { it.validate() } + source() + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -112,11 +116,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [FeedbackDatasetItem]. * * The following fields are required: + * * ```java * .id() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FeedbackDatasetItem]. */ @@ -130,26 +136,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackDatasetItem: FeedbackDatasetItem) = apply { - id = feedbackDatasetItem.id - comment = feedbackDatasetItem.comment - metadata = feedbackDatasetItem.metadata - source = feedbackDatasetItem.source - tags = feedbackDatasetItem.tags.map { it.toMutableList() } - additionalProperties = feedbackDatasetItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackDatasetItem: FeedbackDatasetItem) = + apply { + id = feedbackDatasetItem.id + comment = feedbackDatasetItem.comment + metadata = feedbackDatasetItem.metadata + source = feedbackDatasetItem.source + tags = feedbackDatasetItem.tags.map { it.toMutableList() } + additionalProperties = feedbackDatasetItem.additionalProperties.toMutableMap() + } /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** An optional comment string to log about the dataset event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -158,28 +168,37 @@ private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the dataset event */ - fun comment(comment: JsonField) = apply { this.comment = comment } + fun comment(comment: JsonField) = + apply { + this.comment = comment + } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -188,7 +207,10 @@ private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = + apply { + this.source = source + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -197,56 +219,68 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackDatasetItem = FeedbackDatasetItem( - checkRequired("id", id), - comment, - metadata, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + comment, + metadata, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -255,20 +289,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -277,38 +313,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -321,17 +365,21 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor(private val value: JsonField) : Enum { + class Source @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -355,9 +403,11 @@ private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] 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 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 { @@ -369,11 +419,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -386,11 +436,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -403,23 +453,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -428,11 +475,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackDatasetItem && id == other.id && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackDatasetItem && id == other.id && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -441,6 +488,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index a30bbcd2..704af01b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -22,32 +22,21 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackExperimentItem -@JsonCreator -private constructor( +class FeedbackExperimentItem @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") - @ExcludeMissing - private val comment: JsonField = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * The id of the experiment event to log feedback for. This is the row `id` returned by `POST - * /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ fun id(): String = id.getRequired("id") @@ -55,21 +44,24 @@ private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) @@ -80,32 +72,45 @@ private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the experiment event to log feedback for. This is the row `id` returned by `POST - * /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + @JsonProperty("comment") + @ExcludeMissing + fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + @JsonProperty("source") + @ExcludeMissing + fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -113,33 +118,37 @@ private constructor( private var validated: Boolean = false - fun validate(): FeedbackExperimentItem = apply { - if (validated) { - return@apply - } + fun validate(): FeedbackExperimentItem = + apply { + if (validated) { + return@apply + } - id() - comment() - metadata().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - source() - tags() - validated = true - } + id() + comment() + metadata().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + source() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FeedbackExperimentItem]. + * Returns a mutable builder for constructing an instance of + * [FeedbackExperimentItem]. * * The following fields are required: + * * ```java * .id() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FeedbackExperimentItem]. */ @@ -155,28 +164,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackExperimentItem: FeedbackExperimentItem) = apply { - id = feedbackExperimentItem.id - comment = feedbackExperimentItem.comment - expected = feedbackExperimentItem.expected - metadata = feedbackExperimentItem.metadata - scores = feedbackExperimentItem.scores - source = feedbackExperimentItem.source - tags = feedbackExperimentItem.tags.map { it.toMutableList() } - additionalProperties = feedbackExperimentItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackExperimentItem: FeedbackExperimentItem) = + apply { + id = feedbackExperimentItem.id + comment = feedbackExperimentItem.comment + expected = feedbackExperimentItem.expected + metadata = feedbackExperimentItem.metadata + scores = feedbackExperimentItem.scores + source = feedbackExperimentItem.source + tags = feedbackExperimentItem.tags.map { it.toMutableList() } + additionalProperties = feedbackExperimentItem.additionalProperties.toMutableMap() + } /** - * The id of the experiment event to log feedback for. This is the row `id` returned by - * `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the experiment event to log feedback for. This is the row `id` returned by - * `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** An optional comment string to log about the experiment event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -185,52 +198,67 @@ private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the experiment event */ - fun comment(comment: JsonField) = apply { this.comment = comment } + fun comment(comment: JsonField) = + apply { + this.comment = comment + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -239,7 +267,10 @@ private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = + apply { + this.source = source + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -248,58 +279,70 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackExperimentItem = FeedbackExperimentItem( - checkRequired("id", id), - comment, - expected, - metadata, - scores, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + comment, + expected, + metadata, + scores, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -308,20 +351,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -330,38 +375,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -374,15 +427,13 @@ private constructor( } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -391,20 +442,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -413,38 +466,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -457,17 +518,21 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor(private val value: JsonField) : Enum { + class Source @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -491,9 +556,11 @@ private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] 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 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 { @@ -505,11 +572,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -522,11 +589,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -539,23 +606,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -564,11 +628,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -577,6 +641,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FeedbackExperimentItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackExperimentItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 14572b2f..e1e18a1d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -22,32 +22,21 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackProjectLogsItem -@JsonCreator -private constructor( +class FeedbackProjectLogsItem @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") - @ExcludeMissing - private val comment: JsonField = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * The id of the project logs event to log feedback for. This is the row `id` returned by `POST - * /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ fun id(): String = id.getRequired("id") @@ -55,21 +44,24 @@ private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) @@ -80,32 +72,45 @@ private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the project logs event to log feedback for. This is the row `id` returned by `POST - * /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + @JsonProperty("comment") + @ExcludeMissing + fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + @JsonProperty("source") + @ExcludeMissing + fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -113,33 +118,37 @@ private constructor( private var validated: Boolean = false - fun validate(): FeedbackProjectLogsItem = apply { - if (validated) { - return@apply - } + fun validate(): FeedbackProjectLogsItem = + apply { + if (validated) { + return@apply + } - id() - comment() - metadata().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - source() - tags() - validated = true - } + id() + comment() + metadata().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + source() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FeedbackProjectLogsItem]. + * Returns a mutable builder for constructing an instance of + * [FeedbackProjectLogsItem]. * * The following fields are required: + * * ```java * .id() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FeedbackProjectLogsItem]. */ @@ -155,28 +164,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackProjectLogsItem: FeedbackProjectLogsItem) = apply { - id = feedbackProjectLogsItem.id - comment = feedbackProjectLogsItem.comment - expected = feedbackProjectLogsItem.expected - metadata = feedbackProjectLogsItem.metadata - scores = feedbackProjectLogsItem.scores - source = feedbackProjectLogsItem.source - tags = feedbackProjectLogsItem.tags.map { it.toMutableList() } - additionalProperties = feedbackProjectLogsItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackProjectLogsItem: FeedbackProjectLogsItem) = + apply { + id = feedbackProjectLogsItem.id + comment = feedbackProjectLogsItem.comment + expected = feedbackProjectLogsItem.expected + metadata = feedbackProjectLogsItem.metadata + scores = feedbackProjectLogsItem.scores + source = feedbackProjectLogsItem.source + tags = feedbackProjectLogsItem.tags.map { it.toMutableList() } + additionalProperties = feedbackProjectLogsItem.additionalProperties.toMutableMap() + } /** - * The id of the project logs event to log feedback for. This is the row `id` returned by - * `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the project logs event to log feedback for. This is the row `id` returned by - * `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** An optional comment string to log about the project logs event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -185,52 +198,67 @@ private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the project logs event */ - fun comment(comment: JsonField) = apply { this.comment = comment } + fun comment(comment: JsonField) = + apply { + this.comment = comment + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -239,7 +267,10 @@ private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = + apply { + this.source = source + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -248,58 +279,70 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackProjectLogsItem = FeedbackProjectLogsItem( - checkRequired("id", id), - comment, - expected, - metadata, - scores, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + comment, + expected, + metadata, + scores, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, + * you can log it here and access it in the Braintrust UI. Note, this metadata does + * not correspond to the main event itself, but rather the audit log attached to + * the event. */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -308,20 +351,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -330,38 +375,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -374,15 +427,13 @@ private constructor( } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -391,20 +442,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -413,38 +466,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -457,17 +518,21 @@ private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor(private val value: JsonField) : Enum { + class Source @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -491,9 +556,11 @@ private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] 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 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 { @@ -505,11 +572,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -522,11 +589,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -539,23 +606,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -564,11 +628,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -577,6 +641,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FeedbackProjectLogsItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackProjectLogsItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index d4e37e96..fe72645f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -19,18 +19,17 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class FeedbackResponseSchema -@JsonCreator -private constructor( - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), +class FeedbackResponseSchema @JsonCreator private constructor( + @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun status(): Status = status.getRequired("status") - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -38,28 +37,32 @@ private constructor( private var validated: Boolean = false - fun validate(): FeedbackResponseSchema = apply { - if (validated) { - return@apply - } + fun validate(): FeedbackResponseSchema = + apply { + if (validated) { + return@apply + } - status() - validated = true - } + status() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FeedbackResponseSchema]. + * Returns a mutable builder for constructing an instance of + * [FeedbackResponseSchema]. * * The following fields are required: + * * ```java * .status() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FeedbackResponseSchema]. */ @@ -69,52 +72,68 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackResponseSchema: FeedbackResponseSchema) = apply { - status = feedbackResponseSchema.status - additionalProperties = feedbackResponseSchema.additionalProperties.toMutableMap() - } + internal fun from(feedbackResponseSchema: FeedbackResponseSchema) = + apply { + status = feedbackResponseSchema.status + additionalProperties = feedbackResponseSchema.additionalProperties.toMutableMap() + } fun status(status: Status) = status(JsonField.of(status)) - fun status(status: JsonField) = apply { this.status = status } + fun status(status: JsonField) = + apply { + this.status = status + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackResponseSchema = FeedbackResponseSchema( - checkRequired("status", status), - additionalProperties.toImmutable(), + checkRequired( + "status", status + ), additionalProperties.toImmutable() ) } - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + class Status @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -125,16 +144,18 @@ private constructor( /** An enum containing [Status]'s known values. */ enum class Known { - SUCCESS + SUCCESS, } /** * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Status] 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 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 { @@ -144,11 +165,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -159,11 +180,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -174,23 +195,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -199,11 +217,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackResponseSchema && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackResponseSchema && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -212,6 +230,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 93503c6a..4dac3d22 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -20,16 +20,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchDatasetEventsResponse -@JsonCreator -private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), +class FetchDatasetEventsResponse @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of fetched events */ @@ -38,21 +33,25 @@ private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -60,29 +59,33 @@ private constructor( private var validated: Boolean = false - fun validate(): FetchDatasetEventsResponse = apply { - if (validated) { - return@apply - } + fun validate(): FetchDatasetEventsResponse = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - cursor() - validated = true - } + events().forEach { it.validate() } + cursor() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FetchDatasetEventsResponse]. + * Returns a mutable builder for constructing an instance of + * [FetchDatasetEventsResponse]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FetchDatasetEventsResponse]. */ @@ -93,85 +96,99 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchDatasetEventsResponse: FetchDatasetEventsResponse) = apply { - events = fetchDatasetEventsResponse.events.map { it.toMutableList() } - cursor = fetchDatasetEventsResponse.cursor - additionalProperties = fetchDatasetEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchDatasetEventsResponse: FetchDatasetEventsResponse) = + apply { + events = fetchDatasetEventsResponse.events.map { it.toMutableList() } + cursor = fetchDatasetEventsResponse.cursor + additionalProperties = fetchDatasetEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: DatasetEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: DatasetEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchDatasetEventsResponse = FetchDatasetEventsResponse( - checkRequired("events", events).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchDatasetEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchDatasetEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -180,6 +197,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 23656816..79cd0295 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -20,16 +20,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchExperimentEventsResponse -@JsonCreator -private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), +class FetchExperimentEventsResponse @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of fetched events */ @@ -38,21 +33,25 @@ private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -60,15 +59,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FetchExperimentEventsResponse = apply { - if (validated) { - return@apply - } + fun validate(): FetchExperimentEventsResponse = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - cursor() - validated = true - } + events().forEach { it.validate() } + cursor() + validated = true + } fun toBuilder() = Builder().from(this) @@ -79,11 +79,13 @@ private constructor( * [FetchExperimentEventsResponse]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FetchExperimentEventsResponse]. */ @@ -94,85 +96,99 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchExperimentEventsResponse: FetchExperimentEventsResponse) = apply { - events = fetchExperimentEventsResponse.events.map { it.toMutableList() } - cursor = fetchExperimentEventsResponse.cursor - additionalProperties = fetchExperimentEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchExperimentEventsResponse: FetchExperimentEventsResponse) = + apply { + events = fetchExperimentEventsResponse.events.map { it.toMutableList() } + cursor = fetchExperimentEventsResponse.cursor + additionalProperties = fetchExperimentEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: ExperimentEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: ExperimentEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchExperimentEventsResponse = FetchExperimentEventsResponse( - checkRequired("events", events).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchExperimentEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchExperimentEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -181,6 +197,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 1fd8d53c..09df951f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -20,16 +20,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchProjectLogsEventsResponse -@JsonCreator -private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), +class FetchProjectLogsEventsResponse @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of fetched events */ @@ -38,8 +33,8 @@ private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) @@ -51,10 +46,12 @@ private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -62,15 +59,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FetchProjectLogsEventsResponse = apply { - if (validated) { - return@apply - } + fun validate(): FetchProjectLogsEventsResponse = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - cursor() - validated = true - } + events().forEach { it.validate() } + cursor() + validated = true + } fun toBuilder() = Builder().from(this) @@ -81,11 +79,13 @@ private constructor( * [FetchProjectLogsEventsResponse]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FetchProjectLogsEventsResponse]. */ @@ -96,86 +96,99 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchProjectLogsEventsResponse: FetchProjectLogsEventsResponse) = apply { - events = fetchProjectLogsEventsResponse.events.map { it.toMutableList() } - cursor = fetchProjectLogsEventsResponse.cursor - additionalProperties = - fetchProjectLogsEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchProjectLogsEventsResponse: FetchProjectLogsEventsResponse) = + apply { + events = fetchProjectLogsEventsResponse.events.map { it.toMutableList() } + cursor = fetchProjectLogsEventsResponse.cursor + additionalProperties = fetchProjectLogsEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: ProjectLogsEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: ProjectLogsEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to + * get the next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse( - checkRequired("events", events).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchProjectLogsEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchProjectLogsEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -184,6 +197,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } 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..34c094de 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 @@ -33,57 +33,35 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Function -@JsonCreator -private constructor( +class Function @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("function_data") - @ExcludeMissing - private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") - @ExcludeMissing - private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -108,15 +86,12 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = - Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) /** User-controlled metadata about the prompt */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -124,46 +99,64 @@ private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId @JsonProperty("function_data") @ExcludeMissing fun _functionData(): JsonField = functionData /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId(): JsonField = logId /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** JSON schema for the function's parameters and return type */ @JsonProperty("function_schema") @@ -175,9 +168,13 @@ private constructor( fun _functionType(): JsonField = functionType /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -185,7 +182,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -193,29 +192,30 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - id() - _xactId() - functionData().validate() - logId() - name() - orgId() - projectId() - slug() - created() - description() - functionSchema().ifPresent { it.validate() } - functionType() - metadata().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + id() + _xactId() + functionData().validate() + logId() + name() + orgId() + projectId() + slug() + created() + description() + functionSchema().ifPresent { it.validate() } + functionType() + metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -225,6 +225,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -236,7 +237,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -261,51 +263,61 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - id = function.id - _xactId = function._xactId - functionData = function.functionData - logId = function.logId - name = function.name - orgId = function.orgId - projectId = function.projectId - slug = function.slug - created = function.created - description = function.description - functionSchema = function.functionSchema - functionType = function.functionType - metadata = function.metadata - origin = function.origin - promptData = function.promptData - tags = function.tags.map { it.toMutableList() } - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + id = function.id + _xactId = function._xactId + functionData = function.functionData + logId = function.logId + name = function.name + orgId = function.orgId + projectId = function.projectId + slug = function.slug + created = function.created + description = function.description + functionSchema = function.functionSchema + functionType = function.functionType + metadata = function.metadata + origin = function.origin + promptData = function.promptData + tags = function.tags.map { it.toMutableList() } + additionalProperties = function.additionalProperties.toMutableMap() + } /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = + apply { + this.functionData = functionData + } fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) @@ -317,31 +329,46 @@ private constructor( fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = + apply { + this.logId = logId + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Date of prompt creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -350,7 +377,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of prompt creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -359,30 +389,31 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = - functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = + apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -391,13 +422,19 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the prompt */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -406,7 +443,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -415,64 +455,91 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("functionData", functionData), - checkRequired("logId", logId), - checkRequired("name", name), - checkRequired("orgId", orgId), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - created, - description, - functionSchema, - functionType, - metadata, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "functionData", functionData + ), + checkRequired( + "logId", logId + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + created, + description, + functionSchema, + functionType, + metadata, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( + class FunctionData private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -496,45 +563,44 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -550,16 +616,19 @@ private constructor( companion object { - @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic + fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic + fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic + fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value of type - * [T]. + * An interface that defines how to map each variant of [FunctionData] to a value + * of type [T]. */ interface Visitor { @@ -572,71 +641,62 @@ private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize( - value: FunctionData, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Prompt @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -644,14 +704,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -661,11 +722,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -675,43 +738,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt(checkRequired("type", type), additionalProperties.toImmutable()) + Prompt( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -721,7 +798,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -732,23 +810,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT + PROMPT, } /** * 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 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 { PROMPT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -772,7 +850,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -787,19 +865,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -808,11 +883,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -821,31 +896,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code - @JsonCreator - private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Code @JsonCreator private constructor( + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -853,15 +925,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Code = apply { - if (validated) { - return@apply - } + fun validate(): Code = + apply { + if (validated) { + return@apply + } - data().validate() - type() - validated = true - } + data().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -871,12 +944,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: + * * ```java * .data() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Code]. */ @@ -887,15 +962,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = + apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -903,45 +982,56 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, + ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -959,40 +1049,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1007,9 +1096,11 @@ private constructor( companion object { - @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic + fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic + fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1025,86 +1116,65 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle - @JsonCreator - private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = - JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Bundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = - Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1125,7 +1195,9 @@ private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1141,18 +1213,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Bundle = apply { - if (validated) { - return@apply - } + fun validate(): Bundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1162,6 +1235,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() @@ -1169,7 +1243,8 @@ private constructor( * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1180,40 +1255,38 @@ private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = + apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = - location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = + apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = - location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = - location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1227,11 +1300,17 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1239,44 +1318,57 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -1290,25 +1382,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE + BUNDLE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { BUNDLE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1316,8 +1406,8 @@ private constructor( * 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. + * 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) { @@ -1328,11 +1418,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1343,23 +1433,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1368,11 +1455,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1381,41 +1468,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Inline @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1423,16 +1504,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Inline = apply { - if (validated) { - return@apply - } + fun validate(): Inline = + apply { + if (validated) { + return@apply + } - code() - runtimeContext().validate() - type() - validated = true - } + code() + runtimeContext().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1442,13 +1524,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: + * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1457,31 +1541,37 @@ private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = + apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1489,44 +1579,47 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired("code", code), - checkRequired("runtimeContext", runtimeContext), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "runtimeContext", runtimeContext + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1547,31 +1640,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RuntimeContext]. + * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1579,28 +1674,29 @@ private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = - runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = + apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1608,41 +1704,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @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. + * 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 @@ -1663,33 +1768,29 @@ private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] 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. * - * An instance of [Runtime] 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 { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Runtime] 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. + * 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. + * 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) { @@ -1701,42 +1802,36 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown Runtime: $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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1745,11 +1840,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1758,21 +1853,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -1786,25 +1881,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE + INLINE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { INLINE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1812,8 +1905,8 @@ private constructor( * 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. + * 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) { @@ -1824,11 +1917,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1839,23 +1932,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1864,11 +1954,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1877,13 +1967,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1893,7 +1984,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1904,23 +1996,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE + CODE, } /** * 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 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 { CODE, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1944,7 +2036,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1959,19 +2051,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1980,11 +2069,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1993,31 +2082,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2025,15 +2111,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2043,12 +2130,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -2059,52 +2148,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2114,7 +2220,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2125,23 +2232,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * 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 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 { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2165,7 +2272,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2180,19 +2287,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2201,11 +2305,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2214,23 +2318,26 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** A literal 'p' which identifies the object as a project prompt */ - class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { + class LogId @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2241,16 +2348,18 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - P + P, } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] 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 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 { @@ -2260,11 +2369,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -2275,11 +2384,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2290,23 +2399,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2316,20 +2422,20 @@ private constructor( /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema @JsonCreator private constructor( + @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonValue = parameters - @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns + @JsonProperty("returns") + @ExcludeMissing + fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2337,20 +2443,22 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = apply { - if (validated) { - return@apply - } + fun validate(): FunctionSchema = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2361,45 +2469,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = + apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + fun parameters(parameters: JsonValue) = + apply { + this.parameters = parameters + } - fun returns(returns: JsonValue) = apply { this.returns = returns } + fun returns(returns: JsonValue) = + apply { + this.returns = returns + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema(parameters, returns, additionalProperties.toImmutable()) + FunctionSchema( + parameters, + returns, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2408,22 +2534,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2447,12 +2575,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] 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 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 { @@ -2461,17 +2592,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -2485,11 +2617,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2503,23 +2635,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2529,11 +2658,9 @@ private constructor( /** User-controlled metadata about the prompt */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -2542,20 +2669,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -2564,38 +2693,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2608,20 +2745,12 @@ private constructor( } @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") - @ExcludeMissing - private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Origin @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Id of the object the function is originating from */ @@ -2631,13 +2760,15 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2645,10 +2776,12 @@ private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ + @JsonProperty("internal") + @ExcludeMissing + fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2656,16 +2789,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - internal_() - validated = true - } + objectId() + objectType() + internal_() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2675,12 +2809,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2692,92 +2828,114 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } + fun internal_(internal_: JsonField) = + apply { + this.internal_ = internal_ + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - internal_, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2825,9 +2983,11 @@ private constructor( * 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 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 { @@ -2853,8 +3013,8 @@ private constructor( * 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. + * 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) { @@ -2879,7 +3039,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2903,20 +3063,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2925,11 +3082,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2938,16 +3095,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && functionData == other.functionData && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && metadata == other.metadata && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && functionData == other.functionData && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && metadata == other.metadata && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2956,6 +3112,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{id=$id, _xactId=$_xactId, functionData=$functionData, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionSchema=$functionSchema, functionType=$functionType, metadata=$metadata, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Function{id=$id, _xactId=$_xactId, functionData=$functionData, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionSchema=$functionSchema, functionType=$functionType, metadata=$metadata, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } 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 16db9180..09a7057d 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 @@ -36,14 +36,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new function. If there is an existing function in the project with the same slug as the - * one specified in the request, will return the existing function unmodified + * Create a new function. If there is an existing function in the project with the + * same slug as the one specified in the request, will return the existing function + * unmodified */ -class FunctionCreateParams -private constructor( +class FunctionCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { fun functionData(): FunctionData = body.functionData() @@ -106,48 +107,27 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("function_data") - @ExcludeMissing - private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") - @ExcludeMissing - private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun functionData(): FunctionData = functionData.getRequired("function_data") @@ -162,21 +142,17 @@ private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = - Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -186,13 +162,19 @@ private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -208,7 +190,9 @@ private constructor( @ExcludeMissing fun _functionType(): JsonField = functionType - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -216,7 +200,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -224,23 +210,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } - - functionData().validate() - name() - projectId() - slug() - description() - functionSchema().ifPresent { it.validate() } - functionType() - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + functionData().validate() + name() + projectId() + slug() + description() + functionSchema().ifPresent { it.validate() } + functionType() + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -250,6 +237,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .functionData() * .name() @@ -257,7 +245,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -276,51 +265,60 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - functionData = body.functionData - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionSchema = body.functionSchema - functionType = body.functionType - origin = body.origin - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + functionData = body.functionData + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionSchema = body.functionSchema + functionType = body.functionType + origin = body.origin + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = + apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = - functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = - functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -329,38 +327,40 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = - functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = + apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -369,9 +369,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -380,57 +381,75 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("functionData", functionData), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - description, - functionSchema, - functionType, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "functionData", functionData + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + description, + functionSchema, + functionType, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -439,8 +458,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -448,9 +466,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionCreateParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionCreateParams]. * * The following fields are required: + * * ```java * .functionData() * .name() @@ -458,7 +478,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionCreateParams]. */ @@ -470,234 +491,331 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionCreateParams: FunctionCreateParams) = apply { - body = functionCreateParams.body.toBuilder() - additionalHeaders = functionCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = functionCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(functionCreateParams: FunctionCreateParams) = + apply { + body = functionCreateParams.body.toBuilder() + additionalHeaders = functionCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = functionCreateParams.additionalQueryParams.toBuilder() + } - fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + fun functionData(functionData: FunctionData) = + apply { + body.functionData(functionData) + } - fun functionData(functionData: JsonField) = apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = + apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + fun functionData(prompt: FunctionData.Prompt) = + apply { + body.functionData(prompt) + } - fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + fun functionData(code: FunctionData.Code) = + apply { + body.functionData(code) + } - fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + fun functionData(global: FunctionData.Global) = + apply { + body.functionData(global) + } /** Name of the prompt */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { body.slug(slug) } + fun slug(slug: String) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: FunctionSchema?) = + apply { + body.functionSchema(functionSchema) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: JsonField) = + apply { + body.functionSchema(functionSchema) + } - fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + fun functionType(functionType: FunctionType?) = + apply { + body.functionType(functionType) + } - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = + apply { + body.functionType(functionType) + } - fun origin(origin: Origin?) = apply { body.origin(origin) } + fun origin(origin: Origin?) = + apply { + body.origin(origin) + } fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { body.origin(origin) } + fun origin(origin: JsonField) = + apply { + body.origin(origin) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionCreateParams = FunctionCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( + class FunctionData private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -721,45 +839,44 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -775,16 +892,19 @@ private constructor( companion object { - @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic + fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic + fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic + fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value of type - * [T]. + * An interface that defines how to map each variant of [FunctionData] to a value + * of type [T]. */ interface Visitor { @@ -797,71 +917,62 @@ private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize( - value: FunctionData, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Prompt @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -869,14 +980,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -886,11 +998,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -900,43 +1014,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt(checkRequired("type", type), additionalProperties.toImmutable()) + Prompt( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -946,7 +1074,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -957,23 +1086,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT + PROMPT, } /** * 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 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 { PROMPT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -997,7 +1126,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1012,19 +1141,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1033,11 +1159,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1046,31 +1172,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code - @JsonCreator - private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Code @JsonCreator private constructor( + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1078,15 +1201,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Code = apply { - if (validated) { - return@apply - } + fun validate(): Code = + apply { + if (validated) { + return@apply + } - data().validate() - type() - validated = true - } + data().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1096,12 +1220,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: + * * ```java * .data() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Code]. */ @@ -1112,15 +1238,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = + apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -1128,45 +1258,56 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, + ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1184,40 +1325,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1232,9 +1372,11 @@ private constructor( companion object { - @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic + fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic + fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1250,86 +1392,65 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle - @JsonCreator - private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = - JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Bundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = - Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1350,7 +1471,9 @@ private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1366,18 +1489,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Bundle = apply { - if (validated) { - return@apply - } + fun validate(): Bundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1387,6 +1511,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() @@ -1394,7 +1519,8 @@ private constructor( * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1405,40 +1531,38 @@ private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = + apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = - location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = + apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = - location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = - location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1452,11 +1576,17 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1464,44 +1594,57 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -1515,25 +1658,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE + BUNDLE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { BUNDLE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1541,8 +1682,8 @@ private constructor( * 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. + * 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) { @@ -1553,11 +1694,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1568,23 +1709,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1593,11 +1731,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1606,41 +1744,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Inline @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1648,16 +1780,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Inline = apply { - if (validated) { - return@apply - } + fun validate(): Inline = + apply { + if (validated) { + return@apply + } - code() - runtimeContext().validate() - type() - validated = true - } + code() + runtimeContext().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1667,13 +1800,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: + * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1682,31 +1817,37 @@ private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = + apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1714,44 +1855,47 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired("code", code), - checkRequired("runtimeContext", runtimeContext), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "runtimeContext", runtimeContext + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1772,31 +1916,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RuntimeContext]. + * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1804,28 +1950,29 @@ private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = - runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = + apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1833,41 +1980,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @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. + * 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 @@ -1888,33 +2044,29 @@ private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] 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. * - * An instance of [Runtime] 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 { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Runtime] 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. + * 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. + * 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) { @@ -1926,42 +2078,36 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown Runtime: $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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1970,11 +2116,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1983,21 +2129,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -2011,25 +2157,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE + INLINE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { INLINE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2037,8 +2181,8 @@ private constructor( * 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. + * 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) { @@ -2049,11 +2193,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2064,23 +2208,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2089,11 +2230,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2102,13 +2243,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2118,7 +2260,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2129,23 +2272,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE + CODE, } /** * 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 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 { CODE, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2169,7 +2312,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2184,19 +2327,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2205,11 +2345,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2218,31 +2358,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2250,15 +2387,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2268,12 +2406,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -2284,52 +2424,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2339,7 +2496,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2350,23 +2508,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * 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 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 { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2390,7 +2548,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2405,19 +2563,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2426,11 +2581,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2439,27 +2594,26 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema @JsonCreator private constructor( + @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonValue = parameters - @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns + @JsonProperty("returns") + @ExcludeMissing + fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2467,20 +2621,22 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = apply { - if (validated) { - return@apply - } + fun validate(): FunctionSchema = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2491,45 +2647,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = + apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + fun parameters(parameters: JsonValue) = + apply { + this.parameters = parameters + } - fun returns(returns: JsonValue) = apply { this.returns = returns } + fun returns(returns: JsonValue) = + apply { + this.returns = returns + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema(parameters, returns, additionalProperties.toImmutable()) + FunctionSchema( + parameters, + returns, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2538,22 +2712,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2577,12 +2753,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] 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 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 { @@ -2591,17 +2770,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -2615,11 +2795,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2633,23 +2813,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2658,20 +2835,12 @@ private constructor( } @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") - @ExcludeMissing - private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Origin @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Id of the object the function is originating from */ @@ -2681,13 +2850,15 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2695,10 +2866,12 @@ private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ + @JsonProperty("internal") + @ExcludeMissing + fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2706,16 +2879,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - internal_() - validated = true - } + objectId() + objectType() + internal_() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2725,12 +2899,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2742,92 +2918,114 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } + fun internal_(internal_: JsonField) = + apply { + this.internal_ = internal_ + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - internal_, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2875,9 +3073,11 @@ private constructor( * 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 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 { @@ -2903,8 +3103,8 @@ private constructor( * 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. + * 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) { @@ -2929,7 +3129,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2953,20 +3153,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2975,11 +3172,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2988,20 +3185,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index f2070a12..8076213e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a function object by its id */ -class FunctionDeleteParams -private constructor( +class FunctionDeleteParams private constructor( private val functionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Function id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionDeleteParams]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionDeleteParams]. */ @@ -70,155 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionDeleteParams: FunctionDeleteParams) = apply { - functionId = functionDeleteParams.functionId - additionalHeaders = functionDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = functionDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = functionDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(functionDeleteParams: FunctionDeleteParams) = + apply { + functionId = functionDeleteParams.functionId + additionalHeaders = functionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = functionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = functionDeleteParams.additionalBodyProperties.toMutableMap() + } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = + apply { + this.functionId = functionId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): FunctionDeleteParams = FunctionDeleteParams( - checkRequired("functionId", functionId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "functionId", functionId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 2792f617..16df2c1f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -35,12 +35,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Invoke a function. */ -class FunctionInvokeParams -private constructor( +class FunctionInvokeParams private constructor( private val functionId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Function id */ @@ -59,8 +59,8 @@ private constructor( fun parent(): Optional = body.parent() /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(): Optional = body.stream() @@ -77,8 +77,8 @@ private constructor( fun _parent(): JsonField = body._parent() /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun _stream(): JsonField = body._stream() @@ -91,48 +91,40 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } /** The request to invoke a function */ @NoAutoDetect - class Body - @JsonCreator - private constructor( + class Body @JsonCreator private constructor( @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("messages") - @ExcludeMissing - private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("messages") @ExcludeMissing private val messages: JsonField> = JsonMissing.of(), @JsonProperty("mode") @ExcludeMissing private val mode: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), - @JsonProperty("stream") - @ExcludeMissing - private val stream: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("parent") @ExcludeMissing private val parent: JsonField = JsonMissing.of(), + @JsonProperty("stream") @ExcludeMissing private val stream: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Argument to the function, which can be any JSON serializable value */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** If the function is an LLM, additional messages to pass along to it */ - fun messages(): Optional> = - Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional> = Optional.ofNullable(messages.getNullable("messages")) /** The mode format of the returned value (defaults to 'auto') */ fun mode(): Optional = Optional.ofNullable(mode.getNullable("mode")) @@ -141,8 +133,8 @@ private constructor( fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) @@ -155,19 +147,27 @@ private constructor( fun _messages(): JsonField> = messages /** The mode format of the returned value (defaults to 'auto') */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + @JsonProperty("mode") + @ExcludeMissing + fun _mode(): JsonField = mode /** Options for tracing the function call */ - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + @JsonProperty("parent") + @ExcludeMissing + fun _parent(): JsonField = parent /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ - @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream + @JsonProperty("stream") + @ExcludeMissing + fun _stream(): JsonField = stream /** The version of the function */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -175,25 +175,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - messages().ifPresent { it.forEach { it.validate() } } - mode() - parent().ifPresent { it.validate() } - stream() - version() - validated = true - } + messages().ifPresent { it.forEach { it.validate() } } + mode() + parent().ifPresent { it.validate() } + stream() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -208,34 +210,39 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - input = body.input - messages = body.messages.map { it.toMutableList() } - mode = body.mode - parent = body.parent - stream = body.stream - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + input = body.input + messages = body.messages.map { it.toMutableList() } + mode = body.mode + parent = body.parent + stream = body.stream + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** Argument to the function, which can be any JSON serializable value */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** If the function is an LLM, additional messages to pass along to it */ fun messages(messages: List) = messages(JsonField.of(messages)) /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: JsonField>) = apply { - this.messages = messages.map { it.toMutableList() } - } + fun messages(messages: JsonField>) = + apply { + this.messages = messages.map { it.toMutableList() } + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: Message) = apply { - messages = - (messages ?: JsonField.of(mutableListOf())).also { + fun addMessage(message: Message) = + apply { + messages = (messages ?: JsonField.of(mutableListOf())).also { checkKnown("messages", it).add(message) } - } + } /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) @@ -244,8 +251,7 @@ private constructor( fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(assistant: Message.Assistant) = - addMessage(Message.ofAssistant(assistant)) + fun addMessage(assistant: Message.Assistant) = addMessage(Message.ofAssistant(assistant)) /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) @@ -263,88 +269,106 @@ private constructor( fun mode(mode: Optional) = mode(mode.getOrNull()) /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: JsonField) = apply { this.mode = mode } + fun mode(mode: JsonField) = + apply { + this.mode = mode + } /** Options for tracing the function call */ fun parent(parent: Parent) = parent(JsonField.of(parent)) /** Options for tracing the function call */ - fun parent(parent: JsonField) = apply { this.parent = parent } + fun parent(parent: JsonField) = + apply { + this.parent = parent + } /** Span parent properties */ - fun parent(spanParentStruct: Parent.SpanParentStruct) = - parent(Parent.ofSpanParentStruct(spanParentStruct)) + fun parent(spanParentStruct: Parent.SpanParentStruct) = parent(Parent.ofSpanParentStruct(spanParentStruct)) /** The parent's span identifier, created by calling `.export()` on a span */ fun parent(string: String) = parent(Parent.ofString(string)) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Boolean?) = stream(JsonField.ofNullable(stream)) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Boolean) = stream(stream as Boolean?) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Optional) = stream(stream.getOrNull()) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ - fun stream(stream: JsonField) = apply { this.stream = stream } + fun stream(stream: JsonField) = + apply { + this.stream = stream + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = apply { this.version = version } + fun version(version: JsonField) = + apply { + this.version = version + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - input, - (messages ?: JsonMissing.of()).map { it.toImmutable() }, - mode, - parent, - stream, - version, - additionalProperties.toImmutable(), + input, + (messages ?: JsonMissing.of()).map { it.toImmutable() }, + mode, + parent, + stream, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -353,8 +377,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -362,14 +385,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionInvokeParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionInvokeParams]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionInvokeParams]. */ @@ -382,229 +408,326 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionInvokeParams: FunctionInvokeParams) = apply { - functionId = functionInvokeParams.functionId - body = functionInvokeParams.body.toBuilder() - additionalHeaders = functionInvokeParams.additionalHeaders.toBuilder() - additionalQueryParams = functionInvokeParams.additionalQueryParams.toBuilder() - } + internal fun from(functionInvokeParams: FunctionInvokeParams) = + apply { + functionId = functionInvokeParams.functionId + body = functionInvokeParams.body.toBuilder() + additionalHeaders = functionInvokeParams.additionalHeaders.toBuilder() + additionalQueryParams = functionInvokeParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = + apply { + this.functionId = functionId + } /** Argument to the function, which can be any JSON serializable value */ - fun input(input: JsonValue) = apply { body.input(input) } + fun input(input: JsonValue) = + apply { + body.input(input) + } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: List) = apply { body.messages(messages) } + fun messages(messages: List) = + apply { + body.messages(messages) + } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: JsonField>) = apply { body.messages(messages) } + fun messages(messages: JsonField>) = + apply { + body.messages(messages) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: Message) = apply { body.addMessage(message) } + fun addMessage(message: Message) = + apply { + body.addMessage(message) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(system: Message.System) = apply { body.addMessage(system) } + fun addMessage(system: Message.System) = + apply { + body.addMessage(system) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(user: Message.User) = apply { body.addMessage(user) } + fun addMessage(user: Message.User) = + apply { + body.addMessage(user) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(assistant: Message.Assistant) = apply { body.addMessage(assistant) } + fun addMessage(assistant: Message.Assistant) = + apply { + body.addMessage(assistant) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(tool: Message.Tool) = apply { body.addMessage(tool) } + fun addMessage(tool: Message.Tool) = + apply { + body.addMessage(tool) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(function: Message.Function) = apply { body.addMessage(function) } + fun addMessage(function: Message.Function) = + apply { + body.addMessage(function) + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(fallback: Message.Fallback) = apply { body.addMessage(fallback) } + fun addMessage(fallback: Message.Fallback) = + apply { + body.addMessage(fallback) + } /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: Mode?) = apply { body.mode(mode) } + fun mode(mode: Mode?) = + apply { + body.mode(mode) + } /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Optional) = mode(mode.getOrNull()) /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: JsonField) = apply { body.mode(mode) } + fun mode(mode: JsonField) = + apply { + body.mode(mode) + } /** Options for tracing the function call */ - fun parent(parent: Parent) = apply { body.parent(parent) } + fun parent(parent: Parent) = + apply { + body.parent(parent) + } /** Options for tracing the function call */ - fun parent(parent: JsonField) = apply { body.parent(parent) } + fun parent(parent: JsonField) = + apply { + body.parent(parent) + } /** Span parent properties */ - fun parent(spanParentStruct: Parent.SpanParentStruct) = apply { - body.parent(spanParentStruct) - } + fun parent(spanParentStruct: Parent.SpanParentStruct) = + apply { + body.parent(spanParentStruct) + } /** The parent's span identifier, created by calling `.export()` on a span */ - fun parent(string: String) = apply { body.parent(string) } + fun parent(string: String) = + apply { + body.parent(string) + } /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ - fun stream(stream: Boolean?) = apply { body.stream(stream) } + fun stream(stream: Boolean?) = + apply { + body.stream(stream) + } /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Boolean) = stream(stream as Boolean?) /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ fun stream(stream: Optional) = stream(stream.getOrNull()) /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Whether to stream the response. If true, results will be returned in the + * Braintrust SSE format. */ - fun stream(stream: JsonField) = apply { body.stream(stream) } + fun stream(stream: JsonField) = + apply { + body.stream(stream) + } /** The version of the function */ - fun version(version: String) = apply { body.version(version) } + fun version(version: String) = + apply { + body.version(version) + } /** The version of the function */ - fun version(version: JsonField) = apply { body.version(version) } + fun version(version: JsonField) = + apply { + body.version(version) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionInvokeParams = FunctionInvokeParams( - checkRequired("functionId", functionId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "functionId", functionId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( + class Message private constructor( private val system: System? = null, private val user: User? = null, private val assistant: Assistant? = null, @@ -612,6 +735,7 @@ private constructor( private val function: Function? = null, private val fallback: Fallback? = null, private val _json: JsonValue? = null, + ) { fun system(): Optional = Optional.ofNullable(system) @@ -653,60 +777,59 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Message = apply { - if (validated) { - return@apply - } + fun validate(): Message = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitSystem(system: System) { - system.validate() + system.validate() } override fun visitUser(user: User) { - user.validate() + user.validate() } override fun visitAssistant(assistant: Assistant) { - assistant.validate() + assistant.validate() } override fun visitTool(tool: Tool) { - tool.validate() + tool.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitFallback(fallback: Fallback) { - fallback.validate() + fallback.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ + return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ @@ -725,21 +848,28 @@ private constructor( companion object { - @JvmStatic fun ofSystem(system: System) = Message(system = system) + @JvmStatic + fun ofSystem(system: System) = Message(system = system) - @JvmStatic fun ofUser(user: User) = Message(user = user) + @JvmStatic + fun ofUser(user: User) = Message(user = user) - @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) + @JvmStatic + fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) + @JvmStatic + fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic fun ofFunction(function: Function) = Message(function = function) + @JvmStatic + fun ofFunction(function: Function) = Message(function = function) - @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + @JvmStatic + fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } /** - * An interface that defines how to map each variant of [Message] to a value of type [T]. + * An interface that defines how to map each variant of [Message] to a value of + * type [T]. */ interface Visitor { @@ -758,87 +888,69 @@ private constructor( /** * Maps an unknown variant of [Message] to a value of type [T]. * - * An instance of [Message] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Message] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } internal class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } internal class Serializer : BaseSerializer(Message::class) { - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } @NoAutoDetect - class System - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class System @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") @@ -847,11 +959,17 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -859,16 +977,17 @@ private constructor( private var validated: Boolean = false - fun validate(): System = apply { - if (validated) { - return@apply - } + fun validate(): System = + apply { + if (validated) { + return@apply + } - role() - content() - name() - validated = true - } + role() + content() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -878,11 +997,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [System]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [System]. */ @@ -894,58 +1015,76 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(system: System) = apply { - role = system.role - content = system.content - name = system.name - additionalProperties = system.additionalProperties.toMutableMap() - } + internal fun from(system: System) = + apply { + role = system.role + content = system.content + name = system.name + additionalProperties = system.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): System = System( - checkRequired("role", role), - content, - name, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + name, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -955,7 +1094,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -966,23 +1106,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - SYSTEM + SYSTEM, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { SYSTEM, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1006,7 +1146,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1021,19 +1161,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1042,11 +1179,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1055,25 +1192,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class User - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class User @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") @@ -1082,11 +1210,17 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1094,16 +1228,17 @@ private constructor( private var validated: Boolean = false - fun validate(): User = apply { - if (validated) { - return@apply - } + fun validate(): User = + apply { + if (validated) { + return@apply + } - role() - content().ifPresent { it.validate() } - name() - validated = true - } + role() + content().ifPresent { it.validate() } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1113,11 +1248,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [User]. */ @@ -1129,63 +1266,80 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(user: User) = apply { - role = user.role - content = user.content - name = user.name - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = + apply { + role = user.role + content = user.content + name = user.name + additionalProperties = user.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: Content) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun content(text: String) = content(Content.ofText(text)) - fun contentOfArray(array: List) = - content(Content.ofArray(array)) + fun contentOfArray(array: List) = content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired("role", role), - content, - name, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + name, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1195,7 +1349,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1206,23 +1361,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - USER + USER, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { USER, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1246,7 +1401,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1261,19 +1416,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1283,11 +1435,11 @@ private constructor( @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( + class Content private constructor( private val text: String? = null, private val array: List? = null, private val _json: JsonValue? = null, + ) { fun text(): Optional = Optional.ofNullable(text) @@ -1305,38 +1457,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Content = apply { - if (validated) { - return@apply - } + fun validate(): Content = + apply { + if (validated) { + return@apply + } + + accept(object : Visitor { + override fun visitText(text: String) { - accept( - object : Visitor { - override fun visitText(text: String) {} + } override fun visitArray(array: List) { - array.forEach { it.validate() } + array.forEach { it.validate() } } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, array) /* spotless:on */ @@ -1351,15 +1504,16 @@ private constructor( companion object { - @JvmStatic fun ofText(text: String) = Content(text = text) + @JvmStatic + fun ofText(text: String) = Content(text = text) @JvmStatic fun ofArray(array: List) = Content(array = array) } /** - * An interface that defines how to map each variant of [Content] to a value of type - * [T]. + * An interface that defines how to map each variant of [Content] to a value of + * type [T]. */ interface Visitor { @@ -1370,66 +1524,58 @@ private constructor( /** * Maps an unknown variant of [Content] to a value of type [T]. * - * An instance of [Content] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * An instance of [Content] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } internal class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Content(array = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Content(array = it, _json = json) + } - return Content(_json = json) + return Content(_json = json) } } internal class Serializer : BaseSerializer(Content::class) { - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( + class ChatCompletionContentPart private constructor( private val text: ChatCompletionContentPartText? = null, private val image: ChatCompletionContentPartImage? = null, private val _json: JsonValue? = null, + ) { fun text(): Optional = Optional.ofNullable(text) - fun image(): Optional = - Optional.ofNullable(image) + fun image(): Optional = Optional.ofNullable(image) fun isText(): Boolean = text != null @@ -1442,40 +1588,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - image != null -> visitor.visitImage(image) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ChatCompletionContentPart = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPart = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitText(text: ChatCompletionContentPartText) { - text.validate() + text.validate() } override fun visitImage(image: ChatCompletionContentPartImage) { - image.validate() + image.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, image) /* spotless:on */ @@ -1491,17 +1636,15 @@ private constructor( companion object { @JvmStatic - fun ofText(text: ChatCompletionContentPartText) = - ChatCompletionContentPart(text = text) + fun ofText(text: ChatCompletionContentPartText) = ChatCompletionContentPart(text = text) @JvmStatic - fun ofImage(image: ChatCompletionContentPartImage) = - ChatCompletionContentPart(image = image) + fun ofImage(image: ChatCompletionContentPartImage) = ChatCompletionContentPart(image = image) } /** - * An interface that defines how to map each variant of - * [ChatCompletionContentPart] to a value of type [T]. + * An interface that defines how to map each variant of [ChatCompletionContentPart] + * to a value of type [T]. */ interface Visitor { @@ -1510,78 +1653,56 @@ private constructor( fun visitImage(image: ChatCompletionContentPartImage): T /** - * Maps an unknown variant of [ChatCompletionContentPart] to a value of type - * [T]. + * Maps an unknown variant of [ChatCompletionContentPart] to a value of type [T]. * - * An instance of [ChatCompletionContentPart] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. - * For example, if the SDK is on an older version than the API, then the API - * may respond with new variants that the SDK is unaware of. + * An instance of [ChatCompletionContentPart] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") } } - internal class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { + internal class Deserializer : BaseDeserializer(ChatCompletionContentPart::class) { - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return ChatCompletionContentPart(image = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ChatCompletionContentPart(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ChatCompletionContentPart(image = it, _json = json) + } - return ChatCompletionContentPart(_json = json) + return ChatCompletionContentPart(_json = json) } } - internal class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.image != null -> generator.writeObject(value.image) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid ChatCompletionContentPart") - } + internal class Serializer : BaseSerializer(ChatCompletionContentPart::class) { + + override fun serialize(value: ChatCompletionContentPart, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1590,55 +1711,45 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Assistant - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("function_call") - @ExcludeMissing - private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tool_calls") - @ExcludeMissing - private val toolCalls: JsonField> = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Assistant @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("tool_calls") @ExcludeMissing private val toolCalls: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall(): JsonField = functionCall - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("tool_calls") @ExcludeMissing @@ -1650,18 +1761,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Assistant = apply { - if (validated) { - return@apply - } + fun validate(): Assistant = + apply { + if (validated) { + return@apply + } - role() - content() - functionCall().ifPresent { it.validate() } - name() - toolCalls().ifPresent { it.forEach { it.validate() } } - validated = true - } + role() + content() + functionCall().ifPresent { it.validate() } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } fun toBuilder() = Builder().from(this) @@ -1671,11 +1783,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Assistant]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Assistant]. */ @@ -1689,93 +1803,109 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(assistant: Assistant) = apply { - role = assistant.role - content = assistant.content - functionCall = assistant.functionCall - name = assistant.name - toolCalls = assistant.toolCalls.map { it.toMutableList() } - additionalProperties = assistant.additionalProperties.toMutableMap() - } + internal fun from(assistant: Assistant) = + apply { + role = assistant.role + content = assistant.content + functionCall = assistant.functionCall + name = assistant.name + toolCalls = assistant.toolCalls.map { it.toMutableList() } + additionalProperties = assistant.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } - fun functionCall(functionCall: FunctionCall?) = - functionCall(JsonField.ofNullable(functionCall)) + fun functionCall(functionCall: FunctionCall?) = functionCall(JsonField.ofNullable(functionCall)) - fun functionCall(functionCall: Optional) = - functionCall(functionCall.getOrNull()) + fun functionCall(functionCall: Optional) = functionCall(functionCall.getOrNull()) - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } + fun functionCall(functionCall: JsonField) = + apply { + this.functionCall = functionCall + } fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.getOrNull()) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun toolCalls(toolCalls: List?) = - toolCalls(JsonField.ofNullable(toolCalls)) + fun toolCalls(toolCalls: List?) = toolCalls(JsonField.ofNullable(toolCalls)) - fun toolCalls(toolCalls: Optional>) = - toolCalls(toolCalls.getOrNull()) + fun toolCalls(toolCalls: Optional>) = toolCalls(toolCalls.getOrNull()) - fun toolCalls(toolCalls: JsonField>) = apply { - this.toolCalls = toolCalls.map { it.toMutableList() } - } + fun toolCalls(toolCalls: JsonField>) = + apply { + this.toolCalls = toolCalls.map { it.toMutableList() } + } - fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { - toolCalls = - (toolCalls ?: JsonField.of(mutableListOf())).also { + fun addToolCall(toolCall: ChatCompletionMessageToolCall) = + apply { + toolCalls = (toolCalls ?: JsonField.of(mutableListOf())).also { checkKnown("toolCalls", it).add(toolCall) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Assistant = Assistant( - checkRequired("role", role), - content, - functionCall, - name, - (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + functionCall, + name, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1785,7 +1915,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1796,23 +1927,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - ASSISTANT + ASSISTANT, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 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 { ASSISTANT, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1836,7 +1967,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1851,19 +1982,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1872,17 +2000,11 @@ private constructor( } @NoAutoDetect - class FunctionCall - @JsonCreator - private constructor( - @JsonProperty("arguments") - @ExcludeMissing - private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class FunctionCall @JsonCreator private constructor( + @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun arguments(): String = arguments.getRequired("arguments") @@ -1893,7 +2015,9 @@ private constructor( @ExcludeMissing fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1901,15 +2025,16 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionCall = apply { - if (validated) { - return@apply - } + fun validate(): FunctionCall = + apply { + if (validated) { + return@apply + } - arguments() - name() - validated = true - } + arguments() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1919,12 +2044,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [FunctionCall]. * * The following fields are required: + * * ```java * .arguments() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionCall]. */ @@ -1935,58 +2062,71 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - arguments = functionCall.arguments - name = functionCall.name - additionalProperties = functionCall.additionalProperties.toMutableMap() - } + internal fun from(functionCall: FunctionCall) = + apply { + arguments = functionCall.arguments + name = functionCall.name + additionalProperties = functionCall.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } + fun arguments(arguments: JsonField) = + apply { + this.arguments = arguments + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionCall = FunctionCall( - checkRequired("arguments", arguments), - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "arguments", arguments + ), + checkRequired( + "name", name + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1995,16 +2135,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2013,37 +2152,31 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Tool - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("tool_call_id") - @ExcludeMissing - private val toolCallId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Tool @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("tool_call_id") @ExcludeMissing private val toolCallId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun toolCallId(): Optional = - Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonProperty("tool_call_id") @ExcludeMissing @@ -2055,16 +2188,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Tool = apply { - if (validated) { - return@apply - } + fun validate(): Tool = + apply { + if (validated) { + return@apply + } - role() - content() - toolCallId() - validated = true - } + role() + content() + toolCallId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2074,11 +2208,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Tool]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Tool]. */ @@ -2090,60 +2226,76 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tool: Tool) = apply { - role = tool.role - content = tool.content - toolCallId = tool.toolCallId - additionalProperties = tool.additionalProperties.toMutableMap() - } + internal fun from(tool: Tool) = + apply { + role = tool.role + content = tool.content + toolCallId = tool.toolCallId + additionalProperties = tool.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } + fun toolCallId(toolCallId: JsonField) = + apply { + this.toolCallId = toolCallId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Tool = Tool( - checkRequired("role", role), - content, - toolCallId, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + toolCallId, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2153,7 +2305,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2164,23 +2317,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - TOOL + TOOL, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 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 { TOOL, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2204,7 +2357,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2219,19 +2372,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2240,11 +2390,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2253,25 +2403,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") @@ -2280,11 +2421,17 @@ private constructor( fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing @@ -2292,16 +2439,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - name() - role() - content() - validated = true - } + name() + role() + content() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2311,12 +2459,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .name() * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -2328,58 +2478,78 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - name = function.name - role = function.role - content = function.content - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + name = function.name + role = function.role + content = function.content + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("name", name), - checkRequired("role", role), - content, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "role", role + ), + content, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2389,7 +2559,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2400,23 +2571,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 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 { FUNCTION, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2440,7 +2611,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2455,19 +2626,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2476,11 +2644,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2489,31 +2657,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Fallback - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Fallback @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing @@ -2521,15 +2686,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Fallback = apply { - if (validated) { - return@apply - } + fun validate(): Fallback = + apply { + if (validated) { + return@apply + } - role() - content() - validated = true - } + role() + content() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2539,11 +2705,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Fallback]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Fallback]. */ @@ -2554,54 +2722,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fallback: Fallback) = apply { - role = fallback.role - content = fallback.content - additionalProperties = fallback.additionalProperties.toMutableMap() - } + internal fun from(fallback: Fallback) = + apply { + role = fallback.role + content = fallback.content + additionalProperties = fallback.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Fallback = Fallback( - checkRequired("role", role), - content, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Role @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2611,7 +2794,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2622,23 +2806,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - MODEL + MODEL, } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 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 { MODEL, - /** - * An enum member indicating that [Role] was instantiated with an unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2662,7 +2846,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2677,19 +2861,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2698,11 +2879,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2711,23 +2892,26 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" } } /** The mode format of the returned value (defaults to 'auto') */ - class Mode @JsonCreator private constructor(private val value: JsonField) : Enum { + class Mode @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2748,9 +2932,11 @@ private constructor( * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Mode] 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 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 { @@ -2761,11 +2947,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -2777,11 +2963,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2793,23 +2979,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2820,11 +3003,11 @@ private constructor( /** Options for tracing the function call */ @JsonDeserialize(using = Parent.Deserializer::class) @JsonSerialize(using = Parent.Serializer::class) - class Parent - private constructor( + class Parent private constructor( private val spanParentStruct: SpanParentStruct? = null, private val string: String? = null, private val _json: JsonValue? = null, + ) { /** Span parent properties */ @@ -2846,38 +3029,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - spanParentStruct != null -> visitor.visitSpanParentStruct(spanParentStruct) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + return when { + spanParentStruct != null -> visitor.visitSpanParentStruct(spanParentStruct) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Parent = apply { - if (validated) { - return@apply - } + fun validate(): Parent = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitSpanParentStruct(spanParentStruct: SpanParentStruct) { - spanParentStruct.validate() + spanParentStruct.validate() } - override fun visitString(string: String) {} - } - ) - validated = true - } + override fun visitString(string: String) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + } + }) + validated = true } - return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanParentStruct, string) /* spotless:on */ @@ -2894,14 +3078,17 @@ private constructor( /** Span parent properties */ @JvmStatic - fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = - Parent(spanParentStruct = spanParentStruct) + fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = Parent(spanParentStruct = spanParentStruct) /** The parent's span identifier, created by calling `.export()` on a span */ - @JvmStatic fun ofString(string: String) = Parent(string = string) + @JvmStatic + fun ofString(string: String) = Parent(string = string) } - /** An interface that defines how to map each variant of [Parent] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Parent] to a value of type + * [T]. + */ interface Visitor { /** Span parent properties */ @@ -2913,70 +3100,55 @@ private constructor( /** * Maps an unknown variant of [Parent] to a value of type [T]. * - * An instance of [Parent] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Parent] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Parent: $json") + throw BraintrustInvalidDataException("Unknown Parent: $json") } } internal class Deserializer : BaseDeserializer(Parent::class) { override fun ObjectCodec.deserialize(node: JsonNode): Parent { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Parent(spanParentStruct = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Parent(string = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Parent(spanParentStruct = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Parent(string = it, _json = json) + } - return Parent(_json = json) + return Parent(_json = json) } } internal class Serializer : BaseSerializer(Parent::class) { - override fun serialize( - value: Parent, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parent") - } + override fun serialize(value: Parent, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Parent") + } } } /** Span parent properties */ @NoAutoDetect - class SpanParentStruct - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("propagated_event") - @ExcludeMissing - private val propagatedEvent: JsonField = JsonMissing.of(), - @JsonProperty("row_ids") - @ExcludeMissing - private val rowIds: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class SpanParentStruct @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("propagated_event") @ExcludeMissing private val propagatedEvent: JsonField = JsonMissing.of(), + @JsonProperty("row_ids") @ExcludeMissing private val rowIds: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the container object you are logging to */ @@ -2985,14 +3157,15 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** Include these properties in every span created under this parent */ - fun propagatedEvent(): Optional = - Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) + fun propagatedEvent(): Optional = Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) /** Identifiers for the row to to log a subspan under */ fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) /** The id of the container object you are logging to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId @JsonProperty("object_type") @ExcludeMissing @@ -3004,7 +3177,9 @@ private constructor( fun _propagatedEvent(): JsonField = propagatedEvent /** Identifiers for the row to to log a subspan under */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField = rowIds + @JsonProperty("row_ids") + @ExcludeMissing + fun _rowIds(): JsonField = rowIds @JsonAnyGetter @ExcludeMissing @@ -3012,17 +3187,18 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanParentStruct = apply { - if (validated) { - return@apply - } + fun validate(): SpanParentStruct = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - propagatedEvent().ifPresent { it.validate() } - rowIds().ifPresent { it.validate() } - validated = true - } + objectId() + objectType() + propagatedEvent().ifPresent { it.validate() } + rowIds().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -3032,12 +3208,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [SpanParentStruct]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanParentStruct]. */ @@ -3050,38 +3228,42 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanParentStruct: SpanParentStruct) = apply { - objectId = spanParentStruct.objectId - objectType = spanParentStruct.objectType - propagatedEvent = spanParentStruct.propagatedEvent - rowIds = spanParentStruct.rowIds - additionalProperties = spanParentStruct.additionalProperties.toMutableMap() - } + internal fun from(spanParentStruct: SpanParentStruct) = + apply { + objectId = spanParentStruct.objectId + objectType = spanParentStruct.objectType + propagatedEvent = spanParentStruct.propagatedEvent + rowIds = spanParentStruct.rowIds + additionalProperties = spanParentStruct.additionalProperties.toMutableMap() + } /** The id of the container object you are logging to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the container object you are logging to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: PropagatedEvent?) = - propagatedEvent(JsonField.ofNullable(propagatedEvent)) + fun propagatedEvent(propagatedEvent: PropagatedEvent?) = propagatedEvent(JsonField.ofNullable(propagatedEvent)) /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: Optional) = - propagatedEvent(propagatedEvent.getOrNull()) + fun propagatedEvent(propagatedEvent: Optional) = propagatedEvent(propagatedEvent.getOrNull()) /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: JsonField) = apply { - this.propagatedEvent = propagatedEvent - } + fun propagatedEvent(propagatedEvent: JsonField) = + apply { + this.propagatedEvent = propagatedEvent + } /** Identifiers for the row to to log a subspan under */ fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) @@ -3090,43 +3272,55 @@ private constructor( fun rowIds(rowIds: Optional) = rowIds(rowIds.getOrNull()) /** Identifiers for the row to to log a subspan under */ - fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } + fun rowIds(rowIds: JsonField) = + apply { + this.rowIds = rowIds + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SpanParentStruct = SpanParentStruct( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - propagatedEvent, - rowIds, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + propagatedEvent, + rowIds, + additionalProperties.toImmutable(), ) } - class ObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class ObjectType @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -3136,7 +3330,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -3157,9 +3352,11 @@ private constructor( * 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 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 { @@ -3193,7 +3390,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3209,19 +3406,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3231,11 +3425,9 @@ private constructor( /** Include these properties in every span created under this parent */ @NoAutoDetect - class PropagatedEvent - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class PropagatedEvent @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -3244,22 +3436,22 @@ private constructor( private var validated: Boolean = false - fun validate(): PropagatedEvent = apply { - if (validated) { - return@apply - } + fun validate(): PropagatedEvent = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [PropagatedEvent]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [PropagatedEvent]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [PropagatedEvent]. */ @@ -3268,42 +3460,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(propagatedEvent: PropagatedEvent) = apply { - additionalProperties = propagatedEvent.additionalProperties.toMutableMap() - } + internal fun from(propagatedEvent: PropagatedEvent) = + apply { + additionalProperties = propagatedEvent.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): PropagatedEvent = - PropagatedEvent(additionalProperties.toImmutable()) + fun build(): PropagatedEvent = PropagatedEvent(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3312,26 +3508,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PropagatedEvent{additionalProperties=$additionalProperties}" + override fun toString() = "PropagatedEvent{additionalProperties=$additionalProperties}" } /** Identifiers for the row to to log a subspan under */ @NoAutoDetect - class RowIds - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RowIds @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the row */ @@ -3344,7 +3531,9 @@ private constructor( fun spanId(): String = spanId.getRequired("span_id") /** The id of the row */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** The root_span_id of the row */ @JsonProperty("root_span_id") @@ -3352,7 +3541,9 @@ private constructor( fun _rootSpanId(): JsonField = rootSpanId /** The span_id of the row */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId @JsonAnyGetter @ExcludeMissing @@ -3360,16 +3551,17 @@ private constructor( private var validated: Boolean = false - fun validate(): RowIds = apply { - if (validated) { - return@apply - } + fun validate(): RowIds = + apply { + if (validated) { + return@apply + } - id() - rootSpanId() - spanId() - validated = true - } + id() + rootSpanId() + spanId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3379,13 +3571,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [RowIds]. * * The following fields are required: + * * ```java * .id() * .rootSpanId() * .spanId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RowIds]. */ @@ -3397,70 +3591,88 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(rowIds: RowIds) = apply { - id = rowIds.id - rootSpanId = rowIds.rootSpanId - spanId = rowIds.spanId - additionalProperties = rowIds.additionalProperties.toMutableMap() - } + internal fun from(rowIds: RowIds) = + apply { + id = rowIds.id + rootSpanId = rowIds.rootSpanId + spanId = rowIds.spanId + additionalProperties = rowIds.additionalProperties.toMutableMap() + } /** The id of the row */ fun id(id: String) = id(JsonField.of(id)) /** The id of the row */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** The root_span_id of the row */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** The root_span_id of the row */ - fun rootSpanId(rootSpanId: JsonField) = apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** The span_id of the row */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** The span_id of the row */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RowIds = RowIds( - checkRequired("id", id), - checkRequired("rootSpanId", rootSpanId), - checkRequired("spanId", spanId), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "rootSpanId", rootSpanId + ), + checkRequired( + "spanId", spanId + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3469,16 +3681,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" + override fun toString() = "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3487,21 +3698,19 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionInvokeParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionInvokeParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 3320310c..721e7224 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -13,10 +13,9 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects @NoAutoDetect -class FunctionInvokeResponse -@JsonCreator -private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap() +class FunctionInvokeResponse @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -25,20 +24,25 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionInvokeResponse = apply { - if (validated) { - return@apply - } + fun validate(): FunctionInvokeResponse = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [FunctionInvokeResponse]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [FunctionInvokeResponse]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionInvokeResponse]. */ @@ -47,39 +51,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionInvokeResponse: FunctionInvokeResponse) = apply { - additionalProperties = functionInvokeResponse.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): FunctionInvokeResponse = - FunctionInvokeResponse(additionalProperties.toImmutable()) + internal fun from(functionInvokeResponse: FunctionInvokeResponse) = + apply { + additionalProperties = functionInvokeResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): FunctionInvokeResponse = FunctionInvokeResponse(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionInvokeResponse && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeResponse && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 1ed3037c..27c52924 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.FunctionService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all functions. The functions are sorted by creation date, with the most recently-created - * functions coming first + * List out all functions. The functions are sorted by creation date, with the most + * recently-created functions coming first */ -class FunctionListPage -private constructor( +class FunctionListPage private constructor( private val functionsService: FunctionService, private val params: FunctionListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListPage && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is FunctionListPage && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ - override fun toString() = - "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" + override fun toString() = "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - FunctionListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - FunctionListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { functionsService.list(it) } + return getNextPageParams().map { functionsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -84,16 +74,18 @@ private constructor( @JvmStatic fun of(functionsService: FunctionService, params: FunctionListParams, response: Response) = - FunctionListPage(functionsService, params, response) + FunctionListPage( + functionsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -107,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [FunctionListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -143,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: FunctionListPage) : Iterable { + class AutoPager( + private val firstPage: FunctionListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 4b4eebea..636c7970 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.FunctionServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all functions. The functions are sorted by creation date, with the most recently-created - * functions coming first + * List out all functions. The functions are sorted by creation date, with the most + * recently-created functions coming first */ -class FunctionListPageAsync -private constructor( +class FunctionListPageAsync private constructor( private val functionsService: FunctionServiceAsync, private val params: FunctionListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListPageAsync && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is FunctionListPageAsync && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ - override fun toString() = - "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" + override fun toString() = "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - FunctionListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - FunctionListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { functionsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + functionsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,20 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - functionsService: FunctionServiceAsync, - params: FunctionListParams, - response: Response, - ) = FunctionListPageAsync(functionsService, params, response) + fun of(functionsService: FunctionServiceAsync, params: FunctionListParams, response: Response) = + FunctionListPageAsync( + functionsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -112,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [FunctionListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -150,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: FunctionListPageAsync) { + class AutoPager( + private val firstPage: FunctionListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Function) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Function) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index aaf2b9ca..f40f98e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all functions. The functions are sorted by creation date, with the most recently-created - * functions coming first + * List out all functions. The functions are sorted by creation date, with the most + * recently-created functions coming first */ -class FunctionListParams -private constructor( +class FunctionListParams private constructor( private val endingBefore: String?, private val functionName: String?, private val ids: Ids?, @@ -40,14 +39,15 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -55,8 +55,8 @@ private constructor( fun functionName(): Optional = Optional.ofNullable(functionName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -78,17 +78,17 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ fun version(): Optional = Optional.ofNullable(version) @@ -99,29 +99,71 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.functionName?.let { queryParams.put("function_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.slug?.let { queryParams.put("slug", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.functionName?.let { + queryParams.put( + "function_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.slug?.let { + queryParams.put( + "slug", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): FunctionListParams = builder().build() + @JvmStatic + fun none(): FunctionListParams = builder().build() /** Returns a mutable builder for constructing an instance of [FunctionListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionListParams]. */ @@ -142,71 +184,84 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionListParams: FunctionListParams) = apply { - endingBefore = functionListParams.endingBefore - functionName = functionListParams.functionName - ids = functionListParams.ids - limit = functionListParams.limit - orgName = functionListParams.orgName - projectId = functionListParams.projectId - projectName = functionListParams.projectName - slug = functionListParams.slug - startingAfter = functionListParams.startingAfter - version = functionListParams.version - additionalHeaders = functionListParams.additionalHeaders.toBuilder() - additionalQueryParams = functionListParams.additionalQueryParams.toBuilder() - } + internal fun from(functionListParams: FunctionListParams) = + apply { + endingBefore = functionListParams.endingBefore + functionName = functionListParams.functionName + ids = functionListParams.ids + limit = functionListParams.limit + orgName = functionListParams.orgName + projectId = functionListParams.projectId + projectName = functionListParams.projectName + slug = functionListParams.slug + startingAfter = functionListParams.startingAfter + version = functionListParams.version + additionalHeaders = functionListParams.additionalHeaders.toBuilder() + additionalQueryParams = functionListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the function to search for */ - fun functionName(functionName: String?) = apply { this.functionName = functionName } + fun functionName(functionName: String?) = + apply { + this.functionName = functionName + } /** Name of the function to search for */ fun functionName(functionName: Optional) = functionName(functionName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -215,25 +270,37 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Retrieve prompt with a specific slug */ - fun slug(slug: String?) = apply { this.slug = slug } + fun slug(slug: String?) = + apply { + this.slug = slug + } /** Retrieve prompt with a specific slug */ fun slug(slug: Optional) = slug(slug.getOrNull()) @@ -241,164 +308,195 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionListParams = FunctionListParams( - endingBefore, - functionName, - ids, - limit, - orgName, - projectId, - projectName, - slug, - startingAfter, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + functionName, + ids, + limit, + orgName, + projectId, + projectName, + slug, + startingAfter, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -416,19 +514,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -443,12 +541,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -458,60 +561,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 bd9be34c..ce2d221b 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 @@ -36,14 +36,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace function. If there is an existing function in the project with the same slug as - * the one specified in the request, will replace the existing function with the provided fields + * Create or replace function. If there is an existing function in the project with + * the same slug as the one specified in the request, will replace the existing + * function with the provided fields */ -class FunctionReplaceParams -private constructor( +class FunctionReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { fun functionData(): FunctionData = body.functionData() @@ -106,48 +107,27 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("function_data") - @ExcludeMissing - private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") - @ExcludeMissing - private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun functionData(): FunctionData = functionData.getRequired("function_data") @@ -162,21 +142,17 @@ private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = - Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -186,13 +162,19 @@ private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -208,7 +190,9 @@ private constructor( @ExcludeMissing fun _functionType(): JsonField = functionType - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -216,7 +200,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -224,23 +210,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } - - functionData().validate() - name() - projectId() - slug() - description() - functionSchema().ifPresent { it.validate() } - functionType() - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + functionData().validate() + name() + projectId() + slug() + description() + functionSchema().ifPresent { it.validate() } + functionType() + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -250,6 +237,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .functionData() * .name() @@ -257,7 +245,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -276,51 +265,60 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - functionData = body.functionData - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionSchema = body.functionSchema - functionType = body.functionType - origin = body.origin - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + functionData = body.functionData + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionSchema = body.functionSchema + functionType = body.functionType + origin = body.origin + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = + apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = - functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = - functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -329,38 +327,40 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = - functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = + apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -369,9 +369,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -380,57 +381,75 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("functionData", functionData), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - description, - functionSchema, - functionType, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "functionData", functionData + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + description, + functionSchema, + functionType, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -439,8 +458,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -448,9 +466,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionReplaceParams]. * * The following fields are required: + * * ```java * .functionData() * .name() @@ -458,7 +478,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionReplaceParams]. */ @@ -470,234 +491,331 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionReplaceParams: FunctionReplaceParams) = apply { - body = functionReplaceParams.body.toBuilder() - additionalHeaders = functionReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = functionReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(functionReplaceParams: FunctionReplaceParams) = + apply { + body = functionReplaceParams.body.toBuilder() + additionalHeaders = functionReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = functionReplaceParams.additionalQueryParams.toBuilder() + } - fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + fun functionData(functionData: FunctionData) = + apply { + body.functionData(functionData) + } - fun functionData(functionData: JsonField) = apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = + apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + fun functionData(prompt: FunctionData.Prompt) = + apply { + body.functionData(prompt) + } - fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + fun functionData(code: FunctionData.Code) = + apply { + body.functionData(code) + } - fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + fun functionData(global: FunctionData.Global) = + apply { + body.functionData(global) + } /** Name of the prompt */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { body.slug(slug) } + fun slug(slug: String) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: FunctionSchema?) = + apply { + body.functionSchema(functionSchema) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = - functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: JsonField) = + apply { + body.functionSchema(functionSchema) + } - fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + fun functionType(functionType: FunctionType?) = + apply { + body.functionType(functionType) + } - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = + apply { + body.functionType(functionType) + } - fun origin(origin: Origin?) = apply { body.origin(origin) } + fun origin(origin: Origin?) = + apply { + body.origin(origin) + } fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { body.origin(origin) } + fun origin(origin: JsonField) = + apply { + body.origin(origin) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionReplaceParams = FunctionReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( + class FunctionData private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -721,45 +839,44 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -775,16 +892,19 @@ private constructor( companion object { - @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic + fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic + fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic + fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value of type - * [T]. + * An interface that defines how to map each variant of [FunctionData] to a value + * of type [T]. */ interface Visitor { @@ -797,71 +917,62 @@ private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize( - value: FunctionData, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Prompt @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -869,14 +980,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -886,11 +998,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -900,43 +1014,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt(checkRequired("type", type), additionalProperties.toImmutable()) + Prompt( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -946,7 +1074,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -957,23 +1086,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT + PROMPT, } /** * 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 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 { PROMPT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -997,7 +1126,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1012,19 +1141,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1033,11 +1159,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1046,31 +1172,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code - @JsonCreator - private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Code @JsonCreator private constructor( + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1078,15 +1201,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Code = apply { - if (validated) { - return@apply - } + fun validate(): Code = + apply { + if (validated) { + return@apply + } - data().validate() - type() - validated = true - } + data().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1096,12 +1220,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: + * * ```java * .data() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Code]. */ @@ -1112,15 +1238,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = + apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -1128,45 +1258,56 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, + ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1184,40 +1325,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1232,9 +1372,11 @@ private constructor( companion object { - @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic + fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic + fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1250,86 +1392,65 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle - @JsonCreator - private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = - JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Bundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = - Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1350,7 +1471,9 @@ private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1366,18 +1489,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Bundle = apply { - if (validated) { - return@apply - } + fun validate(): Bundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1387,6 +1511,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() @@ -1394,7 +1519,8 @@ private constructor( * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1405,40 +1531,38 @@ private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = + apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = - location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = + apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = - location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = - location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1452,11 +1576,17 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1464,44 +1594,57 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -1515,25 +1658,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE + BUNDLE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { BUNDLE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1541,8 +1682,8 @@ private constructor( * 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. + * 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) { @@ -1553,11 +1694,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1568,23 +1709,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1593,11 +1731,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1606,41 +1744,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Inline @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1648,16 +1780,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Inline = apply { - if (validated) { - return@apply - } + fun validate(): Inline = + apply { + if (validated) { + return@apply + } - code() - runtimeContext().validate() - type() - validated = true - } + code() + runtimeContext().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1667,13 +1800,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: + * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1682,31 +1817,37 @@ private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = + apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1714,44 +1855,47 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired("code", code), - checkRequired("runtimeContext", runtimeContext), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "runtimeContext", runtimeContext + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1772,31 +1916,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RuntimeContext]. + * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1804,28 +1950,29 @@ private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = - runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = + apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1833,41 +1980,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @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. + * 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 @@ -1888,33 +2044,29 @@ private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] 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. * - * An instance of [Runtime] 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 { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Runtime] 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. + * 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. + * 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) { @@ -1926,42 +2078,36 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown Runtime: $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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1970,11 +2116,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1983,21 +2129,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -2011,25 +2157,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE + INLINE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { INLINE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2037,8 +2181,8 @@ private constructor( * 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. + * 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) { @@ -2049,11 +2193,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2064,23 +2208,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2089,11 +2230,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2102,13 +2243,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2118,7 +2260,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2129,23 +2272,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE + CODE, } /** * 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 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 { CODE, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2169,7 +2312,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2184,19 +2327,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2205,11 +2345,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2218,31 +2358,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2250,15 +2387,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2268,12 +2406,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -2284,52 +2424,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2339,7 +2496,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2350,23 +2508,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * 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 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 { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2390,7 +2548,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2405,19 +2563,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2426,11 +2581,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2439,27 +2594,26 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema @JsonCreator private constructor( + @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonValue = parameters - @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns + @JsonProperty("returns") + @ExcludeMissing + fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2467,20 +2621,22 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = apply { - if (validated) { - return@apply - } + fun validate(): FunctionSchema = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2491,45 +2647,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = + apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } + fun parameters(parameters: JsonValue) = + apply { + this.parameters = parameters + } - fun returns(returns: JsonValue) = apply { this.returns = returns } + fun returns(returns: JsonValue) = + apply { + this.returns = returns + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema(parameters, returns, additionalProperties.toImmutable()) + FunctionSchema( + parameters, + returns, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2538,22 +2712,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2577,12 +2753,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] 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 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 { @@ -2591,17 +2770,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -2615,11 +2795,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2633,23 +2813,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2658,20 +2835,12 @@ private constructor( } @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") - @ExcludeMissing - private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Origin @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Id of the object the function is originating from */ @@ -2681,13 +2850,15 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2695,10 +2866,12 @@ private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ + @JsonProperty("internal") + @ExcludeMissing + fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2706,16 +2879,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - internal_() - validated = true - } + objectId() + objectType() + internal_() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2725,12 +2899,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2742,92 +2918,114 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * The function exists for internal purposes and should not be displayed in the + * list of functions. */ - fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } + fun internal_(internal_: JsonField) = + apply { + this.internal_ = internal_ + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - internal_, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2875,9 +3073,11 @@ private constructor( * 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 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 { @@ -2903,8 +3103,8 @@ private constructor( * 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. + * 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) { @@ -2929,7 +3129,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2953,20 +3153,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2975,11 +3172,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2988,20 +3185,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index a1ec37a0..f0fc93e6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a function object by its id */ -class FunctionRetrieveParams -private constructor( +class FunctionRetrieveParams private constructor( private val functionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Function id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionRetrieveParams]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionRetrieveParams: FunctionRetrieveParams) = apply { - functionId = functionRetrieveParams.functionId - additionalHeaders = functionRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = functionRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(functionRetrieveParams: FunctionRetrieveParams) = + apply { + functionId = functionRetrieveParams.functionId + additionalHeaders = functionRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = functionRetrieveParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = + apply { + this.functionId = functionId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionRetrieveParams = FunctionRetrieveParams( - checkRequired("functionId", functionId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "functionId", functionId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 1f55b477..ead95502 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -36,16 +36,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a function object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a function object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class FunctionUpdateParams -private constructor( +class FunctionUpdateParams private constructor( private val functionId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Function id */ @@ -85,55 +85,41 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_data") - @ExcludeMissing - private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun functionData(): Optional = - Optional.ofNullable(functionData.getNullable("function_data")) + fun functionData(): Optional = Optional.ofNullable(functionData.getNullable("function_data")) /** Name of the prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -148,7 +134,9 @@ private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -156,7 +144,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -164,25 +154,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - description() - functionData().ifPresent { it.validate() } - name() - promptData().ifPresent { it.validate() } - tags() - validated = true - } + description() + functionData().ifPresent { it.validate() } + name() + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -196,14 +188,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - description = body.description - functionData = body.functionData - name = body.name - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + description = body.description + functionData = body.functionData + name = body.name + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -212,26 +205,25 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = + apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = - functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = - functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) - fun functionData(nullableVariant: FunctionData.NullableVariant) = - functionData(FunctionData.ofNullableVariant(nullableVariant)) + fun functionData(nullableVariant: FunctionData.NullableVariant) = functionData(FunctionData.ofNullableVariant(nullableVariant)) /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -240,7 +232,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -249,9 +244,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -260,52 +256,62 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - description, - functionData, - name, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + description, + functionData, + name, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -314,8 +320,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -323,14 +328,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [FunctionUpdateParams]. * * The following fields are required: + * * ```java * .functionId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionUpdateParams]. */ @@ -343,206 +351,287 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionUpdateParams: FunctionUpdateParams) = apply { - functionId = functionUpdateParams.functionId - body = functionUpdateParams.body.toBuilder() - additionalHeaders = functionUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = functionUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(functionUpdateParams: FunctionUpdateParams) = + apply { + functionId = functionUpdateParams.functionId + body = functionUpdateParams.body.toBuilder() + additionalHeaders = functionUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = functionUpdateParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = + apply { + this.functionId = functionId + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + fun functionData(functionData: FunctionData) = + apply { + body.functionData(functionData) + } - fun functionData(functionData: JsonField) = apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = + apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + fun functionData(prompt: FunctionData.Prompt) = + apply { + body.functionData(prompt) + } - fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + fun functionData(code: FunctionData.Code) = + apply { + body.functionData(code) + } - fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } + fun functionData(global: FunctionData.Global) = + apply { + body.functionData(global) + } - fun functionData(nullableVariant: FunctionData.NullableVariant) = apply { - body.functionData(nullableVariant) - } + fun functionData(nullableVariant: FunctionData.NullableVariant) = + apply { + body.functionData(nullableVariant) + } /** Name of the prompt */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the prompt */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionUpdateParams = FunctionUpdateParams( - checkRequired("functionId", functionId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "functionId", functionId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( + class FunctionData private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -572,50 +661,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global, nullableVariant) /* spotless:on */ @@ -632,20 +720,22 @@ private constructor( companion object { - @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic + fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic + fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic + fun ofGlobal(global: Global) = FunctionData(global = global) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - FunctionData(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = FunctionData(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [FunctionData] to a value of type - * [T]. + * An interface that defines how to map each variant of [FunctionData] to a value + * of type [T]. */ interface Visitor { @@ -660,76 +750,66 @@ private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(global = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(nullableVariant = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(global = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionData(nullableVariant = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize( - value: FunctionData, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Prompt @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -737,14 +817,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -754,11 +835,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -768,43 +851,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt(checkRequired("type", type), additionalProperties.toImmutable()) + Prompt( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -814,7 +911,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -825,23 +923,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT + PROMPT, } /** * 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 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 { PROMPT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -865,7 +963,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -880,19 +978,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -901,11 +996,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -914,31 +1009,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code - @JsonCreator - private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Code @JsonCreator private constructor( + @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -946,15 +1038,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Code = apply { - if (validated) { - return@apply - } + fun validate(): Code = + apply { + if (validated) { + return@apply + } - data().validate() - type() - validated = true - } + data().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -964,12 +1057,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: + * * ```java * .data() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Code]. */ @@ -980,15 +1075,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = + apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = + apply { + this.data = data + } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -996,45 +1095,56 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "data", data + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( + class Data private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, + ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1052,40 +1162,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = apply { - if (validated) { - return@apply - } + fun validate(): Data = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() - } - - override fun visitInline(inline: Inline) { - inline.validate() + bundle.validate() } - } - ) - validated = true - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun visitInline(inline: Inline) { + inline.validate() + } + }) + validated = true } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1100,9 +1209,11 @@ private constructor( companion object { - @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic + fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic + fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1118,86 +1229,65 @@ private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize( - value: Data, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle - @JsonCreator - private constructor( - @JsonProperty("bundle_id") - @ExcludeMissing - private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = - JsonMissing.of(), - @JsonProperty("preview") - @ExcludeMissing - private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Bundle @JsonCreator private constructor( + @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = - Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1218,7 +1308,9 @@ private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1234,18 +1326,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Bundle = apply { - if (validated) { - return@apply - } + fun validate(): Bundle = + apply { + if (validated) { + return@apply + } - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true - } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1255,6 +1348,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: + * * ```java * .bundleId() * .location() @@ -1262,7 +1356,8 @@ private constructor( * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1273,40 +1368,38 @@ private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = + apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = + apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = - location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = location(JsonField.of(location)) - fun location(location: JsonField) = apply { - this.location = location - } + fun location(location: JsonField) = + apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = - location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = - location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1320,11 +1413,17 @@ private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = + apply { + this.preview = preview + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1332,44 +1431,57 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired("bundleId", bundleId), - checkRequired("location", location), - checkRequired("runtimeContext", runtimeContext), - preview, - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "bundleId", bundleId + ), + checkRequired( + "location", location + ), + checkRequired( + "runtimeContext", runtimeContext + ), + preview, + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -1383,25 +1495,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE + BUNDLE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { BUNDLE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1409,8 +1519,8 @@ private constructor( * 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. + * 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) { @@ -1421,11 +1531,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1436,23 +1546,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1461,11 +1568,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1474,41 +1581,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline - @JsonCreator - private constructor( - @JsonProperty("code") - @ExcludeMissing - private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") - @ExcludeMissing - private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Inline @JsonCreator private constructor( + @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + @JsonProperty("code") + @ExcludeMissing + fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1516,16 +1617,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Inline = apply { - if (validated) { - return@apply - } + fun validate(): Inline = + apply { + if (validated) { + return@apply + } - code() - runtimeContext().validate() - type() - validated = true - } + code() + runtimeContext().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1535,13 +1637,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: + * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1550,31 +1654,37 @@ private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = + apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = + apply { + this.code = code + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = + apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1582,44 +1692,47 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired("code", code), - checkRequired("runtimeContext", runtimeContext), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "code", code + ), + checkRequired( + "runtimeContext", runtimeContext + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext - @JsonCreator - private constructor( - @JsonProperty("runtime") - @ExcludeMissing - private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class RuntimeContext @JsonCreator private constructor( + @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1640,31 +1753,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = apply { - if (validated) { - return@apply - } + fun validate(): RuntimeContext = + apply { + if (validated) { + return@apply + } - runtime() - version() - validated = true - } + runtime() + version() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RuntimeContext]. + * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: + * * ```java * .runtime() * .version() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1672,28 +1787,29 @@ private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = - runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = + apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = + apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = apply { - this.version = version - } + fun version(version: JsonField) = + apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1701,41 +1817,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired("runtime", runtime), - checkRequired("version", version), - additionalProperties.toImmutable(), + checkRequired( + "runtime", runtime + ), + checkRequired( + "version", version + ), + additionalProperties.toImmutable(), ) } - class Runtime - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Runtime @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. + * 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 @@ -1756,33 +1881,29 @@ private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Runtime] 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. * - * An instance of [Runtime] 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 { NODE, PYTHON, - /** - * An enum member indicating that [Runtime] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Runtime] 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. + * 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. + * 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) { @@ -1794,42 +1915,36 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) + else -> throw BraintrustInvalidDataException("Unknown Runtime: $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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1838,11 +1953,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1851,21 +1966,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -1879,25 +1994,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE + INLINE, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { INLINE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1905,8 +2018,8 @@ private constructor( * 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. + * 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) { @@ -1917,11 +2030,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1932,23 +2045,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1957,11 +2067,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1970,13 +2080,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -1986,7 +2097,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1997,23 +2109,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE + CODE, } /** * 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 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 { CODE, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2037,7 +2149,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2052,19 +2164,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2073,11 +2182,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2086,31 +2195,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2118,15 +2224,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2136,12 +2243,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -2152,52 +2261,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -2207,7 +2333,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -2218,23 +2345,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * 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 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 { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2258,7 +2385,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2273,19 +2400,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2294,11 +2418,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2307,16 +2431,13 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -2325,20 +2446,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -2347,41 +2470,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2395,15 +2523,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "FunctionUpdateParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "FunctionUpdateParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 2dc72265..c7fbe0c4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -23,34 +23,22 @@ import kotlin.jvm.optionals.getOrNull /** * A group is a collection of users which can be assigned an ACL * - * Groups can consist of individual users, as well as a set of groups they inherit from + * Groups can consist of individual users, as well as a set of groups they inherit + * from */ @NoAutoDetect -class Group -@JsonCreator -private constructor( +class Group @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") - @ExcludeMissing - private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") - @ExcludeMissing - private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the group */ @@ -70,44 +58,48 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(): Optional> = - Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = - Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) /** Identifies the user who created the group */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the group */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** * Unique id for the organization that the group belongs under * * It is forbidden to change the org after creating a group */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Date of group creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of group deletion, or null if the group is still active */ @JsonProperty("deleted_at") @@ -115,13 +107,15 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the group */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -133,7 +127,9 @@ private constructor( fun _memberUsers(): JsonField> = memberUsers /** Identifies the user who created the group */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -141,23 +137,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Group = apply { - if (validated) { - return@apply + fun validate(): Group = + apply { + if (validated) { + return@apply + } + + id() + name() + orgId() + created() + deletedAt() + description() + memberGroups() + memberUsers() + userId() + validated = true } - id() - name() - orgId() - created() - deletedAt() - description() - memberGroups() - memberUsers() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -166,13 +163,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Group]. * * The following fields are required: + * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Group]. */ @@ -190,30 +189,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(group: Group) = apply { - id = group.id - name = group.name - orgId = group.orgId - created = group.created - deletedAt = group.deletedAt - description = group.description - memberGroups = group.memberGroups.map { it.toMutableList() } - memberUsers = group.memberUsers.map { it.toMutableList() } - userId = group.userId - additionalProperties = group.additionalProperties.toMutableMap() - } + internal fun from(group: Group) = + apply { + id = group.id + name = group.name + orgId = group.orgId + created = group.created + deletedAt = group.deletedAt + description = group.description + memberGroups = group.memberGroups.map { it.toMutableList() } + memberUsers = group.memberUsers.map { it.toMutableList() } + userId = group.userId + additionalProperties = group.additionalProperties.toMutableMap() + } /** Unique identifier for the group */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the group */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** * Unique id for the organization that the group belongs under @@ -227,7 +233,10 @@ private constructor( * * It is forbidden to change the org after creating a group */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Date of group creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -236,7 +245,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of group creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of group deletion, or null if the group is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -245,7 +257,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -254,48 +269,50 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = - memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = + apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { - memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = + apply { + memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) @@ -304,17 +321,18 @@ private constructor( fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = + apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { - memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = + apply { + memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** Identifies the user who created the group */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -323,48 +341,64 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the group */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Group = Group( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("orgId", orgId), - created, - deletedAt, - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + created, + deletedAt, + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Group && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Group && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -373,6 +407,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Group{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Group{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 492a36c7..18dcc927 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -23,14 +23,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new group. If there is an existing group with the same name as the one specified in the - * request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one + * specified in the request, will return the existing group unmodified */ -class GroupCreateParams -private constructor( +class GroupCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the group */ @@ -42,8 +42,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ fun memberGroups(): Optional> = body.memberGroups() @@ -51,9 +51,9 @@ private constructor( fun memberUsers(): Optional> = body.memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(): Optional = body.orgName() @@ -66,8 +66,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ fun _memberGroups(): JsonField> = body._memberGroups() @@ -75,9 +75,9 @@ private constructor( fun _memberUsers(): JsonField> = body._memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -87,64 +87,52 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") - @ExcludeMissing - private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") - @ExcludeMissing - private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the group */ fun name(): String = name.getRequired("name") /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(): Optional> = - Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = - Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Textual description of the group */ @JsonProperty("description") @@ -154,8 +142,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -167,11 +155,13 @@ private constructor( fun _memberUsers(): JsonField> = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -179,19 +169,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + description() + memberGroups() + memberUsers() + orgName() + validated = true } - name() - description() - memberGroups() - memberUsers() - orgName() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -200,11 +191,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -218,20 +211,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - description = body.description - memberGroups = body.memberGroups.map { it.toMutableList() } - memberUsers = body.memberUsers.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + description = body.description + memberGroups = body.memberGroups.map { it.toMutableList() } + memberUsers = body.memberUsers.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -240,129 +237,140 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = - memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = + apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { - memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = + apply { + memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = - memberUsers(JsonField.ofNullable(memberUsers)) + fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = - memberUsers(memberUsers.getOrNull()) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = + apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { - memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = + apply { + memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -371,8 +379,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -383,11 +390,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupCreateParams]. */ @@ -399,232 +408,297 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupCreateParams: GroupCreateParams) = apply { - body = groupCreateParams.body.toBuilder() - additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(groupCreateParams: GroupCreateParams) = + apply { + body = groupCreateParams.body.toBuilder() + additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() + } /** Name of the group */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the group */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Textual description of the group */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + fun memberGroups(memberGroups: List?) = + apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - body.memberGroups(memberGroups) - } + fun memberGroups(memberGroups: JsonField>) = + apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } + fun addMemberGroup(memberGroup: String) = + apply { + body.addMemberGroup(memberGroup) + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } + fun memberUsers(memberUsers: List?) = + apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - body.memberUsers(memberUsers) - } + fun memberUsers(memberUsers: JsonField>) = + apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } + fun addMemberUser(memberUser: String) = + apply { + body.addMemberUser(memberUser) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupCreateParams = GroupCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 52f95360..4f981e03 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a group object by its id */ -class GroupDeleteParams -private constructor( +class GroupDeleteParams private constructor( private val groupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Group id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupDeleteParams]. * * The following fields are required: + * * ```java * .groupId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupDeleteParams: GroupDeleteParams) = apply { - groupId = groupDeleteParams.groupId - additionalHeaders = groupDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = groupDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = groupDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(groupDeleteParams: GroupDeleteParams) = + apply { + groupId = groupDeleteParams.groupId + additionalHeaders = groupDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = groupDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = groupDeleteParams.additionalBodyProperties.toMutableMap() + } /** Group id */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = + apply { + this.groupId = groupId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): GroupDeleteParams = GroupDeleteParams( - checkRequired("groupId", groupId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "groupId", groupId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index b0123cdf..3b871286 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.GroupService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ -class GroupListPage -private constructor( +class GroupListPage private constructor( private val groupsService: GroupService, private val params: GroupListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListPage && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is GroupListPage && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ - override fun toString() = - "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" + override fun toString() = "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(GroupListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(GroupListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { groupsService.list(it) } + return getNextPageParams().map { groupsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(groupsService: GroupService, params: GroupListParams, response: Response) = - GroupListPage(groupsService, params, response) + GroupListPage( + groupsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [GroupListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: GroupListPage) : Iterable { + class AutoPager( + private val firstPage: GroupListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index 5a17d75a..3f84e56e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.GroupServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ -class GroupListPageAsync -private constructor( +class GroupListPageAsync private constructor( private val groupsService: GroupServiceAsync, private val params: GroupListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListPageAsync && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is GroupListPageAsync && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ - override fun toString() = - "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" + override fun toString() = "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(GroupListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(GroupListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { groupsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + groupsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(groupsService: GroupServiceAsync, params: GroupListParams, response: Response) = - GroupListPageAsync(groupsService, params, response) + GroupListPageAsync( + groupsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [GroupListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: GroupListPageAsync) { + class AutoPager( + private val firstPage: GroupListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Group) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Group) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index d63abcd7..df044bad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ -class GroupListParams -private constructor( +class GroupListParams private constructor( private val endingBefore: String?, private val groupName: String?, private val ids: Ids?, @@ -36,14 +35,15 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -51,8 +51,8 @@ private constructor( fun groupName(): Optional = Optional.ofNullable(groupName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,51 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.groupName?.let { queryParams.put("group_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.groupName?.let { + queryParams.put( + "group_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): GroupListParams = builder().build() + @JvmStatic + fun none(): GroupListParams = builder().build() /** Returns a mutable builder for constructing an instance of [GroupListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupListParams]. */ @@ -113,67 +139,80 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupListParams: GroupListParams) = apply { - endingBefore = groupListParams.endingBefore - groupName = groupListParams.groupName - ids = groupListParams.ids - limit = groupListParams.limit - orgName = groupListParams.orgName - startingAfter = groupListParams.startingAfter - additionalHeaders = groupListParams.additionalHeaders.toBuilder() - additionalQueryParams = groupListParams.additionalQueryParams.toBuilder() - } + internal fun from(groupListParams: GroupListParams) = + apply { + endingBefore = groupListParams.endingBefore + groupName = groupListParams.groupName + ids = groupListParams.ids + limit = groupListParams.limit + orgName = groupListParams.orgName + startingAfter = groupListParams.startingAfter + additionalHeaders = groupListParams.additionalHeaders.toBuilder() + additionalQueryParams = groupListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the group to search for */ - fun groupName(groupName: String?) = apply { this.groupName = groupName } + fun groupName(groupName: String?) = + apply { + this.groupName = groupName + } /** Name of the group to search for */ fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -182,7 +221,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -190,144 +232,172 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupListParams = GroupListParams( - endingBefore, - groupName, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + groupName, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -345,19 +415,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -372,12 +442,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -387,60 +462,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index add7d123..1a856148 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -23,14 +23,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace group. If there is an existing group with the same name as the one specified in - * the request, will replace the existing group with the provided fields + * Create or replace group. If there is an existing group with the same name as the + * one specified in the request, will replace the existing group with the provided + * fields */ -class GroupReplaceParams -private constructor( +class GroupReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the group */ @@ -42,8 +43,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ fun memberGroups(): Optional> = body.memberGroups() @@ -51,9 +52,9 @@ private constructor( fun memberUsers(): Optional> = body.memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(): Optional = body.orgName() @@ -66,8 +67,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ fun _memberGroups(): JsonField> = body._memberGroups() @@ -75,9 +76,9 @@ private constructor( fun _memberUsers(): JsonField> = body._memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -87,64 +88,52 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") - @ExcludeMissing - private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") - @ExcludeMissing - private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the group */ fun name(): String = name.getRequired("name") /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(): Optional> = - Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = - Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Textual description of the group */ @JsonProperty("description") @@ -154,8 +143,8 @@ private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -167,11 +156,13 @@ private constructor( fun _memberUsers(): JsonField> = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -179,19 +170,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + description() + memberGroups() + memberUsers() + orgName() + validated = true } - name() - description() - memberGroups() - memberUsers() - orgName() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -200,11 +192,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -218,20 +212,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - description = body.description - memberGroups = body.memberGroups.map { it.toMutableList() } - memberUsers = body.memberUsers.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + description = body.description + memberGroups = body.memberGroups.map { it.toMutableList() } + memberUsers = body.memberUsers.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -240,129 +238,140 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = - memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = + apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { - memberGroups = - (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = + apply { + memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = - memberUsers(JsonField.ofNullable(memberUsers)) + fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = - memberUsers(memberUsers.getOrNull()) + fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = + apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { - memberUsers = - (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = + apply { + memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -371,8 +380,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -383,11 +391,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupReplaceParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupReplaceParams]. */ @@ -399,232 +409,297 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupReplaceParams: GroupReplaceParams) = apply { - body = groupReplaceParams.body.toBuilder() - additionalHeaders = groupReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = groupReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(groupReplaceParams: GroupReplaceParams) = + apply { + body = groupReplaceParams.body.toBuilder() + additionalHeaders = groupReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = groupReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the group */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the group */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Textual description of the group */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + fun memberGroups(memberGroups: List?) = + apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: Optional>) = - memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = apply { - body.memberGroups(memberGroups) - } + fun memberGroups(memberGroups: JsonField>) = + apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * An inheriting group has all the users contained in its member groups, as well as + * all of their inherited users */ - fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } + fun addMemberGroup(memberGroup: String) = + apply { + body.addMemberGroup(memberGroup) + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } + fun memberUsers(memberUsers: List?) = + apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = apply { - body.memberUsers(memberUsers) - } + fun memberUsers(memberUsers: JsonField>) = + apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } + fun addMemberUser(memberUser: String) = + apply { + body.addMemberUser(memberUser) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the group belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupReplaceParams = GroupReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index a3aece35..9430bc01 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a group object by its id */ -class GroupRetrieveParams -private constructor( +class GroupRetrieveParams private constructor( private val groupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Group id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,11 +43,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupRetrieveParams]. * * The following fields are required: + * * ```java * .groupId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupRetrieveParams]. */ @@ -59,131 +61,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupRetrieveParams: GroupRetrieveParams) = apply { - groupId = groupRetrieveParams.groupId - additionalHeaders = groupRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = groupRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(groupRetrieveParams: GroupRetrieveParams) = + apply { + groupId = groupRetrieveParams.groupId + additionalHeaders = groupRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = groupRetrieveParams.additionalQueryParams.toBuilder() + } /** Group id */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = + apply { + this.groupId = groupId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupRetrieveParams = GroupRetrieveParams( - checkRequired("groupId", groupId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "groupId", groupId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 5945b26a..20c8cdf6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -23,16 +23,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a group object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class GroupUpdateParams -private constructor( +class GroupUpdateParams private constructor( private val groupId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Group id */ @@ -80,67 +80,49 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("add_member_groups") - @ExcludeMissing - private val addMemberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("add_member_users") - @ExcludeMissing - private val addMemberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("remove_member_groups") - @ExcludeMissing - private val removeMemberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("remove_member_users") - @ExcludeMissing - private val removeMemberUsers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("add_member_groups") @ExcludeMissing private val addMemberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("add_member_users") @ExcludeMissing private val addMemberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("remove_member_groups") @ExcludeMissing private val removeMemberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("remove_member_users") @ExcludeMissing private val removeMemberUsers: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(): Optional> = - Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) + fun addMemberGroups(): Optional> = Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) /** A list of user IDs to add to the group */ - fun addMemberUsers(): Optional> = - Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) + fun addMemberUsers(): Optional> = Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) /** Textual description of the group */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the group */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(): Optional> = - Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) + fun removeMemberGroups(): Optional> = Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(): Optional> = - Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) + fun removeMemberUsers(): Optional> = Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) /** A list of group IDs to add to the group's inheriting-from set */ @JsonProperty("add_member_groups") @@ -158,7 +140,9 @@ private constructor( fun _description(): JsonField = description /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** A list of group IDs to remove from the group's inheriting-from set */ @JsonProperty("remove_member_groups") @@ -176,26 +160,28 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + addMemberGroups() + addMemberUsers() + description() + name() + removeMemberGroups() + removeMemberUsers() + validated = true } - addMemberGroups() - addMemberUsers() - description() - name() - removeMemberGroups() - removeMemberUsers() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -210,57 +196,56 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - addMemberGroups = body.addMemberGroups.map { it.toMutableList() } - addMemberUsers = body.addMemberUsers.map { it.toMutableList() } - description = body.description - name = body.name - removeMemberGroups = body.removeMemberGroups.map { it.toMutableList() } - removeMemberUsers = body.removeMemberUsers.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + addMemberGroups = body.addMemberGroups.map { it.toMutableList() } + addMemberUsers = body.addMemberUsers.map { it.toMutableList() } + description = body.description + name = body.name + removeMemberGroups = body.removeMemberGroups.map { it.toMutableList() } + removeMemberUsers = body.removeMemberUsers.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: List?) = - addMemberGroups(JsonField.ofNullable(addMemberGroups)) + fun addMemberGroups(addMemberGroups: List?) = addMemberGroups(JsonField.ofNullable(addMemberGroups)) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: Optional>) = - addMemberGroups(addMemberGroups.getOrNull()) + fun addMemberGroups(addMemberGroups: Optional>) = addMemberGroups(addMemberGroups.getOrNull()) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: JsonField>) = apply { - this.addMemberGroups = addMemberGroups.map { it.toMutableList() } - } + fun addMemberGroups(addMemberGroups: JsonField>) = + apply { + this.addMemberGroups = addMemberGroups.map { it.toMutableList() } + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addAddMemberGroup(addMemberGroup: String) = apply { - addMemberGroups = - (addMemberGroups ?: JsonField.of(mutableListOf())).also { + fun addAddMemberGroup(addMemberGroup: String) = + apply { + addMemberGroups = (addMemberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberGroups", it).add(addMemberGroup) } - } + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: List?) = - addMemberUsers(JsonField.ofNullable(addMemberUsers)) + fun addMemberUsers(addMemberUsers: List?) = addMemberUsers(JsonField.ofNullable(addMemberUsers)) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: Optional>) = - addMemberUsers(addMemberUsers.getOrNull()) + fun addMemberUsers(addMemberUsers: Optional>) = addMemberUsers(addMemberUsers.getOrNull()) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: JsonField>) = apply { - this.addMemberUsers = addMemberUsers.map { it.toMutableList() } - } + fun addMemberUsers(addMemberUsers: JsonField>) = + apply { + this.addMemberUsers = addMemberUsers.map { it.toMutableList() } + } /** A list of user IDs to add to the group */ - fun addAddMemberUser(addMemberUser: String) = apply { - addMemberUsers = - (addMemberUsers ?: JsonField.of(mutableListOf())).also { + fun addAddMemberUser(addMemberUser: String) = + apply { + addMemberUsers = (addMemberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberUsers", it).add(addMemberUser) } - } + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -269,9 +254,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the group */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -280,87 +266,95 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the group */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: List?) = - removeMemberGroups(JsonField.ofNullable(removeMemberGroups)) + fun removeMemberGroups(removeMemberGroups: List?) = removeMemberGroups(JsonField.ofNullable(removeMemberGroups)) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: Optional>) = - removeMemberGroups(removeMemberGroups.getOrNull()) + fun removeMemberGroups(removeMemberGroups: Optional>) = removeMemberGroups(removeMemberGroups.getOrNull()) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { - this.removeMemberGroups = removeMemberGroups.map { it.toMutableList() } - } + fun removeMemberGroups(removeMemberGroups: JsonField>) = + apply { + this.removeMemberGroups = removeMemberGroups.map { it.toMutableList() } + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun addRemoveMemberGroup(removeMemberGroup: String) = apply { - removeMemberGroups = - (removeMemberGroups ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberGroup(removeMemberGroup: String) = + apply { + removeMemberGroups = (removeMemberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberGroups", it).add(removeMemberGroup) } - } + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: List?) = - removeMemberUsers(JsonField.ofNullable(removeMemberUsers)) + fun removeMemberUsers(removeMemberUsers: List?) = removeMemberUsers(JsonField.ofNullable(removeMemberUsers)) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: Optional>) = - removeMemberUsers(removeMemberUsers.getOrNull()) + fun removeMemberUsers(removeMemberUsers: Optional>) = removeMemberUsers(removeMemberUsers.getOrNull()) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { - this.removeMemberUsers = removeMemberUsers.map { it.toMutableList() } - } + fun removeMemberUsers(removeMemberUsers: JsonField>) = + apply { + this.removeMemberUsers = removeMemberUsers.map { it.toMutableList() } + } /** A list of user IDs to remove from the group */ - fun addRemoveMemberUser(removeMemberUser: String) = apply { - removeMemberUsers = - (removeMemberUsers ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberUser(removeMemberUser: String) = + apply { + removeMemberUsers = (removeMemberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberUsers", it).add(removeMemberUser) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (addMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - description, - name, - (removeMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (removeMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (addMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + description, + name, + (removeMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (removeMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -369,8 +363,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" + override fun toString() = "Body{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -381,11 +374,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [GroupUpdateParams]. * * The following fields are required: + * * ```java * .groupId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [GroupUpdateParams]. */ @@ -398,244 +393,305 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupUpdateParams: GroupUpdateParams) = apply { - groupId = groupUpdateParams.groupId - body = groupUpdateParams.body.toBuilder() - additionalHeaders = groupUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = groupUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(groupUpdateParams: GroupUpdateParams) = + apply { + groupId = groupUpdateParams.groupId + body = groupUpdateParams.body.toBuilder() + additionalHeaders = groupUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupUpdateParams.additionalQueryParams.toBuilder() + } /** Group id */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = + apply { + this.groupId = groupId + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: List?) = apply { - body.addMemberGroups(addMemberGroups) - } + fun addMemberGroups(addMemberGroups: List?) = + apply { + body.addMemberGroups(addMemberGroups) + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: Optional>) = - addMemberGroups(addMemberGroups.getOrNull()) + fun addMemberGroups(addMemberGroups: Optional>) = addMemberGroups(addMemberGroups.getOrNull()) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: JsonField>) = apply { - body.addMemberGroups(addMemberGroups) - } + fun addMemberGroups(addMemberGroups: JsonField>) = + apply { + body.addMemberGroups(addMemberGroups) + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addAddMemberGroup(addMemberGroup: String) = apply { - body.addAddMemberGroup(addMemberGroup) - } + fun addAddMemberGroup(addMemberGroup: String) = + apply { + body.addAddMemberGroup(addMemberGroup) + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: List?) = apply { - body.addMemberUsers(addMemberUsers) - } + fun addMemberUsers(addMemberUsers: List?) = + apply { + body.addMemberUsers(addMemberUsers) + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: Optional>) = - addMemberUsers(addMemberUsers.getOrNull()) + fun addMemberUsers(addMemberUsers: Optional>) = addMemberUsers(addMemberUsers.getOrNull()) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: JsonField>) = apply { - body.addMemberUsers(addMemberUsers) - } + fun addMemberUsers(addMemberUsers: JsonField>) = + apply { + body.addMemberUsers(addMemberUsers) + } /** A list of user IDs to add to the group */ - fun addAddMemberUser(addMemberUser: String) = apply { body.addAddMemberUser(addMemberUser) } + fun addAddMemberUser(addMemberUser: String) = + apply { + body.addAddMemberUser(addMemberUser) + } /** Textual description of the group */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the group */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the group */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the group */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: List?) = apply { - body.removeMemberGroups(removeMemberGroups) - } + fun removeMemberGroups(removeMemberGroups: List?) = + apply { + body.removeMemberGroups(removeMemberGroups) + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: Optional>) = - removeMemberGroups(removeMemberGroups.getOrNull()) + fun removeMemberGroups(removeMemberGroups: Optional>) = removeMemberGroups(removeMemberGroups.getOrNull()) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { - body.removeMemberGroups(removeMemberGroups) - } + fun removeMemberGroups(removeMemberGroups: JsonField>) = + apply { + body.removeMemberGroups(removeMemberGroups) + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun addRemoveMemberGroup(removeMemberGroup: String) = apply { - body.addRemoveMemberGroup(removeMemberGroup) - } + fun addRemoveMemberGroup(removeMemberGroup: String) = + apply { + body.addRemoveMemberGroup(removeMemberGroup) + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: List?) = apply { - body.removeMemberUsers(removeMemberUsers) - } + fun removeMemberUsers(removeMemberUsers: List?) = + apply { + body.removeMemberUsers(removeMemberUsers) + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: Optional>) = - removeMemberUsers(removeMemberUsers.getOrNull()) + fun removeMemberUsers(removeMemberUsers: Optional>) = removeMemberUsers(removeMemberUsers.getOrNull()) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { - body.removeMemberUsers(removeMemberUsers) - } + fun removeMemberUsers(removeMemberUsers: JsonField>) = + apply { + body.removeMemberUsers(removeMemberUsers) + } /** A list of user IDs to remove from the group */ - fun addRemoveMemberUser(removeMemberUser: String) = apply { - body.addRemoveMemberUser(removeMemberUser) - } + fun addRemoveMemberUser(removeMemberUser: String) = + apply { + body.addRemoveMemberUser(removeMemberUser) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupUpdateParams = GroupUpdateParams( - checkRequired("groupId", groupId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "groupId", groupId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "GroupUpdateParams{groupId=$groupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "GroupUpdateParams{groupId=$groupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index c726e52b..ea8bc1c4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -21,99 +21,81 @@ import kotlin.jvm.optionals.getOrNull /** A dataset event */ @NoAutoDetect -class InsertDatasetEvent -@JsonCreator -private constructor( +class InsertDatasetEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") - @ExcludeMissing - private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") - @ExcludeMissing - private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") - @ExcludeMissing - private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") - @ExcludeMissing - private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -123,203 +105,234 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object) + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable + * object) + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId(): JsonField = _parentId /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -328,7 +341,9 @@ private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -336,31 +351,33 @@ private constructor( private var validated: Boolean = false - fun validate(): InsertDatasetEvent = apply { - if (validated) { - return@apply - } + fun validate(): InsertDatasetEvent = + apply { + if (validated) { + return@apply + } - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - created() - metadata().ifPresent { it.validate() } - rootSpanId() - spanId() - spanParents() - tags() - validated = true - } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + created() + metadata().ifPresent { it.validate() } + rootSpanId() + spanId() + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [InsertDatasetEvent]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InsertDatasetEvent]. */ @@ -382,241 +399,268 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertDatasetEvent: InsertDatasetEvent) = apply { - id = insertDatasetEvent.id - _isMerge = insertDatasetEvent._isMerge - _mergePaths = insertDatasetEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertDatasetEvent._objectDelete - _parentId = insertDatasetEvent._parentId - created = insertDatasetEvent.created - expected = insertDatasetEvent.expected - input = insertDatasetEvent.input - metadata = insertDatasetEvent.metadata - rootSpanId = insertDatasetEvent.rootSpanId - spanId = insertDatasetEvent.spanId - spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } - tags = insertDatasetEvent.tags.map { it.toMutableList() } - additionalProperties = insertDatasetEvent.additionalProperties.toMutableMap() - } + internal fun from(insertDatasetEvent: InsertDatasetEvent) = + apply { + id = insertDatasetEvent.id + _isMerge = insertDatasetEvent._isMerge + _mergePaths = insertDatasetEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertDatasetEvent._objectDelete + _parentId = insertDatasetEvent._parentId + created = insertDatasetEvent.created + expected = insertDatasetEvent.expected + input = insertDatasetEvent.input + metadata = insertDatasetEvent.metadata + rootSpanId = insertDatasetEvent.rootSpanId + spanId = insertDatasetEvent.spanId + spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } + tags = insertDatasetEvent.tags.map { it.toMutableList() } + additionalProperties = insertDatasetEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = + apply { + this._isMerge = _isMerge + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = - _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. + * + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: JsonField>>) = + apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ - fun addMergePath(mergePath: List) = apply { - _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).also { + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. + * + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. + */ + fun addMergePath(mergePath: List) = + apply { + _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: Boolean?) = - _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = + apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = + apply { + this._parentId = _parentId + } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -625,60 +669,73 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the dataset event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + * The argument that uniquely define an input case (an arbitrary, JSON serializable + * object) */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -686,18 +743,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -705,37 +762,40 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -743,18 +803,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -762,37 +822,40 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -800,18 +863,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -819,48 +882,49 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. + * + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -869,66 +933,75 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertDatasetEvent = InsertDatasetEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - created, - expected, - input, - metadata, - rootSpanId, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + created, + expected, + input, + metadata, + rootSpanId, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -937,20 +1010,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -959,38 +1034,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1003,11 +1086,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1016,6 +1099,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 099bcb9a..56212366 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -18,24 +18,25 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class InsertEventsResponse -@JsonCreator -private constructor( - @JsonProperty("row_ids") - @ExcludeMissing - private val rowIds: JsonField> = JsonMissing.of(), +class InsertEventsResponse @JsonCreator private constructor( + @JsonProperty("row_ids") @ExcludeMissing private val rowIds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ fun rowIds(): List = rowIds.getRequired("row_ids") /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField> = rowIds + @JsonProperty("row_ids") + @ExcludeMissing + fun _rowIds(): JsonField> = rowIds @JsonAnyGetter @ExcludeMissing @@ -43,28 +44,32 @@ private constructor( private var validated: Boolean = false - fun validate(): InsertEventsResponse = apply { - if (validated) { - return@apply - } + fun validate(): InsertEventsResponse = + apply { + if (validated) { + return@apply + } - rowIds() - validated = true - } + rowIds() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [InsertEventsResponse]. + * Returns a mutable builder for constructing an instance of + * [InsertEventsResponse]. * * The following fields are required: + * * ```java * .rowIds() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InsertEventsResponse]. */ @@ -74,68 +79,78 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertEventsResponse: InsertEventsResponse) = apply { - rowIds = insertEventsResponse.rowIds.map { it.toMutableList() } - additionalProperties = insertEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(insertEventsResponse: InsertEventsResponse) = + apply { + rowIds = insertEventsResponse.rowIds.map { it.toMutableList() } + additionalProperties = insertEventsResponse.additionalProperties.toMutableMap() + } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ - fun rowIds(rowIds: JsonField>) = apply { - this.rowIds = rowIds.map { it.toMutableList() } - } + fun rowIds(rowIds: JsonField>) = + apply { + this.rowIds = rowIds.map { it.toMutableList() } + } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input + * The ids of all rows that were inserted, aligning one-to-one with the rows + * provided as input */ - fun addRowId(rowId: String) = apply { - rowIds = - (rowIds ?: JsonField.of(mutableListOf())).also { + fun addRowId(rowId: String) = + apply { + rowIds = (rowIds ?: JsonField.of(mutableListOf())).also { checkKnown("rowIds", it).add(rowId) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertEventsResponse = InsertEventsResponse( - checkRequired("rowIds", rowIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "rowIds", rowIds + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertEventsResponse && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertEventsResponse && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -144,6 +159,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 3b414e84..4f95c38c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -21,125 +21,98 @@ import kotlin.jvm.optionals.getOrNull /** An experiment event */ @NoAutoDetect -class InsertExperimentEvent -@JsonCreator -private constructor( +class InsertExperimentEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") - @ExcludeMissing - private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") - @ExcludeMissing - private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") - @ExcludeMissing - private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") - @ExcludeMissing - private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - private val context: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") - @ExcludeMissing - private val datasetRecordId: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_record_id") @ExcludeMissing private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") - @ExcludeMissing - private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) @@ -147,254 +120,291 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId(): JsonField = _parentId /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId(): JsonField = datasetRecordId /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -402,36 +412,40 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -440,7 +454,9 @@ private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -448,36 +464,41 @@ private constructor( private var validated: Boolean = false - fun validate(): InsertExperimentEvent = apply { - if (validated) { - return@apply - } + fun validate(): InsertExperimentEvent = + apply { + if (validated) { + return@apply + } - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - context().ifPresent { it.validate() } - created() - datasetRecordId() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - rootSpanId() - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanId() - spanParents() - tags() - validated = true - } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + context().ifPresent { it.validate() } + created() + datasetRecordId() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + rootSpanId() + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanId() + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [InsertExperimentEvent]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [InsertExperimentEvent]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [InsertExperimentEvent]. */ @@ -506,269 +527,302 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertExperimentEvent: InsertExperimentEvent) = apply { - id = insertExperimentEvent.id - _isMerge = insertExperimentEvent._isMerge - _mergePaths = insertExperimentEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertExperimentEvent._objectDelete - _parentId = insertExperimentEvent._parentId - context = insertExperimentEvent.context - created = insertExperimentEvent.created - datasetRecordId = insertExperimentEvent.datasetRecordId - error = insertExperimentEvent.error - expected = insertExperimentEvent.expected - input = insertExperimentEvent.input - metadata = insertExperimentEvent.metadata - metrics = insertExperimentEvent.metrics - output = insertExperimentEvent.output - rootSpanId = insertExperimentEvent.rootSpanId - scores = insertExperimentEvent.scores - spanAttributes = insertExperimentEvent.spanAttributes - spanId = insertExperimentEvent.spanId - spanParents = insertExperimentEvent.spanParents.map { it.toMutableList() } - tags = insertExperimentEvent.tags.map { it.toMutableList() } - additionalProperties = insertExperimentEvent.additionalProperties.toMutableMap() - } + internal fun from(insertExperimentEvent: InsertExperimentEvent) = + apply { + id = insertExperimentEvent.id + _isMerge = insertExperimentEvent._isMerge + _mergePaths = insertExperimentEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertExperimentEvent._objectDelete + _parentId = insertExperimentEvent._parentId + context = insertExperimentEvent.context + created = insertExperimentEvent.created + datasetRecordId = insertExperimentEvent.datasetRecordId + error = insertExperimentEvent.error + expected = insertExperimentEvent.expected + input = insertExperimentEvent.input + metadata = insertExperimentEvent.metadata + metrics = insertExperimentEvent.metrics + output = insertExperimentEvent.output + rootSpanId = insertExperimentEvent.rootSpanId + scores = insertExperimentEvent.scores + spanAttributes = insertExperimentEvent.spanAttributes + spanId = insertExperimentEvent.spanId + spanParents = insertExperimentEvent.spanParents.map { it.toMutableList() } + tags = insertExperimentEvent.tags.map { it.toMutableList() } + additionalProperties = insertExperimentEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = + apply { + this._isMerge = _isMerge + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = - _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + fun _mergePaths(_mergePaths: JsonField>>) = + apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun addMergePath(mergePath: List) = apply { - _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).also { + fun addMergePath(mergePath: List) = + apply { + _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: Boolean?) = - _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = + apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = + apply { + this._parentId = _parentId + } /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = + apply { + this.context = context + } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -777,122 +831,144 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the experiment event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String?) = - datasetRecordId(JsonField.ofNullable(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String?) = datasetRecordId(JsonField.ofNullable(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.getOrNull()) + fun datasetRecordId(datasetRecordId: Optional) = datasetRecordId(datasetRecordId.getOrNull()) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } + fun datasetRecordId(datasetRecordId: JsonField) = + apply { + this.datasetRecordId = datasetRecordId + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = + apply { + this.error = error + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = + apply { + this.output = output + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -900,18 +976,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -919,83 +995,91 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = - spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = + apply { + this.spanAttributes = spanAttributes + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1003,18 +1087,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1022,37 +1106,40 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1060,18 +1147,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1079,48 +1166,49 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -1129,93 +1217,94 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertExperimentEvent = InsertExperimentEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - context, - created, - datasetRecordId, - error, - expected, - input, - metadata, - metrics, - output, - rootSpanId, - scores, - spanAttributes, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + context, + created, + datasetRecordId, + error, + expected, + input, + metadata, + metrics, + output, + rootSpanId, + scores, + spanAttributes, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ @NoAutoDetect - class Context - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Context @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -1238,23 +1327,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Context = apply { - if (validated) { - return@apply - } + fun validate(): Context = + apply { + if (validated) { + return@apply + } - callerFilename() - callerFunctionname() - callerLineno() - validated = true - } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Context]. */ @@ -1266,38 +1357,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = + apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String?) = - callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = + apply { + this.callerFilename = callerFilename + } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String?) = - callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = + apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -1309,44 +1399,52 @@ private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = + apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1355,23 +1453,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1380,20 +1475,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1402,38 +1499,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1446,38 +1551,22 @@ private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - private val completionTokens: JsonField = JsonMissing.of(), + class Metrics @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") - @ExcludeMissing - private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") - @ExcludeMissing - private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** This metric is deprecated */ @@ -1491,31 +1580,31 @@ private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1523,35 +1612,41 @@ private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ - @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + @JsonProperty("end") + @ExcludeMissing + fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + @JsonProperty("start") + @ExcludeMissing + fun _start(): JsonField = start /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1559,25 +1654,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true - } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1594,133 +1691,144 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = + apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = + apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = + apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun callerLineno(callerLineno: JsonValue) = + apply { + this.callerLineno = callerLineno + } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long?) = - completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long) = - completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = + apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * A unix timestamp recording when the section of code which produced the + * experiment event finished */ - fun end(end: JsonField) = apply { this.end = end } + fun end(end: JsonField) = + apply { + this.end = end + } /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = + apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * A unix timestamp recording when the section of code which produced the + * experiment event started */ - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = + apply { + this.start = start + } /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1732,47 +1840,57 @@ private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = + apply { + this.tokens = tokens + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1781,25 +1899,23 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1808,20 +1924,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1830,38 +1948,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1874,11 +2000,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1887,6 +2013,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index abf02697..0d2bd5ff 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -21,122 +21,97 @@ import kotlin.jvm.optionals.getOrNull /** A project logs event */ @NoAutoDetect -class InsertProjectLogsEvent -@JsonCreator -private constructor( +class InsertProjectLogsEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") - @ExcludeMissing - private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") - @ExcludeMissing - private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") - @ExcludeMissing - private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") - @ExcludeMissing - private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - private val context: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") - @ExcludeMissing - private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(): Optional>> = - Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - fun _objectDelete(): Optional = - Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) @@ -144,234 +119,273 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge, when + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId(): JsonField = _parentId /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -379,36 +393,40 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -417,7 +435,9 @@ private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -425,35 +445,40 @@ private constructor( private var validated: Boolean = false - fun validate(): InsertProjectLogsEvent = apply { - if (validated) { - return@apply - } + fun validate(): InsertProjectLogsEvent = + apply { + if (validated) { + return@apply + } - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - context().ifPresent { it.validate() } - created() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - rootSpanId() - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanId() - spanParents() - tags() - validated = true - } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + context().ifPresent { it.validate() } + created() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + rootSpanId() + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanId() + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [InsertProjectLogsEvent]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [InsertProjectLogsEvent]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [InsertProjectLogsEvent]. */ @@ -481,268 +506,301 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertProjectLogsEvent: InsertProjectLogsEvent) = apply { - id = insertProjectLogsEvent.id - _isMerge = insertProjectLogsEvent._isMerge - _mergePaths = insertProjectLogsEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertProjectLogsEvent._objectDelete - _parentId = insertProjectLogsEvent._parentId - context = insertProjectLogsEvent.context - created = insertProjectLogsEvent.created - error = insertProjectLogsEvent.error - expected = insertProjectLogsEvent.expected - input = insertProjectLogsEvent.input - metadata = insertProjectLogsEvent.metadata - metrics = insertProjectLogsEvent.metrics - output = insertProjectLogsEvent.output - rootSpanId = insertProjectLogsEvent.rootSpanId - scores = insertProjectLogsEvent.scores - spanAttributes = insertProjectLogsEvent.spanAttributes - spanId = insertProjectLogsEvent.spanId - spanParents = insertProjectLogsEvent.spanParents.map { it.toMutableList() } - tags = insertProjectLogsEvent.tags.map { it.toMutableList() } - additionalProperties = insertProjectLogsEvent.additionalProperties.toMutableMap() - } + internal fun from(insertProjectLogsEvent: InsertProjectLogsEvent) = + apply { + id = insertProjectLogsEvent.id + _isMerge = insertProjectLogsEvent._isMerge + _mergePaths = insertProjectLogsEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertProjectLogsEvent._objectDelete + _parentId = insertProjectLogsEvent._parentId + context = insertProjectLogsEvent.context + created = insertProjectLogsEvent.created + error = insertProjectLogsEvent.error + expected = insertProjectLogsEvent.expected + input = insertProjectLogsEvent.input + metadata = insertProjectLogsEvent.metadata + metrics = insertProjectLogsEvent.metrics + output = insertProjectLogsEvent.output + rootSpanId = insertProjectLogsEvent.rootSpanId + scores = insertProjectLogsEvent.scores + spanAttributes = insertProjectLogsEvent.spanAttributes + spanId = insertProjectLogsEvent.spanId + spanParents = insertProjectLogsEvent.spanParents.map { it.toMutableList() } + tags = insertProjectLogsEvent.tags.map { it.toMutableList() } + additionalProperties = insertProjectLogsEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row, if one is found. If no existing row is found, + * the new row is inserted as is. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = + apply { + this._isMerge = _isMerge + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = - _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = - _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: JsonField>>) = apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + fun _mergePaths(_mergePaths: JsonField>>) = + apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list + * of field names. The deep merge will not descend below any of the specified merge + * paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - fun addMergePath(mergePath: List) = apply { - _mergePaths = - (_mergePaths ?: JsonField.of(mutableListOf())).also { + fun addMergePath(mergePath: List) = + apply { + _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: Boolean?) = - _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: Optional) = - _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: JsonField) = apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = + apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * Tracking hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = + apply { + this._parentId = _parentId + } /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = + apply { + this.context = context + } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -751,97 +809,119 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the project logs event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = + apply { + this.error = error + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = + apply { + this.output = output + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -849,18 +929,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -868,83 +948,91 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = - spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = + apply { + this.spanAttributes = spanAttributes + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -952,18 +1040,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -971,37 +1059,40 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1009,18 +1100,18 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1028,48 +1119,49 @@ private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * \_parent_id. The span_id is a unique identifier describing the row's place in + * the a trace, and the root_span_id is a unique identifier for the whole trace. + * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -1078,92 +1170,93 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertProjectLogsEvent = InsertProjectLogsEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - context, - created, - error, - expected, - input, - metadata, - metrics, - output, - rootSpanId, - scores, - spanAttributes, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + context, + created, + error, + expected, + input, + metadata, + metrics, + output, + rootSpanId, + scores, + spanAttributes, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ @NoAutoDetect - class Context - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Context @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -1186,23 +1279,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Context = apply { - if (validated) { - return@apply - } + fun validate(): Context = + apply { + if (validated) { + return@apply + } - callerFilename() - callerFunctionname() - callerLineno() - validated = true - } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Context]. */ @@ -1214,38 +1309,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = + apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String?) = - callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = + apply { + this.callerFilename = callerFilename + } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String?) = - callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = + apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -1257,44 +1351,52 @@ private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = + apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1303,23 +1405,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1328,20 +1427,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1350,38 +1451,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1394,38 +1503,22 @@ private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - private val completionTokens: JsonField = JsonMissing.of(), + class Metrics @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") - @ExcludeMissing - private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") - @ExcludeMissing - private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** This metric is deprecated */ @@ -1439,31 +1532,31 @@ private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1471,35 +1564,41 @@ private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ - @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + @JsonProperty("end") + @ExcludeMissing + fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + @JsonProperty("start") + @ExcludeMissing + fun _start(): JsonField = start /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1507,25 +1606,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true - } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1542,133 +1643,144 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = + apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = + apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = + apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun callerLineno(callerLineno: JsonValue) = + apply { + this.callerLineno = callerLineno + } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long?) = - completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long) = - completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = + apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ - fun end(end: JsonField) = apply { this.end = end } + fun end(end: JsonField) = + apply { + this.end = end + } /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = + apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = + apply { + this.start = start + } /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1680,47 +1792,57 @@ private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = + apply { + this.tokens = tokens + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1729,25 +1851,23 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1756,20 +1876,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1778,38 +1900,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1822,11 +1952,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1835,6 +1965,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index a7fa4c4d..8c1b55dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -19,22 +19,15 @@ import java.util.Optional /** Summary of a metric's performance */ @NoAutoDetect -class MetricSummary -@JsonCreator -private constructor( - @JsonProperty("improvements") - @ExcludeMissing - private val improvements: JsonField = JsonMissing.of(), - @JsonProperty("metric") - @ExcludeMissing - private val metric: JsonField = JsonMissing.of(), +class MetricSummary @JsonCreator private constructor( + @JsonProperty("improvements") @ExcludeMissing private val improvements: JsonField = JsonMissing.of(), + @JsonProperty("metric") @ExcludeMissing private val metric: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("regressions") - @ExcludeMissing - private val regressions: JsonField = JsonMissing.of(), + @JsonProperty("regressions") @ExcludeMissing private val regressions: JsonField = JsonMissing.of(), @JsonProperty("unit") @ExcludeMissing private val unit: JsonField = JsonMissing.of(), @JsonProperty("diff") @ExcludeMissing private val diff: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Number of improvements in the metric */ @@ -61,19 +54,29 @@ private constructor( fun _improvements(): JsonField = improvements /** Average metric across all examples */ - @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric + @JsonProperty("metric") + @ExcludeMissing + fun _metric(): JsonField = metric /** Name of the metric */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Number of regressions in the metric */ - @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions + @JsonProperty("regressions") + @ExcludeMissing + fun _regressions(): JsonField = regressions /** Unit label for the metric */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + @JsonProperty("unit") + @ExcludeMissing + fun _unit(): JsonField = unit /** Difference in metric between the current and comparison experiment */ - @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff + @JsonProperty("diff") + @ExcludeMissing + fun _diff(): JsonField = diff @JsonAnyGetter @ExcludeMissing @@ -81,20 +84,21 @@ private constructor( private var validated: Boolean = false - fun validate(): MetricSummary = apply { - if (validated) { - return@apply + fun validate(): MetricSummary = + apply { + if (validated) { + return@apply + } + + improvements() + metric() + name() + regressions() + unit() + diff() + validated = true } - improvements() - metric() - name() - regressions() - unit() - diff() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -103,6 +107,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [MetricSummary]. * * The following fields are required: + * * ```java * .improvements() * .metric() @@ -111,7 +116,8 @@ private constructor( * .unit() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [MetricSummary]. */ @@ -126,89 +132,125 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metricSummary: MetricSummary) = apply { - improvements = metricSummary.improvements - metric = metricSummary.metric - name = metricSummary.name - regressions = metricSummary.regressions - unit = metricSummary.unit - diff = metricSummary.diff - additionalProperties = metricSummary.additionalProperties.toMutableMap() - } + internal fun from(metricSummary: MetricSummary) = + apply { + improvements = metricSummary.improvements + metric = metricSummary.metric + name = metricSummary.name + regressions = metricSummary.regressions + unit = metricSummary.unit + diff = metricSummary.diff + additionalProperties = metricSummary.additionalProperties.toMutableMap() + } /** Number of improvements in the metric */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) /** Number of improvements in the metric */ - fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + fun improvements(improvements: JsonField) = + apply { + this.improvements = improvements + } /** Average metric across all examples */ fun metric(metric: Double) = metric(JsonField.of(metric)) /** Average metric across all examples */ - fun metric(metric: JsonField) = apply { this.metric = metric } + fun metric(metric: JsonField) = + apply { + this.metric = metric + } /** Name of the metric */ fun name(name: String) = name(JsonField.of(name)) /** Name of the metric */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Number of regressions in the metric */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) /** Number of regressions in the metric */ - fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + fun regressions(regressions: JsonField) = + apply { + this.regressions = regressions + } /** Unit label for the metric */ fun unit(unit: String) = unit(JsonField.of(unit)) /** Unit label for the metric */ - fun unit(unit: JsonField) = apply { this.unit = unit } + fun unit(unit: JsonField) = + apply { + this.unit = unit + } /** Difference in metric between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) /** Difference in metric between the current and comparison experiment */ - fun diff(diff: JsonField) = apply { this.diff = diff } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun diff(diff: JsonField) = + apply { + this.diff = diff + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MetricSummary = MetricSummary( - checkRequired("improvements", improvements), - checkRequired("metric", metric), - checkRequired("name", name), - checkRequired("regressions", regressions), - checkRequired("unit", unit), - diff, - additionalProperties.toImmutable(), + checkRequired( + "improvements", improvements + ), + checkRequired( + "metric", metric + ), + checkRequired( + "name", name + ), + checkRequired( + "regressions", regressions + ), + checkRequired( + "unit", unit + ), + diff, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MetricSummary && improvements == other.improvements && metric == other.metric && name == other.name && regressions == other.regressions && unit == other.unit && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MetricSummary && improvements == other.improvements && metric == other.metric && name == other.name && regressions == other.regressions && unit == other.unit && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -217,6 +259,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "MetricSummary{improvements=$improvements, metric=$metric, name=$name, regressions=$regressions, unit=$unit, diff=$diff, additionalProperties=$additionalProperties}" + override fun toString() = "MetricSummary{improvements=$improvements, metric=$metric, name=$name, regressions=$regressions, unit=$unit, diff=$diff, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 6eb781e8..f88b718b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -32,22 +32,13 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class OnlineScoreConfig -@JsonCreator -private constructor( - @JsonProperty("sampling_rate") - @ExcludeMissing - private val samplingRate: JsonField = JsonMissing.of(), - @JsonProperty("scorers") - @ExcludeMissing - private val scorers: JsonField> = JsonMissing.of(), - @JsonProperty("apply_to_root_span") - @ExcludeMissing - private val applyToRootSpan: JsonField = JsonMissing.of(), - @JsonProperty("apply_to_span_names") - @ExcludeMissing - private val applyToSpanNames: JsonField> = JsonMissing.of(), +class OnlineScoreConfig @JsonCreator private constructor( + @JsonProperty("sampling_rate") @ExcludeMissing private val samplingRate: JsonField = JsonMissing.of(), + @JsonProperty("scorers") @ExcludeMissing private val scorers: JsonField> = JsonMissing.of(), + @JsonProperty("apply_to_root_span") @ExcludeMissing private val applyToRootSpan: JsonField = JsonMissing.of(), + @JsonProperty("apply_to_span_names") @ExcludeMissing private val applyToSpanNames: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The sampling rate for online scoring */ @@ -57,12 +48,10 @@ private constructor( fun scorers(): List = scorers.getRequired("scorers") /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(): Optional = - Optional.ofNullable(applyToRootSpan.getNullable("apply_to_root_span")) + fun applyToRootSpan(): Optional = Optional.ofNullable(applyToRootSpan.getNullable("apply_to_root_span")) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(): Optional> = - Optional.ofNullable(applyToSpanNames.getNullable("apply_to_span_names")) + fun applyToSpanNames(): Optional> = Optional.ofNullable(applyToSpanNames.getNullable("apply_to_span_names")) /** The sampling rate for online scoring */ @JsonProperty("sampling_rate") @@ -70,7 +59,9 @@ private constructor( fun _samplingRate(): JsonField = samplingRate /** The list of scorers to use for online scoring */ - @JsonProperty("scorers") @ExcludeMissing fun _scorers(): JsonField> = scorers + @JsonProperty("scorers") + @ExcludeMissing + fun _scorers(): JsonField> = scorers /** Whether to trigger online scoring on the root span of each trace */ @JsonProperty("apply_to_root_span") @@ -88,17 +79,18 @@ private constructor( private var validated: Boolean = false - fun validate(): OnlineScoreConfig = apply { - if (validated) { - return@apply - } + fun validate(): OnlineScoreConfig = + apply { + if (validated) { + return@apply + } - samplingRate() - scorers().forEach { it.validate() } - applyToRootSpan() - applyToSpanNames() - validated = true - } + samplingRate() + scorers().forEach { it.validate() } + applyToRootSpan() + applyToSpanNames() + validated = true + } fun toBuilder() = Builder().from(this) @@ -108,12 +100,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [OnlineScoreConfig]. * * The following fields are required: + * * ```java * .samplingRate() * .scorers() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OnlineScoreConfig]. */ @@ -126,37 +120,40 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(onlineScoreConfig: OnlineScoreConfig) = apply { - samplingRate = onlineScoreConfig.samplingRate - scorers = onlineScoreConfig.scorers.map { it.toMutableList() } - applyToRootSpan = onlineScoreConfig.applyToRootSpan - applyToSpanNames = onlineScoreConfig.applyToSpanNames.map { it.toMutableList() } - additionalProperties = onlineScoreConfig.additionalProperties.toMutableMap() - } + internal fun from(onlineScoreConfig: OnlineScoreConfig) = + apply { + samplingRate = onlineScoreConfig.samplingRate + scorers = onlineScoreConfig.scorers.map { it.toMutableList() } + applyToRootSpan = onlineScoreConfig.applyToRootSpan + applyToSpanNames = onlineScoreConfig.applyToSpanNames.map { it.toMutableList() } + additionalProperties = onlineScoreConfig.additionalProperties.toMutableMap() + } /** The sampling rate for online scoring */ fun samplingRate(samplingRate: Double) = samplingRate(JsonField.of(samplingRate)) /** The sampling rate for online scoring */ - fun samplingRate(samplingRate: JsonField) = apply { - this.samplingRate = samplingRate - } + fun samplingRate(samplingRate: JsonField) = + apply { + this.samplingRate = samplingRate + } /** The list of scorers to use for online scoring */ fun scorers(scorers: List) = scorers(JsonField.of(scorers)) /** The list of scorers to use for online scoring */ - fun scorers(scorers: JsonField>) = apply { - this.scorers = scorers.map { it.toMutableList() } - } + fun scorers(scorers: JsonField>) = + apply { + this.scorers = scorers.map { it.toMutableList() } + } /** The list of scorers to use for online scoring */ - fun addScorer(scorer: Scorer) = apply { - scorers = - (scorers ?: JsonField.of(mutableListOf())).also { + fun addScorer(scorer: Scorer) = + apply { + scorers = (scorers ?: JsonField.of(mutableListOf())).also { checkKnown("scorers", it).add(scorer) } - } + } /** The list of scorers to use for online scoring */ fun addScorer(function: Scorer.Function) = addScorer(Scorer.ofFunction(function)) @@ -165,78 +162,87 @@ private constructor( fun addScorer(global: Scorer.Global) = addScorer(Scorer.ofGlobal(global)) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: Boolean?) = - applyToRootSpan(JsonField.ofNullable(applyToRootSpan)) + fun applyToRootSpan(applyToRootSpan: Boolean?) = applyToRootSpan(JsonField.ofNullable(applyToRootSpan)) /** Whether to trigger online scoring on the root span of each trace */ fun applyToRootSpan(applyToRootSpan: Boolean) = applyToRootSpan(applyToRootSpan as Boolean?) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: Optional) = - applyToRootSpan(applyToRootSpan.getOrNull()) + fun applyToRootSpan(applyToRootSpan: Optional) = applyToRootSpan(applyToRootSpan.getOrNull()) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: JsonField) = apply { - this.applyToRootSpan = applyToRootSpan - } + fun applyToRootSpan(applyToRootSpan: JsonField) = + apply { + this.applyToRootSpan = applyToRootSpan + } /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: List?) = - applyToSpanNames(JsonField.ofNullable(applyToSpanNames)) + fun applyToSpanNames(applyToSpanNames: List?) = applyToSpanNames(JsonField.ofNullable(applyToSpanNames)) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: Optional>) = - applyToSpanNames(applyToSpanNames.getOrNull()) + fun applyToSpanNames(applyToSpanNames: Optional>) = applyToSpanNames(applyToSpanNames.getOrNull()) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: JsonField>) = apply { - this.applyToSpanNames = applyToSpanNames.map { it.toMutableList() } - } + fun applyToSpanNames(applyToSpanNames: JsonField>) = + apply { + this.applyToSpanNames = applyToSpanNames.map { it.toMutableList() } + } /** Trigger online scoring on any spans with a name in this list */ - fun addApplyToSpanName(applyToSpanName: String) = apply { - applyToSpanNames = - (applyToSpanNames ?: JsonField.of(mutableListOf())).also { + fun addApplyToSpanName(applyToSpanName: String) = + apply { + applyToSpanNames = (applyToSpanNames ?: JsonField.of(mutableListOf())).also { checkKnown("applyToSpanNames", it).add(applyToSpanName) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): OnlineScoreConfig = OnlineScoreConfig( - checkRequired("samplingRate", samplingRate), - checkRequired("scorers", scorers).map { it.toImmutable() }, - applyToRootSpan, - (applyToSpanNames ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "samplingRate", samplingRate + ), + checkRequired( + "scorers", scorers + ).map { it.toImmutable() }, + applyToRootSpan, + (applyToSpanNames ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Scorer.Deserializer::class) @JsonSerialize(using = Scorer.Serializer::class) - class Scorer - private constructor( + class Scorer private constructor( private val function: Function? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun function(): Optional = Optional.ofNullable(function) @@ -254,40 +260,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - function != null -> visitor.visitFunction(function) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + function != null -> visitor.visitFunction(function) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Scorer = apply { - if (validated) { - return@apply - } + fun validate(): Scorer = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scorer && function == other.function && global == other.global /* spotless:on */ + return /* spotless:off */ other is Scorer && function == other.function && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(function, global) /* spotless:on */ @@ -302,12 +307,17 @@ private constructor( companion object { - @JvmStatic fun ofFunction(function: Function) = Scorer(function = function) + @JvmStatic + fun ofFunction(function: Function) = Scorer(function = function) - @JvmStatic fun ofGlobal(global: Global) = Scorer(global = global) + @JvmStatic + fun ofGlobal(global: Global) = Scorer(global = global) } - /** An interface that defines how to map each variant of [Scorer] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Scorer] to a value of type + * [T]. + */ interface Visitor { fun visitFunction(function: Function): T @@ -317,73 +327,65 @@ private constructor( /** * Maps an unknown variant of [Scorer] to a value of type [T]. * - * An instance of [Scorer] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Scorer] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Scorer: $json") + throw BraintrustInvalidDataException("Unknown Scorer: $json") } } internal class Deserializer : BaseDeserializer(Scorer::class) { override fun ObjectCodec.deserialize(node: JsonNode): Scorer { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Scorer(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Scorer(global = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Scorer(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Scorer(global = it, _json = json) + } - return Scorer(_json = json) + return Scorer(_json = json) } } internal class Serializer : BaseSerializer(Scorer::class) { - override fun serialize( - value: Scorer, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.function != null -> generator.writeObject(value.function) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Scorer") - } + override fun serialize(value: Scorer, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.function != null -> generator.writeObject(value.function) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Scorer") + } } } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun id(): String = id.getRequired("id") fun type(): Type = type.getRequired("type") - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -391,15 +393,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - id() - type() - validated = true - } + id() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -409,12 +412,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .id() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -425,52 +430,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - id = function.id - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + id = function.id + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("id", id), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -480,7 +502,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -491,23 +514,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * 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 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 { FUNCTION, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -531,7 +554,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -546,19 +569,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -567,11 +587,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -580,31 +600,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -612,15 +629,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -630,12 +648,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -646,52 +666,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -701,7 +738,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -712,23 +750,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * 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 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 { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -752,7 +790,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -767,19 +805,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -788,11 +823,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -801,17 +836,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OnlineScoreConfig && samplingRate == other.samplingRate && scorers == other.scorers && applyToRootSpan == other.applyToRootSpan && applyToSpanNames == other.applyToSpanNames && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OnlineScoreConfig && samplingRate == other.samplingRate && scorers == other.scorers && applyToRootSpan == other.applyToRootSpan && applyToSpanNames == other.applyToSpanNames && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -820,6 +854,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" + override fun toString() = "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 584931b5..9fc9931a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -20,27 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Organization -@JsonCreator -private constructor( +class Organization @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("api_url") - @ExcludeMissing - private val apiUrl: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("is_universal_api") - @ExcludeMissing - private val isUniversalApi: JsonField = JsonMissing.of(), - @JsonProperty("proxy_url") - @ExcludeMissing - private val proxyUrl: JsonField = JsonMissing.of(), - @JsonProperty("realtime_url") - @ExcludeMissing - private val realtimeUrl: JsonField = JsonMissing.of(), + @JsonProperty("api_url") @ExcludeMissing private val apiUrl: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("is_universal_api") @ExcludeMissing private val isUniversalApi: JsonField = JsonMissing.of(), + @JsonProperty("proxy_url") @ExcludeMissing private val proxyUrl: JsonField = JsonMissing.of(), + @JsonProperty("realtime_url") @ExcludeMissing private val realtimeUrl: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the organization */ @@ -54,30 +43,38 @@ private constructor( /** Date of organization creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - fun isUniversalApi(): Optional = - Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) - fun realtimeUrl(): Optional = - Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) /** Unique identifier for the organization */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the organization */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl + @JsonProperty("api_url") + @ExcludeMissing + fun _apiUrl(): JsonField = apiUrl /** Date of organization creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi(): JsonField = isUniversalApi - @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl + @JsonProperty("proxy_url") + @ExcludeMissing + fun _proxyUrl(): JsonField = proxyUrl @JsonProperty("realtime_url") @ExcludeMissing @@ -89,21 +86,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Organization = apply { - if (validated) { - return@apply + fun validate(): Organization = + apply { + if (validated) { + return@apply + } + + id() + name() + apiUrl() + created() + isUniversalApi() + proxyUrl() + realtimeUrl() + validated = true } - id() - name() - apiUrl() - created() - isUniversalApi() - proxyUrl() - realtimeUrl() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -112,12 +110,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Organization]. * * The following fields are required: + * * ```java * .id() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Organization]. */ @@ -133,34 +133,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(organization: Organization) = apply { - id = organization.id - name = organization.name - apiUrl = organization.apiUrl - created = organization.created - isUniversalApi = organization.isUniversalApi - proxyUrl = organization.proxyUrl - realtimeUrl = organization.realtimeUrl - additionalProperties = organization.additionalProperties.toMutableMap() - } + internal fun from(organization: Organization) = + apply { + id = organization.id + name = organization.name + apiUrl = organization.apiUrl + created = organization.created + isUniversalApi = organization.isUniversalApi + proxyUrl = organization.proxyUrl + realtimeUrl = organization.realtimeUrl + additionalProperties = organization.additionalProperties.toMutableMap() + } /** Unique identifier for the organization */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the organization */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the organization */ fun name(name: String) = name(JsonField.of(name)) /** Name of the organization */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } + fun apiUrl(apiUrl: JsonField) = + apply { + this.apiUrl = apiUrl + } /** Date of organization creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -169,70 +179,89 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of organization creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } - fun isUniversalApi(isUniversalApi: Boolean?) = - isUniversalApi(JsonField.ofNullable(isUniversalApi)) + fun isUniversalApi(isUniversalApi: Boolean?) = isUniversalApi(JsonField.ofNullable(isUniversalApi)) fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = apply { - this.isUniversalApi = isUniversalApi - } + fun isUniversalApi(isUniversalApi: JsonField) = + apply { + this.isUniversalApi = isUniversalApi + } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: JsonField) = + apply { + this.proxyUrl = proxyUrl + } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun realtimeUrl(realtimeUrl: JsonField) = + apply { + this.realtimeUrl = realtimeUrl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Organization = Organization( - checkRequired("id", id), - checkRequired("name", name), - apiUrl, - created, - isUniversalApi, - proxyUrl, - realtimeUrl, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + apiUrl, + created, + isUniversalApi, + proxyUrl, + realtimeUrl, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && created == other.created && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && created == other.created && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -241,6 +270,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Organization{id=$id, name=$name, apiUrl=$apiUrl, created=$created, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + override fun toString() = "Organization{id=$id, name=$name, apiUrl=$apiUrl, created=$created, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index ba3170a9..cf0c7530 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an organization object by its id */ -class OrganizationDeleteParams -private constructor( +class OrganizationDeleteParams private constructor( private val organizationId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Organization id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OrganizationDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [OrganizationDeleteParams]. * * The following fields are required: + * * ```java * .organizationId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(organizationDeleteParams: OrganizationDeleteParams) = apply { - organizationId = organizationDeleteParams.organizationId - additionalHeaders = organizationDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - organizationDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(organizationDeleteParams: OrganizationDeleteParams) = + apply { + organizationId = organizationDeleteParams.organizationId + additionalHeaders = organizationDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = organizationDeleteParams.additionalBodyProperties.toMutableMap() + } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = + apply { + this.organizationId = organizationId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): OrganizationDeleteParams = OrganizationDeleteParams( - checkRequired("organizationId", organizationId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "organizationId", organizationId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index 8bff63be..ecad5972 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.OrganizationService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ -class OrganizationListPage -private constructor( +class OrganizationListPage private constructor( private val organizationsService: OrganizationService, private val params: OrganizationListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListPage && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is OrganizationListPage && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ - override fun toString() = - "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" + override fun toString() = "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - OrganizationListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - OrganizationListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { organizationsService.list(it) } + return getNextPageParams().map { organizationsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - organizationsService: OrganizationService, - params: OrganizationListParams, - response: Response, - ) = OrganizationListPage(organizationsService, params, response) + fun of(organizationsService: OrganizationService, params: OrganizationListParams, response: Response) = + OrganizationListPage( + organizationsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** Returns a mutable builder for constructing an instance of [OrganizationListPage]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [OrganizationListPage]. + */ + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +139,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: OrganizationListPage) : Iterable { + class AutoPager( + private val firstPage: OrganizationListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index cdc6536a..66136ad2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.OrganizationServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ -class OrganizationListPageAsync -private constructor( +class OrganizationListPageAsync private constructor( private val organizationsService: OrganizationServiceAsync, private val params: OrganizationListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListPageAsync && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is OrganizationListPageAsync && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ - override fun toString() = - "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" + override fun toString() = "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - OrganizationListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - OrganizationListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { organizationsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + organizationsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - organizationsService: OrganizationServiceAsync, - params: OrganizationListParams, - response: Response, - ) = OrganizationListPageAsync(organizationsService, params, response) + fun of(organizationsService: OrganizationServiceAsync, params: OrganizationListParams, response: Response) = + OrganizationListPageAsync( + organizationsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,29 +106,29 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -143,7 +136,8 @@ private constructor( * Returns a mutable builder for constructing an instance of * [OrganizationListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -152,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: OrganizationListPageAsync) { + class AutoPager( + private val firstPage: OrganizationListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Organization) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Organization) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index d01ebbf0..030263de 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ -class OrganizationListParams -private constructor( +class OrganizationListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -35,20 +34,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -61,9 +61,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -74,24 +74,49 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): OrganizationListParams = builder().build() + @JvmStatic + fun none(): OrganizationListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [OrganizationListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [OrganizationListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationListParams]. */ @@ -107,60 +132,70 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationListParams: OrganizationListParams) = apply { - endingBefore = organizationListParams.endingBefore - ids = organizationListParams.ids - limit = organizationListParams.limit - orgName = organizationListParams.orgName - startingAfter = organizationListParams.startingAfter - additionalHeaders = organizationListParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationListParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationListParams: OrganizationListParams) = + apply { + endingBefore = organizationListParams.endingBefore + ids = organizationListParams.ids + limit = organizationListParams.limit + orgName = organizationListParams.orgName + startingAfter = organizationListParams.startingAfter + additionalHeaders = organizationListParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -169,7 +204,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -177,143 +215,171 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationListParams = OrganizationListParams( - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -331,19 +397,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -358,12 +424,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -373,60 +444,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index f75b1abe..8c4a6abb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -22,27 +22,29 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Modify organization membership */ -class OrganizationMemberUpdateParams -private constructor( +class OrganizationMemberUpdateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Users to invite to the organization */ fun inviteUsers(): Optional = body.inviteUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(): Optional = body.orgId() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(): Optional = body.orgName() @@ -53,16 +55,18 @@ private constructor( fun _inviteUsers(): JsonField = body._inviteUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun _orgId(): JsonField = body._orgId() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun _orgName(): JsonField = body._orgName() @@ -75,53 +79,44 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("invite_users") - @ExcludeMissing - private val inviteUsers: JsonField = JsonMissing.of(), - @JsonProperty("org_id") - @ExcludeMissing - private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("remove_users") - @ExcludeMissing - private val removeUsers: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("invite_users") @ExcludeMissing private val inviteUsers: JsonField = JsonMissing.of(), + @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("remove_users") @ExcludeMissing private val removeUsers: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Users to invite to the organization */ - fun inviteUsers(): Optional = - Optional.ofNullable(inviteUsers.getNullable("invite_users")) + fun inviteUsers(): Optional = Optional.ofNullable(inviteUsers.getNullable("invite_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Users to remove from the organization */ - fun removeUsers(): Optional = - Optional.ofNullable(removeUsers.getNullable("remove_users")) + fun removeUsers(): Optional = Optional.ofNullable(removeUsers.getNullable("remove_users")) /** Users to invite to the organization */ @JsonProperty("invite_users") @@ -129,18 +124,24 @@ private constructor( fun _inviteUsers(): JsonField = inviteUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName /** Users to remove from the organization */ @JsonProperty("remove_users") @@ -153,24 +154,26 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + inviteUsers().ifPresent { it.validate() } + orgId() + orgName() + removeUsers().ifPresent { it.validate() } + validated = true } - inviteUsers().ifPresent { it.validate() } - orgId() - orgName() - removeUsers().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -183,117 +186,135 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - inviteUsers = body.inviteUsers - orgId = body.orgId - orgName = body.orgName - removeUsers = body.removeUsers - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + inviteUsers = body.inviteUsers + orgId = body.orgId + orgName = body.orgName + removeUsers = body.removeUsers + additionalProperties = body.additionalProperties.toMutableMap() + } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers?) = - inviteUsers(JsonField.ofNullable(inviteUsers)) + fun inviteUsers(inviteUsers: InviteUsers?) = inviteUsers(JsonField.ofNullable(inviteUsers)) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: Optional) = - inviteUsers(inviteUsers.getOrNull()) + fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: JsonField) = apply { - this.inviteUsers = inviteUsers - } + fun inviteUsers(inviteUsers: JsonField) = + apply { + this.inviteUsers = inviteUsers + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the id of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the id of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the id of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the name of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the name of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the name of the - * organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers?) = - removeUsers(JsonField.ofNullable(removeUsers)) + fun removeUsers(removeUsers: RemoveUsers?) = removeUsers(JsonField.ofNullable(removeUsers)) /** Users to remove from the organization */ - fun removeUsers(removeUsers: Optional) = - removeUsers(removeUsers.getOrNull()) + fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) /** Users to remove from the organization */ - fun removeUsers(removeUsers: JsonField) = apply { - this.removeUsers = removeUsers - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeUsers(removeUsers: JsonField) = + apply { + this.removeUsers = removeUsers + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(inviteUsers, orgId, orgName, removeUsers, additionalProperties.toImmutable()) + Body( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -302,21 +323,22 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" + override fun toString() = "Body{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): OrganizationMemberUpdateParams = builder().build() + @JvmStatic + fun none(): OrganizationMemberUpdateParams = builder().build() /** * Returns a mutable builder for constructing an instance of * [OrganizationMemberUpdateParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationMemberUpdateParams]. */ @@ -328,229 +350,274 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = apply { - body = organizationMemberUpdateParams.body.toBuilder() - additionalHeaders = organizationMemberUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationMemberUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = + apply { + body = organizationMemberUpdateParams.body.toBuilder() + additionalHeaders = organizationMemberUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationMemberUpdateParams.additionalQueryParams.toBuilder() + } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers?) = apply { body.inviteUsers(inviteUsers) } + fun inviteUsers(inviteUsers: InviteUsers?) = + apply { + body.inviteUsers(inviteUsers) + } /** Users to invite to the organization */ fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: JsonField) = apply { - body.inviteUsers(inviteUsers) - } + fun inviteUsers(inviteUsers: JsonField) = + apply { + body.inviteUsers(inviteUsers) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ - fun orgId(orgId: String?) = apply { body.orgId(orgId) } + fun orgId(orgId: String?) = + apply { + body.orgId(orgId) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the id of + * the organization. */ - fun orgId(orgId: JsonField) = apply { body.orgId(orgId) } + fun orgId(orgId: JsonField) = + apply { + body.orgId(orgId) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, or in case you want to + * explicitly assert the organization you are modifying, you may specify the name + * of the organization. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers?) = apply { body.removeUsers(removeUsers) } + fun removeUsers(removeUsers: RemoveUsers?) = + apply { + body.removeUsers(removeUsers) + } /** Users to remove from the organization */ fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) /** Users to remove from the organization */ - fun removeUsers(removeUsers: JsonField) = apply { - body.removeUsers(removeUsers) - } + fun removeUsers(removeUsers: JsonField) = + apply { + body.removeUsers(removeUsers) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationMemberUpdateParams = OrganizationMemberUpdateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** Users to invite to the organization */ @NoAutoDetect - class InviteUsers - @JsonCreator - private constructor( - @JsonProperty("emails") - @ExcludeMissing - private val emails: JsonField> = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("group_ids") - @ExcludeMissing - private val groupIds: JsonField> = JsonMissing.of(), - @JsonProperty("group_name") - @ExcludeMissing - private val groupName: JsonField = JsonMissing.of(), - @JsonProperty("group_names") - @ExcludeMissing - private val groupNames: JsonField> = JsonMissing.of(), - @JsonProperty("ids") - @ExcludeMissing - private val ids: JsonField> = JsonMissing.of(), - @JsonProperty("send_invite_emails") - @ExcludeMissing - private val sendInviteEmails: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class InviteUsers @JsonCreator private constructor( + @JsonProperty("emails") @ExcludeMissing private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("group_ids") @ExcludeMissing private val groupIds: JsonField> = JsonMissing.of(), + @JsonProperty("group_name") @ExcludeMissing private val groupName: JsonField = JsonMissing.of(), + @JsonProperty("group_names") @ExcludeMissing private val groupNames: JsonField> = JsonMissing.of(), + @JsonProperty("ids") @ExcludeMissing private val ids: JsonField> = JsonMissing.of(), + @JsonProperty("send_invite_emails") @ExcludeMissing private val sendInviteEmails: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Emails of users to invite */ @@ -560,28 +627,29 @@ private constructor( fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) /** Optional list of group ids to add newly-invited users to. */ - fun groupIds(): Optional> = - Optional.ofNullable(groupIds.getNullable("group_ids")) + fun groupIds(): Optional> = Optional.ofNullable(groupIds.getNullable("group_ids")) /** Singular form of group_names */ fun groupName(): Optional = Optional.ofNullable(groupName.getNullable("group_name")) /** Optional list of group names to add newly-invited users to. */ - fun groupNames(): Optional> = - Optional.ofNullable(groupNames.getNullable("group_names")) + fun groupNames(): Optional> = Optional.ofNullable(groupNames.getNullable("group_names")) /** Ids of existing users to invite */ fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(): Optional = - Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) + fun sendInviteEmails(): Optional = Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) /** Emails of users to invite */ - @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails + @JsonProperty("emails") + @ExcludeMissing + fun _emails(): JsonField> = emails /** Singular form of group_ids */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId(): JsonField = groupId /** Optional list of group ids to add newly-invited users to. */ @JsonProperty("group_ids") @@ -589,7 +657,9 @@ private constructor( fun _groupIds(): JsonField> = groupIds /** Singular form of group_names */ - @JsonProperty("group_name") @ExcludeMissing fun _groupName(): JsonField = groupName + @JsonProperty("group_name") + @ExcludeMissing + fun _groupName(): JsonField = groupName /** Optional list of group names to add newly-invited users to. */ @JsonProperty("group_names") @@ -597,7 +667,9 @@ private constructor( fun _groupNames(): JsonField> = groupNames /** Ids of existing users to invite */ - @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids + @JsonProperty("ids") + @ExcludeMissing + fun _ids(): JsonField> = ids /** If true, send invite emails to the users who wore actually added */ @JsonProperty("send_invite_emails") @@ -610,27 +682,29 @@ private constructor( private var validated: Boolean = false - fun validate(): InviteUsers = apply { - if (validated) { - return@apply + fun validate(): InviteUsers = + apply { + if (validated) { + return@apply + } + + emails() + groupId() + groupIds() + groupName() + groupNames() + ids() + sendInviteEmails() + validated = true } - emails() - groupId() - groupIds() - groupName() - groupNames() - ids() - sendInviteEmails() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [InviteUsers]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InviteUsers]. */ @@ -646,16 +720,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inviteUsers: InviteUsers) = apply { - emails = inviteUsers.emails.map { it.toMutableList() } - groupId = inviteUsers.groupId - groupIds = inviteUsers.groupIds.map { it.toMutableList() } - groupName = inviteUsers.groupName - groupNames = inviteUsers.groupNames.map { it.toMutableList() } - ids = inviteUsers.ids.map { it.toMutableList() } - sendInviteEmails = inviteUsers.sendInviteEmails - additionalProperties = inviteUsers.additionalProperties.toMutableMap() - } + internal fun from(inviteUsers: InviteUsers) = + apply { + emails = inviteUsers.emails.map { it.toMutableList() } + groupId = inviteUsers.groupId + groupIds = inviteUsers.groupIds.map { it.toMutableList() } + groupName = inviteUsers.groupName + groupNames = inviteUsers.groupNames.map { it.toMutableList() } + ids = inviteUsers.ids.map { it.toMutableList() } + sendInviteEmails = inviteUsers.sendInviteEmails + additionalProperties = inviteUsers.additionalProperties.toMutableMap() + } /** Emails of users to invite */ fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) @@ -664,17 +739,18 @@ private constructor( fun emails(emails: Optional>) = emails(emails.getOrNull()) /** Emails of users to invite */ - fun emails(emails: JsonField>) = apply { - this.emails = emails.map { it.toMutableList() } - } + fun emails(emails: JsonField>) = + apply { + this.emails = emails.map { it.toMutableList() } + } /** Emails of users to invite */ - fun addEmail(email: String) = apply { - emails = - (emails ?: JsonField.of(mutableListOf())).also { + fun addEmail(email: String) = + apply { + emails = (emails ?: JsonField.of(mutableListOf())).also { checkKnown("emails", it).add(email) } - } + } /** Singular form of group_ids */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) @@ -683,7 +759,10 @@ private constructor( fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** Singular form of group_ids */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + fun groupId(groupId: JsonField) = + apply { + this.groupId = groupId + } /** Optional list of group ids to add newly-invited users to. */ fun groupIds(groupIds: List?) = groupIds(JsonField.ofNullable(groupIds)) @@ -692,17 +771,18 @@ private constructor( fun groupIds(groupIds: Optional>) = groupIds(groupIds.getOrNull()) /** Optional list of group ids to add newly-invited users to. */ - fun groupIds(groupIds: JsonField>) = apply { - this.groupIds = groupIds.map { it.toMutableList() } - } + fun groupIds(groupIds: JsonField>) = + apply { + this.groupIds = groupIds.map { it.toMutableList() } + } /** Optional list of group ids to add newly-invited users to. */ - fun addGroupId(groupId: String) = apply { - groupIds = - (groupIds ?: JsonField.of(mutableListOf())).also { + fun addGroupId(groupId: String) = + apply { + groupIds = (groupIds ?: JsonField.of(mutableListOf())).also { checkKnown("groupIds", it).add(groupId) } - } + } /** Singular form of group_names */ fun groupName(groupName: String?) = groupName(JsonField.ofNullable(groupName)) @@ -711,7 +791,10 @@ private constructor( fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** Singular form of group_names */ - fun groupName(groupName: JsonField) = apply { this.groupName = groupName } + fun groupName(groupName: JsonField) = + apply { + this.groupName = groupName + } /** Optional list of group names to add newly-invited users to. */ fun groupNames(groupNames: List?) = groupNames(JsonField.ofNullable(groupNames)) @@ -720,17 +803,18 @@ private constructor( fun groupNames(groupNames: Optional>) = groupNames(groupNames.getOrNull()) /** Optional list of group names to add newly-invited users to. */ - fun groupNames(groupNames: JsonField>) = apply { - this.groupNames = groupNames.map { it.toMutableList() } - } + fun groupNames(groupNames: JsonField>) = + apply { + this.groupNames = groupNames.map { it.toMutableList() } + } /** Optional list of group names to add newly-invited users to. */ - fun addGroupName(groupName: String) = apply { - groupNames = - (groupNames ?: JsonField.of(mutableListOf())).also { + fun addGroupName(groupName: String) = + apply { + groupNames = (groupNames ?: JsonField.of(mutableListOf())).also { checkKnown("groupNames", it).add(groupName) } - } + } /** Ids of existing users to invite */ fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) @@ -739,70 +823,79 @@ private constructor( fun ids(ids: Optional>) = ids(ids.getOrNull()) /** Ids of existing users to invite */ - fun ids(ids: JsonField>) = apply { - this.ids = ids.map { it.toMutableList() } - } + fun ids(ids: JsonField>) = + apply { + this.ids = ids.map { it.toMutableList() } + } /** Ids of existing users to invite */ - fun addId(id: String) = apply { - ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } - } + fun addId(id: String) = + apply { + ids = (ids ?: JsonField.of(mutableListOf())).also { + checkKnown("ids", it).add(id) + } + } /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Boolean?) = - sendInviteEmails(JsonField.ofNullable(sendInviteEmails)) + fun sendInviteEmails(sendInviteEmails: Boolean?) = sendInviteEmails(JsonField.ofNullable(sendInviteEmails)) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Boolean) = - sendInviteEmails(sendInviteEmails as Boolean?) + fun sendInviteEmails(sendInviteEmails: Boolean) = sendInviteEmails(sendInviteEmails as Boolean?) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Optional) = - sendInviteEmails(sendInviteEmails.getOrNull()) + fun sendInviteEmails(sendInviteEmails: Optional) = sendInviteEmails(sendInviteEmails.getOrNull()) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: JsonField) = apply { - this.sendInviteEmails = sendInviteEmails - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun sendInviteEmails(sendInviteEmails: JsonField) = + apply { + this.sendInviteEmails = sendInviteEmails + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InviteUsers = InviteUsers( - (emails ?: JsonMissing.of()).map { it.toImmutable() }, - groupId, - (groupIds ?: JsonMissing.of()).map { it.toImmutable() }, - groupName, - (groupNames ?: JsonMissing.of()).map { it.toImmutable() }, - (ids ?: JsonMissing.of()).map { it.toImmutable() }, - sendInviteEmails, - additionalProperties.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + groupId, + (groupIds ?: JsonMissing.of()).map { it.toImmutable() }, + groupName, + (groupNames ?: JsonMissing.of()).map { it.toImmutable() }, + (ids ?: JsonMissing.of()).map { it.toImmutable() }, + sendInviteEmails, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InviteUsers && emails == other.emails && groupId == other.groupId && groupIds == other.groupIds && groupName == other.groupName && groupNames == other.groupNames && ids == other.ids && sendInviteEmails == other.sendInviteEmails && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InviteUsers && emails == other.emails && groupId == other.groupId && groupIds == other.groupIds && groupName == other.groupName && groupNames == other.groupNames && ids == other.ids && sendInviteEmails == other.sendInviteEmails && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -811,23 +904,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InviteUsers{emails=$emails, groupId=$groupId, groupIds=$groupIds, groupName=$groupName, groupNames=$groupNames, ids=$ids, sendInviteEmails=$sendInviteEmails, additionalProperties=$additionalProperties}" + override fun toString() = "InviteUsers{emails=$emails, groupId=$groupId, groupIds=$groupIds, groupName=$groupName, groupNames=$groupNames, ids=$ids, sendInviteEmails=$sendInviteEmails, additionalProperties=$additionalProperties}" } /** Users to remove from the organization */ @NoAutoDetect - class RemoveUsers - @JsonCreator - private constructor( - @JsonProperty("emails") - @ExcludeMissing - private val emails: JsonField> = JsonMissing.of(), - @JsonProperty("ids") - @ExcludeMissing - private val ids: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RemoveUsers @JsonCreator private constructor( + @JsonProperty("emails") @ExcludeMissing private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("ids") @ExcludeMissing private val ids: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Emails of users to remove */ @@ -837,10 +923,14 @@ private constructor( fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) /** Emails of users to remove */ - @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails + @JsonProperty("emails") + @ExcludeMissing + fun _emails(): JsonField> = emails /** Ids of users to remove */ - @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids + @JsonProperty("ids") + @ExcludeMissing + fun _ids(): JsonField> = ids @JsonAnyGetter @ExcludeMissing @@ -848,22 +938,24 @@ private constructor( private var validated: Boolean = false - fun validate(): RemoveUsers = apply { - if (validated) { - return@apply - } + fun validate(): RemoveUsers = + apply { + if (validated) { + return@apply + } - emails() - ids() - validated = true - } + emails() + ids() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [RemoveUsers]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RemoveUsers]. */ @@ -874,11 +966,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeUsers: RemoveUsers) = apply { - emails = removeUsers.emails.map { it.toMutableList() } - ids = removeUsers.ids.map { it.toMutableList() } - additionalProperties = removeUsers.additionalProperties.toMutableMap() - } + internal fun from(removeUsers: RemoveUsers) = + apply { + emails = removeUsers.emails.map { it.toMutableList() } + ids = removeUsers.ids.map { it.toMutableList() } + additionalProperties = removeUsers.additionalProperties.toMutableMap() + } /** Emails of users to remove */ fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) @@ -887,17 +980,18 @@ private constructor( fun emails(emails: Optional>) = emails(emails.getOrNull()) /** Emails of users to remove */ - fun emails(emails: JsonField>) = apply { - this.emails = emails.map { it.toMutableList() } - } + fun emails(emails: JsonField>) = + apply { + this.emails = emails.map { it.toMutableList() } + } /** Emails of users to remove */ - fun addEmail(email: String) = apply { - emails = - (emails ?: JsonField.of(mutableListOf())).also { + fun addEmail(email: String) = + apply { + emails = (emails ?: JsonField.of(mutableListOf())).also { checkKnown("emails", it).add(email) } - } + } /** Ids of users to remove */ fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) @@ -906,48 +1000,59 @@ private constructor( fun ids(ids: Optional>) = ids(ids.getOrNull()) /** Ids of users to remove */ - fun ids(ids: JsonField>) = apply { - this.ids = ids.map { it.toMutableList() } - } + fun ids(ids: JsonField>) = + apply { + this.ids = ids.map { it.toMutableList() } + } /** Ids of users to remove */ - fun addId(id: String) = apply { - ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addId(id: String) = + apply { + ids = (ids ?: JsonField.of(mutableListOf())).also { + checkKnown("ids", it).add(id) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveUsers = RemoveUsers( - (emails ?: JsonMissing.of()).map { it.toImmutable() }, - (ids ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + (ids ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveUsers && emails == other.emails && ids == other.ids && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveUsers && emails == other.emails && ids == other.ids && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -956,20 +1061,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RemoveUsers{emails=$emails, ids=$ids, additionalProperties=$additionalProperties}" + override fun toString() = "RemoveUsers{emails=$emails, ids=$ids, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationMemberUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationMemberUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "OrganizationMemberUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "OrganizationMemberUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 3d45ef35..75ac31bf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an organization object by its id */ -class OrganizationRetrieveParams -private constructor( +class OrganizationRetrieveParams private constructor( private val organizationId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Organization id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OrganizationRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [OrganizationRetrieveParams]. * * The following fields are required: + * * ```java * .organizationId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = apply { - organizationId = organizationRetrieveParams.organizationId - additionalHeaders = organizationRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = + apply { + organizationId = organizationRetrieveParams.organizationId + additionalHeaders = organizationRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationRetrieveParams.additionalQueryParams.toBuilder() + } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = + apply { + this.organizationId = organizationId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( - checkRequired("organizationId", organizationId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "organizationId", organizationId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 83efeac1..07a403a7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an organization object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class OrganizationUpdateParams -private constructor( +class OrganizationUpdateParams private constructor( private val organizationId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Organization id */ @@ -65,65 +65,58 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("api_url") - @ExcludeMissing - private val apiUrl: JsonField = JsonMissing.of(), - @JsonProperty("is_universal_api") - @ExcludeMissing - private val isUniversalApi: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("proxy_url") - @ExcludeMissing - private val proxyUrl: JsonField = JsonMissing.of(), - @JsonProperty("realtime_url") - @ExcludeMissing - private val realtimeUrl: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("api_url") @ExcludeMissing private val apiUrl: JsonField = JsonMissing.of(), + @JsonProperty("is_universal_api") @ExcludeMissing private val isUniversalApi: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("proxy_url") @ExcludeMissing private val proxyUrl: JsonField = JsonMissing.of(), + @JsonProperty("realtime_url") @ExcludeMissing private val realtimeUrl: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) - fun isUniversalApi(): Optional = - Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) /** Name of the organization */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) - fun realtimeUrl(): Optional = - Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) - @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl + @JsonProperty("api_url") + @ExcludeMissing + fun _apiUrl(): JsonField = apiUrl @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi(): JsonField = isUniversalApi /** Name of the organization */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl + @JsonProperty("proxy_url") + @ExcludeMissing + fun _proxyUrl(): JsonField = proxyUrl @JsonProperty("realtime_url") @ExcludeMissing @@ -135,25 +128,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + apiUrl() + isUniversalApi() + name() + proxyUrl() + realtimeUrl() + validated = true } - apiUrl() - isUniversalApi() - name() - proxyUrl() - realtimeUrl() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -167,32 +162,35 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - apiUrl = body.apiUrl - isUniversalApi = body.isUniversalApi - name = body.name - proxyUrl = body.proxyUrl - realtimeUrl = body.realtimeUrl - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + apiUrl = body.apiUrl + isUniversalApi = body.isUniversalApi + name = body.name + proxyUrl = body.proxyUrl + realtimeUrl = body.realtimeUrl + additionalProperties = body.additionalProperties.toMutableMap() + } fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } + fun apiUrl(apiUrl: JsonField) = + apply { + this.apiUrl = apiUrl + } - fun isUniversalApi(isUniversalApi: Boolean?) = - isUniversalApi(JsonField.ofNullable(isUniversalApi)) + fun isUniversalApi(isUniversalApi: Boolean?) = isUniversalApi(JsonField.ofNullable(isUniversalApi)) fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = apply { - this.isUniversalApi = isUniversalApi - } + fun isUniversalApi(isUniversalApi: JsonField) = + apply { + this.isUniversalApi = isUniversalApi + } /** Name of the organization */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -201,58 +199,72 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the organization */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: JsonField) = + apply { + this.proxyUrl = proxyUrl + } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = apply { - this.realtimeUrl = realtimeUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun realtimeUrl(realtimeUrl: JsonField) = + apply { + this.realtimeUrl = realtimeUrl + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalProperties.toImmutable(), + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -261,8 +273,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + override fun toString() = "Body{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -270,14 +281,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OrganizationUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [OrganizationUpdateParams]. * * The following fields are required: + * * ```java * .organizationId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [OrganizationUpdateParams]. */ @@ -290,190 +304,256 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationUpdateParams: OrganizationUpdateParams) = apply { - organizationId = organizationUpdateParams.organizationId - body = organizationUpdateParams.body.toBuilder() - additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationUpdateParams: OrganizationUpdateParams) = + apply { + organizationId = organizationUpdateParams.organizationId + body = organizationUpdateParams.body.toBuilder() + additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() + } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = + apply { + this.organizationId = organizationId + } - fun apiUrl(apiUrl: String?) = apply { body.apiUrl(apiUrl) } + fun apiUrl(apiUrl: String?) = + apply { + body.apiUrl(apiUrl) + } fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = apply { body.apiUrl(apiUrl) } + fun apiUrl(apiUrl: JsonField) = + apply { + body.apiUrl(apiUrl) + } - fun isUniversalApi(isUniversalApi: Boolean?) = apply { body.isUniversalApi(isUniversalApi) } + fun isUniversalApi(isUniversalApi: Boolean?) = + apply { + body.isUniversalApi(isUniversalApi) + } fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = - isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = apply { - body.isUniversalApi(isUniversalApi) - } + fun isUniversalApi(isUniversalApi: JsonField) = + apply { + body.isUniversalApi(isUniversalApi) + } /** Name of the organization */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the organization */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the organization */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun proxyUrl(proxyUrl: String?) = apply { body.proxyUrl(proxyUrl) } + fun proxyUrl(proxyUrl: String?) = + apply { + body.proxyUrl(proxyUrl) + } fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = apply { body.proxyUrl(proxyUrl) } + fun proxyUrl(proxyUrl: JsonField) = + apply { + body.proxyUrl(proxyUrl) + } - fun realtimeUrl(realtimeUrl: String?) = apply { body.realtimeUrl(realtimeUrl) } + fun realtimeUrl(realtimeUrl: String?) = + apply { + body.realtimeUrl(realtimeUrl) + } fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = apply { body.realtimeUrl(realtimeUrl) } + fun realtimeUrl(realtimeUrl: JsonField) = + apply { + body.realtimeUrl(realtimeUrl) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationUpdateParams = OrganizationUpdateParams( - checkRequired("organizationId", organizationId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "organizationId", organizationId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "OrganizationUpdateParams{organizationId=$organizationId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "OrganizationUpdateParams{organizationId=$organizationId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index c1bb28cb..932a8cd1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -21,17 +21,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class PatchOrganizationMembersOutput -@JsonCreator -private constructor( +class PatchOrganizationMembersOutput @JsonCreator private constructor( @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("send_email_error") - @ExcludeMissing - private val sendEmailError: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), + @JsonProperty("send_email_error") @ExcludeMissing private val sendEmailError: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the org that was modified. */ @@ -40,20 +35,23 @@ private constructor( fun status(): Status = status.getRequired("status") /** - * If invite emails failed to send for some reason, the patch operation will still complete, but - * we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ - fun sendEmailError(): Optional = - Optional.ofNullable(sendEmailError.getNullable("send_email_error")) + fun sendEmailError(): Optional = Optional.ofNullable(sendEmailError.getNullable("send_email_error")) /** The id of the org that was modified. */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status /** - * If invite emails failed to send for some reason, the patch operation will still complete, but - * we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ @JsonProperty("send_email_error") @ExcludeMissing @@ -65,16 +63,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PatchOrganizationMembersOutput = apply { - if (validated) { - return@apply - } + fun validate(): PatchOrganizationMembersOutput = + apply { + if (validated) { + return@apply + } - orgId() - status() - sendEmailError() - validated = true - } + orgId() + status() + sendEmailError() + validated = true + } fun toBuilder() = Builder().from(this) @@ -85,12 +84,14 @@ private constructor( * [PatchOrganizationMembersOutput]. * * The following fields are required: + * * ```java * .orgId() * .status() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PatchOrganizationMembersOutput]. */ @@ -102,85 +103,105 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = apply { - orgId = patchOrganizationMembersOutput.orgId - status = patchOrganizationMembersOutput.status - sendEmailError = patchOrganizationMembersOutput.sendEmailError - additionalProperties = - patchOrganizationMembersOutput.additionalProperties.toMutableMap() - } + internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = + apply { + orgId = patchOrganizationMembersOutput.orgId + status = patchOrganizationMembersOutput.status + sendEmailError = patchOrganizationMembersOutput.sendEmailError + additionalProperties = patchOrganizationMembersOutput.additionalProperties.toMutableMap() + } /** The id of the org that was modified. */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** The id of the org that was modified. */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } fun status(status: Status) = status(JsonField.of(status)) - fun status(status: JsonField) = apply { this.status = status } + fun status(status: JsonField) = + apply { + this.status = status + } /** - * If invite emails failed to send for some reason, the patch operation will still complete, - * but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ - fun sendEmailError(sendEmailError: String?) = - sendEmailError(JsonField.ofNullable(sendEmailError)) + fun sendEmailError(sendEmailError: String?) = sendEmailError(JsonField.ofNullable(sendEmailError)) /** - * If invite emails failed to send for some reason, the patch operation will still complete, - * but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ - fun sendEmailError(sendEmailError: Optional) = - sendEmailError(sendEmailError.getOrNull()) + fun sendEmailError(sendEmailError: Optional) = sendEmailError(sendEmailError.getOrNull()) /** - * If invite emails failed to send for some reason, the patch operation will still complete, - * but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still + * complete, but we will return an error message here */ - fun sendEmailError(sendEmailError: JsonField) = apply { - this.sendEmailError = sendEmailError - } + fun sendEmailError(sendEmailError: JsonField) = + apply { + this.sendEmailError = sendEmailError + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PatchOrganizationMembersOutput = PatchOrganizationMembersOutput( - checkRequired("orgId", orgId), - checkRequired("status", status), - sendEmailError, - additionalProperties.toImmutable(), + checkRequired( + "orgId", orgId + ), + checkRequired( + "status", status + ), + sendEmailError, + additionalProperties.toImmutable(), ) } - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + class Status @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -191,16 +212,18 @@ private constructor( /** An enum containing [Status]'s known values. */ enum class Known { - SUCCESS + SUCCESS, } /** * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Status] 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 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 { @@ -210,11 +233,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -225,11 +248,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -240,23 +263,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -265,11 +285,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PatchOrganizationMembersOutput && orgId == other.orgId && status == other.status && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PatchOrganizationMembersOutput && orgId == other.orgId && status == other.status && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -278,6 +298,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PatchOrganizationMembersOutput{orgId=$orgId, status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + override fun toString() = "PatchOrganizationMembersOutput{orgId=$orgId, status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 8da4413e..698f529c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -20,25 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Project -@JsonCreator -private constructor( +class Project @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("settings") - @ExcludeMissing - private val settings: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("settings") @ExcludeMissing private val settings: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the project */ @@ -54,36 +45,46 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of project deletion, or null if the project is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - fun settings(): Optional = - Optional.ofNullable(settings.getNullable("settings")) + fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) /** Identifies the user who created the project */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the project */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Date of project creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of project deletion, or null if the project is still active */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonField = settings + @JsonProperty("settings") + @ExcludeMissing + fun _settings(): JsonField = settings /** Identifies the user who created the project */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -91,21 +92,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Project = apply { - if (validated) { - return@apply + fun validate(): Project = + apply { + if (validated) { + return@apply + } + + id() + name() + orgId() + created() + deletedAt() + settings().ifPresent { it.validate() } + userId() + validated = true } - id() - name() - orgId() - created() - deletedAt() - settings().ifPresent { it.validate() } - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -114,13 +116,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Project]. * * The following fields are required: + * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Project]. */ @@ -136,34 +140,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(project: Project) = apply { - id = project.id - name = project.name - orgId = project.orgId - created = project.created - deletedAt = project.deletedAt - settings = project.settings - userId = project.userId - additionalProperties = project.additionalProperties.toMutableMap() - } + internal fun from(project: Project) = + apply { + id = project.id + name = project.name + orgId = project.orgId + created = project.created + deletedAt = project.deletedAt + settings = project.settings + userId = project.userId + additionalProperties = project.additionalProperties.toMutableMap() + } /** Unique identifier for the project */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique id for the organization that the project belongs under */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Date of project creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -172,7 +186,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of project deletion, or null if the project is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -181,13 +198,19 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of project deletion, or null if the project is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) fun settings(settings: Optional) = settings(settings.getOrNull()) - fun settings(settings: JsonField) = apply { this.settings = settings } + fun settings(settings: JsonField) = + apply { + this.settings = settings + } /** Identifies the user who created the project */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -196,46 +219,62 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the project */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Project = Project( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("orgId", orgId), - created, - deletedAt, - settings, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + created, + deletedAt, + settings, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Project && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && settings == other.settings && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Project && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && settings == other.settings && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -244,6 +283,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Project{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, settings=$settings, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Project{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, settings=$settings, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 6d92a603..3b391d17 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -22,23 +22,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project. If there is an existing project with the same name as the one specified in - * the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the + * one specified in the request, will return the existing project unmodified */ -class ProjectCreateParams -private constructor( +class ProjectCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(): Optional = body.orgName() @@ -46,9 +46,9 @@ private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -58,45 +58,44 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -104,15 +103,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - orgName() - validated = true - } + name() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -122,11 +122,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -137,68 +139,88 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) + Body( + checkRequired( + "name", name + ), + orgName, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -207,8 +229,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -219,11 +240,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectCreateParams]. */ @@ -235,174 +258,220 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectCreateParams: ProjectCreateParams) = apply { - body = projectCreateParams.body.toBuilder() - additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectCreateParams: ProjectCreateParams) = + apply { + body = projectCreateParams.body.toBuilder() + additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the project belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectCreateParams = ProjectCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 969df0a9..68da5858 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project object by its id */ -class ProjectDeleteParams -private constructor( +class ProjectDeleteParams private constructor( private val projectId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Project id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectDeleteParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectDeleteParams: ProjectDeleteParams) = apply { - projectId = projectDeleteParams.projectId - additionalHeaders = projectDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = projectDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectDeleteParams: ProjectDeleteParams) = + apply { + projectId = projectDeleteParams.projectId + additionalHeaders = projectDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectDeleteParams.additionalBodyProperties.toMutableMap() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectDeleteParams = ProjectDeleteParams( - checkRequired("projectId", projectId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "projectId", projectId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index d970247c..c4f4483f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.ProjectService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all projects. The projects are sorted by creation date, with the most recently-created - * projects coming first + * List out all projects. The projects are sorted by creation date, with the most + * recently-created projects coming first */ -class ProjectListPage -private constructor( +class ProjectListPage private constructor( private val projectsService: ProjectService, private val params: ProjectListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListPage && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectListPage && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ - override fun toString() = - "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" + override fun toString() = "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectsService.list(it) } + return getNextPageParams().map { projectsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -84,16 +74,18 @@ private constructor( @JvmStatic fun of(projectsService: ProjectService, params: ProjectListParams, response: Response) = - ProjectListPage(projectsService, params, response) + ProjectListPage( + projectsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -107,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ProjectListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -143,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectListPage) : Iterable { + class AutoPager( + private val firstPage: ProjectListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 2ef21803..324a224f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.ProjectServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all projects. The projects are sorted by creation date, with the most recently-created - * projects coming first + * List out all projects. The projects are sorted by creation date, with the most + * recently-created projects coming first */ -class ProjectListPageAsync -private constructor( +class ProjectListPageAsync private constructor( private val projectsService: ProjectServiceAsync, private val params: ProjectListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListPageAsync && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectListPageAsync && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ - override fun toString() = - "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" + override fun toString() = "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { projectsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + projectsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,20 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectsService: ProjectServiceAsync, - params: ProjectListParams, - response: Response, - ) = ProjectListPageAsync(projectsService, params, response) + fun of(projectsService: ProjectServiceAsync, params: ProjectListParams, response: Response) = + ProjectListPageAsync( + projectsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -112,34 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** Returns a mutable builder for constructing an instance of [ProjectListPageAsync]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ProjectListPageAsync]. + */ + @JvmStatic + fun builder() = Builder() } class Builder { @@ -148,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectListPageAsync) { + class AutoPager( + private val firstPage: ProjectListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Project) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Project) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index c011f50b..539d3cbe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all projects. The projects are sorted by creation date, with the most recently-created - * projects coming first + * List out all projects. The projects are sorted by creation date, with the most + * recently-created projects coming first */ -class ProjectListParams -private constructor( +class ProjectListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -36,20 +35,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,51 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ProjectListParams = builder().build() + @JvmStatic + fun none(): ProjectListParams = builder().build() /** Returns a mutable builder for constructing an instance of [ProjectListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectListParams]. */ @@ -113,61 +139,71 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectListParams: ProjectListParams) = apply { - endingBefore = projectListParams.endingBefore - ids = projectListParams.ids - limit = projectListParams.limit - orgName = projectListParams.orgName - projectName = projectListParams.projectName - startingAfter = projectListParams.startingAfter - additionalHeaders = projectListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectListParams: ProjectListParams) = + apply { + endingBefore = projectListParams.endingBefore + ids = projectListParams.ids + limit = projectListParams.limit + orgName = projectListParams.orgName + projectName = projectListParams.projectName + startingAfter = projectListParams.startingAfter + additionalHeaders = projectListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -176,13 +212,19 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -190,144 +232,172 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectListParams = ProjectListParams( - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -345,19 +415,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -372,12 +442,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -387,60 +462,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index ea2b6b82..e82d4edf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of project logs events */ -class ProjectLogFeedbackParams -private constructor( +class ProjectLogFeedbackParams private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("feedback") - @ExcludeMissing - private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of project logs feedback items */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - feedback().forEach { it.validate() } - validated = true - } + feedback().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of project logs feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of project logs feedback items */ - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = + apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of project logs feedback items */ - fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { - this.feedback = - (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackProjectLogsItem) = + apply { + this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("feedback", feedback).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "feedback", feedback + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -174,8 +184,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -183,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectLogFeedbackParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectLogFeedbackParams]. * * The following fields are required: + * * ```java * .projectId() * .feedback() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogFeedbackParams]. */ @@ -204,163 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = apply { - projectId = projectLogFeedbackParams.projectId - body = projectLogFeedbackParams.body.toBuilder() - additionalHeaders = projectLogFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = + apply { + projectId = projectLogFeedbackParams.projectId + body = projectLogFeedbackParams.body.toBuilder() + additionalHeaders = projectLogFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFeedbackParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** A list of project logs feedback items */ - fun feedback(feedback: List) = apply { body.feedback(feedback) } + fun feedback(feedback: List) = + apply { + body.feedback(feedback) + } /** A list of project logs feedback items */ - fun feedback(feedback: JsonField>) = apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = + apply { + body.feedback(feedback) + } /** A list of project logs feedback items */ - fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { body.addFeedback(feedback) } + fun addFeedback(feedback: FeedbackProjectLogsItem) = + apply { + body.addFeedback(feedback) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( - checkRequired("projectId", projectId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectLogFeedbackParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectLogFeedbackParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 1d82f560..6576d624 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -12,12 +12,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same + * path, but with the parameters in the URL query rather than in the request body. + * For more complex queries, use the `POST /btql` endpoint. */ -class ProjectLogFetchParams -private constructor( +class ProjectLogFetchParams private constructor( private val projectId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -25,6 +24,7 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -33,52 +33,55 @@ private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -89,20 +92,36 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.maxRootSpanId?.let { + queryParams.put( + "max_root_span_id", listOf(it.toString()) + ) + } + this.maxXactId?.let { + queryParams.put( + "max_xact_id", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -110,14 +129,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectLogFetchParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectLogFetchParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogFetchParams]. */ @@ -133,263 +155,310 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFetchParams: ProjectLogFetchParams) = apply { - projectId = projectLogFetchParams.projectId - limit = projectLogFetchParams.limit - maxRootSpanId = projectLogFetchParams.maxRootSpanId - maxXactId = projectLogFetchParams.maxXactId - version = projectLogFetchParams.version - additionalHeaders = projectLogFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFetchParams: ProjectLogFetchParams) = + apply { + projectId = projectLogFetchParams.projectId + limit = projectLogFetchParams.limit + maxRootSpanId = projectLogFetchParams.maxRootSpanId + maxXactId = projectLogFetchParams.maxXactId + version = projectLogFetchParams.version + additionalHeaders = projectLogFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFetchParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String?) = + apply { + this.maxXactId = maxXactId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFetchParams = ProjectLogFetchParams( - checkRequired("projectId", projectId), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 4eb11877..aa9256e2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -22,138 +22,146 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use the - * `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ -class ProjectLogFetchPostParams -private constructor( +class ProjectLogFetchPostParams private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ fun projectId(): String = projectId /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun _version(): JsonField = body._version() @@ -163,169 +171,168 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("cursor") - @ExcludeMissing - private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") - @ExcludeMissing - private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") - @ExcludeMissing - private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") - @ExcludeMissing - private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - private val version: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(): Optional = - Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(): Optional = - Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + @JsonProperty("limit") + @ExcludeMissing + fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") + @ExcludeMissing + fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonProperty("version") + @ExcludeMissing + fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -333,25 +340,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true } - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -365,261 +374,284 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = + apply { + this.cursor = cursor + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { this.limit = limit } + fun limit(limit: JsonField) = + apply { + this.limit = limit + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: JsonField) = + apply { + this.maxXactId = maxXactId + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = + apply { + this.version = version + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -628,8 +660,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -637,14 +668,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectLogFetchPostParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectLogFetchPostParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogFetchPostParams]. */ @@ -657,358 +691,431 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = apply { - projectId = projectLogFetchPostParams.projectId - body = projectLogFetchPostParams.body.toBuilder() - additionalHeaders = projectLogFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = + apply { + projectId = projectLogFetchPostParams.projectId + body = projectLogFetchPostParams.body.toBuilder() + additionalHeaders = projectLogFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFetchPostParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: String?) = apply { body.cursor(cursor) } + fun cursor(cursor: String?) = + apply { + body.cursor(cursor) + } /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order + * from latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * The string can be obtained directly from the `cursor` property of the previous + * fetch query */ - fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } + fun cursor(cursor: JsonField) = + apply { + body.cursor(cursor) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: Long?) = apply { body.limit(limit) } + fun limit(limit: Long?) = + apply { + body.limit(limit) + } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Fetch queries may be paginated if the total result size is expected to be large + * (e.g. project_logs which accumulate over a long time). Note that fetch queries + * only support pagination in descending time order (from latest to earliest + * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier + * pages, except with an earlier `_xact_id`. This happens because pagination occurs + * over the whole version history of the event log. You will most likely want to + * exclude any such duplicate, outdated rows (by `id`) from your combined result + * set. + * + * The `limit` parameter controls the number of full traces to return. So you may + * end up with more individual rows than the specified limit if you are fetching + * events containing traces. */ - fun limit(limit: JsonField) = apply { body.limit(limit) } + fun limit(limit: JsonField) = + apply { + body.limit(limit) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } + fun maxRootSpanId(maxRootSpanId: String?) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = - maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = + apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: String?) = + apply { + body.maxXactId(maxXactId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the minimum (earliest) + * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` + * for an overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } + fun maxXactId(maxXactId: JsonField) = + apply { + body.maxXactId(maxXactId) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: String?) = apply { body.version(version) } + fun version(version: String?) = + apply { + body.version(version) + } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You + * can use the `max_xact_id` returned by a past fetch as the version to reproduce + * that exact fetch. */ - fun version(version: JsonField) = apply { body.version(version) } + fun version(version: JsonField) = + apply { + body.version(version) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFetchPostParams = ProjectLogFetchPostParams( - checkRequired("projectId", projectId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectLogFetchPostParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 00032977..d3e46403 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the project logs */ -class ProjectLogInsertParams -private constructor( +class ProjectLogInsertParams private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -44,28 +44,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("events") - @ExcludeMissing - private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of project logs events to insert */ @@ -82,14 +79,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - events().forEach { it.validate() } - validated = true - } + events().forEach { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -99,11 +97,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,59 +113,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of project logs events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of project logs events to insert */ - fun events(events: JsonField>) = apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = + apply { + this.events = events.map { it.toMutableList() } + } /** A list of project logs events to insert */ - fun addEvent(event: InsertProjectLogsEvent) = apply { - events = - (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertProjectLogsEvent) = + apply { + events = (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("events", events).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "events", events + ).map { it.toImmutable() }, additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -182,15 +192,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectLogInsertParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectLogInsertParams]. * * The following fields are required: + * * ```java * .projectId() * .events() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogInsertParams]. */ @@ -203,161 +216,209 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogInsertParams: ProjectLogInsertParams) = apply { - projectId = projectLogInsertParams.projectId - body = projectLogInsertParams.body.toBuilder() - additionalHeaders = projectLogInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogInsertParams: ProjectLogInsertParams) = + apply { + projectId = projectLogInsertParams.projectId + body = projectLogInsertParams.body.toBuilder() + additionalHeaders = projectLogInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogInsertParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** A list of project logs events to insert */ - fun events(events: List) = apply { body.events(events) } + fun events(events: List) = + apply { + body.events(events) + } /** A list of project logs events to insert */ - fun events(events: JsonField>) = apply { body.events(events) } + fun events(events: JsonField>) = + apply { + body.events(events) + } /** A list of project logs events to insert */ - fun addEvent(event: InsertProjectLogsEvent) = apply { body.addEvent(event) } + fun addEvent(event: InsertProjectLogsEvent) = + apply { + body.addEvent(event) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogInsertParams = ProjectLogInsertParams( - checkRequired("projectId", projectId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectLogInsertParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectLogInsertParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 94a6ee65..f1bc7509 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -23,71 +23,43 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectLogsEvent -@JsonCreator -private constructor( +class ProjectLogsEvent @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") - @ExcludeMissing - private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") - @ExcludeMissing - private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - private val context: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") - @ExcludeMissing - private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") - @ExcludeMissing - private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") - @ExcludeMissing - private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the project logs (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the project logs (see the + * `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -107,51 +79,62 @@ private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different project logs events together as part + * of a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error + @JsonProperty("error") + @ExcludeMissing + fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected(): JsonValue = expected - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -159,113 +142,147 @@ private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output + @JsonProperty("output") + @ExcludeMissing + fun _output(): JsonValue = output /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = - Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * An array of the parent `span_ids` of this project logs event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ - fun spanParents(): Optional> = - Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the project logs (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the project logs (see the + * `version` parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId(): JsonField = logId /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the project */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** A unique identifier for the trace this project logs event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different project logs events together as part + * of a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId(): JsonField = spanId /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context /** Whether this span is a root span */ - @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") + @ExcludeMissing + fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -273,15 +290,18 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * An array of the parent `span_ids` of this project logs event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -289,30 +309,31 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectLogsEvent = apply { - if (validated) { - return@apply - } + fun validate(): ProjectLogsEvent = + apply { + if (validated) { + return@apply + } - id() - _xactId() - created() - logId() - orgId() - projectId() - rootSpanId() - spanId() - context().ifPresent { it.validate() } - isRoot() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanParents() - tags() - validated = true - } + id() + _xactId() + created() + logId() + orgId() + projectId() + rootSpanId() + spanId() + context().ifPresent { it.validate() } + isRoot() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanParents() + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -322,6 +343,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectLogsEvent]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -333,7 +355,8 @@ private constructor( * .spanId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectLogsEvent]. */ @@ -363,139 +386,184 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogsEvent: ProjectLogsEvent) = apply { - id = projectLogsEvent.id - _xactId = projectLogsEvent._xactId - created = projectLogsEvent.created - logId = projectLogsEvent.logId - orgId = projectLogsEvent.orgId - projectId = projectLogsEvent.projectId - rootSpanId = projectLogsEvent.rootSpanId - spanId = projectLogsEvent.spanId - context = projectLogsEvent.context - error = projectLogsEvent.error - expected = projectLogsEvent.expected - input = projectLogsEvent.input - isRoot = projectLogsEvent.isRoot - metadata = projectLogsEvent.metadata - metrics = projectLogsEvent.metrics - origin = projectLogsEvent.origin - output = projectLogsEvent.output - scores = projectLogsEvent.scores - spanAttributes = projectLogsEvent.spanAttributes - spanParents = projectLogsEvent.spanParents.map { it.toMutableList() } - tags = projectLogsEvent.tags.map { it.toMutableList() } - additionalProperties = projectLogsEvent.additionalProperties.toMutableMap() - } + internal fun from(projectLogsEvent: ProjectLogsEvent) = + apply { + id = projectLogsEvent.id + _xactId = projectLogsEvent._xactId + created = projectLogsEvent.created + logId = projectLogsEvent.logId + orgId = projectLogsEvent.orgId + projectId = projectLogsEvent.projectId + rootSpanId = projectLogsEvent.rootSpanId + spanId = projectLogsEvent.spanId + context = projectLogsEvent.context + error = projectLogsEvent.error + expected = projectLogsEvent.expected + input = projectLogsEvent.input + isRoot = projectLogsEvent.isRoot + metadata = projectLogsEvent.metadata + metrics = projectLogsEvent.metrics + origin = projectLogsEvent.origin + output = projectLogsEvent.output + scores = projectLogsEvent.scores + spanAttributes = projectLogsEvent.spanAttributes + spanParents = projectLogsEvent.spanParents.map { it.toMutableList() } + tags = projectLogsEvent.tags.map { it.toMutableList() } + additionalProperties = projectLogsEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the project logs (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the project logs (see the + * `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the project logs (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the project logs (see the + * `version` parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the project logs event was created */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** A literal 'g' which identifies the log as a project log */ fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'g' which identifies the log as a project log */ - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = + apply { + this.logId = logId + } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique id for the organization that the project belongs under */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the project */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** A unique identifier for the trace this project logs event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this project logs event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = + apply { + this.rootSpanId = rootSpanId + } /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different project logs events together as part + * of a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * A unique identifier used to link different project logs events together as part + * of a full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = + apply { + this.spanId = spanId + } /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = + apply { + this.context = context + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = + apply { + this.error = error + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = + apply { + this.expected = expected + } /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). */ - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = + apply { + this.input = input + } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -507,55 +575,64 @@ private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } + fun isRoot(isRoot: JsonField) = + apply { + this.isRoot = isRoot + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -564,97 +641,109 @@ private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = + apply { + this.output = output + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = - spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = - spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = + apply { + this.spanAttributes = spanAttributes + } /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = + apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * An array of the parent `span_ids` of this project logs event. This should be + * empty for the root span of a trace, and should most often contain just one + * parent element for subspans */ - fun addSpanParent(spanParent: String) = apply { - spanParents = - (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = + apply { + spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -663,73 +752,104 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectLogsEvent = ProjectLogsEvent( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("created", created), - checkRequired("logId", logId), - checkRequired("orgId", orgId), - checkRequired("projectId", projectId), - checkRequired("rootSpanId", rootSpanId), - checkRequired("spanId", spanId), - context, - error, - expected, - input, - isRoot, - metadata, - metrics, - origin, - output, - scores, - spanAttributes, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "created", created + ), + checkRequired( + "logId", logId + ), + checkRequired( + "orgId", orgId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "rootSpanId", rootSpanId + ), + checkRequired( + "spanId", spanId + ), + context, + error, + expected, + input, + isRoot, + metadata, + metrics, + origin, + output, + scores, + spanAttributes, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** A literal 'g' which identifies the log as a project log */ - class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { + class LogId @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -740,16 +860,18 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - G + G, } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] 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 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 { @@ -759,11 +881,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -774,11 +896,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -789,23 +911,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -814,38 +933,28 @@ private constructor( } /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ @NoAutoDetect - class Context - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Context @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = - Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = - Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = - Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -868,23 +977,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Context = apply { - if (validated) { - return@apply - } + fun validate(): Context = + apply { + if (validated) { + return@apply + } - callerFilename() - callerFunctionname() - callerLineno() - validated = true - } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Context]. */ @@ -896,38 +1007,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = + apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String?) = - callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: Optional) = - callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = + apply { + this.callerFilename = callerFilename + } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String?) = - callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: Optional) = - callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = + apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -939,44 +1049,52 @@ private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = + apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -985,23 +1103,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1010,20 +1125,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1032,38 +1149,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1076,38 +1201,22 @@ private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonProperty("caller_filename") - @ExcludeMissing - private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") - @ExcludeMissing - private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") - @ExcludeMissing - private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") - @ExcludeMissing - private val completionTokens: JsonField = JsonMissing.of(), + class Metrics @JsonCreator private constructor( + @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") - @ExcludeMissing - private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") - @ExcludeMissing - private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") - @ExcludeMissing - private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** This metric is deprecated */ @@ -1121,31 +1230,31 @@ private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(): Optional = - Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - fun promptTokens(): Optional = - Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1153,35 +1262,41 @@ private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ - @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + @JsonProperty("end") + @ExcludeMissing + fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + @JsonProperty("start") + @ExcludeMissing + fun _start(): JsonField = start /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1189,25 +1304,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true - } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1224,133 +1341,144 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = + apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = + apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = + apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } + fun callerLineno(callerLineno: JsonValue) = + apply { + this.callerLineno = callerLineno + } /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long?) = - completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Long) = - completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: Optional) = - completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = + apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * A unix timestamp recording when the section of code which produced the project + * logs event finished */ - fun end(end: JsonField) = apply { this.end = end } + fun end(end: JsonField) = + apply { + this.end = end + } /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = + apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * A unix timestamp recording when the section of code which produced the project + * logs event started */ - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = + apply { + this.start = start + } /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1362,47 +1490,57 @@ private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = + apply { + this.tokens = tokens + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1411,27 +1549,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin - @JsonCreator - private constructor( + class Origin @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** ID of the original event. */ @@ -1447,13 +1576,19 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -1466,17 +1601,18 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - id() - _xactId() - objectId() - objectType() - validated = true - } + id() + _xactId() + objectId() + objectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1486,6 +1622,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -1493,7 +1630,8 @@ private constructor( * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -1506,82 +1644,111 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : - Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1614,9 +1781,11 @@ private constructor( * 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 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 { @@ -1637,8 +1806,8 @@ private constructor( * 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. + * 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) { @@ -1658,7 +1827,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1677,20 +1846,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1699,11 +1865,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1712,25 +1878,23 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -1739,20 +1903,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1761,38 +1927,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1805,11 +1979,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && logId == other.logId && orgId == other.orgId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && logId == other.logId && orgId == other.orgId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1818,6 +1992,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, logId=$logId, orgId=$orgId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, logId=$logId, orgId=$orgId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 6694a858..d66db835 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project object by its id */ -class ProjectRetrieveParams -private constructor( +class ProjectRetrieveParams private constructor( private val projectId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectRetrieveParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectRetrieveParams: ProjectRetrieveParams) = apply { - projectId = projectRetrieveParams.projectId - additionalHeaders = projectRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectRetrieveParams: ProjectRetrieveParams) = + apply { + projectId = projectRetrieveParams.projectId + additionalHeaders = projectRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectRetrieveParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectRetrieveParams = ProjectRetrieveParams( - checkRequired("projectId", projectId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 6144049c..2ebce579 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 @@ -31,38 +31,24 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** A project score is a user-configured score, which can be manually-labeled through the UI */ +/** + * A project score is a user-configured score, which can be manually-labeled + * through the UI + */ @NoAutoDetect -class ProjectScore -@JsonCreator -private constructor( +class ProjectScore @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") - @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("categories") - @ExcludeMissing - private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - private val config: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the project score */ @@ -80,8 +66,7 @@ private constructor( fun userId(): String = userId.getRequired("user_id") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = - Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) fun config(): Optional = Optional.ofNullable(config.getNullable("config")) @@ -89,41 +74,64 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ fun position(): Optional = Optional.ofNullable(position.getNullable("position")) /** Unique identifier for the project score */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @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 + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @ExcludeMissing fun _categories(): JsonField = categories - @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + @JsonProperty("config") + @ExcludeMissing + fun _config(): JsonField = config /** Date of project score creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Textual description of the project score */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position @JsonAnyGetter @ExcludeMissing @@ -131,23 +139,24 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScore = apply { - if (validated) { - return@apply - } + fun validate(): ProjectScore = + apply { + if (validated) { + return@apply + } - id() - name() - projectId() - scoreType() - userId() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - created() - description() - position() - validated = true - } + id() + name() + projectId() + scoreType() + userId() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + created() + description() + position() + validated = true + } fun toBuilder() = Builder().from(this) @@ -157,6 +166,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectScore]. * * The following fields are required: + * * ```java * .id() * .name() @@ -165,7 +175,8 @@ private constructor( * .userId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScore]. */ @@ -184,57 +195,75 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScore: ProjectScore) = apply { - id = projectScore.id - name = projectScore.name - projectId = projectScore.projectId - scoreType = projectScore.scoreType - userId = projectScore.userId - categories = projectScore.categories - config = projectScore.config - created = projectScore.created - description = projectScore.description - position = projectScore.position - additionalProperties = projectScore.additionalProperties.toMutableMap() - } + internal fun from(projectScore: ProjectScore) = + apply { + id = projectScore.id + name = projectScore.name + projectId = projectScore.projectId + scoreType = projectScore.scoreType + userId = projectScore.userId + categories = projectScore.categories + config = projectScore.config + created = projectScore.created + description = projectScore.description + position = projectScore.position + additionalProperties = projectScore.additionalProperties.toMutableMap() + } /** Unique identifier for the project score */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project score */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = 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)) - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { this.categories = categories } + fun categories(categories: JsonField) = + apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) @@ -243,14 +272,16 @@ private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = + apply { + this.config = config + } /** Date of project score creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -259,7 +290,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project score creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -268,64 +302,100 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ fun position(position: String?) = position(JsonField.ofNullable(position)) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ fun position(position: Optional) = position(position.getOrNull()) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - fun position(position: JsonField) = apply { this.position = position } + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ + fun position(position: JsonField) = + apply { + this.position = position + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScore = ProjectScore( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("scoreType", scoreType), - checkRequired("userId", userId), - categories, - config, - created, - description, - position, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "scoreType", scoreType + ), + checkRequired( + "userId", userId + ), + categories, + config, + created, + description, + position, + additionalProperties.toImmutable(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -358,9 +428,11 @@ private constructor( * 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 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 { @@ -371,17 +443,18 @@ private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -397,11 +470,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -417,23 +490,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -444,13 +514,13 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( + class Categories private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { /** For categorical-type project scores, the list of all categories */ @@ -486,48 +556,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = apply { - if (validated) { - return@apply - } + fun validate(): Categories = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) {} + override fun visitMinimum(minimum: List) { + + } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -546,22 +617,23 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = - Categories(categorical = categorical) + fun ofCategorical(categorical: List) = Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic + fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic + fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of type [T]. + * An interface that defines how to map each variant of [Categories] to a value of + * type [T]. */ interface Visitor { @@ -579,70 +651,59 @@ private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [Categories] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Weighted @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -651,20 +712,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Weighted = apply { - if (validated) { - return@apply - } + fun validate(): Weighted = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -673,41 +736,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = + apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -720,11 +788,9 @@ private constructor( } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -733,20 +799,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -755,41 +823,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -803,11 +876,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScore && id == other.id && name == other.name && projectId == other.projectId && scoreType == other.scoreType && userId == other.userId && categories == other.categories && config == other.config && created == other.created && description == other.description && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScore && id == other.id && name == other.name && projectId == other.projectId && scoreType == other.scoreType && userId == other.userId && categories == other.categories && config == other.config && created == other.created && description == other.description && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -816,6 +889,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectScore{id=$id, name=$name, projectId=$projectId, scoreType=$scoreType, userId=$userId, categories=$categories, config=$config, created=$created, description=$description, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScore{id=$id, name=$name, projectId=$projectId, scoreType=$scoreType, userId=$userId, categories=$categories, config=$config, created=$created, description=$description, position=$position, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index 9637cd01..cc936db0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -18,12 +18,11 @@ import java.util.Objects /** For categorical-type project scores, defines a single category */ @NoAutoDetect -class ProjectScoreCategory -@JsonCreator -private constructor( +class ProjectScoreCategory @JsonCreator private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the category */ @@ -33,10 +32,14 @@ private constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -44,30 +47,34 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreCategory = apply { - if (validated) { - return@apply - } + fun validate(): ProjectScoreCategory = + apply { + if (validated) { + return@apply + } - name() - value() - validated = true - } + name() + value() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreCategory]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreCategory]. * * The following fields are required: + * * ```java * .name() * .value() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreCategory]. */ @@ -78,57 +85,75 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreCategory: ProjectScoreCategory) = apply { - name = projectScoreCategory.name - value = projectScoreCategory.value - additionalProperties = projectScoreCategory.additionalProperties.toMutableMap() - } + internal fun from(projectScoreCategory: ProjectScoreCategory) = + apply { + name = projectScoreCategory.name + value = projectScoreCategory.value + additionalProperties = projectScoreCategory.additionalProperties.toMutableMap() + } /** Name of the category */ fun name(name: String) = name(JsonField.of(name)) /** Name of the category */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) /** Numerical value of the category. Must be between 0 and 1, inclusive */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = + apply { + this.value = value + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScoreCategory = ProjectScoreCategory( - checkRequired("name", name), - checkRequired("value", value), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "value", value + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreCategory && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCategory && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -137,6 +162,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 82cf7754..5650b1eb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -20,26 +20,17 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectScoreConfig -@JsonCreator -private constructor( - @JsonProperty("destination") - @ExcludeMissing - private val destination: JsonField = JsonMissing.of(), - @JsonProperty("multi_select") - @ExcludeMissing - private val multiSelect: JsonField = JsonMissing.of(), - @JsonProperty("online") - @ExcludeMissing - private val online: JsonField = JsonMissing.of(), +class ProjectScoreConfig @JsonCreator private constructor( + @JsonProperty("destination") @ExcludeMissing private val destination: JsonField = JsonMissing.of(), + @JsonProperty("multi_select") @ExcludeMissing private val multiSelect: JsonField = JsonMissing.of(), + @JsonProperty("online") @ExcludeMissing private val online: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun destination(): Optional = - Optional.ofNullable(destination.getNullable("destination")) + fun destination(): Optional = Optional.ofNullable(destination.getNullable("destination")) - fun multiSelect(): Optional = - Optional.ofNullable(multiSelect.getNullable("multi_select")) + fun multiSelect(): Optional = Optional.ofNullable(multiSelect.getNullable("multi_select")) fun online(): Optional = Optional.ofNullable(online.getNullable("online")) @@ -51,7 +42,9 @@ private constructor( @ExcludeMissing fun _multiSelect(): JsonField = multiSelect - @JsonProperty("online") @ExcludeMissing fun _online(): JsonField = online + @JsonProperty("online") + @ExcludeMissing + fun _online(): JsonField = online @JsonAnyGetter @ExcludeMissing @@ -59,23 +52,25 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreConfig = apply { - if (validated) { - return@apply - } + fun validate(): ProjectScoreConfig = + apply { + if (validated) { + return@apply + } - destination() - multiSelect() - online().ifPresent { it.validate() } - validated = true - } + destination() + multiSelect() + online().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectScoreConfig]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreConfig]. */ @@ -87,20 +82,22 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreConfig: ProjectScoreConfig) = apply { - destination = projectScoreConfig.destination - multiSelect = projectScoreConfig.multiSelect - online = projectScoreConfig.online - additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() - } + internal fun from(projectScoreConfig: ProjectScoreConfig) = + apply { + destination = projectScoreConfig.destination + multiSelect = projectScoreConfig.multiSelect + online = projectScoreConfig.online + additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() + } fun destination(destination: Destination?) = destination(JsonField.ofNullable(destination)) fun destination(destination: Optional) = destination(destination.getOrNull()) - fun destination(destination: JsonField) = apply { - this.destination = destination - } + fun destination(destination: JsonField) = + apply { + this.destination = destination + } fun multiSelect(multiSelect: Boolean?) = multiSelect(JsonField.ofNullable(multiSelect)) @@ -108,49 +105,70 @@ private constructor( fun multiSelect(multiSelect: Optional) = multiSelect(multiSelect.getOrNull()) - fun multiSelect(multiSelect: JsonField) = apply { this.multiSelect = multiSelect } + fun multiSelect(multiSelect: JsonField) = + apply { + this.multiSelect = multiSelect + } fun online(online: OnlineScoreConfig?) = online(JsonField.ofNullable(online)) fun online(online: Optional) = online(online.getOrNull()) - fun online(online: JsonField) = apply { this.online = online } + fun online(online: JsonField) = + apply { + this.online = online + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScoreConfig = - ProjectScoreConfig(destination, multiSelect, online, additionalProperties.toImmutable()) + ProjectScoreConfig( + destination, + multiSelect, + online, + additionalProperties.toImmutable(), + ) } - class Destination @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Destination @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -161,32 +179,36 @@ private constructor( /** An enum containing [Destination]'s known values. */ enum class Known { - EXPECTED + EXPECTED, } /** - * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [Destination] 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 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 { EXPECTED, /** - * An enum member indicating that [Destination] was instantiated with an unknown value. + * An enum member indicating that [Destination] 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. + * 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. + * 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) { @@ -197,11 +219,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -212,23 +234,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ + return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -237,11 +256,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreConfig && destination == other.destination && multiSelect == other.multiSelect && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreConfig && destination == other.destination && multiSelect == other.multiSelect && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -250,6 +269,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectScoreConfig{destination=$destination, multiSelect=$multiSelect, online=$online, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreConfig{destination=$destination, multiSelect=$multiSelect, online=$online, additionalProperties=$additionalProperties}" } 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 49401ff2..7661dfe8 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 @@ -34,14 +34,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project_score. If there is an existing project_score in the project with the same - * name as the one specified in the request, will return the existing project_score unmodified + * Create a new project_score. If there is an existing project_score in the project + * with the same name as the one specified in the request, will return the existing + * project_score unmodified */ -class ProjectScoreCreateParams -private constructor( +class ProjectScoreCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project score */ @@ -84,37 +85,27 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** A project score is a user-configured score, which can be manually-labeled through the UI */ + /** + * A project score is a user-configured score, which can be manually-labeled + * through the UI + */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") - @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("categories") - @ExcludeMissing - private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project score */ @@ -127,21 +118,22 @@ private constructor( fun scoreType(): ScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = - Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = - Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** The type of the configured score */ @JsonProperty("score_type") @@ -168,19 +160,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - projectId() - scoreType() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - validated = true - } + name() + projectId() + scoreType() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + validated = true + } fun toBuilder() = Builder().from(this) @@ -190,13 +183,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -211,63 +206,73 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - scoreType = body.scoreType - categories = body.categories - config = body.config - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + scoreType = body.scoreType + categories = body.categories + config = body.config + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = 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.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { - this.categories = categories - } + fun categories(categories: JsonField) = + apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = + apply { + this.config = config + } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -276,47 +281,61 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("scoreType", scoreType), - categories, - config, - description, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "scoreType", scoreType + ), + categories, + config, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -325,8 +344,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -334,16 +352,19 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreCreateParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreCreateParams]. */ @@ -355,204 +376,287 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreCreateParams: ProjectScoreCreateParams) = apply { - body = projectScoreCreateParams.body.toBuilder() - additionalHeaders = projectScoreCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreCreateParams: ProjectScoreCreateParams) = + apply { + body = projectScoreCreateParams.body.toBuilder() + additionalHeaders = projectScoreCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project score */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project score */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + 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: ScoreType) = + 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) } + fun categories(categories: Categories) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { body.categories(categories) } + fun categories(categories: JsonField) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = + apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + fun categories(weighted: Categories.Weighted) = + apply { + body.categories(weighted) + } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } + fun categoriesOfMinimum(minimum: List) = + apply { + body.categoriesOfMinimum(minimum) + } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = + apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + fun config(config: ProjectScoreConfig?) = + apply { + body.config(config) + } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { body.config(config) } + fun config(config: JsonField) = + apply { + body.config(config) + } /** Textual description of the project score */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreCreateParams = ProjectScoreCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -585,9 +689,11 @@ private constructor( * 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 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 { @@ -598,17 +704,18 @@ private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -624,11 +731,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -644,23 +751,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -671,13 +775,13 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( + class Categories private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { /** For categorical-type project scores, the list of all categories */ @@ -713,48 +817,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = apply { - if (validated) { - return@apply - } + fun validate(): Categories = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) {} + override fun visitMinimum(minimum: List) { + + } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -773,22 +878,23 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = - Categories(categorical = categorical) + fun ofCategorical(categorical: List) = Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic + fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic + fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of type [T]. + * An interface that defines how to map each variant of [Categories] to a value of + * type [T]. */ interface Visitor { @@ -806,70 +912,59 @@ private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [Categories] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Weighted @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -878,20 +973,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Weighted = apply { - if (validated) { - return@apply - } + fun validate(): Weighted = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -900,41 +997,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = + apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -947,11 +1049,9 @@ private constructor( } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -960,20 +1060,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -982,41 +1084,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1030,15 +1137,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 291b304d..1ddf0990 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project_score object by its id */ -class ProjectScoreDeleteParams -private constructor( +class ProjectScoreDeleteParams private constructor( private val projectScoreId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** ProjectScore id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreDeleteParams]. * * The following fields are required: + * * ```java * .projectScoreId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreDeleteParams: ProjectScoreDeleteParams) = apply { - projectScoreId = projectScoreDeleteParams.projectScoreId - additionalHeaders = projectScoreDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectScoreDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectScoreDeleteParams: ProjectScoreDeleteParams) = + apply { + projectScoreId = projectScoreDeleteParams.projectScoreId + additionalHeaders = projectScoreDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectScoreDeleteParams.additionalBodyProperties.toMutableMap() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun projectScoreId(projectScoreId: String) = + apply { + this.projectScoreId = projectScoreId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( - checkRequired("projectScoreId", projectScoreId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "projectScoreId", projectScoreId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index f0864a38..e082c718 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.ProjectScoreService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ -class ProjectScoreListPage -private constructor( +class ProjectScoreListPage private constructor( private val projectScoresService: ProjectScoreService, private val params: ProjectScoreListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListPage && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListPage && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ - override fun toString() = - "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" + override fun toString() = "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectScoreListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectScoreListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectScoresService.list(it) } + return getNextPageParams().map { projectScoresService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectScoresService: ProjectScoreService, - params: ProjectScoreListParams, - response: Response, - ) = ProjectScoreListPage(projectScoresService, params, response) + fun of(projectScoresService: ProjectScoreService, params: ProjectScoreListParams, response: Response) = + ProjectScoreListPage( + projectScoresService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** Returns a mutable builder for constructing an instance of [ProjectScoreListPage]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ProjectScoreListPage]. + */ + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +139,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectScoreListPage) : Iterable { + class AutoPager( + private val firstPage: ProjectScoreListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index f3328758..342ba7fe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.ProjectScoreServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ -class ProjectScoreListPageAsync -private constructor( +class ProjectScoreListPageAsync private constructor( private val projectScoresService: ProjectScoreServiceAsync, private val params: ProjectScoreListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListPageAsync && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListPageAsync && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ - override fun toString() = - "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" + override fun toString() = "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectScoreListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectScoreListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { projectScoresService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + projectScoresService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectScoresService: ProjectScoreServiceAsync, - params: ProjectScoreListParams, - response: Response, - ) = ProjectScoreListPageAsync(projectScoresService, params, response) + fun of(projectScoresService: ProjectScoreServiceAsync, params: ProjectScoreListParams, response: Response) = + ProjectScoreListPageAsync( + projectScoresService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,29 +106,29 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -143,7 +136,8 @@ private constructor( * Returns a mutable builder for constructing an instance of * [ProjectScoreListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -152,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectScoreListPageAsync) { + class AutoPager( + private val firstPage: ProjectScoreListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (ProjectScore) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (ProjectScore) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } 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 6f86bc5e..879f1efa 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 @@ -26,11 +26,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ -class ProjectScoreListParams -private constructor( +class ProjectScoreListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -42,20 +41,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -80,9 +80,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -93,28 +93,69 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.projectScoreName?.let { queryParams.put("project_score_name", listOf(it.toString())) } - this.scoreType?.let { queryParams.put("score_type", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.projectScoreName?.let { + queryParams.put( + "project_score_name", listOf(it.toString()) + ) + } + this.scoreType?.let { + queryParams.put( + "score_type", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ProjectScoreListParams = builder().build() + @JvmStatic + fun none(): ProjectScoreListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [ProjectScoreListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ProjectScoreListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreListParams]. */ @@ -134,64 +175,74 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreListParams: ProjectScoreListParams) = apply { - endingBefore = projectScoreListParams.endingBefore - ids = projectScoreListParams.ids - limit = projectScoreListParams.limit - orgName = projectScoreListParams.orgName - projectId = projectScoreListParams.projectId - projectName = projectScoreListParams.projectName - projectScoreName = projectScoreListParams.projectScoreName - scoreType = projectScoreListParams.scoreType - startingAfter = projectScoreListParams.startingAfter - additionalHeaders = projectScoreListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreListParams: ProjectScoreListParams) = + apply { + endingBefore = projectScoreListParams.endingBefore + ids = projectScoreListParams.ids + limit = projectScoreListParams.limit + orgName = projectScoreListParams.orgName + projectId = projectScoreListParams.projectId + projectName = projectScoreListParams.projectName + projectScoreName = projectScoreListParams.projectScoreName + scoreType = projectScoreListParams.scoreType + startingAfter = projectScoreListParams.startingAfter + additionalHeaders = projectScoreListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -200,34 +251,46 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_score to search for */ - fun projectScoreName(projectScoreName: String?) = apply { - this.projectScoreName = projectScoreName - } + fun projectScoreName(projectScoreName: String?) = + apply { + this.projectScoreName = projectScoreName + } /** Name of the project_score to search for */ - fun projectScoreName(projectScoreName: Optional) = - projectScoreName(projectScoreName.getOrNull()) + fun projectScoreName(projectScoreName: Optional) = projectScoreName(projectScoreName.getOrNull()) /** The type of the configured score */ - fun scoreType(scoreType: ScoreType?) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType?) = + apply { + this.scoreType = scoreType + } /** The type of the configured score */ fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) @@ -236,153 +299,180 @@ private constructor( fun scoreType(project: ScoreType.ProjectScoreType) = scoreType(ScoreType.ofProject(project)) /** The type of the configured score */ - fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = - scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) + fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreListParams = ProjectScoreListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectScoreName, - scoreType, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectScoreName, + scoreType, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -400,19 +490,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -427,12 +517,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -442,46 +537,43 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } @@ -489,19 +581,18 @@ private constructor( /** The type of the configured score */ @JsonDeserialize(using = ScoreType.Deserializer::class) @JsonSerialize(using = ScoreType.Serializer::class) - class ScoreType - private constructor( + class ScoreType private constructor( private val project: ProjectScoreType? = null, private val projectScoreTypes: List? = null, private val _json: JsonValue? = null, + ) { /** The type of the configured score */ fun project(): Optional = Optional.ofNullable(project) /** The type of the configured score */ - fun projectScoreTypes(): Optional> = - Optional.ofNullable(projectScoreTypes) + fun projectScoreTypes(): Optional> = Optional.ofNullable(projectScoreTypes) fun isProject(): Boolean = project != null @@ -511,25 +602,24 @@ private constructor( fun asProject(): ProjectScoreType = project.getOrThrow("project") /** The type of the configured score */ - fun asProjectScoreTypes(): List = - projectScoreTypes.getOrThrow("projectScoreTypes") + fun asProjectScoreTypes(): List = projectScoreTypes.getOrThrow("projectScoreTypes") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - project != null -> visitor.visitProject(project) - projectScoreTypes != null -> visitor.visitProjectScoreTypes(projectScoreTypes) - else -> visitor.unknown(_json) - } + return when { + project != null -> visitor.visitProject(project) + projectScoreTypes != null -> visitor.visitProjectScoreTypes(projectScoreTypes) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && project == other.project && projectScoreTypes == other.projectScoreTypes /* spotless:on */ + return /* spotless:off */ other is ScoreType && project == other.project && projectScoreTypes == other.projectScoreTypes /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(project, projectScoreTypes) /* spotless:on */ @@ -545,16 +635,17 @@ private constructor( companion object { /** The type of the configured score */ - @JvmStatic fun ofProject(project: ProjectScoreType) = ScoreType(project = project) + @JvmStatic + fun ofProject(project: ProjectScoreType) = ScoreType(project = project) /** The type of the configured score */ @JvmStatic - fun ofProjectScoreTypes(projectScoreTypes: List) = - ScoreType(projectScoreTypes = projectScoreTypes) + fun ofProjectScoreTypes(projectScoreTypes: List) = ScoreType(projectScoreTypes = projectScoreTypes) } /** - * An interface that defines how to map each variant of [ScoreType] to a value of type [T]. + * An interface that defines how to map each variant of [ScoreType] to a value of + * type [T]. */ interface Visitor { @@ -567,65 +658,62 @@ private constructor( /** * Maps an unknown variant of [ScoreType] to a value of type [T]. * - * An instance of [ScoreType] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [ScoreType] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ScoreType: $json") + throw BraintrustInvalidDataException("Unknown ScoreType: $json") } } internal class Deserializer : BaseDeserializer(ScoreType::class) { override fun ObjectCodec.deserialize(node: JsonNode): ScoreType { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ScoreType(project = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return ScoreType(projectScoreTypes = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return ScoreType(project = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return ScoreType(projectScoreTypes = it, _json = json) + } - return ScoreType(_json = json) + return ScoreType(_json = json) } } internal class Serializer : BaseSerializer(ScoreType::class) { - override fun serialize( - value: ScoreType, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.project != null -> generator.writeObject(value.project) - value.projectScoreTypes != null -> - generator.writeObject(value.projectScoreTypes) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ScoreType") - } + override fun serialize(value: ScoreType, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.project != null -> generator.writeObject(value.project) + value.projectScoreTypes != null -> generator.writeObject(value.projectScoreTypes) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ScoreType") + } } } /** The type of the configured score */ - class ProjectScoreType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -658,10 +746,13 @@ private constructor( * 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. + * 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 { @@ -682,8 +773,8 @@ private constructor( * 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. + * 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) { @@ -703,7 +794,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -722,20 +813,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -744,19 +832,21 @@ private constructor( } /** The type of the configured score */ - class ProjectScoreType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -789,10 +879,13 @@ private constructor( * 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. + * 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 { @@ -813,8 +906,8 @@ private constructor( * 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. + * 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) { @@ -834,7 +927,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -853,20 +946,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -876,15 +966,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 8373825d..5a2bad2d 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 @@ -34,15 +34,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace project_score. If there is an existing project_score in the project with the - * same name as the one specified in the request, will replace the existing project_score with the - * provided fields + * Create or replace project_score. If there is an existing project_score in the + * project with the same name as the one specified in the request, will replace the + * existing project_score with the provided fields */ -class ProjectScoreReplaceParams -private constructor( +class ProjectScoreReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project score */ @@ -85,37 +85,27 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** A project score is a user-configured score, which can be manually-labeled through the UI */ + /** + * A project score is a user-configured score, which can be manually-labeled + * through the UI + */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") - @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("categories") - @ExcludeMissing - private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project score */ @@ -128,21 +118,22 @@ private constructor( fun scoreType(): ScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = - Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = - Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** The type of the configured score */ @JsonProperty("score_type") @@ -169,19 +160,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - projectId() - scoreType() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - validated = true - } + name() + projectId() + scoreType() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + validated = true + } fun toBuilder() = Builder().from(this) @@ -191,13 +183,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -212,63 +206,73 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - scoreType = body.scoreType - categories = body.categories - config = body.config - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + scoreType = body.scoreType + categories = body.categories + config = body.config + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = 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.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { - this.categories = categories - } + fun categories(categories: JsonField) = + apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = + apply { + this.config = config + } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -277,47 +281,61 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("scoreType", scoreType), - categories, - config, - description, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "scoreType", scoreType + ), + categories, + config, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -326,8 +344,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -335,16 +352,19 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreReplaceParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreReplaceParams]. */ @@ -356,204 +376,287 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreReplaceParams: ProjectScoreReplaceParams) = apply { - body = projectScoreReplaceParams.body.toBuilder() - additionalHeaders = projectScoreReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreReplaceParams: ProjectScoreReplaceParams) = + apply { + body = projectScoreReplaceParams.body.toBuilder() + additionalHeaders = projectScoreReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the project score */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project score */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + 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: ScoreType) = + 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) } + fun categories(categories: Categories) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { body.categories(categories) } + fun categories(categories: JsonField) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = + apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + fun categories(weighted: Categories.Weighted) = + apply { + body.categories(weighted) + } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } + fun categoriesOfMinimum(minimum: List) = + apply { + body.categoriesOfMinimum(minimum) + } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = + apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + fun config(config: ProjectScoreConfig?) = + apply { + body.config(config) + } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { body.config(config) } + fun config(config: JsonField) = + apply { + body.config(config) + } /** Textual description of the project score */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreReplaceParams = ProjectScoreReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -586,9 +689,11 @@ private constructor( * 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 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 { @@ -599,17 +704,18 @@ private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -625,11 +731,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -645,23 +751,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -672,13 +775,13 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( + class Categories private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { /** For categorical-type project scores, the list of all categories */ @@ -714,48 +817,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = apply { - if (validated) { - return@apply - } + fun validate(): Categories = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) {} + override fun visitMinimum(minimum: List) { + + } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -774,22 +878,23 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = - Categories(categorical = categorical) + fun ofCategorical(categorical: List) = Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic + fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic + fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of type [T]. + * An interface that defines how to map each variant of [Categories] to a value of + * type [T]. */ interface Visitor { @@ -807,70 +912,59 @@ private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [Categories] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Weighted @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -879,20 +973,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Weighted = apply { - if (validated) { - return@apply - } + fun validate(): Weighted = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -901,41 +997,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = + apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -948,11 +1049,9 @@ private constructor( } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -961,20 +1060,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -983,41 +1084,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1031,15 +1137,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 9521a052..8370d2d3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project_score object by its id */ -class ProjectScoreRetrieveParams -private constructor( +class ProjectScoreRetrieveParams private constructor( private val projectScoreId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ProjectScore id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreRetrieveParams]. * * The following fields are required: + * * ```java * .projectScoreId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = apply { - projectScoreId = projectScoreRetrieveParams.projectScoreId - additionalHeaders = projectScoreRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = + apply { + projectScoreId = projectScoreRetrieveParams.projectScoreId + additionalHeaders = projectScoreRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreRetrieveParams.additionalQueryParams.toBuilder() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun projectScoreId(projectScoreId: String) = + apply { + this.projectScoreId = projectScoreId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( - checkRequired("projectScoreId", projectScoreId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectScoreId", projectScoreId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 4784736c..2dd1c1c2 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 @@ -34,16 +34,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class ProjectScoreUpdateParams -private constructor( +class ProjectScoreUpdateParams private constructor( private val projectScoreId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ProjectScore id */ @@ -83,60 +83,48 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } - /** A project score is a user-configured score, which can be manually-labeled through the UI */ + /** + * A project score is a user-configured score, which can be manually-labeled + * through the UI + */ @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("categories") - @ExcludeMissing - private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("score_type") - @ExcludeMissing - private val scoreType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = - Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = - Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The type of the configured score */ - fun scoreType(): Optional = - Optional.ofNullable(scoreType.getNullable("score_type")) + fun scoreType(): Optional = Optional.ofNullable(scoreType.getNullable("score_type")) /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @@ -153,7 +141,9 @@ private constructor( fun _description(): JsonField = description /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The type of the configured score */ @JsonProperty("score_type") @@ -166,25 +156,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - name() - scoreType() - validated = true - } + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + name() + scoreType() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -198,44 +190,45 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - categories = body.categories - config = body.config - description = body.description - name = body.name - scoreType = body.scoreType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + categories = body.categories + config = body.config + description = body.description + name = body.name + scoreType = body.scoreType + additionalProperties = body.additionalProperties.toMutableMap() + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { - this.categories = categories - } + fun categories(categories: JsonField) = + apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = + apply { + this.config = config + } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -244,9 +237,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the project score */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -255,7 +249,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType?) = scoreType(JsonField.ofNullable(scoreType)) @@ -264,44 +261,54 @@ private constructor( 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() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - categories, - config, - description, - name, - scoreType, - additionalProperties.toImmutable(), + categories, + config, + description, + name, + scoreType, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -310,8 +317,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" + override fun toString() = "Body{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -319,14 +325,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectScoreUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectScoreUpdateParams]. * * The following fields are required: + * * ```java * .projectScoreId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectScoreUpdateParams]. */ @@ -339,207 +348,285 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreUpdateParams: ProjectScoreUpdateParams) = apply { - projectScoreId = projectScoreUpdateParams.projectScoreId - body = projectScoreUpdateParams.body.toBuilder() - additionalHeaders = projectScoreUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreUpdateParams: ProjectScoreUpdateParams) = + apply { + projectScoreId = projectScoreUpdateParams.projectScoreId + body = projectScoreUpdateParams.body.toBuilder() + additionalHeaders = projectScoreUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreUpdateParams.additionalQueryParams.toBuilder() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun projectScoreId(projectScoreId: String) = + apply { + this.projectScoreId = projectScoreId + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { body.categories(categories) } + fun categories(categories: Categories) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = apply { body.categories(categories) } + fun categories(categories: JsonField) = + apply { + body.categories(categories) + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = + apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } + fun categories(weighted: Categories.Weighted) = + apply { + body.categories(weighted) + } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } + fun categoriesOfMinimum(minimum: List) = + apply { + body.categoriesOfMinimum(minimum) + } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = + apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + fun config(config: ProjectScoreConfig?) = + apply { + body.config(config) + } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = apply { body.config(config) } + fun config(config: JsonField) = + apply { + body.config(config) + } /** Textual description of the project score */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the project score */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the project score */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project score */ - fun name(name: JsonField) = apply { body.name(name) } + 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: ScoreType?) = + apply { + body.scoreType(scoreType) + } /** The type of the configured score */ 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) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreUpdateParams = ProjectScoreUpdateParams( - checkRequired("projectScoreId", projectScoreId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectScoreId", projectScoreId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( + class Categories private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { /** For categorical-type project scores, the list of all categories */ @@ -575,48 +662,49 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = apply { - if (validated) { - return@apply - } + fun validate(): Categories = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) {} + override fun visitMinimum(minimum: List) { + + } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -635,22 +723,23 @@ private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = - Categories(categorical = categorical) + fun ofCategorical(categorical: List) = Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic + fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic + fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of type [T]. + * An interface that defines how to map each variant of [Categories] to a value of + * type [T]. */ interface Visitor { @@ -668,70 +757,59 @@ private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [Categories] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()) { - it.forEach { it.validate() } - } - ?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Weighted @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -740,20 +818,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Weighted = apply { - if (validated) { - return@apply - } + fun validate(): Weighted = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -762,41 +842,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = + apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -809,11 +894,9 @@ private constructor( } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -822,20 +905,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -844,41 +929,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -892,17 +982,21 @@ private constructor( } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -935,9 +1029,11 @@ private constructor( * 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 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 { @@ -948,17 +1044,18 @@ private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -974,11 +1071,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -994,23 +1091,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1019,15 +1113,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index 9c9bfe47..d786a3cf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -18,18 +18,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectSettings -@JsonCreator -private constructor( - @JsonProperty("comparison_key") - @ExcludeMissing - private val comparisonKey: JsonField = JsonMissing.of(), +class ProjectSettings @JsonCreator private constructor( + @JsonProperty("comparison_key") @ExcludeMissing private val comparisonKey: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(): Optional = - Optional.ofNullable(comparisonKey.getNullable("comparison_key")) + fun comparisonKey(): Optional = Optional.ofNullable(comparisonKey.getNullable("comparison_key")) /** The key used to join two experiments (defaults to `input`). */ @JsonProperty("comparison_key") @@ -42,21 +38,23 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectSettings = apply { - if (validated) { - return@apply - } + fun validate(): ProjectSettings = + apply { + if (validated) { + return@apply + } - comparisonKey() - validated = true - } + comparisonKey() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectSettings]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectSettings]. */ @@ -66,53 +64,62 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSettings: ProjectSettings) = apply { - comparisonKey = projectSettings.comparisonKey - additionalProperties = projectSettings.additionalProperties.toMutableMap() - } + internal fun from(projectSettings: ProjectSettings) = + apply { + comparisonKey = projectSettings.comparisonKey + additionalProperties = projectSettings.additionalProperties.toMutableMap() + } /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: String?) = - comparisonKey(JsonField.ofNullable(comparisonKey)) + fun comparisonKey(comparisonKey: String?) = comparisonKey(JsonField.ofNullable(comparisonKey)) /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: Optional) = - comparisonKey(comparisonKey.getOrNull()) + fun comparisonKey(comparisonKey: Optional) = comparisonKey(comparisonKey.getOrNull()) /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: JsonField) = apply { - this.comparisonKey = comparisonKey - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun comparisonKey(comparisonKey: JsonField) = + apply { + this.comparisonKey = comparisonKey + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSettings = - ProjectSettings(comparisonKey, additionalProperties.toImmutable()) + ProjectSettings( + comparisonKey, additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -121,6 +128,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 69a309f6..f2246bf9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -20,29 +20,20 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * A project tag is a user-configured tag for tracking and filtering your experiments, logs, and - * other data + * A project tag is a user-configured tag for tracking and filtering your + * experiments, logs, and other data */ @NoAutoDetect -class ProjectTag -@JsonCreator -private constructor( +class ProjectTag @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the project tag */ @@ -63,28 +54,41 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the project tag */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Unique identifier for the project tag */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + @JsonProperty("color") + @ExcludeMissing + fun _color(): JsonField = color /** Date of project tag creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Textual description of the project tag */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing @@ -92,21 +96,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ProjectTag = apply { - if (validated) { - return@apply + fun validate(): ProjectTag = + apply { + if (validated) { + return@apply + } + + id() + name() + projectId() + userId() + color() + created() + description() + validated = true } - id() - name() - projectId() - userId() - color() - created() - description() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -115,6 +120,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectTag]. * * The following fields are required: + * * ```java * .id() * .name() @@ -122,7 +128,8 @@ private constructor( * .userId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTag]. */ @@ -138,38 +145,51 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTag: ProjectTag) = apply { - id = projectTag.id - name = projectTag.name - projectId = projectTag.projectId - userId = projectTag.userId - color = projectTag.color - created = projectTag.created - description = projectTag.description - additionalProperties = projectTag.additionalProperties.toMutableMap() - } + internal fun from(projectTag: ProjectTag) = + apply { + id = projectTag.id + name = projectTag.name + projectId = projectTag.projectId + userId = projectTag.userId + color = projectTag.color + created = projectTag.created + description = projectTag.description + additionalProperties = projectTag.additionalProperties.toMutableMap() + } /** Unique identifier for the project tag */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project tag */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } fun userId(userId: String) = userId(JsonField.of(userId)) - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -178,7 +198,10 @@ private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = + apply { + this.color = color + } /** Date of project tag creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -187,7 +210,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project tag creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -196,46 +222,64 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { this.description = description } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = + apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectTag = ProjectTag( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("userId", userId), - color, - created, - description, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "userId", userId + ), + color, + created, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTag && id == other.id && name == other.name && projectId == other.projectId && userId == other.userId && color == other.color && created == other.created && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTag && id == other.id && name == other.name && projectId == other.projectId && userId == other.userId && color == other.color && created == other.created && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -244,6 +288,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ProjectTag{id=$id, name=$name, projectId=$projectId, userId=$userId, color=$color, created=$created, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectTag{id=$id, name=$name, projectId=$projectId, userId=$userId, color=$color, created=$created, description=$description, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 1944b66e..fd9204c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project_tag. If there is an existing project_tag in the project with the same name - * as the one specified in the request, will return the existing project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project + * with the same name as the one specified in the request, will return the existing + * project_tag unmodified */ -class ProjectTagCreateParams -private constructor( +class ProjectTagCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project tag */ @@ -62,30 +63,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project tag */ @@ -98,17 +90,22 @@ private constructor( fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + @JsonProperty("color") + @ExcludeMissing + fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -121,18 +118,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + color() + description() + validated = true } - name() - projectId() - color() - description() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -141,12 +139,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -159,25 +159,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - color = body.color - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + color = body.color + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -186,7 +193,10 @@ private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = + apply { + this.color = color + } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -195,45 +205,57 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { - this.description = description - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = + apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - color, - description, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + color, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -242,8 +264,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -251,15 +272,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagCreateParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagCreateParams]. */ @@ -271,177 +295,235 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagCreateParams: ProjectTagCreateParams) = apply { - body = projectTagCreateParams.body.toBuilder() - additionalHeaders = projectTagCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagCreateParams: ProjectTagCreateParams) = + apply { + body = projectTagCreateParams.body.toBuilder() + additionalHeaders = projectTagCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project tag */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project tag */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Color of the tag for the UI */ - fun color(color: String?) = apply { body.color(color) } + fun color(color: String?) = + apply { + body.color(color) + } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { body.color(color) } + fun color(color: JsonField) = + apply { + body.color(color) + } /** Textual description of the project tag */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagCreateParams = ProjectTagCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 1f3d8f1c..bcdd7f60 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project_tag object by its id */ -class ProjectTagDeleteParams -private constructor( +class ProjectTagDeleteParams private constructor( private val projectTagId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** ProjectTag id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagDeleteParams]. * * The following fields are required: + * * ```java * .projectTagId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTagDeleteParams: ProjectTagDeleteParams) = apply { - projectTagId = projectTagDeleteParams.projectTagId - additionalHeaders = projectTagDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectTagDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectTagDeleteParams: ProjectTagDeleteParams) = + apply { + projectTagId = projectTagDeleteParams.projectTagId + additionalHeaders = projectTagDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectTagDeleteParams.additionalBodyProperties.toMutableMap() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun projectTagId(projectTagId: String) = + apply { + this.projectTagId = projectTagId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( - checkRequired("projectTagId", projectTagId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "projectTagId", projectTagId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 3fdf0ee1..6f5762aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.ProjectTagService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ -class ProjectTagListPage -private constructor( +class ProjectTagListPage private constructor( private val projectTagsService: ProjectTagService, private val params: ProjectTagListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListPage && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectTagListPage && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ - override fun toString() = - "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" + override fun toString() = "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectTagListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectTagListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectTagsService.list(it) } + return getNextPageParams().map { projectTagsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectTagsService: ProjectTagService, - params: ProjectTagListParams, - response: Response, - ) = ProjectTagListPage(projectTagsService, params, response) + fun of(projectTagsService: ProjectTagService, params: ProjectTagListParams, response: Response) = + ProjectTagListPage( + projectTagsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ProjectTagListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectTagListPage) : Iterable { + class AutoPager( + private val firstPage: ProjectTagListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 885b7cbe..12379625 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.ProjectTagServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ -class ProjectTagListPageAsync -private constructor( +class ProjectTagListPageAsync private constructor( private val projectTagsService: ProjectTagServiceAsync, private val params: ProjectTagListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListPageAsync && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectTagListPageAsync && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ - override fun toString() = - "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" + override fun toString() = "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ProjectTagListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - ProjectTagListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { projectTagsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + projectTagsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - projectTagsService: ProjectTagServiceAsync, - params: ProjectTagListParams, - response: Response, - ) = ProjectTagListPageAsync(projectTagsService, params, response) + fun of(projectTagsService: ProjectTagServiceAsync, params: ProjectTagListParams, response: Response) = + ProjectTagListPageAsync( + projectTagsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -151,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ProjectTagListPageAsync) { + class AutoPager( + private val firstPage: ProjectTagListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (ProjectTag) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (ProjectTag) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 431a8583..44d39849 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ -class ProjectTagListParams -private constructor( +class ProjectTagListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -38,20 +37,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,27 +86,64 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.projectTagName?.let { queryParams.put("project_tag_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.projectTagName?.let { + queryParams.put( + "project_tag_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): ProjectTagListParams = builder().build() + @JvmStatic + fun none(): ProjectTagListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [ProjectTagListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [ProjectTagListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagListParams]. */ @@ -125,63 +162,73 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagListParams: ProjectTagListParams) = apply { - endingBefore = projectTagListParams.endingBefore - ids = projectTagListParams.ids - limit = projectTagListParams.limit - orgName = projectTagListParams.orgName - projectId = projectTagListParams.projectId - projectName = projectTagListParams.projectName - projectTagName = projectTagListParams.projectTagName - startingAfter = projectTagListParams.startingAfter - additionalHeaders = projectTagListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagListParams: ProjectTagListParams) = + apply { + endingBefore = projectTagListParams.endingBefore + ids = projectTagListParams.ids + limit = projectTagListParams.limit + orgName = projectTagListParams.orgName + projectId = projectTagListParams.projectId + projectName = projectTagListParams.projectName + projectTagName = projectTagListParams.projectTagName + startingAfter = projectTagListParams.startingAfter + additionalHeaders = projectTagListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -190,173 +237,212 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_tag to search for */ - fun projectTagName(projectTagName: String?) = apply { this.projectTagName = projectTagName } + fun projectTagName(projectTagName: String?) = + apply { + this.projectTagName = projectTagName + } /** Name of the project_tag to search for */ - fun projectTagName(projectTagName: Optional) = - projectTagName(projectTagName.getOrNull()) + fun projectTagName(projectTagName: Optional) = projectTagName(projectTagName.getOrNull()) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagListParams = ProjectTagListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectTagName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectTagName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -374,19 +460,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -401,12 +487,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -416,60 +507,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index ab167ca1..f9bf8d6e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -22,15 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will replace the existing project_tag with the provided - * fields + * Create or replace project_tag. If there is an existing project_tag in the + * project with the same name as the one specified in the request, will replace the + * existing project_tag with the provided fields */ -class ProjectTagReplaceParams -private constructor( +class ProjectTagReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the project tag */ @@ -63,30 +63,21 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project tag */ @@ -99,17 +90,22 @@ private constructor( fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + @JsonProperty("color") + @ExcludeMissing + fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -122,18 +118,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + color() + description() + validated = true } - name() - projectId() - color() - description() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -142,12 +139,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -160,25 +159,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - color = body.color - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + color = body.color + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -187,7 +193,10 @@ private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = + apply { + this.color = color + } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -196,45 +205,57 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { - this.description = description - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = + apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - color, - description, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + color, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -243,8 +264,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -252,15 +272,18 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagReplaceParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagReplaceParams]. */ @@ -272,177 +295,235 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagReplaceParams: ProjectTagReplaceParams) = apply { - body = projectTagReplaceParams.body.toBuilder() - additionalHeaders = projectTagReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagReplaceParams: ProjectTagReplaceParams) = + apply { + body = projectTagReplaceParams.body.toBuilder() + additionalHeaders = projectTagReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the project tag */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the project tag */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Color of the tag for the UI */ - fun color(color: String?) = apply { body.color(color) } + fun color(color: String?) = + apply { + body.color(color) + } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { body.color(color) } + fun color(color: JsonField) = + apply { + body.color(color) + } /** Textual description of the project tag */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagReplaceParams = ProjectTagReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 90bd6349..5a5b92f3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project_tag object by its id */ -class ProjectTagRetrieveParams -private constructor( +class ProjectTagRetrieveParams private constructor( private val projectTagId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ProjectTag id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagRetrieveParams]. * * The following fields are required: + * * ```java * .projectTagId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = apply { - projectTagId = projectTagRetrieveParams.projectTagId - additionalHeaders = projectTagRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = + apply { + projectTagId = projectTagRetrieveParams.projectTagId + additionalHeaders = projectTagRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagRetrieveParams.additionalQueryParams.toBuilder() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun projectTagId(projectTagId: String) = + apply { + this.projectTagId = projectTagId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( - checkRequired("projectTagId", projectTagId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectTagId", projectTagId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 8a93825d..1e44d79d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class ProjectTagUpdateParams -private constructor( +class ProjectTagUpdateParams private constructor( private val projectTagId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** ProjectTag id */ @@ -61,48 +61,42 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("color") - @ExcludeMissing - private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Color of the tag for the UI */ fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + @JsonProperty("color") + @ExcludeMissing + fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -110,7 +104,9 @@ private constructor( fun _description(): JsonField = description /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -118,23 +114,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + color() + description() + name() + validated = true } - color() - description() - name() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -146,12 +144,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - color = body.color - description = body.description - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + color = body.color + description = body.description + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -160,7 +159,10 @@ private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = + apply { + this.color = color + } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -169,9 +171,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the project tag */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -180,36 +183,52 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project tag */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = Body(color, description, name, additionalProperties.toImmutable()) + fun name(name: JsonField) = + apply { + this.name = name + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = + Body( + color, + description, + name, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -218,8 +237,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Body{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -227,14 +245,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [ProjectTagUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [ProjectTagUpdateParams]. * * The following fields are required: + * * ```java * .projectTagId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectTagUpdateParams]. */ @@ -247,179 +268,236 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagUpdateParams: ProjectTagUpdateParams) = apply { - projectTagId = projectTagUpdateParams.projectTagId - body = projectTagUpdateParams.body.toBuilder() - additionalHeaders = projectTagUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagUpdateParams: ProjectTagUpdateParams) = + apply { + projectTagId = projectTagUpdateParams.projectTagId + body = projectTagUpdateParams.body.toBuilder() + additionalHeaders = projectTagUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagUpdateParams.additionalQueryParams.toBuilder() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun projectTagId(projectTagId: String) = + apply { + this.projectTagId = projectTagId + } /** Color of the tag for the UI */ - fun color(color: String?) = apply { body.color(color) } + fun color(color: String?) = + apply { + body.color(color) + } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = apply { body.color(color) } + fun color(color: JsonField) = + apply { + body.color(color) + } /** Textual description of the project tag */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the project tag */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the project tag */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project tag */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagUpdateParams = ProjectTagUpdateParams( - checkRequired("projectTagId", projectTagId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectTagId", projectTagId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectTagUpdateParams{projectTagId=$projectTagId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectTagUpdateParams{projectTagId=$projectTagId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index f47cf5da..7fefab19 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a project object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class ProjectUpdateParams -private constructor( +class ProjectUpdateParams private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Project id */ @@ -41,8 +41,8 @@ private constructor( fun name(): Optional = body.name() /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun settings(): Optional = body.settings() @@ -50,8 +50,8 @@ private constructor( fun _name(): JsonField = body._name() /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun _settings(): JsonField = body._settings() @@ -61,49 +61,45 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("settings") - @ExcludeMissing - private val settings: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("settings") @ExcludeMissing private val settings: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the project */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ - fun settings(): Optional = - Optional.ofNullable(settings.getNullable("settings")) + fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ @JsonProperty("settings") @ExcludeMissing @@ -115,22 +111,24 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - settings().ifPresent { it.validate() } - validated = true - } + name() + settings().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -141,11 +139,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - settings = body.settings - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + settings = body.settings + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -154,54 +153,72 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun settings(settings: Optional) = settings(settings.getOrNull()) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ - fun settings(settings: JsonField) = apply { this.settings = settings } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = Body(name, settings, additionalProperties.toImmutable()) + fun settings(settings: JsonField) = + apply { + this.settings = settings + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = + Body( + name, + settings, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -210,8 +227,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, settings=$settings, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, settings=$settings, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -222,11 +238,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [ProjectUpdateParams]. * * The following fields are required: + * * ```java * .projectId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ProjectUpdateParams]. */ @@ -239,179 +257,230 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectUpdateParams: ProjectUpdateParams) = apply { - projectId = projectUpdateParams.projectId - body = projectUpdateParams.body.toBuilder() - additionalHeaders = projectUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectUpdateParams: ProjectUpdateParams) = + apply { + projectId = projectUpdateParams.projectId + body = projectUpdateParams.body.toBuilder() + additionalHeaders = projectUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectUpdateParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = + apply { + this.projectId = projectId + } /** Name of the project */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the project */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ - fun settings(settings: ProjectSettings?) = apply { body.settings(settings) } + fun settings(settings: ProjectSettings?) = + apply { + body.settings(settings) + } /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ fun settings(settings: Optional) = settings(settings.getOrNull()) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you + * include all settings you want to keep. */ - fun settings(settings: JsonField) = apply { body.settings(settings) } + fun settings(settings: JsonField) = + apply { + body.settings(settings) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectUpdateParams = ProjectUpdateParams( - checkRequired("projectId", projectId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "projectId", projectId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ProjectUpdateParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ProjectUpdateParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 5e093784..13fcc876 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -23,48 +23,32 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Prompt -@JsonCreator -private constructor( +class Prompt @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -87,59 +71,77 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) /** User-controlled metadata about the prompt */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId(): JsonField = _xactId /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId(): JsonField = logId /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -147,7 +149,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -155,26 +159,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - id() - _xactId() - logId() - name() - orgId() - projectId() - slug() - created() - description() - functionType() - metadata().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + id() + _xactId() + logId() + name() + orgId() + projectId() + slug() + created() + description() + functionType() + metadata().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -184,6 +189,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: + * * ```java * .id() * ._xactId() @@ -194,7 +200,8 @@ private constructor( * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -216,72 +223,96 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - id = prompt.id - _xactId = prompt._xactId - logId = prompt.logId - name = prompt.name - orgId = prompt.orgId - projectId = prompt.projectId - slug = prompt.slug - created = prompt.created - description = prompt.description - functionType = prompt.functionType - metadata = prompt.metadata - promptData = prompt.promptData - tags = prompt.tags.map { it.toMutableList() } - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = + apply { + id = prompt.id + _xactId = prompt._xactId + logId = prompt.logId + name = prompt.name + orgId = prompt.orgId + projectId = prompt.projectId + slug = prompt.slug + created = prompt.created + description = prompt.description + functionType = prompt.functionType + metadata = prompt.metadata + promptData = prompt.promptData + tags = prompt.tags.map { it.toMutableList() } + additionalProperties = prompt.additionalProperties.toMutableMap() + } /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * The transaction id of an event is unique to the network operation that processed + * the event insertion. Transaction ids are monotonically increasing over time and + * can be used to retrieve a versioned snapshot of the prompt (see the `version` + * parameter) */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = + apply { + this._xactId = _xactId + } /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = + apply { + this.logId = logId + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Date of prompt creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -290,7 +321,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of prompt creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -299,17 +333,19 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -318,7 +354,10 @@ private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the prompt */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = + apply { + this.metadata = metadata + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -327,7 +366,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -336,65 +378,94 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = Prompt( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("logId", logId), - checkRequired("name", name), - checkRequired("orgId", orgId), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - created, - description, - functionType, - metadata, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "_xactId", _xactId + ), + checkRequired( + "logId", logId + ), + checkRequired( + "name", name + ), + checkRequired( + "orgId", orgId + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + created, + description, + functionType, + metadata, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** A literal 'p' which identifies the object as a project prompt */ - class LogId @JsonCreator private constructor(private val value: JsonField) : Enum { + class LogId @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -405,16 +476,18 @@ private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - P + P, } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] 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 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 { @@ -424,11 +497,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -439,11 +512,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -454,23 +527,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -478,18 +548,21 @@ private constructor( override fun toString() = value.toString() } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -513,12 +586,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] 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 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 { @@ -527,17 +603,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -551,11 +628,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -569,23 +646,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -595,11 +669,9 @@ private constructor( /** User-controlled metadata about the prompt */ @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metadata @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -608,20 +680,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + fun validate(): Metadata = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -630,38 +704,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = + apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -674,11 +756,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionType == other.functionType && metadata == other.metadata && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionType == other.functionType && metadata == other.metadata && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -687,6 +769,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Prompt{id=$id, _xactId=$_xactId, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionType=$functionType, metadata=$metadata, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{id=$id, _xactId=$_xactId, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionType=$functionType, metadata=$metadata, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 3eee9b8f..0a6c199e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -25,14 +25,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the one - * specified in the request, will return the existing prompt unmodified + * Create a new prompt. If there is an existing prompt in the project with the same + * slug as the one specified in the request, will return the existing prompt + * unmodified */ -class PromptCreateParams -private constructor( +class PromptCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the prompt */ @@ -81,39 +82,24 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the prompt */ @@ -126,27 +112,30 @@ private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -163,7 +152,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -171,21 +162,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + slug() + description() + functionType() + promptData().ifPresent { it.validate() } + tags() + validated = true } - name() - projectId() - slug() - description() - functionType() - promptData().ifPresent { it.validate() } - tags() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -194,13 +186,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -216,34 +210,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionType = body.functionType - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionType = body.functionType + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -252,19 +256,19 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -273,9 +277,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -284,54 +289,70 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - description, - functionType, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + description, + functionType, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -340,8 +361,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -352,13 +372,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptCreateParams]. */ @@ -370,206 +392,286 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptCreateParams: PromptCreateParams) = apply { - body = promptCreateParams.body.toBuilder() - additionalHeaders = promptCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = promptCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(promptCreateParams: PromptCreateParams) = + apply { + body = promptCreateParams.body.toBuilder() + additionalHeaders = promptCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptCreateParams.additionalQueryParams.toBuilder() + } /** Name of the prompt */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { body.slug(slug) } + fun slug(slug: String) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + fun functionType(functionType: FunctionType?) = + apply { + body.functionType(functionType) + } - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = + apply { + body.functionType(functionType) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptCreateParams = PromptCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -593,12 +695,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] 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 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 { @@ -607,17 +712,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -631,11 +737,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -649,23 +755,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -674,15 +777,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index c9faaa96..7ab2daf4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -33,25 +33,14 @@ import kotlin.jvm.optionals.getOrNull /** The prompt, model, and its parameters */ @NoAutoDetect -class PromptData -@JsonCreator -private constructor( - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("origin") - @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), - @JsonProperty("parser") - @ExcludeMissing - private val parser: JsonField = JsonMissing.of(), - @JsonProperty("prompt") - @ExcludeMissing - private val prompt: JsonField = JsonMissing.of(), - @JsonProperty("tool_functions") - @ExcludeMissing - private val toolFunctions: JsonField> = JsonMissing.of(), +class PromptData @JsonCreator private constructor( + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("parser") @ExcludeMissing private val parser: JsonField = JsonMissing.of(), + @JsonProperty("prompt") @ExcludeMissing private val prompt: JsonField = JsonMissing.of(), + @JsonProperty("tool_functions") @ExcludeMissing private val toolFunctions: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -62,16 +51,23 @@ private constructor( fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - fun toolFunctions(): Optional> = - Optional.ofNullable(toolFunctions.getNullable("tool_functions")) + fun toolFunctions(): Optional> = Optional.ofNullable(toolFunctions.getNullable("tool_functions")) - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin(): JsonField = origin - @JsonProperty("parser") @ExcludeMissing fun _parser(): JsonField = parser + @JsonProperty("parser") + @ExcludeMissing + fun _parser(): JsonField = parser - @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField = prompt + @JsonProperty("prompt") + @ExcludeMissing + fun _prompt(): JsonField = prompt @JsonProperty("tool_functions") @ExcludeMissing @@ -83,25 +79,27 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptData = apply { - if (validated) { - return@apply - } + fun validate(): PromptData = + apply { + if (validated) { + return@apply + } - options().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - parser().ifPresent { it.validate() } - prompt().ifPresent { it.validate() } - toolFunctions().ifPresent { it.forEach { it.validate() } } - validated = true - } + options().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + parser().ifPresent { it.validate() } + prompt().ifPresent { it.validate() } + toolFunctions().ifPresent { it.forEach { it.validate() } } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [PromptData]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptData]. */ @@ -115,124 +113,135 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptData: PromptData) = apply { - options = promptData.options - origin = promptData.origin - parser = promptData.parser - prompt = promptData.prompt - toolFunctions = promptData.toolFunctions.map { it.toMutableList() } - additionalProperties = promptData.additionalProperties.toMutableMap() - } + internal fun from(promptData: PromptData) = + apply { + options = promptData.options + origin = promptData.origin + parser = promptData.parser + prompt = promptData.prompt + toolFunctions = promptData.toolFunctions.map { it.toMutableList() } + additionalProperties = promptData.additionalProperties.toMutableMap() + } fun options(options: PromptOptions?) = options(JsonField.ofNullable(options)) fun options(options: Optional) = options(options.getOrNull()) - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = + apply { + this.origin = origin + } fun parser(parser: Parser?) = parser(JsonField.ofNullable(parser)) fun parser(parser: Optional) = parser(parser.getOrNull()) - fun parser(parser: JsonField) = apply { this.parser = parser } + fun parser(parser: JsonField) = + apply { + this.parser = parser + } fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - fun prompt(prompt: JsonField) = apply { this.prompt = prompt } + fun prompt(prompt: JsonField) = + apply { + this.prompt = prompt + } fun prompt(completion: Prompt.Completion) = prompt(Prompt.ofCompletion(completion)) fun prompt(chat: Prompt.Chat) = prompt(Prompt.ofChat(chat)) - fun prompt(nullableVariant: Prompt.NullableVariant) = - prompt(Prompt.ofNullableVariant(nullableVariant)) + fun prompt(nullableVariant: Prompt.NullableVariant) = prompt(Prompt.ofNullableVariant(nullableVariant)) - fun toolFunctions(toolFunctions: List?) = - toolFunctions(JsonField.ofNullable(toolFunctions)) + fun toolFunctions(toolFunctions: List?) = toolFunctions(JsonField.ofNullable(toolFunctions)) - fun toolFunctions(toolFunctions: Optional>) = - toolFunctions(toolFunctions.getOrNull()) + fun toolFunctions(toolFunctions: Optional>) = toolFunctions(toolFunctions.getOrNull()) - fun toolFunctions(toolFunctions: JsonField>) = apply { - this.toolFunctions = toolFunctions.map { it.toMutableList() } - } + fun toolFunctions(toolFunctions: JsonField>) = + apply { + this.toolFunctions = toolFunctions.map { it.toMutableList() } + } - fun addToolFunction(toolFunction: ToolFunction) = apply { - toolFunctions = - (toolFunctions ?: JsonField.of(mutableListOf())).also { + fun addToolFunction(toolFunction: ToolFunction) = + apply { + toolFunctions = (toolFunctions ?: JsonField.of(mutableListOf())).also { checkKnown("toolFunctions", it).add(toolFunction) } - } + } - fun addToolFunction(function: ToolFunction.Function) = - addToolFunction(ToolFunction.ofFunction(function)) + fun addToolFunction(function: ToolFunction.Function) = addToolFunction(ToolFunction.ofFunction(function)) - fun addToolFunction(global: ToolFunction.Global) = - addToolFunction(ToolFunction.ofGlobal(global)) + fun addToolFunction(global: ToolFunction.Global) = addToolFunction(ToolFunction.ofGlobal(global)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptData = PromptData( - options, - origin, - parser, - prompt, - (toolFunctions ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + options, + origin, + parser, + prompt, + (toolFunctions ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_id") - @ExcludeMissing - private val promptId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_version") - @ExcludeMissing - private val promptVersion: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Origin @JsonCreator private constructor( + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_id") @ExcludeMissing private val promptId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_version") @ExcludeMissing private val promptVersion: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) fun promptId(): Optional = Optional.ofNullable(promptId.getNullable("prompt_id")) - fun promptVersion(): Optional = - Optional.ofNullable(promptVersion.getNullable("prompt_version")) + fun promptVersion(): Optional = Optional.ofNullable(promptVersion.getNullable("prompt_version")) - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId(): JsonField = promptId + @JsonProperty("prompt_id") + @ExcludeMissing + fun _promptId(): JsonField = promptId @JsonProperty("prompt_version") @ExcludeMissing @@ -244,23 +253,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Origin = apply { - if (validated) { - return@apply - } + fun validate(): Origin = + apply { + if (validated) { + return@apply + } - projectId() - promptId() - promptVersion() - validated = true - } + projectId() + promptId() + promptVersion() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Origin]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Origin]. */ @@ -272,56 +283,76 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = apply { - projectId = origin.projectId - promptId = origin.promptId - promptVersion = origin.promptVersion - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = + apply { + projectId = origin.projectId + promptId = origin.promptId + promptVersion = origin.promptVersion + additionalProperties = origin.additionalProperties.toMutableMap() + } fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } + fun promptId(promptId: JsonField) = + apply { + this.promptId = promptId + } fun promptVersion(promptVersion: String) = promptVersion(JsonField.of(promptVersion)) - fun promptVersion(promptVersion: JsonField) = apply { - this.promptVersion = promptVersion - } + fun promptVersion(promptVersion: JsonField) = + apply { + this.promptVersion = promptVersion + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = - Origin(projectId, promptId, promptVersion, additionalProperties.toImmutable()) + Origin( + projectId, + promptId, + promptVersion, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && projectId == other.projectId && promptId == other.promptId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && projectId == other.projectId && promptId == other.promptId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -330,23 +361,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Origin{projectId=$projectId, promptId=$promptId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{projectId=$projectId, promptId=$promptId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Parser - @JsonCreator - private constructor( - @JsonProperty("choice_scores") - @ExcludeMissing - private val choiceScores: JsonField = JsonMissing.of(), + class Parser @JsonCreator private constructor( + @JsonProperty("choice_scores") @ExcludeMissing private val choiceScores: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("use_cot") - @ExcludeMissing - private val useCot: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("use_cot") @ExcludeMissing private val useCot: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun choiceScores(): ChoiceScores = choiceScores.getRequired("choice_scores") @@ -359,9 +383,13 @@ private constructor( @ExcludeMissing fun _choiceScores(): JsonField = choiceScores - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type - @JsonProperty("use_cot") @ExcludeMissing fun _useCot(): JsonField = useCot + @JsonProperty("use_cot") + @ExcludeMissing + fun _useCot(): JsonField = useCot @JsonAnyGetter @ExcludeMissing @@ -369,16 +397,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Parser = apply { - if (validated) { - return@apply - } + fun validate(): Parser = + apply { + if (validated) { + return@apply + } - choiceScores().validate() - type() - useCot() - validated = true - } + choiceScores().validate() + type() + useCot() + validated = true + } fun toBuilder() = Builder().from(this) @@ -388,13 +417,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Parser]. * * The following fields are required: + * * ```java * .choiceScores() * .type() * .useCot() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Parser]. */ @@ -406,61 +437,80 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(parser: Parser) = apply { - choiceScores = parser.choiceScores - type = parser.type - useCot = parser.useCot - additionalProperties = parser.additionalProperties.toMutableMap() - } + internal fun from(parser: Parser) = + apply { + choiceScores = parser.choiceScores + type = parser.type + useCot = parser.useCot + additionalProperties = parser.additionalProperties.toMutableMap() + } fun choiceScores(choiceScores: ChoiceScores) = choiceScores(JsonField.of(choiceScores)) - fun choiceScores(choiceScores: JsonField) = apply { - this.choiceScores = choiceScores - } + fun choiceScores(choiceScores: JsonField) = + apply { + this.choiceScores = choiceScores + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun useCot(useCot: Boolean) = useCot(JsonField.of(useCot)) - fun useCot(useCot: JsonField) = apply { this.useCot = useCot } + fun useCot(useCot: JsonField) = + apply { + this.useCot = useCot + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Parser = Parser( - checkRequired("choiceScores", choiceScores), - checkRequired("type", type), - checkRequired("useCot", useCot), - additionalProperties.toImmutable(), + checkRequired( + "choiceScores", choiceScores + ), + checkRequired( + "type", type + ), + checkRequired( + "useCot", useCot + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ChoiceScores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class ChoiceScores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -469,20 +519,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ChoiceScores = apply { - if (validated) { - return@apply - } + fun validate(): ChoiceScores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ChoiceScores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ChoiceScores]. */ @@ -491,41 +543,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(choiceScores: ChoiceScores) = apply { - additionalProperties = choiceScores.additionalProperties.toMutableMap() - } + internal fun from(choiceScores: ChoiceScores) = + apply { + additionalProperties = choiceScores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChoiceScores = ChoiceScores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChoiceScores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChoiceScores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -537,17 +594,21 @@ private constructor( override fun toString() = "ChoiceScores{additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -558,16 +619,18 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - LLM_CLASSIFIER + LLM_CLASSIFIER, } /** * 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 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 { @@ -580,8 +643,8 @@ private constructor( * 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. + * 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) { @@ -596,7 +659,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -610,20 +673,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -632,11 +692,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Parser && choiceScores == other.choiceScores && type == other.type && useCot == other.useCot && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Parser && choiceScores == other.choiceScores && type == other.type && useCot == other.useCot && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -645,18 +705,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Parser{choiceScores=$choiceScores, type=$type, useCot=$useCot, additionalProperties=$additionalProperties}" + override fun toString() = "Parser{choiceScores=$choiceScores, type=$type, useCot=$useCot, additionalProperties=$additionalProperties}" } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt - private constructor( + class Prompt private constructor( private val completion: Completion? = null, private val chat: Chat? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { fun completion(): Optional = Optional.ofNullable(completion) @@ -680,45 +739,44 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - completion != null -> visitor.visitCompletion(completion) - chat != null -> visitor.visitChat(chat) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Prompt = apply { - if (validated) { - return@apply - } + fun validate(): Prompt = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitCompletion(completion: Completion) { - completion.validate() + completion.validate() } override fun visitChat(chat: Chat) { - chat.validate() + chat.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(completion, chat, nullableVariant) /* spotless:on */ @@ -734,16 +792,20 @@ private constructor( companion object { - @JvmStatic fun ofCompletion(completion: Completion) = Prompt(completion = completion) + @JvmStatic + fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) + @JvmStatic + fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Prompt(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Prompt(nullableVariant = nullableVariant) } - /** An interface that defines how to map each variant of [Prompt] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Prompt] to a value of type + * [T]. + */ interface Visitor { fun visitCompletion(completion: Completion): T @@ -755,78 +817,69 @@ private constructor( /** * Maps an unknown variant of [Prompt] to a value of type [T]. * - * An instance of [Prompt] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Prompt] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } internal class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(completion = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(chat = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(nullableVariant = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } internal class Serializer : BaseSerializer(Prompt::class) { - override fun serialize( - value: Prompt, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.completion != null -> generator.writeObject(value.completion) - value.chat != null -> generator.writeObject(value.chat) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } @NoAutoDetect - class Completion - @JsonCreator - private constructor( - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Completion @JsonCreator private constructor( + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun content(): String = content.getRequired("content") fun type(): Type = type.getRequired("type") - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -834,15 +887,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Completion = apply { - if (validated) { - return@apply - } + fun validate(): Completion = + apply { + if (validated) { + return@apply + } - content() - type() - validated = true - } + content() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -852,12 +906,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Completion]. * * The following fields are required: + * * ```java * .content() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Completion]. */ @@ -868,52 +924,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(completion: Completion) = apply { - content = completion.content - type = completion.type - additionalProperties = completion.additionalProperties.toMutableMap() - } + internal fun from(completion: Completion) = + apply { + content = completion.content + type = completion.type + additionalProperties = completion.additionalProperties.toMutableMap() + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Completion = Completion( - checkRequired("content", content), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "content", content + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -923,7 +996,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -934,23 +1008,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - COMPLETION + COMPLETION, } /** * 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 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 { COMPLETION, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -974,7 +1048,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -989,19 +1063,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1010,11 +1081,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Completion && content == other.content && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Completion && content == other.content && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1023,25 +1094,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Completion{content=$content, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Completion{content=$content, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Chat - @JsonCreator - private constructor( - @JsonProperty("messages") - @ExcludeMissing - private val messages: JsonField> = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonProperty("tools") - @ExcludeMissing - private val tools: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Chat @JsonCreator private constructor( + @JsonProperty("messages") @ExcludeMissing private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("tools") @ExcludeMissing private val tools: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun messages(): List = messages.getRequired("messages") @@ -1054,9 +1116,13 @@ private constructor( @ExcludeMissing fun _messages(): JsonField> = messages - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type - @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField = tools + @JsonProperty("tools") + @ExcludeMissing + fun _tools(): JsonField = tools @JsonAnyGetter @ExcludeMissing @@ -1064,16 +1130,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Chat = apply { - if (validated) { - return@apply - } + fun validate(): Chat = + apply { + if (validated) { + return@apply + } - messages().forEach { it.validate() } - type() - tools() - validated = true - } + messages().forEach { it.validate() } + type() + tools() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1083,12 +1150,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Chat]. * * The following fields are required: + * * ```java * .messages() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Chat]. */ @@ -1100,84 +1169,96 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chat: Chat) = apply { - messages = chat.messages.map { it.toMutableList() } - type = chat.type - tools = chat.tools - additionalProperties = chat.additionalProperties.toMutableMap() - } + internal fun from(chat: Chat) = + apply { + messages = chat.messages.map { it.toMutableList() } + type = chat.type + tools = chat.tools + additionalProperties = chat.additionalProperties.toMutableMap() + } fun messages(messages: List) = messages(JsonField.of(messages)) - fun messages(messages: JsonField>) = apply { - this.messages = messages.map { it.toMutableList() } - } + fun messages(messages: JsonField>) = + apply { + this.messages = messages.map { it.toMutableList() } + } - fun addMessage(message: Message) = apply { - messages = - (messages ?: JsonField.of(mutableListOf())).also { + fun addMessage(message: Message) = + apply { + messages = (messages ?: JsonField.of(mutableListOf())).also { checkKnown("messages", it).add(message) } - } + } fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) - fun addMessage(assistant: Message.Assistant) = - addMessage(Message.ofAssistant(assistant)) + fun addMessage(assistant: Message.Assistant) = addMessage(Message.ofAssistant(assistant)) fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) - fun addMessage(function: Message.Function) = - addMessage(Message.ofFunction(function)) + fun addMessage(function: Message.Function) = addMessage(Message.ofFunction(function)) - fun addMessage(fallback: Message.Fallback) = - addMessage(Message.ofFallback(fallback)) + fun addMessage(fallback: Message.Fallback) = addMessage(Message.ofFallback(fallback)) fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun tools(tools: String) = tools(JsonField.of(tools)) - fun tools(tools: JsonField) = apply { this.tools = tools } + fun tools(tools: JsonField) = + apply { + this.tools = tools + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Chat = Chat( - checkRequired("messages", messages).map { it.toImmutable() }, - checkRequired("type", type), - tools, - additionalProperties.toImmutable(), + checkRequired( + "messages", messages + ).map { it.toImmutable() }, + checkRequired( + "type", type + ), + tools, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( + class Message private constructor( private val system: System? = null, private val user: User? = null, private val assistant: Assistant? = null, @@ -1185,6 +1266,7 @@ private constructor( private val function: Function? = null, private val fallback: Fallback? = null, private val _json: JsonValue? = null, + ) { fun system(): Optional = Optional.ofNullable(system) @@ -1226,60 +1308,59 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Message = apply { - if (validated) { - return@apply - } + fun validate(): Message = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitSystem(system: System) { - system.validate() + system.validate() } override fun visitUser(user: User) { - user.validate() + user.validate() } override fun visitAssistant(assistant: Assistant) { - assistant.validate() + assistant.validate() } override fun visitTool(tool: Tool) { - tool.validate() + tool.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitFallback(fallback: Fallback) { - fallback.validate() + fallback.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ + return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ @@ -1298,23 +1379,28 @@ private constructor( companion object { - @JvmStatic fun ofSystem(system: System) = Message(system = system) + @JvmStatic + fun ofSystem(system: System) = Message(system = system) - @JvmStatic fun ofUser(user: User) = Message(user = user) + @JvmStatic + fun ofUser(user: User) = Message(user = user) @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) + @JvmStatic + fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic fun ofFunction(function: Function) = Message(function = function) + @JvmStatic + fun ofFunction(function: Function) = Message(function = function) - @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + @JvmStatic + fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } /** - * An interface that defines how to map each variant of [Message] to a value of type - * [T]. + * An interface that defines how to map each variant of [Message] to a value of + * type [T]. */ interface Visitor { @@ -1333,103 +1419,88 @@ private constructor( /** * Maps an unknown variant of [Message] to a value of type [T]. * - * An instance of [Message] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * An instance of [Message] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } internal class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } internal class Serializer : BaseSerializer(Message::class) { - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } @NoAutoDetect - class System - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class System @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1437,16 +1508,17 @@ private constructor( private var validated: Boolean = false - fun validate(): System = apply { - if (validated) { - return@apply - } + fun validate(): System = + apply { + if (validated) { + return@apply + } - role() - content() - name() - validated = true - } + role() + content() + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1456,11 +1528,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [System]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [System]. */ @@ -1469,28 +1543,37 @@ private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(system: System) = apply { - role = system.role - content = system.content - name = system.name - additionalProperties = system.additionalProperties.toMutableMap() - } + internal fun from(system: System) = + apply { + role = system.role + content = system.content + name = system.name + additionalProperties = system.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1498,42 +1581,49 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): System = System( - checkRequired("role", role), - content, - name, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + name, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @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. + * 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 @@ -1547,25 +1637,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - SYSTEM + SYSTEM, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { SYSTEM, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1573,8 +1661,8 @@ private constructor( * 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. + * 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) { @@ -1585,11 +1673,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1600,23 +1688,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1625,11 +1710,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1638,41 +1723,35 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class User - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + override fun toString() = "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class User @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1680,16 +1759,17 @@ private constructor( private var validated: Boolean = false - fun validate(): User = apply { - if (validated) { - return@apply - } + fun validate(): User = + apply { + if (validated) { + return@apply + } - role() - content().ifPresent { it.validate() } - name() - validated = true - } + role() + content().ifPresent { it.validate() } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1699,11 +1779,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [User]. */ @@ -1712,33 +1794,41 @@ private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(user: User) = apply { - role = user.role - content = user.content - name = user.name - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = + apply { + role = user.role + content = user.content + name = user.name + additionalProperties = user.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: Content) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun content(text: String) = content(Content.ofText(text)) - fun contentOfArray(array: List) = - content(Content.ofArray(array)) + fun contentOfArray(array: List) = content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1746,42 +1836,49 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired("role", role), - content, - name, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + name, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @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. + * 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 @@ -1795,25 +1892,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - USER + USER, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { USER, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1821,8 +1916,8 @@ private constructor( * 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. + * 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) { @@ -1833,11 +1928,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1848,23 +1943,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1874,17 +1966,16 @@ private constructor( @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( + class Content private constructor( private val text: String? = null, private val array: List? = null, private val _json: JsonValue? = null, + ) { fun text(): Optional = Optional.ofNullable(text) - fun array(): Optional> = - Optional.ofNullable(array) + fun array(): Optional> = Optional.ofNullable(array) fun isText(): Boolean = text != null @@ -1897,40 +1988,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Content = apply { - if (validated) { - return@apply - } + fun validate(): Content = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitText(text: String) {} + accept(object : Visitor { + override fun visitText(text: String) { - override fun visitArray( - array: List - ) { - array.forEach { it.validate() } } - } - ) - validated = true - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun visitArray(array: List) { + array.forEach { it.validate() } + } + }) + validated = true } - return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, array) /* spotless:on */ @@ -1945,16 +2035,16 @@ private constructor( companion object { - @JvmStatic fun ofText(text: String) = Content(text = text) + @JvmStatic + fun ofText(text: String) = Content(text = text) @JvmStatic - fun ofArray(array: List) = - Content(array = array) + fun ofArray(array: List) = Content(array = array) } /** - * An interface that defines how to map each variant of [Content] to a value - * of type [T]. + * An interface that defines how to map each variant of [Content] to a value of + * type [T]. */ interface Visitor { @@ -1965,70 +2055,58 @@ private constructor( /** * Maps an unknown variant of [Content] to a value of type [T]. * - * An instance of [Content] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new variants that the SDK is unaware of. + * An instance of [Content] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } internal class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>(), - ) { - it.forEach { it.validate() } - } - ?.let { - return Content(array = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { + return Content(array = it, _json = json) + } - return Content(_json = json) + return Content(_json = json) } } internal class Serializer : BaseSerializer(Content::class) { - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart - private constructor( + class ChatCompletionContentPart private constructor( private val text: ChatCompletionContentPartText? = null, private val image: ChatCompletionContentPartImage? = null, private val _json: JsonValue? = null, + ) { - fun text(): Optional = - Optional.ofNullable(text) + fun text(): Optional = Optional.ofNullable(text) - fun image(): Optional = - Optional.ofNullable(image) + fun image(): Optional = Optional.ofNullable(image) fun isText(): Boolean = text != null @@ -2036,50 +2114,44 @@ private constructor( fun asText(): ChatCompletionContentPartText = text.getOrThrow("text") - fun asImage(): ChatCompletionContentPartImage = - image.getOrThrow("image") + fun asImage(): ChatCompletionContentPartImage = image.getOrThrow("image") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - image != null -> visitor.visitImage(image) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ChatCompletionContentPart = apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPart = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitText( - text: ChatCompletionContentPartText - ) { - text.validate() + accept(object : Visitor { + override fun visitText(text: ChatCompletionContentPartText) { + text.validate() } - override fun visitImage( - image: ChatCompletionContentPartImage - ) { - image.validate() + override fun visitImage(image: ChatCompletionContentPartImage) { + image.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, image) /* spotless:on */ @@ -2089,26 +2161,21 @@ private constructor( text != null -> "ChatCompletionContentPart{text=$text}" image != null -> "ChatCompletionContentPart{image=$image}" _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") } companion object { @JvmStatic - fun ofText(text: ChatCompletionContentPartText) = - ChatCompletionContentPart(text = text) + fun ofText(text: ChatCompletionContentPartText) = ChatCompletionContentPart(text = text) @JvmStatic - fun ofImage(image: ChatCompletionContentPartImage) = - ChatCompletionContentPart(image = image) + fun ofImage(image: ChatCompletionContentPartImage) = ChatCompletionContentPart(image = image) } /** - * An interface that defines how to map each variant of - * [ChatCompletionContentPart] to a value of type [T]. + * An interface that defines how to map each variant of [ChatCompletionContentPart] + * to a value of type [T]. */ interface Visitor { @@ -2117,94 +2184,56 @@ private constructor( fun visitImage(image: ChatCompletionContentPartImage): T /** - * Maps an unknown variant of [ChatCompletionContentPart] to a value - * of type [T]. + * Maps an unknown variant of [ChatCompletionContentPart] to a value of type [T]. * - * An instance of [ChatCompletionContentPart] can contain an unknown - * variant if it was deserialized from data that doesn't match any - * known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [ChatCompletionContentPart] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * - * @throws BraintrustInvalidDataException in the default - * implementation. + * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown ChatCompletionContentPart: $json" - ) + throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") } } - internal class Deserializer : - BaseDeserializer( - ChatCompletionContentPart::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - text = it, - _json = json, - ) - } - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return ChatCompletionContentPart( - image = it, - _json = json, - ) - } + internal class Deserializer : BaseDeserializer(ChatCompletionContentPart::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) - return ChatCompletionContentPart(_json = json) + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ChatCompletionContentPart(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ChatCompletionContentPart(image = it, _json = json) + } + + return ChatCompletionContentPart(_json = json) } } - internal class Serializer : - BaseSerializer( - ChatCompletionContentPart::class - ) { - - override fun serialize( - value: ChatCompletionContentPart, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.image != null -> generator.writeObject(value.image) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid ChatCompletionContentPart" - ) - } + internal class Serializer : BaseSerializer(ChatCompletionContentPart::class) { + + override fun serialize(value: ChatCompletionContentPart, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + } } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2213,48 +2242,33 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Assistant - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("function_call") - @ExcludeMissing - private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tool_calls") - @ExcludeMissing - private val toolCalls: JsonField> = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Assistant @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("tool_calls") @ExcludeMissing private val toolCalls: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = - Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2264,7 +2278,9 @@ private constructor( @ExcludeMissing fun _functionCall(): JsonField = functionCall - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("tool_calls") @ExcludeMissing @@ -2276,18 +2292,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Assistant = apply { - if (validated) { - return@apply - } + fun validate(): Assistant = + apply { + if (validated) { + return@apply + } - role() - content() - functionCall().ifPresent { it.validate() } - name() - toolCalls().ifPresent { it.forEach { it.validate() } } - validated = true - } + role() + content() + functionCall().ifPresent { it.validate() } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } fun toBuilder() = Builder().from(this) @@ -2297,11 +2314,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Assistant]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Assistant]. */ @@ -2311,65 +2330,69 @@ private constructor( private var content: JsonField = JsonMissing.of() private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var toolCalls: - JsonField>? = - null - private var additionalProperties: MutableMap = - mutableMapOf() + private var toolCalls: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(assistant: Assistant) = apply { - role = assistant.role - content = assistant.content - functionCall = assistant.functionCall - name = assistant.name - toolCalls = assistant.toolCalls.map { it.toMutableList() } - additionalProperties = assistant.additionalProperties.toMutableMap() - } + internal fun from(assistant: Assistant) = + apply { + role = assistant.role + content = assistant.content + functionCall = assistant.functionCall + name = assistant.name + toolCalls = assistant.toolCalls.map { it.toMutableList() } + additionalProperties = assistant.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } - fun functionCall(functionCall: FunctionCall?) = - functionCall(JsonField.ofNullable(functionCall)) + fun functionCall(functionCall: FunctionCall?) = functionCall(JsonField.ofNullable(functionCall)) - fun functionCall(functionCall: Optional) = - functionCall(functionCall.getOrNull()) + fun functionCall(functionCall: Optional) = functionCall(functionCall.getOrNull()) - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } + fun functionCall(functionCall: JsonField) = + apply { + this.functionCall = functionCall + } fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.getOrNull()) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun toolCalls(toolCalls: List?) = - toolCalls(JsonField.ofNullable(toolCalls)) + fun toolCalls(toolCalls: List?) = toolCalls(JsonField.ofNullable(toolCalls)) - fun toolCalls(toolCalls: Optional>) = - toolCalls(toolCalls.getOrNull()) + fun toolCalls(toolCalls: Optional>) = toolCalls(toolCalls.getOrNull()) fun toolCalls(toolCalls: JsonField>) = apply { this.toolCalls = toolCalls.map { it.toMutableList() } } - fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { - toolCalls = - (toolCalls ?: JsonField.of(mutableListOf())).also { + fun addToolCall(toolCall: ChatCompletionMessageToolCall) = + apply { + toolCalls = (toolCalls ?: JsonField.of(mutableListOf())).also { checkKnown("toolCalls", it).add(toolCall) } - } + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2377,44 +2400,51 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Assistant = Assistant( - checkRequired("role", role), - content, - functionCall, - name, - (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + functionCall, + name, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @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. + * 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 @@ -2428,25 +2458,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - ASSISTANT + ASSISTANT, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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. + * 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 { ASSISTANT, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2454,8 +2482,8 @@ private constructor( * 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. + * 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) { @@ -2466,11 +2494,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2481,23 +2509,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2506,18 +2531,11 @@ private constructor( } @NoAutoDetect - class FunctionCall - @JsonCreator - private constructor( - @JsonProperty("arguments") - @ExcludeMissing - private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class FunctionCall @JsonCreator private constructor( + @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun arguments(): String = arguments.getRequired("arguments") @@ -2528,7 +2546,9 @@ private constructor( @ExcludeMissing fun _arguments(): JsonField = arguments - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2536,31 +2556,33 @@ private constructor( private var validated: Boolean = false - fun validate(): FunctionCall = apply { - if (validated) { - return@apply - } + fun validate(): FunctionCall = + apply { + if (validated) { + return@apply + } - arguments() - name() - validated = true - } + arguments() + name() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionCall]. + * Returns a mutable builder for constructing an instance of [FunctionCall]. * * The following fields are required: + * * ```java * .arguments() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [FunctionCall]. */ @@ -2568,26 +2590,29 @@ private constructor( private var arguments: JsonField? = null private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionCall: FunctionCall) = apply { - arguments = functionCall.arguments - name = functionCall.name - additionalProperties = - functionCall.additionalProperties.toMutableMap() - } + internal fun from(functionCall: FunctionCall) = + apply { + arguments = functionCall.arguments + name = functionCall.name + additionalProperties = functionCall.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = apply { - this.arguments = arguments - } + fun arguments(arguments: JsonField) = + apply { + this.arguments = arguments + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2595,36 +2620,44 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionCall = FunctionCall( - checkRequired("arguments", arguments), - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "arguments", arguments + ), + checkRequired( + "name", name + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2633,16 +2666,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2651,36 +2683,27 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Tool - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonProperty("tool_call_id") - @ExcludeMissing - private val toolCallId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Tool @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonProperty("tool_call_id") @ExcludeMissing private val toolCallId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun toolCallId(): Optional = - Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2696,16 +2719,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Tool = apply { - if (validated) { - return@apply - } + fun validate(): Tool = + apply { + if (validated) { + return@apply + } - role() - content() - toolCallId() - validated = true - } + role() + content() + toolCallId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2715,11 +2739,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Tool]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Tool]. */ @@ -2728,30 +2754,37 @@ private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tool: Tool) = apply { - role = tool.role - content = tool.content - toolCallId = tool.toolCallId - additionalProperties = tool.additionalProperties.toMutableMap() - } + internal fun from(tool: Tool) = + apply { + role = tool.role + content = tool.content + toolCallId = tool.toolCallId + additionalProperties = tool.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - fun toolCallId(toolCallId: JsonField) = apply { - this.toolCallId = toolCallId - } + fun toolCallId(toolCallId: JsonField) = + apply { + this.toolCallId = toolCallId + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2759,42 +2792,49 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Tool = Tool( - checkRequired("role", role), - content, - toolCallId, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + toolCallId, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @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. + * 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 @@ -2808,25 +2848,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - TOOL + TOOL, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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. + * 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 { TOOL, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2834,8 +2872,8 @@ private constructor( * 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. + * 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) { @@ -2846,11 +2884,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2861,23 +2899,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2886,11 +2921,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2899,37 +2934,31 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2941,16 +2970,17 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - name() - role() - content() - validated = true - } + name() + role() + content() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2960,12 +2990,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .name() * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -2974,28 +3006,37 @@ private constructor( private var name: JsonField? = null private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - name = function.name - role = function.role - content = function.content - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + name = function.name + role = function.role + content = function.content + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun additionalProperties(additionalProperties: Map) = apply { @@ -3003,42 +3044,51 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("name", name), - checkRequired("role", role), - content, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "role", role + ), + content, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @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. + * 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 @@ -3052,25 +3102,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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. + * 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 { FUNCTION, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -3078,8 +3126,8 @@ private constructor( * 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. + * 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) { @@ -3090,11 +3138,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -3105,23 +3153,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3130,11 +3175,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3143,30 +3188,24 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Fallback - @JsonCreator - private constructor( - @JsonProperty("role") - @ExcludeMissing - private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - private val content: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Fallback @JsonCreator private constructor( + @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + @JsonProperty("role") + @ExcludeMissing + fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -3178,15 +3217,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Fallback = apply { - if (validated) { - return@apply - } + fun validate(): Fallback = + apply { + if (validated) { + return@apply + } - role() - content() - validated = true - } + role() + content() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3196,11 +3236,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Fallback]. * * The following fields are required: + * * ```java * .role() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Fallback]. */ @@ -3208,25 +3250,31 @@ private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fallback: Fallback) = apply { - role = fallback.role - content = fallback.content - additionalProperties = fallback.additionalProperties.toMutableMap() - } + internal fun from(fallback: Fallback) = + apply { + role = fallback.role + content = fallback.content + additionalProperties = fallback.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = + apply { + this.role = role + } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = + apply { + this.content = content + } fun additionalProperties(additionalProperties: Map) = apply { @@ -3234,41 +3282,48 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Fallback = Fallback( - checkRequired("role", role), - content, - additionalProperties.toImmutable(), + checkRequired( + "role", role + ), + content, + additionalProperties.toImmutable(), ) } - class Role - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class Role @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. + * 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 @@ -3282,25 +3337,23 @@ private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - MODEL + MODEL, } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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. + * 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 { MODEL, - /** - * An enum member indicating that [Role] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Role] was instantiated with an unknown value. */ _UNKNOWN, } @@ -3308,8 +3361,8 @@ private constructor( * 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. + * 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) { @@ -3320,11 +3373,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -3335,23 +3388,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3360,11 +3410,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3373,13 +3423,14 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -3389,7 +3440,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -3400,23 +3452,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CHAT + CHAT, } /** * 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 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 { CHAT, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -3440,7 +3492,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3455,19 +3507,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3476,11 +3525,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Chat && messages == other.messages && type == other.type && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Chat && messages == other.messages && type == other.type && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3489,16 +3538,13 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -3507,20 +3553,22 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -3529,41 +3577,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3578,11 +3631,11 @@ private constructor( @JsonDeserialize(using = ToolFunction.Deserializer::class) @JsonSerialize(using = ToolFunction.Serializer::class) - class ToolFunction - private constructor( + class ToolFunction private constructor( private val function: Function? = null, private val global: Global? = null, private val _json: JsonValue? = null, + ) { fun function(): Optional = Optional.ofNullable(function) @@ -3600,40 +3653,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - function != null -> visitor.visitFunction(function) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + function != null -> visitor.visitFunction(function) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ToolFunction = apply { - if (validated) { - return@apply - } + fun validate(): ToolFunction = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ToolFunction && function == other.function && global == other.global /* spotless:on */ + return /* spotless:off */ other is ToolFunction && function == other.function && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(function, global) /* spotless:on */ @@ -3648,14 +3700,16 @@ private constructor( companion object { - @JvmStatic fun ofFunction(function: Function) = ToolFunction(function = function) + @JvmStatic + fun ofFunction(function: Function) = ToolFunction(function = function) - @JvmStatic fun ofGlobal(global: Global) = ToolFunction(global = global) + @JvmStatic + fun ofGlobal(global: Global) = ToolFunction(global = global) } /** - * An interface that defines how to map each variant of [ToolFunction] to a value of type - * [T]. + * An interface that defines how to map each variant of [ToolFunction] to a value + * of type [T]. */ interface Visitor { @@ -3666,73 +3720,65 @@ private constructor( /** * Maps an unknown variant of [ToolFunction] to a value of type [T]. * - * An instance of [ToolFunction] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [ToolFunction] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolFunction: $json") + throw BraintrustInvalidDataException("Unknown ToolFunction: $json") } } internal class Deserializer : BaseDeserializer(ToolFunction::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolFunction { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolFunction(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolFunction(global = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ToolFunction(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ToolFunction(global = it, _json = json) + } - return ToolFunction(_json = json) + return ToolFunction(_json = json) } } internal class Serializer : BaseSerializer(ToolFunction::class) { - override fun serialize( - value: ToolFunction, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.function != null -> generator.writeObject(value.function) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolFunction") - } + override fun serialize(value: ToolFunction, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.function != null -> generator.writeObject(value.function) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolFunction") + } } } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun id(): String = id.getRequired("id") fun type(): Type = type.getRequired("type") - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3740,15 +3786,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - id() - type() - validated = true - } + id() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3758,12 +3805,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .id() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -3774,52 +3823,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - id = function.id - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + id = function.id + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("id", id), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -3829,7 +3895,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -3840,23 +3907,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** * 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 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 { FUNCTION, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -3880,7 +3947,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3895,19 +3962,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3916,11 +3980,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3929,31 +3993,28 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Global @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3961,15 +4022,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Global = apply { - if (validated) { - return@apply - } + fun validate(): Global = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -3979,12 +4041,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: + * * ```java * .name() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Global]. */ @@ -3995,52 +4059,69 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = + apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired("name", name), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + class Type @JsonCreator private constructor( + private val value: JsonField, + + ) : Enum { /** * Returns this class instance's raw value. @@ -4050,7 +4131,8 @@ private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -4061,23 +4143,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL + GLOBAL, } /** * 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 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 { GLOBAL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4101,7 +4183,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -4116,19 +4198,16 @@ private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = - _value().asString().orElseThrow { - BraintrustInvalidDataException("Value is not a String") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4137,11 +4216,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4150,17 +4229,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptData && options == other.options && origin == other.origin && parser == other.parser && prompt == other.prompt && toolFunctions == other.toolFunctions && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptData && options == other.options && origin == other.origin && parser == other.parser && prompt == other.prompt && toolFunctions == other.toolFunctions && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4169,6 +4247,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PromptData{options=$options, origin=$origin, parser=$parser, prompt=$prompt, toolFunctions=$toolFunctions, additionalProperties=$additionalProperties}" + override fun toString() = "PromptData{options=$options, origin=$origin, parser=$parser, prompt=$prompt, toolFunctions=$toolFunctions, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index a76243f9..54c1ceb1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a prompt object by its id */ -class PromptDeleteParams -private constructor( +class PromptDeleteParams private constructor( private val promptId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Prompt id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptDeleteParams]. * * The following fields are required: + * * ```java * .promptId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptDeleteParams: PromptDeleteParams) = apply { - promptId = promptDeleteParams.promptId - additionalHeaders = promptDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = promptDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = promptDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(promptDeleteParams: PromptDeleteParams) = + apply { + promptId = promptDeleteParams.promptId + additionalHeaders = promptDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = promptDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = promptDeleteParams.additionalBodyProperties.toMutableMap() + } /** Prompt id */ - fun promptId(promptId: String) = apply { this.promptId = promptId } + fun promptId(promptId: String) = + apply { + this.promptId = promptId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): PromptDeleteParams = PromptDeleteParams( - checkRequired("promptId", promptId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "promptId", promptId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index a54dbe4f..1054845e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.PromptService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ -class PromptListPage -private constructor( +class PromptListPage private constructor( private val promptsService: PromptService, private val params: PromptListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListPage && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is PromptListPage && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ - override fun toString() = - "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" + override fun toString() = "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(PromptListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(PromptListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { promptsService.list(it) } + return getNextPageParams().map { promptsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(promptsService: PromptService, params: PromptListParams, response: Response) = - PromptListPage(promptsService, params, response) + PromptListPage( + promptsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [PromptListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: PromptListPage) : Iterable { + class AutoPager( + private val firstPage: PromptListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index 940430e6..06a4044a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.PromptServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ -class PromptListPageAsync -private constructor( +class PromptListPageAsync private constructor( private val promptsService: PromptServiceAsync, private val params: PromptListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListPageAsync && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is PromptListPageAsync && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ - override fun toString() = - "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" + override fun toString() = "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(PromptListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(PromptListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { promptsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + promptsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(promptsService: PromptServiceAsync, params: PromptListParams, response: Response) = - PromptListPageAsync(promptsService, params, response) + PromptListPageAsync( + promptsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [PromptListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: PromptListPageAsync) { + class AutoPager( + private val firstPage: PromptListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Prompt) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Prompt) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index ab888cab..725c3bce 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ -class PromptListParams -private constructor( +class PromptListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -40,20 +39,21 @@ private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -78,17 +78,17 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ fun version(): Optional = Optional.ofNullable(version) @@ -99,29 +99,71 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.promptName?.let { queryParams.put("prompt_name", listOf(it.toString())) } - this.slug?.let { queryParams.put("slug", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.projectId?.let { + queryParams.put( + "project_id", listOf(it.toString()) + ) + } + this.projectName?.let { + queryParams.put( + "project_name", listOf(it.toString()) + ) + } + this.promptName?.let { + queryParams.put( + "prompt_name", listOf(it.toString()) + ) + } + this.slug?.let { + queryParams.put( + "slug", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + this.version?.let { + queryParams.put( + "version", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): PromptListParams = builder().build() + @JvmStatic + fun none(): PromptListParams = builder().build() /** Returns a mutable builder for constructing an instance of [PromptListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptListParams]. */ @@ -142,65 +184,75 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptListParams: PromptListParams) = apply { - endingBefore = promptListParams.endingBefore - ids = promptListParams.ids - limit = promptListParams.limit - orgName = promptListParams.orgName - projectId = promptListParams.projectId - projectName = promptListParams.projectName - promptName = promptListParams.promptName - slug = promptListParams.slug - startingAfter = promptListParams.startingAfter - version = promptListParams.version - additionalHeaders = promptListParams.additionalHeaders.toBuilder() - additionalQueryParams = promptListParams.additionalQueryParams.toBuilder() - } + internal fun from(promptListParams: PromptListParams) = + apply { + endingBefore = promptListParams.endingBefore + ids = promptListParams.ids + limit = promptListParams.limit + orgName = promptListParams.orgName + projectId = promptListParams.projectId + projectName = promptListParams.projectName + promptName = promptListParams.promptName + slug = promptListParams.slug + startingAfter = promptListParams.startingAfter + version = promptListParams.version + additionalHeaders = promptListParams.additionalHeaders.toBuilder() + additionalQueryParams = promptListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -209,31 +261,46 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = apply { this.projectId = projectId } + fun projectId(projectId: String?) = + apply { + this.projectId = projectId + } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = apply { this.projectName = projectName } + fun projectName(projectName: String?) = + apply { + this.projectName = projectName + } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the prompt to search for */ - fun promptName(promptName: String?) = apply { this.promptName = promptName } + fun promptName(promptName: String?) = + apply { + this.promptName = promptName + } /** Name of the prompt to search for */ fun promptName(promptName: Optional) = promptName(promptName.getOrNull()) /** Retrieve prompt with a specific slug */ - fun slug(slug: String?) = apply { this.slug = slug } + fun slug(slug: String?) = + apply { + this.slug = slug + } /** Retrieve prompt with a specific slug */ fun slug(slug: Optional) = slug(slug.getOrNull()) @@ -241,164 +308,195 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String?) = apply { this.version = version } + fun version(version: String?) = + apply { + this.version = version + } /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a + * version identifier (e.g. '81cd05ee665fdfb3'). */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptListParams = PromptListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - promptName, - slug, - startingAfter, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + promptName, + slug, + startingAfter, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -416,19 +514,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -443,12 +541,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -458,60 +561,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 5ac95496..0c5160f5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -32,17 +32,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class PromptOptions -@JsonCreator -private constructor( +class PromptOptions @JsonCreator private constructor( @JsonProperty("model") @ExcludeMissing private val model: JsonField = JsonMissing.of(), - @JsonProperty("params") - @ExcludeMissing - private val params: JsonField = JsonMissing.of(), - @JsonProperty("position") - @ExcludeMissing - private val position: JsonField = JsonMissing.of(), + @JsonProperty("params") @ExcludeMissing private val params: JsonField = JsonMissing.of(), + @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun model(): Optional = Optional.ofNullable(model.getNullable("model")) @@ -51,11 +46,17 @@ private constructor( fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonProperty("model") + @ExcludeMissing + fun _model(): JsonField = model - @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params + @JsonProperty("params") + @ExcludeMissing + fun _params(): JsonField = params - @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + @JsonProperty("position") + @ExcludeMissing + fun _position(): JsonField = position @JsonAnyGetter @ExcludeMissing @@ -63,23 +64,25 @@ private constructor( private var validated: Boolean = false - fun validate(): PromptOptions = apply { - if (validated) { - return@apply - } + fun validate(): PromptOptions = + apply { + if (validated) { + return@apply + } - model() - params().ifPresent { it.validate() } - position() - validated = true - } + model() + params().ifPresent { it.validate() } + position() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [PromptOptions]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptOptions]. */ @@ -91,73 +94,90 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptOptions: PromptOptions) = apply { - model = promptOptions.model - params = promptOptions.params - position = promptOptions.position - additionalProperties = promptOptions.additionalProperties.toMutableMap() - } + internal fun from(promptOptions: PromptOptions) = + apply { + model = promptOptions.model + params = promptOptions.params + position = promptOptions.position + additionalProperties = promptOptions.additionalProperties.toMutableMap() + } fun model(model: String) = model(JsonField.of(model)) - fun model(model: JsonField) = apply { this.model = model } + fun model(model: JsonField) = + apply { + this.model = model + } fun params(params: Params) = params(JsonField.of(params)) - fun params(params: JsonField) = apply { this.params = params } + fun params(params: JsonField) = + apply { + this.params = params + } - fun params(openaiModel: Params.OpenAIModelParams) = - params(Params.ofOpenAIModel(openaiModel)) + fun params(openaiModel: Params.OpenAIModelParams) = params(Params.ofOpenAIModel(openaiModel)) - fun params(anthropicModel: Params.AnthropicModelParams) = - params(Params.ofAnthropicModel(anthropicModel)) + fun params(anthropicModel: Params.AnthropicModelParams) = params(Params.ofAnthropicModel(anthropicModel)) - fun params(googleModel: Params.GoogleModelParams) = - params(Params.ofGoogleModel(googleModel)) + fun params(googleModel: Params.GoogleModelParams) = params(Params.ofGoogleModel(googleModel)) - fun params(windowAiModel: Params.WindowAiModelParams) = - params(Params.ofWindowAiModel(windowAiModel)) + fun params(windowAiModel: Params.WindowAiModelParams) = params(Params.ofWindowAiModel(windowAiModel)) - fun params(jsCompletion: Params.JsCompletionParams) = - params(Params.ofJsCompletion(jsCompletion)) + fun params(jsCompletion: Params.JsCompletionParams) = params(Params.ofJsCompletion(jsCompletion)) fun position(position: String) = position(JsonField.of(position)) - fun position(position: JsonField) = apply { this.position = position } + fun position(position: JsonField) = + apply { + this.position = position + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptOptions = - PromptOptions(model, params, position, additionalProperties.toImmutable()) + PromptOptions( + model, + params, + position, + additionalProperties.toImmutable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( + class Params private constructor( private val openaiModel: OpenAIModelParams? = null, private val anthropicModel: AnthropicModelParams? = null, private val googleModel: GoogleModelParams? = null, private val windowAiModel: WindowAiModelParams? = null, private val jsCompletion: JsCompletionParams? = null, private val _json: JsonValue? = null, + ) { fun openaiModel(): Optional = Optional.ofNullable(openaiModel) @@ -193,55 +213,54 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - openaiModel != null -> visitor.visitOpenAIModel(openaiModel) - anthropicModel != null -> visitor.visitAnthropicModel(anthropicModel) - googleModel != null -> visitor.visitGoogleModel(googleModel) - windowAiModel != null -> visitor.visitWindowAiModel(windowAiModel) - jsCompletion != null -> visitor.visitJsCompletion(jsCompletion) - else -> visitor.unknown(_json) - } + return when { + openaiModel != null -> visitor.visitOpenAIModel(openaiModel) + anthropicModel != null -> visitor.visitAnthropicModel(anthropicModel) + googleModel != null -> visitor.visitGoogleModel(googleModel) + windowAiModel != null -> visitor.visitWindowAiModel(windowAiModel) + jsCompletion != null -> visitor.visitJsCompletion(jsCompletion) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Params = apply { - if (validated) { - return@apply - } + fun validate(): Params = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitOpenAIModel(openaiModel: OpenAIModelParams) { - openaiModel.validate() + openaiModel.validate() } override fun visitAnthropicModel(anthropicModel: AnthropicModelParams) { - anthropicModel.validate() + anthropicModel.validate() } override fun visitGoogleModel(googleModel: GoogleModelParams) { - googleModel.validate() + googleModel.validate() } override fun visitWindowAiModel(windowAiModel: WindowAiModelParams) { - windowAiModel.validate() + windowAiModel.validate() } override fun visitJsCompletion(jsCompletion: JsCompletionParams) { - jsCompletion.validate() + jsCompletion.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Params && openaiModel == other.openaiModel && anthropicModel == other.anthropicModel && googleModel == other.googleModel && windowAiModel == other.windowAiModel && jsCompletion == other.jsCompletion /* spotless:on */ + return /* spotless:off */ other is Params && openaiModel == other.openaiModel && anthropicModel == other.anthropicModel && googleModel == other.googleModel && windowAiModel == other.windowAiModel && jsCompletion == other.jsCompletion /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(openaiModel, anthropicModel, googleModel, windowAiModel, jsCompletion) /* spotless:on */ @@ -263,22 +282,22 @@ private constructor( fun ofOpenAIModel(openaiModel: OpenAIModelParams) = Params(openaiModel = openaiModel) @JvmStatic - fun ofAnthropicModel(anthropicModel: AnthropicModelParams) = - Params(anthropicModel = anthropicModel) + fun ofAnthropicModel(anthropicModel: AnthropicModelParams) = Params(anthropicModel = anthropicModel) @JvmStatic fun ofGoogleModel(googleModel: GoogleModelParams) = Params(googleModel = googleModel) @JvmStatic - fun ofWindowAiModel(windowAiModel: WindowAiModelParams) = - Params(windowAiModel = windowAiModel) + fun ofWindowAiModel(windowAiModel: WindowAiModelParams) = Params(windowAiModel = windowAiModel) @JvmStatic - fun ofJsCompletion(jsCompletion: JsCompletionParams) = - Params(jsCompletion = jsCompletion) + fun ofJsCompletion(jsCompletion: JsCompletionParams) = Params(jsCompletion = jsCompletion) } - /** An interface that defines how to map each variant of [Params] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Params] to a value of type + * [T]. + */ interface Visitor { fun visitOpenAIModel(openaiModel: OpenAIModelParams): T @@ -294,135 +313,96 @@ private constructor( /** * Maps an unknown variant of [Params] to a value of type [T]. * - * An instance of [Params] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Params] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } internal class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(openaiModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(anthropicModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(googleModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(windowAiModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(jsCompletion = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(openaiModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(anthropicModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(googleModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(windowAiModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(jsCompletion = it, _json = json) + } + + return Params(_json = json) } } internal class Serializer : BaseSerializer(Params::class) { - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.openaiModel != null -> generator.writeObject(value.openaiModel) - value.anthropicModel != null -> generator.writeObject(value.anthropicModel) - value.googleModel != null -> generator.writeObject(value.googleModel) - value.windowAiModel != null -> generator.writeObject(value.windowAiModel) - value.jsCompletion != null -> generator.writeObject(value.jsCompletion) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.openaiModel != null -> generator.writeObject(value.openaiModel) + value.anthropicModel != null -> generator.writeObject(value.anthropicModel) + value.googleModel != null -> generator.writeObject(value.googleModel) + value.windowAiModel != null -> generator.writeObject(value.windowAiModel) + value.jsCompletion != null -> generator.writeObject(value.jsCompletion) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } @NoAutoDetect - class OpenAIModelParams - @JsonCreator - private constructor( - @JsonProperty("frequency_penalty") - @ExcludeMissing - private val frequencyPenalty: JsonField = JsonMissing.of(), - @JsonProperty("function_call") - @ExcludeMissing - private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("max_tokens") - @ExcludeMissing - private val maxTokens: JsonField = JsonMissing.of(), + class OpenAIModelParams @JsonCreator private constructor( + @JsonProperty("frequency_penalty") @ExcludeMissing private val frequencyPenalty: JsonField = JsonMissing.of(), + @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens") @ExcludeMissing private val maxTokens: JsonField = JsonMissing.of(), @JsonProperty("n") @ExcludeMissing private val n: JsonField = JsonMissing.of(), - @JsonProperty("presence_penalty") - @ExcludeMissing - private val presencePenalty: JsonField = JsonMissing.of(), - @JsonProperty("response_format") - @ExcludeMissing - private val responseFormat: JsonField = JsonMissing.of(), - @JsonProperty("stop") - @ExcludeMissing - private val stop: JsonField> = JsonMissing.of(), - @JsonProperty("temperature") - @ExcludeMissing - private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("tool_choice") - @ExcludeMissing - private val toolChoice: JsonField = JsonMissing.of(), - @JsonProperty("top_p") - @ExcludeMissing - private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("presence_penalty") @ExcludeMissing private val presencePenalty: JsonField = JsonMissing.of(), + @JsonProperty("response_format") @ExcludeMissing private val responseFormat: JsonField = JsonMissing.of(), + @JsonProperty("stop") @ExcludeMissing private val stop: JsonField> = JsonMissing.of(), + @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("tool_choice") @ExcludeMissing private val toolChoice: JsonField = JsonMissing.of(), + @JsonProperty("top_p") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun frequencyPenalty(): Optional = - Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun functionCall(): Optional = - Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) - fun maxTokens(): Optional = - Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun presencePenalty(): Optional = - Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = - Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) - fun toolChoice(): Optional = - Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -436,7 +416,9 @@ private constructor( @ExcludeMissing fun _maxTokens(): JsonField = maxTokens - @JsonProperty("n") @ExcludeMissing fun _n(): JsonField = n + @JsonProperty("n") + @ExcludeMissing + fun _n(): JsonField = n @JsonProperty("presence_penalty") @ExcludeMissing @@ -446,7 +428,9 @@ private constructor( @ExcludeMissing fun _responseFormat(): JsonField = responseFormat - @JsonProperty("stop") @ExcludeMissing fun _stop(): JsonField> = stop + @JsonProperty("stop") + @ExcludeMissing + fun _stop(): JsonField> = stop @JsonProperty("temperature") @ExcludeMissing @@ -456,7 +440,9 @@ private constructor( @ExcludeMissing fun _toolChoice(): JsonField = toolChoice - @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + @JsonProperty("top_p") + @ExcludeMissing + fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -468,33 +454,33 @@ private constructor( private var validated: Boolean = false - fun validate(): OpenAIModelParams = apply { - if (validated) { - return@apply + fun validate(): OpenAIModelParams = + apply { + if (validated) { + return@apply + } + + frequencyPenalty() + functionCall().ifPresent { it.validate() } + maxTokens() + n() + presencePenalty() + responseFormat().ifPresent { it.validate() } + stop() + temperature() + toolChoice().ifPresent { it.validate() } + topP() + useCache() + validated = true } - frequencyPenalty() - functionCall().ifPresent { it.validate() } - maxTokens() - n() - presencePenalty() - responseFormat().ifPresent { it.validate() } - stop() - temperature() - toolChoice().ifPresent { it.validate() } - topP() - useCache() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [OpenAIModelParams]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [OpenAIModelParams]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [OpenAIModelParams]. */ @@ -514,160 +500,172 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(openaiModelParams: OpenAIModelParams) = apply { - frequencyPenalty = openaiModelParams.frequencyPenalty - functionCall = openaiModelParams.functionCall - maxTokens = openaiModelParams.maxTokens - n = openaiModelParams.n - presencePenalty = openaiModelParams.presencePenalty - responseFormat = openaiModelParams.responseFormat - stop = openaiModelParams.stop.map { it.toMutableList() } - temperature = openaiModelParams.temperature - toolChoice = openaiModelParams.toolChoice - topP = openaiModelParams.topP - useCache = openaiModelParams.useCache - additionalProperties = openaiModelParams.additionalProperties.toMutableMap() - } - - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) - - fun frequencyPenalty(frequencyPenalty: JsonField) = apply { - this.frequencyPenalty = frequencyPenalty - } + internal fun from(openaiModelParams: OpenAIModelParams) = + apply { + frequencyPenalty = openaiModelParams.frequencyPenalty + functionCall = openaiModelParams.functionCall + maxTokens = openaiModelParams.maxTokens + n = openaiModelParams.n + presencePenalty = openaiModelParams.presencePenalty + responseFormat = openaiModelParams.responseFormat + stop = openaiModelParams.stop.map { it.toMutableList() } + temperature = openaiModelParams.temperature + toolChoice = openaiModelParams.toolChoice + topP = openaiModelParams.topP + useCache = openaiModelParams.useCache + additionalProperties = openaiModelParams.additionalProperties.toMutableMap() + } + + fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + + fun frequencyPenalty(frequencyPenalty: JsonField) = + apply { + this.frequencyPenalty = frequencyPenalty + } - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) - fun functionCall(functionCall: JsonField) = apply { - this.functionCall = functionCall - } + fun functionCall(functionCall: JsonField) = + apply { + this.functionCall = functionCall + } - fun functionCall(unionMember0: FunctionCall.UnionMember0) = - functionCall(FunctionCall.ofUnionMember0(unionMember0)) + fun functionCall(unionMember0: FunctionCall.UnionMember0) = functionCall(FunctionCall.ofUnionMember0(unionMember0)) - fun functionCall(function: FunctionCall.Function) = - functionCall(FunctionCall.ofFunction(function)) + fun functionCall(function: FunctionCall.Function) = functionCall(FunctionCall.ofFunction(function)) fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + fun maxTokens(maxTokens: JsonField) = + apply { + this.maxTokens = maxTokens + } fun n(n: Double) = n(JsonField.of(n)) - fun n(n: JsonField) = apply { this.n = n } + fun n(n: JsonField) = + apply { + this.n = n + } - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) - fun presencePenalty(presencePenalty: JsonField) = apply { - this.presencePenalty = presencePenalty - } + fun presencePenalty(presencePenalty: JsonField) = + apply { + this.presencePenalty = presencePenalty + } - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) - fun responseFormat(responseFormat: JsonField) = apply { - this.responseFormat = responseFormat - } + fun responseFormat(responseFormat: JsonField) = + apply { + this.responseFormat = responseFormat + } - fun responseFormat(jsonObject: ResponseFormat.JsonObject) = - responseFormat(ResponseFormat.ofJsonObject(jsonObject)) + fun responseFormat(jsonObject: ResponseFormat.JsonObject) = responseFormat(ResponseFormat.ofJsonObject(jsonObject)) - fun responseFormat(jsonSchema: ResponseFormat.JsonSchema) = - responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) + fun responseFormat(jsonSchema: ResponseFormat.JsonSchema) = responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) - fun responseFormat(text: ResponseFormat.Text) = - responseFormat(ResponseFormat.ofText(text)) + fun responseFormat(text: ResponseFormat.Text) = responseFormat(ResponseFormat.ofText(text)) - fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = - responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) + fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) fun stop(stop: List) = stop(JsonField.of(stop)) - fun stop(stop: JsonField>) = apply { - this.stop = stop.map { it.toMutableList() } - } + fun stop(stop: JsonField>) = + apply { + this.stop = stop.map { it.toMutableList() } + } - fun addStop(stop: String) = apply { - this.stop = - (this.stop ?: JsonField.of(mutableListOf())).also { + fun addStop(stop: String) = + apply { + this.stop = (this.stop ?: JsonField.of(mutableListOf())).also { checkKnown("stop", it).add(stop) } - } + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = + apply { + this.temperature = temperature + } fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) - fun toolChoice(toolChoice: JsonField) = apply { - this.toolChoice = toolChoice - } + fun toolChoice(toolChoice: JsonField) = + apply { + this.toolChoice = toolChoice + } - fun toolChoice(unionMember0: ToolChoice.UnionMember0) = - toolChoice(ToolChoice.ofUnionMember0(unionMember0)) + fun toolChoice(unionMember0: ToolChoice.UnionMember0) = toolChoice(ToolChoice.ofUnionMember0(unionMember0)) - fun toolChoice(function: ToolChoice.Function) = - toolChoice(ToolChoice.ofFunction(function)) + fun toolChoice(function: ToolChoice.Function) = toolChoice(ToolChoice.ofFunction(function)) fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = + apply { + this.topP = topP + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): OpenAIModelParams = OpenAIModelParams( - frequencyPenalty, - functionCall, - maxTokens, - n, - presencePenalty, - responseFormat, - (stop ?: JsonMissing.of()).map { it.toImmutable() }, - temperature, - toolChoice, - topP, - useCache, - additionalProperties.toImmutable(), + frequencyPenalty, + functionCall, + maxTokens, + n, + presencePenalty, + responseFormat, + (stop ?: JsonMissing.of()).map { it.toImmutable() }, + temperature, + toolChoice, + topP, + useCache, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( + class FunctionCall private constructor( private val unionMember0: UnionMember0? = null, private val function: Function? = null, private val _json: JsonValue? = null, + ) { fun unionMember0(): Optional = Optional.ofNullable(unionMember0) @@ -685,38 +683,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionCall = apply { - if (validated) { - return@apply - } + fun validate(): FunctionCall = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) {} + accept(object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + + } override fun visitFunction(function: Function) { - function.validate() + function.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ + return /* spotless:off */ other is FunctionCall && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, function) /* spotless:on */ @@ -732,16 +731,15 @@ private constructor( companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - FunctionCall(unionMember0 = unionMember0) + fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) @JvmStatic fun ofFunction(function: Function) = FunctionCall(function = function) } /** - * An interface that defines how to map each variant of [FunctionCall] to a value of - * type [T]. + * An interface that defines how to map each variant of [FunctionCall] to a value + * of type [T]. */ interface Visitor { @@ -753,61 +751,57 @@ private constructor( * Maps an unknown variant of [FunctionCall] to a value of type [T]. * * An instance of [FunctionCall] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } internal class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } internal class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class UnionMember0 @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. + * 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 @@ -831,19 +825,20 @@ private constructor( * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [UnionMember0] can contain an unknown value in a couple of - * cases: + * An instance of [UnionMember0] 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 { AUTO, NONE, /** - * An enum member indicating that [UnionMember0] was instantiated with an - * unknown value. + * An enum member indicating that [UnionMember0] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -852,8 +847,8 @@ private constructor( * 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. + * 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) { @@ -865,18 +860,17 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { AUTO -> Known.AUTO NONE -> Known.NONE - else -> - throw BraintrustInvalidDataException("Unknown UnionMember0: $value") + else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } /** @@ -885,20 +879,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -907,19 +898,17 @@ private constructor( } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -927,14 +916,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - name() - validated = true - } + name() + validated = true + } fun toBuilder() = Builder().from(this) @@ -944,29 +934,34 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ class Builder internal constructor() { private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - name = function.name - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + name = function.name + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -974,35 +969,40 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1011,20 +1011,19 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" } } @JsonDeserialize(using = ResponseFormat.Deserializer::class) @JsonSerialize(using = ResponseFormat.Serializer::class) - class ResponseFormat - private constructor( + class ResponseFormat private constructor( private val jsonObject: JsonObject? = null, private val jsonSchema: JsonSchema? = null, private val text: Text? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, + ) { fun jsonObject(): Optional = Optional.ofNullable(jsonObject) @@ -1033,8 +1032,7 @@ private constructor( fun text(): Optional = Optional.ofNullable(text) - fun nullableVariant(): Optional = - Optional.ofNullable(nullableVariant) + fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) fun isJsonObject(): Boolean = jsonObject != null @@ -1050,56 +1048,54 @@ private constructor( fun asText(): Text = text.getOrThrow("text") - fun asNullableVariant(): NullableVariant = - nullableVariant.getOrThrow("nullableVariant") + fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - jsonObject != null -> visitor.visitJsonObject(jsonObject) - jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) - text != null -> visitor.visitText(text) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + jsonObject != null -> visitor.visitJsonObject(jsonObject) + jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) + text != null -> visitor.visitText(text) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ResponseFormat = apply { - if (validated) { - return@apply - } + fun validate(): ResponseFormat = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { + accept(object : Visitor { override fun visitJsonObject(jsonObject: JsonObject) { - jsonObject.validate() + jsonObject.validate() } override fun visitJsonSchema(jsonSchema: JsonSchema) { - jsonSchema.validate() + jsonSchema.validate() } override fun visitText(text: Text) { - text.validate() + text.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ @@ -1109,8 +1105,7 @@ private constructor( jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" text != null -> "ResponseFormat{text=$text}" - nullableVariant != null -> - "ResponseFormat{nullableVariant=$nullableVariant}" + nullableVariant != null -> "ResponseFormat{nullableVariant=$nullableVariant}" _json != null -> "ResponseFormat{_unknown=$_json}" else -> throw IllegalStateException("Invalid ResponseFormat") } @@ -1118,18 +1113,16 @@ private constructor( companion object { @JvmStatic - fun ofJsonObject(jsonObject: JsonObject) = - ResponseFormat(jsonObject = jsonObject) + fun ofJsonObject(jsonObject: JsonObject) = ResponseFormat(jsonObject = jsonObject) @JvmStatic - fun ofJsonSchema(jsonSchema: JsonSchema) = - ResponseFormat(jsonSchema = jsonSchema) + fun ofJsonSchema(jsonSchema: JsonSchema) = ResponseFormat(jsonSchema = jsonSchema) - @JvmStatic fun ofText(text: Text) = ResponseFormat(text = text) + @JvmStatic + fun ofText(text: Text) = ResponseFormat(text = text) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - ResponseFormat(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = ResponseFormat(nullableVariant = nullableVariant) } /** @@ -1150,77 +1143,65 @@ private constructor( * Maps an unknown variant of [ResponseFormat] to a value of type [T]. * * An instance of [ResponseFormat] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") + throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") } } - internal class Deserializer : - BaseDeserializer(ResponseFormat::class) { + internal class Deserializer : BaseDeserializer(ResponseFormat::class) { override fun ObjectCodec.deserialize(node: JsonNode): ResponseFormat { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(jsonObject = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(jsonSchema = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(nullableVariant = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ResponseFormat(jsonObject = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ResponseFormat(jsonSchema = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ResponseFormat(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ResponseFormat(nullableVariant = it, _json = json) + } - return ResponseFormat(_json = json) + return ResponseFormat(_json = json) } } internal class Serializer : BaseSerializer(ResponseFormat::class) { - override fun serialize( - value: ResponseFormat, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.jsonObject != null -> generator.writeObject(value.jsonObject) - value.jsonSchema != null -> generator.writeObject(value.jsonSchema) - value.text != null -> generator.writeObject(value.text) - value.nullableVariant != null -> - generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ResponseFormat") - } + override fun serialize(value: ResponseFormat, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.jsonObject != null -> generator.writeObject(value.jsonObject) + value.jsonSchema != null -> generator.writeObject(value.jsonSchema) + value.text != null -> generator.writeObject(value.text) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ResponseFormat") + } } } @NoAutoDetect - class JsonObject - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class JsonObject @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1228,14 +1209,15 @@ private constructor( private var validated: Boolean = false - fun validate(): JsonObject = apply { - if (validated) { - return@apply - } + fun validate(): JsonObject = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1245,29 +1227,34 @@ private constructor( * Returns a mutable builder for constructing an instance of [JsonObject]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [JsonObject]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jsonObject: JsonObject) = apply { - type = jsonObject.type - additionalProperties = jsonObject.additionalProperties.toMutableMap() - } + internal fun from(jsonObject: JsonObject) = + apply { + type = jsonObject.type + additionalProperties = jsonObject.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1275,40 +1262,46 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsonObject = JsonObject( - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "type", type + ), additionalProperties.toImmutable() ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -1322,25 +1315,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - JSON_OBJECT + JSON_OBJECT, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { JSON_OBJECT, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1348,8 +1339,8 @@ private constructor( * 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. + * 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) { @@ -1360,11 +1351,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1375,23 +1366,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1400,11 +1388,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsonObject && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonObject && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1413,22 +1401,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "JsonObject{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "JsonObject{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class JsonSchema - @JsonCreator - private constructor( - @JsonProperty("json_schema") - @ExcludeMissing - private val jsonSchema: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class JsonSchema @JsonCreator private constructor( + @JsonProperty("json_schema") @ExcludeMissing private val jsonSchema: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun jsonSchema(): InnerJsonSchema = jsonSchema.getRequired("json_schema") @@ -1439,7 +1420,9 @@ private constructor( @ExcludeMissing fun _jsonSchema(): JsonField = jsonSchema - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1447,15 +1430,16 @@ private constructor( private var validated: Boolean = false - fun validate(): JsonSchema = apply { - if (validated) { - return@apply - } + fun validate(): JsonSchema = + apply { + if (validated) { + return@apply + } - jsonSchema().validate() - type() - validated = true - } + jsonSchema().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1465,12 +1449,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [JsonSchema]. * * The following fields are required: + * * ```java * .jsonSchema() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [JsonSchema]. */ @@ -1478,26 +1464,29 @@ private constructor( private var jsonSchema: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jsonSchema: JsonSchema) = apply { - this.jsonSchema = jsonSchema.jsonSchema - type = jsonSchema.type - additionalProperties = jsonSchema.additionalProperties.toMutableMap() - } + internal fun from(jsonSchema: JsonSchema) = + apply { + this.jsonSchema = jsonSchema.jsonSchema + type = jsonSchema.type + additionalProperties = jsonSchema.additionalProperties.toMutableMap() + } - fun jsonSchema(jsonSchema: InnerJsonSchema) = - jsonSchema(JsonField.of(jsonSchema)) + fun jsonSchema(jsonSchema: InnerJsonSchema) = jsonSchema(JsonField.of(jsonSchema)) - fun jsonSchema(jsonSchema: JsonField) = apply { - this.jsonSchema = jsonSchema - } + fun jsonSchema(jsonSchema: JsonField) = + apply { + this.jsonSchema = jsonSchema + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1505,63 +1494,59 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsonSchema = JsonSchema( - checkRequired("jsonSchema", jsonSchema), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "jsonSchema", jsonSchema + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InnerJsonSchema - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("schema") - @ExcludeMissing - private val schema: JsonField = JsonMissing.of(), - @JsonProperty("strict") - @ExcludeMissing - private val strict: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class InnerJsonSchema @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("schema") @ExcludeMissing private val schema: JsonField = JsonMissing.of(), + @JsonProperty("strict") @ExcludeMissing private val strict: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun schema(): Optional = - Optional.ofNullable(schema.getNullable("schema")) + fun schema(): Optional = Optional.ofNullable(schema.getNullable("schema")) - fun strict(): Optional = - Optional.ofNullable(strict.getNullable("strict")) + fun strict(): Optional = Optional.ofNullable(strict.getNullable("strict")) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonProperty("description") @ExcludeMissing @@ -1581,32 +1566,34 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerJsonSchema = apply { - if (validated) { - return@apply - } + fun validate(): InnerJsonSchema = + apply { + if (validated) { + return@apply + } - name() - description() - schema().ifPresent { it.validate() } - strict() - validated = true - } + name() + description() + schema().ifPresent { it.validate() } + strict() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [InnerJsonSchema]. + * Returns a mutable builder for constructing an instance of [InnerJsonSchema]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InnerJsonSchema]. */ @@ -1616,33 +1603,38 @@ private constructor( private var description: JsonField = JsonMissing.of() private var schema: JsonField = JsonMissing.of() private var strict: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(innerJsonSchema: InnerJsonSchema) = apply { - name = innerJsonSchema.name - description = innerJsonSchema.description - schema = innerJsonSchema.schema - strict = innerJsonSchema.strict - additionalProperties = - innerJsonSchema.additionalProperties.toMutableMap() - } + internal fun from(innerJsonSchema: InnerJsonSchema) = + apply { + name = innerJsonSchema.name + description = innerJsonSchema.description + schema = innerJsonSchema.schema + strict = innerJsonSchema.strict + additionalProperties = innerJsonSchema.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } - fun description(description: String) = - description(JsonField.of(description)) + fun description(description: String) = description(JsonField.of(description)) - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } fun schema(schema: Schema) = schema(JsonField.of(schema)) - fun schema(schema: JsonField) = apply { this.schema = schema } + fun schema(schema: JsonField) = + apply { + this.schema = schema + } fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict)) @@ -1650,7 +1642,10 @@ private constructor( fun strict(strict: Optional) = strict(strict.getOrNull()) - fun strict(strict: JsonField) = apply { this.strict = strict } + fun strict(strict: JsonField) = + apply { + this.strict = strict + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1658,111 +1653,114 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InnerJsonSchema = InnerJsonSchema( - checkRequired("name", name), - description, - schema, - strict, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + schema, + strict, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Schema - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap() + class Schema @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): Schema = apply { - if (validated) { - return@apply - } + fun validate(): Schema = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of - * [Schema]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [Schema]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [Schema]. */ class Builder internal constructor() { - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(schema: Schema) = apply { - additionalProperties = - schema.additionalProperties.toMutableMap() - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(schema: Schema) = + apply { + additionalProperties = schema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Schema = Schema(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1771,16 +1769,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Schema{additionalProperties=$additionalProperties}" + override fun toString() = "Schema{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerJsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InnerJsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1789,21 +1786,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InnerJsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" + override fun toString() = "InnerJsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -1817,25 +1814,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - JSON_SCHEMA + JSON_SCHEMA, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { JSON_SCHEMA, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -1843,8 +1838,8 @@ private constructor( * 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. + * 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) { @@ -1855,11 +1850,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -1870,23 +1865,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1895,11 +1887,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsonSchema && jsonSchema == other.jsonSchema && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonSchema && jsonSchema == other.jsonSchema && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1908,24 +1900,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "JsonSchema{jsonSchema=$jsonSchema, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "JsonSchema{jsonSchema=$jsonSchema, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Text - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Text @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1933,14 +1922,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Text = apply { - if (validated) { - return@apply - } + fun validate(): Text = + apply { + if (validated) { + return@apply + } - type() - validated = true - } + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -1950,29 +1940,34 @@ private constructor( * Returns a mutable builder for constructing an instance of [Text]. * * The following fields are required: + * * ```java * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Text]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(text: Text) = apply { - type = text.type - additionalProperties = text.additionalProperties.toMutableMap() - } + internal fun from(text: Text) = + apply { + type = text.type + additionalProperties = text.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1980,37 +1975,46 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Text = - Text(checkRequired("type", type), additionalProperties.toImmutable()) + Text( + checkRequired( + "type", type + ), additionalProperties.toImmutable() + ) } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -2024,25 +2028,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - TEXT + TEXT, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { TEXT, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2050,8 +2052,8 @@ private constructor( * 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. + * 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) { @@ -2062,11 +2064,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2077,23 +2079,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2102,11 +2101,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2115,16 +2114,13 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Text{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Text{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class NullableVariant @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -2133,36 +2129,34 @@ private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } + fun validate(): NullableVariant = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of - * [NullableVariant]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [NullableVariant]. */ class Builder internal constructor() { - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = - nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = + apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2170,32 +2164,35 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toImmutable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2204,18 +2201,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "NullableVariant{additionalProperties=$additionalProperties}" + override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" } } @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( + class ToolChoice private constructor( private val unionMember0: UnionMember0? = null, private val function: Function? = null, private val _json: JsonValue? = null, + ) { fun unionMember0(): Optional = Optional.ofNullable(unionMember0) @@ -2233,38 +2229,39 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ToolChoice = apply { - if (validated) { - return@apply - } + fun validate(): ToolChoice = + apply { + if (validated) { + return@apply + } - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) {} + accept(object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + + } override fun visitFunction(function: Function) { - function.validate() + function.validate() } - } - ) - validated = true - } + }) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ToolChoice && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ + return /* spotless:off */ other is ToolChoice && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, function) /* spotless:on */ @@ -2280,10 +2277,10 @@ private constructor( companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - ToolChoice(unionMember0 = unionMember0) + fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) - @JvmStatic fun ofFunction(function: Function) = ToolChoice(function = function) + @JvmStatic + fun ofFunction(function: Function) = ToolChoice(function = function) } /** @@ -2300,61 +2297,57 @@ private constructor( * Maps an unknown variant of [ToolChoice] to a value of type [T]. * * An instance of [ToolChoice] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } internal class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolChoice(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } internal class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class UnionMember0 @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. + * 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 @@ -2381,11 +2374,12 @@ private constructor( * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [UnionMember0] can contain an unknown value in a couple of - * cases: + * An instance of [UnionMember0] 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 { @@ -2393,8 +2387,8 @@ private constructor( NONE, REQUIRED, /** - * An enum member indicating that [UnionMember0] was instantiated with an - * unknown value. + * An enum member indicating that [UnionMember0] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -2403,8 +2397,8 @@ private constructor( * 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. + * 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) { @@ -2417,19 +2411,18 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { AUTO -> Known.AUTO NONE -> Known.NONE REQUIRED -> Known.REQUIRED - else -> - throw BraintrustInvalidDataException("Unknown UnionMember0: $value") + else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } /** @@ -2438,20 +2431,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2460,17 +2450,11 @@ private constructor( } @NoAutoDetect - class Function - @JsonCreator - private constructor( - @JsonProperty("function") - @ExcludeMissing - private val function: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Function @JsonCreator private constructor( + @JsonProperty("function") @ExcludeMissing private val function: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun function(): InnerFunction = function.getRequired("function") @@ -2481,7 +2465,9 @@ private constructor( @ExcludeMissing fun _function(): JsonField = function - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2489,15 +2475,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Function = apply { - if (validated) { - return@apply - } + fun validate(): Function = + apply { + if (validated) { + return@apply + } - function().validate() - type() - validated = true - } + function().validate() + type() + validated = true + } fun toBuilder() = Builder().from(this) @@ -2507,12 +2494,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: + * * ```java * .function() * .type() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Function]. */ @@ -2520,25 +2509,29 @@ private constructor( private var function: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = apply { - this.function = function.function - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = + apply { + this.function = function.function + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun function(function: InnerFunction) = function(JsonField.of(function)) - fun function(function: JsonField) = apply { - this.function = function - } + fun function(function: JsonField) = + apply { + this.function = function + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = + apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2546,45 +2539,50 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired("function", function), - checkRequired("type", type), - additionalProperties.toImmutable(), + checkRequired( + "function", function + ), + checkRequired( + "type", type + ), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InnerFunction - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), + class InnerFunction @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun name(): String = name.getRequired("name") - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2592,48 +2590,52 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerFunction = apply { - if (validated) { - return@apply - } + fun validate(): InnerFunction = + apply { + if (validated) { + return@apply + } - name() - validated = true - } + name() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [InnerFunction]. + * Returns a mutable builder for constructing an instance of [InnerFunction]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [InnerFunction]. */ class Builder internal constructor() { private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(innerFunction: InnerFunction) = apply { - name = innerFunction.name - additionalProperties = - innerFunction.additionalProperties.toMutableMap() - } + internal fun from(innerFunction: InnerFunction) = + apply { + name = innerFunction.name + additionalProperties = innerFunction.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2641,35 +2643,40 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InnerFunction = InnerFunction( - checkRequired("name", name), - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), additionalProperties.toImmutable() ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerFunction && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InnerFunction && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2678,21 +2685,21 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "InnerFunction{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "InnerFunction{name=$name, additionalProperties=$additionalProperties}" } - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 @@ -2706,25 +2713,23 @@ private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION + FUNCTION, } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. + * 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. + * 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 { FUNCTION, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2732,8 +2737,8 @@ private constructor( * 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. + * 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) { @@ -2744,11 +2749,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -2759,23 +2764,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2784,11 +2786,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2797,17 +2799,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Function{function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Function{function=$function, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2816,37 +2817,20 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class AnthropicModelParams - @JsonCreator - private constructor( - @JsonProperty("max_tokens") - @ExcludeMissing - private val maxTokens: JsonField = JsonMissing.of(), - @JsonProperty("temperature") - @ExcludeMissing - private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("max_tokens_to_sample") - @ExcludeMissing - private val maxTokensToSample: JsonField = JsonMissing.of(), - @JsonProperty("stop_sequences") - @ExcludeMissing - private val stopSequences: JsonField> = JsonMissing.of(), - @JsonProperty("top_k") - @ExcludeMissing - private val topK: JsonField = JsonMissing.of(), - @JsonProperty("top_p") - @ExcludeMissing - private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class AnthropicModelParams @JsonCreator private constructor( + @JsonProperty("max_tokens") @ExcludeMissing private val maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens_to_sample") @ExcludeMissing private val maxTokensToSample: JsonField = JsonMissing.of(), + @JsonProperty("stop_sequences") @ExcludeMissing private val stopSequences: JsonField> = JsonMissing.of(), + @JsonProperty("top_k") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), + @JsonProperty("top_p") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -2854,18 +2838,15 @@ private constructor( fun temperature(): Double = temperature.getRequired("temperature") /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = - Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - fun stopSequences(): Optional> = - Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("max_tokens") @ExcludeMissing @@ -2884,9 +2865,13 @@ private constructor( @ExcludeMissing fun _stopSequences(): JsonField> = stopSequences - @JsonProperty("top_k") @ExcludeMissing fun _topK(): JsonField = topK + @JsonProperty("top_k") + @ExcludeMissing + fun _topK(): JsonField = topK - @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + @JsonProperty("top_p") + @ExcludeMissing + fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -2898,35 +2883,39 @@ private constructor( private var validated: Boolean = false - fun validate(): AnthropicModelParams = apply { - if (validated) { - return@apply - } + fun validate(): AnthropicModelParams = + apply { + if (validated) { + return@apply + } - maxTokens() - temperature() - maxTokensToSample() - stopSequences() - topK() - topP() - useCache() - validated = true - } + maxTokens() + temperature() + maxTokensToSample() + stopSequences() + topK() + topP() + useCache() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [AnthropicModelParams]. + * Returns a mutable builder for constructing an instance of + * [AnthropicModelParams]. * * The following fields are required: + * * ```java * .maxTokens() * .temperature() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AnthropicModelParams]. */ @@ -2942,103 +2931,125 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(anthropicModelParams: AnthropicModelParams) = apply { - maxTokens = anthropicModelParams.maxTokens - temperature = anthropicModelParams.temperature - maxTokensToSample = anthropicModelParams.maxTokensToSample - stopSequences = anthropicModelParams.stopSequences.map { it.toMutableList() } - topK = anthropicModelParams.topK - topP = anthropicModelParams.topP - useCache = anthropicModelParams.useCache - additionalProperties = anthropicModelParams.additionalProperties.toMutableMap() - } + internal fun from(anthropicModelParams: AnthropicModelParams) = + apply { + maxTokens = anthropicModelParams.maxTokens + temperature = anthropicModelParams.temperature + maxTokensToSample = anthropicModelParams.maxTokensToSample + stopSequences = anthropicModelParams.stopSequences.map { it.toMutableList() } + topK = anthropicModelParams.topK + topP = anthropicModelParams.topP + useCache = anthropicModelParams.useCache + additionalProperties = anthropicModelParams.additionalProperties.toMutableMap() + } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + fun maxTokens(maxTokens: JsonField) = + apply { + this.maxTokens = maxTokens + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = + apply { + this.temperature = temperature + } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = - maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: JsonField) = apply { - this.maxTokensToSample = maxTokensToSample - } + fun maxTokensToSample(maxTokensToSample: JsonField) = + apply { + this.maxTokensToSample = maxTokensToSample + } - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) - fun stopSequences(stopSequences: JsonField>) = apply { - this.stopSequences = stopSequences.map { it.toMutableList() } - } + fun stopSequences(stopSequences: JsonField>) = + apply { + this.stopSequences = stopSequences.map { it.toMutableList() } + } - fun addStopSequence(stopSequence: String) = apply { - stopSequences = - (stopSequences ?: JsonField.of(mutableListOf())).also { + fun addStopSequence(stopSequence: String) = + apply { + stopSequences = (stopSequences ?: JsonField.of(mutableListOf())).also { checkKnown("stopSequences", it).add(stopSequence) } - } + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = + apply { + this.topK = topK + } fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = + apply { + this.topP = topP + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AnthropicModelParams = AnthropicModelParams( - checkRequired("maxTokens", maxTokens), - checkRequired("temperature", temperature), - maxTokensToSample, - (stopSequences ?: JsonMissing.of()).map { it.toImmutable() }, - topK, - topP, - useCache, - additionalProperties.toImmutable(), + checkRequired( + "maxTokens", maxTokens + ), + checkRequired( + "temperature", temperature + ), + maxTokensToSample, + (stopSequences ?: JsonMissing.of()).map { it.toImmutable() }, + topK, + topP, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AnthropicModelParams && maxTokens == other.maxTokens && temperature == other.temperature && maxTokensToSample == other.maxTokensToSample && stopSequences == other.stopSequences && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AnthropicModelParams && maxTokens == other.maxTokens && temperature == other.temperature && maxTokensToSample == other.maxTokensToSample && stopSequences == other.stopSequences && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3047,45 +3058,29 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AnthropicModelParams{maxTokens=$maxTokens, temperature=$temperature, maxTokensToSample=$maxTokensToSample, stopSequences=$stopSequences, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "AnthropicModelParams{maxTokens=$maxTokens, temperature=$temperature, maxTokensToSample=$maxTokensToSample, stopSequences=$stopSequences, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class GoogleModelParams - @JsonCreator - private constructor( - @JsonProperty("maxOutputTokens") - @ExcludeMissing - private val maxOutputTokens: JsonField = JsonMissing.of(), - @JsonProperty("temperature") - @ExcludeMissing - private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("topK") - @ExcludeMissing - private val topK: JsonField = JsonMissing.of(), - @JsonProperty("topP") - @ExcludeMissing - private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class GoogleModelParams @JsonCreator private constructor( + @JsonProperty("maxOutputTokens") @ExcludeMissing private val maxOutputTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("topK") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), + @JsonProperty("topP") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun maxOutputTokens(): Optional = - Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -3095,9 +3090,13 @@ private constructor( @ExcludeMissing fun _temperature(): JsonField = temperature - @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK + @JsonProperty("topK") + @ExcludeMissing + fun _topK(): JsonField = topK - @JsonProperty("topP") @ExcludeMissing fun _topP(): JsonField = topP + @JsonProperty("topP") + @ExcludeMissing + fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -3109,27 +3108,27 @@ private constructor( private var validated: Boolean = false - fun validate(): GoogleModelParams = apply { - if (validated) { - return@apply - } + fun validate(): GoogleModelParams = + apply { + if (validated) { + return@apply + } - maxOutputTokens() - temperature() - topK() - topP() - useCache() - validated = true - } + maxOutputTokens() + temperature() + topK() + topP() + useCache() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [GoogleModelParams]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [GoogleModelParams]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [GoogleModelParams]. */ @@ -3143,79 +3142,94 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleModelParams: GoogleModelParams) = apply { - maxOutputTokens = googleModelParams.maxOutputTokens - temperature = googleModelParams.temperature - topK = googleModelParams.topK - topP = googleModelParams.topP - useCache = googleModelParams.useCache - additionalProperties = googleModelParams.additionalProperties.toMutableMap() - } + internal fun from(googleModelParams: GoogleModelParams) = + apply { + maxOutputTokens = googleModelParams.maxOutputTokens + temperature = googleModelParams.temperature + topK = googleModelParams.topK + topP = googleModelParams.topP + useCache = googleModelParams.useCache + additionalProperties = googleModelParams.additionalProperties.toMutableMap() + } - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) - fun maxOutputTokens(maxOutputTokens: JsonField) = apply { - this.maxOutputTokens = maxOutputTokens - } + fun maxOutputTokens(maxOutputTokens: JsonField) = + apply { + this.maxOutputTokens = maxOutputTokens + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = + apply { + this.temperature = temperature + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = + apply { + this.topK = topK + } fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = + apply { + this.topP = topP + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GoogleModelParams = GoogleModelParams( - maxOutputTokens, - temperature, - topK, - topP, - useCache, - additionalProperties.toImmutable(), + maxOutputTokens, + temperature, + topK, + topP, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GoogleModelParams && maxOutputTokens == other.maxOutputTokens && temperature == other.temperature && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GoogleModelParams && maxOutputTokens == other.maxOutputTokens && temperature == other.temperature && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3224,40 +3238,31 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "GoogleModelParams{maxOutputTokens=$maxOutputTokens, temperature=$temperature, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "GoogleModelParams{maxOutputTokens=$maxOutputTokens, temperature=$temperature, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class WindowAiModelParams - @JsonCreator - private constructor( - @JsonProperty("temperature") - @ExcludeMissing - private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("topK") - @ExcludeMissing - private val topK: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class WindowAiModelParams @JsonCreator private constructor( + @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("topK") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun temperature(): Optional = - Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("temperature") @ExcludeMissing fun _temperature(): JsonField = temperature - @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK + @JsonProperty("topK") + @ExcludeMissing + fun _topK(): JsonField = topK @JsonProperty("use_cache") @ExcludeMissing @@ -3269,25 +3274,25 @@ private constructor( private var validated: Boolean = false - fun validate(): WindowAiModelParams = apply { - if (validated) { - return@apply - } + fun validate(): WindowAiModelParams = + apply { + if (validated) { + return@apply + } - temperature() - topK() - useCache() - validated = true - } + temperature() + topK() + useCache() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [WindowAiModelParams]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [WindowAiModelParams]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [WindowAiModelParams]. */ @@ -3299,64 +3304,76 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(windowAiModelParams: WindowAiModelParams) = apply { - temperature = windowAiModelParams.temperature - topK = windowAiModelParams.topK - useCache = windowAiModelParams.useCache - additionalProperties = windowAiModelParams.additionalProperties.toMutableMap() - } + internal fun from(windowAiModelParams: WindowAiModelParams) = + apply { + temperature = windowAiModelParams.temperature + topK = windowAiModelParams.topK + useCache = windowAiModelParams.useCache + additionalProperties = windowAiModelParams.additionalProperties.toMutableMap() + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = + apply { + this.temperature = temperature + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = + apply { + this.topK = topK + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): WindowAiModelParams = WindowAiModelParams( - temperature, - topK, - useCache, - additionalProperties.toImmutable(), + temperature, + topK, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is WindowAiModelParams && temperature == other.temperature && topK == other.topK && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is WindowAiModelParams && temperature == other.temperature && topK == other.topK && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3365,23 +3382,17 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "WindowAiModelParams{temperature=$temperature, topK=$topK, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "WindowAiModelParams{temperature=$temperature, topK=$topK, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class JsCompletionParams - @JsonCreator - private constructor( - @JsonProperty("use_cache") - @ExcludeMissing - private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class JsCompletionParams @JsonCreator private constructor( + @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun useCache(): Optional = - Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("use_cache") @ExcludeMissing @@ -3393,23 +3404,23 @@ private constructor( private var validated: Boolean = false - fun validate(): JsCompletionParams = apply { - if (validated) { - return@apply - } + fun validate(): JsCompletionParams = + apply { + if (validated) { + return@apply + } - useCache() - validated = true - } + useCache() + validated = true + } fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [JsCompletionParams]. - */ - @JvmStatic fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [JsCompletionParams]. */ + @JvmStatic + fun builder() = Builder() } /** A builder for [JsCompletionParams]. */ @@ -3419,47 +3430,57 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jsCompletionParams: JsCompletionParams) = apply { - useCache = jsCompletionParams.useCache - additionalProperties = jsCompletionParams.additionalProperties.toMutableMap() - } + internal fun from(jsCompletionParams: JsCompletionParams) = + apply { + useCache = jsCompletionParams.useCache + additionalProperties = jsCompletionParams.additionalProperties.toMutableMap() + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = + apply { + this.useCache = useCache + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsCompletionParams = - JsCompletionParams(useCache, additionalProperties.toImmutable()) + JsCompletionParams( + useCache, additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsCompletionParams && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsCompletionParams && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3468,17 +3489,16 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptOptions && model == other.model && params == other.params && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptOptions && model == other.model && params == other.params && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3487,6 +3507,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "PromptOptions{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "PromptOptions{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index cf0797b3..fed28c24 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -25,14 +25,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will replace the existing prompt with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the + * same slug as the one specified in the request, will replace the existing prompt + * with the provided fields */ -class PromptReplaceParams -private constructor( +class PromptReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the prompt */ @@ -81,39 +82,24 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") - @ExcludeMissing - private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the prompt */ @@ -126,27 +112,30 @@ private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = - Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -163,7 +152,9 @@ private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -171,21 +162,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + slug() + description() + functionType() + promptData().ifPresent { it.validate() } + tags() + validated = true } - name() - projectId() - slug() - description() - functionType() - promptData().ifPresent { it.validate() } - tags() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -194,13 +186,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -216,34 +210,44 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionType = body.functionType - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionType = body.functionType + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -252,19 +256,19 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } - fun functionType(functionType: FunctionType?) = - functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = + apply { + this.functionType = functionType + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -273,9 +277,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -284,54 +289,70 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("slug", slug), - description, - functionType, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "slug", slug + ), + description, + functionType, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -340,8 +361,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -352,13 +372,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptReplaceParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptReplaceParams]. */ @@ -370,206 +392,286 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptReplaceParams: PromptReplaceParams) = apply { - body = promptReplaceParams.body.toBuilder() - additionalHeaders = promptReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = promptReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(promptReplaceParams: PromptReplaceParams) = + apply { + body = promptReplaceParams.body.toBuilder() + additionalHeaders = promptReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = promptReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the prompt */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { body.slug(slug) } + fun slug(slug: String) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } - fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + fun functionType(functionType: FunctionType?) = + apply { + body.functionType(functionType) + } - fun functionType(functionType: Optional) = - functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = + apply { + body.functionType(functionType) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptReplaceParams = PromptReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } - class FunctionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -593,12 +695,15 @@ private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [FunctionType] 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 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 { @@ -607,17 +712,18 @@ private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -631,11 +737,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -649,23 +755,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -674,15 +777,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 039b2d8a..0889cb45 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a prompt object by its id */ -class PromptRetrieveParams -private constructor( +class PromptRetrieveParams private constructor( private val promptId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Prompt id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [PromptRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [PromptRetrieveParams]. * * The following fields are required: + * * ```java * .promptId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptRetrieveParams: PromptRetrieveParams) = apply { - promptId = promptRetrieveParams.promptId - additionalHeaders = promptRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = promptRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(promptRetrieveParams: PromptRetrieveParams) = + apply { + promptId = promptRetrieveParams.promptId + additionalHeaders = promptRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = promptRetrieveParams.additionalQueryParams.toBuilder() + } /** Prompt id */ - fun promptId(promptId: String) = apply { this.promptId = promptId } + fun promptId(promptId: String) = + apply { + this.promptId = promptId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptRetrieveParams = PromptRetrieveParams( - checkRequired("promptId", promptId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "promptId", promptId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index d8447483..abef1b23 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -23,16 +23,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a prompt object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ -class PromptUpdateParams -private constructor( +class PromptUpdateParams private constructor( private val promptId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Prompt id */ @@ -74,52 +74,39 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") - @ExcludeMissing - private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("slug") - @ExcludeMissing - private val slug: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Textual description of the prompt */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = - Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) /** Unique identifier for the prompt */ fun slug(): Optional = Optional.ofNullable(slug.getNullable("slug")) @@ -133,7 +120,9 @@ private constructor( fun _description(): JsonField = description /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -141,10 +130,14 @@ private constructor( fun _promptData(): JsonField = promptData /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug(): JsonField = slug /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -152,25 +145,27 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + description() + name() + promptData().ifPresent { it.validate() } + slug() + tags() + validated = true } - description() - name() - promptData().ifPresent { it.validate() } - slug() - tags() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -184,14 +179,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - description = body.description - name = body.name - promptData = body.promptData - slug = body.slug - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + description = body.description + name = body.name + promptData = body.promptData + slug = body.slug + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -200,9 +196,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -211,7 +208,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -220,9 +220,10 @@ private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = + apply { + this.promptData = promptData + } /** Unique identifier for the prompt */ fun slug(slug: String?) = slug(JsonField.ofNullable(slug)) @@ -231,7 +232,10 @@ private constructor( fun slug(slug: Optional) = slug(slug.getOrNull()) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { this.slug = slug } + fun slug(slug: JsonField) = + apply { + this.slug = slug + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -240,52 +244,62 @@ private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = + apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = + apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - description, - name, - promptData, - slug, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + description, + name, + promptData, + slug, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -294,8 +308,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "Body{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -306,11 +319,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [PromptUpdateParams]. * * The following fields are required: + * * ```java * .promptId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [PromptUpdateParams]. */ @@ -323,200 +338,272 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptUpdateParams: PromptUpdateParams) = apply { - promptId = promptUpdateParams.promptId - body = promptUpdateParams.body.toBuilder() - additionalHeaders = promptUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = promptUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(promptUpdateParams: PromptUpdateParams) = + apply { + promptId = promptUpdateParams.promptId + body = promptUpdateParams.body.toBuilder() + additionalHeaders = promptUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptUpdateParams.additionalQueryParams.toBuilder() + } /** Prompt id */ - fun promptId(promptId: String) = apply { this.promptId = promptId } + fun promptId(promptId: String) = + apply { + this.promptId = promptId + } /** Textual description of the prompt */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the prompt */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the prompt */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } + fun promptData(promptData: PromptData?) = + apply { + body.promptData(promptData) + } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } + fun promptData(promptData: JsonField) = + apply { + body.promptData(promptData) + } /** Unique identifier for the prompt */ - fun slug(slug: String?) = apply { body.slug(slug) } + fun slug(slug: String?) = + apply { + body.slug(slug) + } /** Unique identifier for the prompt */ fun slug(slug: Optional) = slug(slug.getOrNull()) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = apply { body.slug(slug) } + fun slug(slug: JsonField) = + apply { + body.slug(slug) + } /** A list of tags for the prompt */ - fun tags(tags: List?) = apply { body.tags(tags) } + fun tags(tags: List?) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = apply { body.tags(tags) } + fun tags(tags: JsonField>) = + apply { + body.tags(tags) + } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { body.addTag(tag) } + fun addTag(tag: String) = + apply { + body.addTag(tag) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptUpdateParams = PromptUpdateParams( - checkRequired("promptId", promptId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "promptId", promptId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "PromptUpdateParams{promptId=$promptId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "PromptUpdateParams{promptId=$promptId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index a938b801..fda9c97a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -19,38 +19,22 @@ import kotlin.jvm.optionals.getOrNull /** Metadata about the state of the repo when the experiment was created */ @NoAutoDetect -class RepoInfo -@JsonCreator -private constructor( - @JsonProperty("author_email") - @ExcludeMissing - private val authorEmail: JsonField = JsonMissing.of(), - @JsonProperty("author_name") - @ExcludeMissing - private val authorName: JsonField = JsonMissing.of(), - @JsonProperty("branch") - @ExcludeMissing - private val branch: JsonField = JsonMissing.of(), - @JsonProperty("commit") - @ExcludeMissing - private val commit: JsonField = JsonMissing.of(), - @JsonProperty("commit_message") - @ExcludeMissing - private val commitMessage: JsonField = JsonMissing.of(), - @JsonProperty("commit_time") - @ExcludeMissing - private val commitTime: JsonField = JsonMissing.of(), +class RepoInfo @JsonCreator private constructor( + @JsonProperty("author_email") @ExcludeMissing private val authorEmail: JsonField = JsonMissing.of(), + @JsonProperty("author_name") @ExcludeMissing private val authorName: JsonField = JsonMissing.of(), + @JsonProperty("branch") @ExcludeMissing private val branch: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing private val commit: JsonField = JsonMissing.of(), + @JsonProperty("commit_message") @ExcludeMissing private val commitMessage: JsonField = JsonMissing.of(), + @JsonProperty("commit_time") @ExcludeMissing private val commitTime: JsonField = JsonMissing.of(), @JsonProperty("dirty") @ExcludeMissing private val dirty: JsonField = JsonMissing.of(), - @JsonProperty("git_diff") - @ExcludeMissing - private val gitDiff: JsonField = JsonMissing.of(), + @JsonProperty("git_diff") @ExcludeMissing private val gitDiff: JsonField = JsonMissing.of(), @JsonProperty("tag") @ExcludeMissing private val tag: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Email of the author of the most recent commit */ - fun authorEmail(): Optional = - Optional.ofNullable(authorEmail.getNullable("author_email")) + fun authorEmail(): Optional = Optional.ofNullable(authorEmail.getNullable("author_email")) /** Name of the author of the most recent commit */ fun authorName(): Optional = Optional.ofNullable(authorName.getNullable("author_name")) @@ -62,8 +46,7 @@ private constructor( fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) /** Most recent commit message */ - fun commitMessage(): Optional = - Optional.ofNullable(commitMessage.getNullable("commit_message")) + fun commitMessage(): Optional = Optional.ofNullable(commitMessage.getNullable("commit_message")) /** Time of the most recent commit */ fun commitTime(): Optional = Optional.ofNullable(commitTime.getNullable("commit_time")) @@ -72,8 +55,8 @@ private constructor( fun dirty(): Optional = Optional.ofNullable(dirty.getNullable("dirty")) /** - * If the repo was dirty when run, this includes the diff between the current state of the repo - * and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ fun gitDiff(): Optional = Optional.ofNullable(gitDiff.getNullable("git_diff")) @@ -86,13 +69,19 @@ private constructor( fun _authorEmail(): JsonField = authorEmail /** Name of the author of the most recent commit */ - @JsonProperty("author_name") @ExcludeMissing fun _authorName(): JsonField = authorName + @JsonProperty("author_name") + @ExcludeMissing + fun _authorName(): JsonField = authorName /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + @JsonProperty("branch") + @ExcludeMissing + fun _branch(): JsonField = branch /** SHA of most recent commit */ - @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + @JsonProperty("commit") + @ExcludeMissing + fun _commit(): JsonField = commit /** Most recent commit message */ @JsonProperty("commit_message") @@ -100,19 +89,27 @@ private constructor( fun _commitMessage(): JsonField = commitMessage /** Time of the most recent commit */ - @JsonProperty("commit_time") @ExcludeMissing fun _commitTime(): JsonField = commitTime + @JsonProperty("commit_time") + @ExcludeMissing + fun _commitTime(): JsonField = commitTime /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") @ExcludeMissing fun _dirty(): JsonField = dirty + @JsonProperty("dirty") + @ExcludeMissing + fun _dirty(): JsonField = dirty /** - * If the repo was dirty when run, this includes the diff between the current state of the repo - * and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ - @JsonProperty("git_diff") @ExcludeMissing fun _gitDiff(): JsonField = gitDiff + @JsonProperty("git_diff") + @ExcludeMissing + fun _gitDiff(): JsonField = gitDiff /** Name of the tag on the most recent commit */ - @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField = tag + @JsonProperty("tag") + @ExcludeMissing + fun _tag(): JsonField = tag @JsonAnyGetter @ExcludeMissing @@ -120,29 +117,31 @@ private constructor( private var validated: Boolean = false - fun validate(): RepoInfo = apply { - if (validated) { - return@apply + fun validate(): RepoInfo = + apply { + if (validated) { + return@apply + } + + authorEmail() + authorName() + branch() + commit() + commitMessage() + commitTime() + dirty() + gitDiff() + tag() + validated = true } - authorEmail() - authorName() - branch() - commit() - commitMessage() - commitTime() - dirty() - gitDiff() - tag() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [RepoInfo]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RepoInfo]. */ @@ -160,18 +159,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(repoInfo: RepoInfo) = apply { - authorEmail = repoInfo.authorEmail - authorName = repoInfo.authorName - branch = repoInfo.branch - commit = repoInfo.commit - commitMessage = repoInfo.commitMessage - commitTime = repoInfo.commitTime - dirty = repoInfo.dirty - gitDiff = repoInfo.gitDiff - tag = repoInfo.tag - additionalProperties = repoInfo.additionalProperties.toMutableMap() - } + internal fun from(repoInfo: RepoInfo) = + apply { + authorEmail = repoInfo.authorEmail + authorName = repoInfo.authorName + branch = repoInfo.branch + commit = repoInfo.commit + commitMessage = repoInfo.commitMessage + commitTime = repoInfo.commitTime + dirty = repoInfo.dirty + gitDiff = repoInfo.gitDiff + tag = repoInfo.tag + additionalProperties = repoInfo.additionalProperties.toMutableMap() + } /** Email of the author of the most recent commit */ fun authorEmail(authorEmail: String?) = authorEmail(JsonField.ofNullable(authorEmail)) @@ -180,7 +180,10 @@ private constructor( fun authorEmail(authorEmail: Optional) = authorEmail(authorEmail.getOrNull()) /** Email of the author of the most recent commit */ - fun authorEmail(authorEmail: JsonField) = apply { this.authorEmail = authorEmail } + fun authorEmail(authorEmail: JsonField) = + apply { + this.authorEmail = authorEmail + } /** Name of the author of the most recent commit */ fun authorName(authorName: String?) = authorName(JsonField.ofNullable(authorName)) @@ -189,7 +192,10 @@ private constructor( fun authorName(authorName: Optional) = authorName(authorName.getOrNull()) /** Name of the author of the most recent commit */ - fun authorName(authorName: JsonField) = apply { this.authorName = authorName } + fun authorName(authorName: JsonField) = + apply { + this.authorName = authorName + } /** Name of the branch the most recent commit belongs to */ fun branch(branch: String?) = branch(JsonField.ofNullable(branch)) @@ -198,7 +204,10 @@ private constructor( fun branch(branch: Optional) = branch(branch.getOrNull()) /** Name of the branch the most recent commit belongs to */ - fun branch(branch: JsonField) = apply { this.branch = branch } + fun branch(branch: JsonField) = + apply { + this.branch = branch + } /** SHA of most recent commit */ fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) @@ -207,20 +216,22 @@ private constructor( fun commit(commit: Optional) = commit(commit.getOrNull()) /** SHA of most recent commit */ - fun commit(commit: JsonField) = apply { this.commit = commit } + fun commit(commit: JsonField) = + apply { + this.commit = commit + } /** Most recent commit message */ - fun commitMessage(commitMessage: String?) = - commitMessage(JsonField.ofNullable(commitMessage)) + fun commitMessage(commitMessage: String?) = commitMessage(JsonField.ofNullable(commitMessage)) /** Most recent commit message */ - fun commitMessage(commitMessage: Optional) = - commitMessage(commitMessage.getOrNull()) + fun commitMessage(commitMessage: Optional) = commitMessage(commitMessage.getOrNull()) /** Most recent commit message */ - fun commitMessage(commitMessage: JsonField) = apply { - this.commitMessage = commitMessage - } + fun commitMessage(commitMessage: JsonField) = + apply { + this.commitMessage = commitMessage + } /** Time of the most recent commit */ fun commitTime(commitTime: String?) = commitTime(JsonField.ofNullable(commitTime)) @@ -229,7 +240,10 @@ private constructor( fun commitTime(commitTime: Optional) = commitTime(commitTime.getOrNull()) /** Time of the most recent commit */ - fun commitTime(commitTime: JsonField) = apply { this.commitTime = commitTime } + fun commitTime(commitTime: JsonField) = + apply { + this.commitTime = commitTime + } /** Whether or not the repo had uncommitted changes when snapshotted */ fun dirty(dirty: Boolean?) = dirty(JsonField.ofNullable(dirty)) @@ -241,25 +255,31 @@ private constructor( fun dirty(dirty: Optional) = dirty(dirty.getOrNull()) /** Whether or not the repo had uncommitted changes when snapshotted */ - fun dirty(dirty: JsonField) = apply { this.dirty = dirty } + fun dirty(dirty: JsonField) = + apply { + this.dirty = dirty + } /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ fun gitDiff(gitDiff: String?) = gitDiff(JsonField.ofNullable(gitDiff)) /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ fun gitDiff(gitDiff: Optional) = gitDiff(gitDiff.getOrNull()) /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state + * of the repo and the most recent commit. */ - fun gitDiff(gitDiff: JsonField) = apply { this.gitDiff = gitDiff } + fun gitDiff(gitDiff: JsonField) = + apply { + this.gitDiff = gitDiff + } /** Name of the tag on the most recent commit */ fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) @@ -268,48 +288,58 @@ private constructor( fun tag(tag: Optional) = tag(tag.getOrNull()) /** Name of the tag on the most recent commit */ - fun tag(tag: JsonField) = apply { this.tag = tag } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun tag(tag: JsonField) = + apply { + this.tag = tag + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RepoInfo = RepoInfo( - authorEmail, - authorName, - branch, - commit, - commitMessage, - commitTime, - dirty, - gitDiff, - tag, - additionalProperties.toImmutable(), + authorEmail, + authorName, + branch, + commit, + commitMessage, + commitTime, + dirty, + gitDiff, + tag, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RepoInfo && authorEmail == other.authorEmail && authorName == other.authorName && branch == other.branch && commit == other.commit && commitMessage == other.commitMessage && commitTime == other.commitTime && dirty == other.dirty && gitDiff == other.gitDiff && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RepoInfo && authorEmail == other.authorEmail && authorName == other.authorName && branch == other.branch && commit == other.commit && commitMessage == other.commitMessage && commitTime == other.commitTime && dirty == other.dirty && gitDiff == other.gitDiff && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -318,6 +348,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RepoInfo{authorEmail=$authorEmail, authorName=$authorName, branch=$branch, commit=$commit, commitMessage=$commitMessage, commitTime=$commitTime, dirty=$dirty, gitDiff=$gitDiff, tag=$tag, additionalProperties=$additionalProperties}" + override fun toString() = "RepoInfo{authorEmail=$authorEmail, authorName=$authorName, branch=$branch, commit=$commit, commitMessage=$commitMessage, commitTime=$commitTime, dirty=$dirty, gitDiff=$gitDiff, tag=$tag, additionalProperties=$additionalProperties}" } 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..af3cc656 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 @@ -25,34 +25,22 @@ import kotlin.jvm.optionals.getOrNull /** * A role is a collection of permissions which can be granted as part of an ACL * - * Roles can consist of individual permissions, as well as a set of roles they inherit from + * Roles can consist of individual permissions, as well as a set of roles they + * inherit from */ @NoAutoDetect -class Role -@JsonCreator -private constructor( +class Role @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") - @ExcludeMissing - private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") - @ExcludeMissing - private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the role */ @@ -65,31 +53,27 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the role */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = - Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(): Optional> = - Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by any - * other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -99,13 +83,19 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the role */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Date of role creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -113,7 +103,9 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the role */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -123,8 +115,8 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing @@ -133,15 +125,19 @@ private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by any - * other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId(): JsonField = orgId /** Identifies the user who created the role */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -149,22 +145,23 @@ private constructor( private var validated: Boolean = false - fun validate(): Role = apply { - if (validated) { - return@apply - } + fun validate(): Role = + apply { + if (validated) { + return@apply + } - id() - name() - created() - deletedAt() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgId() - userId() - validated = true - } + id() + name() + created() + deletedAt() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgId() + userId() + validated = true + } fun toBuilder() = Builder().from(this) @@ -174,12 +171,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Role]. * * The following fields are required: + * * ```java * .id() * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Role]. */ @@ -197,30 +196,37 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(role: Role) = apply { - id = role.id - name = role.name - created = role.created - deletedAt = role.deletedAt - description = role.description - memberPermissions = role.memberPermissions.map { it.toMutableList() } - memberRoles = role.memberRoles.map { it.toMutableList() } - orgId = role.orgId - userId = role.userId - additionalProperties = role.additionalProperties.toMutableMap() - } + internal fun from(role: Role) = + apply { + id = role.id + name = role.name + created = role.created + deletedAt = role.deletedAt + description = role.description + memberPermissions = role.memberPermissions.map { it.toMutableList() } + memberRoles = role.memberRoles.map { it.toMutableList() } + orgId = role.orgId + userId = role.userId + additionalProperties = role.additionalProperties.toMutableMap() + } /** Unique identifier for the role */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the role */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Date of role creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -229,7 +235,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of role creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -238,7 +247,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -247,73 +259,76 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = - memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = + apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { - memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = + apply { + memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -322,8 +337,8 @@ private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -332,12 +347,15 @@ private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = + apply { + this.orgId = orgId + } /** Identifies the user who created the role */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -346,71 +364,80 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the role */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Role = Role( - checkRequired("id", id), - checkRequired("name", name), - created, - deletedAt, - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + created, + deletedAt, + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgId, + userId, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class MemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class MemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -427,15 +454,16 @@ private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): MemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -445,11 +473,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -460,87 +490,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = + apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -579,9 +623,11 @@ private constructor( * 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 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 { @@ -604,8 +650,8 @@ private constructor( * 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. + * 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) { @@ -627,7 +673,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -648,20 +694,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -670,19 +713,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -732,9 +777,11 @@ private constructor( * * 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 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 { @@ -760,8 +807,8 @@ private constructor( * 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. + * 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) { @@ -786,7 +833,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -801,8 +848,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -811,20 +857,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -833,11 +876,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -846,16 +889,15 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && id == other.id && name == other.name && created == other.created && deletedAt == other.deletedAt && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Role && id == other.id && name == other.name && created == other.created && deletedAt == other.deletedAt && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -864,6 +906,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Role{id=$id, name=$name, created=$created, deletedAt=$deletedAt, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "Role{id=$id, name=$name, created=$created, deletedAt=$deletedAt, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } 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..8125aad3 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 @@ -25,14 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new role. If there is an existing role with the same name as the one specified in the - * request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one + * specified in the request, will return the existing role unmodified */ -class RoleCreateParams -private constructor( +class RoleCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the role */ @@ -47,15 +47,15 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(): Optional> = body.memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(): Optional = body.orgName() @@ -71,15 +71,15 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun _memberRoles(): JsonField> = body._memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -89,64 +89,52 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") - @ExcludeMissing - private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") - @ExcludeMissing - private val memberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the role */ fun name(): String = name.getRequired("name") /** Textual description of the role */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = - Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(): Optional> = - Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Textual description of the role */ @JsonProperty("description") @@ -161,19 +149,21 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -181,18 +171,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgName() - validated = true - } + name() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -202,11 +193,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -220,20 +213,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - description = body.description - memberPermissions = body.memberPermissions.map { it.toMutableList() } - memberRoles = body.memberRoles.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + description = body.description + memberPermissions = body.memberPermissions.map { it.toMutableList() } + memberRoles = body.memberRoles.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -242,129 +239,140 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = - memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = - memberRoles(JsonField.ofNullable(memberRoles)) + fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = - memberRoles(memberRoles.getOrNull()) + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = + apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { - memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = + apply { + memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -373,8 +381,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -385,11 +392,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleCreateParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleCreateParams]. */ @@ -401,251 +410,312 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleCreateParams: RoleCreateParams) = apply { - body = roleCreateParams.body.toBuilder() - additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(roleCreateParams: RoleCreateParams) = + apply { + body = roleCreateParams.body.toBuilder() + additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() + } /** Name of the role */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the role */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Textual description of the role */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: List?) = + apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - body.addMemberPermission(memberPermission) - } + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + body.addMemberPermission(memberPermission) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } + fun memberRoles(memberRoles: List?) = + apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - body.memberRoles(memberRoles) - } + fun memberRoles(memberRoles: JsonField>) = + apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } + fun addMemberRole(memberRole: String) = + apply { + body.addMemberRole(memberRole) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleCreateParams = - RoleCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + RoleCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) } @NoAutoDetect - class MemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class MemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -662,15 +732,16 @@ private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): MemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -680,11 +751,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -695,87 +768,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = + apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -814,9 +901,11 @@ private constructor( * 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 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 { @@ -839,8 +928,8 @@ private constructor( * 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. + * 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) { @@ -862,7 +951,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -883,20 +972,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -905,19 +991,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -967,9 +1055,11 @@ private constructor( * * 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 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 { @@ -995,8 +1085,8 @@ private constructor( * 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. + * 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) { @@ -1021,7 +1111,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1036,8 +1126,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1046,20 +1135,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1068,11 +1154,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1081,20 +1167,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 1eae7094..5e64142f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a role object by its id */ -class RoleDeleteParams -private constructor( +class RoleDeleteParams private constructor( private val roleId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** Role id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -53,11 +52,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleDeleteParams]. * * The following fields are required: + * * ```java * .roleId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleDeleteParams]. */ @@ -70,155 +71,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(roleDeleteParams: RoleDeleteParams) = apply { - roleId = roleDeleteParams.roleId - additionalHeaders = roleDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = roleDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = roleDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(roleDeleteParams: RoleDeleteParams) = + apply { + roleId = roleDeleteParams.roleId + additionalHeaders = roleDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = roleDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = roleDeleteParams.additionalBodyProperties.toMutableMap() + } /** Role id */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String) = + apply { + this.roleId = roleId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): RoleDeleteParams = RoleDeleteParams( - checkRequired("roleId", roleId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "roleId", roleId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index f0957758..12783198 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.RoleService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all roles. The roles are sorted by creation date, with the most recently-created roles - * coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ -class RoleListPage -private constructor( +class RoleListPage private constructor( private val rolesService: RoleService, private val params: RoleListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListPage && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is RoleListPage && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ - override fun toString() = - "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" + override fun toString() = "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(RoleListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(RoleListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { rolesService.list(it) } + return getNextPageParams().map { rolesService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(rolesService: RoleService, params: RoleListParams, response: Response) = - RoleListPage(rolesService, params, response) + RoleListPage( + rolesService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [RoleListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: RoleListPage) : Iterable { + class AutoPager( + private val firstPage: RoleListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index baef96f9..a227e991 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.RoleServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all roles. The roles are sorted by creation date, with the most recently-created roles - * coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ -class RoleListPageAsync -private constructor( +class RoleListPageAsync private constructor( private val rolesService: RoleServiceAsync, private val params: RoleListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListPageAsync && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is RoleListPageAsync && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ - override fun toString() = - "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" + override fun toString() = "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(RoleListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(RoleListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { rolesService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + rolesService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(rolesService: RoleServiceAsync, params: RoleListParams, response: Response) = - RoleListPageAsync(rolesService, params, response) + RoleListPageAsync( + rolesService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [RoleListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: RoleListPageAsync) { + class AutoPager( + private val firstPage: RoleListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Role) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (Role) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index df21940e..870fb484 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all roles. The roles are sorted by creation date, with the most recently-created roles - * coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ -class RoleListParams -private constructor( +class RoleListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -36,20 +35,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,51 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.roleName?.let { queryParams.put("role_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.roleName?.let { + queryParams.put( + "role_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): RoleListParams = builder().build() + @JvmStatic + fun none(): RoleListParams = builder().build() /** Returns a mutable builder for constructing an instance of [RoleListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleListParams]. */ @@ -113,61 +139,71 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleListParams: RoleListParams) = apply { - endingBefore = roleListParams.endingBefore - ids = roleListParams.ids - limit = roleListParams.limit - orgName = roleListParams.orgName - roleName = roleListParams.roleName - startingAfter = roleListParams.startingAfter - additionalHeaders = roleListParams.additionalHeaders.toBuilder() - additionalQueryParams = roleListParams.additionalQueryParams.toBuilder() - } + internal fun from(roleListParams: RoleListParams) = + apply { + endingBefore = roleListParams.endingBefore + ids = roleListParams.ids + limit = roleListParams.limit + orgName = roleListParams.orgName + roleName = roleListParams.roleName + startingAfter = roleListParams.startingAfter + additionalHeaders = roleListParams.additionalHeaders.toBuilder() + additionalQueryParams = roleListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -176,13 +212,19 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the role to search for */ - fun roleName(roleName: String?) = apply { this.roleName = roleName } + fun roleName(roleName: String?) = + apply { + this.roleName = roleName + } /** Name of the role to search for */ fun roleName(roleName: Optional) = roleName(roleName.getOrNull()) @@ -190,144 +232,172 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleListParams = RoleListParams( - endingBefore, - ids, - limit, - orgName, - roleName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + roleName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -345,19 +415,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -372,12 +442,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -387,60 +462,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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..004b08b7 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 @@ -25,14 +25,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace role. If there is an existing role with the same name as the one specified in - * the request, will replace the existing role with the provided fields + * Create or replace role. If there is an existing role with the same name as the + * one specified in the request, will replace the existing role with the provided + * fields */ -class RoleReplaceParams -private constructor( +class RoleReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the role */ @@ -47,15 +48,15 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(): Optional> = body.memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(): Optional = body.orgName() @@ -71,15 +72,15 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun _memberRoles(): JsonField> = body._memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -89,64 +90,52 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") - @ExcludeMissing - private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") - @ExcludeMissing - private val memberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") - @ExcludeMissing - private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the role */ fun name(): String = name.getRequired("name") /** Textual description of the role */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = - Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(): Optional> = - Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Textual description of the role */ @JsonProperty("description") @@ -161,19 +150,21 @@ private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName + @JsonProperty("org_name") + @ExcludeMissing + fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -181,18 +172,19 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - name() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgName() - validated = true - } + name() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } fun toBuilder() = Builder().from(this) @@ -202,11 +194,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -220,20 +214,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - description = body.description - memberPermissions = body.memberPermissions.map { it.toMutableList() } - memberRoles = body.memberRoles.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + description = body.description + memberPermissions = body.memberPermissions.map { it.toMutableList() } + memberRoles = body.memberRoles.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -242,129 +240,140 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = - memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - memberPermissions = - (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = - memberRoles(JsonField.ofNullable(memberRoles)) + fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = - memberRoles(memberRoles.getOrNull()) + fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = + apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { - memberRoles = - (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = + apply { + memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + fun orgName(orgName: JsonField) = + apply { + this.orgName = orgName + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -373,8 +382,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -385,11 +393,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleReplaceParams]. * * The following fields are required: + * * ```java * .name() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleReplaceParams]. */ @@ -401,255 +411,312 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleReplaceParams: RoleReplaceParams) = apply { - body = roleReplaceParams.body.toBuilder() - additionalHeaders = roleReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = roleReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(roleReplaceParams: RoleReplaceParams) = + apply { + body = roleReplaceParams.body.toBuilder() + additionalHeaders = roleReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = roleReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the role */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the role */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Textual description of the role */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: List?) = + apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = - memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: JsonField>) = + apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = apply { - body.addMemberPermission(memberPermission) - } + fun addMemberPermission(memberPermission: MemberPermission) = + apply { + body.addMemberPermission(memberPermission) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } + fun memberRoles(memberRoles: List?) = + apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = apply { - body.memberRoles(memberRoles) - } + fun memberRoles(memberRoles: JsonField>) = + apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } + fun addMemberRole(memberRole: String) = + apply { + body.addMemberRole(memberRole) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: String?) = apply { body.orgName(orgName) } + fun orgName(orgName: String?) = + apply { + body.orgName(orgName) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case + * that your API key belongs to multiple organizations, you may specify the name of + * the organization the role belongs in. */ - fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } + fun orgName(orgName: JsonField) = + apply { + body.orgName(orgName) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleReplaceParams = RoleReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class MemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class MemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -666,15 +733,16 @@ private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): MemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -684,11 +752,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -699,87 +769,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = + apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -818,9 +902,11 @@ private constructor( * 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 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 { @@ -843,8 +929,8 @@ private constructor( * 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. + * 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) { @@ -866,7 +952,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -887,20 +973,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -909,19 +992,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -971,9 +1056,11 @@ private constructor( * * 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 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 { @@ -999,8 +1086,8 @@ private constructor( * 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. + * 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) { @@ -1025,7 +1112,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1040,8 +1127,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1050,20 +1136,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1072,11 +1155,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1085,20 +1168,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 70a23fdd..1bb0b88f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a role object by its id */ -class RoleRetrieveParams -private constructor( +class RoleRetrieveParams private constructor( private val roleId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Role id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,11 +43,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleRetrieveParams]. * * The following fields are required: + * * ```java * .roleId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleRetrieveParams]. */ @@ -59,131 +61,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleRetrieveParams: RoleRetrieveParams) = apply { - roleId = roleRetrieveParams.roleId - additionalHeaders = roleRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = roleRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(roleRetrieveParams: RoleRetrieveParams) = + apply { + roleId = roleRetrieveParams.roleId + additionalHeaders = roleRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = roleRetrieveParams.additionalQueryParams.toBuilder() + } /** Role id */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String) = + apply { + this.roleId = roleId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleRetrieveParams = RoleRetrieveParams( - checkRequired("roleId", roleId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "roleId", roleId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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..b6b26ea8 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 @@ -25,16 +25,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ -class RoleUpdateParams -private constructor( +class RoleUpdateParams private constructor( private val roleId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Role id */ @@ -53,8 +53,7 @@ private constructor( fun name(): Optional = body.name() /** A list of permissions to remove from the role */ - fun removeMemberPermissions(): Optional> = - body.removeMemberPermissions() + fun removeMemberPermissions(): Optional> = body.removeMemberPermissions() /** A list of role IDs to remove from the role's inheriting-from set */ fun removeMemberRoles(): Optional> = body.removeMemberRoles() @@ -72,8 +71,7 @@ private constructor( fun _name(): JsonField = body._name() /** A list of permissions to remove from the role */ - fun _removeMemberPermissions(): JsonField> = - body._removeMemberPermissions() + fun _removeMemberPermissions(): JsonField> = body._removeMemberPermissions() /** A list of role IDs to remove from the role's inheriting-from set */ fun _removeMemberRoles(): JsonField> = body._removeMemberRoles() @@ -84,68 +82,49 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("add_member_permissions") - @ExcludeMissing - private val addMemberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("add_member_roles") - @ExcludeMissing - private val addMemberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("remove_member_permissions") - @ExcludeMissing - private val removeMemberPermissions: JsonField> = - JsonMissing.of(), - @JsonProperty("remove_member_roles") - @ExcludeMissing - private val removeMemberRoles: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("add_member_permissions") @ExcludeMissing private val addMemberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("add_member_roles") @ExcludeMissing private val addMemberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("remove_member_permissions") @ExcludeMissing private val removeMemberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("remove_member_roles") @ExcludeMissing private val removeMemberRoles: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** A list of permissions to add to the role */ - fun addMemberPermissions(): Optional> = - Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) + fun addMemberPermissions(): Optional> = Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(): Optional> = - Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) + fun addMemberRoles(): Optional> = Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) /** Textual description of the role */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** Name of the role */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** A list of permissions to remove from the role */ - fun removeMemberPermissions(): Optional> = - Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) + fun removeMemberPermissions(): Optional> = Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(): Optional> = - Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) + fun removeMemberRoles(): Optional> = Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) /** A list of permissions to add to the role */ @JsonProperty("add_member_permissions") @@ -163,13 +142,14 @@ private constructor( fun _description(): JsonField = description /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** A list of permissions to remove from the role */ @JsonProperty("remove_member_permissions") @ExcludeMissing - fun _removeMemberPermissions(): JsonField> = - removeMemberPermissions + fun _removeMemberPermissions(): JsonField> = removeMemberPermissions /** A list of role IDs to remove from the role's inheriting-from set */ @JsonProperty("remove_member_roles") @@ -182,26 +162,28 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - addMemberPermissions().ifPresent { it.forEach { it.validate() } } - addMemberRoles() - description() - name() - removeMemberPermissions().ifPresent { it.forEach { it.validate() } } - removeMemberRoles() - validated = true - } + addMemberPermissions().ifPresent { it.forEach { it.validate() } } + addMemberRoles() + description() + name() + removeMemberPermissions().ifPresent { it.forEach { it.validate() } } + removeMemberRoles() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -211,29 +193,27 @@ private constructor( private var addMemberRoles: JsonField>? = null private var description: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var removeMemberPermissions: JsonField>? = - null + private var removeMemberPermissions: JsonField>? = null private var removeMemberRoles: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - addMemberPermissions = body.addMemberPermissions.map { it.toMutableList() } - addMemberRoles = body.addMemberRoles.map { it.toMutableList() } - description = body.description - name = body.name - removeMemberPermissions = body.removeMemberPermissions.map { it.toMutableList() } - removeMemberRoles = body.removeMemberRoles.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + addMemberPermissions = body.addMemberPermissions.map { it.toMutableList() } + addMemberRoles = body.addMemberRoles.map { it.toMutableList() } + description = body.description + name = body.name + removeMemberPermissions = body.removeMemberPermissions.map { it.toMutableList() } + removeMemberRoles = body.removeMemberRoles.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: List?) = - addMemberPermissions(JsonField.ofNullable(addMemberPermissions)) + fun addMemberPermissions(addMemberPermissions: List?) = addMemberPermissions(JsonField.ofNullable(addMemberPermissions)) /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: Optional>) = - addMemberPermissions(addMemberPermissions.getOrNull()) + fun addMemberPermissions(addMemberPermissions: Optional>) = addMemberPermissions(addMemberPermissions.getOrNull()) /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: JsonField>) = @@ -242,33 +222,32 @@ private constructor( } /** A list of permissions to add to the role */ - fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { - addMemberPermissions = - (addMemberPermissions ?: JsonField.of(mutableListOf())).also { + fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = + apply { + addMemberPermissions = (addMemberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberPermissions", it).add(addMemberPermission) } - } + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: List?) = - addMemberRoles(JsonField.ofNullable(addMemberRoles)) + fun addMemberRoles(addMemberRoles: List?) = addMemberRoles(JsonField.ofNullable(addMemberRoles)) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: Optional>) = - addMemberRoles(addMemberRoles.getOrNull()) + fun addMemberRoles(addMemberRoles: Optional>) = addMemberRoles(addMemberRoles.getOrNull()) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: JsonField>) = apply { - this.addMemberRoles = addMemberRoles.map { it.toMutableList() } - } + fun addMemberRoles(addMemberRoles: JsonField>) = + apply { + this.addMemberRoles = addMemberRoles.map { it.toMutableList() } + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addAddMemberRole(addMemberRole: String) = apply { - addMemberRoles = - (addMemberRoles ?: JsonField.of(mutableListOf())).also { + fun addAddMemberRole(addMemberRole: String) = + apply { + addMemberRoles = (addMemberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberRoles", it).add(addMemberRole) } - } + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -277,9 +256,10 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** Name of the role */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -288,90 +268,95 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the role */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: List?) = - removeMemberPermissions(JsonField.ofNullable(removeMemberPermissions)) + fun removeMemberPermissions(removeMemberPermissions: List?) = removeMemberPermissions(JsonField.ofNullable(removeMemberPermissions)) /** A list of permissions to remove from the role */ - fun removeMemberPermissions( - removeMemberPermissions: Optional> - ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) + fun removeMemberPermissions(removeMemberPermissions: Optional>) = removeMemberPermissions(removeMemberPermissions.getOrNull()) /** A list of permissions to remove from the role */ - fun removeMemberPermissions( - removeMemberPermissions: JsonField> - ) = apply { - this.removeMemberPermissions = removeMemberPermissions.map { it.toMutableList() } - } + fun removeMemberPermissions(removeMemberPermissions: JsonField>) = + apply { + this.removeMemberPermissions = removeMemberPermissions.map { it.toMutableList() } + } /** A list of permissions to remove from the role */ - fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { - removeMemberPermissions = - (removeMemberPermissions ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = + apply { + removeMemberPermissions = (removeMemberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberPermissions", it).add(removeMemberPermission) } - } + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: List?) = - removeMemberRoles(JsonField.ofNullable(removeMemberRoles)) + fun removeMemberRoles(removeMemberRoles: List?) = removeMemberRoles(JsonField.ofNullable(removeMemberRoles)) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: Optional>) = - removeMemberRoles(removeMemberRoles.getOrNull()) + fun removeMemberRoles(removeMemberRoles: Optional>) = removeMemberRoles(removeMemberRoles.getOrNull()) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { - this.removeMemberRoles = removeMemberRoles.map { it.toMutableList() } - } + fun removeMemberRoles(removeMemberRoles: JsonField>) = + apply { + this.removeMemberRoles = removeMemberRoles.map { it.toMutableList() } + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun addRemoveMemberRole(removeMemberRole: String) = apply { - removeMemberRoles = - (removeMemberRoles ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberRole(removeMemberRole: String) = + apply { + removeMemberRoles = (removeMemberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberRoles", it).add(removeMemberRole) } - } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (addMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - description, - name, - (removeMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (removeMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (addMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + description, + name, + (removeMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (removeMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -380,8 +365,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" + override fun toString() = "Body{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -392,11 +376,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [RoleUpdateParams]. * * The following fields are required: + * * ```java * .roleId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RoleUpdateParams]. */ @@ -409,24 +395,28 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleUpdateParams: RoleUpdateParams) = apply { - roleId = roleUpdateParams.roleId - body = roleUpdateParams.body.toBuilder() - additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(roleUpdateParams: RoleUpdateParams) = + apply { + roleId = roleUpdateParams.roleId + body = roleUpdateParams.body.toBuilder() + additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() + } /** Role id */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String) = + apply { + this.roleId = roleId + } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: List?) = apply { - body.addMemberPermissions(addMemberPermissions) - } + fun addMemberPermissions(addMemberPermissions: List?) = + apply { + body.addMemberPermissions(addMemberPermissions) + } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: Optional>) = - addMemberPermissions(addMemberPermissions.getOrNull()) + fun addMemberPermissions(addMemberPermissions: Optional>) = addMemberPermissions(addMemberPermissions.getOrNull()) /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: JsonField>) = @@ -435,44 +425,61 @@ private constructor( } /** A list of permissions to add to the role */ - fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { - body.addAddMemberPermission(addMemberPermission) - } + fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = + apply { + body.addAddMemberPermission(addMemberPermission) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: List?) = apply { - body.addMemberRoles(addMemberRoles) - } + fun addMemberRoles(addMemberRoles: List?) = + apply { + body.addMemberRoles(addMemberRoles) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: Optional>) = - addMemberRoles(addMemberRoles.getOrNull()) + fun addMemberRoles(addMemberRoles: Optional>) = addMemberRoles(addMemberRoles.getOrNull()) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: JsonField>) = apply { - body.addMemberRoles(addMemberRoles) - } + fun addMemberRoles(addMemberRoles: JsonField>) = + apply { + body.addMemberRoles(addMemberRoles) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addAddMemberRole(addMemberRole: String) = apply { body.addAddMemberRole(addMemberRole) } + fun addAddMemberRole(addMemberRole: String) = + apply { + body.addAddMemberRole(addMemberRole) + } /** Textual description of the role */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** Name of the role */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the role */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the role */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** A list of permissions to remove from the role */ fun removeMemberPermissions(removeMemberPermissions: List?) = @@ -481,194 +488,227 @@ private constructor( } /** A list of permissions to remove from the role */ - fun removeMemberPermissions( - removeMemberPermissions: Optional> - ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) + fun removeMemberPermissions(removeMemberPermissions: Optional>) = removeMemberPermissions(removeMemberPermissions.getOrNull()) /** A list of permissions to remove from the role */ - fun removeMemberPermissions( - removeMemberPermissions: JsonField> - ) = apply { body.removeMemberPermissions(removeMemberPermissions) } + fun removeMemberPermissions(removeMemberPermissions: JsonField>) = + apply { + body.removeMemberPermissions(removeMemberPermissions) + } /** A list of permissions to remove from the role */ - fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { - body.addRemoveMemberPermission(removeMemberPermission) - } + fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = + apply { + body.addRemoveMemberPermission(removeMemberPermission) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: List?) = apply { - body.removeMemberRoles(removeMemberRoles) - } + fun removeMemberRoles(removeMemberRoles: List?) = + apply { + body.removeMemberRoles(removeMemberRoles) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: Optional>) = - removeMemberRoles(removeMemberRoles.getOrNull()) + fun removeMemberRoles(removeMemberRoles: Optional>) = removeMemberRoles(removeMemberRoles.getOrNull()) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { - body.removeMemberRoles(removeMemberRoles) - } + fun removeMemberRoles(removeMemberRoles: JsonField>) = + apply { + body.removeMemberRoles(removeMemberRoles) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun addRemoveMemberRole(removeMemberRole: String) = apply { - body.addRemoveMemberRole(removeMemberRole) - } + fun addRemoveMemberRole(removeMemberRole: String) = + apply { + body.addRemoveMemberRole(removeMemberRole) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleUpdateParams = RoleUpdateParams( - checkRequired("roleId", roleId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "roleId", roleId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class AddMemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class AddMemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -685,15 +725,16 @@ private constructor( private var validated: Boolean = false - fun validate(): AddMemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): AddMemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -703,11 +744,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [AddMemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [AddMemberPermission]. */ @@ -718,87 +761,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addMemberPermission: AddMemberPermission) = apply { - permission = addMemberPermission.permission - restrictObjectType = addMemberPermission.restrictObjectType - additionalProperties = addMemberPermission.additionalProperties.toMutableMap() - } + internal fun from(addMemberPermission: AddMemberPermission) = + apply { + permission = addMemberPermission.permission + restrictObjectType = addMemberPermission.restrictObjectType + additionalProperties = addMemberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AddMemberPermission = AddMemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -837,9 +894,11 @@ private constructor( * 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 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 { @@ -862,8 +921,8 @@ private constructor( * 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. + * 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) { @@ -885,7 +944,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -906,20 +965,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -928,19 +984,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -990,9 +1048,11 @@ private constructor( * * 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 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 { @@ -1018,8 +1078,8 @@ private constructor( * 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. + * 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) { @@ -1044,7 +1104,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1059,8 +1119,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1069,20 +1128,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1091,11 +1147,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AddMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1104,39 +1160,33 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } @NoAutoDetect - class RemoveMemberPermission - @JsonCreator - private constructor( - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class RemoveMemberPermission @JsonCreator private constructor( + @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") @ExcludeMissing @@ -1153,29 +1203,33 @@ private constructor( private var validated: Boolean = false - fun validate(): RemoveMemberPermission = apply { - if (validated) { - return@apply - } + fun validate(): RemoveMemberPermission = + apply { + if (validated) { + return@apply + } - permission() - restrictObjectType() - validated = true - } + permission() + restrictObjectType() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [RemoveMemberPermission]. + * Returns a mutable builder for constructing an instance of + * [RemoveMemberPermission]. * * The following fields are required: + * * ```java * .permission() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [RemoveMemberPermission]. */ @@ -1186,87 +1240,101 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeMemberPermission: RemoveMemberPermission) = apply { - permission = removeMemberPermission.permission - restrictObjectType = removeMemberPermission.restrictObjectType - additionalProperties = removeMemberPermission.additionalProperties.toMutableMap() - } + internal fun from(removeMemberPermission: RemoveMemberPermission) = + apply { + permission = removeMemberPermission.permission + restrictObjectType = removeMemberPermission.restrictObjectType + additionalProperties = removeMemberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } + fun permission(permission: JsonField) = + apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = - restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = - restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = + apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveMemberPermission = RemoveMemberPermission( - checkRequired("permission", permission), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired( + "permission", permission + ), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1305,9 +1373,11 @@ private constructor( * 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 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 { @@ -1330,8 +1400,8 @@ private constructor( * 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. + * 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) { @@ -1353,7 +1423,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1374,20 +1444,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1396,19 +1463,21 @@ private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -1458,9 +1527,11 @@ private constructor( * * 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 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 { @@ -1486,8 +1557,8 @@ private constructor( * 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. + * 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) { @@ -1512,7 +1583,7 @@ private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1527,8 +1598,7 @@ private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1537,20 +1607,17 @@ private constructor( * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1559,11 +1626,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1572,20 +1639,18 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "RoleUpdateParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "RoleUpdateParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index ff05be5e..6d82da0b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -19,19 +19,14 @@ import java.util.Optional /** Summary of a score's performance */ @NoAutoDetect -class ScoreSummary -@JsonCreator -private constructor( - @JsonProperty("improvements") - @ExcludeMissing - private val improvements: JsonField = JsonMissing.of(), +class ScoreSummary @JsonCreator private constructor( + @JsonProperty("improvements") @ExcludeMissing private val improvements: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("regressions") - @ExcludeMissing - private val regressions: JsonField = JsonMissing.of(), + @JsonProperty("regressions") @ExcludeMissing private val regressions: JsonField = JsonMissing.of(), @JsonProperty("score") @ExcludeMissing private val score: JsonField = JsonMissing.of(), @JsonProperty("diff") @ExcludeMissing private val diff: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Number of improvements in the score */ @@ -55,16 +50,24 @@ private constructor( fun _improvements(): JsonField = improvements /** Name of the score */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Number of regressions in the score */ - @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions + @JsonProperty("regressions") + @ExcludeMissing + fun _regressions(): JsonField = regressions /** Average score across all examples */ - @JsonProperty("score") @ExcludeMissing fun _score(): JsonField = score + @JsonProperty("score") + @ExcludeMissing + fun _score(): JsonField = score /** Difference in score between the current and comparison experiment */ - @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff + @JsonProperty("diff") + @ExcludeMissing + fun _diff(): JsonField = diff @JsonAnyGetter @ExcludeMissing @@ -72,19 +75,20 @@ private constructor( private var validated: Boolean = false - fun validate(): ScoreSummary = apply { - if (validated) { - return@apply + fun validate(): ScoreSummary = + apply { + if (validated) { + return@apply + } + + improvements() + name() + regressions() + score() + diff() + validated = true } - improvements() - name() - regressions() - score() - diff() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -93,6 +97,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ScoreSummary]. * * The following fields are required: + * * ```java * .improvements() * .name() @@ -100,7 +105,8 @@ private constructor( * .score() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ScoreSummary]. */ @@ -114,81 +120,112 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scoreSummary: ScoreSummary) = apply { - improvements = scoreSummary.improvements - name = scoreSummary.name - regressions = scoreSummary.regressions - score = scoreSummary.score - diff = scoreSummary.diff - additionalProperties = scoreSummary.additionalProperties.toMutableMap() - } + internal fun from(scoreSummary: ScoreSummary) = + apply { + improvements = scoreSummary.improvements + name = scoreSummary.name + regressions = scoreSummary.regressions + score = scoreSummary.score + diff = scoreSummary.diff + additionalProperties = scoreSummary.additionalProperties.toMutableMap() + } /** Number of improvements in the score */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) /** Number of improvements in the score */ - fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + fun improvements(improvements: JsonField) = + apply { + this.improvements = improvements + } /** Name of the score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the score */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Number of regressions in the score */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) /** Number of regressions in the score */ - fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + fun regressions(regressions: JsonField) = + apply { + this.regressions = regressions + } /** Average score across all examples */ fun score(score: Double) = score(JsonField.of(score)) /** Average score across all examples */ - fun score(score: JsonField) = apply { this.score = score } + fun score(score: JsonField) = + apply { + this.score = score + } /** Difference in score between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) /** Difference in score between the current and comparison experiment */ - fun diff(diff: JsonField) = apply { this.diff = diff } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun diff(diff: JsonField) = + apply { + this.diff = diff + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ScoreSummary = ScoreSummary( - checkRequired("improvements", improvements), - checkRequired("name", name), - checkRequired("regressions", regressions), - checkRequired("score", score), - diff, - additionalProperties.toImmutable(), + checkRequired( + "improvements", improvements + ), + checkRequired( + "name", name + ), + checkRequired( + "regressions", regressions + ), + checkRequired( + "score", score + ), + diff, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreSummary && improvements == other.improvements && name == other.name && regressions == other.regressions && score == other.score && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScoreSummary && improvements == other.improvements && name == other.name && regressions == other.regressions && score == other.score && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -197,6 +234,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ScoreSummary{improvements=$improvements, name=$name, regressions=$regressions, score=$score, diff=$diff, additionalProperties=$additionalProperties}" + override fun toString() = "ScoreSummary{improvements=$improvements, name=$name, regressions=$regressions, score=$score, diff=$diff, additionalProperties=$additionalProperties}" } 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..25ebb526 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 @@ -21,12 +21,11 @@ import kotlin.jvm.optionals.getOrNull /** Human-identifying attributes of the span, such as name, type, etc. */ @NoAutoDetect -class SpanAttributes -@JsonCreator -private constructor( +class SpanAttributes @JsonCreator private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the span, for display purposes only */ @@ -36,10 +35,14 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @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 @@ -47,22 +50,24 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanAttributes = apply { - if (validated) { - return@apply - } + fun validate(): SpanAttributes = + apply { + if (validated) { + return@apply + } - name() - type() - validated = true - } + name() + type() + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [SpanAttributes]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanAttributes]. */ @@ -73,11 +78,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = apply { - name = spanAttributes.name - type = spanAttributes.type - additionalProperties = spanAttributes.additionalProperties.toMutableMap() - } + internal fun from(spanAttributes: SpanAttributes) = + apply { + name = spanAttributes.name + type = spanAttributes.type + additionalProperties = spanAttributes.additionalProperties.toMutableMap() + } /** Name of the span, for display purposes only */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -86,7 +92,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the span, for display purposes only */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Type of the span, for display purposes only */ fun type(type: Type?) = type(JsonField.ofNullable(type)) @@ -95,42 +104,61 @@ private constructor( 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() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): SpanAttributes = SpanAttributes(name, type, additionalProperties.toImmutable()) + 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -163,9 +191,11 @@ private constructor( * 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 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 { @@ -180,11 +210,11 @@ private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -200,11 +230,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -220,23 +250,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -245,11 +272,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanAttributes && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanAttributes && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -258,6 +285,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index ab9266fa..461560c8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -20,31 +20,18 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class SpanIFrame -@JsonCreator -private constructor( +class SpanIFrame @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") - @ExcludeMissing - private val postMessage: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the span iframe */ @@ -63,37 +50,44 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of span iframe deletion, or null if the span iframe is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the span iframe */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(): Optional = - Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) /** Identifies the user who created the span iframe */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the span iframe */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url /** Date of span iframe creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of span iframe deletion, or null if the span iframe is still active */ @JsonProperty("deleted_at") @@ -101,18 +95,22 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the span iframe */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing fun _postMessage(): JsonField = postMessage /** Identifies the user who created the span iframe */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -120,23 +118,24 @@ private constructor( private var validated: Boolean = false - fun validate(): SpanIFrame = apply { - if (validated) { - return@apply + fun validate(): SpanIFrame = + apply { + if (validated) { + return@apply + } + + id() + name() + projectId() + url() + created() + deletedAt() + description() + postMessage() + userId() + validated = true } - id() - name() - projectId() - url() - created() - deletedAt() - description() - postMessage() - userId() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -145,6 +144,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [SpanIFrame]. * * The following fields are required: + * * ```java * .id() * .name() @@ -152,7 +152,8 @@ private constructor( * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIFrame]. */ @@ -170,42 +171,55 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIFrame: SpanIFrame) = apply { - id = spanIFrame.id - name = spanIFrame.name - projectId = spanIFrame.projectId - url = spanIFrame.url - created = spanIFrame.created - deletedAt = spanIFrame.deletedAt - description = spanIFrame.description - postMessage = spanIFrame.postMessage - userId = spanIFrame.userId - additionalProperties = spanIFrame.additionalProperties.toMutableMap() - } + internal fun from(spanIFrame: SpanIFrame) = + apply { + id = spanIFrame.id + name = spanIFrame.name + projectId = spanIFrame.projectId + url = spanIFrame.url + created = spanIFrame.created + deletedAt = spanIFrame.deletedAt + description = spanIFrame.description + postMessage = spanIFrame.postMessage + userId = spanIFrame.userId + additionalProperties = spanIFrame.additionalProperties.toMutableMap() + } /** Unique identifier for the span iframe */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the span iframe */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = + apply { + this.url = url + } /** Date of span iframe creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -214,7 +228,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of span iframe creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of span iframe deletion, or null if the span iframe is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -223,7 +240,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of span iframe deletion, or null if the span iframe is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -232,31 +252,37 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = + apply { + this.description = description + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage } + fun postMessage(postMessage: JsonField) = + apply { + this.postMessage = postMessage + } /** Identifies the user who created the span iframe */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -265,48 +291,66 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the span iframe */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SpanIFrame = SpanIFrame( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("url", url), - created, - deletedAt, - description, - postMessage, - userId, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "url", url + ), + created, + deletedAt, + description, + postMessage, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIFrame && id == other.id && name == other.name && projectId == other.projectId && url == other.url && created == other.created && deletedAt == other.deletedAt && description == other.description && postMessage == other.postMessage && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanIFrame && id == other.id && name == other.name && projectId == other.projectId && url == other.url && created == other.created && deletedAt == other.deletedAt && description == other.description && postMessage == other.postMessage && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -315,6 +359,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SpanIFrame{id=$id, name=$name, projectId=$projectId, url=$url, created=$created, deletedAt=$deletedAt, description=$description, postMessage=$postMessage, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "SpanIFrame{id=$id, name=$name, projectId=$projectId, url=$url, created=$created, deletedAt=$deletedAt, description=$description, postMessage=$postMessage, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 9f81c14e..29e104af 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will return the existing span_iframe unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name + * as the one specified in the request, will return the existing span_iframe + * unmodified */ -class SpanIframeCreateParams -private constructor( +class SpanIframeCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the span iframe */ @@ -45,8 +46,8 @@ private constructor( fun description(): Optional = body.description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -63,8 +64,8 @@ private constructor( fun _description(): JsonField = body._description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -74,31 +75,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") - @ExcludeMissing - private val postMessage: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the span iframe */ @@ -111,24 +103,28 @@ private constructor( fun url(): String = url.getRequired("url") /** Textual description of the span iframe */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(): Optional = - Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url /** Textual description of the span iframe */ @JsonProperty("description") @@ -136,8 +132,8 @@ private constructor( fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing @@ -149,19 +145,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + url() + description() + postMessage() + validated = true } - name() - projectId() - url() - description() - postMessage() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -170,13 +167,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -190,32 +189,42 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - url = body.url - description = body.description - postMessage = body.postMessage - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + url = body.url + description = body.description + postMessage = body.postMessage + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = + apply { + this.url = url + } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -224,72 +233,87 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { - this.postMessage = postMessage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun postMessage(postMessage: JsonField) = + apply { + this.postMessage = postMessage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("url", url), - description, - postMessage, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "url", url + ), + description, + postMessage, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -298,8 +322,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -307,16 +330,19 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeCreateParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeCreateParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeCreateParams]. */ @@ -328,198 +354,262 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = apply { - body = spanIframeCreateParams.body.toBuilder() - additionalHeaders = spanIframeCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = + apply { + body = spanIframeCreateParams.body.toBuilder() + additionalHeaders = spanIframeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeCreateParams.additionalQueryParams.toBuilder() + } /** Name of the span iframe */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the span iframe */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = apply { body.url(url) } + fun url(url: String) = + apply { + body.url(url) + } /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { body.url(url) } + fun url(url: JsonField) = + apply { + body.url(url) + } /** Textual description of the span iframe */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the span iframe */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: Boolean?) = + apply { + body.postMessage(postMessage) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: JsonField) = + apply { + body.postMessage(postMessage) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeCreateParams = SpanIframeCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt index ca88a657..a39365d1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a span_iframe object by its id */ -class SpanIframeDeleteParams -private constructor( +class SpanIframeDeleteParams private constructor( private val spanIframeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, + ) : Params { /** SpanIframe id */ @@ -31,18 +31,17 @@ private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -50,14 +49,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeDeleteParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeDeleteParams]. * * The following fields are required: + * * ```java * .spanIframeId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeDeleteParams]. */ @@ -70,156 +72,190 @@ private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIframeDeleteParams: SpanIframeDeleteParams) = apply { - spanIframeId = spanIframeDeleteParams.spanIframeId - additionalHeaders = spanIframeDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - spanIframeDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(spanIframeDeleteParams: SpanIframeDeleteParams) = + apply { + spanIframeId = spanIframeDeleteParams.spanIframeId + additionalHeaders = spanIframeDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = spanIframeDeleteParams.additionalBodyProperties.toMutableMap() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + fun spanIframeId(spanIframeId: String) = + apply { + this.spanIframeId = spanIframeId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = + apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): SpanIframeDeleteParams = SpanIframeDeleteParams( - checkRequired("spanIframeId", spanIframeId), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired( + "spanIframeId", spanIframeId + ), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = - "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index 26329957..2564c749 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.SpanIframeService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ -class SpanIframeListPage -private constructor( +class SpanIframeListPage private constructor( private val spanIframesService: SpanIframeService, private val params: SpanIframeListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,46 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListPage && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is SpanIframeListPage && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ - override fun toString() = - "SpanIframeListPage{spanIframesService=$spanIframesService, params=$params, response=$response}" + override fun toString() = "SpanIframeListPage{spanIframesService=$spanIframesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - SpanIframeListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - SpanIframeListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(SpanIframeListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(SpanIframeListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { spanIframesService.list(it) } + return getNextPageParams().map { spanIframesService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -83,21 +73,19 @@ private constructor( companion object { @JvmStatic - fun of( - spanIframesService: SpanIframeService, - params: SpanIframeListParams, - response: Response, - ) = SpanIframeListPage(spanIframesService, params, response) + fun of(spanIframesService: SpanIframeService, params: SpanIframeListParams, response: Response) = + SpanIframeListPage( + spanIframesService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -111,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [SpanIframeListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -147,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: SpanIframeListPage) : Iterable { + class AutoPager( + private val firstPage: SpanIframeListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt index b851e390..bf9d1da6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.SpanIframeServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ -class SpanIframeListPageAsync -private constructor( +class SpanIframeListPageAsync private constructor( private val spanIframesService: SpanIframeServiceAsync, private val params: SpanIframeListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,48 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListPageAsync && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is SpanIframeListPageAsync && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ - override fun toString() = - "SpanIframeListPageAsync{spanIframesService=$spanIframesService, params=$params, response=$response}" + override fun toString() = "SpanIframeListPageAsync{spanIframesService=$spanIframesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - SpanIframeListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - ) - } else { - Optional.of( - SpanIframeListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(SpanIframeListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(SpanIframeListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { spanIframesService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + spanIframesService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -85,21 +80,19 @@ private constructor( companion object { @JvmStatic - fun of( - spanIframesService: SpanIframeServiceAsync, - params: SpanIframeListParams, - response: Response, - ) = SpanIframeListPageAsync(spanIframesService, params, response) + fun of(spanIframesService: SpanIframeServiceAsync, params: SpanIframeListParams, response: Response) = + SpanIframeListPageAsync( + spanIframesService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( - @JsonProperty("objects") - private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Response @JsonCreator constructor( + @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -113,36 +106,38 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeListPageAsync]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -151,46 +146,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: SpanIframeListPageAsync) { + class AutoPager( + private val firstPage: SpanIframeListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (SpanIFrame) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (SpanIFrame) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 87ccce77..51eca91e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ -class SpanIframeListParams -private constructor( +class SpanIframeListParams private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -36,20 +35,21 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,25 +78,54 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.spanIframeName?.let { queryParams.put("span_iframe_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.spanIframeName?.let { + queryParams.put( + "span_iframe_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): SpanIframeListParams = builder().build() + @JvmStatic + fun none(): SpanIframeListParams = builder().build() - /** Returns a mutable builder for constructing an instance of [SpanIframeListParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [SpanIframeListParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeListParams]. */ @@ -113,61 +142,71 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeListParams: SpanIframeListParams) = apply { - endingBefore = spanIframeListParams.endingBefore - ids = spanIframeListParams.ids - limit = spanIframeListParams.limit - orgName = spanIframeListParams.orgName - spanIframeName = spanIframeListParams.spanIframeName - startingAfter = spanIframeListParams.startingAfter - additionalHeaders = spanIframeListParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeListParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeListParams: SpanIframeListParams) = + apply { + endingBefore = spanIframeListParams.endingBefore + ids = spanIframeListParams.ids + limit = spanIframeListParams.limit + orgName = spanIframeListParams.orgName + spanIframeName = spanIframeListParams.spanIframeName + startingAfter = spanIframeListParams.startingAfter + additionalHeaders = spanIframeListParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -176,159 +215,192 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the span_iframe to search for */ - fun spanIframeName(spanIframeName: String?) = apply { this.spanIframeName = spanIframeName } + fun spanIframeName(spanIframeName: String?) = + apply { + this.spanIframeName = spanIframeName + } /** Name of the span_iframe to search for */ - fun spanIframeName(spanIframeName: Optional) = - spanIframeName(spanIframeName.getOrNull()) + fun spanIframeName(spanIframeName: Optional) = spanIframeName(spanIframeName.getOrNull()) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeListParams = SpanIframeListParams( - endingBefore, - ids, - limit, - orgName, - spanIframeName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + spanIframeName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -346,19 +418,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -373,12 +445,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -388,60 +465,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, spanIframeName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index d3dc8f16..ae6144aa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -22,14 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will replace the existing span_iframe with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same + * name as the one specified in the request, will replace the existing span_iframe + * with the provided fields */ -class SpanIframeReplaceParams -private constructor( +class SpanIframeReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the span iframe */ @@ -45,8 +46,8 @@ private constructor( fun description(): Optional = body.description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -63,8 +64,8 @@ private constructor( fun _description(): JsonField = body._description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -74,31 +75,22 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - private val projectId: JsonField = JsonMissing.of(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") - @ExcludeMissing - private val postMessage: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the span iframe */ @@ -111,24 +103,28 @@ private constructor( fun url(): String = url.getRequired("url") /** Textual description of the span iframe */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(): Optional = - Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url /** Textual description of the span iframe */ @JsonProperty("description") @@ -136,8 +132,8 @@ private constructor( fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing @@ -149,19 +145,20 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + projectId() + url() + description() + postMessage() + validated = true } - name() - projectId() - url() - description() - postMessage() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -170,13 +167,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -190,32 +189,42 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - projectId = body.projectId - url = body.url - description = body.description - postMessage = body.postMessage - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + projectId = body.projectId + url = body.url + description = body.description + postMessage = body.postMessage + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = + apply { + this.projectId = projectId + } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = + apply { + this.url = url + } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -224,72 +233,87 @@ private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { - this.description = description - } + fun description(description: JsonField) = + apply { + this.description = description + } /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { - this.postMessage = postMessage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun postMessage(postMessage: JsonField) = + apply { + this.postMessage = postMessage + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("projectId", projectId), - checkRequired("url", url), - description, - postMessage, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "projectId", projectId + ), + checkRequired( + "url", url + ), + description, + postMessage, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -298,8 +322,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -307,16 +330,19 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeReplaceParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeReplaceParams]. * * The following fields are required: + * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeReplaceParams]. */ @@ -328,198 +354,262 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = apply { - body = spanIframeReplaceParams.body.toBuilder() - additionalHeaders = spanIframeReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = + apply { + body = spanIframeReplaceParams.body.toBuilder() + additionalHeaders = spanIframeReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the span iframe */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the span iframe */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: String) = apply { body.projectId(projectId) } + fun projectId(projectId: String) = + apply { + body.projectId(projectId) + } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } + fun projectId(projectId: JsonField) = + apply { + body.projectId(projectId) + } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = apply { body.url(url) } + fun url(url: String) = + apply { + body.url(url) + } /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { body.url(url) } + fun url(url: JsonField) = + apply { + body.url(url) + } /** Textual description of the span iframe */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String?) = + apply { + body.description(description) + } /** Textual description of the span iframe */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = apply { body.description(description) } + fun description(description: JsonField) = + apply { + body.description(description) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: Boolean?) = + apply { + body.postMessage(postMessage) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: JsonField) = + apply { + body.postMessage(postMessage) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeReplaceParams = SpanIframeReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt index 241438c1..6059ad2c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a span_iframe object by its id */ -class SpanIframeRetrieveParams -private constructor( +class SpanIframeRetrieveParams private constructor( private val spanIframeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** SpanIframe id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,14 +40,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeRetrieveParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeRetrieveParams]. * * The following fields are required: + * * ```java * .spanIframeId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeRetrieveParams]. */ @@ -59,131 +62,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeRetrieveParams: SpanIframeRetrieveParams) = apply { - spanIframeId = spanIframeRetrieveParams.spanIframeId - additionalHeaders = spanIframeRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeRetrieveParams: SpanIframeRetrieveParams) = + apply { + spanIframeId = spanIframeRetrieveParams.spanIframeId + additionalHeaders = spanIframeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeRetrieveParams.additionalQueryParams.toBuilder() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + fun spanIframeId(spanIframeId: String) = + apply { + this.spanIframeId = spanIframeId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeRetrieveParams = SpanIframeRetrieveParams( - checkRequired("spanIframeId", spanIframeId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "spanIframeId", spanIframeId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 50735234..15870507 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a span_iframe object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ -class SpanIframeUpdateParams -private constructor( +class SpanIframeUpdateParams private constructor( private val spanIframeId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** SpanIframe id */ @@ -41,8 +41,8 @@ private constructor( fun name(): Optional = body.name() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -53,8 +53,8 @@ private constructor( fun _name(): JsonField = body._name() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -67,60 +67,58 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("post_message") - @ExcludeMissing - private val postMessage: JsonField = JsonMissing.of(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the span iframe */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(): Optional = - Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) /** URL to embed the project viewer in an iframe */ fun url(): Optional = Optional.ofNullable(url.getNullable("url")) /** Name of the span iframe */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing fun _postMessage(): JsonField = postMessage /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + @JsonProperty("url") + @ExcludeMissing + fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -128,23 +126,25 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + postMessage() + url() + validated = true } - name() - postMessage() - url() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -156,12 +156,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - postMessage = body.postMessage - url = body.url - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + postMessage = body.postMessage + url = body.url + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -170,33 +171,37 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the span iframe */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { - this.postMessage = postMessage - } + fun postMessage(postMessage: JsonField) = + apply { + this.postMessage = postMessage + } /** URL to embed the project viewer in an iframe */ fun url(url: String?) = url(JsonField.ofNullable(url)) @@ -205,36 +210,52 @@ private constructor( fun url(url: Optional) = url(url.getOrNull()) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { this.url = url } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = Body(name, postMessage, url, additionalProperties.toImmutable()) + fun url(url: JsonField) = + apply { + this.url = url + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = + Body( + name, + postMessage, + url, + additionalProperties.toImmutable(), + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -243,8 +264,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -252,14 +272,17 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SpanIframeUpdateParams]. + * Returns a mutable builder for constructing an instance of + * [SpanIframeUpdateParams]. * * The following fields are required: + * * ```java * .spanIframeId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SpanIframeUpdateParams]. */ @@ -272,194 +295,251 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = apply { - spanIframeId = spanIframeUpdateParams.spanIframeId - body = spanIframeUpdateParams.body.toBuilder() - additionalHeaders = spanIframeUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = + apply { + spanIframeId = spanIframeUpdateParams.spanIframeId + body = spanIframeUpdateParams.body.toBuilder() + additionalHeaders = spanIframeUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeUpdateParams.additionalQueryParams.toBuilder() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + fun spanIframeId(spanIframeId: String) = + apply { + this.spanIframeId = spanIframeId + } /** Name of the span iframe */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the span iframe */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the span iframe */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: Boolean?) = + apply { + body.postMessage(postMessage) + } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is + * useful when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } + fun postMessage(postMessage: JsonField) = + apply { + body.postMessage(postMessage) + } /** URL to embed the project viewer in an iframe */ - fun url(url: String?) = apply { body.url(url) } + fun url(url: String?) = + apply { + body.url(url) + } /** URL to embed the project viewer in an iframe */ fun url(url: Optional) = url(url.getOrNull()) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = apply { body.url(url) } + fun url(url: JsonField) = + apply { + body.url(url) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeUpdateParams = SpanIframeUpdateParams( - checkRequired("spanIframeId", spanIframeId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "spanIframeId", spanIframeId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "SpanIframeUpdateParams{spanIframeId=$spanIframeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "SpanIframeUpdateParams{spanIframeId=$spanIframeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 949d6300..9d77823b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -20,25 +20,14 @@ import kotlin.jvm.optionals.getOrNull /** Summary of a dataset */ @NoAutoDetect -class SummarizeDatasetResponse -@JsonCreator -private constructor( - @JsonProperty("dataset_name") - @ExcludeMissing - private val datasetName: JsonField = JsonMissing.of(), - @JsonProperty("dataset_url") - @ExcludeMissing - private val datasetUrl: JsonField = JsonMissing.of(), - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("project_url") - @ExcludeMissing - private val projectUrl: JsonField = JsonMissing.of(), - @JsonProperty("data_summary") - @ExcludeMissing - private val dataSummary: JsonField = JsonMissing.of(), +class SummarizeDatasetResponse @JsonCreator private constructor( + @JsonProperty("dataset_name") @ExcludeMissing private val datasetName: JsonField = JsonMissing.of(), + @JsonProperty("dataset_url") @ExcludeMissing private val datasetUrl: JsonField = JsonMissing.of(), + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("project_url") @ExcludeMissing private val projectUrl: JsonField = JsonMissing.of(), + @JsonProperty("data_summary") @ExcludeMissing private val dataSummary: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the dataset */ @@ -54,8 +43,7 @@ private constructor( fun projectUrl(): String = projectUrl.getRequired("project_url") /** Summary of a dataset's data */ - fun dataSummary(): Optional = - Optional.ofNullable(dataSummary.getNullable("data_summary")) + fun dataSummary(): Optional = Optional.ofNullable(dataSummary.getNullable("data_summary")) /** Name of the dataset */ @JsonProperty("dataset_name") @@ -63,7 +51,9 @@ private constructor( fun _datasetName(): JsonField = datasetName /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl(): JsonField = datasetUrl + @JsonProperty("dataset_url") + @ExcludeMissing + fun _datasetUrl(): JsonField = datasetUrl /** Name of the project that the dataset belongs to */ @JsonProperty("project_name") @@ -71,7 +61,9 @@ private constructor( fun _projectName(): JsonField = projectName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl + @JsonProperty("project_url") + @ExcludeMissing + fun _projectUrl(): JsonField = projectUrl /** Summary of a dataset's data */ @JsonProperty("data_summary") @@ -84,27 +76,30 @@ private constructor( private var validated: Boolean = false - fun validate(): SummarizeDatasetResponse = apply { - if (validated) { - return@apply + fun validate(): SummarizeDatasetResponse = + apply { + if (validated) { + return@apply + } + + datasetName() + datasetUrl() + projectName() + projectUrl() + dataSummary().ifPresent { it.validate() } + validated = true } - datasetName() - datasetUrl() - projectName() - projectUrl() - dataSummary().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [SummarizeDatasetResponse]. + * Returns a mutable builder for constructing an instance of + * [SummarizeDatasetResponse]. * * The following fields are required: + * * ```java * .datasetName() * .datasetUrl() @@ -112,7 +107,8 @@ private constructor( * .projectUrl() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SummarizeDatasetResponse]. */ @@ -126,38 +122,51 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(summarizeDatasetResponse: SummarizeDatasetResponse) = apply { - datasetName = summarizeDatasetResponse.datasetName - datasetUrl = summarizeDatasetResponse.datasetUrl - projectName = summarizeDatasetResponse.projectName - projectUrl = summarizeDatasetResponse.projectUrl - dataSummary = summarizeDatasetResponse.dataSummary - additionalProperties = summarizeDatasetResponse.additionalProperties.toMutableMap() - } + internal fun from(summarizeDatasetResponse: SummarizeDatasetResponse) = + apply { + datasetName = summarizeDatasetResponse.datasetName + datasetUrl = summarizeDatasetResponse.datasetUrl + projectName = summarizeDatasetResponse.projectName + projectUrl = summarizeDatasetResponse.projectUrl + dataSummary = summarizeDatasetResponse.dataSummary + additionalProperties = summarizeDatasetResponse.additionalProperties.toMutableMap() + } /** Name of the dataset */ fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) /** Name of the dataset */ - fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } + fun datasetName(datasetName: JsonField) = + apply { + this.datasetName = datasetName + } /** URL to the dataset's page in the Braintrust app */ fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) /** URL to the dataset's page in the Braintrust app */ - fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } + fun datasetUrl(datasetUrl: JsonField) = + apply { + this.datasetUrl = datasetUrl + } /** Name of the project that the dataset belongs to */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** Name of the project that the dataset belongs to */ - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + fun projectUrl(projectUrl: JsonField) = + apply { + this.projectUrl = projectUrl + } /** Summary of a dataset's data */ fun dataSummary(dataSummary: DataSummary?) = dataSummary(JsonField.ofNullable(dataSummary)) @@ -166,46 +175,62 @@ private constructor( fun dataSummary(dataSummary: Optional) = dataSummary(dataSummary.getOrNull()) /** Summary of a dataset's data */ - fun dataSummary(dataSummary: JsonField) = apply { - this.dataSummary = dataSummary - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dataSummary(dataSummary: JsonField) = + apply { + this.dataSummary = dataSummary + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SummarizeDatasetResponse = SummarizeDatasetResponse( - checkRequired("datasetName", datasetName), - checkRequired("datasetUrl", datasetUrl), - checkRequired("projectName", projectName), - checkRequired("projectUrl", projectUrl), - dataSummary, - additionalProperties.toImmutable(), + checkRequired( + "datasetName", datasetName + ), + checkRequired( + "datasetUrl", datasetUrl + ), + checkRequired( + "projectName", projectName + ), + checkRequired( + "projectUrl", projectUrl + ), + dataSummary, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SummarizeDatasetResponse && datasetName == other.datasetName && datasetUrl == other.datasetUrl && projectName == other.projectName && projectUrl == other.projectUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeDatasetResponse && datasetName == other.datasetName && datasetUrl == other.datasetUrl && projectName == other.projectName && projectUrl == other.projectUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -214,6 +239,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SummarizeDatasetResponse{datasetName=$datasetName, datasetUrl=$datasetUrl, projectName=$projectName, projectUrl=$projectUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" + override fun toString() = "SummarizeDatasetResponse{datasetName=$datasetName, datasetUrl=$datasetUrl, projectName=$projectName, projectUrl=$projectUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index b23ca9e9..05ec4392 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -20,31 +20,16 @@ import kotlin.jvm.optionals.getOrNull /** Summary of an experiment */ @NoAutoDetect -class SummarizeExperimentResponse -@JsonCreator -private constructor( - @JsonProperty("experiment_name") - @ExcludeMissing - private val experimentName: JsonField = JsonMissing.of(), - @JsonProperty("experiment_url") - @ExcludeMissing - private val experimentUrl: JsonField = JsonMissing.of(), - @JsonProperty("project_name") - @ExcludeMissing - private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("project_url") - @ExcludeMissing - private val projectUrl: JsonField = JsonMissing.of(), - @JsonProperty("comparison_experiment_name") - @ExcludeMissing - private val comparisonExperimentName: JsonField = JsonMissing.of(), - @JsonProperty("metrics") - @ExcludeMissing - private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("scores") - @ExcludeMissing - private val scores: JsonField = JsonMissing.of(), +class SummarizeExperimentResponse @JsonCreator private constructor( + @JsonProperty("experiment_name") @ExcludeMissing private val experimentName: JsonField = JsonMissing.of(), + @JsonProperty("experiment_url") @ExcludeMissing private val experimentUrl: JsonField = JsonMissing.of(), + @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("project_url") @ExcludeMissing private val projectUrl: JsonField = JsonMissing.of(), + @JsonProperty("comparison_experiment_name") @ExcludeMissing private val comparisonExperimentName: JsonField = JsonMissing.of(), + @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the experiment */ @@ -60,8 +45,7 @@ private constructor( fun projectUrl(): String = projectUrl.getRequired("project_url") /** The experiment which scores are baselined against */ - fun comparisonExperimentName(): Optional = - Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) + fun comparisonExperimentName(): Optional = Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) /** Summary of the experiment's metrics */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -85,7 +69,9 @@ private constructor( fun _projectName(): JsonField = projectName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl + @JsonProperty("project_url") + @ExcludeMissing + fun _projectUrl(): JsonField = projectUrl /** The experiment which scores are baselined against */ @JsonProperty("comparison_experiment_name") @@ -93,10 +79,14 @@ private constructor( fun _comparisonExperimentName(): JsonField = comparisonExperimentName /** Summary of the experiment's metrics */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics(): JsonField = metrics /** Summary of the experiment's scores */ - @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores(): JsonField = scores @JsonAnyGetter @ExcludeMissing @@ -104,29 +94,32 @@ private constructor( private var validated: Boolean = false - fun validate(): SummarizeExperimentResponse = apply { - if (validated) { - return@apply - } + fun validate(): SummarizeExperimentResponse = + apply { + if (validated) { + return@apply + } - experimentName() - experimentUrl() - projectName() - projectUrl() - comparisonExperimentName() - metrics().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - validated = true - } + experimentName() + experimentUrl() + projectName() + projectUrl() + comparisonExperimentName() + metrics().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [SummarizeExperimentResponse]. + * Returns a mutable builder for constructing an instance of + * [SummarizeExperimentResponse]. * * The following fields are required: + * * ```java * .experimentName() * .experimentUrl() @@ -134,7 +127,8 @@ private constructor( * .projectUrl() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [SummarizeExperimentResponse]. */ @@ -150,57 +144,65 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(summarizeExperimentResponse: SummarizeExperimentResponse) = apply { - experimentName = summarizeExperimentResponse.experimentName - experimentUrl = summarizeExperimentResponse.experimentUrl - projectName = summarizeExperimentResponse.projectName - projectUrl = summarizeExperimentResponse.projectUrl - comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName - metrics = summarizeExperimentResponse.metrics - scores = summarizeExperimentResponse.scores - additionalProperties = summarizeExperimentResponse.additionalProperties.toMutableMap() - } + internal fun from(summarizeExperimentResponse: SummarizeExperimentResponse) = + apply { + experimentName = summarizeExperimentResponse.experimentName + experimentUrl = summarizeExperimentResponse.experimentUrl + projectName = summarizeExperimentResponse.projectName + projectUrl = summarizeExperimentResponse.projectUrl + comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName + metrics = summarizeExperimentResponse.metrics + scores = summarizeExperimentResponse.scores + additionalProperties = summarizeExperimentResponse.additionalProperties.toMutableMap() + } /** Name of the experiment */ fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) /** Name of the experiment */ - fun experimentName(experimentName: JsonField) = apply { - this.experimentName = experimentName - } + fun experimentName(experimentName: JsonField) = + apply { + this.experimentName = experimentName + } /** URL to the experiment's page in the Braintrust app */ fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) /** URL to the experiment's page in the Braintrust app */ - fun experimentUrl(experimentUrl: JsonField) = apply { - this.experimentUrl = experimentUrl - } + fun experimentUrl(experimentUrl: JsonField) = + apply { + this.experimentUrl = experimentUrl + } /** Name of the project that the experiment belongs to */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** Name of the project that the experiment belongs to */ - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + fun projectName(projectName: JsonField) = + apply { + this.projectName = projectName + } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + fun projectUrl(projectUrl: JsonField) = + apply { + this.projectUrl = projectUrl + } /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: String?) = - comparisonExperimentName(JsonField.ofNullable(comparisonExperimentName)) + fun comparisonExperimentName(comparisonExperimentName: String?) = comparisonExperimentName(JsonField.ofNullable(comparisonExperimentName)) /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: Optional) = - comparisonExperimentName(comparisonExperimentName.getOrNull()) + fun comparisonExperimentName(comparisonExperimentName: Optional) = comparisonExperimentName(comparisonExperimentName.getOrNull()) /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: JsonField) = apply { - this.comparisonExperimentName = comparisonExperimentName - } + fun comparisonExperimentName(comparisonExperimentName: JsonField) = + apply { + this.comparisonExperimentName = comparisonExperimentName + } /** Summary of the experiment's metrics */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) @@ -209,7 +211,10 @@ private constructor( fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** Summary of the experiment's metrics */ - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = + apply { + this.metrics = metrics + } /** Summary of the experiment's scores */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) @@ -218,47 +223,63 @@ private constructor( fun scores(scores: Optional) = scores(scores.getOrNull()) /** Summary of the experiment's scores */ - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = + apply { + this.scores = scores + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SummarizeExperimentResponse = SummarizeExperimentResponse( - checkRequired("experimentName", experimentName), - checkRequired("experimentUrl", experimentUrl), - checkRequired("projectName", projectName), - checkRequired("projectUrl", projectUrl), - comparisonExperimentName, - metrics, - scores, - additionalProperties.toImmutable(), + checkRequired( + "experimentName", experimentName + ), + checkRequired( + "experimentUrl", experimentUrl + ), + checkRequired( + "projectName", projectName + ), + checkRequired( + "projectUrl", projectUrl + ), + comparisonExperimentName, + metrics, + scores, + additionalProperties.toImmutable(), ) } /** Summary of the experiment's metrics */ @NoAutoDetect - class Metrics - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Metrics @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -267,20 +288,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Metrics = apply { - if (validated) { - return@apply - } + fun validate(): Metrics = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -289,38 +312,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = apply { - additionalProperties = metrics.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metrics: Metrics) = + apply { + additionalProperties = metrics.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -334,11 +365,9 @@ private constructor( /** Summary of the experiment's scores */ @NoAutoDetect - class Scores - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class Scores @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -347,20 +376,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Scores = apply { - if (validated) { - return@apply - } + fun validate(): Scores = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Scores]. */ @@ -369,38 +400,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = + apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -413,11 +452,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SummarizeExperimentResponse && experimentName == other.experimentName && experimentUrl == other.experimentUrl && projectName == other.projectName && projectUrl == other.projectUrl && comparisonExperimentName == other.comparisonExperimentName && metrics == other.metrics && scores == other.scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeExperimentResponse && experimentName == other.experimentName && experimentUrl == other.experimentUrl && projectName == other.projectName && projectUrl == other.projectUrl && comparisonExperimentName == other.comparisonExperimentName && metrics == other.metrics && scores == other.scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -426,6 +465,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "SummarizeExperimentResponse{experimentName=$experimentName, experimentUrl=$experimentUrl, projectName=$projectName, projectUrl=$projectUrl, comparisonExperimentName=$comparisonExperimentName, metrics=$metrics, scores=$scores, additionalProperties=$additionalProperties}" + override fun toString() = "SummarizeExperimentResponse{experimentName=$experimentName, experimentUrl=$experimentUrl, projectName=$projectName, projectUrl=$projectUrl, comparisonExperimentName=$comparisonExperimentName, metrics=$metrics, scores=$scores, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index a3a17747..b8b095b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -8,11 +8,14 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import java.util.Objects -/** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ -class TopLevelHelloWorldParams -private constructor( +/** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ +class TopLevelHelloWorldParams private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { fun _additionalHeaders(): Headers = additionalHeaders @@ -27,10 +30,15 @@ private constructor( companion object { - @JvmStatic fun none(): TopLevelHelloWorldParams = builder().build() + @JvmStatic + fun none(): TopLevelHelloWorldParams = builder().build() - /** Returns a mutable builder for constructing an instance of [TopLevelHelloWorldParams]. */ - @JvmStatic fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [TopLevelHelloWorldParams]. + */ + @JvmStatic + fun builder() = Builder() } /** A builder for [TopLevelHelloWorldParams]. */ @@ -41,123 +49,151 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = apply { - additionalHeaders = topLevelHelloWorldParams.additionalHeaders.toBuilder() - additionalQueryParams = topLevelHelloWorldParams.additionalQueryParams.toBuilder() - } + internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = + apply { + additionalHeaders = topLevelHelloWorldParams.additionalHeaders.toBuilder() + additionalQueryParams = topLevelHelloWorldParams.additionalQueryParams.toBuilder() + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): TopLevelHelloWorldParams = - TopLevelHelloWorldParams(additionalHeaders.build(), additionalQueryParams.build()) + TopLevelHelloWorldParams( + additionalHeaders.build(), additionalQueryParams.build() + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index b064f7aa..a2e28021 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -20,24 +20,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class User -@JsonCreator -private constructor( +class User @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("avatar_url") - @ExcludeMissing - private val avatarUrl: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), + @JsonProperty("avatar_url") @ExcludeMissing private val avatarUrl: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), @JsonProperty("email") @ExcludeMissing private val email: JsonField = JsonMissing.of(), - @JsonProperty("family_name") - @ExcludeMissing - private val familyName: JsonField = JsonMissing.of(), - @JsonProperty("given_name") - @ExcludeMissing - private val givenName: JsonField = JsonMissing.of(), + @JsonProperty("family_name") @ExcludeMissing private val familyName: JsonField = JsonMissing.of(), + @JsonProperty("given_name") @ExcludeMissing private val givenName: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the user */ @@ -59,22 +50,34 @@ private constructor( fun givenName(): Optional = Optional.ofNullable(givenName.getNullable("given_name")) /** Unique identifier for the user */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** URL of the user's Avatar image */ - @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl(): JsonField = avatarUrl + @JsonProperty("avatar_url") + @ExcludeMissing + fun _avatarUrl(): JsonField = avatarUrl /** Date of user creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** The user's email */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + @JsonProperty("email") + @ExcludeMissing + fun _email(): JsonField = email /** Family name of the user */ - @JsonProperty("family_name") @ExcludeMissing fun _familyName(): JsonField = familyName + @JsonProperty("family_name") + @ExcludeMissing + fun _familyName(): JsonField = familyName /** Given name of the user */ - @JsonProperty("given_name") @ExcludeMissing fun _givenName(): JsonField = givenName + @JsonProperty("given_name") + @ExcludeMissing + fun _givenName(): JsonField = givenName @JsonAnyGetter @ExcludeMissing @@ -82,20 +85,21 @@ private constructor( private var validated: Boolean = false - fun validate(): User = apply { - if (validated) { - return@apply + fun validate(): User = + apply { + if (validated) { + return@apply + } + + id() + avatarUrl() + created() + email() + familyName() + givenName() + validated = true } - id() - avatarUrl() - created() - email() - familyName() - givenName() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -104,11 +108,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: + * * ```java * .id() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [User]. */ @@ -123,21 +129,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(user: User) = apply { - id = user.id - avatarUrl = user.avatarUrl - created = user.created - email = user.email - familyName = user.familyName - givenName = user.givenName - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = + apply { + id = user.id + avatarUrl = user.avatarUrl + created = user.created + email = user.email + familyName = user.familyName + givenName = user.givenName + additionalProperties = user.additionalProperties.toMutableMap() + } /** Unique identifier for the user */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the user */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** URL of the user's Avatar image */ fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) @@ -146,7 +156,10 @@ private constructor( fun avatarUrl(avatarUrl: Optional) = avatarUrl(avatarUrl.getOrNull()) /** URL of the user's Avatar image */ - fun avatarUrl(avatarUrl: JsonField) = apply { this.avatarUrl = avatarUrl } + fun avatarUrl(avatarUrl: JsonField) = + apply { + this.avatarUrl = avatarUrl + } /** Date of user creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -155,7 +168,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of user creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** The user's email */ fun email(email: String?) = email(JsonField.ofNullable(email)) @@ -164,7 +180,10 @@ private constructor( fun email(email: Optional) = email(email.getOrNull()) /** The user's email */ - fun email(email: JsonField) = apply { this.email = email } + fun email(email: JsonField) = + apply { + this.email = email + } /** Family name of the user */ fun familyName(familyName: String?) = familyName(JsonField.ofNullable(familyName)) @@ -173,7 +192,10 @@ private constructor( fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) /** Family name of the user */ - fun familyName(familyName: JsonField) = apply { this.familyName = familyName } + fun familyName(familyName: JsonField) = + apply { + this.familyName = familyName + } /** Given name of the user */ fun givenName(givenName: String?) = givenName(JsonField.ofNullable(givenName)) @@ -182,45 +204,57 @@ private constructor( fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) /** Given name of the user */ - fun givenName(givenName: JsonField) = apply { this.givenName = givenName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun givenName(givenName: JsonField) = + apply { + this.givenName = givenName + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired("id", id), - avatarUrl, - created, - email, - familyName, - givenName, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + avatarUrl, + created, + email, + familyName, + givenName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && id == other.id && avatarUrl == other.avatarUrl && created == other.created && email == other.email && familyName == other.familyName && givenName == other.givenName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && id == other.id && avatarUrl == other.avatarUrl && created == other.created && email == other.email && familyName == other.familyName && givenName == other.givenName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -229,6 +263,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "User{id=$id, avatarUrl=$avatarUrl, created=$created, email=$email, familyName=$familyName, givenName=$givenName, additionalProperties=$additionalProperties}" + override fun toString() = "User{id=$id, avatarUrl=$avatarUrl, created=$created, email=$email, familyName=$familyName, givenName=$givenName, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index c02d5269..0c0f286d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.UserService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all users. The users are sorted by creation date, with the most recently-created users - * coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ -class UserListPage -private constructor( +class UserListPage private constructor( private val usersService: UserService, private val params: UserListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListPage && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is UserListPage && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ - override fun toString() = - "UserListPage{usersService=$usersService, params=$params, response=$response}" + override fun toString() = "UserListPage{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - UserListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - UserListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(UserListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(UserListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { usersService.list(it) } + return getNextPageParams().map { usersService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(usersService: UserService, params: UserListParams, response: Response) = - UserListPage(usersService, params, response) + UserListPage( + usersService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [UserListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: UserListPage) : Iterable { + class AutoPager( + private val firstPage: UserListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 82830d2e..baa4ce20 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.UserServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all users. The users are sorted by creation date, with the most recently-created users - * coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ -class UserListPageAsync -private constructor( +class UserListPageAsync private constructor( private val usersService: UserServiceAsync, private val params: UserListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListPageAsync && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is UserListPageAsync && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ - override fun toString() = - "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" + override fun toString() = "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - UserListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - UserListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(UserListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(UserListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { usersService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + usersService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(usersService: UserServiceAsync, params: UserListParams, response: Response) = - UserListPageAsync(usersService, params, response) + UserListPageAsync( + usersService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [UserListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: UserListPageAsync) { + class AutoPager( + private val firstPage: UserListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (User) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (User) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index d259099e..be008466 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -23,11 +23,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all users. The users are sorted by creation date, with the most recently-created users - * coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ -class UserListParams -private constructor( +class UserListParams private constructor( private val email: Email?, private val endingBefore: String?, private val familyName: FamilyName?, @@ -38,38 +37,39 @@ private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ fun email(): Optional = Optional.ofNullable(email) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Family name of the user to search for. You may pass the param multiple times to filter for - * more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ fun familyName(): Optional = Optional.ofNullable(familyName) /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ fun givenName(): Optional = Optional.ofNullable(givenName) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -82,9 +82,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -95,27 +95,61 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.email?.let { queryParams.put("email", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.familyName?.let { queryParams.put("family_name", listOf(it.toString())) } - this.givenName?.let { queryParams.put("given_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.email?.let { + queryParams.put( + "email", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.familyName?.let { + queryParams.put( + "family_name", listOf(it.toString()) + ) + } + this.givenName?.let { + queryParams.put( + "given_name", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.orgName?.let { + queryParams.put( + "org_name", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun none(): UserListParams = builder().build() + @JvmStatic + fun none(): UserListParams = builder().build() /** Returns a mutable builder for constructing an instance of [UserListParams]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [UserListParams]. */ @@ -134,135 +168,154 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(userListParams: UserListParams) = apply { - email = userListParams.email - endingBefore = userListParams.endingBefore - familyName = userListParams.familyName - givenName = userListParams.givenName - ids = userListParams.ids - limit = userListParams.limit - orgName = userListParams.orgName - startingAfter = userListParams.startingAfter - additionalHeaders = userListParams.additionalHeaders.toBuilder() - additionalQueryParams = userListParams.additionalQueryParams.toBuilder() - } + internal fun from(userListParams: UserListParams) = + apply { + email = userListParams.email + endingBefore = userListParams.endingBefore + familyName = userListParams.familyName + givenName = userListParams.givenName + ids = userListParams.ids + limit = userListParams.limit + orgName = userListParams.orgName + startingAfter = userListParams.startingAfter + additionalHeaders = userListParams.additionalHeaders.toBuilder() + additionalQueryParams = userListParams.additionalQueryParams.toBuilder() + } /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ - fun email(email: Email?) = apply { this.email = email } + fun email(email: Email?) = + apply { + this.email = email + } /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ fun email(email: Optional) = email(email.getOrNull()) /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ fun email(string: String) = email(Email.ofString(string)) /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ fun emailOfStrings(strings: List) = email(Email.ofStrings(strings)) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ - fun familyName(familyName: FamilyName?) = apply { this.familyName = familyName } + fun familyName(familyName: FamilyName?) = + apply { + this.familyName = familyName + } /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ fun familyName(string: String) = familyName(FamilyName.ofString(string)) /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ fun familyNameOfStrings(strings: List) = familyName(FamilyName.ofStrings(strings)) /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ - fun givenName(givenName: GivenName?) = apply { this.givenName = givenName } + fun givenName(givenName: GivenName?) = + apply { + this.givenName = givenName + } /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ fun givenName(string: String) = givenName(GivenName.ofString(string)) /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ fun givenNameOfStrings(strings: List) = givenName(GivenName.ofStrings(strings)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -271,7 +324,10 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = apply { this.orgName = orgName } + fun orgName(orgName: String?) = + apply { + this.orgName = orgName + } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -279,146 +335,174 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): UserListParams = UserListParams( - email, - endingBefore, - familyName, - givenName, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + email, + endingBefore, + familyName, + givenName, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email + * Email of the user to search for. You may pass the param multiple times to filter + * for more than one email */ @JsonDeserialize(using = Email.Deserializer::class) @JsonSerialize(using = Email.Serializer::class) - class Email - private constructor( + class Email private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -436,19 +520,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Email && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Email && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -463,12 +547,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Email(string = string) + @JvmStatic + fun ofString(string: String) = Email(string = string) - @JvmStatic fun ofStrings(strings: List) = Email(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Email(strings = strings) } - /** An interface that defines how to map each variant of [Email] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Email] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -478,62 +567,58 @@ private constructor( /** * Maps an unknown variant of [Email] to a value of type [T]. * - * An instance of [Email] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Email] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Email: $json") + throw BraintrustInvalidDataException("Unknown Email: $json") } } internal class Deserializer : BaseDeserializer(Email::class) { override fun ObjectCodec.deserialize(node: JsonNode): Email { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Email(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Email(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Email(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Email(strings = it, _json = json) + } - return Email(_json = json) + return Email(_json = json) } } internal class Serializer : BaseSerializer(Email::class) { - override fun serialize( - value: Email, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Email") - } + override fun serialize(value: Email, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Email") + } } } } /** - * Family name of the user to search for. You may pass the param multiple times to filter for - * more than one family name + * Family name of the user to search for. You may pass the param multiple times to + * filter for more than one family name */ @JsonDeserialize(using = FamilyName.Deserializer::class) @JsonSerialize(using = FamilyName.Serializer::class) - class FamilyName - private constructor( + class FamilyName private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -551,19 +636,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FamilyName && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is FamilyName && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -578,13 +663,16 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = FamilyName(string = string) + @JvmStatic + fun ofString(string: String) = FamilyName(string = string) - @JvmStatic fun ofStrings(strings: List) = FamilyName(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = FamilyName(strings = strings) } /** - * An interface that defines how to map each variant of [FamilyName] to a value of type [T]. + * An interface that defines how to map each variant of [FamilyName] to a value of + * type [T]. */ interface Visitor { @@ -595,62 +683,58 @@ private constructor( /** * Maps an unknown variant of [FamilyName] to a value of type [T]. * - * An instance of [FamilyName] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [FamilyName] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FamilyName: $json") + throw BraintrustInvalidDataException("Unknown FamilyName: $json") } } internal class Deserializer : BaseDeserializer(FamilyName::class) { override fun ObjectCodec.deserialize(node: JsonNode): FamilyName { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FamilyName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return FamilyName(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return FamilyName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return FamilyName(strings = it, _json = json) + } - return FamilyName(_json = json) + return FamilyName(_json = json) } } internal class Serializer : BaseSerializer(FamilyName::class) { - override fun serialize( - value: FamilyName, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FamilyName") - } + override fun serialize(value: FamilyName, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FamilyName") + } } } } /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name + * Given name of the user to search for. You may pass the param multiple times to + * filter for more than one given name */ @JsonDeserialize(using = GivenName.Deserializer::class) @JsonSerialize(using = GivenName.Serializer::class) - class GivenName - private constructor( + class GivenName private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -668,19 +752,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GivenName && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is GivenName && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -695,13 +779,16 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = GivenName(string = string) + @JvmStatic + fun ofString(string: String) = GivenName(string = string) - @JvmStatic fun ofStrings(strings: List) = GivenName(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = GivenName(strings = strings) } /** - * An interface that defines how to map each variant of [GivenName] to a value of type [T]. + * An interface that defines how to map each variant of [GivenName] to a value of + * type [T]. */ interface Visitor { @@ -712,62 +799,58 @@ private constructor( /** * Maps an unknown variant of [GivenName] to a value of type [T]. * - * An instance of [GivenName] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [GivenName] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown GivenName: $json") + throw BraintrustInvalidDataException("Unknown GivenName: $json") } } internal class Deserializer : BaseDeserializer(GivenName::class) { override fun ObjectCodec.deserialize(node: JsonNode): GivenName { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return GivenName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return GivenName(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return GivenName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return GivenName(strings = it, _json = json) + } - return GivenName(_json = json) + return GivenName(_json = json) } } internal class Serializer : BaseSerializer(GivenName::class) { - override fun serialize( - value: GivenName, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid GivenName") - } + override fun serialize(value: GivenName, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid GivenName") + } } } } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -785,19 +868,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -812,12 +895,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -827,60 +915,56 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index b5982ab9..d97040de 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a user object by its id */ -class UserRetrieveParams -private constructor( +class UserRetrieveParams private constructor( private val userId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** User id */ @@ -29,10 +29,10 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> userId - else -> "" - } + return when (index) { + 0 -> userId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,11 +43,13 @@ private constructor( * Returns a mutable builder for constructing an instance of [UserRetrieveParams]. * * The following fields are required: + * * ```java * .userId() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [UserRetrieveParams]. */ @@ -59,131 +61,162 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(userRetrieveParams: UserRetrieveParams) = apply { - userId = userRetrieveParams.userId - additionalHeaders = userRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = userRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(userRetrieveParams: UserRetrieveParams) = + apply { + userId = userRetrieveParams.userId + additionalHeaders = userRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = userRetrieveParams.additionalQueryParams.toBuilder() + } /** User id */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String) = + apply { + this.userId = userId + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): UserRetrieveParams = UserRetrieveParams( - checkRequired("userId", userId), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "userId", userId + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 a8bb266f..07910d51 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 @@ -22,36 +22,19 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class View -@JsonCreator -private constructor( +class View @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") - @ExcludeMissing - private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") - @ExcludeMissing - private val viewData: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Unique identifier for the view */ @@ -73,8 +56,7 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -86,13 +68,19 @@ private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Unique identifier for the view */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("id") + @ExcludeMissing + fun _id(): JsonField = id /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -100,10 +88,14 @@ private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType(): JsonField = viewType /** Date of view creation */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") + @ExcludeMissing + fun _created(): JsonField = created /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -111,13 +103,19 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -125,23 +123,24 @@ private constructor( private var validated: Boolean = false - fun validate(): View = apply { - if (validated) { - return@apply - } + fun validate(): View = + apply { + if (validated) { + return@apply + } - id() - name() - objectId() - objectType() - viewType() - created() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true - } + id() + name() + objectId() + objectType() + viewType() + created() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -151,6 +150,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [View]. * * The following fields are required: + * * ```java * .id() * .name() @@ -159,7 +159,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [View]. */ @@ -178,43 +179,56 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(view: View) = apply { - id = view.id - name = view.name - objectId = view.objectId - objectType = view.objectType - viewType = view.viewType - created = view.created - deletedAt = view.deletedAt - options = view.options - userId = view.userId - viewData = view.viewData - additionalProperties = view.additionalProperties.toMutableMap() - } + internal fun from(view: View) = + apply { + id = view.id + name = view.name + objectId = view.objectId + objectType = view.objectType + viewType = view.viewType + created = view.created + deletedAt = view.deletedAt + options = view.options + userId = view.userId + viewData = view.viewData + additionalProperties = view.additionalProperties.toMutableMap() + } /** Unique identifier for the view */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the view */ - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = + apply { + this.id = id + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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)) @@ -223,7 +237,10 @@ private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = + apply { + this.viewType = viewType + } /** Date of view creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -232,7 +249,10 @@ private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of view creation */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = + apply { + this.created = created + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -241,7 +261,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -250,7 +273,10 @@ private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -259,7 +285,10 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -268,55 +297,79 @@ private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + fun viewData(viewData: JsonField) = + apply { + this.viewData = viewData + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): View = View( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - checkRequired("viewType", viewType), - created, - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired( + "id", id + ), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + checkRequired( + "viewType", viewType + ), + created, + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -364,9 +417,11 @@ private constructor( * 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 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 { @@ -382,17 +437,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -413,11 +469,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -438,23 +494,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -463,17 +516,21 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -512,9 +569,11 @@ private constructor( * 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 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 { @@ -526,16 +585,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * 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. + * 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. + * 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) { @@ -553,11 +615,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -575,23 +637,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -600,11 +659,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is View && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && created == other.created && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is View && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && created == other.created && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -613,6 +672,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "View{id=$id, name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, created=$created, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = "View{id=$id, name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, created=$created, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } 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 0597fc32..0e1d6133 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 @@ -25,14 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new view. If there is an existing view with the same name as the one specified in the - * request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one + * specified in the request, will return the existing view unmodified */ -class ViewCreateParams -private constructor( +class ViewCreateParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the view */ @@ -89,42 +89,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") - @ExcludeMissing - private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") - @ExcludeMissing - private val viewData: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the view */ @@ -140,8 +123,7 @@ private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -153,10 +135,14 @@ private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -164,7 +150,9 @@ private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType(): JsonField = viewType /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -172,13 +160,19 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -186,22 +180,23 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + viewType() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true } - name() - objectId() - objectType() - viewType() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -210,6 +205,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .objectId() @@ -217,7 +213,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -234,37 +231,45 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - viewType = body.viewType - deletedAt = body.deletedAt - options = body.options - userId = body.userId - viewData = body.viewData - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + viewType = body.viewType + deletedAt = body.deletedAt + options = body.options + userId = body.userId + viewData = body.viewData + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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)) @@ -273,7 +278,10 @@ private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = + apply { + this.viewType = viewType + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -282,9 +290,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -293,7 +302,10 @@ private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -302,7 +314,10 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -311,47 +326,65 @@ private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewData(viewData: JsonField) = + apply { + this.viewData = viewData + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - checkRequired("viewType", viewType), - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + checkRequired( + "viewType", viewType + ), + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -360,8 +393,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -372,6 +404,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewCreateParams]. * * The following fields are required: + * * ```java * .name() * .objectId() @@ -379,7 +412,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewCreateParams]. */ @@ -391,208 +425,299 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewCreateParams: ViewCreateParams) = apply { - body = viewCreateParams.body.toBuilder() - additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(viewCreateParams: ViewCreateParams) = + apply { + body = viewCreateParams.body.toBuilder() + additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() + } /** Name of the view */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the view */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + 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: ObjectType) = + 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) } + fun viewType(viewType: ViewType?) = + apply { + body.viewType(viewType) + } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + fun viewType(viewType: JsonField) = + apply { + body.viewType(viewType) + } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } + fun deletedAt(deletedAt: OffsetDateTime?) = + apply { + body.deletedAt(deletedAt) + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } + fun deletedAt(deletedAt: JsonField) = + apply { + body.deletedAt(deletedAt) + } /** Options for the view in the app */ - fun options(options: ViewOptions?) = apply { body.options(options) } + fun options(options: ViewOptions?) = + apply { + body.options(options) + } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { body.options(options) } + fun options(options: JsonField) = + apply { + body.options(options) + } /** Identifies the user who created the view */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } /** The view definition */ - fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + fun viewData(viewData: ViewData?) = + apply { + body.viewData(viewData) + } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + fun viewData(viewData: JsonField) = + apply { + body.viewData(viewData) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewCreateParams = - ViewCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -640,9 +765,11 @@ private constructor( * 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 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 { @@ -658,17 +785,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -689,11 +817,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -714,23 +842,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -739,17 +864,21 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -788,9 +917,11 @@ private constructor( * 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 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 { @@ -802,16 +933,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * 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. + * 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. + * 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) { @@ -829,11 +963,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -851,23 +985,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -876,15 +1007,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 70d0d8ce..02851ff5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -19,18 +19,17 @@ import kotlin.jvm.optionals.getOrNull /** The view definition */ @NoAutoDetect -class ViewData -@JsonCreator -private constructor( - @JsonProperty("search") - @ExcludeMissing - private val search: JsonField = JsonMissing.of(), +class ViewData @JsonCreator private constructor( + @JsonProperty("search") @ExcludeMissing private val search: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun search(): Optional = Optional.ofNullable(search.getNullable("search")) - @JsonProperty("search") @ExcludeMissing fun _search(): JsonField = search + @JsonProperty("search") + @ExcludeMissing + fun _search(): JsonField = search @JsonAnyGetter @ExcludeMissing @@ -38,21 +37,23 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewData = apply { - if (validated) { - return@apply - } + fun validate(): ViewData = + apply { + if (validated) { + return@apply + } - search().ifPresent { it.validate() } - validated = true - } + search().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewData]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewData]. */ @@ -62,45 +63,59 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewData: ViewData) = apply { - search = viewData.search - additionalProperties = viewData.additionalProperties.toMutableMap() - } + internal fun from(viewData: ViewData) = + apply { + search = viewData.search + additionalProperties = viewData.additionalProperties.toMutableMap() + } fun search(search: ViewDataSearch?) = search(JsonField.ofNullable(search)) fun search(search: Optional) = search(search.getOrNull()) - fun search(search: JsonField) = apply { this.search = search } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ViewData = ViewData(search, additionalProperties.toImmutable()) + fun search(search: JsonField) = + apply { + this.search = search + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): ViewData = + ViewData( + search, additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewData && search == other.search && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewData && search == other.search && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 6d12484b..96cfd4d0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -19,22 +19,13 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ViewDataSearch -@JsonCreator -private constructor( - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField> = JsonMissing.of(), - @JsonProperty("match") - @ExcludeMissing - private val match: JsonField> = JsonMissing.of(), - @JsonProperty("sort") - @ExcludeMissing - private val sort: JsonField> = JsonMissing.of(), - @JsonProperty("tag") - @ExcludeMissing - private val tag: JsonField> = JsonMissing.of(), +class ViewDataSearch @JsonCreator private constructor( + @JsonProperty("filter") @ExcludeMissing private val filter: JsonField> = JsonMissing.of(), + @JsonProperty("match") @ExcludeMissing private val match: JsonField> = JsonMissing.of(), + @JsonProperty("sort") @ExcludeMissing private val sort: JsonField> = JsonMissing.of(), + @JsonProperty("tag") @ExcludeMissing private val tag: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun filter(): Optional> = Optional.ofNullable(filter.getNullable("filter")) @@ -45,13 +36,21 @@ private constructor( fun tag(): Optional> = Optional.ofNullable(tag.getNullable("tag")) - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField> = filter + @JsonProperty("filter") + @ExcludeMissing + fun _filter(): JsonField> = filter - @JsonProperty("match") @ExcludeMissing fun _match(): JsonField> = match + @JsonProperty("match") + @ExcludeMissing + fun _match(): JsonField> = match - @JsonProperty("sort") @ExcludeMissing fun _sort(): JsonField> = sort + @JsonProperty("sort") + @ExcludeMissing + fun _sort(): JsonField> = sort - @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField> = tag + @JsonProperty("tag") + @ExcludeMissing + fun _tag(): JsonField> = tag @JsonAnyGetter @ExcludeMissing @@ -59,24 +58,26 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewDataSearch = apply { - if (validated) { - return@apply + fun validate(): ViewDataSearch = + apply { + if (validated) { + return@apply + } + + filter() + match() + sort() + tag() + validated = true } - filter() - match() - sort() - tag() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewDataSearch]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewDataSearch]. */ @@ -89,107 +90,121 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewDataSearch: ViewDataSearch) = apply { - filter = viewDataSearch.filter.map { it.toMutableList() } - match = viewDataSearch.match.map { it.toMutableList() } - sort = viewDataSearch.sort.map { it.toMutableList() } - tag = viewDataSearch.tag.map { it.toMutableList() } - additionalProperties = viewDataSearch.additionalProperties.toMutableMap() - } + internal fun from(viewDataSearch: ViewDataSearch) = + apply { + filter = viewDataSearch.filter.map { it.toMutableList() } + match = viewDataSearch.match.map { it.toMutableList() } + sort = viewDataSearch.sort.map { it.toMutableList() } + tag = viewDataSearch.tag.map { it.toMutableList() } + additionalProperties = viewDataSearch.additionalProperties.toMutableMap() + } fun filter(filter: List?) = filter(JsonField.ofNullable(filter)) fun filter(filter: Optional>) = filter(filter.getOrNull()) - fun filter(filter: JsonField>) = apply { - this.filter = filter.map { it.toMutableList() } - } + fun filter(filter: JsonField>) = + apply { + this.filter = filter.map { it.toMutableList() } + } - fun addFilter(filter: JsonValue) = apply { - this.filter = - (this.filter ?: JsonField.of(mutableListOf())).also { + fun addFilter(filter: JsonValue) = + apply { + this.filter = (this.filter ?: JsonField.of(mutableListOf())).also { checkKnown("filter", it).add(filter) } - } + } fun match(match: List?) = match(JsonField.ofNullable(match)) fun match(match: Optional>) = match(match.getOrNull()) - fun match(match: JsonField>) = apply { - this.match = match.map { it.toMutableList() } - } + fun match(match: JsonField>) = + apply { + this.match = match.map { it.toMutableList() } + } - fun addMatch(match: JsonValue) = apply { - this.match = - (this.match ?: JsonField.of(mutableListOf())).also { + fun addMatch(match: JsonValue) = + apply { + this.match = (this.match ?: JsonField.of(mutableListOf())).also { checkKnown("match", it).add(match) } - } + } fun sort(sort: List?) = sort(JsonField.ofNullable(sort)) fun sort(sort: Optional>) = sort(sort.getOrNull()) - fun sort(sort: JsonField>) = apply { - this.sort = sort.map { it.toMutableList() } - } + fun sort(sort: JsonField>) = + apply { + this.sort = sort.map { it.toMutableList() } + } - fun addSort(sort: JsonValue) = apply { - this.sort = - (this.sort ?: JsonField.of(mutableListOf())).also { + fun addSort(sort: JsonValue) = + apply { + this.sort = (this.sort ?: JsonField.of(mutableListOf())).also { checkKnown("sort", it).add(sort) } - } + } fun tag(tag: List?) = tag(JsonField.ofNullable(tag)) fun tag(tag: Optional>) = tag(tag.getOrNull()) - fun tag(tag: JsonField>) = apply { - this.tag = tag.map { it.toMutableList() } - } + fun tag(tag: JsonField>) = + apply { + this.tag = tag.map { it.toMutableList() } + } - fun addTag(tag: JsonValue) = apply { - this.tag = - (this.tag ?: JsonField.of(mutableListOf())).also { checkKnown("tag", it).add(tag) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: JsonValue) = + apply { + this.tag = (this.tag ?: JsonField.of(mutableListOf())).also { + checkKnown("tag", it).add(tag) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ViewDataSearch = ViewDataSearch( - (filter ?: JsonMissing.of()).map { it.toImmutable() }, - (match ?: JsonMissing.of()).map { it.toImmutable() }, - (sort ?: JsonMissing.of()).map { it.toImmutable() }, - (tag ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (filter ?: JsonMissing.of()).map { it.toImmutable() }, + (match ?: JsonMissing.of()).map { it.toImmutable() }, + (sort ?: JsonMissing.of()).map { it.toImmutable() }, + (tag ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewDataSearch && filter == other.filter && match == other.match && sort == other.sort && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewDataSearch && filter == other.filter && match == other.match && sort == other.sort && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -198,6 +213,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ViewDataSearch{filter=$filter, match=$match, sort=$sort, tag=$tag, additionalProperties=$additionalProperties}" + override fun toString() = "ViewDataSearch{filter=$filter, match=$match, sort=$sort, tag=$tag, additionalProperties=$additionalProperties}" } 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..d6cc9336 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 @@ -22,12 +22,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Delete a view object by its id */ -class ViewDeleteParams -private constructor( +class ViewDeleteParams private constructor( private val viewId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** View id */ @@ -51,31 +51,26 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the view applies to */ @@ -85,7 +80,9 @@ private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -98,15 +95,16 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply - } + fun validate(): Body = + apply { + if (validated) { + return@apply + } - objectId() - objectType() - validated = true - } + objectId() + objectType() + validated = true + } fun toBuilder() = Builder().from(this) @@ -116,12 +114,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -132,59 +132,75 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - objectId = body.objectId - objectType = body.objectType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + objectId = body.objectId + objectType = body.objectType + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun objectType(objectType: JsonField) = + apply { + this.objectType = objectType + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -193,8 +209,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "Body{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -205,13 +220,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewDeleteParams]. * * The following fields are required: + * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewDeleteParams]. */ @@ -224,166 +241,222 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewDeleteParams: ViewDeleteParams) = apply { - viewId = viewDeleteParams.viewId - body = viewDeleteParams.body.toBuilder() - additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(viewDeleteParams: ViewDeleteParams) = + apply { + viewId = viewDeleteParams.viewId + body = viewDeleteParams.body.toBuilder() + additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = apply { this.viewId = viewId } + fun viewId(viewId: String) = + apply { + this.viewId = viewId + } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + 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: ObjectType) = + 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) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewDeleteParams = ViewDeleteParams( - checkRequired("viewId", viewId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "viewId", viewId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -431,9 +504,11 @@ private constructor( * 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 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 { @@ -449,17 +524,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -480,11 +556,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -505,23 +581,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -530,15 +603,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewDeleteParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewDeleteParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index fde4f5ac..5ad0e959 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.blocking.ViewService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,14 +22,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all views. The views are sorted by creation date, with the most recently-created views - * coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ -class ViewListPage -private constructor( +class ViewListPage private constructor( private val viewsService: ViewService, private val params: ViewListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,40 +37,35 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListPage && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ViewListPage && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ - override fun toString() = - "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" + override fun toString() = "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ViewListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ViewListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): Optional { - return getNextPageParams().map { viewsService.list(it) } + return getNextPageParams().map { viewsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -78,16 +74,18 @@ private constructor( @JvmStatic fun of(viewsService: ViewService, params: ViewListParams, response: Response) = - ViewListPage(viewsService, params, response) + ViewListPage( + viewsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -101,34 +99,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ViewListPage]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -137,39 +136,48 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ViewListPage) : Iterable { + class AutoPager( + private val firstPage: ViewListPage, - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + ) : Iterable { + + override fun iterator(): Iterator = + iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) + } + page = page.getNextPage().getOrNull() ?: break + index = 0 } - page = page.getNextPage().getOrNull() ?: break - index = 0 } - } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index 0a5f58fb..6fec64a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -9,6 +9,7 @@ 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.models import com.braintrustdata.api.services.async.ViewServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -19,16 +20,19 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector /** - * List out all views. The views are sorted by creation date, with the most recently-created views - * coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ -class ViewListPageAsync -private constructor( +class ViewListPageAsync private constructor( private val viewsService: ViewServiceAsync, private val params: ViewListParams, private val response: Response, + ) { fun response(): Response = response @@ -36,42 +40,39 @@ private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListPageAsync && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ViewListPageAsync && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ - override fun toString() = - "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" + override fun toString() = "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of( - ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() - ) - } else { - Optional.of( - ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() - ) - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of(ViewListParams.builder().from(params).endingBefore(objects().first().id()).build()); + } else { + Optional.of(ViewListParams.builder().from(params).startingAfter(objects().last().id()).build()); + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { viewsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + return getNextPageParams().map { + viewsService.list(it).thenApply { Optional.of(it) } + }.orElseGet { + CompletableFuture.completedFuture(Optional.empty()) + } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,16 +81,18 @@ private constructor( @JvmStatic fun of(viewsService: ViewServiceAsync, params: ViewListParams, response: Response) = - ViewListPageAsync(viewsService, params, response) + ViewListPageAsync( + viewsService, + params, + response, + ) } @NoAutoDetect - class Response - @JsonCreator - constructor( + class Response @JsonCreator constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -103,34 +106,35 @@ private constructor( private var validated: Boolean = false - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun validate(): Response = + apply { + if (validated) { + return@apply + } - objects().map { it.validate() } - validated = true - } + objects().map { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = - "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ViewListPageAsync]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { @@ -139,46 +143,63 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = + apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + this.additionalProperties.put(key, value) + } - fun build() = Response(objects, additionalProperties.toImmutable()) + fun build() = + Response( + objects, additionalProperties.toImmutable() + ) } } - class AutoPager(private val firstPage: ViewListPageAsync) { + class AutoPager( + private val firstPage: ViewListPageAsync, + + ) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (View) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.objects().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) + fun CompletableFuture>.forEach(action: (View) -> Boolean, executor: Executor): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { + it.objects().all(action) + } + .map { + it.getNextPage().forEach(action, executor) + } + .orElseGet { + CompletableFuture.completedFuture(null) + } + }, executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach( + action::test, executor + ) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } + val values = mutableListOf() + return forEach( + values::add, executor + ) + .thenApply { + values + } } } } 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 3dd24391..dc8f6cda 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 @@ -27,11 +27,10 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all views. The views are sorted by creation date, with the most recently-created views - * coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ -class ViewListParams -private constructor( +class ViewListParams private constructor( private val objectId: String, private val objectType: ObjectType, private val endingBefore: String?, @@ -42,6 +41,7 @@ private constructor( private val viewType: ViewType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** The id of the object the ACL applies to */ @@ -53,15 +53,15 @@ private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -71,9 +71,9 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` - * and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -90,17 +90,49 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.viewName?.let { queryParams.put("view_name", listOf(it.toString())) } - this.viewType?.let { queryParams.put("view_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { + queryParams.put( + "object_id", listOf(it.toString()) + ) + } + this.objectType.let { + queryParams.put( + "object_type", listOf(it.toString()) + ) + } + this.endingBefore?.let { + queryParams.put( + "ending_before", listOf(it.toString()) + ) + } + this.ids?.let { + queryParams.put( + "ids", listOf(it.toString()) + ) + } + this.limit?.let { + queryParams.put( + "limit", listOf(it.toString()) + ) + } + this.startingAfter?.let { + queryParams.put( + "starting_after", listOf(it.toString()) + ) + } + this.viewName?.let { + queryParams.put( + "view_name", listOf(it.toString()) + ) + } + this.viewType?.let { + queryParams.put( + "view_type", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) @@ -111,12 +143,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewListParams]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewListParams]. */ @@ -135,69 +169,85 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewListParams: ViewListParams) = apply { - objectId = viewListParams.objectId - objectType = viewListParams.objectType - endingBefore = viewListParams.endingBefore - ids = viewListParams.ids - limit = viewListParams.limit - startingAfter = viewListParams.startingAfter - viewName = viewListParams.viewName - viewType = viewListParams.viewType - additionalHeaders = viewListParams.additionalHeaders.toBuilder() - additionalQueryParams = viewListParams.additionalQueryParams.toBuilder() - } + internal fun from(viewListParams: ViewListParams) = + apply { + objectId = viewListParams.objectId + objectType = viewListParams.objectType + endingBefore = viewListParams.endingBefore + ids = viewListParams.ids + limit = viewListParams.limit + startingAfter = viewListParams.startingAfter + viewName = viewListParams.viewName + viewType = viewListParams.viewType + additionalHeaders = viewListParams.additionalHeaders.toBuilder() + additionalQueryParams = viewListParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + 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: ObjectType) = + apply { + this.objectType = objectType + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + fun endingBefore(endingBefore: String?) = + apply { + this.endingBefore = endingBefore + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of + * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only + * pass one of `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(ids: Ids?) = apply { this.ids = ids } + fun ids(ids: Ids?) = + apply { + this.ids = ids + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = apply { this.limit = limit } + fun limit(limit: Long?) = + apply { + this.limit = limit + } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -208,159 +258,201 @@ private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + fun startingAfter(startingAfter: String?) = + apply { + this.startingAfter = startingAfter + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, + * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = - startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) /** Name of the view to search for */ - fun viewName(viewName: String?) = apply { this.viewName = viewName } + fun viewName(viewName: String?) = + apply { + this.viewName = viewName + } /** Name of the view to search for */ fun viewName(viewName: Optional) = viewName(viewName.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType?) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType?) = + apply { + this.viewType = viewType + } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewListParams = ViewListParams( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - endingBefore, - ids, - limit, - startingAfter, - viewName, - viewType, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + endingBefore, + ids, + limit, + startingAfter, + viewName, + viewType, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -408,9 +500,11 @@ private constructor( * 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 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 { @@ -426,17 +520,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -457,11 +552,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -482,23 +577,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -507,16 +599,16 @@ private constructor( } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, include - * the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( + class Ids private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, + ) { fun string(): Optional = Optional.ofNullable(string) @@ -534,19 +626,19 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -561,12 +653,17 @@ private constructor( companion object { - @JvmStatic fun ofString(string: String) = Ids(string = string) + @JvmStatic + fun ofString(string: String) = Ids(string = string) - @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic + fun ofStrings(strings: List) = Ids(strings = strings) } - /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [Ids] to a value of type + * [T]. + */ interface Visitor { fun visitString(string: String): T @@ -576,62 +673,63 @@ private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -670,9 +768,11 @@ private constructor( * 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 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 { @@ -684,16 +784,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * 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. + * 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. + * 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) { @@ -711,11 +814,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -733,23 +836,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -758,15 +858,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 731eab40..c4b9cff4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -20,29 +20,19 @@ import kotlin.jvm.optionals.getOrNull /** Options for the view in the app */ @NoAutoDetect -class ViewOptions -@JsonCreator -private constructor( - @JsonProperty("columnOrder") - @ExcludeMissing - private val columnOrder: JsonField> = JsonMissing.of(), - @JsonProperty("columnSizing") - @ExcludeMissing - private val columnSizing: JsonField = JsonMissing.of(), - @JsonProperty("columnVisibility") - @ExcludeMissing - private val columnVisibility: JsonField = JsonMissing.of(), +class ViewOptions @JsonCreator private constructor( + @JsonProperty("columnOrder") @ExcludeMissing private val columnOrder: JsonField> = JsonMissing.of(), + @JsonProperty("columnSizing") @ExcludeMissing private val columnSizing: JsonField = JsonMissing.of(), + @JsonProperty("columnVisibility") @ExcludeMissing private val columnVisibility: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun columnOrder(): Optional> = - Optional.ofNullable(columnOrder.getNullable("columnOrder")) + fun columnOrder(): Optional> = Optional.ofNullable(columnOrder.getNullable("columnOrder")) - fun columnSizing(): Optional = - Optional.ofNullable(columnSizing.getNullable("columnSizing")) + fun columnSizing(): Optional = Optional.ofNullable(columnSizing.getNullable("columnSizing")) - fun columnVisibility(): Optional = - Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) + fun columnVisibility(): Optional = Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) @JsonProperty("columnOrder") @ExcludeMissing @@ -62,23 +52,25 @@ private constructor( private var validated: Boolean = false - fun validate(): ViewOptions = apply { - if (validated) { - return@apply - } + fun validate(): ViewOptions = + apply { + if (validated) { + return@apply + } - columnOrder() - columnSizing().ifPresent { it.validate() } - columnVisibility().ifPresent { it.validate() } - validated = true - } + columnOrder() + columnSizing().ifPresent { it.validate() } + columnVisibility().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewOptions]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewOptions]. */ @@ -90,82 +82,87 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewOptions: ViewOptions) = apply { - columnOrder = viewOptions.columnOrder.map { it.toMutableList() } - columnSizing = viewOptions.columnSizing - columnVisibility = viewOptions.columnVisibility - additionalProperties = viewOptions.additionalProperties.toMutableMap() - } + internal fun from(viewOptions: ViewOptions) = + apply { + columnOrder = viewOptions.columnOrder.map { it.toMutableList() } + columnSizing = viewOptions.columnSizing + columnVisibility = viewOptions.columnVisibility + additionalProperties = viewOptions.additionalProperties.toMutableMap() + } fun columnOrder(columnOrder: List?) = columnOrder(JsonField.ofNullable(columnOrder)) fun columnOrder(columnOrder: Optional>) = columnOrder(columnOrder.getOrNull()) - fun columnOrder(columnOrder: JsonField>) = apply { - this.columnOrder = columnOrder.map { it.toMutableList() } - } + fun columnOrder(columnOrder: JsonField>) = + apply { + this.columnOrder = columnOrder.map { it.toMutableList() } + } - fun addColumnOrder(columnOrder: String) = apply { - this.columnOrder = - (this.columnOrder ?: JsonField.of(mutableListOf())).also { + fun addColumnOrder(columnOrder: String) = + apply { + this.columnOrder = (this.columnOrder ?: JsonField.of(mutableListOf())).also { checkKnown("columnOrder", it).add(columnOrder) } - } + } - fun columnSizing(columnSizing: ColumnSizing?) = - columnSizing(JsonField.ofNullable(columnSizing)) + fun columnSizing(columnSizing: ColumnSizing?) = columnSizing(JsonField.ofNullable(columnSizing)) - fun columnSizing(columnSizing: Optional) = - columnSizing(columnSizing.getOrNull()) + fun columnSizing(columnSizing: Optional) = columnSizing(columnSizing.getOrNull()) - fun columnSizing(columnSizing: JsonField) = apply { - this.columnSizing = columnSizing - } + fun columnSizing(columnSizing: JsonField) = + apply { + this.columnSizing = columnSizing + } - fun columnVisibility(columnVisibility: ColumnVisibility?) = - columnVisibility(JsonField.ofNullable(columnVisibility)) + fun columnVisibility(columnVisibility: ColumnVisibility?) = columnVisibility(JsonField.ofNullable(columnVisibility)) - fun columnVisibility(columnVisibility: Optional) = - columnVisibility(columnVisibility.getOrNull()) + fun columnVisibility(columnVisibility: Optional) = columnVisibility(columnVisibility.getOrNull()) - fun columnVisibility(columnVisibility: JsonField) = apply { - this.columnVisibility = columnVisibility - } + fun columnVisibility(columnVisibility: JsonField) = + apply { + this.columnVisibility = columnVisibility + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ViewOptions = ViewOptions( - (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, - columnSizing, - columnVisibility, - additionalProperties.toImmutable(), + (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, + columnSizing, + columnVisibility, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ColumnSizing - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class ColumnSizing @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -174,20 +171,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ColumnSizing = apply { - if (validated) { - return@apply - } + fun validate(): ColumnSizing = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ColumnSizing]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ColumnSizing]. */ @@ -196,38 +195,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(columnSizing: ColumnSizing) = apply { - additionalProperties = columnSizing.additionalProperties.toMutableMap() - } + internal fun from(columnSizing: ColumnSizing) = + apply { + additionalProperties = columnSizing.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ColumnSizing = ColumnSizing(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ColumnSizing && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ColumnSizing && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -240,11 +247,9 @@ private constructor( } @NoAutoDetect - class ColumnVisibility - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + class ColumnVisibility @JsonCreator private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { @JsonAnyGetter @@ -253,20 +258,22 @@ private constructor( private var validated: Boolean = false - fun validate(): ColumnVisibility = apply { - if (validated) { - return@apply - } + fun validate(): ColumnVisibility = + apply { + if (validated) { + return@apply + } - validated = true - } + validated = true + } fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ColumnVisibility]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ColumnVisibility]. */ @@ -275,38 +282,46 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(columnVisibility: ColumnVisibility) = apply { - additionalProperties = columnVisibility.additionalProperties.toMutableMap() - } + internal fun from(columnVisibility: ColumnVisibility) = + apply { + additionalProperties = columnVisibility.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ColumnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ColumnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -319,11 +334,11 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -332,6 +347,5 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" + override fun toString() = "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" } 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 d99f4f94..a6b1c015 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 @@ -25,14 +25,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace view. If there is an existing view with the same name as the one specified in - * the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the + * one specified in the request, will replace the existing view with the provided + * fields */ -class ViewReplaceParams -private constructor( +class ViewReplaceParams private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** Name of the view */ @@ -89,42 +90,25 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") - @ExcludeMissing - private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") - @ExcludeMissing - private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") - @ExcludeMissing - private val viewData: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** Name of the view */ @@ -140,8 +124,7 @@ private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = - Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -153,10 +136,14 @@ private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -164,7 +151,9 @@ private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType(): JsonField = viewType /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -172,13 +161,19 @@ private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -186,22 +181,23 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + name() + objectId() + objectType() + viewType() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true } - name() - objectId() - objectType() - viewType() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -210,6 +206,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .name() * .objectId() @@ -217,7 +214,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -234,37 +232,45 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - viewType = body.viewType - deletedAt = body.deletedAt - options = body.options - userId = body.userId - viewData = body.viewData - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + viewType = body.viewType + deletedAt = body.deletedAt + options = body.options + userId = body.userId + viewData = body.viewData + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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)) @@ -273,7 +279,10 @@ private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = + apply { + this.viewType = viewType + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -282,9 +291,10 @@ private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = + apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -293,7 +303,10 @@ private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -302,7 +315,10 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -311,47 +327,65 @@ private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewData(viewData: JsonField) = + apply { + this.viewData = viewData + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("name", name), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - checkRequired("viewType", viewType), - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired( + "name", name + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + checkRequired( + "viewType", viewType + ), + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -360,8 +394,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -372,6 +405,7 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewReplaceParams]. * * The following fields are required: + * * ```java * .name() * .objectId() @@ -379,7 +413,8 @@ private constructor( * .viewType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewReplaceParams]. */ @@ -391,212 +426,299 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewReplaceParams: ViewReplaceParams) = apply { - body = viewReplaceParams.body.toBuilder() - additionalHeaders = viewReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = viewReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(viewReplaceParams: ViewReplaceParams) = + apply { + body = viewReplaceParams.body.toBuilder() + additionalHeaders = viewReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = viewReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the view */ - fun name(name: String) = apply { body.name(name) } + fun name(name: String) = + apply { + body.name(name) + } /** Name of the view */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + 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: ObjectType) = + 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) } + fun viewType(viewType: ViewType?) = + apply { + body.viewType(viewType) + } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + fun viewType(viewType: JsonField) = + apply { + body.viewType(viewType) + } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } + fun deletedAt(deletedAt: OffsetDateTime?) = + apply { + body.deletedAt(deletedAt) + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } + fun deletedAt(deletedAt: JsonField) = + apply { + body.deletedAt(deletedAt) + } /** Options for the view in the app */ - fun options(options: ViewOptions?) = apply { body.options(options) } + fun options(options: ViewOptions?) = + apply { + body.options(options) + } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { body.options(options) } + fun options(options: JsonField) = + apply { + body.options(options) + } /** Identifies the user who created the view */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } /** The view definition */ - fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + fun viewData(viewData: ViewData?) = + apply { + body.viewData(viewData) + } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + fun viewData(viewData: JsonField) = + apply { + body.viewData(viewData) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewReplaceParams = ViewReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -644,9 +766,11 @@ private constructor( * 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 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 { @@ -662,17 +786,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -693,11 +818,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -718,23 +843,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -743,17 +865,21 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -792,9 +918,11 @@ private constructor( * 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 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 { @@ -806,16 +934,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * 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. + * 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. + * 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) { @@ -833,11 +964,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -855,23 +986,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -880,15 +1008,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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..4b814372 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects /** Get a view object by its id */ -class ViewRetrieveParams -private constructor( +class ViewRetrieveParams private constructor( private val viewId: String, private val objectId: String, private val objectType: ObjectType, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** View id */ @@ -39,18 +39,26 @@ private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { + queryParams.put( + "object_id", listOf(it.toString()) + ) + } + this.objectType.let { + queryParams.put( + "object_type", listOf(it.toString()) + ) + } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -61,13 +69,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewRetrieveParams]. * * The following fields are required: + * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewRetrieveParams]. */ @@ -81,143 +91,189 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewRetrieveParams: ViewRetrieveParams) = apply { - viewId = viewRetrieveParams.viewId - objectId = viewRetrieveParams.objectId - objectType = viewRetrieveParams.objectType - additionalHeaders = viewRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = viewRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(viewRetrieveParams: ViewRetrieveParams) = + apply { + viewId = viewRetrieveParams.viewId + objectId = viewRetrieveParams.objectId + objectType = viewRetrieveParams.objectType + additionalHeaders = viewRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = viewRetrieveParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = apply { this.viewId = viewId } + fun viewId(viewId: String) = + apply { + this.viewId = viewId + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = apply { this.objectId = objectId } + 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: ObjectType) = + apply { + this.objectType = objectType + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewRetrieveParams = ViewRetrieveParams( - checkRequired("viewId", viewId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "viewId", viewId + ), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -265,9 +321,11 @@ private constructor( * 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 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 { @@ -283,17 +341,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -314,11 +373,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -339,23 +398,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -364,15 +420,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 368c4698..de7d0da8 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 @@ -24,16 +24,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields or - * setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ -class ViewUpdateParams -private constructor( +class ViewUpdateParams private constructor( private val viewId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, + ) : Params { /** View id */ @@ -87,46 +87,31 @@ private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic + internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") - @ExcludeMissing - private val viewData: JsonField = JsonMissing.of(), - @JsonProperty("view_type") - @ExcludeMissing - private val viewType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + class Body @JsonCreator private constructor( + @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), + @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The id of the object the view applies to */ @@ -151,7 +136,9 @@ private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -159,19 +146,29 @@ private constructor( fun _objectType(): JsonField = objectType /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData(): JsonField = viewData /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType(): JsonField = viewType @JsonAnyGetter @ExcludeMissing @@ -179,21 +176,22 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { - if (validated) { - return@apply + fun validate(): Body = + apply { + if (validated) { + return@apply + } + + objectId() + objectType() + name() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + viewType() + validated = true } - objectId() - objectType() - name() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - viewType() - validated = true - } - fun toBuilder() = Builder().from(this) companion object { @@ -202,12 +200,14 @@ private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: + * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [Body]. */ @@ -223,30 +223,35 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - objectId = body.objectId - objectType = body.objectType - name = body.name - options = body.options - userId = body.userId - viewData = body.viewData - viewType = body.viewType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = + apply { + objectId = body.objectId + objectType = body.objectType + name = body.name + options = body.options + userId = body.userId + viewData = body.viewData + viewType = body.viewType + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = + apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** Name of the view */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -255,7 +260,10 @@ private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the view */ - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = + apply { + this.name = name + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -264,7 +272,10 @@ private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = + apply { + this.options = options + } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -273,7 +284,10 @@ private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = + apply { + this.userId = userId + } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -282,7 +296,10 @@ private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + fun viewData(viewData: JsonField) = + apply { + this.viewData = viewData + } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) @@ -291,46 +308,60 @@ private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewType(viewType: JsonField) = + apply { + this.viewType = viewType + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = + apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = + apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - name, - options, - userId, - viewData, - viewType, - additionalProperties.toImmutable(), + checkRequired( + "objectId", objectId + ), + checkRequired( + "objectType", objectType + ), + name, + options, + userId, + viewData, + viewType, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -339,8 +370,7 @@ private constructor( override fun hashCode(): Int = hashCode - override fun toString() = - "Body{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" + override fun toString() = "Body{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -351,13 +381,15 @@ private constructor( * Returns a mutable builder for constructing an instance of [ViewUpdateParams]. * * The following fields are required: + * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } /** A builder for [ViewUpdateParams]. */ @@ -370,211 +402,297 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewUpdateParams: ViewUpdateParams) = apply { - viewId = viewUpdateParams.viewId - body = viewUpdateParams.body.toBuilder() - additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(viewUpdateParams: ViewUpdateParams) = + apply { + viewId = viewUpdateParams.viewId + body = viewUpdateParams.body.toBuilder() + additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = apply { this.viewId = viewId } + fun viewId(viewId: String) = + apply { + this.viewId = viewId + } /** The id of the object the view applies to */ - fun objectId(objectId: String) = apply { body.objectId(objectId) } + fun objectId(objectId: String) = + apply { + body.objectId(objectId) + } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } + 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: ObjectType) = + 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) } + fun name(name: String?) = + apply { + body.name(name) + } /** Name of the view */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the view */ - fun name(name: JsonField) = apply { body.name(name) } + fun name(name: JsonField) = + apply { + body.name(name) + } /** Options for the view in the app */ - fun options(options: ViewOptions?) = apply { body.options(options) } + fun options(options: ViewOptions?) = + apply { + body.options(options) + } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = apply { body.options(options) } + fun options(options: JsonField) = + apply { + body.options(options) + } /** Identifies the user who created the view */ - fun userId(userId: String?) = apply { body.userId(userId) } + fun userId(userId: String?) = + apply { + body.userId(userId) + } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = apply { body.userId(userId) } + fun userId(userId: JsonField) = + apply { + body.userId(userId) + } /** The view definition */ - fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } + fun viewData(viewData: ViewData?) = + apply { + body.viewData(viewData) + } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } + fun viewData(viewData: JsonField) = + apply { + body.viewData(viewData) + } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } + fun viewType(viewType: ViewType?) = + apply { + body.viewType(viewType) + } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } + fun viewType(viewType: JsonField) = + apply { + body.viewType(viewType) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = + apply { + body.putAdditionalProperty( + key, value + ) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun removeAdditionalBodyProperty(key: String) = + apply { + body.removeAdditionalProperty(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = + apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = + apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = + apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = + apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + fun removeAdditionalHeaders(name: String) = + apply { + additionalHeaders.remove(name) + } - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = + apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = + apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = + apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = + apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + fun removeAdditionalQueryParams(key: String) = + apply { + additionalQueryParams.remove(key) + } - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = + apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewUpdateParams = ViewUpdateParams( - checkRequired("viewId", viewId), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired( + "viewId", viewId + ), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -622,9 +740,11 @@ private constructor( * 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 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 { @@ -640,17 +760,18 @@ private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown value. + * 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. + * 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. + * 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) { @@ -671,11 +792,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -696,23 +817,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -721,17 +839,21 @@ private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor(private val value: JsonField) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value companion object { @@ -770,9 +892,11 @@ private constructor( * 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 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 { @@ -784,16 +908,19 @@ private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ + /** + * 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. + * 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. + * 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) { @@ -811,11 +938,11 @@ private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a + * known member. */ fun known(): Known = when (this) { @@ -833,23 +960,20 @@ private constructor( /** * 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. + * 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. + * @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") - } + fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -858,15 +982,14 @@ private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = - "ViewUpdateParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = "ViewUpdateParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 5138c220..0c4146d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -19,89 +19,85 @@ import java.util.concurrent.CompletableFuture interface AclServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one + * specified in the request, will return the existing acl unmodified */ fun create(params: AclCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: AclCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an acl object by its id */ fun retrieve(params: AclRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ fun list(params: AclListParams): CompletableFuture = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Delete an acl object by its id */ fun delete(params: AclDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. + * Batch update acls. This operation is idempotent, so adding acls which already + * exist will have no effect, and removing acls which do not exist will have no + * effect. */ - fun batchUpdate(): CompletableFuture = - batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): CompletableFuture = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): CompletableFuture = batchUpdate(params, RequestOptions.none()) + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): CompletableFuture = + batchUpdate( + params, RequestOptions.none() + ) /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ - fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [AclServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [AclServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -110,29 +106,27 @@ interface AclServiceAsync { */ @MustBeClosed fun create(params: AclCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: AclCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as - * [AclServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the + * same as [AclServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: AclRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as @@ -140,58 +134,49 @@ interface AclServiceAsync { */ @MustBeClosed fun list(params: AclListParams): CompletableFuture> = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as - * [AclServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the + * same as [AclServiceAsync.delete]. */ @MustBeClosed fun delete(params: AclDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclServiceAsync.batchUpdate]. + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise + * the same as [AclServiceAsync.batchUpdate]. */ @MustBeClosed - fun batchUpdate(): CompletableFuture> = - batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): CompletableFuture> = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): CompletableFuture> = - batchUpdate(params, RequestOptions.none()) + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): CompletableFuture> = + batchUpdate( + params, RequestOptions.none() + ) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - requestOptions: RequestOptions - ): CompletableFuture> = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): CompletableFuture> = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as @@ -199,13 +184,12 @@ interface AclServiceAsync { */ @MustBeClosed fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture> = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index e99ec877..841e0d36 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -21,248 +21,201 @@ import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams +import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams import java.util.concurrent.CompletableFuture -class AclServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - AclServiceAsync { +class AclServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: AclServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : AclServiceAsync { + + private val withRawResponse: AclServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): AclServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: AclCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: AclCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/acl withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/acl/{acl_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list( - params: AclListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: AclListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/acl withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/acl/batch-update withRawResponse().batchUpdate(params, requestOptions).thenApply { it.parse() } - override fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/acl withRawResponse().findAndDelete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AclServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : AclServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: AclCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: AclCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: AclListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - AclListPageAsync.of(AclServiceAsyncImpl(clientOptions), params, it) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: AclListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AclListPageAsync.of(AclServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val batchUpdateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch-update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + batchUpdateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + findAndDeleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt index dc90a38c..9e8a0053 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt @@ -19,225 +19,204 @@ import java.util.concurrent.CompletableFuture interface AiSecretServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as + * the one specified in the request, will return the existing ai_secret unmodified */ fun create(params: AiSecretCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an ai_secret object by its id */ fun retrieve(params: AiSecretRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update an ai_secret object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: AiSecretUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ fun list(): CompletableFuture = list(AiSecretListParams.none()) /** @see [list] */ - fun list( - params: AiSecretListParams = AiSecretListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: AiSecretListParams = AiSecretListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: AiSecretListParams = AiSecretListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(AiSecretListParams.none(), requestOptions) /** Delete an ai_secret object by its id */ fun delete(params: AiSecretDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Delete a single ai_secret */ fun findAndDelete(params: AiSecretFindAndDeleteParams): CompletableFuture = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ - fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will replace the existing ai_secret with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same + * name as the one specified in the request, will replace the existing ai_secret + * with the provided fields */ fun replace(params: AiSecretReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [AiSecretServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [AiSecretServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same + * as [AiSecretServiceAsync.create]. */ @MustBeClosed fun create(params: AiSecretCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the - * same as [AiSecretServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: AiSecretRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise - * the same as [AiSecretServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretServiceAsync.update]. */ @MustBeClosed fun update(params: AiSecretUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same + * as [AiSecretServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(AiSecretListParams.none()) + fun list(): CompletableFuture> = list(AiSecretListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: AiSecretListParams = AiSecretListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: AiSecretListParams = AiSecretListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: AiSecretListParams = AiSecretListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(AiSecretListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise - * the same as [AiSecretServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretServiceAsync.delete]. */ @MustBeClosed fun delete(params: AiSecretDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.findAndDelete]. + * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the + * same as [AiSecretServiceAsync.findAndDelete]. */ @MustBeClosed - fun findAndDelete( - params: AiSecretFindAndDeleteParams - ): CompletableFuture> = - findAndDelete(params, RequestOptions.none()) + fun findAndDelete(params: AiSecretFindAndDeleteParams): CompletableFuture> = + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as - * [AiSecretServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same + * as [AiSecretServiceAsync.replace]. */ @MustBeClosed fun replace(params: AiSecretReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index fbe03e82..92f11347 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams +import com.braintrustdata.api.models.AiSecretListPage import com.braintrustdata.api.models.AiSecretListPageAsync import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams @@ -26,283 +27,224 @@ import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams import java.util.concurrent.CompletableFuture -class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - AiSecretServiceAsync { +class AiSecretServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: AiSecretServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : AiSecretServiceAsync { + + private val withRawResponse: AiSecretServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): AiSecretServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/ai_secret withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/ai_secret/{ai_secret_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/ai_secret/{ai_secret_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: AiSecretListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: AiSecretListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/ai_secret withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/ai_secret/{ai_secret_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/ai_secret withRawResponse().findAndDelete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/ai_secret withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AiSecretServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : AiSecretServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: AiSecretListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - AiSecretListPageAsync.of( - AiSecretServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: AiSecretListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AiSecretListPageAsync.of(AiSecretServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + findAndDeleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index 94e69910..efa0446f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -17,32 +17,31 @@ import java.util.concurrent.CompletableFuture interface ApiKeyServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same + * name. There is no de-duplication */ fun create(params: ApiKeyCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an api_key object by its id */ fun retrieve(params: ApiKeyRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all api_keys. The api_keys are sorted by creation date, with the most @@ -51,32 +50,29 @@ interface ApiKeyServiceAsync { fun list(): CompletableFuture = list(ApiKeyListParams.none()) /** @see [list] */ - fun list( - params: ApiKeyListParams = ApiKeyListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ApiKeyListParams = ApiKeyListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ApiKeyListParams = ApiKeyListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ApiKeyListParams.none(), requestOptions) /** Delete an api_key object by its id */ fun delete(params: ApiKeyDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -85,75 +81,63 @@ interface ApiKeyServiceAsync { * [ApiKeyServiceAsync.create]. */ @MustBeClosed - fun create( - params: ApiKeyCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) + fun create(params: ApiKeyCreateParams): CompletableFuture> = + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same - * as [ApiKeyServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise + * the same as [ApiKeyServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ApiKeyRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as * [ApiKeyServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ApiKeyListParams.none()) + fun list(): CompletableFuture> = list(ApiKeyListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ApiKeyListParams = ApiKeyListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ApiKeyListParams = ApiKeyListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ApiKeyListParams = ApiKeyListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ApiKeyListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the - * same as [ApiKeyServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is + * otherwise the same as [ApiKeyServiceAsync.delete]. */ @MustBeClosed fun delete(params: ApiKeyDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index ca00a3e4..8bc1a341 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -18,178 +18,144 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams +import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput import java.util.concurrent.CompletableFuture -class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ApiKeyServiceAsync { +class ApiKeyServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ApiKeyServiceAsync { + + private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ApiKeyServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/api_key withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/api_key/{api_key_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/api_key withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/api_key/{api_key_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ApiKeyServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ApiKeyServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ApiKeyListPageAsync.of( - ApiKeyServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ApiKeyListPageAsync.of(ApiKeyServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index a6d7c52c..9e33a36b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -26,46 +26,45 @@ import java.util.concurrent.CompletableFuture interface DatasetServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified + * Create a new dataset. If there is an existing dataset in the project with the + * same name as the one specified in the request, will return the existing dataset + * unmodified */ fun create(params: DatasetCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a dataset object by its id */ fun retrieve(params: DatasetRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a dataset object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: DatasetUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all datasets. The datasets are sorted by creation date, with the most @@ -74,90 +73,82 @@ interface DatasetServiceAsync { fun list(): CompletableFuture = list(DatasetListParams.none()) /** @see [list] */ - fun list( - params: DatasetListParams = DatasetListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: DatasetListParams = DatasetListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: DatasetListParams = DatasetListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(DatasetListParams.none(), requestOptions) /** Delete a dataset object by its id */ fun delete(params: DatasetDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Log feedback for a set of dataset events */ fun feedback(params: DatasetFeedbackParams): CompletableFuture = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but + * with the parameters in the URL query rather than in the request body. For more + * complex queries, use the `POST /btql` endpoint. */ fun fetch(params: DatasetFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but + * with the parameters in the request body rather than in the URL query. For more + * complex queries, use the `POST /btql` endpoint. */ fun fetchPost(params: DatasetFetchPostParams): CompletableFuture = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Insert a set of events into the dataset */ fun insert(params: DatasetInsertParams): CompletableFuture = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Summarize dataset */ fun summarize(params: DatasetSummarizeParams): CompletableFuture = - summarize(params, RequestOptions.none()) + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -167,172 +158,146 @@ interface DatasetServiceAsync { */ @MustBeClosed fun create(params: DatasetCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same - * as [DatasetServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise + * the same as [DatasetServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: DatasetRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the - * same as [DatasetServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is + * otherwise the same as [DatasetServiceAsync.update]. */ @MustBeClosed fun update(params: DatasetUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as * [DatasetServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(DatasetListParams.none()) + fun list(): CompletableFuture> = list(DatasetListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: DatasetListParams = DatasetListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: DatasetListParams = DatasetListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: DatasetListParams = DatasetListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(DatasetListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the - * same as [DatasetServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is + * otherwise the same as [DatasetServiceAsync.delete]. */ @MustBeClosed fun delete(params: DatasetDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is * otherwise the same as [DatasetServiceAsync.feedback]. */ @MustBeClosed - fun feedback( - params: DatasetFeedbackParams - ): CompletableFuture> = - feedback(params, RequestOptions.none()) + fun feedback(params: DatasetFeedbackParams): CompletableFuture> = + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise - * the same as [DatasetServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is + * otherwise the same as [DatasetServiceAsync.fetch]. */ @MustBeClosed - fun fetch( - params: DatasetFetchParams - ): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(params: DatasetFetchParams): CompletableFuture> = + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise - * the same as [DatasetServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is + * otherwise the same as [DatasetServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: DatasetFetchPostParams - ): CompletableFuture> = - fetchPost(params, RequestOptions.none()) + fun fetchPost(params: DatasetFetchPostParams): CompletableFuture> = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise - * the same as [DatasetServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is + * otherwise the same as [DatasetServiceAsync.insert]. */ @MustBeClosed - fun insert( - params: DatasetInsertParams - ): CompletableFuture> = - insert(params, RequestOptions.none()) + fun insert(params: DatasetInsertParams): CompletableFuture> = + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is * otherwise the same as [DatasetServiceAsync.summarize]. */ @MustBeClosed - fun summarize( - params: DatasetSummarizeParams - ): CompletableFuture> = - summarize(params, RequestOptions.none()) + fun summarize(params: DatasetSummarizeParams): CompletableFuture> = + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ @MustBeClosed - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index 7a5002f9..3b020629 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams +import com.braintrustdata.api.models.DatasetListPage import com.braintrustdata.api.models.DatasetListPageAsync import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams @@ -33,397 +34,309 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse import java.util.concurrent.CompletableFuture -class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - DatasetServiceAsync { +class DatasetServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : DatasetServiceAsync { + + private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): DatasetServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/dataset withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/dataset/{dataset_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/dataset/{dataset_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: DatasetListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: DatasetListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/dataset withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/dataset/{dataset_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/dataset/{dataset_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/dataset/{dataset_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/dataset/{dataset_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/dataset/{dataset_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/dataset/{dataset_id}/summarize withRawResponse().summarize(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DatasetServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : DatasetServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: DatasetListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - DatasetListPageAsync.of( - DatasetServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: DatasetListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DatasetListPageAsync.of(DatasetServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + summarizeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt index 49a3693f..628a4047 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt @@ -18,46 +18,44 @@ import java.util.concurrent.CompletableFuture interface EnvVarServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new env_var. If there is an existing env_var with the same name as the one specified - * in the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the + * one specified in the request, will return the existing env_var unmodified */ fun create(params: EnvVarCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an env_var object by its id */ fun retrieve(params: EnvVarRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update an env_var object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: EnvVarUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all env_vars. The env_vars are sorted by creation date, with the most @@ -66,45 +64,42 @@ interface EnvVarServiceAsync { fun list(): CompletableFuture = list(EnvVarListParams.none()) /** @see [list] */ - fun list( - params: EnvVarListParams = EnvVarListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: EnvVarListParams = EnvVarListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: EnvVarListParams = EnvVarListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(EnvVarListParams.none(), requestOptions) /** Delete an env_var object by its id */ fun delete(params: EnvVarDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace env_var. If there is an existing env_var with the same name as the one - * specified in the request, will replace the existing env_var with the provided fields + * Create or replace env_var. If there is an existing env_var with the same name as + * the one specified in the request, will replace the existing env_var with the + * provided fields */ fun replace(params: EnvVarReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [EnvVarServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [EnvVarServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -114,88 +109,77 @@ interface EnvVarServiceAsync { */ @MustBeClosed fun create(params: EnvVarCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same - * as [EnvVarServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise + * the same as [EnvVarServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: EnvVarRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the - * same as [EnvVarServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is + * otherwise the same as [EnvVarServiceAsync.update]. */ @MustBeClosed fun update(params: EnvVarUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as * [EnvVarServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(EnvVarListParams.none()) + fun list(): CompletableFuture> = list(EnvVarListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: EnvVarListParams = EnvVarListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: EnvVarListParams = EnvVarListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: EnvVarListParams = EnvVarListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(EnvVarListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the - * same as [EnvVarServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is + * otherwise the same as [EnvVarServiceAsync.delete]. */ @MustBeClosed fun delete(params: EnvVarDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as @@ -203,13 +187,12 @@ interface EnvVarServiceAsync { */ @MustBeClosed fun replace(params: EnvVarReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index c4ed7f35..e2f36b30 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -25,238 +25,192 @@ import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams import java.util.concurrent.CompletableFuture -class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - EnvVarServiceAsync { +class EnvVarServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: EnvVarServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : EnvVarServiceAsync { + + private val withRawResponse: EnvVarServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): EnvVarServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/env_var withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/env_var/{env_var_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/env_var/{env_var_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: EnvVarListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: EnvVarListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/env_var withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/env_var/{env_var_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/env_var withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - EnvVarServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : EnvVarServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list( - params: EnvVarListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: EnvVarListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt index 69b6f45c..8d84a6a7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt @@ -12,27 +12,31 @@ import java.util.concurrent.CompletableFuture interface EvalServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into - * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and - * scoring functions. The API will then run the evaluation, create an experiment, and return the - * results along with a link to the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is + * built into the Braintrust SDK. In the Eval API, you provide pointers to a + * dataset, task function, and scoring functions. The API will then run the + * evaluation, create an experiment, and return the results along with a link to + * the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ fun create(params: EvalCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [EvalServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [EvalServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -40,16 +44,13 @@ interface EvalServiceAsync { * [EvalServiceAsync.create]. */ @MustBeClosed - fun create( - params: EvalCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) + fun create(params: EvalCreateParams): CompletableFuture> = + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index d0fc0019..8a578fb7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -19,56 +19,49 @@ import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture -class EvalServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - EvalServiceAsync { +class EvalServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: EvalServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : EvalServiceAsync { + + private val withRawResponse: EvalServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): EvalServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: EvalCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: EvalCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/eval withRawResponse().create(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - EvalServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : EvalServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun create( - params: EvalCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "eval") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + override fun create(params: EvalCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "eval") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index e10046e6..b49f1978 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -26,317 +26,278 @@ import java.util.concurrent.CompletableFuture interface ExperimentServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new experiment. If there is an existing experiment in the project with the same name - * as the one specified in the request, will return the existing experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with + * the same name as the one specified in the request, will return the existing + * experiment unmodified */ fun create(params: ExperimentCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get an experiment object by its id */ fun retrieve(params: ExperimentRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: ExperimentUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ fun list(): CompletableFuture = list(ExperimentListParams.none()) /** @see [list] */ - fun list( - params: ExperimentListParams = ExperimentListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ExperimentListParams = ExperimentListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ExperimentListParams = ExperimentListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ExperimentListParams.none(), requestOptions) /** Delete an experiment object by its id */ fun delete(params: ExperimentDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Log feedback for a set of experiment events */ fun feedback(params: ExperimentFeedbackParams): CompletableFuture = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, + * but with the parameters in the URL query rather than in the request body. For + * more complex queries, use the `POST /btql` endpoint. */ fun fetch(params: ExperimentFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ - fun fetchPost( - params: ExperimentFetchPostParams - ): CompletableFuture = fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ExperimentFetchPostParams): CompletableFuture = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Insert a set of events into the experiment */ fun insert(params: ExperimentInsertParams): CompletableFuture = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Summarize experiment */ - fun summarize( - params: ExperimentSummarizeParams - ): CompletableFuture = summarize(params, RequestOptions.none()) + fun summarize(params: ExperimentSummarizeParams): CompletableFuture = + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ExperimentServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [ExperimentServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as - * [ExperimentServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same + * as [ExperimentServiceAsync.create]. */ @MustBeClosed fun create(params: ExperimentCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: ExperimentRetrieveParams - ): CompletableFuture> = retrieve(params, RequestOptions.none()) + fun retrieve(params: ExperimentRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentServiceAsync.update]. */ @MustBeClosed fun update(params: ExperimentUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as - * [ExperimentServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same + * as [ExperimentServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ExperimentListParams.none()) + fun list(): CompletableFuture> = list(ExperimentListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ExperimentListParams = ExperimentListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ExperimentListParams = ExperimentListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ExperimentListParams = ExperimentListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ExperimentListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentServiceAsync.delete]. */ @MustBeClosed fun delete(params: ExperimentDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is - * otherwise the same as [ExperimentServiceAsync.feedback]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, + * but is otherwise the same as [ExperimentServiceAsync.feedback]. */ @MustBeClosed - fun feedback( - params: ExperimentFeedbackParams - ): CompletableFuture> = - feedback(params, RequestOptions.none()) + fun feedback(params: ExperimentFeedbackParams): CompletableFuture> = + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is - * otherwise the same as [ExperimentServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but + * is otherwise the same as [ExperimentServiceAsync.fetch]. */ @MustBeClosed - fun fetch( - params: ExperimentFetchParams - ): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(params: ExperimentFetchParams): CompletableFuture> = + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is - * otherwise the same as [ExperimentServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but + * is otherwise the same as [ExperimentServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: ExperimentFetchPostParams - ): CompletableFuture> = - fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ExperimentFetchPostParams): CompletableFuture> = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is - * otherwise the same as [ExperimentServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, + * but is otherwise the same as [ExperimentServiceAsync.insert]. */ @MustBeClosed - fun insert( - params: ExperimentInsertParams - ): CompletableFuture> = - insert(params, RequestOptions.none()) + fun insert(params: ExperimentInsertParams): CompletableFuture> = + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is - * otherwise the same as [ExperimentServiceAsync.summarize]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, + * but is otherwise the same as [ExperimentServiceAsync.summarize]. */ @MustBeClosed - fun summarize( - params: ExperimentSummarizeParams - ): CompletableFuture> = - summarize(params, RequestOptions.none()) + fun summarize(params: ExperimentSummarizeParams): CompletableFuture> = + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ @MustBeClosed - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 432baacd..0c92d8b0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -22,6 +22,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -33,397 +34,309 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture -class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ExperimentServiceAsync { +class ExperimentServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ExperimentServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ExperimentServiceAsync { + + private val withRawResponse: ExperimentServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ExperimentServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/experiment withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/experiment/{experiment_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/experiment/{experiment_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/experiment withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/experiment/{experiment_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/experiment/{experiment_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/experiment/{experiment_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/experiment/{experiment_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/experiment/{experiment_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/experiment/{experiment_id}/summarize withRawResponse().summarize(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ExperimentServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ExperimentServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ExperimentListPageAsync.of( - ExperimentServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ExperimentListPageAsync.of(ExperimentServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + summarizeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index b625969e..89865299 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -21,46 +21,45 @@ import java.util.concurrent.CompletableFuture interface FunctionServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified + * Create a new function. If there is an existing function in the project with the + * same slug as the one specified in the request, will return the existing function + * unmodified */ fun create(params: FunctionCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a function object by its id */ fun retrieve(params: FunctionRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a function object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: FunctionUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all functions. The functions are sorted by creation date, with the most @@ -69,164 +68,145 @@ interface FunctionServiceAsync { fun list(): CompletableFuture = list(FunctionListParams.none()) /** @see [list] */ - fun list( - params: FunctionListParams = FunctionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: FunctionListParams = FunctionListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: FunctionListParams = FunctionListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(FunctionListParams.none(), requestOptions) /** Delete a function object by its id */ fun delete(params: FunctionDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Invoke a function. */ fun invoke(params: FunctionInvokeParams): CompletableFuture> = - invoke(params, RequestOptions.none()) + invoke( + params, RequestOptions.none() + ) /** @see [invoke] */ - fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Create or replace function. If there is an existing function in the project with the same - * slug as the one specified in the request, will replace the existing function with the - * provided fields + * Create or replace function. If there is an existing function in the project with + * the same slug as the one specified in the request, will replace the existing + * function with the provided fields */ fun replace(params: FunctionReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [FunctionServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [FunctionServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as - * [FunctionServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same + * as [FunctionServiceAsync.create]. */ @MustBeClosed fun create(params: FunctionCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the - * same as [FunctionServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is + * otherwise the same as [FunctionServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: FunctionRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the - * same as [FunctionServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is + * otherwise the same as [FunctionServiceAsync.update]. */ @MustBeClosed fun update(params: FunctionUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as * [FunctionServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(FunctionListParams.none()) + fun list(): CompletableFuture> = list(FunctionListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: FunctionListParams = FunctionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: FunctionListParams = FunctionListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: FunctionListParams = FunctionListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(FunctionListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the - * same as [FunctionServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is + * otherwise the same as [FunctionServiceAsync.delete]. */ @MustBeClosed fun delete(params: FunctionDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is * otherwise the same as [FunctionServiceAsync.invoke]. */ @MustBeClosed - fun invoke( - params: FunctionInvokeParams - ): CompletableFuture>> = - invoke(params, RequestOptions.none()) + fun invoke(params: FunctionInvokeParams): CompletableFuture>> = + invoke( + params, RequestOptions.none() + ) /** @see [invoke] */ @MustBeClosed - fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> + fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture>> /** * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as @@ -234,13 +214,12 @@ interface FunctionServiceAsync { */ @MustBeClosed fun replace(params: FunctionReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 27377950..09c07695 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams import com.braintrustdata.api.models.FunctionInvokeResponse +import com.braintrustdata.api.models.FunctionListPage import com.braintrustdata.api.models.FunctionListPageAsync import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams @@ -28,284 +29,224 @@ import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional import java.util.concurrent.CompletableFuture -class FunctionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - FunctionServiceAsync { +class FunctionServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: FunctionServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : FunctionServiceAsync { + + private val withRawResponse: FunctionServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): FunctionServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/function withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/function/{function_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/function/{function_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: FunctionListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/function withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/function/{function_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions, - ): CompletableFuture> = + override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): CompletableFuture> = // post /v1/function/{function_id}/invoke withRawResponse().invoke(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/function withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - FunctionServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : FunctionServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - FunctionListPageAsync.of( - FunctionServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: FunctionListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + FunctionListPageAsync.of(FunctionServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val invokeHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions, - ): CompletableFuture>> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { invokeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } - } - } - } - } + private val invokeHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): CompletableFuture>> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function", params.getPathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + invokeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index 9c172789..04d7d5b7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -18,92 +18,89 @@ import java.util.concurrent.CompletableFuture interface GroupServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one + * specified in the request, will return the existing group unmodified */ fun create(params: GroupCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a group object by its id */ fun retrieve(params: GroupRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: GroupUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ fun list(): CompletableFuture = list(GroupListParams.none()) /** @see [list] */ - fun list( - params: GroupListParams = GroupListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: GroupListParams = GroupListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: GroupListParams = GroupListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(GroupListParams.none(), requestOptions) /** Delete a group object by its id */ fun delete(params: GroupDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace group. If there is an existing group with the same name as the one - * specified in the request, will replace the existing group with the provided fields + * Create or replace group. If there is an existing group with the same name as the + * one specified in the request, will replace the existing group with the provided + * fields */ fun replace(params: GroupReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [GroupServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [GroupServiceAsync] that provides access to raw HTTP responses for + * each method. + */ interface WithRawResponse { /** @@ -112,88 +109,77 @@ interface GroupServiceAsync { */ @MustBeClosed fun create(params: GroupCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as - * [GroupServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the + * same as [GroupServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: GroupRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same - * as [GroupServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise + * the same as [GroupServiceAsync.update]. */ @MustBeClosed fun update(params: GroupUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as * [GroupServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(GroupListParams.none()) + fun list(): CompletableFuture> = list(GroupListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: GroupListParams = GroupListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: GroupListParams = GroupListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: GroupListParams = GroupListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(GroupListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same - * as [GroupServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise + * the same as [GroupServiceAsync.delete]. */ @MustBeClosed fun delete(params: GroupDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as @@ -201,13 +187,12 @@ interface GroupServiceAsync { */ @MustBeClosed fun replace(params: GroupReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index db541802..7400ac18 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams +import com.braintrustdata.api.models.GroupListPage import com.braintrustdata.api.models.GroupListPageAsync import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams import java.util.concurrent.CompletableFuture -class GroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - GroupServiceAsync { +class GroupServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : GroupServiceAsync { + + private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): GroupServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: GroupCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: GroupCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/group withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/group/{group_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/group/{group_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: GroupListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: GroupListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/group withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/group/{group_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/group withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - GroupServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : GroupServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: GroupCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: GroupCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: GroupListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - GroupListPageAsync.of( - GroupServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: GroupListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + GroupListPageAsync.of(GroupServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index a224dbd9..42e1be2c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -17,7 +17,8 @@ import java.util.concurrent.CompletableFuture interface OrganizationServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -25,62 +26,56 @@ interface OrganizationServiceAsync { /** Get an organization object by its id */ fun retrieve(params: OrganizationRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update an organization object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: OrganizationUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ fun list(): CompletableFuture = list(OrganizationListParams.none()) /** @see [list] */ - fun list( - params: OrganizationListParams = OrganizationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: OrganizationListParams = OrganizationListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: OrganizationListParams = OrganizationListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(OrganizationListParams.none(), requestOptions) /** Delete an organization object by its id */ fun delete(params: OrganizationDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [OrganizationServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [OrganizationServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { @@ -91,77 +86,63 @@ interface OrganizationServiceAsync { * otherwise the same as [OrganizationServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: OrganizationRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + fun retrieve(params: OrganizationRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is - * otherwise the same as [OrganizationServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but + * is otherwise the same as [OrganizationServiceAsync.update]. */ @MustBeClosed - fun update( - params: OrganizationUpdateParams - ): CompletableFuture> = update(params, RequestOptions.none()) + fun update(params: OrganizationUpdateParams): CompletableFuture> = + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as - * [OrganizationServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the + * same as [OrganizationServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(OrganizationListParams.none()) + fun list(): CompletableFuture> = list(OrganizationListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: OrganizationListParams = OrganizationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: OrganizationListParams = OrganizationListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: OrganizationListParams = OrganizationListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(OrganizationListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is - * otherwise the same as [OrganizationServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but + * is otherwise the same as [OrganizationServiceAsync.delete]. */ @MustBeClosed - fun delete( - params: OrganizationDeleteParams - ): CompletableFuture> = delete(params, RequestOptions.none()) + fun delete(params: OrganizationDeleteParams): CompletableFuture> = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 08667293..959bb5c4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams +import com.braintrustdata.api.models.OrganizationListPage import com.braintrustdata.api.models.OrganizationListPageAsync import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams @@ -25,12 +26,12 @@ import com.braintrustdata.api.services.async.organizations.MemberServiceAsync import com.braintrustdata.api.services.async.organizations.MemberServiceAsyncImpl import java.util.concurrent.CompletableFuture -class OrganizationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - OrganizationServiceAsync { +class OrganizationServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: OrganizationServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : OrganizationServiceAsync { + + private val withRawResponse: OrganizationServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } private val members: MemberServiceAsync by lazy { MemberServiceAsyncImpl(clientOptions) } @@ -38,169 +39,132 @@ class OrganizationServiceAsyncImpl internal constructor(private val clientOption override fun members(): MemberServiceAsync = members - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/organization/{organization_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/organization/{organization_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/organization withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/organization/{organization_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - OrganizationServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : OrganizationServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val members: MemberServiceAsync.WithRawResponse by lazy { - MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val members: MemberServiceAsync.WithRawResponse by lazy { MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) } override fun members(): MemberServiceAsync.WithRawResponse = members - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - OrganizationListPageAsync.of( - OrganizationServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + OrganizationListPageAsync.of(OrganizationServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index beca7a59..aa644b97 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -18,207 +18,182 @@ import java.util.concurrent.CompletableFuture interface ProjectScoreServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_score. If there is an existing project_score in the project with the - * same name as the one specified in the request, will return the existing project_score - * unmodified + * Create a new project_score. If there is an existing project_score in the project + * with the same name as the one specified in the request, will return the existing + * project_score unmodified */ fun create(params: ProjectScoreCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a project_score object by its id */ fun retrieve(params: ProjectScoreRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: ProjectScoreUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ fun list(): CompletableFuture = list(ProjectScoreListParams.none()) /** @see [list] */ - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectScoreListParams.none(), requestOptions) /** Delete a project_score object by its id */ fun delete(params: ProjectScoreDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace project_score. If there is an existing project_score in the project with - * the same name as the one specified in the request, will replace the existing project_score - * with the provided fields + * Create or replace project_score. If there is an existing project_score in the + * project with the same name as the one specified in the request, will replace the + * existing project_score with the provided fields */ fun replace(params: ProjectScoreReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ProjectScoreServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [ProjectScoreServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as - * [ProjectScoreServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the + * same as [ProjectScoreServiceAsync.create]. */ @MustBeClosed - fun create( - params: ProjectScoreCreateParams - ): CompletableFuture> = create(params, RequestOptions.none()) + fun create(params: ProjectScoreCreateParams): CompletableFuture> = + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but + * is otherwise the same as [ProjectScoreServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: ProjectScoreRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + fun retrieve(params: ProjectScoreRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, + * but is otherwise the same as [ProjectScoreServiceAsync.update]. */ @MustBeClosed - fun update( - params: ProjectScoreUpdateParams - ): CompletableFuture> = update(params, RequestOptions.none()) + fun update(params: ProjectScoreUpdateParams): CompletableFuture> = + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as - * [ProjectScoreServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the + * same as [ProjectScoreServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ProjectScoreListParams.none()) + fun list(): CompletableFuture> = list(ProjectScoreListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectScoreListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, + * but is otherwise the same as [ProjectScoreServiceAsync.delete]. */ @MustBeClosed - fun delete( - params: ProjectScoreDeleteParams - ): CompletableFuture> = delete(params, RequestOptions.none()) + fun delete(params: ProjectScoreDeleteParams): CompletableFuture> = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as - * [ProjectScoreServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the + * same as [ProjectScoreServiceAsync.replace]. */ @MustBeClosed - fun replace( - params: ProjectScoreReplaceParams - ): CompletableFuture> = replace(params, RequestOptions.none()) + fun replace(params: ProjectScoreReplaceParams): CompletableFuture> = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index cde96d23..1f2c575c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams +import com.braintrustdata.api.models.ProjectScoreListPage import com.braintrustdata.api.models.ProjectScoreListPageAsync import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams import java.util.concurrent.CompletableFuture -class ProjectScoreServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectScoreServiceAsync { +class ProjectScoreServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectScoreServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectScoreServiceAsync { + + private val withRawResponse: ProjectScoreServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ProjectScoreServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_score withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_score/{project_score_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/project_score/{project_score_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_score withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/project_score/{project_score_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/project_score withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectScoreServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : ProjectScoreServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectScoreListPageAsync.of( - ProjectScoreServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectScoreListPageAsync.of(ProjectScoreServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index c1c67326..150a37a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -18,48 +18,46 @@ import java.util.concurrent.CompletableFuture interface ProjectServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse fun logs(): LogServiceAsync /** - * Create a new project. If there is an existing project with the same name as the one specified - * in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the + * one specified in the request, will return the existing project unmodified */ fun create(params: ProjectCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a project object by its id */ fun retrieve(params: ProjectRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a project object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: ProjectUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** * List out all projects. The projects are sorted by creation date, with the most @@ -68,32 +66,29 @@ interface ProjectServiceAsync { fun list(): CompletableFuture = list(ProjectListParams.none()) /** @see [list] */ - fun list( - params: ProjectListParams = ProjectListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ProjectListParams = ProjectListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ProjectListParams = ProjectListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectListParams.none(), requestOptions) /** Delete a project object by its id */ fun delete(params: ProjectDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ProjectServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [ProjectServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -105,87 +100,76 @@ interface ProjectServiceAsync { */ @MustBeClosed fun create(params: ProjectCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same - * as [ProjectServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise + * the same as [ProjectServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the - * same as [ProjectServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is + * otherwise the same as [ProjectServiceAsync.update]. */ @MustBeClosed fun update(params: ProjectUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as * [ProjectServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ProjectListParams.none()) + fun list(): CompletableFuture> = list(ProjectListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectListParams = ProjectListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ProjectListParams = ProjectListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ProjectListParams = ProjectListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the - * same as [ProjectServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is + * otherwise the same as [ProjectServiceAsync.delete]. */ @MustBeClosed fun delete(params: ProjectDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index dba161a5..53bb7b05 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams +import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams @@ -26,12 +27,12 @@ import com.braintrustdata.api.services.async.projects.LogServiceAsync import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl import java.util.concurrent.CompletableFuture -class ProjectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectServiceAsync { +class ProjectServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectServiceAsync { + + private val withRawResponse: ProjectServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } private val logs: LogServiceAsync by lazy { LogServiceAsyncImpl(clientOptions) } @@ -39,206 +40,161 @@ class ProjectServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun logs(): LogServiceAsync = logs - override fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project/{project_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/project/{project_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ProjectListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ProjectListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/project/{project_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ProjectServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val logs: LogServiceAsync.WithRawResponse by lazy { - LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } + private val logs: LogServiceAsync.WithRawResponse by lazy { LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) } override fun logs(): LogServiceAsync.WithRawResponse = logs - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectListPageAsync.of( - ProjectServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectListPageAsync.of(ProjectServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index 6d681309..7a823a70 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -18,128 +18,119 @@ import java.util.concurrent.CompletableFuture interface ProjectTagServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will return the existing project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project + * with the same name as the one specified in the request, will return the existing + * project_tag unmodified */ fun create(params: ProjectTagCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a project_tag object by its id */ fun retrieve(params: ProjectTagRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: ProjectTagUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ fun list(): CompletableFuture = list(ProjectTagListParams.none()) /** @see [list] */ - fun list( - params: ProjectTagListParams = ProjectTagListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: ProjectTagListParams = ProjectTagListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: ProjectTagListParams = ProjectTagListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectTagListParams.none(), requestOptions) /** Delete a project_tag object by its id */ fun delete(params: ProjectTagDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace project_tag. If there is an existing project_tag in the project with the - * same name as the one specified in the request, will replace the existing project_tag with the - * provided fields + * Create or replace project_tag. If there is an existing project_tag in the + * project with the same name as the one specified in the request, will replace the + * existing project_tag with the provided fields */ fun replace(params: ProjectTagReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [ProjectTagServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [ProjectTagServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as - * [ProjectTagServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the + * same as [ProjectTagServiceAsync.create]. */ @MustBeClosed fun create(params: ProjectTagCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise - * the same as [ProjectTagServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: ProjectTagRetrieveParams - ): CompletableFuture> = retrieve(params, RequestOptions.none()) + fun retrieve(params: ProjectTagRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is @@ -147,73 +138,62 @@ interface ProjectTagServiceAsync { */ @MustBeClosed fun update(params: ProjectTagUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as - * [ProjectTagServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same + * as [ProjectTagServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(ProjectTagListParams.none()) + fun list(): CompletableFuture> = list(ProjectTagListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectTagListParams = ProjectTagListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: ProjectTagListParams = ProjectTagListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: ProjectTagListParams = ProjectTagListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectTagListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is - * otherwise the same as [ProjectTagServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but + * is otherwise the same as [ProjectTagServiceAsync.delete]. */ @MustBeClosed fun delete(params: ProjectTagDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as - * [ProjectTagServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same + * as [ProjectTagServiceAsync.replace]. */ @MustBeClosed - fun replace( - params: ProjectTagReplaceParams - ): CompletableFuture> = replace(params, RequestOptions.none()) + fun replace(params: ProjectTagReplaceParams): CompletableFuture> = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index d12a821a..21850a9d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams +import com.braintrustdata.api.models.ProjectTagListPage import com.braintrustdata.api.models.ProjectTagListPageAsync import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams import java.util.concurrent.CompletableFuture -class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectTagServiceAsync { +class ProjectTagServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectTagServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectTagServiceAsync { + + private val withRawResponse: ProjectTagServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ProjectTagServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_tag withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_tag/{project_tag_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/project_tag/{project_tag_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_tag withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/project_tag/{project_tag_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/project_tag withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectTagServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : ProjectTagServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectTagListPageAsync.of( - ProjectTagServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectTagListPageAsync.of(ProjectTagServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index afb7a900..9a962e3b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -18,93 +18,89 @@ import java.util.concurrent.CompletableFuture interface PromptServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified + * Create a new prompt. If there is an existing prompt in the project with the same + * slug as the one specified in the request, will return the existing prompt + * unmodified */ fun create(params: PromptCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a prompt object by its id */ fun retrieve(params: PromptRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a prompt object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ fun update(params: PromptUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ fun list(): CompletableFuture = list(PromptListParams.none()) /** @see [list] */ - fun list( - params: PromptListParams = PromptListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: PromptListParams = PromptListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: PromptListParams = PromptListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(PromptListParams.none(), requestOptions) /** Delete a prompt object by its id */ fun delete(params: PromptDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as - * the one specified in the request, will replace the existing prompt with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the + * same slug as the one specified in the request, will replace the existing prompt + * with the provided fields */ fun replace(params: PromptReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [PromptServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [PromptServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -114,88 +110,77 @@ interface PromptServiceAsync { */ @MustBeClosed fun create(params: PromptCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same - * as [PromptServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise + * the same as [PromptServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: PromptRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same - * as [PromptServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise + * the same as [PromptServiceAsync.update]. */ @MustBeClosed fun update(params: PromptUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as * [PromptServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(PromptListParams.none()) + fun list(): CompletableFuture> = list(PromptListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: PromptListParams = PromptListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: PromptListParams = PromptListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: PromptListParams = PromptListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(PromptListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the - * same as [PromptServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is + * otherwise the same as [PromptServiceAsync.delete]. */ @MustBeClosed fun delete(params: PromptDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as @@ -203,13 +188,12 @@ interface PromptServiceAsync { */ @MustBeClosed fun replace(params: PromptReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 7772aa68..3a65157b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams +import com.braintrustdata.api.models.PromptListPage import com.braintrustdata.api.models.PromptListPageAsync import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams import java.util.concurrent.CompletableFuture -class PromptServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - PromptServiceAsync { +class PromptServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: PromptServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : PromptServiceAsync { + + private val withRawResponse: PromptServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): PromptServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: PromptCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: PromptCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/prompt withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/prompt/{prompt_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/prompt/{prompt_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: PromptListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: PromptListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/prompt withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/prompt/{prompt_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/prompt withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - PromptServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : PromptServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: PromptCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: PromptCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: PromptListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - PromptListPageAsync.of( - PromptServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: PromptListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + PromptListPageAsync.of(PromptServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index 988acc47..4dc148d9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -18,91 +18,89 @@ import java.util.concurrent.CompletableFuture interface RoleServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one + * specified in the request, will return the existing role unmodified */ fun create(params: RoleCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a role object by its id */ fun retrieve(params: RoleRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ fun update(params: RoleUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all roles. The roles are sorted by creation date, with the most recently-created - * roles coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ fun list(): CompletableFuture = list(RoleListParams.none()) /** @see [list] */ - fun list( - params: RoleListParams = RoleListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ fun list(params: RoleListParams = RoleListParams.none()): CompletableFuture = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(RoleListParams.none(), requestOptions) /** Delete a role object by its id */ fun delete(params: RoleDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace role. If there is an existing role with the same name as the one specified - * in the request, will replace the existing role with the provided fields + * Create or replace role. If there is an existing role with the same name as the + * one specified in the request, will replace the existing role with the provided + * fields */ fun replace(params: RoleReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [RoleServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [RoleServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -111,88 +109,77 @@ interface RoleServiceAsync { */ @MustBeClosed fun create(params: RoleCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as - * [RoleServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the + * same as [RoleServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: RoleRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as - * [RoleServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the + * same as [RoleServiceAsync.update]. */ @MustBeClosed fun update(params: RoleUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as * [RoleServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(RoleListParams.none()) + fun list(): CompletableFuture> = list(RoleListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: RoleListParams = RoleListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: RoleListParams = RoleListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: RoleListParams = RoleListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(RoleListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as - * [RoleServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise + * the same as [RoleServiceAsync.delete]. */ @MustBeClosed fun delete(params: RoleDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as @@ -200,13 +187,12 @@ interface RoleServiceAsync { */ @MustBeClosed fun replace(params: RoleReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index f4809686..dec426f5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams +import com.braintrustdata.api.models.RoleListPage import com.braintrustdata.api.models.RoleListPageAsync import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams import java.util.concurrent.CompletableFuture -class RoleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - RoleServiceAsync { +class RoleServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : RoleServiceAsync { + + private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): RoleServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: RoleCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: RoleCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/role withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/role/{role_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/role/{role_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: RoleListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: RoleListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/role withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/role/{role_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/role withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - RoleServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : RoleServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: RoleCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: RoleCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: RoleListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - RoleListPageAsync.of( - RoleServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: RoleListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + RoleListPageAsync.of(RoleServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt index 442357ea..fce4db78 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt @@ -18,127 +18,119 @@ import java.util.concurrent.CompletableFuture interface SpanIframeServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will return the existing span_iframe unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name + * as the one specified in the request, will return the existing span_iframe + * unmodified */ fun create(params: SpanIframeCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a span_iframe object by its id */ fun retrieve(params: SpanIframeRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a span_iframe object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: SpanIframeUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ fun list(): CompletableFuture = list(SpanIframeListParams.none()) /** @see [list] */ - fun list( - params: SpanIframeListParams = SpanIframeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ - fun list( - params: SpanIframeListParams = SpanIframeListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) + fun list(params: SpanIframeListParams = SpanIframeListParams.none()): CompletableFuture = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(SpanIframeListParams.none(), requestOptions) /** Delete a span_iframe object by its id */ fun delete(params: SpanIframeDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace span_iframe. If there is an existing span_iframe with the same name as the - * one specified in the request, will replace the existing span_iframe with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same + * name as the one specified in the request, will replace the existing span_iframe + * with the provided fields */ fun replace(params: SpanIframeReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * A view of [SpanIframeServiceAsync] that provides access to raw HTTP responses for each - * method. + * A view of [SpanIframeServiceAsync] that provides access to raw HTTP responses + * for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as - * [SpanIframeServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the + * same as [SpanIframeServiceAsync.create]. */ @MustBeClosed fun create(params: SpanIframeCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise - * the same as [SpanIframeServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve( - params: SpanIframeRetrieveParams - ): CompletableFuture> = retrieve(params, RequestOptions.none()) + fun retrieve(params: SpanIframeRetrieveParams): CompletableFuture> = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is @@ -146,73 +138,62 @@ interface SpanIframeServiceAsync { */ @MustBeClosed fun update(params: SpanIframeUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as - * [SpanIframeServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same + * as [SpanIframeServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(SpanIframeListParams.none()) + fun list(): CompletableFuture> = list(SpanIframeListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: SpanIframeListParams = SpanIframeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: SpanIframeListParams = SpanIframeListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: SpanIframeListParams = SpanIframeListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(SpanIframeListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is - * otherwise the same as [SpanIframeServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but + * is otherwise the same as [SpanIframeServiceAsync.delete]. */ @MustBeClosed fun delete(params: SpanIframeDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as - * [SpanIframeServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same + * as [SpanIframeServiceAsync.replace]. */ @MustBeClosed - fun replace( - params: SpanIframeReplaceParams - ): CompletableFuture> = replace(params, RequestOptions.none()) + fun replace(params: SpanIframeReplaceParams): CompletableFuture> = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt index 6dd3a6b3..c8752694 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.SpanIFrame import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListPage import com.braintrustdata.api.models.SpanIframeListPageAsync import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams import java.util.concurrent.CompletableFuture -class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - SpanIframeServiceAsync { +class SpanIframeServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: SpanIframeServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : SpanIframeServiceAsync { + + private val withRawResponse: SpanIframeServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): SpanIframeServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/span_iframe withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/span_iframe/{span_iframe_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/span_iframe/{span_iframe_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: SpanIframeListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/span_iframe withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/span_iframe/{span_iframe_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/span_iframe withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - SpanIframeServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : SpanIframeServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: SpanIframeListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - SpanIframeListPageAsync.of( - SpanIframeServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SpanIframeListPageAsync.of(SpanIframeServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index 5411c270..8f17d844 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -11,30 +11,32 @@ import java.util.concurrent.CompletableFuture interface TopLevelServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + /** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ fun helloWorld(): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [helloWorld] */ - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() - ): CompletableFuture = helloWorld(params, RequestOptions.none()) + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): CompletableFuture = + helloWorld( + params, RequestOptions.none() + ) /** @see [helloWorld] */ - fun helloWorld(requestOptions: RequestOptions): CompletableFuture = - helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) /** - * A view of [TopLevelServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [TopLevelServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -43,25 +45,21 @@ interface TopLevelServiceAsync { * [TopLevelServiceAsync.helloWorld]. */ @MustBeClosed - fun helloWorld(): CompletableFuture> = - helloWorld(TopLevelHelloWorldParams.none()) + fun helloWorld(): CompletableFuture> = helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [helloWorld] */ @MustBeClosed - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() - ): CompletableFuture> = helloWorld(params, RequestOptions.none()) + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): CompletableFuture> = + helloWorld( + params, RequestOptions.none() + ) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(requestOptions: RequestOptions): CompletableFuture> = - helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): CompletableFuture> = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index efc7d4ce..49f348d0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -17,46 +17,43 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams import java.util.concurrent.CompletableFuture -class TopLevelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - TopLevelServiceAsync { +class TopLevelServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: TopLevelServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : TopLevelServiceAsync { + + private val withRawResponse: TopLevelServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): TopLevelServiceAsync.WithRawResponse = withRawResponse - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): CompletableFuture = // get /v1 withRawResponse().helloWorld(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TopLevelServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : TopLevelServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = - stringHandler().withErrorHandler(errorHandler) - - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { response.use { helloWorldHandler.handle(it) } } - } + private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) + + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + helloWorldHandler.handle(it) + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index 2bf974c5..274de7e7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -14,85 +14,78 @@ import java.util.concurrent.CompletableFuture interface UserServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Get a user object by its id */ fun retrieve(params: UserRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all users. The users are sorted by creation date, with the most recently-created - * users coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ fun list(): CompletableFuture = list(UserListParams.none()) /** @see [list] */ - fun list( - params: UserListParams = UserListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [list] */ fun list(params: UserListParams = UserListParams.none()): CompletableFuture = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = list(UserListParams.none(), requestOptions) - /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [UserServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as - * [UserServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the + * same as [UserServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: UserRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as * [UserServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = - list(UserListParams.none()) + fun list(): CompletableFuture> = list(UserListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: UserListParams = UserListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list( - params: UserListParams = UserListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) + fun list(params: UserListParams = UserListParams.none()): CompletableFuture> = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture> = list(UserListParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 54c73c41..3041b017 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -15,103 +15,85 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.User +import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListPageAsync import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import java.util.concurrent.CompletableFuture -class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - UserServiceAsync { +class UserServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : UserServiceAsync { + + private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): UserServiceAsync.WithRawResponse = withRawResponse - override fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/user/{user_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list( - params: UserListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: UserListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/user withRawResponse().list(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - UserServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : UserServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun list( - params: UserListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - UserListPageAsync.of( - UserServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + override fun list(params: UserListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + UserListPageAsync.of(UserServiceAsyncImpl(clientOptions), params, it) + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index f70248e9..8134d5a3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -18,84 +18,83 @@ import java.util.concurrent.CompletableFuture interface ViewServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one + * specified in the request, will return the existing view unmodified */ fun create(params: ViewCreateParams): CompletableFuture = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Get a view object by its id */ fun retrieve(params: ViewRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ fun update(params: ViewUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * List out all views. The views are sorted by creation date, with the most recently-created - * views coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ fun list(params: ViewListParams): CompletableFuture = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Delete a view object by its id */ fun delete(params: ViewDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Create or replace view. If there is an existing view with the same name as the one specified - * in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the + * one specified in the request, will replace the existing view with the provided + * fields */ fun replace(params: ViewReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [ViewServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ViewServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -104,44 +103,41 @@ interface ViewServiceAsync { */ @MustBeClosed fun create(params: ViewCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as - * [ViewServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the + * same as [ViewServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ViewRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as - * [ViewServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the + * same as [ViewServiceAsync.update]. */ @MustBeClosed fun update(params: ViewUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as @@ -149,29 +145,27 @@ interface ViewServiceAsync { */ @MustBeClosed fun list(params: ViewListParams): CompletableFuture> = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as - * [ViewServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise + * the same as [ViewServiceAsync.delete]. */ @MustBeClosed fun delete(params: ViewDeleteParams): CompletableFuture> = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as @@ -179,13 +173,12 @@ interface ViewServiceAsync { */ @MustBeClosed fun replace(params: ViewReplaceParams): CompletableFuture> = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 644bd149..2da433b4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams +import com.braintrustdata.api.models.ViewListPage import com.braintrustdata.api.models.ViewListPageAsync import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams @@ -25,246 +26,195 @@ import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams import java.util.concurrent.CompletableFuture -class ViewServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ViewServiceAsync { +class ViewServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ViewServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ViewServiceAsync { + + private val withRawResponse: ViewServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ViewServiceAsync.WithRawResponse = withRawResponse - override fun create( - params: ViewCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun create(params: ViewCreateParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/view withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/view/{view_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/view/{view_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( - params: ViewListParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun list(params: ViewListParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/view withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): CompletableFuture = // delete /v1/view/{view_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): CompletableFuture = // put /v1/view withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ViewServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : ViewServiceAsync.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: ViewCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ViewCreateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ViewListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ViewListPageAsync.of( - ViewServiceAsyncImpl(clientOptions), - params, - it, - ) - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ViewListParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ViewListPageAsync.of(ViewServiceAsyncImpl(clientOptions), params, it) + } + } } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt index 78042415..e27990ac 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -12,61 +12,52 @@ import java.util.concurrent.CompletableFuture interface MemberServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Modify organization membership */ - fun update(): CompletableFuture = - update(OrganizationMemberUpdateParams.none()) + fun update(): CompletableFuture = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** @see [update] */ - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() - ): CompletableFuture = update(params, RequestOptions.none()) + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): CompletableFuture = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update(requestOptions: RequestOptions): CompletableFuture = - update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): CompletableFuture = update(OrganizationMemberUpdateParams.none(), requestOptions) /** - * A view of [MemberServiceAsync] that provides access to raw HTTP responses for each method. + * A view of [MemberServiceAsync] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the - * same as [MemberServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/organization/members`, but is + * otherwise the same as [MemberServiceAsync.update]. */ @MustBeClosed - fun update(): CompletableFuture> = - update(OrganizationMemberUpdateParams.none()) + fun update(): CompletableFuture> = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() - ): CompletableFuture> = - update(params, RequestOptions.none()) + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): CompletableFuture> = + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - requestOptions: RequestOptions - ): CompletableFuture> = - update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): CompletableFuture> = update(OrganizationMemberUpdateParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index ac1cca4a..82c4ff17 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -19,56 +19,49 @@ import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput import java.util.concurrent.CompletableFuture -class MemberServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - MemberServiceAsync { +class MemberServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : MemberServiceAsync { + + private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): MemberServiceAsync.WithRawResponse = withRawResponse - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): CompletableFuture = // patch /v1/organization/members withRawResponse().update(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - MemberServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : MemberServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index b1d19e58..1b67edf9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -17,128 +17,115 @@ import java.util.concurrent.CompletableFuture interface LogServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Log feedback for a set of project logs events */ fun feedback(params: ProjectLogFeedbackParams): CompletableFuture = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same + * path, but with the parameters in the URL query rather than in the request body. + * For more complex queries, use the `POST /btql` endpoint. */ fun fetch(params: ProjectLogFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ - fun fetchPost( - params: ProjectLogFetchPostParams - ): CompletableFuture = fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ProjectLogFetchPostParams): CompletableFuture = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture /** Insert a set of events into the project logs */ fun insert(params: ProjectLogInsertParams): CompletableFuture = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture - /** A view of [LogServiceAsync] that provides access to raw HTTP responses for each method. */ + /** + * A view of [LogServiceAsync] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is - * otherwise the same as [LogServiceAsync.feedback]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, + * but is otherwise the same as [LogServiceAsync.feedback]. */ @MustBeClosed - fun feedback( - params: ProjectLogFeedbackParams - ): CompletableFuture> = - feedback(params, RequestOptions.none()) + fun feedback(params: ProjectLogFeedbackParams): CompletableFuture> = + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is - * otherwise the same as [LogServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but + * is otherwise the same as [LogServiceAsync.fetch]. */ @MustBeClosed - fun fetch( - params: ProjectLogFetchParams - ): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(params: ProjectLogFetchParams): CompletableFuture> = + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is - * otherwise the same as [LogServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but + * is otherwise the same as [LogServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: ProjectLogFetchPostParams - ): CompletableFuture> = - fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ProjectLogFetchPostParams): CompletableFuture> = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is - * otherwise the same as [LogServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but + * is otherwise the same as [LogServiceAsync.insert]. */ @MustBeClosed - fun insert( - params: ProjectLogInsertParams - ): CompletableFuture> = - insert(params, RequestOptions.none()) + fun insert(params: ProjectLogInsertParams): CompletableFuture> = + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index 7c47266f..abb30573 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -24,169 +24,135 @@ import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams import java.util.concurrent.CompletableFuture -class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - LogServiceAsync { +class LogServiceAsyncImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : LogServiceAsync { + + private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): LogServiceAsync.WithRawResponse = withRawResponse - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_logs/{project_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): CompletableFuture = // get /v1/project_logs/{project_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_logs/{project_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture = + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): CompletableFuture = // post /v1/project_logs/{project_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - LogServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : LogServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): CompletableFuture> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + return request.thenComposeAsync { clientOptions.httpClient.executeAsync( + it, requestOptions + ) }.thenApply { response -> response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index 5d4a4de6..70828f20 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -18,78 +18,85 @@ import com.google.errorprone.annotations.MustBeClosed interface AclService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one + * specified in the request, will return the existing acl unmodified */ - fun create(params: AclCreateParams): Acl = create(params, RequestOptions.none()) + fun create(params: AclCreateParams): Acl = + create( + params, RequestOptions.none() + ) /** @see [create] */ fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** Get an acl object by its id */ - fun retrieve(params: AclRetrieveParams): Acl = retrieve(params, RequestOptions.none()) + fun retrieve(params: AclRetrieveParams): Acl = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Acl + fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** - * List out all acls. The acls are sorted by creation date, with the most recently-created acls - * coming first + * List out all acls. The acls are sorted by creation date, with the most + * recently-created acls coming first */ - fun list(params: AclListParams): AclListPage = list(params, RequestOptions.none()) + fun list(params: AclListParams): AclListPage = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AclListPage + fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): AclListPage /** Delete an acl object by its id */ - fun delete(params: AclDeleteParams): Acl = delete(params, RequestOptions.none()) + fun delete(params: AclDeleteParams): Acl = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. + * Batch update acls. This operation is idempotent, so adding acls which already + * exist will have no effect, and removing acls which do not exist will have no + * effect. */ fun batchUpdate(): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AclBatchUpdateResponse + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): AclBatchUpdateResponse /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): AclBatchUpdateResponse = batchUpdate(params, RequestOptions.none()) + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): AclBatchUpdateResponse = + batchUpdate( + params, RequestOptions.none() + ) /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): Acl = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ - fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Acl + fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl - /** A view of [AclService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [AclService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -98,29 +105,27 @@ interface AclService { */ @MustBeClosed fun create(params: AclCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: AclCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as - * [AclService.retrieve]. + * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the + * same as [AclService.retrieve]. */ @MustBeClosed fun retrieve(params: AclRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as @@ -128,55 +133,49 @@ interface AclService { */ @MustBeClosed fun list(params: AclListParams): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as - * [AclService.delete]. + * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the + * same as [AclService.delete]. */ @MustBeClosed fun delete(params: AclDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclService.batchUpdate]. + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise + * the same as [AclService.batchUpdate]. */ @MustBeClosed - fun batchUpdate(): HttpResponseFor = - batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): HttpResponseFor = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): HttpResponseFor = batchUpdate(params, RequestOptions.none()) + fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): HttpResponseFor = + batchUpdate( + params, RequestOptions.none() + ) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as @@ -184,13 +183,12 @@ interface AclService { */ @MustBeClosed fun findAndDelete(params: AclFindAndDeleteParams): HttpResponseFor = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index 39e18573..de7b127f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -25,11 +25,12 @@ import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -class AclServiceImpl internal constructor(private val clientOptions: ClientOptions) : AclService { +class AclServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: AclService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : AclService { + + private val withRawResponse: AclService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): AclService.WithRawResponse = withRawResponse @@ -49,186 +50,176 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).parse() - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): AclBatchUpdateResponse = + override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): AclBatchUpdateResponse = // post /v1/acl/batch-update withRawResponse().batchUpdate(params, requestOptions).parse() - override fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions, - ): Acl = + override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): Acl = // delete /v1/acl withRawResponse().findAndDelete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AclService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : AclService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: AclCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: AclCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: AclListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { AclListPage.of(AclServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: AclListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AclListPage.of(AclServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val batchUpdateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch-update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + batchUpdateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete( - params: AclFindAndDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + findAndDeleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt index 867aab8c..b796ff67 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt @@ -18,211 +18,204 @@ import com.google.errorprone.annotations.MustBeClosed interface AiSecretService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as + * the one specified in the request, will return the existing ai_secret unmodified */ - fun create(params: AiSecretCreateParams): AISecret = create(params, RequestOptions.none()) + fun create(params: AiSecretCreateParams): AISecret = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** Get an ai_secret object by its id */ - fun retrieve(params: AiSecretRetrieveParams): AISecret = retrieve(params, RequestOptions.none()) + fun retrieve(params: AiSecretRetrieveParams): AISecret = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** - * Partially update an ai_secret object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - fun update(params: AiSecretUpdateParams): AISecret = update(params, RequestOptions.none()) + fun update(params: AiSecretUpdateParams): AISecret = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most - * recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the + * most recently-created ai_secrets coming first */ fun list(): AiSecretListPage = list(AiSecretListParams.none()) /** @see [list] */ - fun list( - params: AiSecretListParams = AiSecretListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AiSecretListPage + fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): AiSecretListPage /** @see [list] */ fun list(params: AiSecretListParams = AiSecretListParams.none()): AiSecretListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): AiSecretListPage = - list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): AiSecretListPage = list(AiSecretListParams.none(), requestOptions) /** Delete an ai_secret object by its id */ - fun delete(params: AiSecretDeleteParams): AISecret = delete(params, RequestOptions.none()) + fun delete(params: AiSecretDeleteParams): AISecret = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** Delete a single ai_secret */ fun findAndDelete(params: AiSecretFindAndDeleteParams): AISecret = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ - fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret /** - * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one - * specified in the request, will replace the existing ai_secret with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same + * name as the one specified in the request, will replace the existing ai_secret + * with the provided fields */ - fun replace(params: AiSecretReplaceParams): AISecret = replace(params, RequestOptions.none()) + fun replace(params: AiSecretReplaceParams): AISecret = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AISecret + fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret - /** A view of [AiSecretService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [AiSecretService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.create]. + * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same + * as [AiSecretService.create]. */ @MustBeClosed fun create(params: AiSecretCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the - * same as [AiSecretService.retrieve]. + * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretService.retrieve]. */ @MustBeClosed fun retrieve(params: AiSecretRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise - * the same as [AiSecretService.update]. + * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretService.update]. */ @MustBeClosed fun update(params: AiSecretUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.list]. + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same + * as [AiSecretService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(AiSecretListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: AiSecretListParams = AiSecretListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: AiSecretListParams = AiSecretListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: AiSecretListParams = AiSecretListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(AiSecretListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise - * the same as [AiSecretService.delete]. + * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is + * otherwise the same as [AiSecretService.delete]. */ @MustBeClosed fun delete(params: AiSecretDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.findAndDelete]. + * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the + * same as [AiSecretService.findAndDelete]. */ @MustBeClosed fun findAndDelete(params: AiSecretFindAndDeleteParams): HttpResponseFor = - findAndDelete(params, RequestOptions.none()) + findAndDelete( + params, RequestOptions.none() + ) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as - * [AiSecretService.replace]. + * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same + * as [AiSecretService.replace]. */ @MustBeClosed fun replace(params: AiSecretReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index 8824fdce..74bd1cac 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -25,12 +25,12 @@ import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams -class AiSecretServiceImpl internal constructor(private val clientOptions: ClientOptions) : - AiSecretService { +class AiSecretServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: AiSecretService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : AiSecretService { + + private val withRawResponse: AiSecretService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): AiSecretService.WithRawResponse = withRawResponse @@ -38,10 +38,7 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client // post /v1/ai_secret withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions, - ): AISecret = + override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): AISecret = // get /v1/ai_secret/{ai_secret_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -49,10 +46,7 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client // patch /v1/ai_secret/{ai_secret_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: AiSecretListParams, - requestOptions: RequestOptions, - ): AiSecretListPage = + override fun list(params: AiSecretListParams, requestOptions: RequestOptions): AiSecretListPage = // get /v1/ai_secret withRawResponse().list(params, requestOptions).parse() @@ -60,10 +54,7 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client // delete /v1/ai_secret/{ai_secret_id} withRawResponse().delete(params, requestOptions).parse() - override fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions, - ): AISecret = + override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): AISecret = // delete /v1/ai_secret withRawResponse().findAndDelete(params, requestOptions).parse() @@ -71,198 +62,194 @@ class AiSecretServiceImpl internal constructor(private val clientOptions: Client // put /v1/ai_secret withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AiSecretService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + ) : AiSecretService.WithRawResponse { - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - override fun create( - params: AiSecretCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: AiSecretRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: AiSecretUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: AiSecretListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { AiSecretListPage.of(AiSecretServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: AiSecretListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AiSecretListPage.of(AiSecretServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: AiSecretDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val findAndDeleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete( - params: AiSecretFindAndDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { findAndDeleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + findAndDeleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: AiSecretReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index 7f07d4a8..7f3aa7e6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -16,31 +16,31 @@ import com.google.errorprone.annotations.MustBeClosed interface ApiKeyService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same + * name. There is no de-duplication */ fun create(params: ApiKeyCreateParams): CreateApiKeyOutput = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CreateApiKeyOutput + fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CreateApiKeyOutput /** Get an api_key object by its id */ - fun retrieve(params: ApiKeyRetrieveParams): ApiKey = retrieve(params, RequestOptions.none()) + fun retrieve(params: ApiKeyRetrieveParams): ApiKey = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ApiKey + fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey /** * List out all api_keys. The api_keys are sorted by creation date, with the most @@ -49,29 +49,30 @@ interface ApiKeyService { fun list(): ApiKeyListPage = list(ApiKeyListParams.none()) /** @see [list] */ - fun list( - params: ApiKeyListParams = ApiKeyListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ApiKeyListPage + fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ApiKeyListPage /** @see [list] */ fun list(params: ApiKeyListParams = ApiKeyListParams.none()): ApiKeyListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ApiKeyListPage = - list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ApiKeyListPage = list(ApiKeyListParams.none(), requestOptions) /** Delete an api_key object by its id */ - fun delete(params: ApiKeyDeleteParams): ApiKey = delete(params, RequestOptions.none()) + fun delete(params: ApiKeyDeleteParams): ApiKey = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ApiKey + fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey - /** A view of [ApiKeyService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ApiKeyService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -80,67 +81,62 @@ interface ApiKeyService { */ @MustBeClosed fun create(params: ApiKeyCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same - * as [ApiKeyService.retrieve]. + * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise + * the same as [ApiKeyService.retrieve]. */ @MustBeClosed fun retrieve(params: ApiKeyRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as * [ApiKeyService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(ApiKeyListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(ApiKeyListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ApiKeyListParams = ApiKeyListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ApiKeyListParams = ApiKeyListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ApiKeyListParams = ApiKeyListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ApiKeyListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the - * same as [ApiKeyService.delete]. + * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is + * otherwise the same as [ApiKeyService.delete]. */ @MustBeClosed fun delete(params: ApiKeyDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index cba100a5..92710f6f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -23,19 +23,16 @@ import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput -class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ApiKeyService { +class ApiKeyServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ApiKeyService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ApiKeyService { + + private val withRawResponse: ApiKeyService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ApiKeyService.WithRawResponse = withRawResponse - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions, - ): CreateApiKeyOutput = + override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CreateApiKeyOutput = // post /v1/api_key withRawResponse().create(params, requestOptions).parse() @@ -51,117 +48,116 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp // delete /v1/api_key/{api_key_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ApiKeyService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ApiKeyService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ApiKeyListPage.of(ApiKeyServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ApiKeyListPage.of(ApiKeyServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 91a18478..43c28c5e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -25,43 +25,45 @@ import com.google.errorprone.annotations.MustBeClosed interface DatasetService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified + * Create a new dataset. If there is an existing dataset in the project with the + * same name as the one specified in the request, will return the existing dataset + * unmodified */ - fun create(params: DatasetCreateParams): Dataset = create(params, RequestOptions.none()) + fun create(params: DatasetCreateParams): Dataset = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Dataset + fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** Get a dataset object by its id */ - fun retrieve(params: DatasetRetrieveParams): Dataset = retrieve(params, RequestOptions.none()) + fun retrieve(params: DatasetRetrieveParams): Dataset = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Dataset + fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** - * Partially update a dataset object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: DatasetUpdateParams): Dataset = update(params, RequestOptions.none()) + fun update(params: DatasetUpdateParams): Dataset = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Dataset + fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** * List out all datasets. The datasets are sorted by creation date, with the most @@ -70,87 +72,83 @@ interface DatasetService { fun list(): DatasetListPage = list(DatasetListParams.none()) /** @see [list] */ - fun list( - params: DatasetListParams = DatasetListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): DatasetListPage + fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): DatasetListPage /** @see [list] */ fun list(params: DatasetListParams = DatasetListParams.none()): DatasetListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): DatasetListPage = - list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): DatasetListPage = list(DatasetListParams.none(), requestOptions) /** Delete a dataset object by its id */ - fun delete(params: DatasetDeleteParams): Dataset = delete(params, RequestOptions.none()) + fun delete(params: DatasetDeleteParams): Dataset = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Dataset + fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** Log feedback for a set of dataset events */ fun feedback(params: DatasetFeedbackParams): FeedbackResponseSchema = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FeedbackResponseSchema + fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but + * with the parameters in the URL query rather than in the request body. For more + * complex queries, use the `POST /btql` endpoint. */ fun fetch(params: DatasetFetchParams): FetchDatasetEventsResponse = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchDatasetEventsResponse + fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchDatasetEventsResponse /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but + * with the parameters in the request body rather than in the URL query. For more + * complex queries, use the `POST /btql` endpoint. */ fun fetchPost(params: DatasetFetchPostParams): FetchDatasetEventsResponse = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchDatasetEventsResponse + fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchDatasetEventsResponse /** Insert a set of events into the dataset */ fun insert(params: DatasetInsertParams): InsertEventsResponse = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): InsertEventsResponse + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse /** Summarize dataset */ fun summarize(params: DatasetSummarizeParams): SummarizeDatasetResponse = - summarize(params, RequestOptions.none()) + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SummarizeDatasetResponse + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeDatasetResponse - /** A view of [DatasetService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [DatasetService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -159,83 +157,77 @@ interface DatasetService { */ @MustBeClosed fun create(params: DatasetCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same - * as [DatasetService.retrieve]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise + * the same as [DatasetService.retrieve]. */ @MustBeClosed fun retrieve(params: DatasetRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the - * same as [DatasetService.update]. + * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is + * otherwise the same as [DatasetService.update]. */ @MustBeClosed fun update(params: DatasetUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as * [DatasetService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(DatasetListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(DatasetListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: DatasetListParams = DatasetListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: DatasetListParams = DatasetListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: DatasetListParams = DatasetListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(DatasetListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the - * same as [DatasetService.delete]. + * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is + * otherwise the same as [DatasetService.delete]. */ @MustBeClosed fun delete(params: DatasetDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is @@ -243,59 +235,55 @@ interface DatasetService { */ @MustBeClosed fun feedback(params: DatasetFeedbackParams): HttpResponseFor = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise - * the same as [DatasetService.fetch]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is + * otherwise the same as [DatasetService.fetch]. */ @MustBeClosed fun fetch(params: DatasetFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise - * the same as [DatasetService.fetchPost]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is + * otherwise the same as [DatasetService.fetchPost]. */ @MustBeClosed fun fetchPost(params: DatasetFetchPostParams): HttpResponseFor = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise - * the same as [DatasetService.insert]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is + * otherwise the same as [DatasetService.insert]. */ @MustBeClosed fun insert(params: DatasetInsertParams): HttpResponseFor = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is @@ -303,13 +291,12 @@ interface DatasetService { */ @MustBeClosed fun summarize(params: DatasetSummarizeParams): HttpResponseFor = - summarize(params, RequestOptions.none()) + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ @MustBeClosed - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 033ed993..652d92dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -32,12 +32,12 @@ import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse -class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : - DatasetService { +class DatasetServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: DatasetService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : DatasetService { + + private val withRawResponse: DatasetService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): DatasetService.WithRawResponse = withRawResponse @@ -61,317 +61,290 @@ class DatasetServiceImpl internal constructor(private val clientOptions: ClientO // delete /v1/dataset/{dataset_id} withRawResponse().delete(params, requestOptions).parse() - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions, - ): FeedbackResponseSchema = + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = // post /v1/dataset/{dataset_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions, - ): FetchDatasetEventsResponse = + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): FetchDatasetEventsResponse = // get /v1/dataset/{dataset_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions, - ): FetchDatasetEventsResponse = + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): FetchDatasetEventsResponse = // post /v1/dataset/{dataset_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions, - ): InsertEventsResponse = + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): InsertEventsResponse = // post /v1/dataset/{dataset_id}/insert withRawResponse().insert(params, requestOptions).parse() - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions, - ): SummarizeDatasetResponse = + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): SummarizeDatasetResponse = // get /v1/dataset/{dataset_id}/summarize withRawResponse().summarize(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DatasetService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : DatasetService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: DatasetListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { DatasetListPage.of(DatasetServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: DatasetListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DatasetListPage.of(DatasetServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + summarizeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt index 843a4762..4c8e6a9a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt @@ -17,43 +17,44 @@ import com.google.errorprone.annotations.MustBeClosed interface EnvVarService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new env_var. If there is an existing env_var with the same name as the one specified - * in the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the + * one specified in the request, will return the existing env_var unmodified */ - fun create(params: EnvVarCreateParams): EnvVar = create(params, RequestOptions.none()) + fun create(params: EnvVarCreateParams): EnvVar = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar /** Get an env_var object by its id */ - fun retrieve(params: EnvVarRetrieveParams): EnvVar = retrieve(params, RequestOptions.none()) + fun retrieve(params: EnvVarRetrieveParams): EnvVar = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar /** - * Partially update an env_var object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: EnvVarUpdateParams): EnvVar = update(params, RequestOptions.none()) + fun update(params: EnvVarUpdateParams): EnvVar = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar /** * List out all env_vars. The env_vars are sorted by creation date, with the most @@ -62,41 +63,43 @@ interface EnvVarService { fun list(): EnvVarListResponse = list(EnvVarListParams.none()) /** @see [list] */ - fun list( - params: EnvVarListParams = EnvVarListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVarListResponse + fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): EnvVarListResponse /** @see [list] */ fun list(params: EnvVarListParams = EnvVarListParams.none()): EnvVarListResponse = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): EnvVarListResponse = - list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): EnvVarListResponse = list(EnvVarListParams.none(), requestOptions) /** Delete an env_var object by its id */ - fun delete(params: EnvVarDeleteParams): EnvVar = delete(params, RequestOptions.none()) + fun delete(params: EnvVarDeleteParams): EnvVar = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar /** - * Create or replace env_var. If there is an existing env_var with the same name as the one - * specified in the request, will replace the existing env_var with the provided fields + * Create or replace env_var. If there is an existing env_var with the same name as + * the one specified in the request, will replace the existing env_var with the + * provided fields */ - fun replace(params: EnvVarReplaceParams): EnvVar = replace(params, RequestOptions.none()) + fun replace(params: EnvVarReplaceParams): EnvVar = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): EnvVar + fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar - /** A view of [EnvVarService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [EnvVarService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -105,44 +108,41 @@ interface EnvVarService { */ @MustBeClosed fun create(params: EnvVarCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same - * as [EnvVarService.retrieve]. + * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise + * the same as [EnvVarService.retrieve]. */ @MustBeClosed fun retrieve(params: EnvVarRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the - * same as [EnvVarService.update]. + * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is + * otherwise the same as [EnvVarService.update]. */ @MustBeClosed fun update(params: EnvVarUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as @@ -153,36 +153,32 @@ interface EnvVarService { /** @see [list] */ @MustBeClosed - fun list( - params: EnvVarListParams = EnvVarListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: EnvVarListParams = EnvVarListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: EnvVarListParams = EnvVarListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(EnvVarListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the - * same as [EnvVarService.delete]. + * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is + * otherwise the same as [EnvVarService.delete]. */ @MustBeClosed fun delete(params: EnvVarDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as @@ -190,13 +186,12 @@ interface EnvVarService { */ @MustBeClosed fun replace(params: EnvVarReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index aa611b8f..00059edc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams -class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOptions) : - EnvVarService { +class EnvVarServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: EnvVarService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : EnvVarService { + + private val withRawResponse: EnvVarService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): EnvVarService.WithRawResponse = withRawResponse @@ -45,10 +45,7 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp // patch /v1/env_var/{env_var_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: EnvVarListParams, - requestOptions: RequestOptions, - ): EnvVarListResponse = + override fun list(params: EnvVarListParams, requestOptions: RequestOptions): EnvVarListResponse = // get /v1/env_var withRawResponse().list(params, requestOptions).parse() @@ -60,169 +57,165 @@ class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOp // put /v1/env_var withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - EnvVarService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : EnvVarService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: EnvVarCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: EnvVarRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: EnvVarUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list( - params: EnvVarListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: EnvVarListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: EnvVarDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: EnvVarReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt index fa1bcc99..2a8701e1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt @@ -11,27 +11,31 @@ import com.google.errorprone.annotations.MustBeClosed interface EvalService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into - * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and - * scoring functions. The API will then run the evaluation, create an experiment, and return the - * results along with a link to the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is + * built into the Braintrust SDK. In the Eval API, you provide pointers to a + * dataset, task function, and scoring functions. The API will then run the + * evaluation, create an experiment, and return the results along with a link to + * the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ fun create(params: EvalCreateParams): SummarizeExperimentResponse = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SummarizeExperimentResponse + fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeExperimentResponse - /** A view of [EvalService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [EvalService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -40,13 +44,12 @@ interface EvalService { */ @MustBeClosed fun create(params: EvalCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: EvalCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index e761eba5..124d8a1c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -18,52 +18,50 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse -class EvalServiceImpl internal constructor(private val clientOptions: ClientOptions) : EvalService { +class EvalServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: EvalService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : EvalService { + + private val withRawResponse: EvalService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): EvalService.WithRawResponse = withRawResponse - override fun create( - params: EvalCreateParams, - requestOptions: RequestOptions, - ): SummarizeExperimentResponse = + override fun create(params: EvalCreateParams, requestOptions: RequestOptions): SummarizeExperimentResponse = // post /v1/eval withRawResponse().create(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - EvalService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : EvalService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun create( - params: EvalCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "eval") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun create(params: EvalCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "eval") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 17bc351f..4a23c31f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -25,295 +25,278 @@ import com.google.errorprone.annotations.MustBeClosed interface ExperimentService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new experiment. If there is an existing experiment in the project with the same name - * as the one specified in the request, will return the existing experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with + * the same name as the one specified in the request, will return the existing + * experiment unmodified */ - fun create(params: ExperimentCreateParams): Experiment = create(params, RequestOptions.none()) + fun create(params: ExperimentCreateParams): Experiment = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Experiment + fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** Get an experiment object by its id */ fun retrieve(params: ExperimentRetrieveParams): Experiment = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Experiment + fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - fun update(params: ExperimentUpdateParams): Experiment = update(params, RequestOptions.none()) + fun update(params: ExperimentUpdateParams): Experiment = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Experiment + fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** - * List out all experiments. The experiments are sorted by creation date, with the most - * recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the + * most recently-created experiments coming first */ fun list(): ExperimentListPage = list(ExperimentListParams.none()) /** @see [list] */ - fun list( - params: ExperimentListParams = ExperimentListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ExperimentListPage + fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ExperimentListPage /** @see [list] */ fun list(params: ExperimentListParams = ExperimentListParams.none()): ExperimentListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ExperimentListPage = - list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ExperimentListPage = list(ExperimentListParams.none(), requestOptions) /** Delete an experiment object by its id */ - fun delete(params: ExperimentDeleteParams): Experiment = delete(params, RequestOptions.none()) + fun delete(params: ExperimentDeleteParams): Experiment = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Experiment + fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** Log feedback for a set of experiment events */ fun feedback(params: ExperimentFeedbackParams): FeedbackResponseSchema = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FeedbackResponseSchema + fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the - * parameters in the URL query rather than in the request body. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, + * but with the parameters in the URL query rather than in the request body. For + * more complex queries, use the `POST /btql` endpoint. */ fun fetch(params: ExperimentFetchParams): FetchExperimentEventsResponse = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchExperimentEventsResponse + fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchExperimentEventsResponse /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ fun fetchPost(params: ExperimentFetchPostParams): FetchExperimentEventsResponse = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchExperimentEventsResponse + fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchExperimentEventsResponse /** Insert a set of events into the experiment */ fun insert(params: ExperimentInsertParams): InsertEventsResponse = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): InsertEventsResponse + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse /** Summarize experiment */ fun summarize(params: ExperimentSummarizeParams): SummarizeExperimentResponse = - summarize(params, RequestOptions.none()) + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SummarizeExperimentResponse + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeExperimentResponse - /** A view of [ExperimentService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ExperimentService] that provides access to raw HTTP responses for + * each method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as - * [ExperimentService.create]. + * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same + * as [ExperimentService.create]. */ @MustBeClosed fun create(params: ExperimentCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentService.retrieve]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentService.retrieve]. */ @MustBeClosed fun retrieve(params: ExperimentRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentService.update]. + * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentService.update]. */ @MustBeClosed fun update(params: ExperimentUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as - * [ExperimentService.list]. + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same + * as [ExperimentService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ExperimentListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ExperimentListParams = ExperimentListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ExperimentListParams = ExperimentListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ExperimentListParams = ExperimentListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ExperimentListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise - * the same as [ExperimentService.delete]. + * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is + * otherwise the same as [ExperimentService.delete]. */ @MustBeClosed fun delete(params: ExperimentDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is - * otherwise the same as [ExperimentService.feedback]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, + * but is otherwise the same as [ExperimentService.feedback]. */ @MustBeClosed fun feedback(params: ExperimentFeedbackParams): HttpResponseFor = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is - * otherwise the same as [ExperimentService.fetch]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but + * is otherwise the same as [ExperimentService.fetch]. */ @MustBeClosed fun fetch(params: ExperimentFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is - * otherwise the same as [ExperimentService.fetchPost]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but + * is otherwise the same as [ExperimentService.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: ExperimentFetchPostParams - ): HttpResponseFor = fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ExperimentFetchPostParams): HttpResponseFor = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is - * otherwise the same as [ExperimentService.insert]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, + * but is otherwise the same as [ExperimentService.insert]. */ @MustBeClosed fun insert(params: ExperimentInsertParams): HttpResponseFor = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is - * otherwise the same as [ExperimentService.summarize]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, + * but is otherwise the same as [ExperimentService.summarize]. */ @MustBeClosed - fun summarize( - params: ExperimentSummarizeParams - ): HttpResponseFor = summarize(params, RequestOptions.none()) + fun summarize(params: ExperimentSummarizeParams): HttpResponseFor = + summarize( + params, RequestOptions.none() + ) /** @see [summarize] */ @MustBeClosed - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 7ec0526e..2fdf032d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -32,361 +32,319 @@ import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse -class ExperimentServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ExperimentService { +class ExperimentServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ExperimentService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ExperimentService { + + private val withRawResponse: ExperimentService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ExperimentService.WithRawResponse = withRawResponse - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions, - ): Experiment = + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): Experiment = // post /v1/experiment withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions, - ): Experiment = + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): Experiment = // get /v1/experiment/{experiment_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions, - ): Experiment = + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): Experiment = // patch /v1/experiment/{experiment_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions, - ): ExperimentListPage = + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): ExperimentListPage = // get /v1/experiment withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions, - ): Experiment = + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): Experiment = // delete /v1/experiment/{experiment_id} withRawResponse().delete(params, requestOptions).parse() - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions, - ): FeedbackResponseSchema = + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = // post /v1/experiment/{experiment_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions, - ): FetchExperimentEventsResponse = + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): FetchExperimentEventsResponse = // get /v1/experiment/{experiment_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions, - ): FetchExperimentEventsResponse = + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): FetchExperimentEventsResponse = // post /v1/experiment/{experiment_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions, - ): InsertEventsResponse = + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): InsertEventsResponse = // post /v1/experiment/{experiment_id}/insert withRawResponse().insert(params, requestOptions).parse() - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions, - ): SummarizeExperimentResponse = + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): SummarizeExperimentResponse = // get /v1/experiment/{experiment_id}/summarize withRawResponse().summarize(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ExperimentService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ExperimentService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ExperimentListPage.of(ExperimentServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ExperimentListPage.of(ExperimentServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { summarizeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + summarizeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 2002b104..0a53085d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -20,43 +20,45 @@ import java.util.Optional interface FunctionService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified + * Create a new function. If there is an existing function in the project with the + * same slug as the one specified in the request, will return the existing function + * unmodified */ - fun create(params: FunctionCreateParams): Function = create(params, RequestOptions.none()) + fun create(params: FunctionCreateParams): Function = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** Get a function object by its id */ - fun retrieve(params: FunctionRetrieveParams): Function = retrieve(params, RequestOptions.none()) + fun retrieve(params: FunctionRetrieveParams): Function = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** - * Partially update a function object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: FunctionUpdateParams): Function = update(params, RequestOptions.none()) + fun update(params: FunctionUpdateParams): Function = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** * List out all functions. The functions are sorted by creation date, with the most @@ -65,98 +67,95 @@ interface FunctionService { fun list(): FunctionListPage = list(FunctionListParams.none()) /** @see [list] */ - fun list( - params: FunctionListParams = FunctionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): FunctionListPage + fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): FunctionListPage /** @see [list] */ fun list(params: FunctionListParams = FunctionListParams.none()): FunctionListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): FunctionListPage = - list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): FunctionListPage = list(FunctionListParams.none(), requestOptions) /** Delete a function object by its id */ - fun delete(params: FunctionDeleteParams): Function = delete(params, RequestOptions.none()) + fun delete(params: FunctionDeleteParams): Function = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** Invoke a function. */ fun invoke(params: FunctionInvokeParams): Optional = - invoke(params, RequestOptions.none()) + invoke( + params, RequestOptions.none() + ) /** @see [invoke] */ - fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Optional + fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): Optional /** - * Create or replace function. If there is an existing function in the project with the same - * slug as the one specified in the request, will replace the existing function with the - * provided fields + * Create or replace function. If there is an existing function in the project with + * the same slug as the one specified in the request, will replace the existing + * function with the provided fields */ - fun replace(params: FunctionReplaceParams): Function = replace(params, RequestOptions.none()) + fun replace(params: FunctionReplaceParams): Function = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Function + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Function - /** A view of [FunctionService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [FunctionService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as - * [FunctionService.create]. + * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same + * as [FunctionService.create]. */ @MustBeClosed fun create(params: FunctionCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the - * same as [FunctionService.retrieve]. + * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is + * otherwise the same as [FunctionService.retrieve]. */ @MustBeClosed fun retrieve(params: FunctionRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the - * same as [FunctionService.update]. + * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is + * otherwise the same as [FunctionService.update]. */ @MustBeClosed fun update(params: FunctionUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as @@ -167,52 +166,46 @@ interface FunctionService { /** @see [list] */ @MustBeClosed - fun list( - params: FunctionListParams = FunctionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: FunctionListParams = FunctionListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: FunctionListParams = FunctionListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(FunctionListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the - * same as [FunctionService.delete]. + * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is + * otherwise the same as [FunctionService.delete]. */ @MustBeClosed fun delete(params: FunctionDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is * otherwise the same as [FunctionService.invoke]. */ @MustBeClosed - fun invoke( - params: FunctionInvokeParams - ): HttpResponseFor> = invoke(params, RequestOptions.none()) + fun invoke(params: FunctionInvokeParams): HttpResponseFor> = + invoke( + params, RequestOptions.none() + ) /** @see [invoke] */ @MustBeClosed - fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> + fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor> /** * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as @@ -220,13 +213,12 @@ interface FunctionService { */ @MustBeClosed fun replace(params: FunctionReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index cf7eb4ad..0e8d7fb5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -27,12 +27,12 @@ import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional -class FunctionServiceImpl internal constructor(private val clientOptions: ClientOptions) : - FunctionService { +class FunctionServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: FunctionService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : FunctionService { + + private val withRawResponse: FunctionService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): FunctionService.WithRawResponse = withRawResponse @@ -40,10 +40,7 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client // post /v1/function withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions, - ): Function = + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): Function = // get /v1/function/{function_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -51,10 +48,7 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client // patch /v1/function/{function_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions, - ): FunctionListPage = + override fun list(params: FunctionListParams, requestOptions: RequestOptions): FunctionListPage = // get /v1/function withRawResponse().list(params, requestOptions).parse() @@ -62,10 +56,7 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client // delete /v1/function/{function_id} withRawResponse().delete(params, requestOptions).parse() - override fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions, - ): Optional = + override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): Optional = // post /v1/function/{function_id}/invoke withRawResponse().invoke(params, requestOptions).parse() @@ -73,199 +64,194 @@ class FunctionServiceImpl internal constructor(private val clientOptions: Client // put /v1/function withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - FunctionService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : FunctionService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { FunctionListPage.of(FunctionServiceImpl(clientOptions), params, it) } - } + override fun list(params: FunctionListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + FunctionListPage.of(FunctionServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val invokeHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val invokeHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun invoke( - params: FunctionInvokeParams, - requestOptions: RequestOptions, - ): HttpResponseFor> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { invokeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } - } - } - } + override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): HttpResponseFor> { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function", params.getPathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + invokeHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index 5249cbc6..b5e07be5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -17,86 +17,89 @@ import com.google.errorprone.annotations.MustBeClosed interface GroupService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one + * specified in the request, will return the existing group unmodified */ - fun create(params: GroupCreateParams): Group = create(params, RequestOptions.none()) + fun create(params: GroupCreateParams): Group = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** Get a group object by its id */ - fun retrieve(params: GroupRetrieveParams): Group = retrieve(params, RequestOptions.none()) + fun retrieve(params: GroupRetrieveParams): Group = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: GroupUpdateParams): Group = update(params, RequestOptions.none()) + fun update(params: GroupUpdateParams): Group = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** - * List out all groups. The groups are sorted by creation date, with the most recently-created - * groups coming first + * List out all groups. The groups are sorted by creation date, with the most + * recently-created groups coming first */ fun list(): GroupListPage = list(GroupListParams.none()) /** @see [list] */ - fun list( - params: GroupListParams = GroupListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): GroupListPage + fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): GroupListPage /** @see [list] */ fun list(params: GroupListParams = GroupListParams.none()): GroupListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): GroupListPage = - list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): GroupListPage = list(GroupListParams.none(), requestOptions) /** Delete a group object by its id */ - fun delete(params: GroupDeleteParams): Group = delete(params, RequestOptions.none()) + fun delete(params: GroupDeleteParams): Group = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** - * Create or replace group. If there is an existing group with the same name as the one - * specified in the request, will replace the existing group with the provided fields + * Create or replace group. If there is an existing group with the same name as the + * one specified in the request, will replace the existing group with the provided + * fields */ - fun replace(params: GroupReplaceParams): Group = replace(params, RequestOptions.none()) + fun replace(params: GroupReplaceParams): Group = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Group + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Group - /** A view of [GroupService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [GroupService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -105,82 +108,77 @@ interface GroupService { */ @MustBeClosed fun create(params: GroupCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as - * [GroupService.retrieve]. + * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the + * same as [GroupService.retrieve]. */ @MustBeClosed fun retrieve(params: GroupRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same - * as [GroupService.update]. + * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise + * the same as [GroupService.update]. */ @MustBeClosed fun update(params: GroupUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as * [GroupService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(GroupListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(GroupListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: GroupListParams = GroupListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: GroupListParams = GroupListParams.none()): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(GroupListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same - * as [GroupService.delete]. + * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise + * the same as [GroupService.delete]. */ @MustBeClosed fun delete(params: GroupDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as @@ -188,13 +186,12 @@ interface GroupService { */ @MustBeClosed fun replace(params: GroupReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 84a146af..85b6d8c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -class GroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : - GroupService { +class GroupServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: GroupService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : GroupService { + + private val withRawResponse: GroupService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): GroupService.WithRawResponse = withRawResponse @@ -57,171 +57,168 @@ class GroupServiceImpl internal constructor(private val clientOptions: ClientOpt // put /v1/group withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - GroupService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : GroupService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: GroupCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: GroupCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: GroupListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { GroupListPage.of(GroupServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: GroupListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + GroupListPage.of(GroupServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index b2ddae2c..969b1911 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -16,7 +16,8 @@ import com.google.errorprone.annotations.MustBeClosed interface OrganizationService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -24,60 +25,56 @@ interface OrganizationService { /** Get an organization object by its id */ fun retrieve(params: OrganizationRetrieveParams): Organization = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Organization + fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Organization /** - * Partially update an organization object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: OrganizationUpdateParams): Organization = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Organization + fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Organization /** - * List out all organizations. The organizations are sorted by creation date, with the most - * recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with + * the most recently-created organizations coming first */ fun list(): OrganizationListPage = list(OrganizationListParams.none()) /** @see [list] */ - fun list( - params: OrganizationListParams = OrganizationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): OrganizationListPage + fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): OrganizationListPage /** @see [list] */ fun list(params: OrganizationListParams = OrganizationListParams.none()): OrganizationListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): OrganizationListPage = - list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): OrganizationListPage = list(OrganizationListParams.none(), requestOptions) /** Delete an organization object by its id */ fun delete(params: OrganizationDeleteParams): Organization = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Organization + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Organization /** - * A view of [OrganizationService] that provides access to raw HTTP responses for each method. + * A view of [OrganizationService] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { @@ -89,68 +86,62 @@ interface OrganizationService { */ @MustBeClosed fun retrieve(params: OrganizationRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is - * otherwise the same as [OrganizationService.update]. + * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but + * is otherwise the same as [OrganizationService.update]. */ @MustBeClosed fun update(params: OrganizationUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as - * [OrganizationService.list]. + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the + * same as [OrganizationService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(OrganizationListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: OrganizationListParams = OrganizationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: OrganizationListParams = OrganizationListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: OrganizationListParams = OrganizationListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(OrganizationListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is - * otherwise the same as [OrganizationService.delete]. + * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but + * is otherwise the same as [OrganizationService.delete]. */ @MustBeClosed fun delete(params: OrganizationDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index b6af330b..e3af7e0b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.OrganizationUpdateParams import com.braintrustdata.api.services.blocking.organizations.MemberService import com.braintrustdata.api.services.blocking.organizations.MemberServiceImpl -class OrganizationServiceImpl internal constructor(private val clientOptions: ClientOptions) : - OrganizationService { +class OrganizationServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: OrganizationService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : OrganizationService { + + private val withRawResponse: OrganizationService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } private val members: MemberService by lazy { MemberServiceImpl(clientOptions) } @@ -37,153 +37,136 @@ class OrganizationServiceImpl internal constructor(private val clientOptions: Cl override fun members(): MemberService = members - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions, - ): Organization = + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): Organization = // get /v1/organization/{organization_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions, - ): Organization = + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): Organization = // patch /v1/organization/{organization_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions, - ): OrganizationListPage = + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): OrganizationListPage = // get /v1/organization withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions, - ): Organization = + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): Organization = // delete /v1/organization/{organization_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - OrganizationService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : OrganizationService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val members: MemberService.WithRawResponse by lazy { - MemberServiceImpl.WithRawResponseImpl(clientOptions) - } + private val members: MemberService.WithRawResponse by lazy { MemberServiceImpl.WithRawResponseImpl(clientOptions) } override fun members(): MemberService.WithRawResponse = members - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - OrganizationListPage.of(OrganizationServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + OrganizationListPage.of(OrganizationServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index 5f9df9bc..338717ee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -17,195 +17,182 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectScoreService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_score. If there is an existing project_score in the project with the - * same name as the one specified in the request, will return the existing project_score - * unmodified + * Create a new project_score. If there is an existing project_score in the project + * with the same name as the one specified in the request, will return the existing + * project_score unmodified */ fun create(params: ProjectScoreCreateParams): ProjectScore = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** Get a project_score object by its id */ fun retrieve(params: ProjectScoreRetrieveParams): ProjectScore = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ fun update(params: ProjectScoreUpdateParams): ProjectScore = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ fun list(): ProjectScoreListPage = list(ProjectScoreListParams.none()) /** @see [list] */ - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScoreListPage + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectScoreListPage /** @see [list] */ fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): ProjectScoreListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectScoreListPage = - list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectScoreListPage = list(ProjectScoreListParams.none(), requestOptions) /** Delete a project_score object by its id */ fun delete(params: ProjectScoreDeleteParams): ProjectScore = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** - * Create or replace project_score. If there is an existing project_score in the project with - * the same name as the one specified in the request, will replace the existing project_score - * with the provided fields + * Create or replace project_score. If there is an existing project_score in the + * project with the same name as the one specified in the request, will replace the + * existing project_score with the provided fields */ fun replace(params: ProjectScoreReplaceParams): ProjectScore = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectScore + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** - * A view of [ProjectScoreService] that provides access to raw HTTP responses for each method. + * A view of [ProjectScoreService] that provides access to raw HTTP responses for + * each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as - * [ProjectScoreService.create]. + * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the + * same as [ProjectScoreService.create]. */ @MustBeClosed fun create(params: ProjectScoreCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreService.retrieve]. + * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but + * is otherwise the same as [ProjectScoreService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectScoreRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreService.update]. + * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, + * but is otherwise the same as [ProjectScoreService.update]. */ @MustBeClosed fun update(params: ProjectScoreUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as - * [ProjectScoreService.list]. + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the + * same as [ProjectScoreService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ProjectScoreListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ProjectScoreListParams = ProjectScoreListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectScoreListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is - * otherwise the same as [ProjectScoreService.delete]. + * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, + * but is otherwise the same as [ProjectScoreService.delete]. */ @MustBeClosed fun delete(params: ProjectScoreDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as - * [ProjectScoreService.replace]. + * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the + * same as [ProjectScoreService.replace]. */ @MustBeClosed fun replace(params: ProjectScoreReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index ec7b0393..f6dad76f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -24,224 +24,201 @@ import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -class ProjectScoreServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectScoreService { +class ProjectScoreServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectScoreService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectScoreService { + + private val withRawResponse: ProjectScoreService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ProjectScoreService.WithRawResponse = withRawResponse - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): ProjectScore = // post /v1/project_score withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): ProjectScore = // get /v1/project_score/{project_score_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): ProjectScore = // patch /v1/project_score/{project_score_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions, - ): ProjectScoreListPage = + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): ProjectScoreListPage = // get /v1/project_score withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): ProjectScore = // delete /v1/project_score/{project_score_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions, - ): ProjectScore = + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): ProjectScore = // put /v1/project_score withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectScoreService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ProjectScoreService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectScoreListPage.of(ProjectScoreServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectScoreListPage.of(ProjectScoreServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index 197931d5..c48696e5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -17,45 +17,46 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse fun logs(): LogService /** - * Create a new project. If there is an existing project with the same name as the one specified - * in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the + * one specified in the request, will return the existing project unmodified */ - fun create(params: ProjectCreateParams): Project = create(params, RequestOptions.none()) + fun create(params: ProjectCreateParams): Project = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Project + fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Project /** Get a project object by its id */ - fun retrieve(params: ProjectRetrieveParams): Project = retrieve(params, RequestOptions.none()) + fun retrieve(params: ProjectRetrieveParams): Project = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Project + fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Project /** - * Partially update a project object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: ProjectUpdateParams): Project = update(params, RequestOptions.none()) + fun update(params: ProjectUpdateParams): Project = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Project + fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Project /** * List out all projects. The projects are sorted by creation date, with the most @@ -64,29 +65,30 @@ interface ProjectService { fun list(): ProjectListPage = list(ProjectListParams.none()) /** @see [list] */ - fun list( - params: ProjectListParams = ProjectListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectListPage + fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectListPage /** @see [list] */ fun list(params: ProjectListParams = ProjectListParams.none()): ProjectListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectListPage = - list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectListPage = list(ProjectListParams.none(), requestOptions) /** Delete a project object by its id */ - fun delete(params: ProjectDeleteParams): Project = delete(params, RequestOptions.none()) + fun delete(params: ProjectDeleteParams): Project = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Project + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Project - /** A view of [ProjectService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ProjectService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { fun logs(): LogService.WithRawResponse @@ -97,82 +99,76 @@ interface ProjectService { */ @MustBeClosed fun create(params: ProjectCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same - * as [ProjectService.retrieve]. + * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise + * the same as [ProjectService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the - * same as [ProjectService.update]. + * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is + * otherwise the same as [ProjectService.update]. */ @MustBeClosed fun update(params: ProjectUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as * [ProjectService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(ProjectListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(ProjectListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectListParams = ProjectListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ProjectListParams = ProjectListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ProjectListParams = ProjectListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the - * same as [ProjectService.delete]. + * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is + * otherwise the same as [ProjectService.delete]. */ @MustBeClosed fun delete(params: ProjectDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 502035c3..5f78530d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -25,12 +25,12 @@ import com.braintrustdata.api.models.ProjectUpdateParams import com.braintrustdata.api.services.blocking.projects.LogService import com.braintrustdata.api.services.blocking.projects.LogServiceImpl -class ProjectServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectService { +class ProjectServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectService { + + private val withRawResponse: ProjectService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } private val logs: LogService by lazy { LogServiceImpl(clientOptions) } @@ -58,150 +58,146 @@ class ProjectServiceImpl internal constructor(private val clientOptions: ClientO // delete /v1/project/{project_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ProjectService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val logs: LogService.WithRawResponse by lazy { - LogServiceImpl.WithRawResponseImpl(clientOptions) - } + private val logs: LogService.WithRawResponse by lazy { LogServiceImpl.WithRawResponseImpl(clientOptions) } override fun logs(): LogService.WithRawResponse = logs - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectListPage.of(ProjectServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectListPage.of(ProjectServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index d06930e4..8c267908 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -17,120 +17,119 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectTagService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will return the existing project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project + * with the same name as the one specified in the request, will return the existing + * project_tag unmodified */ - fun create(params: ProjectTagCreateParams): ProjectTag = create(params, RequestOptions.none()) + fun create(params: ProjectTagCreateParams): ProjectTag = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** Get a project_tag object by its id */ fun retrieve(params: ProjectTagRetrieveParams): ProjectTag = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - fun update(params: ProjectTagUpdateParams): ProjectTag = update(params, RequestOptions.none()) + fun update(params: ProjectTagUpdateParams): ProjectTag = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ fun list(): ProjectTagListPage = list(ProjectTagListParams.none()) /** @see [list] */ - fun list( - params: ProjectTagListParams = ProjectTagListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTagListPage + fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectTagListPage /** @see [list] */ fun list(params: ProjectTagListParams = ProjectTagListParams.none()): ProjectTagListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectTagListPage = - list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectTagListPage = list(ProjectTagListParams.none(), requestOptions) /** Delete a project_tag object by its id */ - fun delete(params: ProjectTagDeleteParams): ProjectTag = delete(params, RequestOptions.none()) + fun delete(params: ProjectTagDeleteParams): ProjectTag = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** - * Create or replace project_tag. If there is an existing project_tag in the project with the - * same name as the one specified in the request, will replace the existing project_tag with the - * provided fields + * Create or replace project_tag. If there is an existing project_tag in the + * project with the same name as the one specified in the request, will replace the + * existing project_tag with the provided fields */ fun replace(params: ProjectTagReplaceParams): ProjectTag = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProjectTag + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag - /** A view of [ProjectTagService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ProjectTagService] that provides access to raw HTTP responses for + * each method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as - * [ProjectTagService.create]. + * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the + * same as [ProjectTagService.create]. */ @MustBeClosed fun create(params: ProjectTagCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise - * the same as [ProjectTagService.retrieve]. + * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectTagRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is @@ -138,68 +137,62 @@ interface ProjectTagService { */ @MustBeClosed fun update(params: ProjectTagUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as - * [ProjectTagService.list]. + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same + * as [ProjectTagService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ProjectTagListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: ProjectTagListParams = ProjectTagListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: ProjectTagListParams = ProjectTagListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: ProjectTagListParams = ProjectTagListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectTagListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is - * otherwise the same as [ProjectTagService.delete]. + * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but + * is otherwise the same as [ProjectTagService.delete]. */ @MustBeClosed fun delete(params: ProjectTagDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as - * [ProjectTagService.replace]. + * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same + * as [ProjectTagService.replace]. */ @MustBeClosed fun replace(params: ProjectTagReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 79f8d590..94aaba01 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -24,222 +24,201 @@ import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -class ProjectTagServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectTagService { +class ProjectTagServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ProjectTagService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ProjectTagService { + + private val withRawResponse: ProjectTagService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ProjectTagService.WithRawResponse = withRawResponse - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): ProjectTag = // post /v1/project_tag withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): ProjectTag = // get /v1/project_tag/{project_tag_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): ProjectTag = // patch /v1/project_tag/{project_tag_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions, - ): ProjectTagListPage = + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): ProjectTagListPage = // get /v1/project_tag withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): ProjectTag = // delete /v1/project_tag/{project_tag_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions, - ): ProjectTag = + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): ProjectTag = // put /v1/project_tag withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProjectTagService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ProjectTagService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ProjectTagListPage.of(ProjectTagServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectTagListPage.of(ProjectTagServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index e3d04a03..c235c86f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -17,86 +17,90 @@ import com.google.errorprone.annotations.MustBeClosed interface PromptService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified + * Create a new prompt. If there is an existing prompt in the project with the same + * slug as the one specified in the request, will return the existing prompt + * unmodified */ - fun create(params: PromptCreateParams): Prompt = create(params, RequestOptions.none()) + fun create(params: PromptCreateParams): Prompt = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** Get a prompt object by its id */ - fun retrieve(params: PromptRetrieveParams): Prompt = retrieve(params, RequestOptions.none()) + fun retrieve(params: PromptRetrieveParams): Prompt = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** - * Partially update a prompt object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - fun update(params: PromptUpdateParams): Prompt = update(params, RequestOptions.none()) + fun update(params: PromptUpdateParams): Prompt = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** - * List out all prompts. The prompts are sorted by creation date, with the most recently-created - * prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most + * recently-created prompts coming first */ fun list(): PromptListPage = list(PromptListParams.none()) /** @see [list] */ - fun list( - params: PromptListParams = PromptListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): PromptListPage + fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): PromptListPage /** @see [list] */ fun list(params: PromptListParams = PromptListParams.none()): PromptListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): PromptListPage = - list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): PromptListPage = list(PromptListParams.none(), requestOptions) /** Delete a prompt object by its id */ - fun delete(params: PromptDeleteParams): Prompt = delete(params, RequestOptions.none()) + fun delete(params: PromptDeleteParams): Prompt = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as - * the one specified in the request, will replace the existing prompt with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the + * same slug as the one specified in the request, will replace the existing prompt + * with the provided fields */ - fun replace(params: PromptReplaceParams): Prompt = replace(params, RequestOptions.none()) + fun replace(params: PromptReplaceParams): Prompt = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Prompt + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt - /** A view of [PromptService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [PromptService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -105,83 +109,77 @@ interface PromptService { */ @MustBeClosed fun create(params: PromptCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same - * as [PromptService.retrieve]. + * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise + * the same as [PromptService.retrieve]. */ @MustBeClosed fun retrieve(params: PromptRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same - * as [PromptService.update]. + * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise + * the same as [PromptService.update]. */ @MustBeClosed fun update(params: PromptUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as * [PromptService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(PromptListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(PromptListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: PromptListParams = PromptListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: PromptListParams = PromptListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: PromptListParams = PromptListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(PromptListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the - * same as [PromptService.delete]. + * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is + * otherwise the same as [PromptService.delete]. */ @MustBeClosed fun delete(params: PromptDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as @@ -189,13 +187,12 @@ interface PromptService { */ @MustBeClosed fun replace(params: PromptReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index 7736249d..b8603315 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -class PromptServiceImpl internal constructor(private val clientOptions: ClientOptions) : - PromptService { +class PromptServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: PromptService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : PromptService { + + private val withRawResponse: PromptService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): PromptService.WithRawResponse = withRawResponse @@ -57,171 +57,168 @@ class PromptServiceImpl internal constructor(private val clientOptions: ClientOp // put /v1/prompt withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - PromptService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : PromptService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: PromptCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: PromptCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: PromptListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { PromptListPage.of(PromptServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: PromptListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + PromptListPage.of(PromptServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index a913ecca..b1095a40 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -17,86 +17,89 @@ import com.google.errorprone.annotations.MustBeClosed interface RoleService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one + * specified in the request, will return the existing role unmodified */ - fun create(params: RoleCreateParams): Role = create(params, RequestOptions.none()) + fun create(params: RoleCreateParams): Role = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** Get a role object by its id */ - fun retrieve(params: RoleRetrieveParams): Role = retrieve(params, RequestOptions.none()) + fun retrieve(params: RoleRetrieveParams): Role = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ - fun update(params: RoleUpdateParams): Role = update(params, RequestOptions.none()) + fun update(params: RoleUpdateParams): Role = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** - * List out all roles. The roles are sorted by creation date, with the most recently-created - * roles coming first + * List out all roles. The roles are sorted by creation date, with the most + * recently-created roles coming first */ fun list(): RoleListPage = list(RoleListParams.none()) /** @see [list] */ - fun list( - params: RoleListParams = RoleListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): RoleListPage + fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): RoleListPage /** @see [list] */ fun list(params: RoleListParams = RoleListParams.none()): RoleListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): RoleListPage = - list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): RoleListPage = list(RoleListParams.none(), requestOptions) /** Delete a role object by its id */ - fun delete(params: RoleDeleteParams): Role = delete(params, RequestOptions.none()) + fun delete(params: RoleDeleteParams): Role = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** - * Create or replace role. If there is an existing role with the same name as the one specified - * in the request, will replace the existing role with the provided fields + * Create or replace role. If there is an existing role with the same name as the + * one specified in the request, will replace the existing role with the provided + * fields */ - fun replace(params: RoleReplaceParams): Role = replace(params, RequestOptions.none()) + fun replace(params: RoleReplaceParams): Role = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Role + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Role - /** A view of [RoleService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [RoleService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -105,82 +108,77 @@ interface RoleService { */ @MustBeClosed fun create(params: RoleCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as - * [RoleService.retrieve]. + * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the + * same as [RoleService.retrieve]. */ @MustBeClosed fun retrieve(params: RoleRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as - * [RoleService.update]. + * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the + * same as [RoleService.update]. */ @MustBeClosed fun update(params: RoleUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as * [RoleService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(RoleListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(RoleListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: RoleListParams = RoleListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: RoleListParams = RoleListParams.none()): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(RoleListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as - * [RoleService.delete]. + * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise + * the same as [RoleService.delete]. */ @MustBeClosed fun delete(params: RoleDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as @@ -188,13 +186,12 @@ interface RoleService { */ @MustBeClosed fun replace(params: RoleReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 8c0a69cb..7add91aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -24,11 +24,12 @@ import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -class RoleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RoleService { +class RoleServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: RoleService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : RoleService { + + private val withRawResponse: RoleService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): RoleService.WithRawResponse = withRawResponse @@ -56,171 +57,168 @@ class RoleServiceImpl internal constructor(private val clientOptions: ClientOpti // put /v1/role withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - RoleService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : RoleService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: RoleCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: RoleCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: RoleListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { RoleListPage.of(RoleServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: RoleListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + RoleListPage.of(RoleServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt index f8630cc6..cd1bc3c5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt @@ -17,119 +17,119 @@ import com.google.errorprone.annotations.MustBeClosed interface SpanIframeService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new span_iframe. If there is an existing span_iframe with the same name as the one - * specified in the request, will return the existing span_iframe unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name + * as the one specified in the request, will return the existing span_iframe + * unmodified */ - fun create(params: SpanIframeCreateParams): SpanIFrame = create(params, RequestOptions.none()) + fun create(params: SpanIframeCreateParams): SpanIFrame = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame /** Get a span_iframe object by its id */ fun retrieve(params: SpanIframeRetrieveParams): SpanIFrame = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame /** - * Partially update a span_iframe object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - fun update(params: SpanIframeUpdateParams): SpanIFrame = update(params, RequestOptions.none()) + fun update(params: SpanIframeUpdateParams): SpanIFrame = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame /** - * List out all span_iframes. The span_iframes are sorted by creation date, with the most - * recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with + * the most recently-created span_iframes coming first */ fun list(): SpanIframeListPage = list(SpanIframeListParams.none()) /** @see [list] */ - fun list( - params: SpanIframeListParams = SpanIframeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIframeListPage + fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): SpanIframeListPage /** @see [list] */ fun list(params: SpanIframeListParams = SpanIframeListParams.none()): SpanIframeListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): SpanIframeListPage = - list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): SpanIframeListPage = list(SpanIframeListParams.none(), requestOptions) /** Delete a span_iframe object by its id */ - fun delete(params: SpanIframeDeleteParams): SpanIFrame = delete(params, RequestOptions.none()) + fun delete(params: SpanIframeDeleteParams): SpanIFrame = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame /** - * Create or replace span_iframe. If there is an existing span_iframe with the same name as the - * one specified in the request, will replace the existing span_iframe with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same + * name as the one specified in the request, will replace the existing span_iframe + * with the provided fields */ fun replace(params: SpanIframeReplaceParams): SpanIFrame = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SpanIFrame + fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame - /** A view of [SpanIframeService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [SpanIframeService] that provides access to raw HTTP responses for + * each method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as - * [SpanIframeService.create]. + * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the + * same as [SpanIframeService.create]. */ @MustBeClosed fun create(params: SpanIframeCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise - * the same as [SpanIframeService.retrieve]. + * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeService.retrieve]. */ @MustBeClosed fun retrieve(params: SpanIframeRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is @@ -137,68 +137,62 @@ interface SpanIframeService { */ @MustBeClosed fun update(params: SpanIframeUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as - * [SpanIframeService.list]. + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same + * as [SpanIframeService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(SpanIframeListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: SpanIframeListParams = SpanIframeListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list( - params: SpanIframeListParams = SpanIframeListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) + fun list(params: SpanIframeListParams = SpanIframeListParams.none()): HttpResponseFor = + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(SpanIframeListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is - * otherwise the same as [SpanIframeService.delete]. + * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but + * is otherwise the same as [SpanIframeService.delete]. */ @MustBeClosed fun delete(params: SpanIframeDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as - * [SpanIframeService.replace]. + * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same + * as [SpanIframeService.replace]. */ @MustBeClosed fun replace(params: SpanIframeReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt index 33029900..0e29471d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -24,222 +24,201 @@ import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams -class SpanIframeServiceImpl internal constructor(private val clientOptions: ClientOptions) : - SpanIframeService { +class SpanIframeServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: SpanIframeService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : SpanIframeService { + + private val withRawResponse: SpanIframeService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): SpanIframeService.WithRawResponse = withRawResponse - override fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): SpanIFrame = // post /v1/span_iframe withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): SpanIFrame = // get /v1/span_iframe/{span_iframe_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): SpanIFrame = // patch /v1/span_iframe/{span_iframe_id} withRawResponse().update(params, requestOptions).parse() - override fun list( - params: SpanIframeListParams, - requestOptions: RequestOptions, - ): SpanIframeListPage = + override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): SpanIframeListPage = // get /v1/span_iframe withRawResponse().list(params, requestOptions).parse() - override fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): SpanIFrame = // delete /v1/span_iframe/{span_iframe_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions, - ): SpanIFrame = + override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): SpanIFrame = // put /v1/span_iframe withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - SpanIframeService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : SpanIframeService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: SpanIframeCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: SpanIframeRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: SpanIframeUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: SpanIframeListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { SpanIframeListPage.of(SpanIframeServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SpanIframeListPage.of(SpanIframeServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: SpanIframeDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: SpanIframeReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index f7d77d83..831f140a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -10,28 +10,33 @@ import com.google.errorprone.annotations.MustBeClosed interface TopLevelService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ + /** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ fun helloWorld(): String = helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): String + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): String /** @see [helloWorld] */ fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): String = - helloWorld(params, RequestOptions.none()) + helloWorld( + params, RequestOptions.none() + ) /** @see [helloWorld] */ - fun helloWorld(requestOptions: RequestOptions): String = - helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): String = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) - /** A view of [TopLevelService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [TopLevelService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -43,20 +48,17 @@ interface TopLevelService { /** @see [helloWorld] */ @MustBeClosed - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [helloWorld] */ @MustBeClosed - fun helloWorld( - params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() - ): HttpResponseFor = helloWorld(params, RequestOptions.none()) + fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): HttpResponseFor = + helloWorld( + params, RequestOptions.none() + ) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(requestOptions: RequestOptions): HttpResponseFor = - helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): HttpResponseFor = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 2bee0c27..0b9e70ab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -16,43 +16,44 @@ import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams -class TopLevelServiceImpl internal constructor(private val clientOptions: ClientOptions) : - TopLevelService { +class TopLevelServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: TopLevelService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : TopLevelService { + + private val withRawResponse: TopLevelService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): TopLevelService.WithRawResponse = withRawResponse - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions, - ): String = + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): String = // get /v1 withRawResponse().helloWorld(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TopLevelService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : TopLevelService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = - stringHandler().withErrorHandler(errorHandler) - - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { response.use { helloWorldHandler.handle(it) } } + private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) + + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + helloWorldHandler.handle(it) + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index 8a297070..63bda6ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -13,78 +13,78 @@ import com.google.errorprone.annotations.MustBeClosed interface UserService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Get a user object by its id */ - fun retrieve(params: UserRetrieveParams): User = retrieve(params, RequestOptions.none()) + fun retrieve(params: UserRetrieveParams): User = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): User + fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): User /** - * List out all users. The users are sorted by creation date, with the most recently-created - * users coming first + * List out all users. The users are sorted by creation date, with the most + * recently-created users coming first */ fun list(): UserListPage = list(UserListParams.none()) /** @see [list] */ - fun list( - params: UserListParams = UserListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): UserListPage + fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): UserListPage /** @see [list] */ fun list(params: UserListParams = UserListParams.none()): UserListPage = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list(requestOptions: RequestOptions): UserListPage = - list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): UserListPage = list(UserListParams.none(), requestOptions) - /** A view of [UserService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [UserService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as - * [UserService.retrieve]. + * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the + * same as [UserService.retrieve]. */ @MustBeClosed fun retrieve(params: UserRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as * [UserService.list]. */ - @MustBeClosed fun list(): HttpResponseFor = list(UserListParams.none()) + @MustBeClosed + fun list(): HttpResponseFor = list(UserListParams.none()) /** @see [list] */ @MustBeClosed - fun list( - params: UserListParams = UserListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: UserListParams = UserListParams.none()): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = list(UserListParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 08e5047d..06605588 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -19,11 +19,12 @@ import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams -class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { +class UserServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: UserService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : UserService { + + private val withRawResponse: UserService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): UserService.WithRawResponse = withRawResponse @@ -35,63 +36,64 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti // get /v1/user withRawResponse().list(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - UserService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : UserService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun list( - params: UserListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { UserListPage.of(UserServiceImpl(clientOptions), params, it) } - } + override fun list(params: UserListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + UserListPage.of(UserServiceImpl(clientOptions), params, it) + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index f997b1b2..100b76c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -17,78 +17,83 @@ import com.google.errorprone.annotations.MustBeClosed interface ViewService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one + * specified in the request, will return the existing view unmodified */ - fun create(params: ViewCreateParams): View = create(params, RequestOptions.none()) + fun create(params: ViewCreateParams): View = + create( + params, RequestOptions.none() + ) /** @see [create] */ - fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): View /** Get a view object by its id */ - fun retrieve(params: ViewRetrieveParams): View = retrieve(params, RequestOptions.none()) + fun retrieve(params: ViewRetrieveParams): View = + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ - fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): View /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ - fun update(params: ViewUpdateParams): View = update(params, RequestOptions.none()) + fun update(params: ViewUpdateParams): View = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): View /** - * List out all views. The views are sorted by creation date, with the most recently-created - * views coming first + * List out all views. The views are sorted by creation date, with the most + * recently-created views coming first */ - fun list(params: ViewListParams): ViewListPage = list(params, RequestOptions.none()) + fun list(params: ViewListParams): ViewListPage = + list( + params, RequestOptions.none() + ) /** @see [list] */ - fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ViewListPage + fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): ViewListPage /** Delete a view object by its id */ - fun delete(params: ViewDeleteParams): View = delete(params, RequestOptions.none()) + fun delete(params: ViewDeleteParams): View = + delete( + params, RequestOptions.none() + ) /** @see [delete] */ - fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): View /** - * Create or replace view. If there is an existing view with the same name as the one specified - * in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the + * one specified in the request, will replace the existing view with the provided + * fields */ - fun replace(params: ViewReplaceParams): View = replace(params, RequestOptions.none()) + fun replace(params: ViewReplaceParams): View = + replace( + params, RequestOptions.none() + ) /** @see [replace] */ - fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): View + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): View - /** A view of [ViewService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [ViewService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** @@ -97,44 +102,41 @@ interface ViewService { */ @MustBeClosed fun create(params: ViewCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) + create( + params, RequestOptions.none() + ) /** @see [create] */ @MustBeClosed - fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as - * [ViewService.retrieve]. + * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the + * same as [ViewService.retrieve]. */ @MustBeClosed fun retrieve(params: ViewRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve( + params, RequestOptions.none() + ) /** @see [retrieve] */ @MustBeClosed - fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as - * [ViewService.update]. + * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the + * same as [ViewService.update]. */ @MustBeClosed fun update(params: ViewUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as @@ -142,29 +144,27 @@ interface ViewService { */ @MustBeClosed fun list(params: ViewListParams): HttpResponseFor = - list(params, RequestOptions.none()) + list( + params, RequestOptions.none() + ) /** @see [list] */ @MustBeClosed - fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as - * [ViewService.delete]. + * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise + * the same as [ViewService.delete]. */ @MustBeClosed fun delete(params: ViewDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) + delete( + params, RequestOptions.none() + ) /** @see [delete] */ @MustBeClosed - fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as @@ -172,13 +172,12 @@ interface ViewService { */ @MustBeClosed fun replace(params: ViewReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) + replace( + params, RequestOptions.none() + ) /** @see [replace] */ @MustBeClosed - fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 8c11e74f..1ae3e726 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -24,11 +24,12 @@ import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -class ViewServiceImpl internal constructor(private val clientOptions: ClientOptions) : ViewService { +class ViewServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: ViewService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : ViewService { + + private val withRawResponse: ViewService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): ViewService.WithRawResponse = withRawResponse @@ -56,171 +57,168 @@ class ViewServiceImpl internal constructor(private val clientOptions: ClientOpti // put /v1/view withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ViewService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : ViewService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create( - params: ViewCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create(params: ViewCreateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + createHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + retrieveHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun list( - params: ViewListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { ViewListPage.of(ViewServiceImpl(clientOptions), params, it) } - } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list(params: ViewListParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + listHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ViewListPage.of(ViewServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + deleteHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + replaceHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt index d6298636..1fc7b5c1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -11,7 +11,8 @@ import com.google.errorprone.annotations.MustBeClosed interface MemberService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse @@ -19,49 +20,43 @@ interface MemberService { fun update(): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): PatchOrganizationMembersOutput + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): PatchOrganizationMembersOutput /** @see [update] */ - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() - ): PatchOrganizationMembersOutput = update(params, RequestOptions.none()) + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): PatchOrganizationMembersOutput = + update( + params, RequestOptions.none() + ) /** @see [update] */ - fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = - update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none(), requestOptions) - /** A view of [MemberService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [MemberService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the - * same as [MemberService.update]. + * Returns a raw HTTP response for `patch /v1/organization/members`, but is + * otherwise the same as [MemberService.update]. */ @MustBeClosed - fun update(): HttpResponseFor = - update(OrganizationMemberUpdateParams.none()) + fun update(): HttpResponseFor = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** @see [update] */ @MustBeClosed - fun update( - params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() - ): HttpResponseFor = update(params, RequestOptions.none()) + fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): HttpResponseFor = + update( + params, RequestOptions.none() + ) /** @see [update] */ @MustBeClosed - fun update( - requestOptions: RequestOptions - ): HttpResponseFor = - update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): HttpResponseFor = update(OrganizationMemberUpdateParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index ffd783ac..c46ea290 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -18,53 +18,50 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput -class MemberServiceImpl internal constructor(private val clientOptions: ClientOptions) : - MemberService { +class MemberServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: MemberService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : MemberService { + + private val withRawResponse: MemberService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): MemberService.WithRawResponse = withRawResponse - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions, - ): PatchOrganizationMembersOutput = + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): PatchOrganizationMembersOutput = // patch /v1/organization/members withRawResponse().update(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - MemberService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : MemberService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + updateHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index 3289dca2..d5bd1944 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -16,121 +16,115 @@ import com.google.errorprone.annotations.MustBeClosed interface LogService { /** - * Returns a view of this service that provides access to raw HTTP responses for each method. + * Returns a view of this service that provides access to raw HTTP responses for + * each method. */ fun withRawResponse(): WithRawResponse /** Log feedback for a set of project logs events */ fun feedback(params: ProjectLogFeedbackParams): FeedbackResponseSchema = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FeedbackResponseSchema + fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body. For more complex queries, - * use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same + * path, but with the parameters in the URL query rather than in the request body. + * For more complex queries, use the `POST /btql` endpoint. */ fun fetch(params: ProjectLogFetchParams): FetchProjectLogsEventsResponse = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ - fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchProjectLogsEventsResponse + fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchProjectLogsEventsResponse /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query. For more complex queries, use - * the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, + * but with the parameters in the request body rather than in the URL query. For + * more complex queries, use the `POST /btql` endpoint. */ fun fetchPost(params: ProjectLogFetchPostParams): FetchProjectLogsEventsResponse = - fetchPost(params, RequestOptions.none()) + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FetchProjectLogsEventsResponse + fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchProjectLogsEventsResponse /** Insert a set of events into the project logs */ fun insert(params: ProjectLogInsertParams): InsertEventsResponse = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): InsertEventsResponse + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse - /** A view of [LogService] that provides access to raw HTTP responses for each method. */ + /** + * A view of [LogService] that provides access to raw HTTP responses for each + * method. + */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is - * otherwise the same as [LogService.feedback]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, + * but is otherwise the same as [LogService.feedback]. */ @MustBeClosed fun feedback(params: ProjectLogFeedbackParams): HttpResponseFor = - feedback(params, RequestOptions.none()) + feedback( + params, RequestOptions.none() + ) /** @see [feedback] */ @MustBeClosed - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is - * otherwise the same as [LogService.fetch]. + * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but + * is otherwise the same as [LogService.fetch]. */ @MustBeClosed fun fetch(params: ProjectLogFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fetch( + params, RequestOptions.none() + ) /** @see [fetch] */ @MustBeClosed - fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is - * otherwise the same as [LogService.fetchPost]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but + * is otherwise the same as [LogService.fetchPost]. */ @MustBeClosed - fun fetchPost( - params: ProjectLogFetchPostParams - ): HttpResponseFor = - fetchPost(params, RequestOptions.none()) + fun fetchPost(params: ProjectLogFetchPostParams): HttpResponseFor = + fetchPost( + params, RequestOptions.none() + ) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is - * otherwise the same as [LogService.insert]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but + * is otherwise the same as [LogService.insert]. */ @MustBeClosed fun insert(params: ProjectLogInsertParams): HttpResponseFor = - insert(params, RequestOptions.none()) + insert( + params, RequestOptions.none() + ) /** @see [insert] */ @MustBeClosed - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index d060fec8..23884a8a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -23,156 +23,139 @@ import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { +class LogServiceImpl internal constructor( + private val clientOptions: ClientOptions, - private val withRawResponse: LogService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } +) : LogService { + + private val withRawResponse: LogService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } override fun withRawResponse(): LogService.WithRawResponse = withRawResponse - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions, - ): FeedbackResponseSchema = + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = // post /v1/project_logs/{project_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions, - ): FetchProjectLogsEventsResponse = + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse = // get /v1/project_logs/{project_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions, - ): FetchProjectLogsEventsResponse = + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse = // post /v1/project_logs/{project_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions, - ): InsertEventsResponse = + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): InsertEventsResponse = // post /v1/project_logs/{project_id}/insert withRawResponse().insert(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - LogService.WithRawResponse { + class WithRawResponseImpl internal constructor( + private val clientOptions: ClientOptions, + + ) : LogService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { feedbackHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + feedbackHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { fetchPostHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + fetchPostHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { insertHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): HttpResponseFor { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions + .applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute( + request, requestOptions + ) + return response.parseable { + response.use { + insertHandler.handle(it) + } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt index 1d2dd2d0..bfb17770 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt @@ -36,20 +36,16 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { $ prism mock path/to/your.openapi.yml """ .trimIndent(), - e, + e ) } } override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { - ConditionEvaluationResult.disabled( - "Environment variable $SKIP_TESTS_ENV is set to true" - ) + ConditionEvaluationResult.disabled("Environment variable $SKIP_TESTS_ENV is set to true") } else { - ConditionEvaluationResult.enabled( - "Environment variable $SKIP_TESTS_ENV is not set to true" - ) + ConditionEvaluationResult.enabled("Environment variable $SKIP_TESTS_ENV is not set to true") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt index a7a9b514..afe2bc55 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt @@ -1,7 +1,7 @@ package com.braintrustdata.api.core -import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat internal class PhantomReachableTest { @@ -11,10 +11,8 @@ internal class PhantomReachableTest { val closeable = AutoCloseable { closed = true } closeWhenPhantomReachable( - // Pass an inline object for the object to observe so that it becomes immediately - // unreachable. - Any(), - closeable, + // Pass an inline object for the object to observe so that it becomes immediately unreachable. + Any(), closeable ) assertThat(closed).isFalse() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt index fcdb9f5c..5fed9eeb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt @@ -27,55 +27,55 @@ internal class ValuesTest { KNOWN_BOOLEAN( KnownValue.of(true), expectedAsKnown = Optional.of(true), - expectedAsBoolean = Optional.of(true), + expectedAsBoolean = Optional.of(true) ), BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), KNOWN_NUMBER( KnownValue.of(42), expectedAsKnown = Optional.of(42), - expectedAsNumber = Optional.of(42), + expectedAsNumber = Optional.of(42) ), NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), KNOWN_STRING( KnownValue.of("hello"), expectedAsKnown = Optional.of("hello"), - expectedAsString = Optional.of("hello"), + expectedAsString = Optional.of("hello") ), STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), KNOWN_ARRAY_NOT_ALL_JSON( KnownValue.of(listOf("a", "b", NON_JSON)), - expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)) ), KNOWN_ARRAY( KnownValue.of(listOf("a", "b", "c")), expectedAsKnown = Optional.of(listOf("a", "b", "c")), expectedAsArray = - Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))) ), ARRAY( JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), expectedAsArray = - Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))) ), KNOWN_OBJECT_NOT_ALL_STRING_KEYS( KnownValue.of(mapOf("a" to "b", 42 to "c")), - expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")) ), KNOWN_OBJECT_NOT_ALL_JSON( KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), - expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)) ), KNOWN_OBJECT( KnownValue.of(mapOf("a" to "b", "b" to "c")), expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), expectedAsObject = - Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))) ), OBJECT( JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), expectedAsObject = - Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), - ), + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))) + ) } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt index 2a5ed57a..f66d69ea 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt @@ -1,8 +1,9 @@ package com.braintrustdata.api.core.http +import org.junit.jupiter.api.Test import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat +import org.assertj.core.api.Assumptions.assumeThat; import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -11,28 +12,28 @@ internal class HeadersTest { enum class TestCase( val headers: Headers, val expectedMap: Map>, - val expectedSize: Int, + val expectedSize: Int ) { EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( Headers.builder().put("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), PUT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT( Headers.builder().put("name1", "value").put("name2", "value").build(), expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT_SAME_NAME( Headers.builder().put("name", "value1").put("name", "value2").build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT_MULTIPLE( Headers.builder() @@ -40,7 +41,7 @@ internal class HeadersTest { .put("name", listOf("value1", "value2")) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4, + expectedSize = 4 ), PUT_CASE_INSENSITIVE( Headers.builder() @@ -49,25 +50,25 @@ internal class HeadersTest { .put("nAmE", "value3") .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3, + expectedSize = 3 ), PUT_ALL_MAP( Headers.builder() .putAll( mapOf( "name1" to listOf("value1", "value2"), - "name2" to listOf("value1", "value2"), + "name2" to listOf("value1", "value2") ) ) .build(), expectedMap = mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), - expectedSize = 4, + expectedSize = 4 ), PUT_ALL_HEADERS( Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), PUT_ALL_CASE_INSENSITIVE( Headers.builder() @@ -75,32 +76,32 @@ internal class HeadersTest { mapOf( "name" to listOf("value1"), "NAME" to listOf("value2"), - "nAmE" to listOf("value3"), + "nAmE" to listOf("value3") ) ) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3, + expectedSize = 3 ), REMOVE_ABSENT( Headers.builder().remove("name").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_PRESENT_ONE( Headers.builder().put("name", "value").remove("name").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_PRESENT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_CASE_INSENSITIVE( Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_ALL( Headers.builder() @@ -109,7 +110,7 @@ internal class HeadersTest { .removeAll(setOf("name1", "name2", "name3")) .build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -118,22 +119,22 @@ internal class HeadersTest { .removeAll(setOf("NAME1", "nAmE3")) .build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), CLEAR( Headers.builder().put("name1", "value").put("name2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REPLACE_ONE_ABSENT( Headers.builder().replace("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_ONE_PRESENT_ONE( Headers.builder().put("name", "value1").replace("name", "value2").build(), expectedMap = mapOf("name" to listOf("value2")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_ONE_PRESENT_MULTIPLE( Headers.builder() @@ -141,12 +142,12 @@ internal class HeadersTest { .replace("name", "value3") .build(), expectedMap = mapOf("name" to listOf("value3")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_MULTIPLE_ABSENT( Headers.builder().replace("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_MULTIPLE_PRESENT_ONE( Headers.builder() @@ -154,7 +155,7 @@ internal class HeadersTest { .replace("name", listOf("value2", "value3")) .build(), expectedMap = mapOf("name" to listOf("value2", "value3")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( Headers.builder() @@ -162,7 +163,7 @@ internal class HeadersTest { .replace("name", listOf("value3", "value4")) .build(), expectedMap = mapOf("name" to listOf("value3", "value4")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_CASE_INSENSITIVE( Headers.builder() @@ -170,7 +171,7 @@ internal class HeadersTest { .replace("NAME", listOf("value2", "value3")) .build(), expectedMap = mapOf("NAME" to listOf("value2", "value3")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_ALL_MAP( Headers.builder() @@ -183,9 +184,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2"), + "name3" to listOf("value2") ), - expectedSize = 3, + expectedSize = 3 ), REPLACE_ALL_HEADERS( Headers.builder() @@ -198,9 +199,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2"), + "name3" to listOf("value2") ), - expectedSize = 3, + expectedSize = 3 ), REPLACE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -209,8 +210,8 @@ internal class HeadersTest { .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) .build(), expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), - expectedSize = 2, - ), + expectedSize = 2 + ) } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt index 08e55c66..7fe37959 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt @@ -1,8 +1,9 @@ package com.braintrustdata.api.core.http +import org.junit.jupiter.api.Test import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat +import org.assertj.core.api.Assumptions.assumeThat; import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -11,28 +12,28 @@ internal class QueryParamsTest { enum class TestCase( val queryParams: QueryParams, val expectedMap: Map>, - val expectedSize: Int, + val expectedSize: Int ) { EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( QueryParams.builder().put("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), PUT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT( QueryParams.builder().put("key1", "value").put("key2", "value").build(), expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT_SAME_NAME( QueryParams.builder().put("key", "value1").put("key", "value2").build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), MULTIPLE_PUT_MULTIPLE( QueryParams.builder() @@ -40,40 +41,40 @@ internal class QueryParamsTest { .put("key", listOf("value1", "value2")) .build(), expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4, + expectedSize = 4 ), PUT_ALL_MAP( QueryParams.builder() .putAll( mapOf( "key1" to listOf("value1", "value2"), - "key2" to listOf("value1", "value2"), + "key2" to listOf("value1", "value2") ) ) .build(), expectedMap = mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), - expectedSize = 4, + expectedSize = 4 ), PUT_ALL_HEADERS( QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), REMOVE_ABSENT( QueryParams.builder().remove("key").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_PRESENT_ONE( QueryParams.builder().put("key", "value").remove("key").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_PRESENT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REMOVE_ALL( QueryParams.builder() @@ -82,22 +83,22 @@ internal class QueryParamsTest { .removeAll(setOf("key1", "key2", "key3")) .build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), CLEAR( QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0, + expectedSize = 0 ), REPLACE_ONE_ABSENT( QueryParams.builder().replace("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_ONE_PRESENT_ONE( QueryParams.builder().put("key", "value1").replace("key", "value2").build(), expectedMap = mapOf("key" to listOf("value2")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_ONE_PRESENT_MULTIPLE( QueryParams.builder() @@ -105,12 +106,12 @@ internal class QueryParamsTest { .replace("key", "value3") .build(), expectedMap = mapOf("key" to listOf("value3")), - expectedSize = 1, + expectedSize = 1 ), REPLACE_MULTIPLE_ABSENT( QueryParams.builder().replace("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_MULTIPLE_PRESENT_ONE( QueryParams.builder() @@ -118,7 +119,7 @@ internal class QueryParamsTest { .replace("key", listOf("value2", "value3")) .build(), expectedMap = mapOf("key" to listOf("value2", "value3")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( QueryParams.builder() @@ -126,7 +127,7 @@ internal class QueryParamsTest { .replace("key", listOf("value3", "value4")) .build(), expectedMap = mapOf("key" to listOf("value3", "value4")), - expectedSize = 2, + expectedSize = 2 ), REPLACE_ALL_MAP( QueryParams.builder() @@ -139,9 +140,9 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2"), + "key3" to listOf("value2") ), - expectedSize = 3, + expectedSize = 3 ), REPLACE_ALL_HEADERS( QueryParams.builder() @@ -156,10 +157,10 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2"), + "key3" to listOf("value2") ), - expectedSize = 3, - ), + expectedSize = 3 + ) } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt index d538b9b3..9370b6d7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt @@ -6,12 +6,12 @@ import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario -import java.io.InputStream -import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource +import java.io.InputStream +import java.util.concurrent.CompletableFuture @WireMockTest internal class RetryingHttpClientTest { @@ -26,12 +26,12 @@ internal class RetryingHttpClientTest { object : HttpClient { override fun execute( request: HttpRequest, - requestOptions: RequestOptions, + requestOptions: RequestOptions ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions, + requestOptions: RequestOptions ): CompletableFuture = okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } @@ -71,7 +71,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) @@ -97,7 +97,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) @@ -140,24 +140,24 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("0")), + .withHeader("x-stainless-retry-count", equalTo("0")) ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("1")), + .withHeader("x-stainless-retry-count", equalTo("1")) ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("2")), + .withHeader("x-stainless-retry-count", equalTo("2")) ) assertNoResponseLeaks() } @@ -191,14 +191,14 @@ internal class RetryingHttpClientTest { .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) verify( 2, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("42")), + .withHeader("x-stainless-retry-count", equalTo("42")) ) assertNoResponseLeaks() } @@ -226,7 +226,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async, + async ) assertThat(response.statusCode()).isEqualTo(200) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt index 824c8711..3759f563 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt @@ -1,13 +1,13 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.core.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.* +import com.braintrustdata.api.core.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import java.util.* internal class SerializerTest { @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) @@ -23,7 +23,9 @@ internal class SerializerTest { fun isActive(): Boolean? = isActive.getNullable("is_active") - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") + @ExcludeMissing + fun _isActive() = isActive @JsonAnyGetter @ExcludeMissing @@ -42,19 +44,21 @@ internal class SerializerTest { } return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties + isActive == other.isActive && + additionalProperties == other.additionalProperties } override fun hashCode(): Int { if (hashCode == 0) { - hashCode = Objects.hash(isActive, additionalProperties) + hashCode = Objects.hash( + isActive, + additionalProperties, + ) } return hashCode } - override fun toString() = - "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" + override fun toString() = "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" companion object { fun builder() = Builder() @@ -70,7 +74,9 @@ internal class SerializerTest { @JsonProperty("is_active") @ExcludeMissing - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } + fun isActive(isActive: JsonField) = apply { + this.isActive = isActive + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -86,11 +92,14 @@ internal class SerializerTest { this.additionalProperties.putAll(additionalProperties) } - fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs(isActive, additionalProperties.toImmutable()) + fun build(): ClassWithBooleanFieldPrefixedWithIs = ClassWithBooleanFieldPrefixedWithIs( + isActive, + additionalProperties.toImmutable(), + ) } } + @Test fun serializeBooleanPrefixedWithIs() { val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt index 693b9866..5d5e9323 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt @@ -11,32 +11,26 @@ class AISecretTest { @Test fun createAISecret() { - val aiSecret = - AISecret.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata( - AISecret.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .previewSecret("preview_secret") - .type("type") - .build() - assertThat(aiSecret).isNotNull - assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(aiSecret.name()).isEqualTo("name") - assertThat(aiSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(aiSecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(aiSecret.metadata()) - .contains( - AISecret.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(aiSecret.previewSecret()).contains("preview_secret") - assertThat(aiSecret.type()).contains("type") + val aiSecret = AISecret.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata(AISecret.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .previewSecret("preview_secret") + .type("type") + .build() + assertThat(aiSecret).isNotNull + assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aiSecret.name()).isEqualTo("name") + assertThat(aiSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aiSecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(aiSecret.metadata()).contains(AISecret.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(aiSecret.previewSecret()).contains("preview_secret") + assertThat(aiSecret.type()).contains("type") } } 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..942ae28c 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 @@ -10,109 +10,80 @@ class AclBatchUpdateParamsTest { @Test fun create() { - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() + AclBatchUpdateParams.builder() + .addAddAcl(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() } @Test fun body() { - val params = - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() + val params = AclBatchUpdateParams.builder() + .addAddAcl(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addAcls()) - .contains( - listOf( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) - assertThat(body.removeAcls()) - .contains( - listOf( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) + assertNotNull(body) + assertThat(body.addAcls()).contains(listOf(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build())) + assertThat(body.removeAcls()).contains(listOf(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = AclBatchUpdateParams.builder().build() + val params = AclBatchUpdateParams.builder().build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } } 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..b862daca 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 @@ -10,67 +10,56 @@ class AclBatchUpdateResponseTest { @Test fun createAclBatchUpdateResponse() { - val aclBatchUpdateResponse = - AclBatchUpdateResponse.builder() - .addAddedAcl( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemovedAcl( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - assertThat(aclBatchUpdateResponse).isNotNull - assertThat(aclBatchUpdateResponse.addedAcls()) - .containsExactly( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - assertThat(aclBatchUpdateResponse.removedAcls()) - .containsExactly( - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val aclBatchUpdateResponse = AclBatchUpdateResponse.builder() + .addAddedAcl(Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemovedAcl(Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() + assertThat(aclBatchUpdateResponse).isNotNull + assertThat(aclBatchUpdateResponse.addedAcls()).containsExactly(Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + assertThat(aclBatchUpdateResponse.removedAcls()).containsExactly(Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.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..33bf5671 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 @@ -10,55 +10,52 @@ class AclCreateParamsTest { @Test fun create() { - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).contains(AclCreateParams.Permission.CREATE) - assertThat(body.restrictObjectType()) - .contains(AclCreateParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .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.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).contains(AclCreateParams.Permission.CREATE) + assertThat(body.restrictObjectType()).contains(AclCreateParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun bodyWithoutOptionalFields() { - val params = - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .build() + val params = AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt index 51793459..cd7e95c7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt @@ -9,16 +9,20 @@ class AclDeleteParamsTest { @Test fun create() { - AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "aclId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aclId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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..335f462e 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 @@ -10,55 +10,52 @@ class AclFindAndDeleteParamsTest { @Test fun create() { - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).contains(AclFindAndDeleteParams.Permission.CREATE) - assertThat(body.restrictObjectType()) - .contains(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .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.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).contains(AclFindAndDeleteParams.Permission.CREATE) + assertThat(body.restrictObjectType()).contains(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun bodyWithoutOptionalFields() { - val params = - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.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..09d041f2 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 @@ -10,50 +10,45 @@ class AclListParamsTest { @Test fun create() { - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt index fd23f612..d3e50fea 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class AclRetrieveParamsTest { @Test fun create() { - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "aclId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aclId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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..2bd881dc 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 @@ -10,29 +10,28 @@ class AclTest { @Test fun createAcl() { - val acl = - Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(acl).isNotNull - 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.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.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val acl = Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(acl).isNotNull + 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.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.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/AiSecretCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt index 213130fd..d00281be 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt @@ -11,56 +11,50 @@ class AiSecretCreateParamsTest { @Test fun create() { - AiSecretCreateParams.builder() - .name("name") - .metadata( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() + AiSecretCreateParams.builder() + .name("name") + .metadata(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = - AiSecretCreateParams.builder() - .name("name") - .metadata( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()) - .contains( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.orgName()).contains("org_name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + val params = AiSecretCreateParams.builder() + .name("name") + .metadata(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.metadata()).contains(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.orgName()).contains("org_name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretCreateParams.builder().name("name").build() + val params = AiSecretCreateParams.builder() + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt index a59725a1..98eaa5fd 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt @@ -9,19 +9,20 @@ class AiSecretDeleteParamsTest { @Test fun create() { - AiSecretDeleteParams.builder().aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt index f46d2fb2..dd00f4fc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt @@ -10,27 +10,35 @@ class AiSecretFindAndDeleteParamsTest { @Test fun create() { - AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() + AiSecretFindAndDeleteParams.builder() + .name("name") + .orgName("org_name") + .build() } @Test fun body() { - val params = AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() + val params = AiSecretFindAndDeleteParams.builder() + .name("name") + .orgName("org_name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretFindAndDeleteParams.builder().name("name").build() + val params = AiSecretFindAndDeleteParams.builder() + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt index fff7ec47..9388f3ff 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt @@ -10,50 +10,43 @@ class AiSecretListParamsTest { @Test fun create() { - AiSecretListParams.builder() - .aiSecretName("ai_secret_name") - .aiSecretType("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AiSecretListParams.builder() + .aiSecretName("ai_secret_name") + .aiSecretType("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - AiSecretListParams.builder() - .aiSecretName("ai_secret_name") - .aiSecretType("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ai_secret_name", "ai_secret_name") - expected.put( - "ai_secret_type", - AiSecretListParams.AiSecretType.ofString("string").toString(), - ) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AiSecretListParams.builder() + .aiSecretName("ai_secret_name") + .aiSecretType("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ai_secret_name", "ai_secret_name") + expected.put("ai_secret_type", AiSecretListParams.AiSecretType.ofString("string").toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = AiSecretListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AiSecretListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt index b716129c..96bc3a6a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt @@ -11,56 +11,50 @@ class AiSecretReplaceParamsTest { @Test fun create() { - AiSecretReplaceParams.builder() - .name("name") - .metadata( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() + AiSecretReplaceParams.builder() + .name("name") + .metadata(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = - AiSecretReplaceParams.builder() - .name("name") - .metadata( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()) - .contains( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.orgName()).contains("org_name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + val params = AiSecretReplaceParams.builder() + .name("name") + .metadata(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.metadata()).contains(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.orgName()).contains("org_name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretReplaceParams.builder().name("name").build() + val params = AiSecretReplaceParams.builder() + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt index 5c6d07cc..0eddf89f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt @@ -9,19 +9,20 @@ class AiSecretRetrieveParamsTest { @Test fun create() { - AiSecretRetrieveParams.builder().aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt index b45e1c86..17084aa8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt @@ -11,70 +11,60 @@ class AiSecretUpdateParamsTest { @Test fun create() { - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .secret("secret") - .type("type") - .build() + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .secret("secret") - .type("type") - .build() + val params = AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .secret("secret") + .type("type") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.metadata()) - .contains( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + assertNotNull(body) + assertThat(body.metadata()).contains(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.name()).contains("name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt index d450a958..683112d5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -10,27 +10,35 @@ class ApiKeyCreateParamsTest { @Test fun create() { - ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + ApiKeyCreateParams.builder() + .name("name") + .orgName("org_name") + .build() } @Test fun body() { - val params = ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + val params = ApiKeyCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = ApiKeyCreateParams.builder().name("name").build() + val params = ApiKeyCreateParams.builder() + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt index 0b7c5a7d..6de59487 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt @@ -9,17 +9,20 @@ class ApiKeyDeleteParamsTest { @Test fun create() { - ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "apiKeyId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "apiKeyId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index 41532fd3..9f6485af 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -10,44 +10,40 @@ class ApiKeyListParamsTest { @Test fun create() { - ApiKeyListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ApiKeyListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ApiKeyListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("api_key_name", "api_key_name") - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ApiKeyListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("api_key_name", "api_key_name") + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ApiKeyListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ApiKeyListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt index 2170ff30..29fe0c51 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class ApiKeyRetrieveParamsTest { @Test fun create() { - ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "apiKeyId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "apiKeyId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt index 5d9ab3b9..4893810a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt @@ -10,21 +10,20 @@ class ApiKeyTest { @Test fun createApiKey() { - val apiKey = - ApiKey.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .previewName("preview_name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(apiKey).isNotNull - assertThat(apiKey.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKey.name()).isEqualTo("name") - assertThat(apiKey.previewName()).isEqualTo("preview_name") - assertThat(apiKey.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(apiKey.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKey.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val apiKey = ApiKey.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(apiKey).isNotNull + assertThat(apiKey.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.name()).isEqualTo("name") + assertThat(apiKey.previewName()).isEqualTo("preview_name") + assertThat(apiKey.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKey.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt index fbf9f7e4..dede2dfa 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt @@ -9,25 +9,18 @@ class ChatCompletionContentPartImageTest { @Test fun createChatCompletionContentPartImage() { - val chatCompletionContentPartImage = - ChatCompletionContentPartImage.builder() - .imageUrl( - ChatCompletionContentPartImage.ImageUrl.builder() - .url("url") - .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) - .build() - ) - .type(ChatCompletionContentPartImage.Type.IMAGE_URL) - .build() - assertThat(chatCompletionContentPartImage).isNotNull - assertThat(chatCompletionContentPartImage.imageUrl()) - .isEqualTo( - ChatCompletionContentPartImage.ImageUrl.builder() - .url("url") - .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) - .build() - ) - assertThat(chatCompletionContentPartImage.type()) - .isEqualTo(ChatCompletionContentPartImage.Type.IMAGE_URL) + val chatCompletionContentPartImage = ChatCompletionContentPartImage.builder() + .imageUrl(ChatCompletionContentPartImage.ImageUrl.builder() + .url("url") + .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) + .build()) + .type(ChatCompletionContentPartImage.Type.IMAGE_URL) + .build() + assertThat(chatCompletionContentPartImage).isNotNull + assertThat(chatCompletionContentPartImage.imageUrl()).isEqualTo(ChatCompletionContentPartImage.ImageUrl.builder() + .url("url") + .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) + .build()) + assertThat(chatCompletionContentPartImage.type()).isEqualTo(ChatCompletionContentPartImage.Type.IMAGE_URL) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt index 5e71c215..1ce72db0 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt @@ -9,14 +9,12 @@ class ChatCompletionContentPartTextTest { @Test fun createChatCompletionContentPartText() { - val chatCompletionContentPartText = - ChatCompletionContentPartText.builder() - .type(ChatCompletionContentPartText.Type.TEXT) - .text("text") - .build() - assertThat(chatCompletionContentPartText).isNotNull - assertThat(chatCompletionContentPartText.type()) - .isEqualTo(ChatCompletionContentPartText.Type.TEXT) - assertThat(chatCompletionContentPartText.text()).contains("text") + val chatCompletionContentPartText = ChatCompletionContentPartText.builder() + .type(ChatCompletionContentPartText.Type.TEXT) + .text("text") + .build() + assertThat(chatCompletionContentPartText).isNotNull + assertThat(chatCompletionContentPartText.type()).isEqualTo(ChatCompletionContentPartText.Type.TEXT) + assertThat(chatCompletionContentPartText.text()).contains("text") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt index c609ef38..f5079fc1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt @@ -9,27 +9,20 @@ class ChatCompletionMessageToolCallTest { @Test fun createChatCompletionMessageToolCall() { - val chatCompletionMessageToolCall = - ChatCompletionMessageToolCall.builder() - .id("id") - .function( - ChatCompletionMessageToolCall.Function.builder() - .arguments("arguments") - .name("name") - .build() - ) - .type(ChatCompletionMessageToolCall.Type.FUNCTION) - .build() - assertThat(chatCompletionMessageToolCall).isNotNull - assertThat(chatCompletionMessageToolCall.id()).isEqualTo("id") - assertThat(chatCompletionMessageToolCall.function()) - .isEqualTo( - ChatCompletionMessageToolCall.Function.builder() - .arguments("arguments") - .name("name") - .build() - ) - assertThat(chatCompletionMessageToolCall.type()) - .isEqualTo(ChatCompletionMessageToolCall.Type.FUNCTION) + val chatCompletionMessageToolCall = ChatCompletionMessageToolCall.builder() + .id("id") + .function(ChatCompletionMessageToolCall.Function.builder() + .arguments("arguments") + .name("name") + .build()) + .type(ChatCompletionMessageToolCall.Type.FUNCTION) + .build() + assertThat(chatCompletionMessageToolCall).isNotNull + assertThat(chatCompletionMessageToolCall.id()).isEqualTo("id") + assertThat(chatCompletionMessageToolCall.function()).isEqualTo(ChatCompletionMessageToolCall.Function.builder() + .arguments("arguments") + .name("name") + .build()) + assertThat(chatCompletionMessageToolCall.type()).isEqualTo(ChatCompletionMessageToolCall.Type.FUNCTION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt index 7cced6c5..cd737854 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt @@ -9,51 +9,34 @@ class CodeBundleTest { @Test fun createCodeBundle() { - val codeBundle = - CodeBundle.builder() - .bundleId("bundle_id") - .location( - CodeBundle.Location.Experiment.builder() - .evalName("eval_name") - .position( - CodeBundle.Location.Experiment.Position.Type.builder() - .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) - .build() - ) - .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) - .build() - ) - .runtimeContext( - CodeBundle.RuntimeContext.builder() - .runtime(CodeBundle.RuntimeContext.Runtime.NODE) - .version("version") - .build() - ) - .preview("preview") - .build() - assertThat(codeBundle).isNotNull - assertThat(codeBundle.bundleId()).isEqualTo("bundle_id") - assertThat(codeBundle.location()) - .isEqualTo( - CodeBundle.Location.ofExperiment( - CodeBundle.Location.Experiment.builder() - .evalName("eval_name") - .position( - CodeBundle.Location.Experiment.Position.Type.builder() - .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) - .build() - ) - .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) - .build() - ) - ) - assertThat(codeBundle.runtimeContext()) - .isEqualTo( - CodeBundle.RuntimeContext.builder() - .runtime(CodeBundle.RuntimeContext.Runtime.NODE) - .version("version") - .build() - ) - assertThat(codeBundle.preview()).contains("preview") + val codeBundle = CodeBundle.builder() + .bundleId("bundle_id") + .location(CodeBundle.Location.Experiment.builder() + .evalName("eval_name") + .position(CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) + .build()) + .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) + .build()) + .runtimeContext(CodeBundle.RuntimeContext.builder() + .runtime(CodeBundle.RuntimeContext.Runtime.NODE) + .version("version") + .build()) + .preview("preview") + .build() + assertThat(codeBundle).isNotNull + assertThat(codeBundle.bundleId()).isEqualTo("bundle_id") + assertThat(codeBundle.location()).isEqualTo(CodeBundle.Location.ofExperiment(CodeBundle.Location.Experiment.builder() + .evalName("eval_name") + .position(CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) + .build()) + .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) + .build())) + assertThat(codeBundle.runtimeContext()).isEqualTo(CodeBundle.RuntimeContext.builder() + .runtime(CodeBundle.RuntimeContext.Runtime.NODE) + .version("version") + .build()) + assertThat(codeBundle.preview()).contains("preview") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt index 6bfead25..12fa7a4c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt @@ -10,24 +10,22 @@ class CreateApiKeyOutputTest { @Test fun createCreateApiKeyOutput() { - val createApiKeyOutput = - CreateApiKeyOutput.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .key("key") - .name("name") - .previewName("preview_name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(createApiKeyOutput).isNotNull - assertThat(createApiKeyOutput.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createApiKeyOutput.key()).isEqualTo("key") - assertThat(createApiKeyOutput.name()).isEqualTo("name") - assertThat(createApiKeyOutput.previewName()).isEqualTo("preview_name") - assertThat(createApiKeyOutput.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(createApiKeyOutput.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createApiKeyOutput.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val createApiKeyOutput = CreateApiKeyOutput.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .key("key") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(createApiKeyOutput).isNotNull + assertThat(createApiKeyOutput.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.key()).isEqualTo("key") + assertThat(createApiKeyOutput.name()).isEqualTo("name") + assertThat(createApiKeyOutput.previewName()).isEqualTo("preview_name") + assertThat(createApiKeyOutput.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(createApiKeyOutput.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt index 6ce8e5d3..e4af5d85 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt @@ -10,60 +10,26 @@ class CrossObjectInsertResponseTest { @Test fun createCrossObjectInsertResponse() { - val crossObjectInsertResponse = - CrossObjectInsertResponse.builder() - .dataset( - CrossObjectInsertResponse.Dataset.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - .experiment( - CrossObjectInsertResponse.Experiment.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - .projectLogs( - CrossObjectInsertResponse.ProjectLogs.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - .build() - assertThat(crossObjectInsertResponse).isNotNull - assertThat(crossObjectInsertResponse.dataset()) - .contains( - CrossObjectInsertResponse.Dataset.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - assertThat(crossObjectInsertResponse.experiment()) - .contains( - CrossObjectInsertResponse.Experiment.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) - assertThat(crossObjectInsertResponse.projectLogs()) - .contains( - CrossObjectInsertResponse.ProjectLogs.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("row_ids" to listOf("string"))), - ) - .build() - ) + val crossObjectInsertResponse = CrossObjectInsertResponse.builder() + .dataset(CrossObjectInsertResponse.Dataset.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + .experiment(CrossObjectInsertResponse.Experiment.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + .projectLogs(CrossObjectInsertResponse.ProjectLogs.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + .build() + assertThat(crossObjectInsertResponse).isNotNull + assertThat(crossObjectInsertResponse.dataset()).contains(CrossObjectInsertResponse.Dataset.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + assertThat(crossObjectInsertResponse.experiment()).contains(CrossObjectInsertResponse.Experiment.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) + assertThat(crossObjectInsertResponse.projectLogs()).contains(CrossObjectInsertResponse.ProjectLogs.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt index 4cc2a2db..2a0381cb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt @@ -9,8 +9,10 @@ class DataSummaryTest { @Test fun createDataSummary() { - val dataSummary = DataSummary.builder().totalRecords(0L).build() - assertThat(dataSummary).isNotNull - assertThat(dataSummary.totalRecords()).isEqualTo(0L) + val dataSummary = DataSummary.builder() + .totalRecords(0L) + .build() + assertThat(dataSummary).isNotNull + assertThat(dataSummary.totalRecords()).isEqualTo(0L) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index 53e0d257..506e2734 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -11,58 +11,49 @@ class DatasetCreateParamsTest { @Test fun create() { - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() + DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build() } @Test fun body() { - val params = - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.description()).contains("description") - assertThat(body.metadata()) - .contains( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + val params = DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.description()).contains("description") + assertThat(body.metadata()).contains(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt index 8b41dbf4..b088a25f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt @@ -9,17 +9,20 @@ class DatasetDeleteParamsTest { @Test fun create() { - DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt index 687f05e1..d1168c6e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -11,60 +11,48 @@ class DatasetEventTest { @Test fun createDatasetEvent() { - val datasetEvent = - DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .origin( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .addTag("string") - .build() - assertThat(datasetEvent).isNotNull - assertThat(datasetEvent.id()).isEqualTo("id") - assertThat(datasetEvent._xactId()).isEqualTo("_xact_id") - assertThat(datasetEvent.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(datasetEvent.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(datasetEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(datasetEvent.spanId()).isEqualTo("span_id") - assertThat(datasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetEvent.isRoot()).contains(true) - assertThat(datasetEvent.metadata()) - .contains( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(datasetEvent.origin()) - .contains( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - assertThat(datasetEvent.tags().get()).containsExactly("string") + val datasetEvent = DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .origin(DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .addTag("string") + .build() + assertThat(datasetEvent).isNotNull + assertThat(datasetEvent.id()).isEqualTo("id") + assertThat(datasetEvent._xactId()).isEqualTo("_xact_id") + assertThat(datasetEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetEvent.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(datasetEvent.spanId()).isEqualTo("span_id") + assertThat(datasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent.isRoot()).contains(true) + assertThat(datasetEvent.metadata()).contains(DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(datasetEvent.origin()).contains(DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build()) + assertThat(datasetEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index 512fb176..f91d17c9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -11,91 +11,78 @@ class DatasetFeedbackParamsTest { @Test fun create() { - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - .build() + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - .build() + val params = DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder().id("id").build()) - .build() + val params = DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackDatasetItem.builder().id("id").build())) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackDatasetItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder().id("id").build()) - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .build()) + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index 1a2a1725..83be2844 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -10,49 +10,50 @@ class DatasetFetchParamsTest { @Test fun create() { - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index 3120e7e1..ab4d88d8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -10,60 +10,57 @@ class DatasetFetchPostParamsTest { @Test fun create() { - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index 9f080dd0..d0c459e2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -12,114 +12,96 @@ class DatasetInsertParamsTest { @Test fun create() { - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + val params = DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()) - .isEqualTo( - listOf( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder().build()) - .build() + val params = DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) } @Test fun getPathParam() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index de58fd44..e3a35955 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -10,50 +10,46 @@ class DatasetListParamsTest { @Test fun create() { - DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("dataset_name", "dataset_name") - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("dataset_name", "dataset_name") + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = DatasetListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt index 95326568..8473c6ff 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt @@ -9,19 +9,20 @@ class DatasetRetrieveParamsTest { @Test fun create() { - DatasetRetrieveParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index 83303cf0..d2073c3f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -10,44 +10,41 @@ class DatasetSummarizeParamsTest { @Test fun create() { - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() } @Test fun queryParams() { - val params = - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - val expected = QueryParams.builder() - expected.put("summarize_data", "true") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() + val expected = QueryParams.builder() + expected.put("summarize_data", "true") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt index 829a918e..5c0ada06 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt @@ -11,34 +11,28 @@ class DatasetTest { @Test fun createDataset() { - val dataset = - Dataset.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - Dataset.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(dataset).isNotNull - assertThat(dataset.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(dataset.name()).isEqualTo("name") - assertThat(dataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(dataset.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.description()).contains("description") - assertThat(dataset.metadata()) - .contains( - Dataset.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(dataset.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val dataset = Dataset.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .metadata(Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(dataset).isNotNull + assertThat(dataset.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.name()).isEqualTo("name") + assertThat(dataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.description()).contains("description") + assertThat(dataset.metadata()).contains(Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(dataset.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index c7976ff2..4b84f951 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -11,63 +11,57 @@ class DatasetUpdateParamsTest { @Test fun create() { - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .build() } @Test fun body() { - val params = - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() + val params = DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.metadata()) - .contains( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("name") + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.metadata()).contains(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.name()).contains("name") } @Test fun bodyWithoutOptionalFields() { - val params = - DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt index d5e8e9f1..f901f36e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt @@ -10,47 +10,45 @@ class EnvVarCreateParamsTest { @Test fun create() { - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() + EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() } @Test fun body() { - val params = - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) - assertThat(body.value()).contains("value") + val params = EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) + val params = EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt index b6264f9d..6808443f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt @@ -9,17 +9,20 @@ class EnvVarDeleteParamsTest { @Test fun create() { - EnvVarDeleteParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - EnvVarDeleteParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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..1d3b4b4f 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 @@ -10,41 +10,37 @@ class EnvVarListParamsTest { @Test fun create() { - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() + EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() } @Test fun queryParams() { - val params = - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("env_var_name", "env_var_name") - expected.put( - "ids", - EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("env_var_name", "env_var_name") + expected.put("ids", EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = EnvVarListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = EnvVarListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt index 35b86df1..4e695e38 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt @@ -10,30 +10,24 @@ class EnvVarListResponseTest { @Test fun createEnvVarListResponse() { - val envVarListResponse = - EnvVarListResponse.builder() - .addObject( - EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(envVarListResponse).isNotNull - assertThat(envVarListResponse.objects()) - .containsExactly( - EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) + val envVarListResponse = EnvVarListResponse.builder() + .addObject(EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build()) + .build() + assertThat(envVarListResponse).isNotNull + assertThat(envVarListResponse.objects()).containsExactly(EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt index 68d9ebd2..53857e16 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt @@ -10,47 +10,45 @@ class EnvVarReplaceParamsTest { @Test fun create() { - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() + EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() } @Test fun body() { - val params = - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.value()).contains("value") + val params = EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) + val params = EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt index bca82bdc..513ce8d5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class EnvVarRetrieveParamsTest { @Test fun create() { - EnvVarRetrieveParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - EnvVarRetrieveParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt index 224dddbb..f7825f39 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt @@ -10,21 +10,20 @@ class EnvVarTest { @Test fun createEnvVar() { - val envVar = - EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - assertThat(envVar).isNotNull - assertThat(envVar.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(envVar.name()).isEqualTo("name") - assertThat(envVar.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(envVar.objectType()).isEqualTo(EnvVar.ObjectType.ORGANIZATION) - assertThat(envVar.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(envVar.used()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + val envVar = EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(envVar).isNotNull + assertThat(envVar.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(envVar.name()).isEqualTo("name") + assertThat(envVar.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(envVar.objectType()).isEqualTo(EnvVar.ObjectType.ORGANIZATION) + assertThat(envVar.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(envVar.used()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt index e4ad1080..7188655e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt @@ -10,54 +10,51 @@ class EnvVarUpdateParamsTest { @Test fun create() { - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() } @Test fun body() { - val params = - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.value()).contains("value") + val params = EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() + val params = EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } @Test fun getPathParam() { - val params = - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index 5ac72887..3381511b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -11,212 +11,161 @@ class EvalCreateParamsTest { @Test fun create() { - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .task( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - .isPublic(true) - .maxConcurrency(0.0) - .metadata( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() + EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + .isPublic(true) + .maxConcurrency(0.0) + .metadata(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() } @Test fun body() { - val params = - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .task( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - .isPublic(true) - .maxConcurrency(0.0) - .metadata( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() + val params = EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + .isPublic(true) + .maxConcurrency(0.0) + .metadata(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.data()) - .isEqualTo( - EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() - ) - ) - assertThat(body.projectId()).isEqualTo("project_id") - assertThat(body.scores()) - .isEqualTo( - listOf( - EvalCreateParams.Score.ofFunctionId( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - ) - ) - assertThat(body.task()) - .isEqualTo( - EvalCreateParams.Task.ofFunctionId( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - ) - assertThat(body.baseExperimentId()).contains("base_experiment_id") - assertThat(body.baseExperimentName()).contains("base_experiment_name") - assertThat(body.experimentName()).contains("experiment_name") - assertThat(body.gitMetadataSettings()) - .contains( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - assertThat(body.isPublic()).contains(true) - assertThat(body.maxConcurrency()).contains(0.0) - assertThat(body.metadata()) - .contains( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.repoInfo()) - .contains( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - assertThat(body.stream()).contains(true) - assertThat(body.timeout()).contains(0.0) - assertThat(body.trialCount()).contains(0.0) + assertNotNull(body) + assertThat(body.data()).isEqualTo(EvalCreateParams.Data.ofDatasetId(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build())) + assertThat(body.projectId()).isEqualTo("project_id") + assertThat(body.scores()).isEqualTo(listOf(EvalCreateParams.Score.ofFunctionId(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()))) + assertThat(body.task()).isEqualTo(EvalCreateParams.Task.ofFunctionId(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build())) + assertThat(body.baseExperimentId()).contains("base_experiment_id") + assertThat(body.baseExperimentName()).contains("base_experiment_name") + assertThat(body.experimentName()).contains("experiment_name") + assertThat(body.gitMetadataSettings()).contains(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + assertThat(body.isPublic()).contains(true) + assertThat(body.maxConcurrency()).contains(0.0) + assertThat(body.metadata()).contains(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.repoInfo()).contains(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + assertThat(body.stream()).contains(true) + assertThat(body.timeout()).contains(0.0) + assertThat(body.trialCount()).contains(0.0) } @Test fun bodyWithoutOptionalFields() { - val params = - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder().functionId("function_id").build() - ) - .task(EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build()) - .build() + val params = EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.data()) - .isEqualTo( - EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() - ) - ) - assertThat(body.projectId()).isEqualTo("project_id") - assertThat(body.scores()) - .isEqualTo( - listOf( - EvalCreateParams.Score.ofFunctionId( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .build() - ) - ) - ) - assertThat(body.task()) - .isEqualTo( - EvalCreateParams.Task.ofFunctionId( - EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build() - ) - ) + assertNotNull(body) + assertThat(body.data()).isEqualTo(EvalCreateParams.Data.ofDatasetId(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build())) + assertThat(body.projectId()).isEqualTo("project_id") + assertThat(body.scores()).isEqualTo(listOf(EvalCreateParams.Score.ofFunctionId(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .build()))) + assertThat(body.task()).isEqualTo(EvalCreateParams.Task.ofFunctionId(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .build())) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 0b43f784..95de1502 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -11,111 +11,95 @@ class ExperimentCreateParamsTest { @Test fun create() { - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("x") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("x") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build() } @Test fun body() { - val params = - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("x") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() + val params = ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("x") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).contains("dataset_version") - assertThat(body.description()).contains("description") - assertThat(body.ensureNew()).contains(true) - assertThat(body.metadata()) - .contains( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("x") - assertThat(body.public_()).contains(true) - assertThat(body.repoInfo()) - .contains( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) + assertNotNull(body) + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.description()).contains("description") + assertThat(body.ensureNew()).contains(true) + assertThat(body.metadata()).contains(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.name()).contains("x") + assertThat(body.public_()).contains(true) + assertThat(body.repoInfo()).contains(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt index 30220ebc..6a49fc3d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt @@ -9,21 +9,20 @@ class ExperimentDeleteParamsTest { @Test fun create() { - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 3830f18c..34834679 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 @@ -11,124 +11,100 @@ class ExperimentEventTest { @Test fun createExperimentEvent() { - val experimentEvent = - ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .addSpanParent("string") - .addTag("string") - .build() - assertThat(experimentEvent).isNotNull - assertThat(experimentEvent.id()).isEqualTo("id") - assertThat(experimentEvent._xactId()).isEqualTo("_xact_id") - assertThat(experimentEvent.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experimentEvent.experimentId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experimentEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experimentEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(experimentEvent.spanId()).isEqualTo("span_id") - assertThat(experimentEvent.context()) - .contains( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") - assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent.isRoot()).contains(true) - assertThat(experimentEvent.metadata()) - .contains( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(experimentEvent.metrics()) - .contains( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - assertThat(experimentEvent.origin()) - .contains( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent.scores()) - .contains( - ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(experimentEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) - assertThat(experimentEvent.spanParents().get()).containsExactly("string") - assertThat(experimentEvent.tags().get()).containsExactly("string") + val experimentEvent = ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build() + assertThat(experimentEvent).isNotNull + assertThat(experimentEvent.id()).isEqualTo("id") + assertThat(experimentEvent._xactId()).isEqualTo("_xact_id") + assertThat(experimentEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experimentEvent.experimentId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experimentEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experimentEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(experimentEvent.spanId()).isEqualTo("span_id") + assertThat(experimentEvent.context()).contains(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") + assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.isRoot()).contains(true) + assertThat(experimentEvent.metadata()).contains(ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(experimentEvent.metrics()).contains(ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + assertThat(experimentEvent.origin()).contains(ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build()) + assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.scores()).contains(ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(experimentEvent.spanAttributes()).contains(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.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/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index edb22bd0..99065209 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -11,109 +11,90 @@ class ExperimentFeedbackParamsTest { @Test fun create() { - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - .build() + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - .build() + val params = ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder().id("id").build()) - .build() + val params = ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackExperimentItem.builder().id("id").build())) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackExperimentItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder().id("id").build()) - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .build()) + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index a699676d..b782831e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -10,53 +10,50 @@ class ExperimentFetchParamsTest { @Test fun create() { - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index f537a14a..001acc2f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -10,60 +10,57 @@ class ExperimentFetchPostParamsTest { @Test fun create() { - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 9627ff9b..89d62de4 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 @@ -12,210 +12,171 @@ class ExperimentInsertParamsTest { @Test fun create() { - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + val params = ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()) - .isEqualTo( - listOf( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder().build()) - .build() + val params = ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) } @Test fun getPathParam() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 06a265e5..9e8221f4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -10,50 +10,46 @@ class ExperimentListParamsTest { @Test fun create() { - ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("experiment_name", "experiment_name") - expected.put( - "ids", - ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("experiment_name", "experiment_name") + expected.put("ids", ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ExperimentListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt index b9530a24..7a6cd8f1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class ExperimentRetrieveParamsTest { @Test fun create() { - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index 257ca247..02307eab 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -10,47 +10,44 @@ class ExperimentSummarizeParamsTest { @Test fun create() { - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() } @Test fun queryParams() { - val params = - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - val expected = QueryParams.builder() - expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("summarize_scores", "true") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() + val expected = QueryParams.builder() + expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("summarize_scores", "true") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt index 2d2df4e3..4fa1b102 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt @@ -11,72 +11,60 @@ class ExperimentTest { @Test fun createExperiment() { - val experiment = - Experiment.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .public_(true) - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .commit("commit") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - Experiment.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(experiment).isNotNull - assertThat(experiment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.name()).isEqualTo("name") - assertThat(experiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.public_()).isEqualTo(true) - assertThat(experiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.commit()).contains("commit") - assertThat(experiment.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.datasetVersion()).contains("dataset_version") - assertThat(experiment.deletedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.description()).contains("description") - assertThat(experiment.metadata()) - .contains( - Experiment.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(experiment.repoInfo()) - .contains( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - assertThat(experiment.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val experiment = Experiment.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .public_(true) + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit("commit") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .metadata(Experiment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(experiment).isNotNull + assertThat(experiment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.name()).isEqualTo("name") + assertThat(experiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.public_()).isEqualTo(true) + assertThat(experiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.commit()).contains("commit") + assertThat(experiment.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.datasetVersion()).contains("dataset_version") + assertThat(experiment.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experiment.description()).contains("description") + assertThat(experiment.metadata()).contains(Experiment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(experiment.repoInfo()).contains(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + assertThat(experiment.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index e7ed2b95..7abf3e9b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -11,119 +11,102 @@ class ExperimentUpdateParamsTest { @Test fun create() { - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build() } @Test fun body() { - val params = - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() + val params = ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).contains("dataset_version") - assertThat(body.description()).contains("description") - assertThat(body.metadata()) - .contains( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("name") - assertThat(body.public_()).contains(true) - assertThat(body.repoInfo()) - .contains( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) + assertNotNull(body) + assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.description()).contains("description") + assertThat(body.metadata()).contains(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(body.name()).contains("name") + assertThat(body.public_()).contains(true) + assertThat(body.repoInfo()).contains(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index 6543fca7..b803ec6d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -10,28 +10,22 @@ class FeedbackDatasetItemTest { @Test fun createFeedbackDatasetItem() { - val feedbackDatasetItem = - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackDatasetItem).isNotNull - assertThat(feedbackDatasetItem.id()).isEqualTo("id") - assertThat(feedbackDatasetItem.comment()).contains("comment") - assertThat(feedbackDatasetItem.metadata()) - .contains( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) - assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") + val feedbackDatasetItem = FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackDatasetItem).isNotNull + assertThat(feedbackDatasetItem.id()).isEqualTo("id") + assertThat(feedbackDatasetItem.comment()).contains("comment") + assertThat(feedbackDatasetItem.metadata()).contains(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) + assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index eef4dee8..f1fda957 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -10,42 +10,30 @@ class FeedbackExperimentItemTest { @Test fun createFeedbackExperimentItem() { - val feedbackExperimentItem = - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackExperimentItem).isNotNull - assertThat(feedbackExperimentItem.id()).isEqualTo("id") - assertThat(feedbackExperimentItem.comment()).contains("comment") - assertThat(feedbackExperimentItem._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(feedbackExperimentItem.metadata()) - .contains( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(feedbackExperimentItem.scores()) - .contains( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) - assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") + val feedbackExperimentItem = FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackExperimentItem).isNotNull + assertThat(feedbackExperimentItem.id()).isEqualTo("id") + assertThat(feedbackExperimentItem.comment()).contains("comment") + assertThat(feedbackExperimentItem._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackExperimentItem.metadata()).contains(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(feedbackExperimentItem.scores()).contains(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) + assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index 34f44497..69d0d47b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -10,42 +10,30 @@ class FeedbackProjectLogsItemTest { @Test fun createFeedbackProjectLogsItem() { - val feedbackProjectLogsItem = - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackProjectLogsItem).isNotNull - assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") - assertThat(feedbackProjectLogsItem.comment()).contains("comment") - assertThat(feedbackProjectLogsItem._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(feedbackProjectLogsItem.metadata()) - .contains( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(feedbackProjectLogsItem.scores()) - .contains( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) - assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") + val feedbackProjectLogsItem = FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackProjectLogsItem).isNotNull + assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") + assertThat(feedbackProjectLogsItem.comment()).contains("comment") + assertThat(feedbackProjectLogsItem._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackProjectLogsItem.metadata()).contains(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(feedbackProjectLogsItem.scores()).contains(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) + assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt index a1b62a0b..daebb6ba 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt @@ -9,9 +9,10 @@ class FeedbackResponseSchemaTest { @Test fun createFeedbackResponseSchema() { - val feedbackResponseSchema = - FeedbackResponseSchema.builder().status(FeedbackResponseSchema.Status.SUCCESS).build() - assertThat(feedbackResponseSchema).isNotNull - assertThat(feedbackResponseSchema.status()).isEqualTo(FeedbackResponseSchema.Status.SUCCESS) + val feedbackResponseSchema = FeedbackResponseSchema.builder() + .status(FeedbackResponseSchema.Status.SUCCESS) + .build() + assertThat(feedbackResponseSchema).isNotNull + assertThat(feedbackResponseSchema.status()).isEqualTo(FeedbackResponseSchema.Status.SUCCESS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt index ad7d703b..7017147f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -11,68 +11,54 @@ class FetchDatasetEventsResponseTest { @Test fun createFetchDatasetEventsResponse() { - val fetchDatasetEventsResponse = - FetchDatasetEventsResponse.builder() - .addEvent( - DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .origin( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .addTag("string") - .build() - ) - .cursor("cursor") - .build() - assertThat(fetchDatasetEventsResponse).isNotNull - assertThat(fetchDatasetEventsResponse.events()) - .containsExactly( - DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .origin( - DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .addTag("string") - .build() - ) - assertThat(fetchDatasetEventsResponse.cursor()).contains("cursor") + val fetchDatasetEventsResponse = FetchDatasetEventsResponse.builder() + .addEvent(DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .origin(DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .addTag("string") + .build()) + .cursor("cursor") + .build() + assertThat(fetchDatasetEventsResponse).isNotNull + assertThat(fetchDatasetEventsResponse.events()).containsExactly(DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .origin(DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .addTag("string") + .build()) + assertThat(fetchDatasetEventsResponse.cursor()).contains("cursor") } } 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 7e95ce35..fd2b1539 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 @@ -11,133 +11,106 @@ class FetchExperimentEventsResponseTest { @Test fun createFetchExperimentEventsResponse() { - val fetchExperimentEventsResponse = - FetchExperimentEventsResponse.builder() - .addEvent( - ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .addSpanParent("string") - .addTag("string") - .build() - ) - .cursor("cursor") - .build() - assertThat(fetchExperimentEventsResponse).isNotNull - assertThat(fetchExperimentEventsResponse.events()) - .containsExactly( - ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .addSpanParent("string") - .addTag("string") - .build() - ) - assertThat(fetchExperimentEventsResponse.cursor()).contains("cursor") + val fetchExperimentEventsResponse = FetchExperimentEventsResponse.builder() + .addEvent(ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build()) + .cursor("cursor") + .build() + assertThat(fetchExperimentEventsResponse).isNotNull + assertThat(fetchExperimentEventsResponse.events()).containsExactly(ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build()) + assertThat(fetchExperimentEventsResponse.cursor()).contains("cursor") } } 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 4c35853e..e99c2e4e 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 @@ -11,133 +11,106 @@ class FetchProjectLogsEventsResponseTest { @Test fun createFetchProjectLogsEventsResponse() { - val fetchProjectLogsEventsResponse = - FetchProjectLogsEventsResponse.builder() - .addEvent( - ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .addSpanParent("string") - .addTag("string") - .build() - ) - .cursor("cursor") - .build() - assertThat(fetchProjectLogsEventsResponse).isNotNull - assertThat(fetchProjectLogsEventsResponse.events()) - .containsExactly( - ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .addSpanParent("string") - .addTag("string") - .build() - ) - assertThat(fetchProjectLogsEventsResponse.cursor()).contains("cursor") + val fetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse.builder() + .addEvent(ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build()) + .cursor("cursor") + .build() + assertThat(fetchProjectLogsEventsResponse).isNotNull + assertThat(fetchProjectLogsEventsResponse.events()).containsExactly(ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build()) + assertThat(fetchProjectLogsEventsResponse.cursor()).contains("cursor") } } 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 f4114dc7..19b3364c 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 @@ -11,351 +11,216 @@ class FunctionCreateParamsTest { @Test fun create() { - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()) - .isEqualTo( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionSchema()) - .contains( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - assertThat(body.functionType()).contains(FunctionCreateParams.FunctionType.LLM) - assertThat(body.origin()) - .contains( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.functionData()).isEqualTo(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionSchema()).contains(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + assertThat(body.functionType()).contains(FunctionCreateParams.FunctionType.LLM) + assertThat(body.origin()).contains(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()) - .isEqualTo( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.functionData()).isEqualTo(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt index 480affa6..0ddf31ef 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt @@ -9,19 +9,20 @@ class FunctionDeleteParamsTest { @Test fun create() { - FunctionDeleteParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index dcfb6ecc..d494cacb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -11,146 +11,105 @@ class FunctionInvokeParamsTest { @Test fun create() { - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - .stream(true) - .version("version") - .build() + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build()) + .stream(true) + .version("version") + .build() } @Test fun body() { - val params = - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - .stream(true) - .version("version") - .build() + val params = FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build()) + .stream(true) + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body.messages()) - .contains( - listOf( - FunctionInvokeParams.Message.ofSystem( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - ) - ) - assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) - assertThat(body.parent()) - .contains( - FunctionInvokeParams.Parent.ofSpanParentStruct( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - ) - assertThat(body.stream()).contains(true) - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.messages()).contains(listOf(FunctionInvokeParams.Message.ofSystem(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()))) + assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) + assertThat(body.parent()).contains(FunctionInvokeParams.Parent.ofSpanParentStruct(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build())) + assertThat(body.stream()).contains(true) + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 289b3695..4838dff0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -10,56 +10,52 @@ class FunctionListParamsTest { @Test fun create() { - FunctionListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .functionName("function_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() + FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() } @Test fun queryParams() { - val params = - FunctionListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .functionName("function_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("function_name", "function_name") - expected.put( - "ids", - FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("slug", "slug") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("function_name", "function_name") + expected.put("ids", FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("slug", "slug") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = FunctionListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = FunctionListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.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 56eba313..6e455332 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 @@ -11,351 +11,216 @@ class FunctionReplaceParamsTest { @Test fun create() { - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()) - .isEqualTo( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionSchema()) - .contains( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - assertThat(body.functionType()).contains(FunctionReplaceParams.FunctionType.LLM) - assertThat(body.origin()) - .contains( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.functionData()).isEqualTo(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionSchema()).contains(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + assertThat(body.functionType()).contains(FunctionReplaceParams.FunctionType.LLM) + assertThat(body.origin()).contains(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()) - .isEqualTo( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.functionData()).isEqualTo(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt index 95d6777e..29b1b68a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt @@ -9,19 +9,20 @@ class FunctionRetrieveParamsTest { @Test fun create() { - FunctionRetrieveParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 b6570597..65ad88e1 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 @@ -11,234 +11,142 @@ class FunctionTest { @Test fun createFunction() { - val function = - Function.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("_xact_id") - .functionData( - Function.FunctionData.Prompt.builder() - .type(Function.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .logId(Function.LogId.P) - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .functionSchema( - Function.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(Function.FunctionType.LLM) - .metadata( - Function.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .origin( - Function.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - assertThat(function).isNotNull - assertThat(function.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function._xactId()).isEqualTo("_xact_id") - assertThat(function.functionData()) - .isEqualTo( - Function.FunctionData.ofPrompt( - Function.FunctionData.Prompt.builder() - .type(Function.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(function.logId()).isEqualTo(Function.LogId.P) - assertThat(function.name()).isEqualTo("name") - assertThat(function.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function.slug()).isEqualTo("slug") - assertThat(function.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(function.description()).contains("description") - assertThat(function.functionSchema()) - .contains( - Function.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - assertThat(function.functionType()).contains(Function.FunctionType.LLM) - assertThat(function.metadata()) - .contains( - Function.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(function.origin()) - .contains( - Function.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(function.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(function.tags().get()).containsExactly("string") + val function = Function.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._xactId("_xact_id") + .functionData(Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build()) + .logId(Function.LogId.P) + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .functionSchema(Function.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(Function.FunctionType.LLM) + .metadata(Function.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .origin(Function.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Function.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() + assertThat(function).isNotNull + assertThat(function.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function._xactId()).isEqualTo("_xact_id") + assertThat(function.functionData()).isEqualTo(Function.FunctionData.ofPrompt(Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(function.logId()).isEqualTo(Function.LogId.P) + assertThat(function.name()).isEqualTo("name") + assertThat(function.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function.slug()).isEqualTo("slug") + assertThat(function.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(function.description()).contains("description") + assertThat(function.functionSchema()).contains(Function.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + assertThat(function.functionType()).contains(Function.FunctionType.LLM) + assertThat(function.metadata()).contains(Function.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(function.origin()).contains(Function.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Function.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(function.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(function.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index 051c89be..e88bb07d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -11,298 +11,183 @@ class FunctionUpdateParamsTest { @Test fun create() { - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.functionData()) - .contains( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).contains("name") - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.functionData()).contains(FunctionUpdateParams.FunctionData.ofPrompt(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).contains("name") + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index c9d71536..e4be7a89 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -10,43 +10,44 @@ class GroupCreateParamsTest { @Test fun create() { - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = GroupCreateParams.builder().name("x").build() + val params = GroupCreateParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt index e7f479a6..db4190e4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt @@ -9,17 +9,20 @@ class GroupDeleteParamsTest { @Test fun create() { - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index c5cd5eb4..53ff9db9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -10,44 +10,40 @@ class GroupListParamsTest { @Test fun create() { - GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("group_name", "group_name") - expected.put( - "ids", - GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("group_name", "group_name") + expected.put("ids", GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = GroupListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = GroupListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index 093c89bc..1e04ba8f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -10,43 +10,44 @@ class GroupReplaceParamsTest { @Test fun create() { - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = GroupReplaceParams.builder().name("x").build() + val params = GroupReplaceParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt index 289d5b88..b86977bd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class GroupRetrieveParamsTest { @Test fun create() { - GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt index 1acccdaa..476f11a1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt @@ -10,29 +10,26 @@ class GroupTest { @Test fun createGroup() { - val group = - Group.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(group).isNotNull - assertThat(group.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.name()).isEqualTo("name") - assertThat(group.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.description()).contains("description") - assertThat(group.memberGroups().get()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.memberUsers().get()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val group = Group.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(group).isNotNull + assertThat(group.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.name()).isEqualTo("name") + assertThat(group.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(group.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(group.description()).contains("description") + assertThat(group.memberGroups().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.memberUsers().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index cb449a6e..46d425b2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -10,61 +10,60 @@ class GroupUpdateParamsTest { @Test fun create() { - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("x") - assertThat(body.removeMemberGroups()) - .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.removeMemberUsers()) - .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertNotNull(body) + assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("x") + assertThat(body.removeMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.removeMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun bodyWithoutOptionalFields() { - val params = - GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt index 53366aec..bc3c26de 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt @@ -11,45 +11,38 @@ class InsertDatasetEventTest { @Test fun createInsertDatasetEvent() { - val insertDatasetEvent = - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertDatasetEvent).isNotNull - assertThat(insertDatasetEvent.id()).contains("id") - assertThat(insertDatasetEvent._isMerge()).contains(true) - assertThat(insertDatasetEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertDatasetEvent._objectDelete()).contains(true) - assertThat(insertDatasetEvent._parentId()).contains("_parent_id") - assertThat(insertDatasetEvent.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEvent.metadata()) - .contains( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") - assertThat(insertDatasetEvent.spanId()).contains("span_id") - assertThat(insertDatasetEvent.spanParents().get()).containsExactly("string") - assertThat(insertDatasetEvent.tags().get()).containsExactly("string") + val insertDatasetEvent = InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertDatasetEvent).isNotNull + assertThat(insertDatasetEvent.id()).contains("id") + assertThat(insertDatasetEvent._isMerge()).contains(true) + assertThat(insertDatasetEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertDatasetEvent._objectDelete()).contains(true) + assertThat(insertDatasetEvent._parentId()).contains("_parent_id") + assertThat(insertDatasetEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEvent.metadata()).contains(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") + assertThat(insertDatasetEvent.spanId()).contains("span_id") + assertThat(insertDatasetEvent.spanParents().get()).containsExactly("string") + assertThat(insertDatasetEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt index 96d2a732..32730c21 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt @@ -9,8 +9,10 @@ class InsertEventsResponseTest { @Test fun createInsertEventsResponse() { - val insertEventsResponse = InsertEventsResponse.builder().addRowId("string").build() - assertThat(insertEventsResponse).isNotNull - assertThat(insertEventsResponse.rowIds()).containsExactly("string") + val insertEventsResponse = InsertEventsResponse.builder() + .addRowId("string") + .build() + assertThat(insertEventsResponse).isNotNull + assertThat(insertEventsResponse.rowIds()).containsExactly("string") } } 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 e9425570..5135be62 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 @@ -11,108 +11,88 @@ class InsertExperimentEventTest { @Test fun createInsertExperimentEvent() { - val insertExperimentEvent = - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertExperimentEvent).isNotNull - assertThat(insertExperimentEvent.id()).contains("id") - assertThat(insertExperimentEvent._isMerge()).contains(true) - assertThat(insertExperimentEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertExperimentEvent._objectDelete()).contains(true) - assertThat(insertExperimentEvent._parentId()).contains("_parent_id") - assertThat(insertExperimentEvent.context()) - .contains( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - assertThat(insertExperimentEvent.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") - assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent.metadata()) - .contains( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(insertExperimentEvent.metrics()) - .contains( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") - assertThat(insertExperimentEvent.scores()) - .contains( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(insertExperimentEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) - assertThat(insertExperimentEvent.spanId()).contains("span_id") - assertThat(insertExperimentEvent.spanParents().get()).containsExactly("string") - assertThat(insertExperimentEvent.tags().get()).containsExactly("string") + val insertExperimentEvent = InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertExperimentEvent).isNotNull + assertThat(insertExperimentEvent.id()).contains("id") + assertThat(insertExperimentEvent._isMerge()).contains(true) + assertThat(insertExperimentEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertExperimentEvent._objectDelete()).contains(true) + assertThat(insertExperimentEvent._parentId()).contains("_parent_id") + assertThat(insertExperimentEvent.context()).contains(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + assertThat(insertExperimentEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") + assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent.metadata()).contains(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(insertExperimentEvent.metrics()).contains(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") + assertThat(insertExperimentEvent.scores()).contains(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(insertExperimentEvent.spanAttributes()).contains(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.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 3454b8e9..203cd955 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 @@ -11,106 +11,86 @@ class InsertProjectLogsEventTest { @Test fun createInsertProjectLogsEvent() { - val insertProjectLogsEvent = - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertProjectLogsEvent).isNotNull - assertThat(insertProjectLogsEvent.id()).contains("id") - assertThat(insertProjectLogsEvent._isMerge()).contains(true) - assertThat(insertProjectLogsEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertProjectLogsEvent._objectDelete()).contains(true) - assertThat(insertProjectLogsEvent._parentId()).contains("_parent_id") - assertThat(insertProjectLogsEvent.context()) - .contains( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - assertThat(insertProjectLogsEvent.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent.metadata()) - .contains( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(insertProjectLogsEvent.metrics()) - .contains( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") - assertThat(insertProjectLogsEvent.scores()) - .contains( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(insertProjectLogsEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) - assertThat(insertProjectLogsEvent.spanId()).contains("span_id") - assertThat(insertProjectLogsEvent.spanParents().get()).containsExactly("string") - assertThat(insertProjectLogsEvent.tags().get()).containsExactly("string") + val insertProjectLogsEvent = InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertProjectLogsEvent).isNotNull + assertThat(insertProjectLogsEvent.id()).contains("id") + assertThat(insertProjectLogsEvent._isMerge()).contains(true) + assertThat(insertProjectLogsEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertProjectLogsEvent._objectDelete()).contains(true) + assertThat(insertProjectLogsEvent._parentId()).contains("_parent_id") + assertThat(insertProjectLogsEvent.context()).contains(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + assertThat(insertProjectLogsEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent.metadata()).contains(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(insertProjectLogsEvent.metrics()).contains(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") + assertThat(insertProjectLogsEvent.scores()).contains(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(insertProjectLogsEvent.spanAttributes()).contains(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.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/MetricSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt index cc848c7c..df3be6e7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt @@ -9,21 +9,20 @@ class MetricSummaryTest { @Test fun createMetricSummary() { - val metricSummary = - MetricSummary.builder() - .improvements(0L) - .metric(0.0) - .name("name") - .regressions(0L) - .unit("unit") - .diff(0.0) - .build() - assertThat(metricSummary).isNotNull - assertThat(metricSummary.improvements()).isEqualTo(0L) - assertThat(metricSummary.metric()).isEqualTo(0.0) - assertThat(metricSummary.name()).isEqualTo("name") - assertThat(metricSummary.regressions()).isEqualTo(0L) - assertThat(metricSummary.unit()).isEqualTo("unit") - assertThat(metricSummary.diff()).contains(0.0) + val metricSummary = MetricSummary.builder() + .improvements(0L) + .metric(0.0) + .name("name") + .regressions(0L) + .unit("unit") + .diff(0.0) + .build() + assertThat(metricSummary).isNotNull + assertThat(metricSummary.improvements()).isEqualTo(0L) + assertThat(metricSummary.metric()).isEqualTo(0.0) + assertThat(metricSummary.name()).isEqualTo("name") + assertThat(metricSummary.regressions()).isEqualTo(0L) + assertThat(metricSummary.unit()).isEqualTo("unit") + assertThat(metricSummary.diff()).contains(0.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt index 33f7f133..43f48d74 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt @@ -9,30 +9,22 @@ class OnlineScoreConfigTest { @Test fun createOnlineScoreConfig() { - val onlineScoreConfig = - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - assertThat(onlineScoreConfig).isNotNull - assertThat(onlineScoreConfig.samplingRate()).isEqualTo(0.0) - assertThat(onlineScoreConfig.scorers()) - .containsExactly( - OnlineScoreConfig.Scorer.ofFunction( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - ) - assertThat(onlineScoreConfig.applyToRootSpan()).contains(true) - assertThat(onlineScoreConfig.applyToSpanNames().get()).containsExactly("string") + val onlineScoreConfig = OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + assertThat(onlineScoreConfig).isNotNull + assertThat(onlineScoreConfig.samplingRate()).isEqualTo(0.0) + assertThat(onlineScoreConfig.scorers()).containsExactly(OnlineScoreConfig.Scorer.ofFunction(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build())) + assertThat(onlineScoreConfig.applyToRootSpan()).contains(true) + assertThat(onlineScoreConfig.applyToSpanNames().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt index b86730ee..ca6c898c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt @@ -9,21 +9,20 @@ class OrganizationDeleteParamsTest { @Test fun create() { - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index 823cdd9c..989ed6d7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -10,41 +10,37 @@ class OrganizationListParamsTest { @Test fun create() { - OrganizationListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - OrganizationListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = OrganizationListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = OrganizationListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt index ccb97ded..edc65598 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -10,86 +10,71 @@ class OrganizationMemberUpdateParamsTest { @Test fun create() { - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() + OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() } @Test fun body() { - val params = - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() + val params = OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.inviteUsers()) - .contains( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - assertThat(body.orgId()).contains("org_id") - assertThat(body.orgName()).contains("org_name") - assertThat(body.removeUsers()) - .contains( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + assertNotNull(body) + assertThat(body.inviteUsers()).contains(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + assertThat(body.orgId()).contains("org_id") + assertThat(body.orgName()).contains("org_name") + assertThat(body.removeUsers()).contains(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = OrganizationMemberUpdateParams.builder().build() + val params = OrganizationMemberUpdateParams.builder().build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt index d7faaa14..3e1619c0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class OrganizationRetrieveParamsTest { @Test fun create() { - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt index d458dc17..84924053 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt @@ -10,24 +10,22 @@ class OrganizationTest { @Test fun createOrganization() { - val organization = - Organization.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .apiUrl("api_url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .isUniversalApi(true) - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() - assertThat(organization).isNotNull - assertThat(organization.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(organization.name()).isEqualTo("name") - assertThat(organization.apiUrl()).contains("api_url") - assertThat(organization.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(organization.isUniversalApi()).contains(true) - assertThat(organization.proxyUrl()).contains("proxy_url") - assertThat(organization.realtimeUrl()).contains("realtime_url") + val organization = Organization.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .apiUrl("api_url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isUniversalApi(true) + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + assertThat(organization).isNotNull + assertThat(organization.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(organization.name()).isEqualTo("name") + assertThat(organization.apiUrl()).contains("api_url") + assertThat(organization.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(organization.isUniversalApi()).contains(true) + assertThat(organization.proxyUrl()).contains("proxy_url") + assertThat(organization.realtimeUrl()).contains("realtime_url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt index 00ff172f..4bd931bb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -10,60 +10,57 @@ class OrganizationUpdateParamsTest { @Test fun create() { - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() } @Test fun body() { - val params = - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() + val params = OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.apiUrl()).contains("api_url") - assertThat(body.isUniversalApi()).contains(true) - assertThat(body.name()).contains("name") - assertThat(body.proxyUrl()).contains("proxy_url") - assertThat(body.realtimeUrl()).contains("realtime_url") + assertNotNull(body) + assertThat(body.apiUrl()).contains("api_url") + assertThat(body.isUniversalApi()).contains(true) + assertThat(body.name()).contains("name") + assertThat(body.proxyUrl()).contains("proxy_url") + assertThat(body.realtimeUrl()).contains("realtime_url") } @Test fun bodyWithoutOptionalFields() { - val params = - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt index dabc2d8c..0819b00a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt @@ -9,16 +9,14 @@ class PatchOrganizationMembersOutputTest { @Test fun createPatchOrganizationMembersOutput() { - val patchOrganizationMembersOutput = - PatchOrganizationMembersOutput.builder() - .orgId("org_id") - .status(PatchOrganizationMembersOutput.Status.SUCCESS) - .sendEmailError("send_email_error") - .build() - assertThat(patchOrganizationMembersOutput).isNotNull - assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") - assertThat(patchOrganizationMembersOutput.status()) - .isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) - assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") + val patchOrganizationMembersOutput = PatchOrganizationMembersOutput.builder() + .orgId("org_id") + .status(PatchOrganizationMembersOutput.Status.SUCCESS) + .sendEmailError("send_email_error") + .build() + assertThat(patchOrganizationMembersOutput).isNotNull + assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") + assertThat(patchOrganizationMembersOutput.status()).isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) + assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index 32b8bed3..6636e8d0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -10,27 +10,35 @@ class ProjectCreateParamsTest { @Test fun create() { - ProjectCreateParams.builder().name("x").orgName("org_name").build() + ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build() } @Test fun body() { - val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectCreateParams.builder().name("x").build() + val params = ProjectCreateParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt index b55b368f..de270023 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt @@ -9,17 +9,20 @@ class ProjectDeleteParamsTest { @Test fun create() { - ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 2f0484be..8c574a5d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -10,44 +10,40 @@ class ProjectListParamsTest { @Test fun create() { - ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index d7a429e1..f32e301e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -11,109 +11,90 @@ class ProjectLogFeedbackParamsTest { @Test fun create() { - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - .build() + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - .build() + val params = ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) - .build() + val params = ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackProjectLogsItem.builder().id("id").build())) + assertNotNull(body) + assertThat(body.feedback()).isEqualTo(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .build()) + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index 6e341ea3..9909aba6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -10,53 +10,50 @@ class ProjectLogFetchParamsTest { @Test fun create() { - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 9d2530b0..e924c459 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -10,60 +10,57 @@ class ProjectLogFetchPostParamsTest { @Test fun create() { - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 24369344..1e5223c4 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 @@ -12,207 +12,168 @@ class ProjectLogInsertParamsTest { @Test fun create() { - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() } @Test fun body() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() + val params = ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()) - .isEqualTo( - listOf( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - ) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build())) } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder().build()) - .build() + val params = ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) } @Test fun getPathParam() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 d49aac8a..dd167ade 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 @@ -11,124 +11,100 @@ class ProjectLogsEventTest { @Test fun createProjectLogsEvent() { - val projectLogsEvent = - ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .origin( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores( - ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - ) - .addSpanParent("string") - .addTag("string") - .build() - assertThat(projectLogsEvent).isNotNull - assertThat(projectLogsEvent.id()).isEqualTo("id") - assertThat(projectLogsEvent._xactId()).isEqualTo("_xact_id") - assertThat(projectLogsEvent.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectLogsEvent.logId()).isEqualTo(ProjectLogsEvent.LogId.G) - assertThat(projectLogsEvent.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectLogsEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectLogsEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(projectLogsEvent.spanId()).isEqualTo("span_id") - assertThat(projectLogsEvent.context()) - .contains( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent.isRoot()).contains(true) - assertThat(projectLogsEvent.metadata()) - .contains( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(projectLogsEvent.metrics()) - .contains( - ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - assertThat(projectLogsEvent.origin()) - .contains( - ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build() - ) - assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent.scores()) - .contains( - ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(projectLogsEvent.spanAttributes()) - .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build()) - assertThat(projectLogsEvent.spanParents().get()).containsExactly("string") - assertThat(projectLogsEvent.tags().get()).containsExactly("string") + val projectLogsEvent = ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata(ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .origin(ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .addSpanParent("string") + .addTag("string") + .build() + assertThat(projectLogsEvent).isNotNull + assertThat(projectLogsEvent.id()).isEqualTo("id") + assertThat(projectLogsEvent._xactId()).isEqualTo("_xact_id") + assertThat(projectLogsEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectLogsEvent.logId()).isEqualTo(ProjectLogsEvent.LogId.G) + assertThat(projectLogsEvent.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectLogsEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectLogsEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(projectLogsEvent.spanId()).isEqualTo("span_id") + assertThat(projectLogsEvent.context()).contains(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.isRoot()).contains(true) + assertThat(projectLogsEvent.metadata()).contains(ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(projectLogsEvent.metrics()).contains(ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + assertThat(projectLogsEvent.origin()).contains(ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build()) + assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.scores()).contains(ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(projectLogsEvent.spanAttributes()).contains(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.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/ProjectRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt index 071ceffa..7e1485f4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt @@ -9,19 +9,20 @@ class ProjectRetrieveParamsTest { @Test fun create() { - ProjectRetrieveParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt index 95a3b093..1ad3a943 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt @@ -9,9 +9,12 @@ class ProjectScoreCategoryTest { @Test fun createProjectScoreCategory() { - val projectScoreCategory = ProjectScoreCategory.builder().name("name").value(0.0).build() - assertThat(projectScoreCategory).isNotNull - assertThat(projectScoreCategory.name()).isEqualTo("name") - assertThat(projectScoreCategory.value()).isEqualTo(0.0) + val projectScoreCategory = ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build() + assertThat(projectScoreCategory).isNotNull + assertThat(projectScoreCategory.name()).isEqualTo("name") + assertThat(projectScoreCategory.value()).isEqualTo(0.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt index ebd3f975..f91c8470 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt @@ -9,41 +9,30 @@ class ProjectScoreConfigTest { @Test fun createProjectScoreConfig() { - val projectScoreConfig = - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - assertThat(projectScoreConfig).isNotNull - assertThat(projectScoreConfig.destination()) - .contains(ProjectScoreConfig.Destination.EXPECTED) - assertThat(projectScoreConfig.multiSelect()).contains(true) - assertThat(projectScoreConfig.online()) - .contains( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) + val projectScoreConfig = ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build() + assertThat(projectScoreConfig).isNotNull + assertThat(projectScoreConfig.destination()).contains(ProjectScoreConfig.Destination.EXPECTED) + assertThat(projectScoreConfig.multiSelect()).contains(true) + assertThat(projectScoreConfig.online()).contains(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) } } 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 f2eb7ba1..01e59ccc 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 @@ -10,117 +10,96 @@ class ProjectScoreCreateParamsTest { @Test fun create() { - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build() } @Test fun body() { - val params = - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() + val params = ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build() - val body = params._body() + val body = params._body() - 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.categories()) - .contains( - ProjectScoreCreateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - ) - assertThat(body.config()) - .contains( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - assertThat(body.description()).contains("description") + 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.categories()).contains(ProjectScoreCreateParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build()))) + assertThat(body.config()).contains(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .build() + val params = ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt index f341257a..948fc987 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt @@ -9,21 +9,20 @@ class ProjectScoreDeleteParamsTest { @Test fun create() { - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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..8aa8a527 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 @@ -10,59 +10,49 @@ class ProjectScoreListParamsTest { @Test fun create() { - ProjectScoreListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectScoreName("project_score_name") + .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ProjectScoreListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("project_score_name", "project_score_name") - expected.put( - "score_type", - ProjectScoreListParams.ScoreType.ofProject( - ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString() - ) - .toString(), - ) - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectScoreName("project_score_name") + .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("project_score_name", "project_score_name") + expected.put("score_type", ProjectScoreListParams.ScoreType.ofProject(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString()).toString()) + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectScoreListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectScoreListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } 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 022d016b..5fc517ab 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 @@ -10,117 +10,96 @@ class ProjectScoreReplaceParamsTest { @Test fun create() { - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build() } @Test fun body() { - val params = - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() + val params = ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build() - val body = params._body() + val body = params._body() - 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.categories()) - .contains( - ProjectScoreReplaceParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - ) - assertThat(body.config()) - .contains( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - assertThat(body.description()).contains("description") + 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.categories()).contains(ProjectScoreReplaceParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build()))) + assertThat(body.config()).contains(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .build() + val params = ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt index d5ba83a1..2e00d311 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class ProjectScoreRetrieveParamsTest { @Test fun create() { - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 888ef861..74af95f8 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 @@ -10,74 +10,58 @@ class ProjectScoreTest { @Test fun createProjectScore() { - val projectScore = - ProjectScore.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScore.ScoreType.SLIDER) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .position("position") - .build() - assertThat(projectScore).isNotNull - 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.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectScore.categories()) - .contains( - ProjectScore.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - ) - assertThat(projectScore.config()) - .contains( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - assertThat(projectScore.created()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectScore.description()).contains("description") - assertThat(projectScore.position()).contains("position") + val projectScore = ProjectScore.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScore.ScoreType.SLIDER) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .position("position") + .build() + assertThat(projectScore).isNotNull + 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.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectScore.categories()).contains(ProjectScore.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build()))) + assertThat(projectScore.config()).contains(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + assertThat(projectScore.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectScore.description()).contains("description") + assertThat(projectScore.position()).contains("position") } } 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 7f153a84..411468cf 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 @@ -10,124 +10,102 @@ class ProjectScoreUpdateParamsTest { @Test fun create() { - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() } @Test fun body() { - val params = - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() + val params = ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.categories()) - .contains( - ProjectScoreUpdateParams.Categories.ofCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - ) - assertThat(body.config()) - .contains( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") - assertThat(body.scoreType()).contains(ProjectScoreUpdateParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.categories()).contains(ProjectScoreUpdateParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build()))) + assertThat(body.config()).contains(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.scoreType()).contains(ProjectScoreUpdateParams.ScoreType.SLIDER) } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt index 0624066d..78b8b0dc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt @@ -9,8 +9,10 @@ class ProjectSettingsTest { @Test fun createProjectSettings() { - val projectSettings = ProjectSettings.builder().comparisonKey("comparison_key").build() - assertThat(projectSettings).isNotNull - assertThat(projectSettings.comparisonKey()).contains("comparison_key") + val projectSettings = ProjectSettings.builder() + .comparisonKey("comparison_key") + .build() + assertThat(projectSettings).isNotNull + assertThat(projectSettings.comparisonKey()).contains("comparison_key") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt index 04649ccf..f9195ece 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -10,45 +10,43 @@ class ProjectTagCreateParamsTest { @Test fun create() { - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() } @Test fun body() { - val params = - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") + val params = ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt index 30ff07c4..6149efa2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt @@ -9,21 +9,20 @@ class ProjectTagDeleteParamsTest { @Test fun create() { - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index b0008157..99c6c2e3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -10,50 +10,46 @@ class ProjectTagListParamsTest { @Test fun create() { - ProjectTagListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectTagName("project_tag_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectTagName("project_tag_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - ProjectTagListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectTagName("project_tag_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("project_tag_name", "project_tag_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectTagName("project_tag_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("project_tag_name", "project_tag_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectTagListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectTagListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt index 9e25d87a..53ca1e92 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -10,45 +10,43 @@ class ProjectTagReplaceParamsTest { @Test fun create() { - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() } @Test fun body() { - val params = - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") + val params = ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt index a1d9d5ee..041d9af1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class ProjectTagRetrieveParamsTest { @Test fun create() { - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt index d9a83759..d8cdefb8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt @@ -10,23 +10,22 @@ class ProjectTagTest { @Test fun createProjectTag() { - val projectTag = - ProjectTag.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .build() - assertThat(projectTag).isNotNull - assertThat(projectTag.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.name()).isEqualTo("name") - assertThat(projectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.color()).contains("color") - assertThat(projectTag.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectTag.description()).contains("description") + val projectTag = ProjectTag.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .build() + assertThat(projectTag).isNotNull + assertThat(projectTag.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.name()).isEqualTo("name") + assertThat(projectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.color()).contains("color") + assertThat(projectTag.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectTag.description()).contains("description") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt index 343aa380..24144f60 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -10,54 +10,51 @@ class ProjectTagUpdateParamsTest { @Test fun create() { - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() } @Test fun body() { - val params = - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") + val params = ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt index 390af485..0efd6798 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt @@ -10,24 +10,26 @@ class ProjectTest { @Test fun createProject() { - val project = - Project.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(project).isNotNull - assertThat(project.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(project.name()).isEqualTo("name") - assertThat(project.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(project.settings()) - .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) - assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val project = Project.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(project).isNotNull + assertThat(project.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(project.name()).isEqualTo("name") + assertThat(project.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.settings()).contains(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 63716ab9..36d8c5bb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -10,48 +10,54 @@ class ProjectUpdateParamsTest { @Test fun create() { - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .build() + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .build() } @Test fun body() { - val params = - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).contains("name") - assertThat(body.settings()) - .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) + val params = ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).contains("name") + assertThat(body.settings()).contains(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 92e03d0c..81985d29 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -11,279 +11,174 @@ class PromptCreateParamsTest { @Test fun create() { - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionType()).contains(PromptCreateParams.FunctionType.LLM) - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionType()).contains(PromptCreateParams.FunctionType.LLM) + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index f2acf4d6..6d419229 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -10,151 +10,86 @@ class PromptDataTest { @Test fun createPromptData() { - val promptData = - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - assertThat(promptData).isNotNull - assertThat(promptData.options()) - .contains( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - assertThat(promptData.origin()) - .contains( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - assertThat(promptData.parser()) - .contains( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - assertThat(promptData.prompt()) - .contains( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - assertThat(promptData.toolFunctions().get()) - .containsExactly( - PromptData.ToolFunction.ofFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - ) + val promptData = PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build() + assertThat(promptData).isNotNull + assertThat(promptData.options()).contains(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + assertThat(promptData.origin()).contains(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + assertThat(promptData.parser()).contains(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + assertThat(promptData.prompt()).contains(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + assertThat(promptData.toolFunctions().get()).containsExactly(PromptData.ToolFunction.ofFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build())) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt index ac1b91bb..729e3959 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt @@ -9,17 +9,20 @@ class PromptDeleteParamsTest { @Test fun create() { - PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index 913ef416..9ff476ea 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -10,56 +10,52 @@ class PromptListParamsTest { @Test fun create() { - PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .promptName("prompt_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() + PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .promptName("prompt_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() } @Test fun queryParams() { - val params = - PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .promptName("prompt_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("prompt_name", "prompt_name") - expected.put("slug", "slug") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .promptName("prompt_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("prompt_name", "prompt_name") + expected.put("slug", "slug") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = PromptListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = PromptListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt index 119a47b3..e2f8f9bc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -9,72 +9,42 @@ class PromptOptionsTest { @Test fun createPromptOptions() { - val promptOptions = - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - assertThat(promptOptions).isNotNull - assertThat(promptOptions.model()).contains("model") - assertThat(promptOptions.params()) - .contains( - PromptOptions.Params.ofOpenAIModel( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - ) - assertThat(promptOptions.position()).contains("position") + val promptOptions = PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build() + assertThat(promptOptions).isNotNull + assertThat(promptOptions.model()).contains("model") + assertThat(promptOptions.params()).contains(PromptOptions.Params.ofOpenAIModel(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build())) + assertThat(promptOptions.position()).contains("position") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 18d87eb2..22a37bc6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -11,279 +11,174 @@ class PromptReplaceParamsTest { @Test fun create() { - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() } @Test fun body() { - val params = - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() + val params = PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionType()).contains(PromptReplaceParams.FunctionType.LLM) - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionType()).contains(PromptReplaceParams.FunctionType.LLM) + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt index 622fb8c9..322439c4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class PromptRetrieveParamsTest { @Test fun create() { - PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index c65cd2c6..692fcfe0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -11,193 +11,118 @@ class PromptTest { @Test fun createPrompt() { - val prompt = - Prompt.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("_xact_id") - .logId(Prompt.LogId.P) - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .functionType(Prompt.FunctionType.LLM) - .metadata( - Prompt.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - assertThat(prompt).isNotNull - assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt._xactId()).isEqualTo("_xact_id") - assertThat(prompt.logId()).isEqualTo(Prompt.LogId.P) - assertThat(prompt.name()).isEqualTo("name") - assertThat(prompt.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt.slug()).isEqualTo("slug") - assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(prompt.description()).contains("description") - assertThat(prompt.functionType()).contains(Prompt.FunctionType.LLM) - assertThat(prompt.metadata()) - .contains( - Prompt.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(prompt.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(prompt.tags().get()).containsExactly("string") + val prompt = Prompt.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._xactId("_xact_id") + .logId(Prompt.LogId.P) + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .functionType(Prompt.FunctionType.LLM) + .metadata(Prompt.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build() + assertThat(prompt).isNotNull + assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt._xactId()).isEqualTo("_xact_id") + assertThat(prompt.logId()).isEqualTo(Prompt.LogId.P) + assertThat(prompt.name()).isEqualTo("name") + assertThat(prompt.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt.slug()).isEqualTo("slug") + assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(prompt.description()).contains("description") + assertThat(prompt.functionType()).contains(Prompt.FunctionType.LLM) + assertThat(prompt.metadata()).contains(Prompt.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + assertThat(prompt.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(prompt.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 7dae6fe3..1212ba35 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -11,279 +11,177 @@ class PromptUpdateParamsTest { @Test fun create() { - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .slug("slug") - .addTag("string") - .build() + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .slug("slug") + .addTag("string") + .build() } @Test fun body() { - val params = - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .slug("slug") - .addTag("string") - .build() + val params = PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .slug("slug") + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") - assertThat(body.promptData()) - .contains( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams.ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - assertThat(body.slug()).contains("slug") - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.promptData()).contains(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + assertThat(body.slug()).contains("slug") + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = - PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt index 83eec5e0..a5d12e34 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt @@ -9,27 +9,26 @@ class RepoInfoTest { @Test fun createRepoInfo() { - val repoInfo = - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - assertThat(repoInfo).isNotNull - assertThat(repoInfo.authorEmail()).contains("author_email") - assertThat(repoInfo.authorName()).contains("author_name") - assertThat(repoInfo.branch()).contains("branch") - assertThat(repoInfo.commit()).contains("commit") - assertThat(repoInfo.commitMessage()).contains("commit_message") - assertThat(repoInfo.commitTime()).contains("commit_time") - assertThat(repoInfo.dirty()).contains(true) - assertThat(repoInfo.gitDiff()).contains("git_diff") - assertThat(repoInfo.tag()).contains("tag") + val repoInfo = RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + assertThat(repoInfo).isNotNull + assertThat(repoInfo.authorEmail()).contains("author_email") + assertThat(repoInfo.authorName()).contains("author_name") + assertThat(repoInfo.branch()).contains("branch") + assertThat(repoInfo.commit()).contains("commit") + assertThat(repoInfo.commitMessage()).contains("commit_message") + assertThat(repoInfo.commitTime()).contains("commit_time") + assertThat(repoInfo.dirty()).contains(true) + assertThat(repoInfo.gitDiff()).contains("git_diff") + assertThat(repoInfo.tag()).contains("tag") } } 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..bfd19a81 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 @@ -10,67 +10,53 @@ class RoleCreateParamsTest { @Test fun create() { - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberPermissions()) - .contains( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberPermissions()).contains(listOf(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = RoleCreateParams.builder().name("x").build() + val params = RoleCreateParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt index 3d7f97a5..55d96c38 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt @@ -9,17 +9,20 @@ class RoleDeleteParamsTest { @Test fun create() { - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 9a390aec..82eb0ae2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -10,44 +10,40 @@ class RoleListParamsTest { @Test fun create() { - RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("role_name", "role_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("role_name", "role_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = RoleListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = RoleListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.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..d544cfc4 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 @@ -10,67 +10,53 @@ class RoleReplaceParamsTest { @Test fun create() { - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberPermissions()) - .contains( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberPermissions()).contains(listOf(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = RoleReplaceParams.builder().name("x").build() + val params = RoleReplaceParams.builder() + .name("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt index 696fe39a..10474e3d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class RoleRetrieveParamsTest { @Test fun create() { - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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..5a7786a9 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 @@ -10,38 +10,32 @@ class RoleTest { @Test fun createRole() { - val role = - Role.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .addMemberPermission( - Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(role).isNotNull - assertThat(role.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.name()).isEqualTo("name") - assertThat(role.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.description()).contains("description") - assertThat(role.memberPermissions().get()) - .containsExactly( - Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) - .build() - ) - assertThat(role.memberRoles().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val role = Role.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addMemberPermission(Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(role).isNotNull + assertThat(role.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.name()).isEqualTo("name") + assertThat(role.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(role.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(role.description()).contains("description") + assertThat(role.memberPermissions().get()).containsExactly(Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + assertThat(role.memberRoles().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.userId()).contains("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..d20c05b3 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 @@ -10,108 +10,78 @@ class RoleUpdateParamsTest { @Test fun create() { - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addMemberPermissions()) - .contains( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.addMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("x") - assertThat(body.removeMemberPermissions()) - .contains( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.removeMemberRoles()) - .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertNotNull(body) + assertThat(body.addMemberPermissions()).contains(listOf(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.addMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("x") + assertThat(body.removeMemberPermissions()).contains(listOf(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.removeMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun bodyWithoutOptionalFields() { - val params = - RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt index 35c169e5..08e71773 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt @@ -9,19 +9,18 @@ class ScoreSummaryTest { @Test fun createScoreSummary() { - val scoreSummary = - ScoreSummary.builder() - .improvements(0L) - .name("name") - .regressions(0L) - .score(0.0) - .diff(-1.0) - .build() - assertThat(scoreSummary).isNotNull - assertThat(scoreSummary.improvements()).isEqualTo(0L) - assertThat(scoreSummary.name()).isEqualTo("name") - assertThat(scoreSummary.regressions()).isEqualTo(0L) - assertThat(scoreSummary.score()).isEqualTo(0.0) - assertThat(scoreSummary.diff()).contains(-1.0) + val scoreSummary = ScoreSummary.builder() + .improvements(0L) + .name("name") + .regressions(0L) + .score(0.0) + .diff(-1.0) + .build() + assertThat(scoreSummary).isNotNull + assertThat(scoreSummary.improvements()).isEqualTo(0L) + assertThat(scoreSummary.name()).isEqualTo("name") + assertThat(scoreSummary.regressions()).isEqualTo(0L) + assertThat(scoreSummary.score()).isEqualTo(0.0) + assertThat(scoreSummary.diff()).contains(-1.0) } } 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..83cd4c86 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,12 @@ class SpanAttributesTest { @Test fun createSpanAttributes() { - val spanAttributes = - SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() - assertThat(spanAttributes).isNotNull - assertThat(spanAttributes.name()).contains("name") - assertThat(spanAttributes.type()).contains(SpanAttributes.Type.LLM) + val spanAttributes = SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + assertThat(spanAttributes).isNotNull + assertThat(spanAttributes.name()).contains("name") + assertThat(spanAttributes.type()).contains(SpanAttributes.Type.LLM) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt index a972b937..e84b0503 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt @@ -10,28 +10,26 @@ class SpanIFrameTest { @Test fun createSpanIFrame() { - val spanIFrame = - SpanIFrame.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .postMessage(true) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(spanIFrame).isNotNull - assertThat(spanIFrame.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(spanIFrame.name()).isEqualTo("name") - assertThat(spanIFrame.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(spanIFrame.url()).isEqualTo("url") - assertThat(spanIFrame.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(spanIFrame.deletedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(spanIFrame.description()).contains("description") - assertThat(spanIFrame.postMessage()).contains(true) - assertThat(spanIFrame.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val spanIFrame = SpanIFrame.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .postMessage(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(spanIFrame).isNotNull + assertThat(spanIFrame.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(spanIFrame.name()).isEqualTo("name") + assertThat(spanIFrame.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(spanIFrame.url()).isEqualTo("url") + assertThat(spanIFrame.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(spanIFrame.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(spanIFrame.description()).contains("description") + assertThat(spanIFrame.postMessage()).contains(true) + assertThat(spanIFrame.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt index baf7a58f..6f3e3abe 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt @@ -10,50 +10,48 @@ class SpanIframeCreateParamsTest { @Test fun create() { - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() } @Test fun body() { - val params = - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") - assertThat(body.description()).contains("description") - assertThat(body.postMessage()).contains(true) + val params = SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + assertThat(body.description()).contains("description") + assertThat(body.postMessage()).contains(true) } @Test fun bodyWithoutOptionalFields() { - val params = - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") + val params = SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt index a1a4a437..dd3daa38 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt @@ -9,21 +9,20 @@ class SpanIframeDeleteParamsTest { @Test fun create() { - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt index 50d720b8..7d25f092 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt @@ -10,44 +10,40 @@ class SpanIframeListParamsTest { @Test fun create() { - SpanIframeListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .spanIframeName("span_iframe_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .spanIframeName("span_iframe_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - SpanIframeListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .spanIframeName("span_iframe_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("span_iframe_name", "span_iframe_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = SpanIframeListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .spanIframeName("span_iframe_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("span_iframe_name", "span_iframe_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = SpanIframeListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = SpanIframeListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt index 305c97ad..10f992e8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt @@ -10,50 +10,48 @@ class SpanIframeReplaceParamsTest { @Test fun create() { - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() } @Test fun body() { - val params = - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") - assertThat(body.description()).contains("description") - assertThat(body.postMessage()).contains(true) + val params = SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + assertThat(body.description()).contains("description") + assertThat(body.postMessage()).contains(true) } @Test fun bodyWithoutOptionalFields() { - val params = - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") + val params = SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt index ad6927a4..153e172c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt @@ -9,21 +9,20 @@ class SpanIframeRetrieveParamsTest { @Test fun create() { - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index 57fce4c2..575579e0 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -10,54 +10,51 @@ class SpanIframeUpdateParamsTest { @Test fun create() { - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() } @Test fun body() { - val params = - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).contains("name") - assertThat(body.postMessage()).contains(true) - assertThat(body.url()).contains("url") + val params = SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).contains("name") + assertThat(body.postMessage()).contains(true) + assertThat(body.url()).contains("url") } @Test fun bodyWithoutOptionalFields() { - val params = - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt index a9675505..8a1b1547 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt @@ -9,20 +9,22 @@ class SummarizeDatasetResponseTest { @Test fun createSummarizeDatasetResponse() { - val summarizeDatasetResponse = - SummarizeDatasetResponse.builder() - .datasetName("dataset_name") - .datasetUrl("https://example.com") - .projectName("project_name") - .projectUrl("https://example.com") - .dataSummary(DataSummary.builder().totalRecords(0L).build()) - .build() - assertThat(summarizeDatasetResponse).isNotNull - assertThat(summarizeDatasetResponse.datasetName()).isEqualTo("dataset_name") - assertThat(summarizeDatasetResponse.datasetUrl()).isEqualTo("https://example.com") - assertThat(summarizeDatasetResponse.projectName()).isEqualTo("project_name") - assertThat(summarizeDatasetResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(summarizeDatasetResponse.dataSummary()) - .contains(DataSummary.builder().totalRecords(0L).build()) + val summarizeDatasetResponse = SummarizeDatasetResponse.builder() + .datasetName("dataset_name") + .datasetUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .dataSummary(DataSummary.builder() + .totalRecords(0L) + .build()) + .build() + assertThat(summarizeDatasetResponse).isNotNull + assertThat(summarizeDatasetResponse.datasetName()).isEqualTo("dataset_name") + assertThat(summarizeDatasetResponse.datasetUrl()).isEqualTo("https://example.com") + assertThat(summarizeDatasetResponse.projectName()).isEqualTo("project_name") + assertThat(summarizeDatasetResponse.projectUrl()).isEqualTo("https://example.com") + assertThat(summarizeDatasetResponse.dataSummary()).contains(DataSummary.builder() + .totalRecords(0L) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt index 35580e00..60d9d9a2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt @@ -10,88 +10,56 @@ class SummarizeExperimentResponseTest { @Test fun createSummarizeExperimentResponse() { - val summarizeExperimentResponse = - SummarizeExperimentResponse.builder() - .experimentName("experiment_name") - .experimentUrl("https://example.com") - .projectName("project_name") - .projectUrl("https://example.com") - .comparisonExperimentName("comparison_experiment_name") - .metrics( - SummarizeExperimentResponse.Metrics.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "improvements" to 0, - "metric" to 0, - "name" to "name", - "regressions" to 0, - "unit" to "unit", - "diff" to 0, - ) - ), - ) - .build() - ) - .scores( - SummarizeExperimentResponse.Scores.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "improvements" to 0, - "name" to "name", - "regressions" to 0, - "score" to 0, - "diff" to -1, - ) - ), - ) - .build() - ) - .build() - assertThat(summarizeExperimentResponse).isNotNull - assertThat(summarizeExperimentResponse.experimentName()).isEqualTo("experiment_name") - assertThat(summarizeExperimentResponse.experimentUrl()).isEqualTo("https://example.com") - assertThat(summarizeExperimentResponse.projectName()).isEqualTo("project_name") - assertThat(summarizeExperimentResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(summarizeExperimentResponse.comparisonExperimentName()) - .contains("comparison_experiment_name") - assertThat(summarizeExperimentResponse.metrics()) - .contains( - SummarizeExperimentResponse.Metrics.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "improvements" to 0, - "metric" to 0, - "name" to "name", - "regressions" to 0, - "unit" to "unit", - "diff" to 0, - ) - ), - ) - .build() - ) - assertThat(summarizeExperimentResponse.scores()) - .contains( - SummarizeExperimentResponse.Scores.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "improvements" to 0, - "name" to "name", - "regressions" to 0, - "score" to 0, - "diff" to -1, - ) - ), - ) - .build() - ) + val summarizeExperimentResponse = SummarizeExperimentResponse.builder() + .experimentName("experiment_name") + .experimentUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .comparisonExperimentName("comparison_experiment_name") + .metrics(SummarizeExperimentResponse.Metrics.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf( + "improvements" to 0, + "metric" to 0, + "name" to "name", + "regressions" to 0, + "unit" to "unit", + "diff" to 0, + ))) + .build()) + .scores(SummarizeExperimentResponse.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf( + "improvements" to 0, + "name" to "name", + "regressions" to 0, + "score" to 0, + "diff" to -1, + ))) + .build()) + .build() + assertThat(summarizeExperimentResponse).isNotNull + assertThat(summarizeExperimentResponse.experimentName()).isEqualTo("experiment_name") + assertThat(summarizeExperimentResponse.experimentUrl()).isEqualTo("https://example.com") + assertThat(summarizeExperimentResponse.projectName()).isEqualTo("project_name") + assertThat(summarizeExperimentResponse.projectUrl()).isEqualTo("https://example.com") + assertThat(summarizeExperimentResponse.comparisonExperimentName()).contains("comparison_experiment_name") + assertThat(summarizeExperimentResponse.metrics()).contains(SummarizeExperimentResponse.Metrics.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf( + "improvements" to 0, + "metric" to 0, + "name" to "name", + "regressions" to 0, + "unit" to "unit", + "diff" to 0, + ))) + .build()) + assertThat(summarizeExperimentResponse.scores()).contains(SummarizeExperimentResponse.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(mapOf( + "improvements" to 0, + "name" to "name", + "regressions" to 0, + "score" to 0, + "diff" to -1, + ))) + .build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt index 56273dcf..7dd57e85 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt @@ -8,6 +8,6 @@ class TopLevelHelloWorldParamsTest { @Test fun create() { - TopLevelHelloWorldParams.builder().build() + TopLevelHelloWorldParams.builder().build() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 02f28453..3ad7d36d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -10,50 +10,46 @@ class UserListParamsTest { @Test fun create() { - UserListParams.builder() - .email("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName("string") - .givenName("string") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + UserListParams.builder() + .email("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName("string") + .givenName("string") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = - UserListParams.builder() - .email("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName("string") - .givenName("string") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("email", UserListParams.Email.ofString("string").toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("family_name", UserListParams.FamilyName.ofString("string").toString()) - expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) - expected.put( - "ids", - UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = UserListParams.builder() + .email("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName("string") + .givenName("string") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("email", UserListParams.Email.ofString("string").toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("family_name", UserListParams.FamilyName.ofString("string").toString()) + expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) + expected.put("ids", UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = UserListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = UserListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt index f1686cc4..8d679477 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt @@ -9,17 +9,20 @@ class UserRetrieveParamsTest { @Test fun create() { - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - assertThat(params).isNotNull - // path param "userId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "userId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt index fe6f4802..5de80102 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt @@ -10,21 +10,20 @@ class UserTest { @Test fun createUser() { - val user = - User.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .avatarUrl("avatar_url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .email("email") - .familyName("family_name") - .givenName("given_name") - .build() - assertThat(user).isNotNull - assertThat(user.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(user.avatarUrl()).contains("avatar_url") - assertThat(user.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(user.email()).contains("email") - assertThat(user.familyName()).contains("family_name") - assertThat(user.givenName()).contains("given_name") + val user = User.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .avatarUrl("avatar_url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .familyName("family_name") + .givenName("given_name") + .build() + assertThat(user).isNotNull + assertThat(user.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(user.avatarUrl()).contains("avatar_url") + assertThat(user.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(user.email()).contains("email") + assertThat(user.familyName()).contains("family_name") + assertThat(user.givenName()).contains("given_name") } } 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 1f09c824..19223c9d 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 @@ -12,138 +12,104 @@ class ViewCreateParamsTest { @Test fun create() { - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() } @Test fun body() { - val params = - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() + val params = ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() - val body = params._body() + val body = params._body() - 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.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.options()) - .contains( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .contains( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) + 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.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()).contains(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).contains(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .build() + val params = ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - 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.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) + 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.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt index 7d1baa55..17b06040 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt @@ -10,20 +10,16 @@ class ViewDataSearchTest { @Test fun createViewDataSearch() { - val viewDataSearch = - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - assertThat(viewDataSearch).isNotNull - assertThat(viewDataSearch.filter().get()) - .containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.match().get()) - .containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.sort().get()) - .containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.tag().get()).containsExactly(JsonValue.from(mapOf())) + val viewDataSearch = ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + assertThat(viewDataSearch).isNotNull + assertThat(viewDataSearch.filter().get()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.match().get()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.sort().get()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.tag().get()).containsExactly(JsonValue.from(mapOf())) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt index 10157eee..86ef2bc6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt @@ -10,26 +10,20 @@ class ViewDataTest { @Test fun createViewData() { - val viewData = - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - assertThat(viewData).isNotNull - assertThat(viewData.search()) - .contains( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) + val viewData = ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build() + assertThat(viewData).isNotNull + assertThat(viewData.search()).contains(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) } } 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..fba424b7 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 @@ -10,57 +10,54 @@ class ViewDeleteParamsTest { @Test fun create() { - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() } @Test fun body() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @Test fun bodyWithoutOptionalFields() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @Test fun getPathParam() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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..56b75c4d 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 @@ -10,56 +10,51 @@ class ViewListParamsTest { @Test fun create() { - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.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) - .build() + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.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) + .build() } @Test fun queryParams() { - val params = - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.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) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - 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()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.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) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("ids", ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) + 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()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt index 3d6989ba..09ead451 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt @@ -10,33 +10,22 @@ class ViewOptionsTest { @Test fun createViewOptions() { - val viewOptions = - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - assertThat(viewOptions).isNotNull - assertThat(viewOptions.columnOrder().get()).containsExactly("string") - assertThat(viewOptions.columnSizing()) - .contains( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - assertThat(viewOptions.columnVisibility()) - .contains( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) + val viewOptions = ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build() + assertThat(viewOptions).isNotNull + assertThat(viewOptions.columnOrder().get()).containsExactly("string") + assertThat(viewOptions.columnSizing()).contains(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + assertThat(viewOptions.columnVisibility()).contains(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .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 069dcccd..cc4d9372 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 @@ -12,138 +12,104 @@ class ViewReplaceParamsTest { @Test fun create() { - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() } @Test fun body() { - val params = - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() + val params = ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() - val body = params._body() + val body = params._body() - 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.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.options()) - .contains( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .contains( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) + 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.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()).contains(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).contains(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) } @Test fun bodyWithoutOptionalFields() { - val params = - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .build() + val params = ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - 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.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) + 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.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..ed35155f 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 @@ -10,53 +10,50 @@ class ViewRetrieveParamsTest { @Test fun create() { - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() } @Test fun queryParams() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 fd19dbb6..4ebef9a9 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 @@ -11,81 +11,58 @@ class ViewTest { @Test fun createView() { - val view = - View.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(View.ObjectType.ORGANIZATION) - .viewType(View.ViewType.PROJECTS) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - assertThat(view).isNotNull - 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.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")) - assertThat(view.options()) - .contains( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(view.viewData()) - .contains( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) + val view = View.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(View.ObjectType.ORGANIZATION) + .viewType(View.ViewType.PROJECTS) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build() + assertThat(view).isNotNull + 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.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")) + assertThat(view.options()).contains(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.viewData()).contains(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) } } 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 67d83174..6208c9bb 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 @@ -11,149 +11,114 @@ class ViewUpdateParamsTest { @Test fun create() { - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() } @Test fun body() { - val params = - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() + val params = ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) - assertThat(body.name()).contains("name") - assertThat(body.options()) - .contains( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .contains( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - assertThat(body.viewType()).contains(ViewUpdateParams.ViewType.PROJECTS) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertThat(body.name()).contains("name") + assertThat(body.options()).contains(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).contains(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + assertThat(body.viewType()).contains(ViewUpdateParams.ViewType.PROJECTS) } @Test fun bodyWithoutOptionalFields() { - val params = - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .build() + val params = ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) } @Test fun getPathParam() { - val params = - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 1d611bfb..76b08329 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -35,10 +35,9 @@ class ErrorHandlingTest { companion object { - private val ERROR: BraintrustError = - BraintrustError.builder() - .putAdditionalProperty("errorProperty", JsonValue.from("42")) - .build() + private val ERROR: BraintrustError = BraintrustError.builder() + .putAdditionalProperty("errorProperty", JsonValue.from("42")) + .build() private val ERROR_JSON: ByteArray = jsonMapper().writeValueAsBytes(ERROR) @@ -53,189 +52,231 @@ class ErrorHandlingTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - client = - BraintrustOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.httpBaseUrl) - .apiKey("My API Key") - .build() + client = BraintrustOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() } @Test fun projectsCreate400() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(400) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate401() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(401) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate403() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(403) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate404() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(404) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate422() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(422) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate429() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(429) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate500() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(500) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreate999() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e.statusCode()).isEqualTo(999) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(999) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(ERROR_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains( + entry(HEADER_NAME, listOf(HEADER_VALUE)) + ) } @Test fun projectsCreateInvalidJsonBody() { - val projectService = client.projects() - stubFor( - post(anyUrl()) - .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) - ) - - val e = - assertThrows { - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - } - - assertThat(e).hasMessage("Error reading response") + val projectService = client.projects() + stubFor( + post(anyUrl()).willReturn( + status(200) + .withHeader(HEADER_NAME, HEADER_VALUE) + .withBody(NOT_JSON) + ) + ) + + val e = assertThrows { + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + } + + assertThat(e).hasMessage("Error reading response") } private fun Headers.toMap(): Map> = diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt index 9e25370e..b65e3e95 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt @@ -26,33 +26,30 @@ internal class ServiceParamsTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - client = - BraintrustOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.httpBaseUrl) - .apiKey("My API Key") - .build() + client = BraintrustOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() } @Test fun create() { - val projectService = client.projects() - stubFor(post(anyUrl()).willReturn(ok("{}"))) - - projectService.create( - ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .putAdditionalHeader("Secret-Header", "42") - .putAdditionalQueryParam("secret_query_param", "42") - .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) - .build() - ) - - verify( - postRequestedFor(anyUrl()) - .withHeader("Secret-Header", equalTo("42")) - .withQueryParam("secret_query_param", equalTo("42")) - .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) - ) + val projectService = client.projects() + stubFor(post(anyUrl()).willReturn(ok("{}"))) + + projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build()) + + verify( + postRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) + ) } } 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..7c23deb9 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 @@ -18,155 +18,127 @@ class AclServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = - aclServiceAsync.create( - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val acl = aclFuture.get() - acl.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = aclServiceAsync.create(AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val acl = aclFuture.get() + acl.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = - aclServiceAsync.retrieve( - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val acl = aclFuture.get() - acl.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = aclServiceAsync.retrieve(AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val acl = aclFuture.get() + acl.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val pageFuture = - aclServiceAsync.list( - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build() - ) - - val page = pageFuture.get() - page.response().validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val pageFuture = aclServiceAsync.list(AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build()) + + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = - aclServiceAsync.delete( - AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val acl = aclFuture.get() - acl.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = aclServiceAsync.delete(AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val acl = aclFuture.get() + acl.validate() } @Test fun batchUpdate() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclBatchUpdateResponseFuture = - aclServiceAsync.batchUpdate( - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) - - val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() - aclBatchUpdateResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclBatchUpdateResponseFuture = aclServiceAsync.batchUpdate(AclBatchUpdateParams.builder() + .addAddAcl(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build()) + + val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() + aclBatchUpdateResponse.validate() } @Test fun findAndDelete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = - aclServiceAsync.findAndDelete( - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val acl = aclFuture.get() - acl.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = aclServiceAsync.findAndDelete(AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val acl = aclFuture.get() + acl.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt index cc5d3c0a..c7a4be39 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams +import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams @@ -19,158 +20,130 @@ class AiSecretServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.create( - AiSecretCreateParams.builder() - .name("name") - .metadata( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.create(AiSecretCreateParams.builder() + .name("name") + .metadata(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.retrieve( - AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.retrieve(AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.update( - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .secret("secret") - .type("type") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.update(AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .secret("secret") + .type("type") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() - val pageFuture = aiSecretServiceAsync.list() + val pageFuture = aiSecretServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.delete( - AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.delete(AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun findAndDelete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.findAndDelete( - AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.findAndDelete(AiSecretFindAndDeleteParams.builder() + .name("name") + .orgName("org_name") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = - aiSecretServiceAsync.replace( - AiSecretReplaceParams.builder() - .name("name") - .metadata( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = aiSecretServiceAsync.replace(AiSecretReplaceParams.builder() + .name("name") + .metadata(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + + val aISecret = aISecretFuture.get() + aISecret.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt index f7d5a9ac..ab12b91e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams +import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -15,74 +16,64 @@ class ApiKeyServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val createApiKeyOutputFuture = - apiKeyServiceAsync.create( - ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - ) + val createApiKeyOutputFuture = apiKeyServiceAsync.create(ApiKeyCreateParams.builder() + .name("name") + .orgName("org_name") + .build()) - val createApiKeyOutput = createApiKeyOutputFuture.get() - createApiKeyOutput.validate() + val createApiKeyOutput = createApiKeyOutputFuture.get() + createApiKeyOutput.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val apiKeyFuture = - apiKeyServiceAsync.retrieve( - ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val apiKeyFuture = apiKeyServiceAsync.retrieve(ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val apiKey = apiKeyFuture.get() - apiKey.validate() + val apiKey = apiKeyFuture.get() + apiKey.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val pageFuture = apiKeyServiceAsync.list() + val pageFuture = apiKeyServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val apiKeyFuture = - apiKeyServiceAsync.delete( - ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val apiKeyFuture = apiKeyServiceAsync.delete(ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val apiKey = apiKeyFuture.get() - apiKey.validate() + val apiKey = apiKeyFuture.get() + apiKey.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt index 4e6b2e1f..6dfc687d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams +import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams @@ -25,254 +26,205 @@ class DatasetServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = - datasetServiceAsync.create( - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - val dataset = datasetFuture.get() - dataset.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = datasetServiceAsync.create(DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build()) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = - datasetServiceAsync.retrieve( - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val dataset = datasetFuture.get() - dataset.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = datasetServiceAsync.retrieve(DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = - datasetServiceAsync.update( - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() - ) - - val dataset = datasetFuture.get() - dataset.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = datasetServiceAsync.update(DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .build()) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() - val pageFuture = datasetServiceAsync.list() + val pageFuture = datasetServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = - datasetServiceAsync.delete( - DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val dataset = datasetFuture.get() - dataset.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = datasetServiceAsync.delete(DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun feedback() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val feedbackResponseSchemaFuture = - datasetServiceAsync.feedback( - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) - - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val feedbackResponseSchemaFuture = datasetServiceAsync.feedback(DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build()) + .build()) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val fetchDatasetEventsResponseFuture = - datasetServiceAsync.fetch( - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val fetchDatasetEventsResponseFuture = datasetServiceAsync.fetch(DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() + fetchDatasetEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val fetchDatasetEventsResponseFuture = - datasetServiceAsync.fetchPost( - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val fetchDatasetEventsResponseFuture = datasetServiceAsync.fetchPost(DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() + fetchDatasetEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val insertEventsResponseFuture = - datasetServiceAsync.insert( - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) - - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val insertEventsResponseFuture = datasetServiceAsync.insert(DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } @Test fun summarize() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val summarizeDatasetResponseFuture = - datasetServiceAsync.summarize( - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - ) - - val summarizeDatasetResponse = summarizeDatasetResponseFuture.get() - summarizeDatasetResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val summarizeDatasetResponseFuture = datasetServiceAsync.summarize(DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build()) + + val summarizeDatasetResponse = summarizeDatasetResponseFuture.get() + summarizeDatasetResponse.validate() } } 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..1d393bb4 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 @@ -18,133 +18,109 @@ class EnvVarServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.create( - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.create(EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.retrieve( - EnvVarRetrieveParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.retrieve(EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.update( - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.update(EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.list( - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.list(EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.delete( - EnvVarDeleteParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.delete(EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = - envVarServiceAsync.replace( - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() - ) - - val envVar = envVarFuture.get() - envVar.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = envVarServiceAsync.replace(EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build()) + + val envVar = envVarFuture.get() + envVar.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt index 406d7f7b..2dbf5ef8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt @@ -15,66 +15,54 @@ class EvalServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val evalServiceAsync = client.evals() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val evalServiceAsync = client.evals() - val summarizeExperimentResponseFuture = - evalServiceAsync.create( - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .task( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - .isPublic(true) - .maxConcurrency(0.0) - .metadata( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() - ) + val summarizeExperimentResponseFuture = evalServiceAsync.create(EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + .isPublic(true) + .maxConcurrency(0.0) + .metadata(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build()) - val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() - summarizeExperimentResponse.validate() + val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() + summarizeExperimentResponse.validate() } } 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 e4ab67f2..d9925d89 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 @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams @@ -27,329 +28,266 @@ class ExperimentServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = - experimentServiceAsync.create( - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("x") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() - ) - - val experiment = experimentFuture.get() - experiment.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = experimentServiceAsync.create(ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("x") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build()) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = - experimentServiceAsync.retrieve( - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val experiment = experimentFuture.get() - experiment.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = experimentServiceAsync.retrieve(ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = - experimentServiceAsync.update( - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() - ) - - val experiment = experimentFuture.get() - experiment.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = experimentServiceAsync.update(ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build()) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() - val pageFuture = experimentServiceAsync.list() + val pageFuture = experimentServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = - experimentServiceAsync.delete( - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val experiment = experimentFuture.get() - experiment.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = experimentServiceAsync.delete(ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun feedback() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val feedbackResponseSchemaFuture = - experimentServiceAsync.feedback( - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) - - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val feedbackResponseSchemaFuture = experimentServiceAsync.feedback(ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build()) + .build()) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val fetchExperimentEventsResponseFuture = - experimentServiceAsync.fetch( - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val fetchExperimentEventsResponseFuture = experimentServiceAsync.fetch(ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() + fetchExperimentEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val fetchExperimentEventsResponseFuture = - experimentServiceAsync.fetchPost( - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val fetchExperimentEventsResponseFuture = experimentServiceAsync.fetchPost(ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() + fetchExperimentEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val insertEventsResponseFuture = - experimentServiceAsync.insert( - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) - - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val insertEventsResponseFuture = experimentServiceAsync.insert(ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } @Test fun summarize() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val summarizeExperimentResponseFuture = - experimentServiceAsync.summarize( - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - ) - - val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() - summarizeExperimentResponse.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val summarizeExperimentResponseFuture = experimentServiceAsync.summarize(ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build()) + + val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() + summarizeExperimentResponse.validate() } } 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 58578b30..852d1e77 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 @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams +import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams @@ -23,452 +24,297 @@ class FunctionServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.create( - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val functionFuture = functionServiceAsync.create(FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.retrieve( - FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val functionFuture = functionServiceAsync.retrieve(FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.update( - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val functionFuture = functionServiceAsync.update(FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val pageFuture = functionServiceAsync.list() + val pageFuture = functionServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.delete( - FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val functionFuture = functionServiceAsync.delete(FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun invoke() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val responseFuture = - functionServiceAsync.invoke( - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - .stream(true) - .version("version") - .build() - ) + val responseFuture = functionServiceAsync.invoke(FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build()) + .stream(true) + .version("version") + .build()) - val response = responseFuture.get() - val unwrappedResponse = response.getOrNull() - assertNotNull(unwrappedResponse) - unwrappedResponse.validate() + val response = responseFuture.get() + val unwrappedResponse = response.getOrNull() + assertNotNull(unwrappedResponse) + unwrappedResponse.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = - functionServiceAsync.replace( - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val functionFuture = functionServiceAsync.replace(FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt index 314e7023..d14aa978 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams +import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams @@ -17,128 +18,109 @@ class GroupServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.create( - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.create(GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + val group = groupFuture.get() + group.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.retrieve( - GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.retrieve(GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val group = groupFuture.get() + group.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.update( - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.update(GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val group = groupFuture.get() + group.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() - val pageFuture = groupServiceAsync.list() + val pageFuture = groupServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.delete( - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.delete(GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val group = groupFuture.get() + group.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = - groupServiceAsync.replace( - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - val group = groupFuture.get() - group.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = groupServiceAsync.replace(GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + val group = groupFuture.get() + group.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt index b89247bd..d6f423f1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.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.models.OrganizationDeleteParams +import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import org.junit.jupiter.api.Test @@ -15,81 +16,68 @@ class OrganizationServiceAsyncTest { @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = - organizationServiceAsync.retrieve( - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val organizationFuture = organizationServiceAsync.retrieve(OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = - organizationServiceAsync.update( - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() - ) + val organizationFuture = organizationServiceAsync.update(OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build()) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val pageFuture = organizationServiceAsync.list() + val pageFuture = organizationServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = - organizationServiceAsync.delete( - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val organizationFuture = organizationServiceAsync.delete(OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } } 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 efa55642..7ed089bb 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 @@ -9,6 +9,7 @@ import com.braintrustdata.api.models.ProjectScoreCategory import com.braintrustdata.api.models.ProjectScoreConfig import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams +import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams @@ -20,191 +21,155 @@ class ProjectScoreServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.create( - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.create(ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.retrieve( - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.retrieve(ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.update( - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.update(ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() - val pageFuture = projectScoreServiceAsync.list() + val pageFuture = projectScoreServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.delete( - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.delete(ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = - projectScoreServiceAsync.replace( - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() - ) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = projectScoreServiceAsync.replace(ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build()) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt index 85f07a6a..b1b29862 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams +import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectSettings import com.braintrustdata.api.models.ProjectUpdateParams @@ -17,96 +18,84 @@ class ProjectServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = - projectServiceAsync.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - - val project = projectFuture.get() - project.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = projectServiceAsync.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + + val project = projectFuture.get() + project.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = - projectServiceAsync.retrieve( - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val project = projectFuture.get() - project.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = projectServiceAsync.retrieve(ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val project = projectFuture.get() + project.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = - projectServiceAsync.update( - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .build() - ) - - val project = projectFuture.get() - project.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = projectServiceAsync.update(ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .build()) + + val project = projectFuture.get() + project.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() - val pageFuture = projectServiceAsync.list() + val pageFuture = projectServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = - projectServiceAsync.delete( - ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val project = projectFuture.get() - project.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = projectServiceAsync.delete(ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val project = projectFuture.get() + project.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt index 8105ac95..36d9a445 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams +import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams @@ -17,125 +18,104 @@ class ProjectTagServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.create( - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.create(ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.retrieve( - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.retrieve(ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.update( - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.update(ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() - val pageFuture = projectTagServiceAsync.list() + val pageFuture = projectTagServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.delete( - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.delete(ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = - projectTagServiceAsync.replace( - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = projectTagServiceAsync.replace(ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + + val projectTag = projectTagFuture.get() + projectTag.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt index 2535012d..a59c59a5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptDeleteParams +import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptOptions import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams @@ -20,358 +21,232 @@ class PromptServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.create( - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.create(PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.retrieve( - PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.retrieve(PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.update( - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .slug("slug") - .addTag("string") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.update(PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .slug("slug") + .addTag("string") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() - val pageFuture = promptServiceAsync.list() + val pageFuture = promptServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.delete( - PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.delete(PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = - promptServiceAsync.replace( - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) - - val prompt = promptFuture.get() - prompt.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = promptServiceAsync.replace(PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) + + val prompt = promptFuture.get() + prompt.validate() } } 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..5f27b17c 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 @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams +import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams @@ -17,155 +18,121 @@ class RoleServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.create( - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.create(RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + val role = roleFuture.get() + role.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.retrieve( - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.retrieve(RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val role = roleFuture.get() + role.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.update( - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.update(RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val role = roleFuture.get() + role.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() - val pageFuture = roleServiceAsync.list() + val pageFuture = roleServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.delete( - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.delete(RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val role = roleFuture.get() + role.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = - roleServiceAsync.replace( - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - val role = roleFuture.get() - role.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = roleServiceAsync.replace(RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + val role = roleFuture.get() + role.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt index 8d448a50..b9d4a0bb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams @@ -17,127 +18,106 @@ class SpanIframeServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.create( - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.create(SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.retrieve( - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.retrieve(SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.update( - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.update(SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() - val pageFuture = spanIframeServiceAsync.list() + val pageFuture = spanIframeServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.delete( - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.delete(SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = - spanIframeServiceAsync.replace( - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - ) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = spanIframeServiceAsync.replace(SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build()) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt index dee09b2e..8ac4b613 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.TopLevelHelloWorldParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -12,15 +13,14 @@ class TopLevelServiceAsyncTest { @Test fun helloWorld() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val topLevelServiceAsync = client.topLevel() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val topLevelServiceAsync = client.topLevel() - val responseFuture = topLevelServiceAsync.helloWorld() + val responseFuture = topLevelServiceAsync.helloWorld() - val response = responseFuture.get() + val response = responseFuture.get() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt index 38f452e7..082c2586 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -13,34 +14,31 @@ class UserServiceAsyncTest { @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userServiceAsync = client.users() - - val userFuture = - userServiceAsync.retrieve( - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - val user = userFuture.get() - user.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userServiceAsync = client.users() + + val userFuture = userServiceAsync.retrieve(UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + val user = userFuture.get() + user.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userServiceAsync = client.users() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userServiceAsync = client.users() - val pageFuture = userServiceAsync.list() + val pageFuture = userServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } } 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 8a7b3bfb..d86d5880 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 @@ -23,222 +23,168 @@ class ViewServiceAsyncTest { @Test fun create() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.create( - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.create(ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build()) + + val view = viewFuture.get() + view.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.retrieve( - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.retrieve(ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build()) + + val view = viewFuture.get() + view.validate() } @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.update( - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.update(ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build()) + + val view = viewFuture.get() + view.validate() } @Test fun list() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val pageFuture = - viewServiceAsync.list( - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build() - ) - - val page = pageFuture.get() - page.response().validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val pageFuture = viewServiceAsync.list(ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build()) + + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.delete( - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.delete(ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build()) + + val view = viewFuture.get() + view.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = - viewServiceAsync.replace( - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - ) - - val view = viewFuture.get() - view.validate() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = viewServiceAsync.replace(ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build()) + + val view = viewFuture.get() + view.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt index 12efbd59..4710a3ed 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt @@ -13,39 +13,31 @@ class MemberServiceAsyncTest { @Test fun update() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val memberServiceAsync = client.organizations().members() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberServiceAsync = client.organizations().members() - val patchOrganizationMembersOutputFuture = - memberServiceAsync.update( - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) + val patchOrganizationMembersOutputFuture = memberServiceAsync.update(OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build()) - val patchOrganizationMembersOutput = patchOrganizationMembersOutputFuture.get() - patchOrganizationMembersOutput.validate() + val patchOrganizationMembersOutput = patchOrganizationMembersOutputFuture.get() + patchOrganizationMembersOutput.validate() } } 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 fec1f6b8..492d6f27 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 @@ -21,162 +21,128 @@ class LogServiceAsyncTest { @Test fun feedback() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val feedbackResponseSchemaFuture = - logServiceAsync.feedback( - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) + val feedbackResponseSchemaFuture = logServiceAsync.feedback(ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build()) + .build()) - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val fetchProjectLogsEventsResponseFuture = - logServiceAsync.fetch( - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) + val fetchProjectLogsEventsResponseFuture = logServiceAsync.fetch(ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) - val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() - fetchProjectLogsEventsResponse.validate() + val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() + fetchProjectLogsEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val fetchProjectLogsEventsResponseFuture = - logServiceAsync.fetchPost( - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) + val fetchProjectLogsEventsResponseFuture = logServiceAsync.fetchPost(ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) - val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() - fetchProjectLogsEventsResponse.validate() + val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() + fetchProjectLogsEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val insertEventsResponseFuture = - logServiceAsync.insert( - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) + val insertEventsResponseFuture = logServiceAsync.insert(ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } } 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..606645e8 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 @@ -18,149 +18,121 @@ class AclServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = - aclService.create( - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = aclService.create(AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + acl.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = - aclService.retrieve( - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = aclService.retrieve(AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + acl.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val page = - aclService.list( - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build() - ) - - page.response().validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val page = aclService.list(AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build()) + + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = - aclService.delete( - AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = aclService.delete(AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + acl.validate() } @Test fun batchUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val aclBatchUpdateResponse = - aclService.batchUpdate( - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) - - aclBatchUpdateResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val aclBatchUpdateResponse = aclService.batchUpdate(AclBatchUpdateParams.builder() + .addAddAcl(AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build()) + + aclBatchUpdateResponse.validate() } @Test fun findAndDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = - aclService.findAndDelete( - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = aclService.findAndDelete(AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + acl.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt index 6da192a1..e3d4c517 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams +import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams @@ -19,151 +20,123 @@ class AiSecretServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.create( - AiSecretCreateParams.builder() - .name("name") - .metadata( - AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.create(AiSecretCreateParams.builder() + .name("name") + .metadata(AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + + aISecret.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.retrieve( - AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.retrieve(AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + aISecret.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.update( - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata( - AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .secret("secret") - .type("type") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.update(AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .secret("secret") + .type("type") + .build()) + + aISecret.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() - val page = aiSecretService.list() + val page = aiSecretService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.delete( - AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.delete(AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + aISecret.validate() } @Test fun findAndDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.findAndDelete( - AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.findAndDelete(AiSecretFindAndDeleteParams.builder() + .name("name") + .orgName("org_name") + .build()) + + aISecret.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = - aiSecretService.replace( - AiSecretReplaceParams.builder() - .name("name") - .metadata( - AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - - aISecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = aiSecretService.replace(AiSecretReplaceParams.builder() + .name("name") + .metadata(AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + + aISecret.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index 46eefb44..3392aae9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams +import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -15,70 +16,60 @@ class ApiKeyServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val createApiKeyOutput = - apiKeyService.create( - ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - ) + val createApiKeyOutput = apiKeyService.create(ApiKeyCreateParams.builder() + .name("name") + .orgName("org_name") + .build()) - createApiKeyOutput.validate() + createApiKeyOutput.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val apiKey = - apiKeyService.retrieve( - ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val apiKey = apiKeyService.retrieve(ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - apiKey.validate() + apiKey.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val page = apiKeyService.list() + val page = apiKeyService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val apiKey = - apiKeyService.delete( - ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val apiKey = apiKeyService.delete(ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - apiKey.validate() + apiKey.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index a9bae5c4..62712f54 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams +import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams @@ -25,244 +26,195 @@ class DatasetServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = - datasetService.create( - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = datasetService.create(DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .build()) + + dataset.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = - datasetService.retrieve( - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = datasetService.retrieve(DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + dataset.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = - datasetService.update( - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata( - DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .build() - ) - - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = datasetService.update(DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .build()) + + dataset.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() - val page = datasetService.list() + val page = datasetService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = - datasetService.delete( - DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = datasetService.delete(DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + dataset.validate() } @Test fun feedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val feedbackResponseSchema = - datasetService.feedback( - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata( - FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) - - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val feedbackResponseSchema = datasetService.feedback(DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build()) + .build()) + + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val fetchDatasetEventsResponse = - datasetService.fetch( - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val fetchDatasetEventsResponse = datasetService.fetch(DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + fetchDatasetEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val fetchDatasetEventsResponse = - datasetService.fetchPost( - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val fetchDatasetEventsResponse = datasetService.fetchPost(DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + fetchDatasetEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val insertEventsResponse = - datasetService.insert( - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) - - insertEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val insertEventsResponse = datasetService.insert(DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) + + insertEventsResponse.validate() } @Test fun summarize() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val summarizeDatasetResponse = - datasetService.summarize( - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - ) - - summarizeDatasetResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val summarizeDatasetResponse = datasetService.summarize(DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build()) + + summarizeDatasetResponse.validate() } } 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..45209f68 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 @@ -18,127 +18,103 @@ class EnvVarServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.create( - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.create(EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build()) + + envVar.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.retrieve( - EnvVarRetrieveParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.retrieve(EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + envVar.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.update( - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.update(EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build()) + + envVar.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.list( - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.list(EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build()) + + envVar.validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.delete( - EnvVarDeleteParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.delete(EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + envVar.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = - envVarService.replace( - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() - ) - - envVar.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = envVarService.replace(EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build()) + + envVar.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index feaa3f95..73833227 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -15,65 +15,53 @@ class EvalServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val evalService = client.evals() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val evalService = client.evals() - val summarizeExperimentResponse = - evalService.create( - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) - .projectId("project_id") - .addScore( - EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .task( - EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build() - ) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings( - EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build() - ) - .isPublic(true) - .maxConcurrency(0.0) - .metadata( - EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() - ) + val summarizeExperimentResponse = evalService.create(EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + .build()) + .projectId("project_id") + .addScore(EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .task(EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build()) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build()) + .isPublic(true) + .maxConcurrency(0.0) + .metadata(EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build()) - summarizeExperimentResponse.validate() + summarizeExperimentResponse.validate() } } 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 b4e00567..a80c4a0c 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 @@ -11,6 +11,7 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams @@ -27,319 +28,256 @@ class ExperimentServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = - experimentService.create( - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata( - ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("x") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() - ) - - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = experimentService.create(ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata(ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("x") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build()) + + experiment.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = - experimentService.retrieve( - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = experimentService.retrieve(ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + experiment.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = - experimentService.update( - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata( - ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") - .public_(true) - .repoInfo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - .build() - ) - - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = experimentService.update(ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata(ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .name("name") + .public_(true) + .repoInfo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + .build()) + + experiment.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() - val page = experimentService.list() + val page = experimentService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = - experimentService.delete( - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = experimentService.delete(ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + experiment.validate() } @Test fun feedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val feedbackResponseSchema = - experimentService.feedback( - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) - - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val feedbackResponseSchema = experimentService.feedback(ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build()) + .build()) + + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val fetchExperimentEventsResponse = - experimentService.fetch( - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val fetchExperimentEventsResponse = experimentService.fetch(ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + fetchExperimentEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val fetchExperimentEventsResponse = - experimentService.fetchPost( - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val fetchExperimentEventsResponse = experimentService.fetchPost(ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + + fetchExperimentEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val insertEventsResponse = - experimentService.insert( - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) - - insertEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val insertEventsResponse = experimentService.insert(ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) + + insertEventsResponse.validate() } @Test fun summarize() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val summarizeExperimentResponse = - experimentService.summarize( - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - ) - - summarizeExperimentResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val summarizeExperimentResponse = experimentService.summarize(ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build()) + + summarizeExperimentResponse.validate() } } 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 d5caebf7..2097fbb1 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 @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams +import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams @@ -23,445 +24,290 @@ class FunctionServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.create( - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val function = functionService.create(FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - function.validate() + function.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.retrieve( - FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val function = functionService.retrieve(FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - function.validate() + function.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.update( - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val function = functionService.update(FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - function.validate() + function.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val page = functionService.list() + val page = functionService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.delete( - FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val function = functionService.delete(FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - function.validate() + function.validate() } @Test fun invoke() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val response = - functionService.invoke( - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage( - FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build() - ) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent( - FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType( - FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS - ) - .propagatedEvent( - FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .rowIds( - FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build() - ) - .build() - ) - .stream(true) - .version("version") - .build() - ) + val response = functionService.invoke(FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage(FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build()) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build()) + .build()) + .stream(true) + .version("version") + .build()) - val unwrappedResponse = response.getOrNull() - assertNotNull(unwrappedResponse) - unwrappedResponse.validate() + val unwrappedResponse = response.getOrNull() + assertNotNull(unwrappedResponse) + unwrappedResponse.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = - functionService.replace( - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema( - FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build() - ) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) + val function = functionService.replace(FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build()) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema(FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build()) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) - function.validate() + function.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index 5bb132ad..26f5904b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams +import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams @@ -17,122 +18,103 @@ class GroupServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.create( - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.create(GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + group.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.retrieve( - GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.retrieve(GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + group.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.update( - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.update(GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + group.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() - val page = groupService.list() + val page = groupService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.delete( - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.delete(GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + group.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = - groupService.replace( - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = groupService.replace(GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + group.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt index 97c88d5c..a1dd9aeb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.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.models.OrganizationDeleteParams +import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import org.junit.jupiter.api.Test @@ -15,77 +16,64 @@ class OrganizationServiceTest { @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = - organizationService.retrieve( - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val organization = organizationService.retrieve(OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - organization.validate() + organization.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = - organizationService.update( - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() - ) + val organization = organizationService.update(OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build()) - organization.validate() + organization.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val page = organizationService.list() + val page = organizationService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = - organizationService.delete( - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val organization = organizationService.delete(OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - organization.validate() + organization.validate() } } 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 0f7d4d1c..b9d3d052 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 @@ -9,6 +9,7 @@ import com.braintrustdata.api.models.ProjectScoreCategory import com.braintrustdata.api.models.ProjectScoreConfig import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams +import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams @@ -20,185 +21,149 @@ class ProjectScoreServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.create( - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.create(ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build()) + + projectScore.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.retrieve( - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.retrieve(ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + projectScore.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.update( - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.update(ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build()) + + projectScore.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() - val page = projectScoreService.list() + val page = projectScoreService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.delete( - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.delete(ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + projectScore.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = - projectScoreService.replace( - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical( - listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) - ) - .config( - ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online( - OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer( - OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build() - ) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - ) - .build() - ) - .description("description") - .build() - ) - - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = projectScoreService.replace(ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() + .name("name") + .value(0.0) + .build())) + .config(ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online(OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer(OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build()) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build()) + .build()) + .description("description") + .build()) + + projectScore.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 9b95d382..0759010d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams +import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectSettings import com.braintrustdata.api.models.ProjectUpdateParams @@ -17,91 +18,79 @@ class ProjectServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = - projectService.create( - ProjectCreateParams.builder().name("x").orgName("org_name").build() - ) - - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = projectService.create(ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .build()) + + project.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = - projectService.retrieve( - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = projectService.retrieve(ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + project.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = - projectService.update( - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) - .build() - ) - - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = projectService.update(ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder() + .comparisonKey("comparison_key") + .build()) + .build()) + + project.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() - val page = projectService.list() + val page = projectService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = - projectService.delete( - ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = projectService.delete(ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + project.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt index 503f9390..dac7a1eb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams +import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams @@ -17,119 +18,98 @@ class ProjectTagServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.create( - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.create(ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + + projectTag.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.retrieve( - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.retrieve(ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + projectTag.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.update( - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.update(ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build()) + + projectTag.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() - val page = projectTagService.list() + val page = projectTagService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.delete( - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.delete(ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + projectTag.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = - projectTagService.replace( - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = projectTagService.replace(ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + + projectTag.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 68eff58c..3edea5b3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -8,6 +8,7 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptDeleteParams +import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptOptions import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams @@ -20,352 +21,226 @@ class PromptServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = - promptService.create( - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) - - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = promptService.create(PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) + + prompt.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val prompt = - promptService.retrieve( - PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val prompt = promptService.retrieve(PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - prompt.validate() + prompt.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = - promptService.update( - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .slug("slug") - .addTag("string") - .build() - ) - - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = promptService.update(PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .slug("slug") + .addTag("string") + .build()) + + prompt.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val page = promptService.list() + val page = promptService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val prompt = - promptService.delete( - PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val prompt = promptService.delete(PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) - prompt.validate() + prompt.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = - promptService.replace( - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData( - PromptData.builder() - .options( - PromptOptions.builder() - .model("model") - .params( - PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall( - PromptOptions.Params.OpenAIModelParams.FunctionCall - .UnionMember0 - .AUTO - ) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .builder() - .type( - PromptOptions.Params.OpenAIModelParams - .ResponseFormat - .JsonObject - .Type - .JSON_OBJECT - ) - .build() - ) - .addStop("string") - .temperature(0.0) - .toolChoice( - PromptOptions.Params.OpenAIModelParams.ToolChoice - .UnionMember0 - .AUTO - ) - .topP(0.0) - .useCache(true) - .build() - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores( - PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - .addToolFunction( - PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build() - ) - .build() - ) - .addTag("string") - .build() - ) - - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = promptService.replace(PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData(PromptData.builder() + .options(PromptOptions.builder() + .model("model") + .params(PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() + .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) + .build()) + .addStop("string") + .temperature(0.0) + .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) + .topP(0.0) + .useCache(true) + .build()) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build()) + .addToolFunction(PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build()) + .build()) + .addTag("string") + .build()) + + prompt.validate() } } 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..b480a17c 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 @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams +import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams @@ -17,149 +18,115 @@ class RoleServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.create( - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.create(RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + role.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.retrieve( - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.retrieve(RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + role.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.update( - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.update(RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + role.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() - val page = roleService.list() + val page = roleService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.delete( - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.delete(RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + role.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = - roleService.replace( - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - ) - - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = roleService.replace(RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build()) + + role.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index 0f18d989..158d05e0 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -6,6 +6,7 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams +import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams @@ -17,121 +18,100 @@ class SpanIframeServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.create( - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.create(SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build()) + + spanIFrame.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.retrieve( - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.retrieve(SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + spanIFrame.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.update( - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.update(SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build()) + + spanIFrame.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() - val page = spanIframeService.list() + val page = spanIframeService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.delete( - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.delete(SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + spanIFrame.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = - spanIframeService.replace( - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - ) - - spanIFrame.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = spanIframeService.replace(SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build()) + + spanIFrame.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt index a1e4f554..b454e134 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.TopLevelHelloWorldParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -12,13 +13,12 @@ class TopLevelServiceTest { @Test fun helloWorld() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val topLevelService = client.topLevel() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val topLevelService = client.topLevel() - topLevelService.helloWorld() + topLevelService.helloWorld() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index bdf88104..ca790444 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -13,32 +14,29 @@ class UserServiceTest { @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userService = client.users() - - val user = - userService.retrieve( - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - - user.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userService = client.users() + + val user = userService.retrieve(UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + + user.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userService = client.users() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userService = client.users() - val page = userService.list() + val page = userService.list() - page.response().validate() + page.response().validate() } } 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 888e7466..4fb57c0c 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 @@ -23,216 +23,162 @@ class ViewServiceTest { @Test fun create() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.create( - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.create(ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build()) + + view.validate() } @Test fun retrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.retrieve( - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.retrieve(ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build()) + + view.validate() } @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.update( - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.update(ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build()) + + view.validate() } @Test fun list() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val page = - viewService.list( - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build() - ) - - page.response().validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val page = viewService.list(ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build()) + + page.response().validate() } @Test fun delete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.delete( - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.delete(ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build()) + + view.validate() } @Test fun replace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = - viewService.replace( - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .addColumnOrder("string") - .columnSizing( - ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .columnVisibility( - ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build() - ) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - .build() - ) - - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = viewService.replace(ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options(ViewOptions.builder() + .addColumnOrder("string") + .columnSizing(ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build()) + .build()) + .build()) + + view.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt index d23dacb9..47cb2e31 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt @@ -13,38 +13,30 @@ class MemberServiceTest { @Test fun update() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val memberService = client.organizations().members() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberService = client.organizations().members() - val patchOrganizationMembersOutput = - memberService.update( - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) + val patchOrganizationMembersOutput = memberService.update(OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + .build()) - patchOrganizationMembersOutput.validate() + patchOrganizationMembersOutput.validate() } } 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 fca0f5f6..128d5225 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 @@ -21,158 +21,124 @@ class LogServiceTest { @Test fun feedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val feedbackResponseSchema = - logService.feedback( - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata( - FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .scores( - FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - ) - .build() - ) + val feedbackResponseSchema = logService.feedback(ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .scores(FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build()) + .build()) - feedbackResponseSchema.validate() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val fetchProjectLogsEventsResponse = - logService.fetch( - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) + val fetchProjectLogsEventsResponse = logService.fetch(ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) - fetchProjectLogsEventsResponse.validate() + fetchProjectLogsEventsResponse.validate() } @Test fun fetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val fetchProjectLogsEventsResponse = - logService.fetchPost( - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) + val fetchProjectLogsEventsResponse = logService.fetchPost(ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) - fetchProjectLogsEventsResponse.validate() + fetchProjectLogsEventsResponse.validate() } @Test fun insert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val insertEventsResponse = - logService.insert( - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .metrics( - InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build() - ) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores( - InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .spanAttributes( - SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - ) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - ) - .build() - ) + val insertEventsResponse = logService.insert(ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build()) + .metrics(InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build()) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores(InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build()) + .spanAttributes(SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build()) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build()) + .build()) - insertEventsResponse.validate() + insertEventsResponse.validate() } } From 4a82e6f3159a2b6697f8dbe23304a693e0448ebb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 03:56:13 +0000 Subject: [PATCH 76/87] chore(internal): codegen related update (#146) --- .../client/okhttp/BraintrustOkHttpClient.kt | 306 +- .../okhttp/BraintrustOkHttpClientAsync.kt | 304 +- .../api/client/okhttp/OkHttpClient.kt | 54 +- .../api/client/BraintrustClient.kt | 46 +- .../api/client/BraintrustClientAsync.kt | 44 +- .../api/client/BraintrustClientAsyncImpl.kt | 157 +- .../api/client/BraintrustClientImpl.kt | 133 +- .../api/core/BaseDeserializer.kt | 20 +- .../braintrustdata/api/core/ClientOptions.kt | 317 +- .../braintrustdata/api/core/ObjectMappers.kt | 4 +- .../com/braintrustdata/api/core/Params.kt | 5 +- .../braintrustdata/api/core/PrepareRequest.kt | 10 +- .../com/braintrustdata/api/core/Properties.kt | 12 +- .../braintrustdata/api/core/RequestOptions.kt | 10 +- .../com/braintrustdata/api/core/Timeout.kt | 92 +- .../com/braintrustdata/api/core/Utils.kt | 21 +- .../com/braintrustdata/api/core/Values.kt | 74 +- .../api/core/handlers/ErrorHandler.kt | 5 +- .../api/core/handlers/JsonHandler.kt | 5 +- .../braintrustdata/api/core/http/Headers.kt | 5 +- .../api/core/http/HttpClient.kt | 5 +- .../api/core/http/HttpRequest.kt | 202 +- .../api/core/http/HttpRequestBodies.kt | 10 +- .../api/core/http/HttpRequestBody.kt | 7 +- .../http/PhantomReachableClosingHttpClient.kt | 2 +- .../api/core/http/QueryParams.kt | 7 +- .../api/core/http/RetryingHttpClient.kt | 181 +- .../api/errors/BadRequestException.kt | 7 +- .../api/errors/BraintrustError.kt | 74 +- .../errors/BraintrustInvalidDataException.kt | 3 +- .../api/errors/BraintrustIoException.kt | 3 +- .../api/errors/BraintrustServiceException.kt | 12 +- .../api/errors/InternalServerException.kt | 8 +- .../api/errors/NotFoundException.kt | 7 +- .../api/errors/PermissionDeniedException.kt | 7 +- .../api/errors/RateLimitException.kt | 7 +- .../api/errors/UnauthorizedException.kt | 7 +- .../errors/UnexpectedStatusCodeException.kt | 8 +- .../errors/UnprocessableEntityException.kt | 7 +- .../com/braintrustdata/api/models/AISecret.kt | 291 +- .../com/braintrustdata/api/models/Acl.kt | 595 ++- .../api/models/AclBatchUpdateParams.kt | 1697 +++---- .../api/models/AclBatchUpdateResponse.kt | 288 +- .../api/models/AclCreateParams.kt | 948 ++-- .../api/models/AclDeleteParams.kt | 246 +- .../api/models/AclFindAndDeleteParams.kt | 947 ++-- .../braintrustdata/api/models/AclListPage.kt | 134 +- .../api/models/AclListPageAsync.kt | 167 +- .../api/models/AclListParams.kt | 493 +- .../api/models/AclRetrieveParams.kt | 209 +- .../api/models/AiSecretCreateParams.kt | 653 ++- .../api/models/AiSecretDeleteParams.kt | 249 +- .../api/models/AiSecretFindAndDeleteParams.kt | 438 +- .../api/models/AiSecretListPage.kt | 140 +- .../api/models/AiSecretListPageAsync.kt | 181 +- .../api/models/AiSecretListParams.kt | 524 +-- .../api/models/AiSecretReplaceParams.kt | 654 ++- .../api/models/AiSecretRetrieveParams.kt | 212 +- .../api/models/AiSecretUpdateParams.kt | 540 +-- .../com/braintrustdata/api/models/ApiKey.kt | 191 +- .../api/models/ApiKeyCreateParams.kt | 439 +- .../api/models/ApiKeyDeleteParams.kt | 246 +- .../api/models/ApiKeyListPage.kt | 134 +- .../api/models/ApiKeyListPageAsync.kt | 167 +- .../api/models/ApiKeyListParams.kt | 427 +- .../api/models/ApiKeyRetrieveParams.kt | 212 +- .../models/ChatCompletionContentPartImage.kt | 346 +- .../models/ChatCompletionContentPartText.kt | 172 +- .../models/ChatCompletionMessageToolCall.kt | 327 +- .../braintrustdata/api/models/CodeBundle.kt | 1212 +++-- .../api/models/CreateApiKeyOutput.kt | 208 +- .../api/models/CrossObjectInsertResponse.kt | 388 +- .../braintrustdata/api/models/DataSummary.kt | 103 +- .../com/braintrustdata/api/models/Dataset.kt | 313 +- .../api/models/DatasetCreateParams.kt | 525 +-- .../api/models/DatasetDeleteParams.kt | 246 +- .../braintrustdata/api/models/DatasetEvent.kt | 757 ++- .../api/models/DatasetFeedbackParams.kt | 380 +- .../api/models/DatasetFetchParams.kt | 466 +- .../api/models/DatasetFetchPostParams.kt | 1175 +++-- .../api/models/DatasetInsertParams.kt | 372 +- .../api/models/DatasetListPage.kt | 140 +- .../api/models/DatasetListPageAsync.kt | 183 +- .../api/models/DatasetListParams.kt | 457 +- .../api/models/DatasetRetrieveParams.kt | 212 +- .../api/models/DatasetSummarizeParams.kt | 250 +- .../api/models/DatasetUpdateParams.kt | 510 +-- .../com/braintrustdata/api/models/EnvVar.kt | 251 +- .../api/models/EnvVarCreateParams.kt | 503 +- .../api/models/EnvVarDeleteParams.kt | 246 +- .../api/models/EnvVarListParams.kt | 441 +- .../api/models/EnvVarListResponse.kt | 117 +- .../api/models/EnvVarReplaceParams.kt | 504 +- .../api/models/EnvVarRetrieveParams.kt | 212 +- .../api/models/EnvVarUpdateParams.kt | 400 +- .../api/models/EvalCreateParams.kt | 4069 ++++++++--------- .../braintrustdata/api/models/Experiment.kt | 491 +- .../api/models/ExperimentCreateParams.kt | 917 ++-- .../api/models/ExperimentDeleteParams.kt | 250 +- .../api/models/ExperimentEvent.kt | 1729 ++++--- .../api/models/ExperimentFeedbackParams.kt | 380 +- .../api/models/ExperimentFetchParams.kt | 469 +- .../api/models/ExperimentFetchPostParams.kt | 1175 +++-- .../api/models/ExperimentInsertParams.kt | 375 +- .../api/models/ExperimentListPage.kt | 148 +- .../api/models/ExperimentListPageAsync.kt | 184 +- .../api/models/ExperimentListParams.kt | 465 +- .../api/models/ExperimentRetrieveParams.kt | 212 +- .../api/models/ExperimentSummarizeParams.kt | 299 +- .../api/models/ExperimentUpdateParams.kt | 787 ++-- .../api/models/FeedbackDatasetItem.kt | 384 +- .../api/models/FeedbackExperimentItem.kt | 535 +-- .../api/models/FeedbackProjectLogsItem.kt | 535 +-- .../api/models/FeedbackResponseSchema.kt | 163 +- .../api/models/FetchDatasetEventsResponse.kt | 160 +- .../models/FetchExperimentEventsResponse.kt | 157 +- .../models/FetchProjectLogsEventsResponse.kt | 154 +- .../com/braintrustdata/api/models/Function.kt | 2273 +++++---- .../api/models/FunctionCreateParams.kt | 2385 +++++----- .../api/models/FunctionDeleteParams.kt | 249 +- .../api/models/FunctionInvokeParams.kt | 2779 ++++++----- .../api/models/FunctionInvokeResponse.kt | 93 +- .../api/models/FunctionListPage.kt | 140 +- .../api/models/FunctionListPageAsync.kt | 181 +- .../api/models/FunctionListParams.kt | 499 +- .../api/models/FunctionReplaceParams.kt | 2385 +++++----- .../api/models/FunctionRetrieveParams.kt | 212 +- .../api/models/FunctionUpdateParams.kt | 1933 ++++---- .../com/braintrustdata/api/models/Group.kt | 305 +- .../api/models/GroupCreateParams.kt | 622 ++- .../api/models/GroupDeleteParams.kt | 246 +- .../api/models/GroupListPage.kt | 134 +- .../api/models/GroupListPageAsync.kt | 167 +- .../api/models/GroupListParams.kt | 427 +- .../api/models/GroupReplaceParams.kt | 623 ++- .../api/models/GroupRetrieveParams.kt | 209 +- .../api/models/GroupUpdateParams.kt | 628 ++- .../api/models/InsertDatasetEvent.kt | 1242 +++-- .../api/models/InsertEventsResponse.kt | 138 +- .../api/models/InsertExperimentEvent.kt | 2135 ++++----- .../api/models/InsertProjectLogsEvent.kt | 2077 ++++----- .../api/models/MetricSummary.kt | 195 +- .../api/models/OnlineScoreConfig.kt | 603 ++- .../braintrustdata/api/models/Organization.kt | 222 +- .../api/models/OrganizationDeleteParams.kt | 250 +- .../api/models/OrganizationListPage.kt | 153 +- .../api/models/OrganizationListPageAsync.kt | 181 +- .../api/models/OrganizationListParams.kt | 417 +- .../models/OrganizationMemberUpdateParams.kt | 1013 ++-- .../api/models/OrganizationRetrieveParams.kt | 212 +- .../api/models/OrganizationUpdateParams.kt | 500 +- .../models/PatchOrganizationMembersOutput.kt | 225 +- .../com/braintrustdata/api/models/Project.kt | 216 +- .../api/models/ProjectCreateParams.kt | 439 +- .../api/models/ProjectDeleteParams.kt | 246 +- .../api/models/ProjectListPage.kt | 140 +- .../api/models/ProjectListPageAsync.kt | 183 +- .../api/models/ProjectListParams.kt | 427 +- .../api/models/ProjectLogFeedbackParams.kt | 380 +- .../api/models/ProjectLogFetchParams.kt | 469 +- .../api/models/ProjectLogFetchPostParams.kt | 1175 +++-- .../api/models/ProjectLogInsertParams.kt | 375 +- .../api/models/ProjectLogsEvent.kt | 1753 ++++--- .../api/models/ProjectRetrieveParams.kt | 212 +- .../braintrustdata/api/models/ProjectScore.kt | 648 ++- .../api/models/ProjectScoreCategory.kt | 124 +- .../api/models/ProjectScoreConfig.kt | 202 +- .../api/models/ProjectScoreCreateParams.kt | 872 ++-- .../api/models/ProjectScoreDeleteParams.kt | 250 +- .../api/models/ProjectScoreListPage.kt | 153 +- .../api/models/ProjectScoreListPageAsync.kt | 181 +- .../api/models/ProjectScoreListParams.kt | 671 ++- .../api/models/ProjectScoreReplaceParams.kt | 873 ++-- .../api/models/ProjectScoreRetrieveParams.kt | 212 +- .../api/models/ProjectScoreUpdateParams.kt | 859 ++-- .../api/models/ProjectSettings.kt | 112 +- .../braintrustdata/api/models/ProjectTag.kt | 223 +- .../api/models/ProjectTagCreateParams.kt | 444 +- .../api/models/ProjectTagDeleteParams.kt | 250 +- .../api/models/ProjectTagListPage.kt | 148 +- .../api/models/ProjectTagListPageAsync.kt | 184 +- .../api/models/ProjectTagListParams.kt | 465 +- .../api/models/ProjectTagReplaceParams.kt | 445 +- .../api/models/ProjectTagRetrieveParams.kt | 212 +- .../api/models/ProjectTagUpdateParams.kt | 432 +- .../api/models/ProjectUpdateParams.kt | 439 +- .../com/braintrustdata/api/models/Prompt.kt | 581 +-- .../api/models/PromptCreateParams.kt | 628 ++- .../braintrustdata/api/models/PromptData.kt | 3347 +++++++------- .../api/models/PromptDeleteParams.kt | 246 +- .../api/models/PromptListPage.kt | 134 +- .../api/models/PromptListPageAsync.kt | 167 +- .../api/models/PromptListParams.kt | 499 +- .../api/models/PromptOptions.kt | 2931 ++++++------ .../api/models/PromptReplaceParams.kt | 628 ++- .../api/models/PromptRetrieveParams.kt | 212 +- .../api/models/PromptUpdateParams.kt | 503 +- .../com/braintrustdata/api/models/RepoInfo.kt | 275 +- .../com/braintrustdata/api/models/Role.kt | 555 ++- .../api/models/RoleCreateParams.kt | 858 ++-- .../api/models/RoleDeleteParams.kt | 246 +- .../braintrustdata/api/models/RoleListPage.kt | 134 +- .../api/models/RoleListPageAsync.kt | 167 +- .../api/models/RoleListParams.kt | 427 +- .../api/models/RoleReplaceParams.kt | 859 ++-- .../api/models/RoleRetrieveParams.kt | 209 +- .../api/models/RoleUpdateParams.kt | 1101 +++-- .../braintrustdata/api/models/ScoreSummary.kt | 174 +- .../api/models/SpanAttributes.kt | 168 +- .../braintrustdata/api/models/SpanIFrame.kt | 279 +- .../api/models/SpanIframeCreateParams.kt | 520 +-- .../api/models/SpanIframeDeleteParams.kt | 250 +- .../api/models/SpanIframeListPage.kt | 148 +- .../api/models/SpanIframeListPageAsync.kt | 184 +- .../api/models/SpanIframeListParams.kt | 435 +- .../api/models/SpanIframeReplaceParams.kt | 520 +-- .../api/models/SpanIframeRetrieveParams.kt | 212 +- .../api/models/SpanIframeUpdateParams.kt | 476 +- .../api/models/SummarizeDatasetResponse.kt | 186 +- .../api/models/SummarizeExperimentResponse.kt | 388 +- .../api/models/TopLevelHelloWorldParams.kt | 202 +- .../com/braintrustdata/api/models/User.kt | 195 +- .../braintrustdata/api/models/UserListPage.kt | 134 +- .../api/models/UserListPageAsync.kt | 167 +- .../api/models/UserListParams.kt | 756 ++- .../api/models/UserRetrieveParams.kt | 209 +- .../com/braintrustdata/api/models/View.kt | 394 +- .../api/models/ViewCreateParams.kt | 688 ++- .../com/braintrustdata/api/models/ViewData.kt | 105 +- .../api/models/ViewDataSearch.kt | 204 +- .../api/models/ViewDeleteParams.kt | 458 +- .../braintrustdata/api/models/ViewListPage.kt | 134 +- .../api/models/ViewListPageAsync.kt | 167 +- .../api/models/ViewListParams.kt | 589 +-- .../braintrustdata/api/models/ViewOptions.kt | 304 +- .../api/models/ViewReplaceParams.kt | 689 ++- .../api/models/ViewRetrieveParams.kt | 313 +- .../api/models/ViewUpdateParams.kt | 675 ++- .../api/services/async/AclServiceAsync.kt | 162 +- .../api/services/async/AclServiceAsyncImpl.kt | 357 +- .../services/async/AiSecretServiceAsync.kt | 201 +- .../async/AiSecretServiceAsyncImpl.kt | 416 +- .../api/services/async/ApiKeyServiceAsync.kt | 112 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 248 +- .../api/services/async/DatasetServiceAsync.kt | 271 +- .../services/async/DatasetServiceAsyncImpl.kt | 585 ++- .../api/services/async/EnvVarServiceAsync.kt | 159 +- .../services/async/EnvVarServiceAsyncImpl.kt | 348 +- .../api/services/async/EvalServiceAsync.kt | 39 +- .../services/async/EvalServiceAsyncImpl.kt | 71 +- .../services/async/ExperimentServiceAsync.kt | 301 +- .../async/ExperimentServiceAsyncImpl.kt | 585 ++- .../services/async/FunctionServiceAsync.kt | 187 +- .../async/FunctionServiceAsyncImpl.kt | 417 +- .../api/services/async/GroupServiceAsync.kt | 165 +- .../services/async/GroupServiceAsyncImpl.kt | 360 +- .../async/OrganizationServiceAsync.kt | 129 +- .../async/OrganizationServiceAsyncImpl.kt | 252 +- .../async/ProjectScoreServiceAsync.kt | 195 +- .../async/ProjectScoreServiceAsyncImpl.kt | 360 +- .../api/services/async/ProjectServiceAsync.kt | 136 +- .../services/async/ProjectServiceAsyncImpl.kt | 308 +- .../services/async/ProjectTagServiceAsync.kt | 180 +- .../async/ProjectTagServiceAsyncImpl.kt | 360 +- .../api/services/async/PromptServiceAsync.kt | 164 +- .../services/async/PromptServiceAsyncImpl.kt | 360 +- .../api/services/async/RoleServiceAsync.kt | 162 +- .../services/async/RoleServiceAsyncImpl.kt | 360 +- .../services/async/SpanIframeServiceAsync.kt | 179 +- .../async/SpanIframeServiceAsyncImpl.kt | 360 +- .../services/async/TopLevelServiceAsync.kt | 44 +- .../async/TopLevelServiceAsyncImpl.kt | 57 +- .../api/services/async/UserServiceAsync.kt | 67 +- .../services/async/UserServiceAsyncImpl.kt | 132 +- .../api/services/async/ViewServiceAsync.kt | 147 +- .../services/async/ViewServiceAsyncImpl.kt | 360 +- .../async/organizations/MemberServiceAsync.kt | 49 +- .../organizations/MemberServiceAsyncImpl.kt | 71 +- .../async/projects/LogServiceAsync.kt | 127 +- .../async/projects/LogServiceAsyncImpl.kt | 242 +- .../api/services/blocking/AclService.kt | 150 +- .../api/services/blocking/AclServiceImpl.kt | 321 +- .../api/services/blocking/AiSecretService.kt | 195 +- .../services/blocking/AiSecretServiceImpl.kt | 375 +- .../api/services/blocking/ApiKeyService.kt | 106 +- .../services/blocking/ApiKeyServiceImpl.kt | 218 +- .../api/services/blocking/DatasetService.kt | 251 +- .../services/blocking/DatasetServiceImpl.kt | 533 ++- .../api/services/blocking/EnvVarService.kt | 157 +- .../services/blocking/EnvVarServiceImpl.kt | 311 +- .../api/services/blocking/EvalService.kt | 35 +- .../api/services/blocking/EvalServiceImpl.kt | 68 +- .../services/blocking/ExperimentService.kt | 273 +- .../blocking/ExperimentServiceImpl.kt | 558 +-- .../api/services/blocking/FunctionService.kt | 184 +- .../services/blocking/FunctionServiceImpl.kt | 362 +- .../api/services/blocking/GroupService.kt | 161 +- .../api/services/blocking/GroupServiceImpl.kt | 311 +- .../services/blocking/OrganizationService.kt | 109 +- .../blocking/OrganizationServiceImpl.kt | 239 +- .../services/blocking/ProjectScoreService.kt | 169 +- .../blocking/ProjectScoreServiceImpl.kt | 343 +- .../api/services/blocking/ProjectService.kt | 136 +- .../services/blocking/ProjectServiceImpl.kt | 266 +- .../services/blocking/ProjectTagService.kt | 169 +- .../blocking/ProjectTagServiceImpl.kt | 341 +- .../api/services/blocking/PromptService.kt | 165 +- .../services/blocking/PromptServiceImpl.kt | 311 +- .../api/services/blocking/RoleService.kt | 161 +- .../api/services/blocking/RoleServiceImpl.kt | 310 +- .../services/blocking/SpanIframeService.kt | 168 +- .../blocking/SpanIframeServiceImpl.kt | 341 +- .../api/services/blocking/TopLevelService.kt | 40 +- .../services/blocking/TopLevelServiceImpl.kt | 55 +- .../api/services/blocking/UserService.kt | 62 +- .../api/services/blocking/UserServiceImpl.kt | 110 +- .../api/services/blocking/ViewService.kt | 153 +- .../api/services/blocking/ViewServiceImpl.kt | 310 +- .../blocking/organizations/MemberService.kt | 47 +- .../organizations/MemberServiceImpl.kt | 69 +- .../services/blocking/projects/LogService.kt | 112 +- .../blocking/projects/LogServiceImpl.kt | 233 +- .../braintrustdata/api/TestServerExtension.kt | 10 +- .../api/core/PhantomReachableTest.kt | 8 +- .../com/braintrustdata/api/core/ValuesTest.kt | 22 +- .../api/core/http/HeadersTest.kt | 67 +- .../api/core/http/QueryParamsTest.kt | 53 +- .../api/core/http/RetryingHttpClientTest.kt | 26 +- .../api/core/http/SerializerTest.kt | 31 +- .../braintrustdata/api/models/AISecretTest.kt | 48 +- .../api/models/AclBatchUpdateParamsTest.kt | 155 +- .../api/models/AclBatchUpdateResponseTest.kt | 113 +- .../api/models/AclCreateParamsTest.kt | 77 +- .../api/models/AclDeleteParamsTest.kt | 18 +- .../api/models/AclFindAndDeleteParamsTest.kt | 77 +- .../api/models/AclListParamsTest.kt | 69 +- .../api/models/AclRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/AclTest.kt | 47 +- .../api/models/AiSecretCreateParamsTest.kt | 76 +- .../api/models/AiSecretDeleteParamsTest.kt | 21 +- .../models/AiSecretFindAndDeleteParamsTest.kt | 28 +- .../api/models/AiSecretListParamsTest.kt | 67 +- .../api/models/AiSecretReplaceParamsTest.kt | 76 +- .../api/models/AiSecretRetrieveParamsTest.kt | 21 +- .../api/models/AiSecretUpdateParamsTest.kt | 88 +- .../api/models/ApiKeyCreateParamsTest.kt | 28 +- .../api/models/ApiKeyDeleteParamsTest.kt | 19 +- .../api/models/ApiKeyListParamsTest.kt | 58 +- .../api/models/ApiKeyRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/ApiKeyTest.kt | 31 +- .../ChatCompletionContentPartImageTest.kt | 33 +- .../ChatCompletionContentPartTextTest.kt | 16 +- .../ChatCompletionMessageToolCallTest.kt | 37 +- .../api/models/CodeBundleTest.kt | 75 +- .../api/models/CreateApiKeyOutputTest.kt | 36 +- .../models/CrossObjectInsertResponseTest.kt | 76 +- .../api/models/DataSummaryTest.kt | 8 +- .../api/models/DatasetCreateParamsTest.kt | 77 +- .../api/models/DatasetDeleteParamsTest.kt | 19 +- .../api/models/DatasetEventTest.kt | 98 +- .../api/models/DatasetFeedbackParamsTest.kt | 127 +- .../api/models/DatasetFetchParamsTest.kt | 65 +- .../api/models/DatasetFetchPostParamsTest.kt | 75 +- .../api/models/DatasetInsertParamsTest.kt | 168 +- .../api/models/DatasetListParamsTest.kt | 70 +- .../api/models/DatasetRetrieveParamsTest.kt | 21 +- .../api/models/DatasetSummarizeParamsTest.kt | 51 +- .../braintrustdata/api/models/DatasetTest.kt | 52 +- .../api/models/DatasetUpdateParamsTest.kt | 78 +- .../api/models/EnvVarCreateParamsTest.kt | 66 +- .../api/models/EnvVarDeleteParamsTest.kt | 19 +- .../api/models/EnvVarListParamsTest.kt | 52 +- .../api/models/EnvVarListResponseTest.kt | 44 +- .../api/models/EnvVarReplaceParamsTest.kt | 66 +- .../api/models/EnvVarRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/EnvVarTest.kt | 31 +- .../api/models/EnvVarUpdateParamsTest.kt | 67 +- .../api/models/EvalCreateParamsTest.kt | 339 +- .../api/models/ExperimentCreateParamsTest.kt | 172 +- .../api/models/ExperimentDeleteParamsTest.kt | 23 +- .../api/models/ExperimentEventTest.kt | 214 +- .../models/ExperimentFeedbackParamsTest.kt | 157 +- .../api/models/ExperimentFetchParamsTest.kt | 69 +- .../models/ExperimentFetchPostParamsTest.kt | 75 +- .../api/models/ExperimentInsertParamsTest.kt | 339 +- .../api/models/ExperimentListParamsTest.kt | 70 +- .../models/ExperimentRetrieveParamsTest.kt | 23 +- .../models/ExperimentSummarizeParamsTest.kt | 57 +- .../api/models/ExperimentTest.kt | 122 +- .../api/models/ExperimentUpdateParamsTest.kt | 179 +- .../api/models/FeedbackDatasetItemTest.kt | 40 +- .../api/models/FeedbackExperimentItemTest.kt | 62 +- .../api/models/FeedbackProjectLogsItemTest.kt | 62 +- .../api/models/FeedbackResponseSchemaTest.kt | 9 +- .../models/FetchDatasetEventsResponseTest.kt | 112 +- .../FetchExperimentEventsResponseTest.kt | 229 +- .../FetchProjectLogsEventsResponseTest.kt | 229 +- .../api/models/FunctionCreateParamsTest.kt | 533 ++- .../api/models/FunctionDeleteParamsTest.kt | 21 +- .../api/models/FunctionInvokeParamsTest.kt | 209 +- .../api/models/FunctionListParamsTest.kt | 82 +- .../api/models/FunctionReplaceParamsTest.kt | 533 ++- .../api/models/FunctionRetrieveParamsTest.kt | 21 +- .../braintrustdata/api/models/FunctionTest.kt | 366 +- .../api/models/FunctionUpdateParamsTest.kt | 439 +- .../api/models/GroupCreateParamsTest.kt | 57 +- .../api/models/GroupDeleteParamsTest.kt | 19 +- .../api/models/GroupListParamsTest.kt | 58 +- .../api/models/GroupReplaceParamsTest.kt | 57 +- .../api/models/GroupRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/GroupTest.kt | 45 +- .../api/models/GroupUpdateParamsTest.kt | 79 +- .../api/models/InsertDatasetEventTest.kt | 73 +- .../api/models/InsertEventsResponseTest.kt | 8 +- .../api/models/InsertExperimentEventTest.kt | 186 +- .../api/models/InsertProjectLogsEventTest.kt | 182 +- .../api/models/MetricSummaryTest.kt | 31 +- .../api/models/OnlineScoreConfigTest.kt | 42 +- .../models/OrganizationDeleteParamsTest.kt | 23 +- .../api/models/OrganizationListParamsTest.kt | 52 +- .../OrganizationMemberUpdateParamsTest.kt | 123 +- .../models/OrganizationRetrieveParamsTest.kt | 23 +- .../api/models/OrganizationTest.kt | 36 +- .../models/OrganizationUpdateParamsTest.kt | 75 +- .../PatchOrganizationMembersOutputTest.kt | 20 +- .../api/models/ProjectCreateParamsTest.kt | 28 +- .../api/models/ProjectDeleteParamsTest.kt | 19 +- .../api/models/ProjectListParamsTest.kt | 58 +- .../models/ProjectLogFeedbackParamsTest.kt | 157 +- .../api/models/ProjectLogFetchParamsTest.kt | 69 +- .../models/ProjectLogFetchPostParamsTest.kt | 75 +- .../api/models/ProjectLogInsertParamsTest.kt | 333 +- .../api/models/ProjectLogsEventTest.kt | 214 +- .../api/models/ProjectRetrieveParamsTest.kt | 21 +- .../api/models/ProjectScoreCategoryTest.kt | 11 +- .../api/models/ProjectScoreConfigTest.kt | 61 +- .../models/ProjectScoreCreateParamsTest.kt | 179 +- .../models/ProjectScoreDeleteParamsTest.kt | 23 +- .../api/models/ProjectScoreListParamsTest.kt | 82 +- .../models/ProjectScoreReplaceParamsTest.kt | 179 +- .../models/ProjectScoreRetrieveParamsTest.kt | 23 +- .../api/models/ProjectScoreTest.kt | 122 +- .../models/ProjectScoreUpdateParamsTest.kt | 184 +- .../api/models/ProjectSettingsTest.kt | 8 +- .../api/models/ProjectTagCreateParamsTest.kt | 58 +- .../api/models/ProjectTagDeleteParamsTest.kt | 23 +- .../api/models/ProjectTagListParamsTest.kt | 70 +- .../api/models/ProjectTagReplaceParamsTest.kt | 58 +- .../models/ProjectTagRetrieveParamsTest.kt | 23 +- .../api/models/ProjectTagTest.kt | 35 +- .../api/models/ProjectTagUpdateParamsTest.kt | 67 +- .../braintrustdata/api/models/ProjectTest.kt | 40 +- .../api/models/ProjectUpdateParamsTest.kt | 64 +- .../api/models/PromptCreateParamsTest.kt | 419 +- .../api/models/PromptDataTest.kt | 227 +- .../api/models/PromptDeleteParamsTest.kt | 19 +- .../api/models/PromptListParamsTest.kt | 82 +- .../api/models/PromptOptionsTest.kt | 104 +- .../api/models/PromptReplaceParamsTest.kt | 419 +- .../api/models/PromptRetrieveParamsTest.kt | 19 +- .../braintrustdata/api/models/PromptTest.kt | 301 +- .../api/models/PromptUpdateParamsTest.kt | 414 +- .../braintrustdata/api/models/RepoInfoTest.kt | 43 +- .../api/models/RoleCreateParamsTest.kt | 90 +- .../api/models/RoleDeleteParamsTest.kt | 19 +- .../api/models/RoleListParamsTest.kt | 58 +- .../api/models/RoleReplaceParamsTest.kt | 90 +- .../api/models/RoleRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/RoleTest.kt | 60 +- .../api/models/RoleUpdateParamsTest.kt | 144 +- .../api/models/ScoreSummaryTest.kt | 27 +- .../api/models/SpanAttributesTest.kt | 12 +- .../api/models/SpanIFrameTest.kt | 44 +- .../api/models/SpanIframeCreateParamsTest.kt | 72 +- .../api/models/SpanIframeDeleteParamsTest.kt | 23 +- .../api/models/SpanIframeListParamsTest.kt | 58 +- .../api/models/SpanIframeReplaceParamsTest.kt | 72 +- .../models/SpanIframeRetrieveParamsTest.kt | 23 +- .../api/models/SpanIframeUpdateParamsTest.kt | 67 +- .../models/SummarizeDatasetResponseTest.kt | 32 +- .../models/SummarizeExperimentResponseTest.kt | 134 +- .../models/TopLevelHelloWorldParamsTest.kt | 2 +- .../api/models/UserListParamsTest.kt | 70 +- .../api/models/UserRetrieveParamsTest.kt | 19 +- .../com/braintrustdata/api/models/UserTest.kt | 31 +- .../api/models/ViewCreateParamsTest.kt | 208 +- .../api/models/ViewDataSearchTest.kt | 26 +- .../braintrustdata/api/models/ViewDataTest.kt | 36 +- .../api/models/ViewDeleteParamsTest.kt | 69 +- .../api/models/ViewListParamsTest.kt | 81 +- .../api/models/ViewOptionsTest.kt | 45 +- .../api/models/ViewReplaceParamsTest.kt | 208 +- .../api/models/ViewRetrieveParamsTest.kt | 69 +- .../com/braintrustdata/api/models/ViewTest.kt | 129 +- .../api/models/ViewUpdateParamsTest.kt | 221 +- .../api/services/ErrorHandlingTest.kt | 343 +- .../api/services/ServiceParamsTest.kt | 45 +- .../api/services/async/AclServiceAsyncTest.kt | 232 +- .../async/AiSecretServiceAsyncTest.kt | 227 +- .../services/async/ApiKeyServiceAsyncTest.kt | 89 +- .../services/async/DatasetServiceAsyncTest.kt | 374 +- .../services/async/EnvVarServiceAsyncTest.kt | 192 +- .../services/async/EvalServiceAsyncTest.kt | 106 +- .../async/ExperimentServiceAsyncTest.kt | 510 ++- .../async/FunctionServiceAsyncTest.kt | 664 +-- .../services/async/GroupServiceAsyncTest.kt | 184 +- .../async/OrganizationServiceAsyncTest.kt | 100 +- .../async/ProjectScoreServiceAsyncTest.kt | 293 +- .../services/async/ProjectServiceAsyncTest.kt | 135 +- .../async/ProjectTagServiceAsyncTest.kt | 176 +- .../services/async/PromptServiceAsyncTest.kt | 537 ++- .../services/async/RoleServiceAsyncTest.kt | 223 +- .../async/SpanIframeServiceAsyncTest.kt | 180 +- .../async/TopLevelServiceAsyncTest.kt | 16 +- .../services/async/UserServiceAsyncTest.kt | 44 +- .../services/async/ViewServiceAsyncTest.kt | 340 +- .../organizations/MemberServiceAsyncTest.kt | 56 +- .../async/projects/LogServiceAsyncTest.kt | 240 +- .../api/services/blocking/AclServiceTest.kt | 220 +- .../services/blocking/AiSecretServiceTest.kt | 213 +- .../services/blocking/ApiKeyServiceTest.kt | 81 +- .../services/blocking/DatasetServiceTest.kt | 354 +- .../services/blocking/EnvVarServiceTest.kt | 180 +- .../api/services/blocking/EvalServiceTest.kt | 104 +- .../blocking/ExperimentServiceTest.kt | 490 +- .../services/blocking/FunctionServiceTest.kt | 650 ++- .../api/services/blocking/GroupServiceTest.kt | 172 +- .../blocking/OrganizationServiceTest.kt | 92 +- .../blocking/ProjectScoreServiceTest.kt | 281 +- .../services/blocking/ProjectServiceTest.kt | 125 +- .../blocking/ProjectTagServiceTest.kt | 164 +- .../services/blocking/PromptServiceTest.kt | 517 ++- .../api/services/blocking/RoleServiceTest.kt | 211 +- .../blocking/SpanIframeServiceTest.kt | 168 +- .../services/blocking/TopLevelServiceTest.kt | 14 +- .../api/services/blocking/UserServiceTest.kt | 40 +- .../api/services/blocking/ViewServiceTest.kt | 328 +- .../organizations/MemberServiceTest.kt | 54 +- .../blocking/projects/LogServiceTest.kt | 232 +- 539 files changed, 71083 insertions(+), 77748 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 84c8fb9c..94c291ac 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -19,15 +19,10 @@ class BraintrustOkHttpClient private constructor() { companion object { - /** - * Returns a mutable builder for constructing an instance of - * [BraintrustOkHttpClient]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [BraintrustOkHttpClient]. */ + @JvmStatic fun builder() = Builder() - @JvmStatic - fun fromEnv(): BraintrustClient = builder().fromEnv().build() + @JvmStatic fun fromEnv(): BraintrustClient = builder().fromEnv().build() } /** A builder for [BraintrustOkHttpClient]. */ @@ -38,163 +33,99 @@ class BraintrustOkHttpClient private constructor() { private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = - apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } - - fun jsonMapper(jsonMapper: JsonMapper) = - apply { - clientOptions.jsonMapper(jsonMapper) - } - - fun clock(clock: Clock) = - apply { - clientOptions.clock(clock) - } - - fun headers(headers: Headers) = - apply { - clientOptions.headers(headers) - } - - fun headers(headers: Map>) = - apply { - clientOptions.headers(headers) - } - - fun putHeader(name: String, value: String) = - apply { - clientOptions.putHeader( - name, value - ) - } - - fun putHeaders(name: String, values: Iterable) = - apply { - clientOptions.putHeaders( - name, values - ) - } - - fun putAllHeaders(headers: Headers) = - apply { - clientOptions.putAllHeaders(headers) - } - - fun putAllHeaders(headers: Map>) = - apply { - clientOptions.putAllHeaders(headers) - } - - fun replaceHeaders(name: String, value: String) = - apply { - clientOptions.replaceHeaders( - name, value - ) - } - - fun replaceHeaders(name: String, values: Iterable) = - apply { - clientOptions.replaceHeaders( - name, values - ) - } - - fun replaceAllHeaders(headers: Headers) = - apply { - clientOptions.replaceAllHeaders(headers) - } - - fun replaceAllHeaders(headers: Map>) = - apply { - clientOptions.replaceAllHeaders(headers) - } - - fun removeHeaders(name: String) = - apply { - clientOptions.removeHeaders(name) - } - - fun removeAllHeaders(names: Set) = - apply { - clientOptions.removeAllHeaders(names) - } - - fun queryParams(queryParams: QueryParams) = - apply { - clientOptions.queryParams(queryParams) - } - - fun queryParams(queryParams: Map>) = - apply { - clientOptions.queryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = - apply { - clientOptions.putQueryParam( - key, value - ) - } - - fun putQueryParams(key: String, values: Iterable) = - apply { - clientOptions.putQueryParams( - key, values - ) - } - - fun putAllQueryParams(queryParams: QueryParams) = - apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = - apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = - apply { - clientOptions.replaceQueryParams( - key, value - ) - } - - fun replaceQueryParams(key: String, values: Iterable) = - apply { - clientOptions.replaceQueryParams( - key, values - ) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = - apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = - apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun removeQueryParams(key: String) = - apply { - clientOptions.removeQueryParams(key) - } - - fun removeAllQueryParams(keys: Set) = - apply { - clientOptions.removeAllQueryParams(keys) - } - - fun timeout(timeout: Timeout) = - apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } + fun baseUrl(baseUrl: String) = apply { + clientOptions.baseUrl(baseUrl) + this.baseUrl = baseUrl + } + + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } /** * Sets the maximum time allowed for a complete HTTP call, not including retries. @@ -205,40 +136,31 @@ class BraintrustOkHttpClient private constructor() { */ fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - fun maxRetries(maxRetries: Int) = - apply { - clientOptions.maxRetries(maxRetries) - } + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } - fun proxy(proxy: Proxy) = - apply { - this.proxy = proxy - } + fun proxy(proxy: Proxy) = apply { this.proxy = proxy } - fun responseValidation(responseValidation: Boolean) = - apply { - clientOptions.responseValidation(responseValidation) - } + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } - fun apiKey(apiKey: String?) = - apply { - clientOptions.apiKey(apiKey) - } + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun fromEnv() = - apply { - clientOptions.fromEnv() - } + fun fromEnv() = apply { clientOptions.fromEnv() } fun build(): BraintrustClient = - BraintrustClientImpl(clientOptions - .httpClient(OkHttpClient.builder() - .baseUrl(baseUrl) - .timeout(timeout) - .proxy(proxy) - .build()) - .build()) + BraintrustClientImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build() + ) + .build() + ) } } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index 51d97cb3..ffc88f5c 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -20,14 +20,11 @@ class BraintrustOkHttpClientAsync private constructor() { companion object { /** - * Returns a mutable builder for constructing an instance of - * [BraintrustOkHttpClientAsync]. + * Returns a mutable builder for constructing an instance of [BraintrustOkHttpClientAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() - @JvmStatic - fun fromEnv(): BraintrustClientAsync = builder().fromEnv().build() + @JvmStatic fun fromEnv(): BraintrustClientAsync = builder().fromEnv().build() } /** A builder for [BraintrustOkHttpClientAsync]. */ @@ -38,163 +35,99 @@ class BraintrustOkHttpClientAsync private constructor() { private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = - apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } - - fun jsonMapper(jsonMapper: JsonMapper) = - apply { - clientOptions.jsonMapper(jsonMapper) - } - - fun clock(clock: Clock) = - apply { - clientOptions.clock(clock) - } - - fun headers(headers: Headers) = - apply { - clientOptions.headers(headers) - } - - fun headers(headers: Map>) = - apply { - clientOptions.headers(headers) - } - - fun putHeader(name: String, value: String) = - apply { - clientOptions.putHeader( - name, value - ) - } - - fun putHeaders(name: String, values: Iterable) = - apply { - clientOptions.putHeaders( - name, values - ) - } - - fun putAllHeaders(headers: Headers) = - apply { - clientOptions.putAllHeaders(headers) - } - - fun putAllHeaders(headers: Map>) = - apply { - clientOptions.putAllHeaders(headers) - } - - fun replaceHeaders(name: String, value: String) = - apply { - clientOptions.replaceHeaders( - name, value - ) - } - - fun replaceHeaders(name: String, values: Iterable) = - apply { - clientOptions.replaceHeaders( - name, values - ) - } - - fun replaceAllHeaders(headers: Headers) = - apply { - clientOptions.replaceAllHeaders(headers) - } - - fun replaceAllHeaders(headers: Map>) = - apply { - clientOptions.replaceAllHeaders(headers) - } - - fun removeHeaders(name: String) = - apply { - clientOptions.removeHeaders(name) - } - - fun removeAllHeaders(names: Set) = - apply { - clientOptions.removeAllHeaders(names) - } - - fun queryParams(queryParams: QueryParams) = - apply { - clientOptions.queryParams(queryParams) - } - - fun queryParams(queryParams: Map>) = - apply { - clientOptions.queryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = - apply { - clientOptions.putQueryParam( - key, value - ) - } - - fun putQueryParams(key: String, values: Iterable) = - apply { - clientOptions.putQueryParams( - key, values - ) - } - - fun putAllQueryParams(queryParams: QueryParams) = - apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = - apply { - clientOptions.putAllQueryParams(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = - apply { - clientOptions.replaceQueryParams( - key, value - ) - } - - fun replaceQueryParams(key: String, values: Iterable) = - apply { - clientOptions.replaceQueryParams( - key, values - ) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = - apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = - apply { - clientOptions.replaceAllQueryParams(queryParams) - } - - fun removeQueryParams(key: String) = - apply { - clientOptions.removeQueryParams(key) - } - - fun removeAllQueryParams(keys: Set) = - apply { - clientOptions.removeAllQueryParams(keys) - } - - fun timeout(timeout: Timeout) = - apply { - clientOptions.timeout(timeout) - this.timeout = timeout - } + fun baseUrl(baseUrl: String) = apply { + clientOptions.baseUrl(baseUrl) + this.baseUrl = baseUrl + } + + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } /** * Sets the maximum time allowed for a complete HTTP call, not including retries. @@ -205,40 +138,31 @@ class BraintrustOkHttpClientAsync private constructor() { */ fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) - fun maxRetries(maxRetries: Int) = - apply { - clientOptions.maxRetries(maxRetries) - } + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } - fun proxy(proxy: Proxy) = - apply { - this.proxy = proxy - } + fun proxy(proxy: Proxy) = apply { this.proxy = proxy } - fun responseValidation(responseValidation: Boolean) = - apply { - clientOptions.responseValidation(responseValidation) - } + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } - fun apiKey(apiKey: String?) = - apply { - clientOptions.apiKey(apiKey) - } + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun fromEnv() = - apply { - clientOptions.fromEnv() - } + fun fromEnv() = apply { clientOptions.fromEnv() } fun build(): BraintrustClientAsync = - BraintrustClientAsyncImpl(clientOptions - .httpClient(OkHttpClient.builder() - .baseUrl(baseUrl) - .timeout(timeout) - .proxy(proxy) - .build()) - .build()) + BraintrustClientAsyncImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build() + ) + .build() + ) } } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index fff41a7f..49a5df68 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -5,27 +5,26 @@ import com.braintrustdata.api.core.Timeout import com.braintrustdata.api.core.checkRequired import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpClient +import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpRequestBody import com.braintrustdata.api.core.http.HttpResponse -import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.errors.BraintrustIoException import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CompletableFuture -import java.util.concurrent.TimeUnit import okhttp3.Call import okhttp3.Callback import okhttp3.HttpUrl -import okhttp3.Response -import okhttp3.Request -import okhttp3.RequestBody -import okhttp3.MediaType import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Request +import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink @@ -33,10 +32,7 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) return try { @@ -56,16 +52,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } - newCall(request, requestOptions).enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(BraintrustIoException("Request failed", e)) + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(BraintrustIoException("Request failed", e)) + } } - }) + ) return future } @@ -87,11 +85,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } if (logLevel != null) { clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor() - .setLevel(logLevel) - .apply { - redactHeader("Authorization") - } + HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } ) } @@ -118,16 +112,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val headers.values(name).forEach { builder.header(name, it) } } - if (!headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0) { + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { builder.header( "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString() + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { builder.header( "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString() + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), ) } @@ -187,9 +183,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun okhttp3.Headers.toHeaders(): Headers { - val headersBuilder = Headers.builder() - forEach { (name, value) -> headersBuilder.put(name, value) } - return headersBuilder.build() + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() } companion object { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index 98b6a055..bc327480 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -23,33 +23,31 @@ import com.braintrustdata.api.services.blocking.UserService import com.braintrustdata.api.services.blocking.ViewService /** - * A client for interacting with the Braintrust REST API synchronously. You can - * also switch to asynchronous execution via the [async] method. + * A client for interacting with the Braintrust REST API synchronously. You can also switch to + * asynchronous execution via the [async] method. * - * This client performs best when you create a single instance and reuse it for all - * interactions with the REST API. This is because each client holds its own - * connection pool and thread pools. Reusing connections and threads reduces - * latency and saves memory. The client also handles rate limiting per client. This - * means that creating and using multiple instances at the same time will not - * respect rate limits. + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. * - * The threads and connections that are held will be released automatically if they - * remain idle. But if you are writing an application that needs to aggressively - * release unused resources, then you may call [close]. + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. */ interface BraintrustClient { /** * Returns a version of this client that uses asynchronous execution. * - * The returned client shares its resources, like its connection pool and thread - * pools, with this client. + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. */ fun async(): BraintrustClientAsync /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse @@ -94,21 +92,17 @@ interface BraintrustClient { /** * Closes this client, relinquishing any underlying resources. * - * This is purposefully not inherited from [AutoCloseable] because the client is - * long-lived and usually should not be synchronously closed via - * try-with-resources. + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. * - * It's also usually not necessary to call this method at all. the default HTTP - * client automatically releases threads and connections if they remain idle, but - * if you are writing an application that needs to aggressively release unused - * resources, then you may call this method. + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. */ fun close() - /** - * A view of [BraintrustClient] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [BraintrustClient] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { fun topLevel(): TopLevelService.WithRawResponse diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index 56e174fe..24ed3368 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -23,33 +23,31 @@ import com.braintrustdata.api.services.async.UserServiceAsync import com.braintrustdata.api.services.async.ViewServiceAsync /** - * A client for interacting with the Braintrust REST API asynchronously. You can - * also switch to synchronous execution via the [sync] method. + * A client for interacting with the Braintrust REST API asynchronously. You can also switch to + * synchronous execution via the [sync] method. * - * This client performs best when you create a single instance and reuse it for all - * interactions with the REST API. This is because each client holds its own - * connection pool and thread pools. Reusing connections and threads reduces - * latency and saves memory. The client also handles rate limiting per client. This - * means that creating and using multiple instances at the same time will not - * respect rate limits. + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. * - * The threads and connections that are held will be released automatically if they - * remain idle. But if you are writing an application that needs to aggressively - * release unused resources, then you may call [close]. + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. */ interface BraintrustClientAsync { /** * Returns a version of this client that uses synchronous execution. * - * The returned client shares its resources, like its connection pool and thread - * pools, with this client. + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. */ fun sync(): BraintrustClient /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse @@ -94,20 +92,18 @@ interface BraintrustClientAsync { /** * Closes this client, relinquishing any underlying resources. * - * This is purposefully not inherited from [AutoCloseable] because the client is - * long-lived and usually should not be synchronously closed via - * try-with-resources. + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. * - * It's also usually not necessary to call this method at all. the default HTTP - * client automatically releases threads and connections if they remain idle, but - * if you are writing an application that needs to aggressively release unused - * resources, then you may call this method. + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. */ fun close() /** - * A view of [BraintrustClientAsync] that provides access to raw HTTP responses for - * each method. + * A view of [BraintrustClientAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index 87e33418..e945466b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -43,57 +43,86 @@ import com.braintrustdata.api.services.async.UserServiceAsyncImpl import com.braintrustdata.api.services.async.ViewServiceAsync import com.braintrustdata.api.services.async.ViewServiceAsyncImpl -class BraintrustClientAsyncImpl( - private val clientOptions: ClientOptions, - -) : BraintrustClientAsync { +class BraintrustClientAsyncImpl(private val clientOptions: ClientOptions) : BraintrustClientAsync { private val clientOptionsWithUserAgent = - - if (clientOptions.headers.names().contains("User-Agent")) clientOptions - - else clientOptions.toBuilder().putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}").build() + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() // Pass the original clientOptions so that this client sets its own User-Agent. private val sync: BraintrustClient by lazy { BraintrustClientImpl(clientOptions) } - private val withRawResponse: BraintrustClientAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: BraintrustClientAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) } + private val topLevel: TopLevelServiceAsync by lazy { + TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptionsWithUserAgent) } + private val projects: ProjectServiceAsync by lazy { + ProjectServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val experiments: ExperimentServiceAsync by lazy { ExperimentServiceAsyncImpl(clientOptionsWithUserAgent) } + private val experiments: ExperimentServiceAsync by lazy { + ExperimentServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val datasets: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptionsWithUserAgent) } + private val datasets: DatasetServiceAsync by lazy { + DatasetServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val prompts: PromptServiceAsync by lazy { PromptServiceAsyncImpl(clientOptionsWithUserAgent) } + private val prompts: PromptServiceAsync by lazy { + PromptServiceAsyncImpl(clientOptionsWithUserAgent) + } private val roles: RoleServiceAsync by lazy { RoleServiceAsyncImpl(clientOptionsWithUserAgent) } - private val groups: GroupServiceAsync by lazy { GroupServiceAsyncImpl(clientOptionsWithUserAgent) } + private val groups: GroupServiceAsync by lazy { + GroupServiceAsyncImpl(clientOptionsWithUserAgent) + } private val acls: AclServiceAsync by lazy { AclServiceAsyncImpl(clientOptionsWithUserAgent) } private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptionsWithUserAgent) } - private val projectScores: ProjectScoreServiceAsync by lazy { ProjectScoreServiceAsyncImpl(clientOptionsWithUserAgent) } + private val projectScores: ProjectScoreServiceAsync by lazy { + ProjectScoreServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val projectTags: ProjectTagServiceAsync by lazy { ProjectTagServiceAsyncImpl(clientOptionsWithUserAgent) } + private val projectTags: ProjectTagServiceAsync by lazy { + ProjectTagServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val spanIframes: SpanIframeServiceAsync by lazy { SpanIframeServiceAsyncImpl(clientOptionsWithUserAgent) } + private val spanIframes: SpanIframeServiceAsync by lazy { + SpanIframeServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val functions: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptionsWithUserAgent) } + private val functions: FunctionServiceAsync by lazy { + FunctionServiceAsyncImpl(clientOptionsWithUserAgent) + } private val views: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptionsWithUserAgent) } - private val organizations: OrganizationServiceAsync by lazy { OrganizationServiceAsyncImpl(clientOptionsWithUserAgent) } + private val organizations: OrganizationServiceAsync by lazy { + OrganizationServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptionsWithUserAgent) } + private val apiKeys: ApiKeyServiceAsync by lazy { + ApiKeyServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val aiSecrets: AiSecretServiceAsync by lazy { AiSecretServiceAsyncImpl(clientOptionsWithUserAgent) } + private val aiSecrets: AiSecretServiceAsync by lazy { + AiSecretServiceAsyncImpl(clientOptionsWithUserAgent) + } - private val envVars: EnvVarServiceAsync by lazy { EnvVarServiceAsyncImpl(clientOptionsWithUserAgent) } + private val envVars: EnvVarServiceAsync by lazy { + EnvVarServiceAsyncImpl(clientOptionsWithUserAgent) + } private val evals: EvalServiceAsync by lazy { EvalServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -141,48 +170,84 @@ class BraintrustClientAsyncImpl( override fun close() = clientOptions.httpClient.close() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : BraintrustClientAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BraintrustClientAsync.WithRawResponse { - private val topLevel: TopLevelServiceAsync.WithRawResponse by lazy { TopLevelServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val topLevel: TopLevelServiceAsync.WithRawResponse by lazy { + TopLevelServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val projects: ProjectServiceAsync.WithRawResponse by lazy { ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val projects: ProjectServiceAsync.WithRawResponse by lazy { + ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val experiments: ExperimentServiceAsync.WithRawResponse by lazy { ExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val experiments: ExperimentServiceAsync.WithRawResponse by lazy { + ExperimentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val datasets: DatasetServiceAsync.WithRawResponse by lazy { DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val datasets: DatasetServiceAsync.WithRawResponse by lazy { + DatasetServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val prompts: PromptServiceAsync.WithRawResponse by lazy { PromptServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val prompts: PromptServiceAsync.WithRawResponse by lazy { + PromptServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val roles: RoleServiceAsync.WithRawResponse by lazy { RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val roles: RoleServiceAsync.WithRawResponse by lazy { + RoleServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val groups: GroupServiceAsync.WithRawResponse by lazy { GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val groups: GroupServiceAsync.WithRawResponse by lazy { + GroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val acls: AclServiceAsync.WithRawResponse by lazy { AclServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val acls: AclServiceAsync.WithRawResponse by lazy { + AclServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val users: UserServiceAsync.WithRawResponse by lazy { UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val users: UserServiceAsync.WithRawResponse by lazy { + UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val projectScores: ProjectScoreServiceAsync.WithRawResponse by lazy { ProjectScoreServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val projectScores: ProjectScoreServiceAsync.WithRawResponse by lazy { + ProjectScoreServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val projectTags: ProjectTagServiceAsync.WithRawResponse by lazy { ProjectTagServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val projectTags: ProjectTagServiceAsync.WithRawResponse by lazy { + ProjectTagServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val spanIframes: SpanIframeServiceAsync.WithRawResponse by lazy { SpanIframeServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val spanIframes: SpanIframeServiceAsync.WithRawResponse by lazy { + SpanIframeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val functions: FunctionServiceAsync.WithRawResponse by lazy { FunctionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val functions: FunctionServiceAsync.WithRawResponse by lazy { + FunctionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val views: ViewServiceAsync.WithRawResponse by lazy { ViewServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val views: ViewServiceAsync.WithRawResponse by lazy { + ViewServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val organizations: OrganizationServiceAsync.WithRawResponse by lazy { OrganizationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val organizations: OrganizationServiceAsync.WithRawResponse by lazy { + OrganizationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val apiKeys: ApiKeyServiceAsync.WithRawResponse by lazy { ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val apiKeys: ApiKeyServiceAsync.WithRawResponse by lazy { + ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val aiSecrets: AiSecretServiceAsync.WithRawResponse by lazy { AiSecretServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val aiSecrets: AiSecretServiceAsync.WithRawResponse by lazy { + AiSecretServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val envVars: EnvVarServiceAsync.WithRawResponse by lazy { EnvVarServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val envVars: EnvVarServiceAsync.WithRawResponse by lazy { + EnvVarServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } - private val evals: EvalServiceAsync.WithRawResponse by lazy { EvalServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val evals: EvalServiceAsync.WithRawResponse by lazy { + EvalServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index ef76e148..3eecd3cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -43,27 +43,32 @@ import com.braintrustdata.api.services.blocking.UserServiceImpl import com.braintrustdata.api.services.blocking.ViewService import com.braintrustdata.api.services.blocking.ViewServiceImpl -class BraintrustClientImpl( - private val clientOptions: ClientOptions, - -) : BraintrustClient { +class BraintrustClientImpl(private val clientOptions: ClientOptions) : BraintrustClient { private val clientOptionsWithUserAgent = - - if (clientOptions.headers.names().contains("User-Agent")) clientOptions - - else clientOptions.toBuilder().putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}").build() + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() // Pass the original clientOptions so that this client sets its own User-Agent. private val async: BraintrustClientAsync by lazy { BraintrustClientAsyncImpl(clientOptions) } - private val withRawResponse: BraintrustClient.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: BraintrustClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptionsWithUserAgent) } + private val topLevel: TopLevelService by lazy { + TopLevelServiceImpl(clientOptionsWithUserAgent) + } private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) } - private val experiments: ExperimentService by lazy { ExperimentServiceImpl(clientOptionsWithUserAgent) } + private val experiments: ExperimentService by lazy { + ExperimentServiceImpl(clientOptionsWithUserAgent) + } private val datasets: DatasetService by lazy { DatasetServiceImpl(clientOptionsWithUserAgent) } @@ -77,21 +82,33 @@ class BraintrustClientImpl( private val users: UserService by lazy { UserServiceImpl(clientOptionsWithUserAgent) } - private val projectScores: ProjectScoreService by lazy { ProjectScoreServiceImpl(clientOptionsWithUserAgent) } + private val projectScores: ProjectScoreService by lazy { + ProjectScoreServiceImpl(clientOptionsWithUserAgent) + } - private val projectTags: ProjectTagService by lazy { ProjectTagServiceImpl(clientOptionsWithUserAgent) } + private val projectTags: ProjectTagService by lazy { + ProjectTagServiceImpl(clientOptionsWithUserAgent) + } - private val spanIframes: SpanIframeService by lazy { SpanIframeServiceImpl(clientOptionsWithUserAgent) } + private val spanIframes: SpanIframeService by lazy { + SpanIframeServiceImpl(clientOptionsWithUserAgent) + } - private val functions: FunctionService by lazy { FunctionServiceImpl(clientOptionsWithUserAgent) } + private val functions: FunctionService by lazy { + FunctionServiceImpl(clientOptionsWithUserAgent) + } private val views: ViewService by lazy { ViewServiceImpl(clientOptionsWithUserAgent) } - private val organizations: OrganizationService by lazy { OrganizationServiceImpl(clientOptionsWithUserAgent) } + private val organizations: OrganizationService by lazy { + OrganizationServiceImpl(clientOptionsWithUserAgent) + } private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptionsWithUserAgent) } - private val aiSecrets: AiSecretService by lazy { AiSecretServiceImpl(clientOptionsWithUserAgent) } + private val aiSecrets: AiSecretService by lazy { + AiSecretServiceImpl(clientOptionsWithUserAgent) + } private val envVars: EnvVarService by lazy { EnvVarServiceImpl(clientOptionsWithUserAgent) } @@ -141,48 +158,84 @@ class BraintrustClientImpl( override fun close() = clientOptions.httpClient.close() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : BraintrustClient.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BraintrustClient.WithRawResponse { - private val topLevel: TopLevelService.WithRawResponse by lazy { TopLevelServiceImpl.WithRawResponseImpl(clientOptions) } + private val topLevel: TopLevelService.WithRawResponse by lazy { + TopLevelServiceImpl.WithRawResponseImpl(clientOptions) + } - private val projects: ProjectService.WithRawResponse by lazy { ProjectServiceImpl.WithRawResponseImpl(clientOptions) } + private val projects: ProjectService.WithRawResponse by lazy { + ProjectServiceImpl.WithRawResponseImpl(clientOptions) + } - private val experiments: ExperimentService.WithRawResponse by lazy { ExperimentServiceImpl.WithRawResponseImpl(clientOptions) } + private val experiments: ExperimentService.WithRawResponse by lazy { + ExperimentServiceImpl.WithRawResponseImpl(clientOptions) + } - private val datasets: DatasetService.WithRawResponse by lazy { DatasetServiceImpl.WithRawResponseImpl(clientOptions) } + private val datasets: DatasetService.WithRawResponse by lazy { + DatasetServiceImpl.WithRawResponseImpl(clientOptions) + } - private val prompts: PromptService.WithRawResponse by lazy { PromptServiceImpl.WithRawResponseImpl(clientOptions) } + private val prompts: PromptService.WithRawResponse by lazy { + PromptServiceImpl.WithRawResponseImpl(clientOptions) + } - private val roles: RoleService.WithRawResponse by lazy { RoleServiceImpl.WithRawResponseImpl(clientOptions) } + private val roles: RoleService.WithRawResponse by lazy { + RoleServiceImpl.WithRawResponseImpl(clientOptions) + } - private val groups: GroupService.WithRawResponse by lazy { GroupServiceImpl.WithRawResponseImpl(clientOptions) } + private val groups: GroupService.WithRawResponse by lazy { + GroupServiceImpl.WithRawResponseImpl(clientOptions) + } - private val acls: AclService.WithRawResponse by lazy { AclServiceImpl.WithRawResponseImpl(clientOptions) } + private val acls: AclService.WithRawResponse by lazy { + AclServiceImpl.WithRawResponseImpl(clientOptions) + } - private val users: UserService.WithRawResponse by lazy { UserServiceImpl.WithRawResponseImpl(clientOptions) } + private val users: UserService.WithRawResponse by lazy { + UserServiceImpl.WithRawResponseImpl(clientOptions) + } - private val projectScores: ProjectScoreService.WithRawResponse by lazy { ProjectScoreServiceImpl.WithRawResponseImpl(clientOptions) } + private val projectScores: ProjectScoreService.WithRawResponse by lazy { + ProjectScoreServiceImpl.WithRawResponseImpl(clientOptions) + } - private val projectTags: ProjectTagService.WithRawResponse by lazy { ProjectTagServiceImpl.WithRawResponseImpl(clientOptions) } + private val projectTags: ProjectTagService.WithRawResponse by lazy { + ProjectTagServiceImpl.WithRawResponseImpl(clientOptions) + } - private val spanIframes: SpanIframeService.WithRawResponse by lazy { SpanIframeServiceImpl.WithRawResponseImpl(clientOptions) } + private val spanIframes: SpanIframeService.WithRawResponse by lazy { + SpanIframeServiceImpl.WithRawResponseImpl(clientOptions) + } - private val functions: FunctionService.WithRawResponse by lazy { FunctionServiceImpl.WithRawResponseImpl(clientOptions) } + private val functions: FunctionService.WithRawResponse by lazy { + FunctionServiceImpl.WithRawResponseImpl(clientOptions) + } - private val views: ViewService.WithRawResponse by lazy { ViewServiceImpl.WithRawResponseImpl(clientOptions) } + private val views: ViewService.WithRawResponse by lazy { + ViewServiceImpl.WithRawResponseImpl(clientOptions) + } - private val organizations: OrganizationService.WithRawResponse by lazy { OrganizationServiceImpl.WithRawResponseImpl(clientOptions) } + private val organizations: OrganizationService.WithRawResponse by lazy { + OrganizationServiceImpl.WithRawResponseImpl(clientOptions) + } - private val apiKeys: ApiKeyService.WithRawResponse by lazy { ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) } + private val apiKeys: ApiKeyService.WithRawResponse by lazy { + ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) + } - private val aiSecrets: AiSecretService.WithRawResponse by lazy { AiSecretServiceImpl.WithRawResponseImpl(clientOptions) } + private val aiSecrets: AiSecretService.WithRawResponse by lazy { + AiSecretServiceImpl.WithRawResponseImpl(clientOptions) + } - private val envVars: EnvVarService.WithRawResponse by lazy { EnvVarServiceImpl.WithRawResponseImpl(clientOptions) } + private val envVars: EnvVarService.WithRawResponse by lazy { + EnvVarServiceImpl.WithRawResponseImpl(clientOptions) + } - private val evals: EvalService.WithRawResponse by lazy { EvalServiceImpl.WithRawResponseImpl(clientOptions) } + private val evals: EvalService.WithRawResponse by lazy { + EvalServiceImpl.WithRawResponseImpl(clientOptions) + } override fun topLevel(): TopLevelService.WithRawResponse = topLevel diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt index a197b7fe..64d8a5b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt @@ -13,9 +13,13 @@ import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer import kotlin.reflect.KClass -abstract class BaseDeserializer(type: KClass) : StdDeserializer(type.java), ContextualDeserializer { +abstract class BaseDeserializer(type: KClass) : + StdDeserializer(type.java), ContextualDeserializer { - override fun createContextual(context: DeserializationContext, property: BeanProperty?): JsonDeserializer { + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer { return this } @@ -25,7 +29,11 @@ abstract class BaseDeserializer(type: KClass) : StdDeserializer(t protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference, validate: (T) -> Unit = {}): T? { + protected fun ObjectCodec.tryDeserialize( + node: JsonNode, + type: TypeReference, + validate: (T) -> Unit = {}, + ): T? { return try { readValue(treeAsTokens(node), type).apply(validate) } catch (e: JsonMappingException) { @@ -35,7 +43,11 @@ abstract class BaseDeserializer(type: KClass) : StdDeserializer(t } } - protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType, validate: (T) -> Unit = {}): T? { + protected fun ObjectCodec.tryDeserialize( + node: JsonNode, + type: JavaType, + validate: (T) -> Unit = {}, + ): T? { return try { readValue(treeAsTokens(node), type).apply(validate) } catch (e: JsonMappingException) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 4e3c5177..38dc1b87 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -12,7 +12,8 @@ import java.time.Clock import java.util.Optional import kotlin.jvm.optionals.getOrNull -class ClientOptions private constructor( +class ClientOptions +private constructor( private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @@ -24,7 +25,6 @@ class ClientOptions private constructor( @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, private val apiKey: String?, - ) { fun apiKey(): Optional = Optional.ofNullable(apiKey) @@ -39,16 +39,13 @@ class ClientOptions private constructor( * Returns a mutable builder for constructing an instance of [ClientOptions]. * * The following fields are required: - * * ```java * .httpClient() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() - @JvmStatic - fun fromEnv(): ClientOptions = builder().fromEnv().build() + @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } /** A builder for [ClientOptions]. */ @@ -66,232 +63,160 @@ class ClientOptions private constructor( private var apiKey: String? = null @JvmSynthetic - internal fun from(clientOptions: ClientOptions) = - apply { - httpClient = clientOptions.originalHttpClient - jsonMapper = clientOptions.jsonMapper - clock = clientOptions.clock - baseUrl = clientOptions.baseUrl - headers = clientOptions.headers.toBuilder() - queryParams = clientOptions.queryParams.toBuilder() - responseValidation = clientOptions.responseValidation - timeout = clientOptions.timeout - maxRetries = clientOptions.maxRetries - apiKey = clientOptions.apiKey - } + internal fun from(clientOptions: ClientOptions) = apply { + httpClient = clientOptions.originalHttpClient + jsonMapper = clientOptions.jsonMapper + clock = clientOptions.clock + baseUrl = clientOptions.baseUrl + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() + responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout + maxRetries = clientOptions.maxRetries + apiKey = clientOptions.apiKey + } - fun httpClient(httpClient: HttpClient) = - apply { - this.httpClient = httpClient - } + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } - fun jsonMapper(jsonMapper: JsonMapper) = - apply { - this.jsonMapper = jsonMapper - } + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } - fun clock(clock: Clock) = - apply { - this.clock = clock - } + fun clock(clock: Clock) = apply { this.clock = clock } - fun baseUrl(baseUrl: String) = - apply { - this.baseUrl = baseUrl - } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } - fun responseValidation(responseValidation: Boolean) = - apply { - this.responseValidation = responseValidation - } + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } - fun timeout(timeout: Timeout) = - apply { - this.timeout = timeout - } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } - fun maxRetries(maxRetries: Int) = - apply { - this.maxRetries = maxRetries - } + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - fun apiKey(apiKey: String?) = - apply { - this.apiKey = apiKey - } + fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) - fun headers(headers: Headers) = - apply { - this.headers.clear() - putAllHeaders(headers) - } + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } - fun headers(headers: Map>) = - apply { - this.headers.clear() - putAllHeaders(headers) - } + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } - fun putHeader(name: String, value: String) = - apply { - headers.put(name, value) - } + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } - fun putHeaders(name: String, values: Iterable) = - apply { - headers.put(name, values) - } + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } - fun putAllHeaders(headers: Headers) = - apply { - this.headers.putAll(headers) - } + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } - fun putAllHeaders(headers: Map>) = - apply { - this.headers.putAll(headers) - } + fun putAllHeaders(headers: Map>) = apply { + this.headers.putAll(headers) + } - fun replaceHeaders(name: String, value: String) = - apply { - headers.replace(name, value) - } + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } - fun replaceHeaders(name: String, values: Iterable) = - apply { - headers.replace(name, values) - } + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } - fun replaceAllHeaders(headers: Headers) = - apply { - this.headers.replaceAll(headers) - } + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } - fun replaceAllHeaders(headers: Map>) = - apply { - this.headers.replaceAll(headers) - } + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } - fun removeHeaders(name: String) = - apply { - headers.remove(name) - } + fun removeHeaders(name: String) = apply { headers.remove(name) } - fun removeAllHeaders(names: Set) = - apply { - headers.removeAll(names) - } + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } - fun queryParams(queryParams: QueryParams) = - apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } - fun queryParams(queryParams: Map>) = - apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } - fun putQueryParam(key: String, value: String) = - apply { - queryParams.put(key, value) - } + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } - fun putQueryParams(key: String, values: Iterable) = - apply { - queryParams.put(key, values) - } + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } - fun putAllQueryParams(queryParams: QueryParams) = - apply { - this.queryParams.putAll(queryParams) - } + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } - fun putAllQueryParams(queryParams: Map>) = - apply { - this.queryParams.putAll(queryParams) - } + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } - fun replaceQueryParams(key: String, value: String) = - apply { - queryParams.replace(key, value) - } + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } - fun replaceQueryParams(key: String, values: Iterable) = - apply { - queryParams.replace(key, values) - } + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } - fun replaceAllQueryParams(queryParams: QueryParams) = - apply { - this.queryParams.replaceAll(queryParams) - } + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } - fun replaceAllQueryParams(queryParams: Map>) = - apply { - this.queryParams.replaceAll(queryParams) - } + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } - fun removeQueryParams(key: String) = - apply { - queryParams.remove(key) - } + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } - fun removeAllQueryParams(keys: Set) = - apply { - queryParams.removeAll(keys) - } + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun fromEnv() = - apply { - System.getenv("BRAINTRUST_API_KEY")?.let { - apiKey(it) - } - } + fun fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } } fun build(): ClientOptions { - val httpClient = checkRequired( - "httpClient", httpClient - ) - - val headers = Headers.builder() - val queryParams = QueryParams.builder() - headers.put("X-Stainless-Lang", "java") - headers.put("X-Stainless-Arch", getOsArch()) - headers.put("X-Stainless-OS", getOsName()) - headers.put("X-Stainless-OS-Version", getOsVersion()) - headers.put("X-Stainless-Package-Version", getPackageVersion()) - headers.put("X-Stainless-Runtime", "JRE") - headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - apiKey?.let { - if (!it.isEmpty()) { - headers.put("Authorization", "Bearer $it") - } - } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) - - return ClientOptions( - httpClient, - PhantomReachableClosingHttpClient(RetryingHttpClient.builder() - .httpClient(httpClient) - .clock(clock) - .maxRetries(maxRetries) - .build()), - jsonMapper, - clock, - baseUrl, - headers.build(), - queryParams.build(), - responseValidation, - timeout, - maxRetries, - apiKey, - ) + val httpClient = checkRequired("httpClient", httpClient) + + val headers = Headers.builder() + val queryParams = QueryParams.builder() + headers.put("X-Stainless-Lang", "java") + headers.put("X-Stainless-Arch", getOsArch()) + headers.put("X-Stainless-OS", getOsName()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime", "JRE") + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + apiKey?.let { + if (!it.isEmpty()) { + headers.put("Authorization", "Bearer $it") + } + } + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) + + return ClientOptions( + httpClient, + PhantomReachableClosingHttpClient( + RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build() + ), + jsonMapper, + clock, + baseUrl, + headers.build(), + queryParams.build(), + responseValidation, + timeout, + maxRetries, + apiKey, + ) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt index 048e0759..588027c6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ObjectMappers.kt @@ -2,6 +2,8 @@ package com.braintrustdata.api.core +import com.braintrustdata.api.errors.BraintrustException +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.DeserializationFeature @@ -16,8 +18,6 @@ import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder -import com.braintrustdata.api.errors.BraintrustException -import com.braintrustdata.api.errors.BraintrustInvalidDataException import java.io.InputStream fun jsonMapper(): JsonMapper = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt index 9c89c69c..f98bf142 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Params.kt @@ -8,6 +8,9 @@ interface Params { /** The full set of headers in the parameters, including both fixed and additional headers. */ fun _headers(): Headers - /** The full set of query params in the parameters, including both fixed and additional query params. */ + /** + * The full set of query params in the parameters, including both fixed and additional query + * params. + */ fun _queryParams(): QueryParams } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt index 74b30572..e9aaadff 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/PrepareRequest.kt @@ -6,10 +6,7 @@ import com.braintrustdata.api.core.http.HttpRequest import java.util.concurrent.CompletableFuture @JvmSynthetic -internal fun HttpRequest.prepare( - clientOptions: ClientOptions, - params: Params -): HttpRequest = +internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = toBuilder() .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(params._queryParams()) @@ -20,7 +17,8 @@ internal fun HttpRequest.prepare( @JvmSynthetic internal fun HttpRequest.prepareAsync( clientOptions: ClientOptions, - params: Params + params: Params, ): CompletableFuture = - // This async version exists to make it easier to add async specific preparation logic in the future. + // This async version exists to make it easier to add async specific preparation logic in the + // future. CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt index 4c80349e..a0924603 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt @@ -9,9 +9,12 @@ fun getOsArch(): String { return when (osArch) { null -> "unknown" - "i386", "x32", "x86" -> "x32" - "amd64", "x86_64" -> "x64" - "arm"-> "arm" + "i386", + "x32", + "x86" -> "x32" + "amd64", + "x86_64" -> "x64" + "arm" -> "arm" "aarch64" -> "arm64" else -> "other:${osArch}" } @@ -33,6 +36,7 @@ fun getOsName(): String { fun getOsVersion(): String = System.getProperty("os.version", "unknown") -fun getPackageVersion(): String = Properties::class.java.`package`.implementationVersion ?: "unknown" +fun getPackageVersion(): String = + Properties::class.java.`package`.implementationVersion ?: "unknown" fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt index d68148e3..fe7c8372 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt @@ -2,11 +2,7 @@ package com.braintrustdata.api.core import java.time.Duration -class RequestOptions -private constructor( - val responseValidation: Boolean?, - val timeout: Timeout?, -) { +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { companion object { @@ -41,9 +37,7 @@ private constructor( this.responseValidation = responseValidation } - fun timeout(timeout: Timeout) = apply { - this.timeout = timeout - } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt index d07f5d3c..6a0cdcc7 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt @@ -8,12 +8,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** A class containing timeouts for various processing phases of a request. */ -class Timeout private constructor( +class Timeout +private constructor( private val connect: Duration?, private val read: Duration?, private val write: Duration?, private val request: Duration?, - ) { /** @@ -26,8 +26,7 @@ class Timeout private constructor( fun connect(): Duration = connect ?: Duration.ofMinutes(1) /** - * The maximum time allowed between two data packets when waiting for the server’s - * response. + * The maximum time allowed between two data packets when waiting for the server’s response. * * A value of [Duration.ZERO] means there's no timeout. * @@ -36,8 +35,7 @@ class Timeout private constructor( fun read(): Duration = read ?: request() /** - * The maximum time allowed between two data packets when sending the request to - * the server. + * The maximum time allowed between two data packets when sending the request to the server. * * A value of [Duration.ZERO] means there's no timeout. * @@ -48,8 +46,8 @@ class Timeout private constructor( /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server - * processing, as well as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * @@ -61,12 +59,10 @@ class Timeout private constructor( companion object { - @JvmStatic - fun default() = builder().build() + @JvmStatic fun default() = builder().build() /** Returns a mutable builder for constructing an instance of [Timeout]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Timeout]. */ @@ -78,13 +74,12 @@ class Timeout private constructor( private var request: Duration? = null @JvmSynthetic - internal fun from(timeout: Timeout) = - apply { - connect = timeout.connect - read = timeout.read - write = timeout.write - request = timeout.request - } + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } /** * The maximum time allowed to establish a connection with a host. @@ -93,10 +88,7 @@ class Timeout private constructor( * * Defaults to `Duration.ofMinutes(1)`. */ - fun connect(connect: Duration?) = - apply { - this.connect = connect - } + fun connect(connect: Duration?) = apply { this.connect = connect } /** * The maximum time allowed to establish a connection with a host. @@ -108,21 +100,16 @@ class Timeout private constructor( fun connect(connect: Optional) = connect(connect.getOrNull()) /** - * The maximum time allowed between two data packets when waiting for the server’s - * response. + * The maximum time allowed between two data packets when waiting for the server’s response. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `request()`. */ - fun read(read: Duration?) = - apply { - this.read = read - } + fun read(read: Duration?) = apply { this.read = read } /** - * The maximum time allowed between two data packets when waiting for the server’s - * response. + * The maximum time allowed between two data packets when waiting for the server’s response. * * A value of [Duration.ZERO] means there's no timeout. * @@ -131,21 +118,16 @@ class Timeout private constructor( fun read(read: Optional) = read(read.getOrNull()) /** - * The maximum time allowed between two data packets when sending the request to - * the server. + * The maximum time allowed between two data packets when sending the request to the server. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `request()`. */ - fun write(write: Duration?) = - apply { - this.write = write - } + fun write(write: Duration?) = apply { this.write = write } /** - * The maximum time allowed between two data packets when sending the request to - * the server. + * The maximum time allowed between two data packets when sending the request to the server. * * A value of [Duration.ZERO] means there's no timeout. * @@ -156,23 +138,20 @@ class Timeout private constructor( /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server - * processing, as well as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * * Defaults to `Duration.ofMinutes(1)`. */ - fun request(request: Duration?) = - apply { - this.request = request - } + fun request(request: Duration?) = apply { this.request = request } /** * The maximum time allowed for a complete HTTP call, not including retries. * - * This includes resolving DNS, connecting, writing the request body, server - * processing, as well as reading the response body. + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. * * A value of [Duration.ZERO] means there's no timeout. * @@ -180,13 +159,7 @@ class Timeout private constructor( */ fun request(request: Optional) = request(request.getOrNull()) - fun build(): Timeout = - Timeout( - connect, - read, - write, - request, - ) + fun build(): Timeout = Timeout(connect, read, write, request) } @JvmSynthetic @@ -202,14 +175,15 @@ class Timeout private constructor( .build() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ - override fun toString() = "Timeout{connect=$connect, read=$read, write=$write, request=$request}" + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 57ab7e19..6761ce6a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -18,8 +18,7 @@ internal fun List.toImmutable(): List = internal fun Map.toImmutable(): Map = if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) -@JvmSynthetic -internal fun immutableEmptyMap(): Map = Collections.emptyMap() +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() @JvmSynthetic internal fun , V> SortedMap.toImmutable(): SortedMap = @@ -29,26 +28,26 @@ internal fun , V> SortedMap.toImmutable(): SortedMap { } /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned - * by the API then this method will return an empty `Optional`, otherwise the - * returned `Optional` is given a `JsonValue`. + * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API + * then this method will return an empty `Optional`, otherwise the returned `Optional` is given + * a `JsonValue`. */ fun asUnknown(): Optional = when (this) { @@ -88,7 +88,8 @@ sealed class JsonField { try { JsonValue.from(it) } catch (e: IllegalArgumentException) { - // The known value is a list, but not all values are convertible to `JsonValue`. + // The known value is a list, but not all values are convertible to + // `JsonValue`. return Optional.empty() } } @@ -111,7 +112,8 @@ sealed class JsonField { try { JsonValue.from(value) } catch (e: IllegalArgumentException) { - // The known value is a map, but not all items are convertible to `JsonValue`. + // The known value is a map, but not all items are convertible + // to `JsonValue`. return Optional.empty() } @@ -147,8 +149,7 @@ sealed class JsonField { is JsonValue -> this } - @JvmSynthetic - fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) fun accept(visitor: Visitor): R = when (this) { @@ -156,13 +157,12 @@ sealed class JsonField { is JsonValue -> accept(visitor as JsonValue.Visitor) } - interface Visitor: JsonValue.Visitor { + interface Visitor : JsonValue.Visitor { fun visitKnown(value: T): R = visitDefault() } companion object { - @JvmStatic - fun of(value: T): JsonField = KnownValue.of(value) + @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) @JvmStatic fun ofNullable(value: T?): JsonField = @@ -173,8 +173,9 @@ sealed class JsonField { } /** - * This class is a Jackson filter that can be used to exclude missing properties from objects. This filter - * should not be used directly and should instead use the @ExcludeMissing annotation. + * This class is a Jackson filter that can be used to exclude missing properties from objects. + * This filter should not be used directly and should instead use the @ExcludeMissing + * annotation. */ class IsMissing { override fun equals(other: Any?): Boolean = other is JsonMissing @@ -199,11 +200,11 @@ sealed class JsonField { } @JsonDeserialize(using = JsonValue.Deserializer::class) -sealed class JsonValue: JsonField() { +sealed class JsonValue : JsonField() { - fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) - fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) fun accept(visitor: Visitor): R = when (this) { @@ -218,12 +219,19 @@ sealed class JsonValue: JsonField() { interface Visitor { fun visitNull(): R = visitDefault() + fun visitMissing(): R = visitDefault() + fun visitBoolean(value: Boolean): R = visitDefault() + fun visitNumber(value: Number): R = visitDefault() + fun visitString(value: String): R = visitDefault() + fun visitArray(values: List): R = visitDefault() + fun visitObject(values: Map): R = visitDefault() + fun visitDefault(): R { throw RuntimeException("Unexpected value") } @@ -249,8 +257,12 @@ sealed class JsonValue: JsonField() { BOOLEAN -> JsonBoolean.of(node.booleanValue()) NUMBER -> JsonNumber.of(node.numberValue()) STRING -> JsonString.of(node.textValue()) - ARRAY -> JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) - OBJECT -> JsonObject.of(node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap()) + ARRAY -> + JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) + OBJECT -> + JsonObject.of( + node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap() + ) BINARY, POJO, null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") @@ -297,11 +309,14 @@ class JsonMissing : JsonValue() { @JvmStatic fun of() = INSTANCE } - class Serializer: BaseSerializer(JsonMissing::class) { - override fun serialize(value: JsonMissing, generator: JsonGenerator, provider: SerializerProvider) { + class Serializer : BaseSerializer(JsonMissing::class) { + override fun serialize( + value: JsonMissing, + generator: JsonGenerator, + provider: SerializerProvider, + ) { throw RuntimeException("JsonMissing cannot be serialized") } - } } @@ -402,9 +417,7 @@ private constructor( override fun toString() = values.toString() companion object { - @JsonCreator - @JvmStatic - fun of(values: List) = JsonArray(values.toImmutable()) + @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) } } @@ -435,10 +448,7 @@ private constructor( } @JacksonAnnotationsInside -@JsonInclude( - JsonInclude.Include.CUSTOM, - valueFilter = JsonField.IsMissing::class, -) +@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) annotation class ExcludeMissing @JacksonAnnotationsInside @@ -447,7 +457,8 @@ annotation class ExcludeMissing isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE) + fieldVisibility = Visibility.NONE, +) annotation class NoAutoDetect class MultipartField @@ -498,7 +509,10 @@ private constructor( return MultipartField( value, contentType - ?: if (value is KnownValue && (value.value is InputStream || value.value is ByteArray)) + ?: if ( + value is KnownValue && + (value.value is InputStream || value.value is ByteArray) + ) "application/octet-stream" else "text/plain; charset=utf-8", filename, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt index 28b08bfe..12cfc384 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/ErrorHandler.kt @@ -2,20 +2,19 @@ package com.braintrustdata.api.core.handlers -import com.fasterxml.jackson.databind.json.JsonMapper import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BadRequestException +import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.errors.InternalServerException import com.braintrustdata.api.errors.NotFoundException import com.braintrustdata.api.errors.PermissionDeniedException import com.braintrustdata.api.errors.RateLimitException -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.errors.BraintrustException import com.braintrustdata.api.errors.UnauthorizedException import com.braintrustdata.api.errors.UnexpectedStatusCodeException import com.braintrustdata.api.errors.UnprocessableEntityException +import com.fasterxml.jackson.databind.json.JsonMapper import java.io.ByteArrayInputStream import java.io.InputStream diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt index 041ed543..ae855a7b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/handlers/JsonHandler.kt @@ -2,12 +2,11 @@ package com.braintrustdata.api.core.handlers -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.braintrustdata.api.core.enhanceJacksonException import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustException +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt index 5530338e..6d37e804 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/Headers.kt @@ -1,13 +1,12 @@ package com.braintrustdata.api.core.http import com.braintrustdata.api.core.toImmutable -import java.util.Collections import java.util.TreeMap class Headers private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() @@ -75,7 +74,7 @@ private constructor( values.toImmutable() } .toImmutable(), - size + size, ) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt index b797df53..5941bacd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt @@ -1,8 +1,8 @@ package com.braintrustdata.api.core.http +import com.braintrustdata.api.core.RequestOptions import java.lang.AutoCloseable import java.util.concurrent.CompletableFuture -import com.braintrustdata.api.core.RequestOptions interface HttpClient : AutoCloseable { @@ -11,8 +11,7 @@ interface HttpClient : AutoCloseable { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - fun execute(request: HttpRequest): HttpResponse = - execute(request, RequestOptions.none()) + fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) fun executeAsync( request: HttpRequest, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index 3ab2cb24..1105f7d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -51,129 +51,85 @@ private constructor( this.pathSegments.addAll(pathSegments) } - fun headers(headers: Headers) = - apply { - this.headers.clear() - putAllHeaders(headers) - } - - fun headers(headers: Map>) = - apply { - this.headers.clear() - putAllHeaders(headers) - } - - fun putHeader(name: String, value: String) = - apply { - headers.put(name, value) - } - - fun putHeaders(name: String, values: Iterable) = - apply { - headers.put(name, values) - } - - fun putAllHeaders(headers: Headers) = - apply { - this.headers.putAll(headers) - } - - fun putAllHeaders(headers: Map>) = - apply { - this.headers.putAll(headers) - } - - fun replaceHeaders(name: String, value: String) = - apply { - headers.replace(name, value) - } - - fun replaceHeaders(name: String, values: Iterable) = - apply { - headers.replace(name, values) - } - - fun replaceAllHeaders(headers: Headers) = - apply { - this.headers.replaceAll(headers) - } - - fun replaceAllHeaders(headers: Map>) = - apply { - this.headers.replaceAll(headers) - } - - fun removeHeaders(name: String) = - apply { - headers.remove(name) - } - - fun removeAllHeaders(names: Set) = - apply { - headers.removeAll(names) - } - - fun queryParams(queryParams: QueryParams) = - apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } - - fun queryParams(queryParams: Map>) = - apply { - this.queryParams.clear() - putAllQueryParams(queryParams) - } - - fun putQueryParam(key: String, value: String) = - apply { - queryParams.put(key, value) - } - - fun putQueryParams(key: String, values: Iterable) = - apply { - queryParams.put(key, values) - } - - fun putAllQueryParams(queryParams: QueryParams) = - apply { - this.queryParams.putAll(queryParams) - } - - fun putAllQueryParams(queryParams: Map>) = - apply { - this.queryParams.putAll(queryParams) - } - - fun replaceQueryParams(key: String, value: String) = - apply { - queryParams.replace(key, value) - } - - fun replaceQueryParams(key: String, values: Iterable) = - apply { - queryParams.replace(key, values) - } - - fun replaceAllQueryParams(queryParams: QueryParams) = - apply { - this.queryParams.replaceAll(queryParams) - } - - fun replaceAllQueryParams(queryParams: Map>) = - apply { - this.queryParams.replaceAll(queryParams) - } - - fun removeQueryParams(key: String) = - apply { - queryParams.remove(key) - } - - fun removeAllQueryParams(keys: Set) = - apply { - queryParams.removeAll(keys) - } + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + + fun putAllHeaders(headers: Map>) = apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } fun body(body: HttpRequestBody) = apply { this.body = body } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt index 125e268b..bb5b61ab 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBodies.kt @@ -67,7 +67,10 @@ internal fun multipartFormData( .build() } - private fun serializePart(name: String, node: JsonNode): Sequence> = + private fun serializePart( + name: String, + node: JsonNode, + ): Sequence> = when (node.nodeType) { JsonNodeType.MISSING, JsonNodeType.NULL -> emptySequence() @@ -108,7 +111,10 @@ internal fun multipartFormData( serializePart("$name[$key]", value) } JsonNodeType.POJO, - null -> throw BraintrustInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") + null -> + throw BraintrustInvalidDataException( + "Unexpected JsonNode type: ${node.nodeType}" + ) } private fun String.toInputStream(): InputStream = ByteArrayInputStream(toByteArray()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt index fae4bf81..ebf2b4d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt @@ -12,10 +12,11 @@ interface HttpRequestBody : AutoCloseable { fun contentLength(): Long /** - * Determines if a request can be repeated in a meaningful way, for example before doing a retry. + * Determines if a request can be repeated in a meaningful way, for example before doing a + * retry. * - * The most typical case when a request can't be retried is if the request body is being streamed. In this case the - * body data isn't available on subsequent attempts. + * The most typical case when a request can't be retried is if the request body is being + * streamed. In this case the body data isn't available on subsequent attempts. */ fun repeatable(): Boolean diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt index efd180a9..e766e040 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/PhantomReachableClosingHttpClient.kt @@ -19,7 +19,7 @@ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpCli override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture = httpClient.executeAsync(request, requestOptions) override fun close() = httpClient.close() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt index 2f2252b4..215eea16 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt @@ -5,7 +5,7 @@ import com.braintrustdata.api.core.toImmutable class QueryParams private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() @@ -69,10 +69,7 @@ private constructor( } fun build() = - QueryParams( - map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), - size - ) + QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size) } override fun hashCode(): Int = map.hashCode() diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 61d75ca3..56bdac87 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -1,8 +1,8 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.errors.BraintrustIoException import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.checkRequired +import com.braintrustdata.api.errors.BraintrustIoException import java.io.IOException import java.time.Clock import java.time.Duration @@ -22,16 +22,13 @@ import kotlin.math.pow class RetryingHttpClient private constructor( - private val httpClient: HttpClient, - private val clock: Clock, - private val maxRetries: Int, - private val idempotencyHeader: String?, + private val httpClient: HttpClient, + private val clock: Clock, + private val maxRetries: Int, + private val idempotencyHeader: String?, ) : HttpClient { - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) } @@ -50,21 +47,21 @@ private constructor( } val response = - try { - val response = httpClient.execute(modifiedRequest, requestOptions) - if (++retries > maxRetries || !shouldRetry(response)) { - return response - } - - response - } catch (throwable: Throwable) { - if (++retries > maxRetries || !shouldRetry(throwable)) { - throw throwable - } + try { + val response = httpClient.execute(modifiedRequest, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } - null + response + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable } + null + } + val backoffMillis = getRetryBackoffMillis(retries, response) // All responses must be closed, so close the failed one before retrying. response?.close() @@ -73,8 +70,8 @@ private constructor( } override fun executeAsync( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): CompletableFuture { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.executeAsync(request, requestOptions) @@ -89,42 +86,43 @@ private constructor( var retries = 0 fun executeWithRetries( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): CompletableFuture { val requestWithRetryCount = if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request - return httpClient.executeAsync(requestWithRetryCount, requestOptions) - .handleAsync( - fun( - response: HttpResponse?, - throwable: Throwable? - ): CompletableFuture { - if (response != null) { - if (++retries > maxRetries || !shouldRetry(response)) { - return CompletableFuture.completedFuture(response) - } - } else { - if (++retries > maxRetries || !shouldRetry(throwable!!)) { - val failedFuture = CompletableFuture() - failedFuture.completeExceptionally(throwable) - return failedFuture - } - } - - val backoffMillis = getRetryBackoffMillis(retries, response) - // All responses must be closed, so close the failed one before retrying. - response?.close() - return sleepAsync(backoffMillis.toMillis()).thenCompose { - executeWithRetries(requestWithRetryCount, requestOptions) - } - }, - ) { - // Run in the same thread. - it.run() + return httpClient + .executeAsync(requestWithRetryCount, requestOptions) + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable?, + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + return sleepAsync(backoffMillis.toMillis()).thenCompose { + executeWithRetries(requestWithRetryCount, requestOptions) + } } - .thenCompose(Function.identity()) + ) { + // Run in the same thread. + it.run() + } + .thenCompose(Function.identity()) } return executeWithRetries(modifiedRequest, requestOptions) @@ -184,30 +182,38 @@ private constructor( private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After - response?.headers()?.let { headers -> - headers.values("Retry-After-Ms").getOrNull(0)?.toFloatOrNull()?.times(TimeUnit.MILLISECONDS.toNanos(1)) + response + ?.headers() + ?.let { headers -> + headers + .values("Retry-After-Ms") + .getOrNull(0) + ?.toFloatOrNull() + ?.times(TimeUnit.MILLISECONDS.toNanos(1)) ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) - ?: try { - ChronoUnit.MILLIS.between( - OffsetDateTime.now(clock), - OffsetDateTime.parse( - retryAfter, - DateTimeFormatter.RFC_1123_DATE_TIME - ) - ) - } catch (e: DateTimeParseException) { - null - } + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME, + ), + ) + } catch (e: DateTimeParseException) { + null + } } - }?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter } - } + ?.let { retryAfterNanos -> + // If the API asks us to wait a certain amount of time (and it's a reasonable + // amount), just + // do what it says. + val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) + if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { + return retryAfter + } + } // Apply exponential backoff, but not more than the max. val backoffSeconds = min(0.5 * 2.0.pow(retries - 1), 8.0) @@ -225,18 +231,17 @@ private constructor( private fun sleepAsync(millis: Long): CompletableFuture { val future = CompletableFuture() TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + millis, ) return future } - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder internal constructor() { @@ -255,11 +260,11 @@ private constructor( fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } fun build(): HttpClient = - RetryingHttpClient( - checkRequired("httpClient", httpClient), - clock, - maxRetries, - idempotencyHeader, - ) + RetryingHttpClient( + checkRequired("httpClient", httpClient), + clock, + maxRetries, + idempotencyHeader, + ) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt index 83ec706e..b8c65254 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class BadRequestException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(400, headers, body, error) +class BadRequestException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(400, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index d2e399b6..afcc62d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -13,9 +13,14 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects @NoAutoDetect -class BraintrustError @JsonCreator private constructor( - @JsonAnyGetter @ExcludeMissing @JsonAnySetter @get:JvmName("additionalProperties") val additionalProperties: Map = immutableEmptyMap(), - +class BraintrustError +@JsonCreator +private constructor( + @JsonAnyGetter + @ExcludeMissing + @JsonAnySetter + @get:JvmName("additionalProperties") + val additionalProperties: Map = immutableEmptyMap() ) { fun toBuilder() = Builder().from(this) @@ -23,8 +28,7 @@ class BraintrustError @JsonCreator private constructor( companion object { /** Returns a mutable builder for constructing an instance of [BraintrustError]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [BraintrustError]. */ @@ -33,46 +37,38 @@ class BraintrustError @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(braintrustError: BraintrustError) = - apply { - additionalProperties = braintrustError.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(braintrustError: BraintrustError) = apply { + additionalProperties = braintrustError.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): BraintrustError = BraintrustError(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BraintrustError && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt index 78a326db..d1fdfdee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt @@ -2,4 +2,5 @@ package com.braintrustdata.api.errors class BraintrustInvalidDataException @JvmOverloads -constructor(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) +constructor(message: String? = null, cause: Throwable? = null) : + BraintrustException(message, cause) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt index b7e0d934..6fb793a1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt @@ -2,4 +2,5 @@ package com.braintrustdata.api.errors class BraintrustIoException @JvmOverloads -constructor(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) +constructor(message: String? = null, cause: Throwable? = null) : + BraintrustException(message, cause) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt index fb883c12..728ac6bd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt @@ -5,12 +5,12 @@ import com.braintrustdata.api.core.http.Headers abstract class BraintrustServiceException @JvmOverloads constructor( - private val statusCode: Int, - private val headers: Headers, - private val body: String, - private val error: BraintrustError, - message: String = "$statusCode: $error", - cause: Throwable? = null + private val statusCode: Int, + private val headers: Headers, + private val body: String, + private val error: BraintrustError, + message: String = "$statusCode: $error", + cause: Throwable? = null, ) : BraintrustException(message, cause) { fun statusCode(): Int = statusCode diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt index b2eadeb8..36cc4432 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt @@ -3,8 +3,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers class InternalServerException( - statusCode: Int, - headers: Headers, - body: String, - error: BraintrustError, + statusCode: Int, + headers: Headers, + body: String, + error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt index cd43aa64..ecc1a307 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class NotFoundException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(404, headers, body, error) +class NotFoundException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(404, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt index 72fb9d36..27380e3e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class PermissionDeniedException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(403, headers, body, error) +class PermissionDeniedException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(403, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt index be083e9c..a9352a3a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class RateLimitException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(429, headers, body, error) +class RateLimitException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(429, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt index d5541528..57f9242f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class UnauthorizedException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(401, headers, body, error) +class UnauthorizedException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(401, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt index c460ecad..7aa10d9b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt @@ -3,8 +3,8 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers class UnexpectedStatusCodeException( - statusCode: Int, - headers: Headers, - body: String, - error: BraintrustError, + statusCode: Int, + headers: Headers, + body: String, + error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt index b3d59795..6e216b4e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt @@ -2,8 +2,5 @@ package com.braintrustdata.api.errors import com.braintrustdata.api.core.http.Headers -class UnprocessableEntityException( - headers: Headers, - body: String, - error: BraintrustError, -) : BraintrustServiceException(422, headers, body, error) +class UnprocessableEntityException(headers: Headers, body: String, error: BraintrustError) : + BraintrustServiceException(422, headers, body, error) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index 7da801b6..baafa57f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -20,16 +20,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class AISecret @JsonCreator private constructor( +class AISecret +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("preview_secret") @ExcludeMissing private val previewSecret: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("preview_secret") + @ExcludeMissing + private val previewSecret: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the AI secret */ @@ -46,41 +53,30 @@ class AISecret @JsonCreator private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - fun previewSecret(): Optional = Optional.ofNullable(previewSecret.getNullable("preview_secret")) + fun previewSecret(): Optional = + Optional.ofNullable(previewSecret.getNullable("preview_secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Unique identifier for the AI secret */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the AI secret */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Date of AI secret creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("preview_secret") @ExcludeMissing fun _previewSecret(): JsonField = previewSecret - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -88,22 +84,21 @@ class AISecret @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): AISecret = - apply { - if (validated) { - return@apply - } - - id() - name() - orgId() - created() - metadata().ifPresent { it.validate() } - previewSecret() - type() - validated = true + fun validate(): AISecret = apply { + if (validated) { + return@apply } + id() + name() + orgId() + created() + metadata().ifPresent { it.validate() } + previewSecret() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -112,15 +107,13 @@ class AISecret @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [AISecret]. * * The following fields are required: - * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AISecret]. */ @@ -136,44 +129,34 @@ class AISecret @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecret: AISecret) = - apply { - id = aiSecret.id - name = aiSecret.name - orgId = aiSecret.orgId - created = aiSecret.created - metadata = aiSecret.metadata - previewSecret = aiSecret.previewSecret - type = aiSecret.type - additionalProperties = aiSecret.additionalProperties.toMutableMap() - } + internal fun from(aiSecret: AISecret) = apply { + id = aiSecret.id + name = aiSecret.name + orgId = aiSecret.orgId + created = aiSecret.created + metadata = aiSecret.metadata + previewSecret = aiSecret.previewSecret + type = aiSecret.type + additionalProperties = aiSecret.additionalProperties.toMutableMap() + } /** Unique identifier for the AI secret */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the AI secret */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Date of AI secret creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -182,87 +165,68 @@ class AISecret @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of AI secret creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun previewSecret(previewSecret: String?) = previewSecret(JsonField.ofNullable(previewSecret)) + fun previewSecret(previewSecret: String?) = + previewSecret(JsonField.ofNullable(previewSecret)) - fun previewSecret(previewSecret: Optional) = previewSecret(previewSecret.getOrNull()) + fun previewSecret(previewSecret: Optional) = + previewSecret(previewSecret.getOrNull()) - fun previewSecret(previewSecret: JsonField) = - apply { - this.previewSecret = previewSecret - } + fun previewSecret(previewSecret: JsonField) = apply { + this.previewSecret = previewSecret + } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AISecret = AISecret( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "orgId", orgId - ), - created, - metadata, - previewSecret, - type, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("orgId", orgId), + created, + metadata, + previewSecret, + type, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -271,22 +235,20 @@ class AISecret @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -295,46 +257,38 @@ class AISecret @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -347,11 +301,11 @@ class AISecret @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -360,5 +314,6 @@ class AISecret @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" } 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 0eb35bf2..f408b1d3 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 @@ -22,31 +22,48 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on + * a project, they will also have read permissions on any experiment, dataset, etc. created within + * that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ @NoAutoDetect -class Acl @JsonCreator private constructor( +class Acl +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_object_org_id") @ExcludeMissing private val _objectOrgId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("_object_org_id") + @ExcludeMissing + private val _objectOrgId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the acl */ @@ -65,39 +82,31 @@ class Acl @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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 = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 - */ + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the acl */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The organization the ACL's referred object belongs to */ @JsonProperty("_object_org_id") @@ -105,9 +114,7 @@ class Acl @JsonCreator private constructor( fun __objectOrgId(): JsonField = _objectOrgId /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -115,49 +122,33 @@ class Acl @JsonCreator private constructor( fun _objectType(): JsonField = objectType /** Date of acl creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ - @JsonProperty("group_id") - @ExcludeMissing - fun _groupId(): JsonField = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing 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 + /** 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 /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -165,25 +156,24 @@ class Acl @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Acl = - apply { - if (validated) { - return@apply - } - - id() - _objectOrgId() - objectId() - objectType() - created() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true + fun validate(): Acl = apply { + if (validated) { + return@apply } + id() + _objectOrgId() + objectId() + objectType() + created() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -192,7 +182,6 @@ class Acl @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Acl]. * * The following fields are required: - * * ```java * .id() * ._objectOrgId() @@ -200,8 +189,7 @@ class Acl @JsonCreator private constructor( * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Acl]. */ @@ -220,56 +208,45 @@ class Acl @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(acl: Acl) = - apply { - id = acl.id - _objectOrgId = acl._objectOrgId - objectId = acl.objectId - objectType = acl.objectType - created = acl.created - groupId = acl.groupId - permission = acl.permission - restrictObjectType = acl.restrictObjectType - roleId = acl.roleId - userId = acl.userId - additionalProperties = acl.additionalProperties.toMutableMap() - } + internal fun from(acl: Acl) = apply { + id = acl.id + _objectOrgId = acl._objectOrgId + objectId = acl.objectId + objectType = acl.objectType + created = acl.created + groupId = acl.groupId + permission = acl.permission + restrictObjectType = acl.restrictObjectType + roleId = acl.roleId + userId = acl.userId + additionalProperties = acl.additionalProperties.toMutableMap() + } /** Unique identifier for the acl */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the acl */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** The organization the ACL's referred object belongs to */ fun _objectOrgId(_objectOrgId: String) = _objectOrgId(JsonField.of(_objectOrgId)) /** The organization the ACL's referred object belongs to */ - fun _objectOrgId(_objectOrgId: JsonField) = - apply { - this._objectOrgId = _objectOrgId - } + fun _objectOrgId(_objectOrgId: JsonField) = apply { + this._objectOrgId = _objectOrgId + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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)) @@ -278,182 +255,137 @@ class Acl @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of acl creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - fun groupId(groupId: JsonField) = - apply { - this.groupId = groupId - } - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: JsonField) = apply { this.permission = permission } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + 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`. + * 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) = restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: JsonField) = - apply { - this.roleId = roleId - } + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Acl = Acl( - checkRequired( - "id", id - ), - checkRequired( - "_objectOrgId", _objectOrgId - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - created, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_objectOrgId", _objectOrgId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + created, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -501,11 +433,9 @@ class Acl @JsonCreator private constructor( * 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 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 { @@ -521,18 +451,17 @@ class Acl @JsonCreator private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -553,11 +482,11 @@ class Acl @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -578,20 +507,23 @@ class Acl @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -599,25 +531,18 @@ class Acl @JsonCreator private constructor( 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 { + /** 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -656,11 +581,9 @@ class Acl @JsonCreator private constructor( * 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 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 { @@ -673,18 +596,17 @@ class Acl @JsonCreator private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -702,11 +624,11 @@ class Acl @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -724,20 +646,23 @@ class Acl @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -746,24 +671,22 @@ class Acl @JsonCreator 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -808,16 +731,12 @@ class Acl @JsonCreator private constructor( } /** - * 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. + * 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 { @@ -833,18 +752,18 @@ class Acl @JsonCreator private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an - * unknown value. + * 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. + * 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. + * 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) { @@ -865,11 +784,11 @@ class Acl @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -890,20 +809,23 @@ class Acl @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -912,11 +834,11 @@ class Acl @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Acl && id == other.id && _objectOrgId == other._objectOrgId && objectId == other.objectId && objectType == other.objectType && created == other.created && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Acl && id == other.id && _objectOrgId == other._objectOrgId && objectId == other.objectId && objectType == other.objectType && created == other.created && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -925,5 +847,6 @@ class Acl @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Acl{id=$id, _objectOrgId=$_objectOrgId, objectId=$objectId, objectType=$objectType, created=$created, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "Acl{id=$id, _objectOrgId=$_objectOrgId, objectId=$objectId, objectType=$objectType, created=$created, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } 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 bf9e92e9..c7232bb9 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 @@ -25,70 +25,61 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Batch update acls. This operation is idempotent, so adding acls which already - * exist will have no effect, and removing acls which do not exist will have no - * effect. + * Batch update acls. This operation is idempotent, so adding acls which already exist will have no + * effect, and removing acls which do not exist will have no effect. */ -class AclBatchUpdateParams private constructor( +class AclBatchUpdateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ fun addAcls(): Optional> = body.addAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ fun removeAcls(): Optional> = body.removeAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ fun _addAcls(): JsonField> = body._addAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ fun _removeAcls(): JsonField> = body._removeAcls() @@ -98,76 +89,72 @@ class AclBatchUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("add_acls") @ExcludeMissing private val addAcls: JsonField> = JsonMissing.of(), - @JsonProperty("remove_acls") @ExcludeMissing private val removeAcls: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("add_acls") + @ExcludeMissing + private val addAcls: JsonField> = JsonMissing.of(), + @JsonProperty("remove_acls") + @ExcludeMissing + private val removeAcls: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ fun addAcls(): Optional> = Optional.ofNullable(addAcls.getNullable("add_acls")) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun removeAcls(): Optional> = Optional.ofNullable(removeAcls.getNullable("remove_acls")) + fun removeAcls(): Optional> = + Optional.ofNullable(removeAcls.getNullable("remove_acls")) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - @JsonProperty("add_acls") - @ExcludeMissing - fun _addAcls(): JsonField> = addAcls + @JsonProperty("add_acls") @ExcludeMissing fun _addAcls(): JsonField> = addAcls /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ @JsonProperty("remove_acls") @ExcludeMissing @@ -179,24 +166,22 @@ class AclBatchUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - addAcls().ifPresent { it.forEach { it.validate() } } - removeAcls().ifPresent { it.forEach { it.validate() } } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + addAcls().ifPresent { it.forEach { it.validate() } } + removeAcls().ifPresent { it.forEach { it.validate() } } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -207,181 +192,165 @@ class AclBatchUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - addAcls = body.addAcls.map { it.toMutableList() } - removeAcls = body.removeAcls.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + addAcls = body.addAcls.map { it.toMutableList() } + removeAcls = body.removeAcls.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. */ fun addAcls(addAcls: List?) = addAcls(JsonField.ofNullable(addAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. */ fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. */ - fun addAcls(addAcls: JsonField>) = - apply { - this.addAcls = addAcls.map { it.toMutableList() } - } + fun addAcls(addAcls: JsonField>) = apply { + this.addAcls = addAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. */ - fun addAddAcl(addAcl: AddAcl) = - apply { - addAcls = (addAcls ?: JsonField.of(mutableListOf())).also { + fun addAddAcl(addAcl: AddAcl) = apply { + addAcls = + (addAcls ?: JsonField.of(mutableListOf())).also { checkKnown("addAcls", it).add(addAcl) } - } + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. */ - fun removeAcls(removeAcls: List?) = removeAcls(JsonField.ofNullable(removeAcls)) + fun removeAcls(removeAcls: List?) = + removeAcls(JsonField.ofNullable(removeAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. */ - fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) + fun removeAcls(removeAcls: Optional>) = + removeAcls(removeAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. */ - fun removeAcls(removeAcls: JsonField>) = - apply { - this.removeAcls = removeAcls.map { it.toMutableList() } - } + fun removeAcls(removeAcls: JsonField>) = apply { + this.removeAcls = removeAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. */ - fun addRemoveAcl(removeAcl: RemoveAcl) = - apply { - removeAcls = (removeAcls ?: JsonField.of(mutableListOf())).also { + fun addRemoveAcl(removeAcl: RemoveAcl) = apply { + removeAcls = + (removeAcls ?: JsonField.of(mutableListOf())).also { checkKnown("removeAcls", it).add(removeAcl) } - } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, - (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, + (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -390,22 +359,18 @@ class AclBatchUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): AclBatchUpdateParams = builder().build() + @JvmStatic fun none(): AclBatchUpdateParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of - * [AclBatchUpdateParams]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [AclBatchUpdateParams]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [AclBatchUpdateParams]. */ @@ -417,325 +382,272 @@ class AclBatchUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = - apply { - body = aclBatchUpdateParams.body.toBuilder() - additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { + body = aclBatchUpdateParams.body.toBuilder() + additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun addAcls(addAcls: List?) = - apply { - body.addAcls(addAcls) - } + fun addAcls(addAcls: List?) = apply { body.addAcls(addAcls) } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun addAcls(addAcls: JsonField>) = - apply { - body.addAcls(addAcls) - } + fun addAcls(addAcls: JsonField>) = apply { body.addAcls(addAcls) } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun addAddAcl(addAcl: AddAcl) = - apply { - body.addAddAcl(addAcl) - } + fun addAddAcl(addAcl: AddAcl) = apply { body.addAddAcl(addAcl) } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun removeAcls(removeAcls: List?) = - apply { - body.removeAcls(removeAcls) - } + fun removeAcls(removeAcls: List?) = apply { body.removeAcls(removeAcls) } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun removeAcls(removeAcls: JsonField>) = - apply { - body.removeAcls(removeAcls) - } + fun removeAcls(removeAcls: JsonField>) = apply { + body.removeAcls(removeAcls) + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun addRemoveAcl(removeAcl: RemoveAcl) = - apply { - body.addRemoveAcl(removeAcl) - } + fun addRemoveAcl(removeAcl: RemoveAcl) = apply { body.addRemoveAcl(removeAcl) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclBatchUpdateParams = AclBatchUpdateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ @NoAutoDetect - class AddAcl @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class AddAcl + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the ACL applies to */ @@ -745,39 +657,35 @@ class AclBatchUpdateParams private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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 = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -785,44 +693,34 @@ class AclBatchUpdateParams private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - @JsonProperty("group_id") - @ExcludeMissing - fun _groupId(): JsonField = groupId - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * 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 + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -830,22 +728,21 @@ class AclBatchUpdateParams private constructor( private var validated: Boolean = false - fun validate(): AddAcl = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true + fun validate(): AddAcl = apply { + if (validated) { + return@apply } + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -854,14 +751,12 @@ class AclBatchUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [AddAcl]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AddAcl]. */ @@ -877,98 +772,87 @@ class AclBatchUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addAcl: AddAcl) = - apply { - objectId = addAcl.objectId - objectType = addAcl.objectType - groupId = addAcl.groupId - permission = addAcl.permission - restrictObjectType = addAcl.restrictObjectType - roleId = addAcl.roleId - userId = addAcl.userId - additionalProperties = addAcl.additionalProperties.toMutableMap() - } + internal fun from(addAcl: AddAcl) = apply { + objectId = addAcl.objectId + objectType = addAcl.objectType + groupId = addAcl.groupId + permission = addAcl.permission + restrictObjectType = addAcl.restrictObjectType + roleId = addAcl.roleId + userId = addAcl.userId + additionalProperties = addAcl.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun groupId(groupId: JsonField) = - apply { - this.groupId = groupId - } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + 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`. + * 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) = restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -986,91 +870,71 @@ class AclBatchUpdateParams private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = - apply { - this.roleId = roleId - } + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AddAcl = AddAcl( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1118,11 +982,9 @@ class AclBatchUpdateParams private constructor( * 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 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 { @@ -1148,8 +1010,8 @@ class AclBatchUpdateParams private constructor( * 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. + * 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) { @@ -1174,7 +1036,7 @@ class AclBatchUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1198,17 +1060,20 @@ class AclBatchUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1216,25 +1081,19 @@ class AclBatchUpdateParams private constructor( 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 { + /** 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1273,11 +1132,9 @@ class AclBatchUpdateParams private constructor( * 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 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 { @@ -1300,8 +1157,8 @@ class AclBatchUpdateParams private constructor( * 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. + * 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) { @@ -1323,7 +1180,7 @@ class AclBatchUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1344,17 +1201,20 @@ class AclBatchUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1363,24 +1223,22 @@ class AclBatchUpdateParams 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1430,11 +1288,9 @@ class AclBatchUpdateParams private constructor( * * 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 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 { @@ -1460,8 +1316,8 @@ class AclBatchUpdateParams private constructor( * 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. + * 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) { @@ -1486,7 +1342,7 @@ class AclBatchUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1501,7 +1357,8 @@ class AclBatchUpdateParams private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1510,17 +1367,20 @@ class AclBatchUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1529,11 +1389,11 @@ class AclBatchUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1542,32 +1402,47 @@ class AclBatchUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ @NoAutoDetect - class RemoveAcl @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RemoveAcl + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the ACL applies to */ @@ -1577,39 +1452,35 @@ class AclBatchUpdateParams private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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 = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -1617,44 +1488,34 @@ class AclBatchUpdateParams private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - @JsonProperty("group_id") - @ExcludeMissing - fun _groupId(): JsonField = groupId - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * 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 + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -1662,22 +1523,21 @@ class AclBatchUpdateParams private constructor( private var validated: Boolean = false - fun validate(): RemoveAcl = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true + fun validate(): RemoveAcl = apply { + if (validated) { + return@apply } + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1686,14 +1546,12 @@ class AclBatchUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [RemoveAcl]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RemoveAcl]. */ @@ -1709,98 +1567,87 @@ class AclBatchUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeAcl: RemoveAcl) = - apply { - objectId = removeAcl.objectId - objectType = removeAcl.objectType - groupId = removeAcl.groupId - permission = removeAcl.permission - restrictObjectType = removeAcl.restrictObjectType - roleId = removeAcl.roleId - userId = removeAcl.userId - additionalProperties = removeAcl.additionalProperties.toMutableMap() - } + internal fun from(removeAcl: RemoveAcl) = apply { + objectId = removeAcl.objectId + objectType = removeAcl.objectType + groupId = removeAcl.groupId + permission = removeAcl.permission + restrictObjectType = removeAcl.restrictObjectType + roleId = removeAcl.roleId + userId = removeAcl.userId + additionalProperties = removeAcl.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun groupId(groupId: JsonField) = - apply { - this.groupId = groupId - } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + 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`. + * 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) = restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -1818,91 +1665,71 @@ class AclBatchUpdateParams private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = - apply { - this.roleId = roleId - } + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveAcl = RemoveAcl( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1950,11 +1777,9 @@ class AclBatchUpdateParams private constructor( * 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 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 { @@ -1980,8 +1805,8 @@ class AclBatchUpdateParams private constructor( * 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. + * 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) { @@ -2006,7 +1831,7 @@ class AclBatchUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2030,17 +1855,20 @@ class AclBatchUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2048,25 +1876,19 @@ class AclBatchUpdateParams private constructor( 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 { + /** 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2105,11 +1927,9 @@ class AclBatchUpdateParams private constructor( * 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 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 { @@ -2132,8 +1952,8 @@ class AclBatchUpdateParams private constructor( * 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. + * 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) { @@ -2155,7 +1975,7 @@ class AclBatchUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2176,17 +1996,20 @@ class AclBatchUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2195,24 +2018,22 @@ class AclBatchUpdateParams 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2262,11 +2083,9 @@ class AclBatchUpdateParams private constructor( * * 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 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 { @@ -2292,8 +2111,8 @@ class AclBatchUpdateParams private constructor( * 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. + * 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) { @@ -2318,7 +2137,7 @@ class AclBatchUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2333,7 +2152,8 @@ class AclBatchUpdateParams private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -2342,17 +2162,20 @@ class AclBatchUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2361,11 +2184,11 @@ class AclBatchUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2374,18 +2197,20 @@ class AclBatchUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index 6c708b70..eec25147 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -18,68 +18,63 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class AclBatchUpdateResponse @JsonCreator private constructor( - @JsonProperty("added_acls") @ExcludeMissing private val addedAcls: JsonField> = JsonMissing.of(), - @JsonProperty("removed_acls") @ExcludeMissing private val removedAcls: JsonField> = JsonMissing.of(), +class AclBatchUpdateResponse +@JsonCreator +private constructor( + @JsonProperty("added_acls") + @ExcludeMissing + private val addedAcls: JsonField> = JsonMissing.of(), + @JsonProperty("removed_acls") + @ExcludeMissing + private val removedAcls: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ fun addedAcls(): List = addedAcls.getRequired("added_acls") /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ fun removedAcls(): List = removedAcls.getRequired("removed_acls") /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ - @JsonProperty("added_acls") - @ExcludeMissing - fun _addedAcls(): JsonField> = addedAcls + @JsonProperty("added_acls") @ExcludeMissing fun _addedAcls(): JsonField> = addedAcls /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ @JsonProperty("removed_acls") @ExcludeMissing @@ -91,34 +86,30 @@ class AclBatchUpdateResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): AclBatchUpdateResponse = - apply { - if (validated) { - return@apply - } - - addedAcls().forEach { it.validate() } - removedAcls().forEach { it.validate() } - validated = true + fun validate(): AclBatchUpdateResponse = apply { + if (validated) { + return@apply } + addedAcls().forEach { it.validate() } + removedAcls().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [AclBatchUpdateResponse]. + * Returns a mutable builder for constructing an instance of [AclBatchUpdateResponse]. * * The following fields are required: - * * ```java * .addedAcls() * .removedAcls() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AclBatchUpdateResponse]. */ @@ -129,157 +120,131 @@ class AclBatchUpdateResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclBatchUpdateResponse: AclBatchUpdateResponse) = - apply { - addedAcls = aclBatchUpdateResponse.addedAcls.map { it.toMutableList() } - removedAcls = aclBatchUpdateResponse.removedAcls.map { it.toMutableList() } - additionalProperties = aclBatchUpdateResponse.additionalProperties.toMutableMap() - } + internal fun from(aclBatchUpdateResponse: AclBatchUpdateResponse) = apply { + addedAcls = aclBatchUpdateResponse.addedAcls.map { it.toMutableList() } + removedAcls = aclBatchUpdateResponse.removedAcls.map { it.toMutableList() } + additionalProperties = aclBatchUpdateResponse.additionalProperties.toMutableMap() + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ fun addedAcls(addedAcls: List) = addedAcls(JsonField.of(addedAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun addedAcls(addedAcls: JsonField>) = - apply { - this.addedAcls = addedAcls.map { it.toMutableList() } - } + fun addedAcls(addedAcls: JsonField>) = apply { + this.addedAcls = addedAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun addAddedAcl(addedAcl: Acl) = - apply { - addedAcls = (addedAcls ?: JsonField.of(mutableListOf())).also { + fun addAddedAcl(addedAcl: Acl) = apply { + addedAcls = + (addedAcls ?: JsonField.of(mutableListOf())).also { checkKnown("addedAcls", it).add(addedAcl) } - } + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ fun removedAcls(removedAcls: List) = removedAcls(JsonField.of(removedAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun removedAcls(removedAcls: JsonField>) = - apply { - this.removedAcls = removedAcls.map { it.toMutableList() } - } + fun removedAcls(removedAcls: JsonField>) = apply { + this.removedAcls = removedAcls.map { it.toMutableList() } + } /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. */ - fun addRemovedAcl(removedAcl: Acl) = - apply { - removedAcls = (removedAcls ?: JsonField.of(mutableListOf())).also { + fun addRemovedAcl(removedAcl: Acl) = apply { + removedAcls = + (removedAcls ?: JsonField.of(mutableListOf())).also { checkKnown("removedAcls", it).add(removedAcl) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AclBatchUpdateResponse = AclBatchUpdateResponse( - checkRequired( - "addedAcls", addedAcls - ).map { it.toImmutable() }, - checkRequired( - "removedAcls", removedAcls - ).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("addedAcls", addedAcls).map { it.toImmutable() }, + checkRequired("removedAcls", removedAcls).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclBatchUpdateResponse && addedAcls == other.addedAcls && removedAcls == other.removedAcls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AclBatchUpdateResponse && addedAcls == other.addedAcls && removedAcls == other.removedAcls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -288,5 +253,6 @@ class AclBatchUpdateResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" + override fun toString() = + "AclBatchUpdateResponse{addedAcls=$addedAcls, removedAcls=$removedAcls, additionalProperties=$additionalProperties}" } 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 5cb6f558..58566fc6 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 @@ -24,14 +24,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new acl. If there is an existing acl with the same contents as the one - * specified in the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one specified in the + * request, will return the existing acl unmodified */ -class AclCreateParams private constructor( +class AclCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** The id of the object the ACL applies to */ @@ -41,32 +41,24 @@ class AclCreateParams private constructor( fun objectType(): ObjectType = body.objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun groupId(): Optional = body.groupId() - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(): Optional = body.permission() /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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() - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = body.roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun userId(): Optional = body.userId() @@ -77,32 +69,24 @@ class AclCreateParams private constructor( fun _objectType(): JsonField = body._objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun _groupId(): JsonField = body._groupId() - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun _permission(): JsonField = body._permission() /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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() - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun _roleId(): JsonField = body._roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun _userId(): JsonField = body._userId() @@ -112,36 +96,49 @@ class AclCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the ACL applies to */ @@ -151,39 +148,35 @@ class AclCreateParams private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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 = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -191,44 +184,34 @@ class AclCreateParams private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - @JsonProperty("group_id") - @ExcludeMissing - fun _groupId(): JsonField = groupId - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * 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 + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -236,22 +219,21 @@ class AclCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -260,14 +242,12 @@ class AclCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -283,98 +263,87 @@ class AclCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - objectId = body.objectId - objectType = body.objectType - groupId = body.groupId - permission = body.permission - restrictObjectType = body.restrictObjectType - roleId = body.roleId - userId = body.userId - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + objectId = body.objectId + objectType = body.objectType + groupId = body.groupId + permission = body.permission + restrictObjectType = body.restrictObjectType + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun groupId(groupId: JsonField) = - apply { - this.groupId = groupId - } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + 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`. + * 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) = restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -392,81 +361,64 @@ class AclCreateParams private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = - apply { - this.roleId = roleId - } + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -475,7 +427,8 @@ class AclCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -486,14 +439,12 @@ class AclCreateParams private constructor( * Returns a mutable builder for constructing an instance of [AclCreateParams]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AclCreateParams]. */ @@ -505,332 +456,240 @@ class AclCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclCreateParams: AclCreateParams) = - apply { - body = aclCreateParams.body.toBuilder() - additionalHeaders = aclCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = aclCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(aclCreateParams: AclCreateParams) = apply { + body = aclCreateParams.body.toBuilder() + additionalHeaders = aclCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclCreateParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: String) = apply { body.objectId(objectId) } /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = - apply { - body.objectId(objectId) - } + 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: ObjectType) = 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 provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun groupId(groupId: String?) = - apply { - body.groupId(groupId) - } + fun groupId(groupId: String?) = apply { body.groupId(groupId) } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - fun groupId(groupId: JsonField) = - apply { - body.groupId(groupId) - } - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun permission(permission: Permission?) = - apply { - body.permission(permission) - } + fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: Permission?) = apply { body.permission(permission) } + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(permission: JsonField) = - apply { - body.permission(permission) - } + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: JsonField) = apply { body.permission(permission) } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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 { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = apply { + body.restrictObjectType(restrictObjectType) + } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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) = restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + body.restrictObjectType(restrictObjectType) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: String?) = - apply { - body.roleId(roleId) - } + fun roleId(roleId: String?) = apply { body.roleId(roleId) } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: JsonField) = - apply { - body.roleId(roleId) - } + fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: String?) = - apply { - body.userId(userId) - } + fun userId(userId: String?) = apply { body.userId(userId) } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: JsonField) = - apply { - body.userId(userId) - } + fun userId(userId: JsonField) = apply { body.userId(userId) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclCreateParams = - AclCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -878,11 +737,9 @@ class AclCreateParams private constructor( * 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 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 { @@ -898,18 +755,17 @@ class AclCreateParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -930,11 +786,11 @@ class AclCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -955,20 +811,23 @@ class AclCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -976,25 +835,18 @@ class AclCreateParams private constructor( 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 { + /** 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1033,11 +885,9 @@ class AclCreateParams private constructor( * 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 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 { @@ -1050,18 +900,17 @@ class AclCreateParams private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -1079,11 +928,11 @@ class AclCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -1101,20 +950,23 @@ class AclCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1123,24 +975,22 @@ class AclCreateParams 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1185,16 +1035,12 @@ class AclCreateParams private constructor( } /** - * 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. + * 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 { @@ -1210,18 +1056,18 @@ class AclCreateParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an - * unknown value. + * 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. + * 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. + * 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) { @@ -1242,11 +1088,11 @@ class AclCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -1267,20 +1113,23 @@ class AclCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1289,14 +1138,15 @@ class AclCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AclCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AclCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 91337103..53bbe12f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an acl object by its id */ -class AclDeleteParams private constructor( +class AclDeleteParams +private constructor( private val aclId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Acl id */ @@ -31,17 +31,18 @@ class AclDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -52,13 +53,11 @@ class AclDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [AclDeleteParams]. * * The following fields are required: - * * ```java * .aclId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AclDeleteParams]. */ @@ -71,190 +70,155 @@ class AclDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aclDeleteParams: AclDeleteParams) = - apply { - aclId = aclDeleteParams.aclId - additionalHeaders = aclDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aclDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aclDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(aclDeleteParams: AclDeleteParams) = apply { + aclId = aclDeleteParams.aclId + additionalHeaders = aclDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aclDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aclDeleteParams.additionalBodyProperties.toMutableMap() + } /** Acl id */ - fun aclId(aclId: String) = - apply { - this.aclId = aclId - } + fun aclId(aclId: String) = apply { this.aclId = aclId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): AclDeleteParams = AclDeleteParams( - checkRequired( - "aclId", aclId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("aclId", aclId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AclDeleteParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "AclDeleteParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 7281b052..43a401e5 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 @@ -24,11 +24,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Delete a single acl */ -class AclFindAndDeleteParams private constructor( +class AclFindAndDeleteParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** The id of the object the ACL applies to */ @@ -38,32 +38,24 @@ class AclFindAndDeleteParams private constructor( fun objectType(): ObjectType = body.objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun groupId(): Optional = body.groupId() - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(): Optional = body.permission() /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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() - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = body.roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun userId(): Optional = body.userId() @@ -74,32 +66,24 @@ class AclFindAndDeleteParams private constructor( fun _objectType(): JsonField = body._objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun _groupId(): JsonField = body._groupId() - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun _permission(): JsonField = body._permission() /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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() - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun _roleId(): JsonField = body._roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided */ fun _userId(): JsonField = body._userId() @@ -109,36 +93,49 @@ class AclFindAndDeleteParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams /** - * An ACL grants a certain permission or role to a certain user or group on an - * object. + * An ACL grants a certain permission or role to a certain user or group on an object. * - * ACLs are inherited across the object hierarchy. So for example, if a user has - * read permissions on a project, they will also have read permissions on any - * experiment, dataset, etc. created within that project. + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as - * part of a role. + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. */ @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") @ExcludeMissing private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the ACL applies to */ @@ -148,39 +145,35 @@ class AclFindAndDeleteParams private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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 = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + 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 + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -188,44 +181,34 @@ class AclFindAndDeleteParams private constructor( fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - @JsonProperty("group_id") - @ExcludeMissing - fun _groupId(): JsonField = groupId - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * 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 + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -233,22 +216,21 @@ class AclFindAndDeleteParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -257,14 +239,12 @@ class AclFindAndDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -280,98 +260,87 @@ class AclFindAndDeleteParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - objectId = body.objectId - objectType = body.objectType - groupId = body.groupId - permission = body.permission - restrictObjectType = body.restrictObjectType - roleId = body.roleId - userId = body.userId - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + objectId = body.objectId + objectType = body.objectType + groupId = body.groupId + permission = body.permission + restrictObjectType = body.restrictObjectType + roleId = body.roleId + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun groupId(groupId: JsonField) = - apply { - this.groupId = groupId - } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + 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`. + * 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) = restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } /** * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be @@ -389,81 +358,64 @@ class AclFindAndDeleteParams private constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - fun roleId(roleId: JsonField) = - apply { - this.roleId = roleId - } + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -472,7 +424,8 @@ class AclFindAndDeleteParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -480,18 +433,15 @@ class AclFindAndDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AclFindAndDeleteParams]. + * Returns a mutable builder for constructing an instance of [AclFindAndDeleteParams]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AclFindAndDeleteParams]. */ @@ -503,332 +453,244 @@ class AclFindAndDeleteParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclFindAndDeleteParams: AclFindAndDeleteParams) = - apply { - body = aclFindAndDeleteParams.body.toBuilder() - additionalHeaders = aclFindAndDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aclFindAndDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(aclFindAndDeleteParams: AclFindAndDeleteParams) = apply { + body = aclFindAndDeleteParams.body.toBuilder() + additionalHeaders = aclFindAndDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aclFindAndDeleteParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: String) = apply { body.objectId(objectId) } /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = - apply { - body.objectId(objectId) - } + 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: ObjectType) = 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 provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun groupId(groupId: String?) = - apply { - body.groupId(groupId) - } + fun groupId(groupId: String?) = apply { body.groupId(groupId) } /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided - */ - fun groupId(groupId: JsonField) = - apply { - body.groupId(groupId) - } - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided */ - fun permission(permission: Permission?) = - apply { - body.permission(permission) - } + fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: Permission?) = apply { body.permission(permission) } + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun permission(permission: JsonField) = - apply { - body.permission(permission) - } + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(permission: JsonField) = apply { body.permission(permission) } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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 { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = apply { + body.restrictObjectType(restrictObjectType) + } /** - * When setting a permission directly, optionally restricts the permission grant to - * just the specified object type. Cannot be set alongside a `role_id`. + * 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) = restrictObjectType(restrictObjectType.getOrNull()) + 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`. + * 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 { - body.restrictObjectType(restrictObjectType) - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + body.restrictObjectType(restrictObjectType) + } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: String?) = - apply { - body.roleId(roleId) - } + fun roleId(roleId: String?) = apply { body.roleId(roleId) } /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(roleId: JsonField) = - apply { - body.roleId(roleId) - } + fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: String?) = - apply { - body.userId(userId) - } + fun userId(userId: String?) = apply { body.userId(userId) } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will - * be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided */ - fun userId(userId: JsonField) = - apply { - body.userId(userId) - } + fun userId(userId: JsonField) = apply { body.userId(userId) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclFindAndDeleteParams = AclFindAndDeleteParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -876,11 +738,9 @@ class AclFindAndDeleteParams private constructor( * 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 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 { @@ -896,18 +756,17 @@ class AclFindAndDeleteParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -928,11 +787,11 @@ class AclFindAndDeleteParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -953,20 +812,23 @@ class AclFindAndDeleteParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -974,25 +836,18 @@ class AclFindAndDeleteParams private constructor( 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 { + /** 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1031,11 +886,9 @@ class AclFindAndDeleteParams private constructor( * 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 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 { @@ -1048,18 +901,17 @@ class AclFindAndDeleteParams private constructor( UPDATE_ACLS, DELETE_ACLS, /** - * An enum member indicating that [Permission] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -1077,11 +929,11 @@ class AclFindAndDeleteParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -1099,20 +951,23 @@ class AclFindAndDeleteParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1121,24 +976,22 @@ class AclFindAndDeleteParams 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`. + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1183,16 +1036,12 @@ class AclFindAndDeleteParams private constructor( } /** - * 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. + * 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 { @@ -1208,18 +1057,18 @@ class AclFindAndDeleteParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [RestrictObjectType] was instantiated with an - * unknown value. + * 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. + * 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. + * 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) { @@ -1240,11 +1089,11 @@ class AclFindAndDeleteParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -1265,20 +1114,23 @@ class AclFindAndDeleteParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1287,14 +1139,15 @@ class AclFindAndDeleteParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AclFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AclFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index e4cc0a07..f265a4be 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.AclService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ -class AclListPage private constructor( +class AclListPage +private constructor( private val aclsService: AclService, private val params: AclListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,40 @@ class AclListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListPage && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AclListPage && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ - override fun toString() = "AclListPage{aclsService=$aclsService, params=$params, response=$response}" + override fun toString() = + "AclListPage{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(AclListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(AclListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + AclListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + AclListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { aclsService.list(it) } + return getNextPageParams().map { aclsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +78,16 @@ class AclListPage private constructor( @JvmStatic fun of(aclsService: AclService, params: AclListParams, response: Response) = - AclListPage( - aclsService, - params, - response, - ) + AclListPage(aclsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +101,34 @@ class AclListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AclListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +137,39 @@ class AclListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: AclListPage, + class AutoPager(private val firstPage: AclListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index e5906d51..9d691383 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.AclServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ -class AclListPageAsync private constructor( +class AclListPageAsync +private constructor( private val aclsService: AclServiceAsync, private val params: AclListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,42 @@ class AclListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListPageAsync && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AclListPageAsync && aclsService == other.aclsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclsService, params, response) /* spotless:on */ - override fun toString() = "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" + override fun toString() = + "AclListPageAsync{aclsService=$aclsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(AclListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(AclListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + AclListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + AclListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - aclsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { aclsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -81,18 +80,16 @@ class AclListPageAsync private constructor( @JvmStatic fun of(aclsService: AclServiceAsync, params: AclListParams, response: Response) = - AclListPageAsync( - aclsService, - params, - response, - ) + AclListPageAsync(aclsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,35 +103,34 @@ class AclListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AclListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -143,63 +139,46 @@ class AclListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: AclListPageAsync, - - ) { + class AutoPager(private val firstPage: AclListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Acl) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Acl) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } 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 2a622bec..46304214 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 @@ -27,10 +27,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ -class AclListParams private constructor( +class AclListParams +private constructor( private val objectId: String, private val objectType: ObjectType, private val endingBefore: String?, @@ -39,7 +40,6 @@ class AclListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** The id of the object the ACL applies to */ @@ -51,15 +51,15 @@ class AclListParams private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -69,9 +69,9 @@ class AclListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -82,39 +82,15 @@ class AclListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { - queryParams.put( - "object_id", listOf(it.toString()) - ) - } - this.objectType.let { - queryParams.put( - "object_type", listOf(it.toString()) - ) - } - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } + this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) @@ -125,14 +101,12 @@ class AclListParams private constructor( * Returns a mutable builder for constructing an instance of [AclListParams]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AclListParams]. */ @@ -149,83 +123,67 @@ class AclListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclListParams: AclListParams) = - apply { - objectId = aclListParams.objectId - objectType = aclListParams.objectType - endingBefore = aclListParams.endingBefore - ids = aclListParams.ids - limit = aclListParams.limit - startingAfter = aclListParams.startingAfter - additionalHeaders = aclListParams.additionalHeaders.toBuilder() - additionalQueryParams = aclListParams.additionalQueryParams.toBuilder() - } + internal fun from(aclListParams: AclListParams) = apply { + objectId = aclListParams.objectId + objectType = aclListParams.objectType + endingBefore = aclListParams.endingBefore + ids = aclListParams.ids + limit = aclListParams.limit + startingAfter = aclListParams.startingAfter + additionalHeaders = aclListParams.additionalHeaders.toBuilder() + additionalQueryParams = aclListParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = - apply { - this.objectId = objectId - } + 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: ObjectType) = apply { this.objectType = objectType } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -236,181 +194,145 @@ class AclListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclListParams = AclListParams( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - endingBefore, - ids, - limit, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + endingBefore, + ids, + limit, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -458,11 +380,9 @@ class AclListParams private constructor( * 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 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 { @@ -478,18 +398,17 @@ class AclListParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -510,11 +429,11 @@ class AclListParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -535,20 +454,23 @@ class AclListParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -557,16 +479,16 @@ class AclListParams private constructor( } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -584,19 +506,19 @@ class AclListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -611,17 +533,12 @@ class AclListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -631,56 +548,60 @@ class AclListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index edd1a180..a91c07d2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an acl object by its id */ -class AclRetrieveParams private constructor( +class AclRetrieveParams +private constructor( private val aclId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Acl id */ @@ -29,10 +29,10 @@ class AclRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,13 +43,11 @@ class AclRetrieveParams private constructor( * Returns a mutable builder for constructing an instance of [AclRetrieveParams]. * * The following fields are required: - * * ```java * .aclId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AclRetrieveParams]. */ @@ -61,162 +59,131 @@ class AclRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aclRetrieveParams: AclRetrieveParams) = - apply { - aclId = aclRetrieveParams.aclId - additionalHeaders = aclRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = aclRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(aclRetrieveParams: AclRetrieveParams) = apply { + aclId = aclRetrieveParams.aclId + additionalHeaders = aclRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = aclRetrieveParams.additionalQueryParams.toBuilder() + } /** Acl id */ - fun aclId(aclId: String) = - apply { - this.aclId = aclId - } + fun aclId(aclId: String) = apply { this.aclId = aclId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AclRetrieveParams = AclRetrieveParams( - checkRequired( - "aclId", aclId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("aclId", aclId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AclRetrieveParams && aclId == other.aclId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aclId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AclRetrieveParams{aclId=$aclId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index a8215c3d..4de28c65 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -22,14 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as - * the one specified in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as the one specified + * in the request, will return the existing ai_secret unmodified */ -class AiSecretCreateParams private constructor( +class AiSecretCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the AI secret */ @@ -38,15 +38,15 @@ class AiSecretCreateParams private constructor( fun metadata(): Optional = body.metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. */ fun orgName(): Optional = body.orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not + * replaced with null. */ fun secret(): Optional = body.secret() @@ -58,15 +58,15 @@ class AiSecretCreateParams private constructor( fun _metadata(): JsonField = body._metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not + * replaced with null. */ fun _secret(): JsonField = body._secret() @@ -78,22 +78,33 @@ class AiSecretCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("secret") + @ExcludeMissing + private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the AI secret */ @@ -102,49 +113,39 @@ class AiSecretCreateParams private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the AI secret */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ - @JsonProperty("secret") - @ExcludeMissing - fun _secret(): JsonField = secret + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -152,20 +153,19 @@ class AiSecretCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - metadata().ifPresent { it.validate() } - orgName() - secret() - type() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + metadata().ifPresent { it.validate() } + orgName() + secret() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -174,13 +174,11 @@ class AiSecretCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -194,133 +192,108 @@ class AiSecretCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - metadata = body.metadata - orgName = body.orgName - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + metadata = body.metadata + orgName = body.orgName + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. */ fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. */ - fun secret(secret: JsonField) = - apply { - this.secret = secret - } + fun secret(secret: JsonField) = apply { this.secret = secret } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = - apply { - this.type = type - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - metadata, - orgName, - secret, - type, - additionalProperties.toImmutable(), + checkRequired("name", name), + metadata, + orgName, + secret, + type, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -329,7 +302,8 @@ class AiSecretCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -337,17 +311,14 @@ class AiSecretCreateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AiSecretCreateParams]. + * Returns a mutable builder for constructing an instance of [AiSecretCreateParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AiSecretCreateParams]. */ @@ -359,263 +330,200 @@ class AiSecretCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretCreateParams: AiSecretCreateParams) = - apply { - body = aiSecretCreateParams.body.toBuilder() - additionalHeaders = aiSecretCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretCreateParams: AiSecretCreateParams) = apply { + body = aiSecretCreateParams.body.toBuilder() + additionalHeaders = aiSecretCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretCreateParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } - fun metadata(metadata: Metadata?) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ - fun secret(secret: String?) = - apply { - body.secret(secret) - } + fun secret(secret: String?) = apply { body.secret(secret) } /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ - fun secret(secret: JsonField) = - apply { - body.secret(secret) - } + fun secret(secret: JsonField) = apply { body.secret(secret) } - fun type(type: String?) = - apply { - body.type(type) - } + fun type(type: String?) = apply { body.type(type) } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = - apply { - body.type(type) - } + fun type(type: JsonField) = apply { body.type(type) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretCreateParams = AiSecretCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -624,22 +532,20 @@ class AiSecretCreateParams private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -648,46 +554,38 @@ class AiSecretCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -700,14 +598,15 @@ class AiSecretCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AiSecretCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AiSecretCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index 3cbf2d45..b62db648 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an ai_secret object by its id */ -class AiSecretDeleteParams private constructor( +class AiSecretDeleteParams +private constructor( private val aiSecretId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** AiSecret id */ @@ -31,17 +31,18 @@ class AiSecretDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -49,17 +50,14 @@ class AiSecretDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AiSecretDeleteParams]. + * Returns a mutable builder for constructing an instance of [AiSecretDeleteParams]. * * The following fields are required: - * * ```java * .aiSecretId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AiSecretDeleteParams]. */ @@ -72,190 +70,155 @@ class AiSecretDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(aiSecretDeleteParams: AiSecretDeleteParams) = - apply { - aiSecretId = aiSecretDeleteParams.aiSecretId - additionalHeaders = aiSecretDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = aiSecretDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(aiSecretDeleteParams: AiSecretDeleteParams) = apply { + aiSecretId = aiSecretDeleteParams.aiSecretId + additionalHeaders = aiSecretDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = aiSecretDeleteParams.additionalBodyProperties.toMutableMap() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = - apply { - this.aiSecretId = aiSecretId - } + fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): AiSecretDeleteParams = AiSecretDeleteParams( - checkRequired( - "aiSecretId", aiSecretId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("aiSecretId", aiSecretId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is AiSecretDeleteParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "AiSecretDeleteParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index ffce1c86..09e2cfab 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -22,20 +22,20 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Delete a single ai_secret */ -class AiSecretFindAndDeleteParams private constructor( +class AiSecretFindAndDeleteParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the AI secret */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. */ fun orgName(): Optional = body.orgName() @@ -43,9 +43,9 @@ class AiSecretFindAndDeleteParams private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -55,44 +55,45 @@ class AiSecretFindAndDeleteParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the AI secret */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the AI secret */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -100,17 +101,16 @@ class AiSecretFindAndDeleteParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - orgName() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -119,13 +119,11 @@ class AiSecretFindAndDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -136,88 +134,68 @@ class AiSecretFindAndDeleteParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body( - checkRequired( - "name", name - ), - orgName, - additionalProperties.toImmutable(), - ) + Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -226,7 +204,8 @@ class AiSecretFindAndDeleteParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -234,17 +213,14 @@ class AiSecretFindAndDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AiSecretFindAndDeleteParams]. + * Returns a mutable builder for constructing an instance of [AiSecretFindAndDeleteParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AiSecretFindAndDeleteParams]. */ @@ -256,220 +232,174 @@ class AiSecretFindAndDeleteParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = - apply { - body = aiSecretFindAndDeleteParams.body.toBuilder() - additionalHeaders = aiSecretFindAndDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretFindAndDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretFindAndDeleteParams: AiSecretFindAndDeleteParams) = apply { + body = aiSecretFindAndDeleteParams.body.toBuilder() + additionalHeaders = aiSecretFindAndDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretFindAndDeleteParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretFindAndDeleteParams = AiSecretFindAndDeleteParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretFindAndDeleteParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AiSecretFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AiSecretFindAndDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index cb07762e..31ca38f9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.AiSecretService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the - * most recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first */ -class AiSecretListPage private constructor( +class AiSecretListPage +private constructor( private val aiSecretsService: AiSecretService, private val params: AiSecretListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class AiSecretListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListPage && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AiSecretListPage && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ - override fun toString() = "AiSecretListPage{aiSecretsService=$aiSecretsService, params=$params, response=$response}" + override fun toString() = + "AiSecretListPage{aiSecretsService=$aiSecretsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(AiSecretListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(AiSecretListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + AiSecretListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + AiSecretListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { aiSecretsService.list(it) } + return getNextPageParams().map { aiSecretsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +84,16 @@ class AiSecretListPage private constructor( @JvmStatic fun of(aiSecretsService: AiSecretService, params: AiSecretListParams, response: Response) = - AiSecretListPage( - aiSecretsService, - params, - response, - ) + AiSecretListPage(aiSecretsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +107,34 @@ class AiSecretListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [AiSecretListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +143,39 @@ class AiSecretListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: AiSecretListPage, + class AutoPager(private val firstPage: AiSecretListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 0808cf83..09526724 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.AiSecretServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the - * most recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first */ -class AiSecretListPageAsync private constructor( +class AiSecretListPageAsync +private constructor( private val aiSecretsService: AiSecretServiceAsync, private val params: AiSecretListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class AiSecretListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListPageAsync && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AiSecretListPageAsync && aiSecretsService == other.aiSecretsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretsService, params, response) /* spotless:on */ - override fun toString() = "AiSecretListPageAsync{aiSecretsService=$aiSecretsService, params=$params, response=$response}" + override fun toString() = + "AiSecretListPageAsync{aiSecretsService=$aiSecretsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(AiSecretListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(AiSecretListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + AiSecretListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + AiSecretListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - aiSecretsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { aiSecretsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,20 @@ class AiSecretListPageAsync private constructor( companion object { @JvmStatic - fun of(aiSecretsService: AiSecretServiceAsync, params: AiSecretListParams, response: Response) = - AiSecretListPageAsync( - aiSecretsService, - params, - response, - ) + fun of( + aiSecretsService: AiSecretServiceAsync, + params: AiSecretListParams, + response: Response, + ) = AiSecretListPageAsync(aiSecretsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,38 +112,36 @@ class AiSecretListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of - * [AiSecretListPageAsync]. + * Returns a mutable builder for constructing an instance of [AiSecretListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +150,46 @@ class AiSecretListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: AiSecretListPageAsync, - - ) { + class AutoPager(private val firstPage: AiSecretListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (AISecret) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (AISecret) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index 34a3b048..d41f9f78 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the - * most recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first */ -class AiSecretListParams private constructor( +class AiSecretListParams +private constructor( private val aiSecretName: String?, private val aiSecretType: AiSecretType?, private val endingBefore: String?, @@ -36,7 +37,6 @@ class AiSecretListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the ai_secret to search for */ @@ -47,15 +47,15 @@ class AiSecretListParams private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -68,9 +68,9 @@ class AiSecretListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -81,56 +81,26 @@ class AiSecretListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.aiSecretName?.let { - queryParams.put( - "ai_secret_name", listOf(it.toString()) - ) - } - this.aiSecretType?.let { - queryParams.put( - "ai_secret_type", listOf(it.toString()) - ) - } - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.aiSecretName?.let { queryParams.put("ai_secret_name", listOf(it.toString())) } + this.aiSecretType?.let { queryParams.put("ai_secret_type", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): AiSecretListParams = builder().build() + @JvmStatic fun none(): AiSecretListParams = builder().build() /** Returns a mutable builder for constructing an instance of [AiSecretListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AiSecretListParams]. */ @@ -148,92 +118,78 @@ class AiSecretListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretListParams: AiSecretListParams) = - apply { - aiSecretName = aiSecretListParams.aiSecretName - aiSecretType = aiSecretListParams.aiSecretType - endingBefore = aiSecretListParams.endingBefore - ids = aiSecretListParams.ids - limit = aiSecretListParams.limit - orgName = aiSecretListParams.orgName - startingAfter = aiSecretListParams.startingAfter - additionalHeaders = aiSecretListParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretListParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretListParams: AiSecretListParams) = apply { + aiSecretName = aiSecretListParams.aiSecretName + aiSecretType = aiSecretListParams.aiSecretType + endingBefore = aiSecretListParams.endingBefore + ids = aiSecretListParams.ids + limit = aiSecretListParams.limit + orgName = aiSecretListParams.orgName + startingAfter = aiSecretListParams.startingAfter + additionalHeaders = aiSecretListParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretListParams.additionalQueryParams.toBuilder() + } /** Name of the ai_secret to search for */ - fun aiSecretName(aiSecretName: String?) = - apply { - this.aiSecretName = aiSecretName - } + fun aiSecretName(aiSecretName: String?) = apply { this.aiSecretName = aiSecretName } /** Name of the ai_secret to search for */ fun aiSecretName(aiSecretName: Optional) = aiSecretName(aiSecretName.getOrNull()) - fun aiSecretType(aiSecretType: AiSecretType?) = - apply { - this.aiSecretType = aiSecretType - } + fun aiSecretType(aiSecretType: AiSecretType?) = apply { this.aiSecretType = aiSecretType } - fun aiSecretType(aiSecretType: Optional) = aiSecretType(aiSecretType.getOrNull()) + fun aiSecretType(aiSecretType: Optional) = + aiSecretType(aiSecretType.getOrNull()) fun aiSecretType(string: String) = aiSecretType(AiSecretType.ofString(string)) - fun aiSecretTypeOfStrings(strings: List) = aiSecretType(AiSecretType.ofStrings(strings)) + fun aiSecretTypeOfStrings(strings: List) = + aiSecretType(AiSecretType.ofStrings(strings)) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -242,10 +198,7 @@ class AiSecretListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -253,169 +206,141 @@ class AiSecretListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretListParams = AiSecretListParams( - aiSecretName, - aiSecretType, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + aiSecretName, + aiSecretType, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = AiSecretType.Deserializer::class) @JsonSerialize(using = AiSecretType.Serializer::class) - class AiSecretType private constructor( + class AiSecretType + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -433,19 +358,19 @@ class AiSecretListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretType && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is AiSecretType && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -460,16 +385,14 @@ class AiSecretListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = AiSecretType(string = string) + @JvmStatic fun ofString(string: String) = AiSecretType(string = string) - @JvmStatic - fun ofStrings(strings: List) = AiSecretType(strings = strings) + @JvmStatic fun ofStrings(strings: List) = AiSecretType(strings = strings) } /** - * An interface that defines how to map each variant of [AiSecretType] to a value - * of type [T]. + * An interface that defines how to map each variant of [AiSecretType] to a value of type + * [T]. */ interface Visitor { @@ -480,58 +403,62 @@ class AiSecretListParams private constructor( /** * Maps an unknown variant of [AiSecretType] to a value of type [T]. * - * An instance of [AiSecretType] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [AiSecretType] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown AiSecretType: $json") + throw BraintrustInvalidDataException("Unknown AiSecretType: $json") } } internal class Deserializer : BaseDeserializer(AiSecretType::class) { override fun ObjectCodec.deserialize(node: JsonNode): AiSecretType { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return AiSecretType(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return AiSecretType(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return AiSecretType(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return AiSecretType(strings = it, _json = json) + } - return AiSecretType(_json = json) + return AiSecretType(_json = json) } } internal class Serializer : BaseSerializer(AiSecretType::class) { - override fun serialize(value: AiSecretType, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid AiSecretType") - } + override fun serialize( + value: AiSecretType, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AiSecretType") + } } } } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -549,19 +476,19 @@ class AiSecretListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -576,17 +503,12 @@ class AiSecretListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -596,56 +518,60 @@ class AiSecretListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretListParams && aiSecretName == other.aiSecretName && aiSecretType == other.aiSecretType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretName, aiSecretType, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AiSecretListParams{aiSecretName=$aiSecretName, aiSecretType=$aiSecretType, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 2f6d1f04..30fafd07 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -22,15 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace ai_secret. If there is an existing ai_secret with the same - * name as the one specified in the request, will replace the existing ai_secret - * with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one + * specified in the request, will replace the existing ai_secret with the provided fields */ -class AiSecretReplaceParams private constructor( +class AiSecretReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the AI secret */ @@ -39,15 +38,15 @@ class AiSecretReplaceParams private constructor( fun metadata(): Optional = body.metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. */ fun orgName(): Optional = body.orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not + * replaced with null. */ fun secret(): Optional = body.secret() @@ -59,15 +58,15 @@ class AiSecretReplaceParams private constructor( fun _metadata(): JsonField = body._metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * AI Secret belongs in. */ fun _orgName(): JsonField = body._orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not + * replaced with null. */ fun _secret(): JsonField = body._secret() @@ -79,22 +78,33 @@ class AiSecretReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("secret") + @ExcludeMissing + private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the AI secret */ @@ -103,49 +113,39 @@ class AiSecretReplaceParams private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the AI secret */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ - @JsonProperty("secret") - @ExcludeMissing - fun _secret(): JsonField = secret + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -153,20 +153,19 @@ class AiSecretReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - metadata().ifPresent { it.validate() } - orgName() - secret() - type() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + metadata().ifPresent { it.validate() } + orgName() + secret() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -175,13 +174,11 @@ class AiSecretReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -195,133 +192,108 @@ class AiSecretReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - metadata = body.metadata - orgName = body.orgName - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + metadata = body.metadata + orgName = body.orgName + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. */ fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left + * intact, not replaced with null. */ - fun secret(secret: JsonField) = - apply { - this.secret = secret - } + fun secret(secret: JsonField) = apply { this.secret = secret } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = - apply { - this.type = type - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - metadata, - orgName, - secret, - type, - additionalProperties.toImmutable(), + checkRequired("name", name), + metadata, + orgName, + secret, + type, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && metadata == other.metadata && orgName == other.orgName && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -330,7 +302,8 @@ class AiSecretReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -338,17 +311,14 @@ class AiSecretReplaceParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AiSecretReplaceParams]. + * Returns a mutable builder for constructing an instance of [AiSecretReplaceParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AiSecretReplaceParams]. */ @@ -360,263 +330,200 @@ class AiSecretReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretReplaceParams: AiSecretReplaceParams) = - apply { - body = aiSecretReplaceParams.body.toBuilder() - additionalHeaders = aiSecretReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretReplaceParams: AiSecretReplaceParams) = apply { + body = aiSecretReplaceParams.body.toBuilder() + additionalHeaders = aiSecretReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the AI secret */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } - fun metadata(metadata: Metadata?) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the AI Secret belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the AI Secret belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ - fun secret(secret: String?) = - apply { - body.secret(secret) - } + fun secret(secret: String?) = apply { body.secret(secret) } /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be - * left intact, not replaced with null. + * Secret value. If omitted in a PUT request, the existing secret value will be left intact, + * not replaced with null. */ - fun secret(secret: JsonField) = - apply { - body.secret(secret) - } + fun secret(secret: JsonField) = apply { body.secret(secret) } - fun type(type: String?) = - apply { - body.type(type) - } + fun type(type: String?) = apply { body.type(type) } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = - apply { - body.type(type) - } + fun type(type: JsonField) = apply { body.type(type) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretReplaceParams = AiSecretReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -625,22 +532,20 @@ class AiSecretReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -649,46 +554,38 @@ class AiSecretReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -701,14 +598,15 @@ class AiSecretReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AiSecretReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AiSecretReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index 4319dc92..63959bb2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an ai_secret object by its id */ -class AiSecretRetrieveParams private constructor( +class AiSecretRetrieveParams +private constructor( private val aiSecretId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** AiSecret id */ @@ -29,10 +29,10 @@ class AiSecretRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class AiSecretRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AiSecretRetrieveParams]. + * Returns a mutable builder for constructing an instance of [AiSecretRetrieveParams]. * * The following fields are required: - * * ```java * .aiSecretId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AiSecretRetrieveParams]. */ @@ -62,162 +59,131 @@ class AiSecretRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = - apply { - aiSecretId = aiSecretRetrieveParams.aiSecretId - additionalHeaders = aiSecretRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretRetrieveParams: AiSecretRetrieveParams) = apply { + aiSecretId = aiSecretRetrieveParams.aiSecretId + additionalHeaders = aiSecretRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretRetrieveParams.additionalQueryParams.toBuilder() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = - apply { - this.aiSecretId = aiSecretId - } + fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( - checkRequired( - "aiSecretId", aiSecretId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("aiSecretId", aiSecretId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretRetrieveParams && aiSecretId == other.aiSecretId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AiSecretRetrieveParams{aiSecretId=$aiSecretId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 50a0c389..a1146def 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an ai_secret object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ -class AiSecretUpdateParams private constructor( +class AiSecretUpdateParams +private constructor( private val aiSecretId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** AiSecret id */ @@ -61,28 +61,37 @@ class AiSecretUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> aiSecretId - else -> "" - } + return when (index) { + 0 -> aiSecretId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("secret") @ExcludeMissing private val secret: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("secret") + @ExcludeMissing + private val secret: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -94,22 +103,14 @@ class AiSecretUpdateParams private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Name of the AI secret */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("secret") - @ExcludeMissing - fun _secret(): JsonField = secret + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -117,26 +118,24 @@ class AiSecretUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - name() - secret() - type() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + metadata().ifPresent { it.validate() } + name() + secret() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -149,23 +148,19 @@ class AiSecretUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - metadata = body.metadata - name = body.name - secret = body.secret - type = body.type - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + metadata = body.metadata + name = body.name + secret = body.secret + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the AI secret */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -174,71 +169,49 @@ class AiSecretUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) fun secret(secret: Optional) = secret(secret.getOrNull()) - fun secret(secret: JsonField) = - apply { - this.secret = secret - } + fun secret(secret: JsonField) = apply { this.secret = secret } fun type(type: String?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = - apply { - this.type = type - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body( - metadata, - name, - secret, - type, - additionalProperties.toImmutable(), - ) + Body(metadata, name, secret, type, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && metadata == other.metadata && name == other.name && secret == other.secret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -247,7 +220,8 @@ class AiSecretUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -255,17 +229,14 @@ class AiSecretUpdateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AiSecretUpdateParams]. + * Returns a mutable builder for constructing an instance of [AiSecretUpdateParams]. * * The following fields are required: - * * ```java * .aiSecretId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AiSecretUpdateParams]. */ @@ -278,237 +249,175 @@ class AiSecretUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(aiSecretUpdateParams: AiSecretUpdateParams) = - apply { - aiSecretId = aiSecretUpdateParams.aiSecretId - body = aiSecretUpdateParams.body.toBuilder() - additionalHeaders = aiSecretUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = aiSecretUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(aiSecretUpdateParams: AiSecretUpdateParams) = apply { + aiSecretId = aiSecretUpdateParams.aiSecretId + body = aiSecretUpdateParams.body.toBuilder() + additionalHeaders = aiSecretUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aiSecretUpdateParams.additionalQueryParams.toBuilder() + } /** AiSecret id */ - fun aiSecretId(aiSecretId: String) = - apply { - this.aiSecretId = aiSecretId - } + fun aiSecretId(aiSecretId: String) = apply { this.aiSecretId = aiSecretId } - fun metadata(metadata: Metadata?) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - fun metadata(metadata: JsonField) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the AI secret */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the AI secret */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the AI secret */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } - fun secret(secret: String?) = - apply { - body.secret(secret) - } + fun secret(secret: String?) = apply { body.secret(secret) } fun secret(secret: Optional) = secret(secret.getOrNull()) - fun secret(secret: JsonField) = - apply { - body.secret(secret) - } + fun secret(secret: JsonField) = apply { body.secret(secret) } - fun type(type: String?) = - apply { - body.type(type) - } + fun type(type: String?) = apply { body.type(type) } fun type(type: Optional) = type(type.getOrNull()) - fun type(type: JsonField) = - apply { - body.type(type) - } + fun type(type: JsonField) = apply { body.type(type) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): AiSecretUpdateParams = AiSecretUpdateParams( - checkRequired( - "aiSecretId", aiSecretId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("aiSecretId", aiSecretId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -517,22 +426,20 @@ class AiSecretUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -541,46 +448,38 @@ class AiSecretUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -593,14 +492,15 @@ class AiSecretUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AiSecretUpdateParams && aiSecretId == other.aiSecretId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(aiSecretId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "AiSecretUpdateParams{aiSecretId=$aiSecretId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "AiSecretUpdateParams{aiSecretId=$aiSecretId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index b36d8cef..0b88b229 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -20,15 +20,22 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ApiKey @JsonCreator private constructor( +class ApiKey +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("preview_name") @ExcludeMissing private val previewName: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("preview_name") + @ExcludeMissing + private val previewName: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the api key */ @@ -49,33 +56,23 @@ class ApiKey @JsonCreator private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the api key */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the api key */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("preview_name") @ExcludeMissing fun _previewName(): JsonField = previewName /** Date of api key creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Unique identifier for the user */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -83,21 +80,20 @@ class ApiKey @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ApiKey = - apply { - if (validated) { - return@apply - } - - id() - name() - previewName() - created() - orgId() - userId() - validated = true + fun validate(): ApiKey = apply { + if (validated) { + return@apply } + id() + name() + previewName() + created() + orgId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -106,15 +102,13 @@ class ApiKey @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [ApiKey]. * * The following fields are required: - * * ```java * .id() * .name() * .previewName() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ApiKey]. */ @@ -129,41 +123,31 @@ class ApiKey @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKey: ApiKey) = - apply { - id = apiKey.id - name = apiKey.name - previewName = apiKey.previewName - created = apiKey.created - orgId = apiKey.orgId - userId = apiKey.userId - additionalProperties = apiKey.additionalProperties.toMutableMap() - } + internal fun from(apiKey: ApiKey) = apply { + id = apiKey.id + name = apiKey.name + previewName = apiKey.previewName + created = apiKey.created + orgId = apiKey.orgId + userId = apiKey.userId + additionalProperties = apiKey.additionalProperties.toMutableMap() + } /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - fun previewName(previewName: JsonField) = - apply { - this.previewName = previewName - } + fun previewName(previewName: JsonField) = apply { this.previewName = previewName } /** Date of api key creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -172,10 +156,7 @@ class ApiKey @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of api key creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the organization */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) @@ -184,10 +165,7 @@ class ApiKey @JsonCreator private constructor( fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the user */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -196,61 +174,45 @@ class ApiKey @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Unique identifier for the user */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ApiKey = ApiKey( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "previewName", previewName - ), - created, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("previewName", previewName), + created, + orgId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKey && id == other.id && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ApiKey && id == other.id && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -259,5 +221,6 @@ class ApiKey @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ApiKey{id=$id, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "ApiKey{id=$id, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index bcde02a6..a66bf130 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -22,23 +22,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new api_key. It is possible to have multiple API keys with the same - * name. There is no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same name. There is no + * de-duplication */ -class ApiKeyCreateParams private constructor( +class ApiKeyCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the api key. Does not have to be unique */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * API key belongs in. */ fun orgName(): Optional = body.orgName() @@ -46,9 +46,9 @@ class ApiKeyCreateParams private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * API key belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -58,44 +58,45 @@ class ApiKeyCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the api key. Does not have to be unique */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -103,17 +104,16 @@ class ApiKeyCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - orgName() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -122,13 +122,11 @@ class ApiKeyCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -139,88 +137,68 @@ class ApiKeyCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the api key. Does not have to be unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key. Does not have to be unique */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body( - checkRequired( - "name", name - ), - orgName, - additionalProperties.toImmutable(), - ) + Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -229,7 +207,8 @@ class ApiKeyCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -240,13 +219,11 @@ class ApiKeyCreateParams private constructor( * Returns a mutable builder for constructing an instance of [ApiKeyCreateParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ApiKeyCreateParams]. */ @@ -258,220 +235,174 @@ class ApiKeyCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = - apply { - body = apiKeyCreateParams.body.toBuilder() - additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { + body = apiKeyCreateParams.body.toBuilder() + additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() + } /** Name of the api key. Does not have to be unique */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the api key. Does not have to be unique */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the API key belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the API key belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyCreateParams = ApiKeyCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ApiKeyCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ApiKeyCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index d1089b96..f0404eda 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an api_key object by its id */ -class ApiKeyDeleteParams private constructor( +class ApiKeyDeleteParams +private constructor( private val apiKeyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** ApiKey id */ @@ -31,17 +31,18 @@ class ApiKeyDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -52,13 +53,11 @@ class ApiKeyDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [ApiKeyDeleteParams]. * * The following fields are required: - * * ```java * .apiKeyId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ApiKeyDeleteParams]. */ @@ -71,190 +70,155 @@ class ApiKeyDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = - apply { - apiKeyId = apiKeyDeleteParams.apiKeyId - additionalHeaders = apiKeyDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = apiKeyDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = apply { + apiKeyId = apiKeyDeleteParams.apiKeyId + additionalHeaders = apiKeyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = apiKeyDeleteParams.additionalBodyProperties.toMutableMap() + } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = - apply { - this.apiKeyId = apiKeyId - } + fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( - checkRequired( - "apiKeyId", apiKeyId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("apiKeyId", apiKeyId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ApiKeyDeleteParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 9f5c298c..0b0839e1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.ApiKeyService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created + * api_keys coming first */ -class ApiKeyListPage private constructor( +class ApiKeyListPage +private constructor( private val apiKeysService: ApiKeyService, private val params: ApiKeyListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,40 @@ class ApiKeyListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListPage && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ApiKeyListPage && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ - override fun toString() = "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" + override fun toString() = + "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { apiKeysService.list(it) } + return getNextPageParams().map { apiKeysService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +78,16 @@ class ApiKeyListPage private constructor( @JvmStatic fun of(apiKeysService: ApiKeyService, params: ApiKeyListParams, response: Response) = - ApiKeyListPage( - apiKeysService, - params, - response, - ) + ApiKeyListPage(apiKeysService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +101,34 @@ class ApiKeyListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ApiKeyListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +137,39 @@ class ApiKeyListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ApiKeyListPage, + class AutoPager(private val firstPage: ApiKeyListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index 4d1e49f6..86f19e49 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.ApiKeyServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created + * api_keys coming first */ -class ApiKeyListPageAsync private constructor( +class ApiKeyListPageAsync +private constructor( private val apiKeysService: ApiKeyServiceAsync, private val params: ApiKeyListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,42 @@ class ApiKeyListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListPageAsync && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ApiKeyListPageAsync && apiKeysService == other.apiKeysService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeysService, params, response) /* spotless:on */ - override fun toString() = "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" + override fun toString() = + "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - apiKeysService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { apiKeysService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -81,18 +80,16 @@ class ApiKeyListPageAsync private constructor( @JvmStatic fun of(apiKeysService: ApiKeyServiceAsync, params: ApiKeyListParams, response: Response) = - ApiKeyListPageAsync( - apiKeysService, - params, - response, - ) + ApiKeyListPageAsync(apiKeysService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,35 +103,34 @@ class ApiKeyListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ApiKeyListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -143,63 +139,46 @@ class ApiKeyListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ApiKeyListPageAsync, - - ) { + class AutoPager(private val firstPage: ApiKeyListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (ApiKey) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (ApiKey) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index fdf434a9..124f92d2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first + * List out all api_keys. The api_keys are sorted by creation date, with the most recently-created + * api_keys coming first */ -class ApiKeyListParams private constructor( +class ApiKeyListParams +private constructor( private val apiKeyName: String?, private val endingBefore: String?, private val ids: Ids?, @@ -35,7 +36,6 @@ class ApiKeyListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the api_key to search for */ @@ -44,15 +44,15 @@ class ApiKeyListParams private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ class ApiKeyListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,51 +78,25 @@ class ApiKeyListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.apiKeyName?.let { - queryParams.put( - "api_key_name", listOf(it.toString()) - ) - } - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.apiKeyName?.let { queryParams.put("api_key_name", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): ApiKeyListParams = builder().build() + @JvmStatic fun none(): ApiKeyListParams = builder().build() /** Returns a mutable builder for constructing an instance of [ApiKeyListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ApiKeyListParams]. */ @@ -139,23 +113,19 @@ class ApiKeyListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyListParams: ApiKeyListParams) = - apply { - apiKeyName = apiKeyListParams.apiKeyName - endingBefore = apiKeyListParams.endingBefore - ids = apiKeyListParams.ids - limit = apiKeyListParams.limit - orgName = apiKeyListParams.orgName - startingAfter = apiKeyListParams.startingAfter - additionalHeaders = apiKeyListParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyListParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyListParams: ApiKeyListParams) = apply { + apiKeyName = apiKeyListParams.apiKeyName + endingBefore = apiKeyListParams.endingBefore + ids = apiKeyListParams.ids + limit = apiKeyListParams.limit + orgName = apiKeyListParams.orgName + startingAfter = apiKeyListParams.startingAfter + additionalHeaders = apiKeyListParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyListParams.additionalQueryParams.toBuilder() + } /** Name of the api_key to search for */ - fun apiKeyName(apiKeyName: String?) = - apply { - this.apiKeyName = apiKeyName - } + fun apiKeyName(apiKeyName: String?) = apply { this.apiKeyName = apiKeyName } /** Name of the api_key to search for */ fun apiKeyName(apiKeyName: Optional) = apiKeyName(apiKeyName.getOrNull()) @@ -163,56 +133,47 @@ class ApiKeyListParams private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -221,10 +182,7 @@ class ApiKeyListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -232,172 +190,144 @@ class ApiKeyListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyListParams = ApiKeyListParams( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + apiKeyName, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -415,19 +345,19 @@ class ApiKeyListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -442,17 +372,12 @@ class ApiKeyListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -462,56 +387,60 @@ class ApiKeyListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyListParams && apiKeyName == other.apiKeyName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyName, endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 59821a4f..50963e4d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an api_key object by its id */ -class ApiKeyRetrieveParams private constructor( +class ApiKeyRetrieveParams +private constructor( private val apiKeyId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** ApiKey id */ @@ -29,10 +29,10 @@ class ApiKeyRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class ApiKeyRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ApiKeyRetrieveParams]. + * Returns a mutable builder for constructing an instance of [ApiKeyRetrieveParams]. * * The following fields are required: - * * ```java * .apiKeyId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ApiKeyRetrieveParams]. */ @@ -62,162 +59,131 @@ class ApiKeyRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = - apply { - apiKeyId = apiKeyRetrieveParams.apiKeyId - additionalHeaders = apiKeyRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = apiKeyRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = apply { + apiKeyId = apiKeyRetrieveParams.apiKeyId + additionalHeaders = apiKeyRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyRetrieveParams.additionalQueryParams.toBuilder() + } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = - apply { - this.apiKeyId = apiKeyId - } + fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( - checkRequired( - "apiKeyId", apiKeyId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("apiKeyId", apiKeyId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ApiKeyRetrieveParams && apiKeyId == other.apiKeyId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(apiKeyId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index f69a09f1..fcb0d184 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -20,24 +20,23 @@ import java.util.Objects import java.util.Optional @NoAutoDetect -class ChatCompletionContentPartImage @JsonCreator private constructor( - @JsonProperty("image_url") @ExcludeMissing private val imageUrl: JsonField = JsonMissing.of(), +class ChatCompletionContentPartImage +@JsonCreator +private constructor( + @JsonProperty("image_url") + @ExcludeMissing + private val imageUrl: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") fun type(): Type = type.getRequired("type") - @JsonProperty("image_url") - @ExcludeMissing - fun _imageUrl(): JsonField = imageUrl + @JsonProperty("image_url") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -45,17 +44,16 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionContentPartImage = - apply { - if (validated) { - return@apply - } - - imageUrl().validate() - type() - validated = true + fun validate(): ChatCompletionContentPartImage = apply { + if (validated) { + return@apply } + imageUrl().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -65,14 +63,12 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( * [ChatCompletionContentPartImage]. * * The following fields are required: - * * ```java * .imageUrl() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ChatCompletionContentPartImage]. */ @@ -83,84 +79,67 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionContentPartImage: ChatCompletionContentPartImage) = - apply { - imageUrl = chatCompletionContentPartImage.imageUrl - type = chatCompletionContentPartImage.type - additionalProperties = chatCompletionContentPartImage.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionContentPartImage: ChatCompletionContentPartImage) = apply { + imageUrl = chatCompletionContentPartImage.imageUrl + type = chatCompletionContentPartImage.type + additionalProperties = + chatCompletionContentPartImage.additionalProperties.toMutableMap() + } fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) - fun imageUrl(imageUrl: JsonField) = - apply { - this.imageUrl = imageUrl - } + fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionContentPartImage = ChatCompletionContentPartImage( - checkRequired( - "imageUrl", imageUrl - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("imageUrl", imageUrl), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ImageUrl @JsonCreator private constructor( + class ImageUrl + @JsonCreator + private constructor( @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("detail") @ExcludeMissing private val detail: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("detail") + @ExcludeMissing + private val detail: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun url(): String = url.getRequired("url") fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) - @JsonProperty("url") - @ExcludeMissing - fun _url(): JsonField = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - @JsonProperty("detail") - @ExcludeMissing - fun _detail(): JsonField = detail + @JsonProperty("detail") @ExcludeMissing fun _detail(): JsonField = detail @JsonAnyGetter @ExcludeMissing @@ -168,17 +147,16 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ImageUrl = - apply { - if (validated) { - return@apply - } - - url() - detail() - validated = true + fun validate(): ImageUrl = apply { + if (validated) { + return@apply } + url() + detail() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -187,13 +165,11 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [ImageUrl]. * * The following fields are required: - * * ```java * .url() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ImageUrl]. */ @@ -204,78 +180,54 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(imageUrl: ImageUrl) = - apply { - url = imageUrl.url - detail = imageUrl.detail - additionalProperties = imageUrl.additionalProperties.toMutableMap() - } + internal fun from(imageUrl: ImageUrl) = apply { + url = imageUrl.url + detail = imageUrl.detail + additionalProperties = imageUrl.additionalProperties.toMutableMap() + } fun url(url: String) = url(JsonField.of(url)) - fun url(url: JsonField) = - apply { - this.url = url - } + fun url(url: JsonField) = apply { this.url = url } fun detail(detail: Detail) = detail(JsonField.of(detail)) - fun detail(detail: JsonField) = - apply { - this.detail = detail - } + fun detail(detail: JsonField) = apply { this.detail = detail } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ImageUrl = - ImageUrl( - checkRequired( - "url", url - ), - detail, - additionalProperties.toImmutable(), - ) + ImageUrl(checkRequired("url", url), detail, additionalProperties.toImmutable()) } - class Detail @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Detail @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -299,18 +251,18 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( * An enum containing [Detail]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Detail] 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 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 { AUTO, LOW, HIGH, - /** An enum member indicating that [Detail] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Detail] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -318,8 +270,8 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( * 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. + * 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) { @@ -336,7 +288,7 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -352,17 +304,20 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ + return /* spotless:off */ other is Detail && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -371,11 +326,11 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ImageUrl && url == other.url && detail == other.detail && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ImageUrl && url == other.url && detail == other.detail && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -384,24 +339,21 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = + "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -412,18 +364,16 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - IMAGE_URL, + IMAGE_URL } /** * 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 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 { @@ -433,11 +383,11 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -448,11 +398,11 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -463,20 +413,23 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -485,11 +438,11 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPartImage && imageUrl == other.imageUrl && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartImage && imageUrl == other.imageUrl && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -498,5 +451,6 @@ class ChatCompletionContentPartImage @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ChatCompletionContentPartImage{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index 444bd3c7..c4b1ce91 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -20,24 +20,21 @@ import java.util.Objects import java.util.Optional @NoAutoDetect -class ChatCompletionContentPartText @JsonCreator private constructor( +class ChatCompletionContentPartText +@JsonCreator +private constructor( @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonProperty("text") @ExcludeMissing private val text: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun type(): Type = type.getRequired("type") fun text(): Optional = Optional.ofNullable(text.getNullable("text")) - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("text") - @ExcludeMissing - fun _text(): JsonField = text + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text @JsonAnyGetter @ExcludeMissing @@ -45,17 +42,16 @@ class ChatCompletionContentPartText @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionContentPartText = - apply { - if (validated) { - return@apply - } - - type() - text() - validated = true + fun validate(): ChatCompletionContentPartText = apply { + if (validated) { + return@apply } + type() + text() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -65,13 +61,11 @@ class ChatCompletionContentPartText @JsonCreator private constructor( * [ChatCompletionContentPartText]. * * The following fields are required: - * * ```java * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ChatCompletionContentPartText]. */ @@ -82,78 +76,58 @@ class ChatCompletionContentPartText @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionContentPartText: ChatCompletionContentPartText) = - apply { - type = chatCompletionContentPartText.type - text = chatCompletionContentPartText.text - additionalProperties = chatCompletionContentPartText.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionContentPartText: ChatCompletionContentPartText) = apply { + type = chatCompletionContentPartText.type + text = chatCompletionContentPartText.text + additionalProperties = chatCompletionContentPartText.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun text(text: String) = text(JsonField.of(text)) - fun text(text: JsonField) = - apply { - this.text = text - } + fun text(text: JsonField) = apply { this.text = text } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionContentPartText = ChatCompletionContentPartText( - checkRequired( - "type", type - ), - text, - additionalProperties.toImmutable(), + checkRequired("type", type), + text, + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -164,18 +138,16 @@ class ChatCompletionContentPartText @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - TEXT, + TEXT } /** * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Type] can contain an unknown value in a couple of cases: - * - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * + * - It was 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 { @@ -185,11 +157,11 @@ class ChatCompletionContentPartText @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -200,11 +172,11 @@ class ChatCompletionContentPartText @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -215,20 +187,23 @@ class ChatCompletionContentPartText @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -237,11 +212,11 @@ class ChatCompletionContentPartText @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPartText && type == other.type && text == other.text && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPartText && type == other.type && text == other.text && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -250,5 +225,6 @@ class ChatCompletionContentPartText @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ChatCompletionContentPartText{type=$type, text=$text, additionalProperties=$additionalProperties}" + override fun toString() = + "ChatCompletionContentPartText{type=$type, text=$text, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 66d851d6..3ae3ad83 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -19,12 +19,15 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class ChatCompletionMessageToolCall @JsonCreator private constructor( +class ChatCompletionMessageToolCall +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("function") @ExcludeMissing private val function: JsonField = JsonMissing.of(), + @JsonProperty("function") + @ExcludeMissing + private val function: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun id(): String = id.getRequired("id") @@ -33,17 +36,11 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("function") - @ExcludeMissing - fun _function(): JsonField = function + @JsonProperty("function") @ExcludeMissing fun _function(): JsonField = function - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -51,18 +48,17 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ChatCompletionMessageToolCall = - apply { - if (validated) { - return@apply - } - - id() - function().validate() - type() - validated = true + fun validate(): ChatCompletionMessageToolCall = apply { + if (validated) { + return@apply } + id() + function().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,15 +68,13 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( * [ChatCompletionMessageToolCall]. * * The following fields are required: - * * ```java * .id() * .function() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ChatCompletionMessageToolCall]. */ @@ -92,95 +86,74 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chatCompletionMessageToolCall: ChatCompletionMessageToolCall) = - apply { - id = chatCompletionMessageToolCall.id - function = chatCompletionMessageToolCall.function - type = chatCompletionMessageToolCall.type - additionalProperties = chatCompletionMessageToolCall.additionalProperties.toMutableMap() - } + internal fun from(chatCompletionMessageToolCall: ChatCompletionMessageToolCall) = apply { + id = chatCompletionMessageToolCall.id + function = chatCompletionMessageToolCall.function + type = chatCompletionMessageToolCall.type + additionalProperties = chatCompletionMessageToolCall.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) - fun function(function: JsonField) = - apply { - this.function = function - } + fun function(function: JsonField) = apply { this.function = function } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChatCompletionMessageToolCall = ChatCompletionMessageToolCall( - checkRequired( - "id", id - ), - checkRequired( - "function", function - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("function", function), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Function @JsonCreator private constructor( - @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Function + @JsonCreator + private constructor( + @JsonProperty("arguments") + @ExcludeMissing + private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun arguments(): String = arguments.getRequired("arguments") fun name(): String = name.getRequired("name") - @JsonProperty("arguments") - @ExcludeMissing - fun _arguments(): JsonField = arguments + @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonField = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -188,17 +161,16 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - arguments() - name() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + arguments() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -207,14 +179,12 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .arguments() * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ @@ -225,71 +195,53 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - arguments = function.arguments - name = function.name - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + arguments = function.arguments + name = function.name + additionalProperties = function.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = - apply { - this.arguments = arguments - } + fun arguments(arguments: JsonField) = apply { this.arguments = arguments } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "arguments", arguments - ), - checkRequired( - "name", name - ), - additionalProperties.toImmutable(), + checkRequired("arguments", arguments), + checkRequired("name", name), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -298,24 +250,21 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -326,18 +275,16 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** * 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 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 { @@ -347,11 +294,11 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -362,11 +309,11 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -377,20 +324,23 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -399,11 +349,11 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionMessageToolCall && id == other.id && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChatCompletionMessageToolCall && id == other.id && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -412,5 +362,6 @@ class ChatCompletionMessageToolCall @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "ChatCompletionMessageToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index d0ec91d3..e5712817 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -31,13 +31,22 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CodeBundle @JsonCreator private constructor( - @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), +class CodeBundle +@JsonCreator +private constructor( + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun bundleId(): String = bundleId.getRequired("bundle_id") @@ -49,22 +58,16 @@ class CodeBundle @JsonCreator private constructor( /** A preview of the code */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) - @JsonProperty("bundle_id") - @ExcludeMissing - fun _bundleId(): JsonField = bundleId + @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId - @JsonProperty("location") - @ExcludeMissing - fun _location(): JsonField = location + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext /** A preview of the code */ - @JsonProperty("preview") - @ExcludeMissing - fun _preview(): JsonField = preview + @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview @JsonAnyGetter @ExcludeMissing @@ -72,19 +75,18 @@ class CodeBundle @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): CodeBundle = - apply { - if (validated) { - return@apply - } - - bundleId() - location().validate() - runtimeContext().validate() - preview() - validated = true + fun validate(): CodeBundle = apply { + if (validated) { + return@apply } + bundleId() + location().validate() + runtimeContext().validate() + preview() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -93,15 +95,13 @@ class CodeBundle @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [CodeBundle]. * * The following fields are required: - * * ```java * .bundleId() * .location() * .runtimeContext() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [CodeBundle]. */ @@ -114,39 +114,32 @@ class CodeBundle @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(codeBundle: CodeBundle) = - apply { - bundleId = codeBundle.bundleId - location = codeBundle.location - runtimeContext = codeBundle.runtimeContext - preview = codeBundle.preview - additionalProperties = codeBundle.additionalProperties.toMutableMap() - } + internal fun from(codeBundle: CodeBundle) = apply { + bundleId = codeBundle.bundleId + location = codeBundle.location + runtimeContext = codeBundle.runtimeContext + preview = codeBundle.preview + additionalProperties = codeBundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = - apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } fun location(location: Location) = location(JsonField.of(location)) - fun location(location: JsonField) = - apply { - this.location = location - } + fun location(location: JsonField) = apply { this.location = location } fun location(experiment: Location.Experiment) = location(Location.ofExperiment(experiment)) fun location(function: Location.Function) = location(Location.ofFunction(function)) - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = - apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = apply { + this.runtimeContext = runtimeContext + } /** A preview of the code */ fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) @@ -155,60 +148,44 @@ class CodeBundle @JsonCreator private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = - apply { - this.preview = preview - } + fun preview(preview: JsonField) = apply { this.preview = preview } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CodeBundle = CodeBundle( - checkRequired( - "bundleId", bundleId - ), - checkRequired( - "location", location - ), - checkRequired( - "runtimeContext", runtimeContext - ), - preview, - additionalProperties.toImmutable(), + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), + preview, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Location.Deserializer::class) @JsonSerialize(using = Location.Serializer::class) - class Location private constructor( + class Location + private constructor( private val experiment: Experiment? = null, private val function: Function? = null, private val _json: JsonValue? = null, - ) { fun experiment(): Optional = Optional.ofNullable(experiment) @@ -226,39 +203,40 @@ class CodeBundle @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - experiment != null -> visitor.visitExperiment(experiment) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + experiment != null -> visitor.visitExperiment(experiment) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Location = - apply { - if (validated) { - return@apply - } + fun validate(): Location = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitExperiment(experiment: Experiment) { - experiment.validate() + experiment.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Location && experiment == other.experiment && function == other.function /* spotless:on */ + return /* spotless:off */ other is Location && experiment == other.experiment && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experiment, function) /* spotless:on */ @@ -273,16 +251,13 @@ class CodeBundle @JsonCreator private constructor( companion object { - @JvmStatic - fun ofExperiment(experiment: Experiment) = Location(experiment = experiment) + @JvmStatic fun ofExperiment(experiment: Experiment) = Location(experiment = experiment) - @JvmStatic - fun ofFunction(function: Function) = Location(function = function) + @JvmStatic fun ofFunction(function: Function) = Location(function = function) } /** - * An interface that defines how to map each variant of [Location] to a value of - * type [T]. + * An interface that defines how to map each variant of [Location] to a value of type [T]. */ interface Visitor { @@ -293,53 +268,67 @@ class CodeBundle @JsonCreator private constructor( /** * Maps an unknown variant of [Location] to a value of type [T]. * - * An instance of [Location] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Location] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Location: $json") + throw BraintrustInvalidDataException("Unknown Location: $json") } } internal class Deserializer : BaseDeserializer(Location::class) { override fun ObjectCodec.deserialize(node: JsonNode): Location { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Location(experiment = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Location(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(experiment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Location(function = it, _json = json) + } - return Location(_json = json) + return Location(_json = json) } } internal class Serializer : BaseSerializer(Location::class) { - override fun serialize(value: Location, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.experiment != null -> generator.writeObject(value.experiment) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Location") - } + override fun serialize( + value: Location, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.experiment != null -> generator.writeObject(value.experiment) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Location") + } } } @NoAutoDetect - class Experiment @JsonCreator private constructor( - @JsonProperty("eval_name") @ExcludeMissing private val evalName: JsonField = JsonMissing.of(), - @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Experiment + @JsonCreator + private constructor( + @JsonProperty("eval_name") + @ExcludeMissing + private val evalName: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun evalName(): String = evalName.getRequired("eval_name") @@ -348,17 +337,13 @@ class CodeBundle @JsonCreator private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("eval_name") - @ExcludeMissing - fun _evalName(): JsonField = evalName + @JsonProperty("eval_name") @ExcludeMissing fun _evalName(): JsonField = evalName @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -366,18 +351,17 @@ class CodeBundle @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Experiment = - apply { - if (validated) { - return@apply - } - - evalName() - position().validate() - type() - validated = true + fun validate(): Experiment = apply { + if (validated) { + return@apply } + evalName() + position().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -386,15 +370,13 @@ class CodeBundle @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Experiment]. * * The following fields are required: - * * ```java * .evalName() * .position() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -406,27 +388,20 @@ class CodeBundle @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = - apply { - evalName = experiment.evalName - position = experiment.position - type = experiment.type - additionalProperties = experiment.additionalProperties.toMutableMap() - } + internal fun from(experiment: Experiment) = apply { + evalName = experiment.evalName + position = experiment.position + type = experiment.type + additionalProperties = experiment.additionalProperties.toMutableMap() + } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) - fun evalName(evalName: JsonField) = - apply { - this.evalName = evalName - } + fun evalName(evalName: JsonField) = apply { this.evalName = evalName } fun position(position: Position) = position(JsonField.of(position)) - fun position(position: JsonField) = - apply { - this.position = position - } + fun position(position: JsonField) = apply { this.position = position } fun position(type: Position.Type) = position(Position.ofType(type)) @@ -434,59 +409,46 @@ class CodeBundle @JsonCreator private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment( - checkRequired( - "evalName", evalName - ), - checkRequired( - "position", position - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("evalName", evalName), + checkRequired("position", position), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position private constructor( + class Position + private constructor( private val type: Type? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, - ) { fun type(): Optional = Optional.ofNullable(type) @@ -504,39 +466,40 @@ class CodeBundle @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - type != null -> visitor.visitType(type) - scorer != null -> visitor.visitScorer(scorer) - else -> visitor.unknown(_json) - } + return when { + type != null -> visitor.visitType(type) + scorer != null -> visitor.visitScorer(scorer) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Position = - apply { - if (validated) { - return@apply - } + fun validate(): Position = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitType(type: Type) { - type.validate() + type.validate() } override fun visitScorer(scorer: Scorer) { - scorer.validate() + scorer.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Position && type == other.type && scorer == other.scorer /* spotless:on */ + return /* spotless:off */ other is Position && type == other.type && scorer == other.scorer /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(type, scorer) /* spotless:on */ @@ -551,11 +514,9 @@ class CodeBundle @JsonCreator private constructor( companion object { - @JvmStatic - fun ofType(type: Type) = Position(type = type) + @JvmStatic fun ofType(type: Type) = Position(type = type) - @JvmStatic - fun ofScorer(scorer: Scorer) = Position(scorer = scorer) + @JvmStatic fun ofScorer(scorer: Scorer) = Position(scorer = scorer) } /** @@ -571,58 +532,66 @@ class CodeBundle @JsonCreator private constructor( /** * Maps an unknown variant of [Position] to a value of type [T]. * - * An instance of [Position] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Position] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } internal class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Position(type = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Position(scorer = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Position(type = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Position(scorer = it, _json = json) + } - return Position(_json = json) + return Position(_json = json) } } internal class Serializer : BaseSerializer(Position::class) { - override fun serialize(value: Position, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.type != null -> generator.writeObject(value.type) - value.scorer != null -> generator.writeObject(value.scorer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } + override fun serialize( + value: Position, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.type != null -> generator.writeObject(value.type) + value.scorer != null -> generator.writeObject(value.scorer) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Position") + } } } @NoAutoDetect - class Type @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Type + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun type(): InnerType = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -630,16 +599,15 @@ class CodeBundle @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Type = - apply { - if (validated) { - return@apply - } - - type() - validated = true + fun validate(): Type = apply { + if (validated) { + return@apply } + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -648,34 +616,29 @@ class CodeBundle @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Type]. * * The following fields are required: - * * ```java * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Type]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(type: Type) = - apply { - this.type = type.type - additionalProperties = type.additionalProperties.toMutableMap() - } + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties = type.additionalProperties.toMutableMap() + } fun type(type: InnerType) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -683,46 +646,37 @@ class CodeBundle @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Type = - Type( - checkRequired( - "type", type - ), additionalProperties.toImmutable() - ) + Type(checkRequired("type", type), additionalProperties.toImmutable()) } - class InnerType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class InnerType + @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. + * 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 @@ -736,25 +690,25 @@ class CodeBundle @JsonCreator private constructor( /** An enum containing [InnerType]'s known values. */ enum class Known { - TASK, + TASK } /** - * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [InnerType] can contain an unknown value in a couple of cases: + * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] + * member. * + * An instance of [InnerType] 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. - * + * 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 { TASK, /** - * An enum member indicating that [InnerType] was instantiated with an unknown - * value. + * An enum member indicating that [InnerType] was instantiated with an + * unknown value. */ _UNKNOWN, } @@ -763,8 +717,8 @@ class CodeBundle @JsonCreator private constructor( * 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. + * 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) { @@ -775,35 +729,41 @@ class CodeBundle @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { TASK -> Known.TASK - else -> throw BraintrustInvalidDataException("Unknown InnerType: $value") + else -> + throw BraintrustInvalidDataException( + "Unknown InnerType: $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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerType && value == other.value /* spotless:on */ + return /* spotless:off */ other is InnerType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -812,11 +772,11 @@ class CodeBundle @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Type && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -825,28 +785,31 @@ class CodeBundle @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Type{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Scorer @JsonCreator private constructor( - @JsonProperty("index") @ExcludeMissing private val index: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Scorer + @JsonCreator + private constructor( + @JsonProperty("index") + @ExcludeMissing + private val index: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun index(): Long = index.getRequired("index") fun type(): Type = type.getRequired("type") - @JsonProperty("index") - @ExcludeMissing - fun _index(): JsonField = index + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -854,17 +817,16 @@ class CodeBundle @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Scorer = - apply { - if (validated) { - return@apply - } - - index() - type() - validated = true + fun validate(): Scorer = apply { + if (validated) { + return@apply } + index() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -873,14 +835,12 @@ class CodeBundle @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Scorer]. * * The following fields are required: - * * ```java * .index() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Scorer]. */ @@ -888,29 +848,23 @@ class CodeBundle @JsonCreator private constructor( private var index: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(scorer: Scorer) = - apply { - index = scorer.index - type = scorer.type - additionalProperties = scorer.additionalProperties.toMutableMap() - } + internal fun from(scorer: Scorer) = apply { + index = scorer.index + type = scorer.type + additionalProperties = scorer.additionalProperties.toMutableMap() + } fun index(index: Long) = index(JsonField.of(index)) - fun index(index: JsonField) = - apply { - this.index = index - } + fun index(index: JsonField) = apply { this.index = index } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -918,50 +872,41 @@ class CodeBundle @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scorer = Scorer( - checkRequired( - "index", index - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("index", index), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -975,23 +920,25 @@ class CodeBundle @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - SCORER, + SCORER } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { SCORER, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -999,8 +946,8 @@ class CodeBundle @JsonCreator private constructor( * 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. + * 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) { @@ -1011,11 +958,11 @@ class CodeBundle @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1026,20 +973,23 @@ class CodeBundle @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1048,11 +998,11 @@ class CodeBundle @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scorer && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scorer && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1061,14 +1011,13 @@ class CodeBundle @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Scorer{index=$index, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Scorer{index=$index, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1078,8 +1027,7 @@ class CodeBundle @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1090,23 +1038,23 @@ class CodeBundle @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - EXPERIMENT, + EXPERIMENT } /** * 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 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 { EXPERIMENT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1130,7 +1078,7 @@ class CodeBundle @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1145,16 +1093,19 @@ class CodeBundle @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1163,11 +1114,11 @@ class CodeBundle @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && evalName == other.evalName && position == other.position && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && evalName == other.evalName && position == other.position && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1176,28 +1127,31 @@ class CodeBundle @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Experiment{evalName=$evalName, position=$position, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Experiment{evalName=$evalName, position=$position, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function @JsonCreator private constructor( - @JsonProperty("index") @ExcludeMissing private val index: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Function + @JsonCreator + private constructor( + @JsonProperty("index") + @ExcludeMissing + private val index: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun index(): Long = index.getRequired("index") fun type(): Type = type.getRequired("type") - @JsonProperty("index") - @ExcludeMissing - fun _index(): JsonField = index + @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1205,17 +1159,16 @@ class CodeBundle @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - index() - type() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + index() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1224,14 +1177,12 @@ class CodeBundle @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .index() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ @@ -1242,69 +1193,52 @@ class CodeBundle @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - index = function.index - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + index = function.index + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun index(index: Long) = index(JsonField.of(index)) - fun index(index: JsonField) = - apply { - this.index = index - } + fun index(index: JsonField) = apply { this.index = index } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "index", index - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("index", index), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1314,8 +1248,7 @@ class CodeBundle @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1326,23 +1259,23 @@ class CodeBundle @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** * 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 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 { FUNCTION, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1366,7 +1299,7 @@ class CodeBundle @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1381,16 +1314,19 @@ class CodeBundle @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1399,11 +1335,11 @@ class CodeBundle @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && index == other.index && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1412,29 +1348,32 @@ class CodeBundle @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{index=$index, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{index=$index, type=$type, additionalProperties=$additionalProperties}" } } @NoAutoDetect - class RuntimeContext @JsonCreator private constructor( - @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RuntimeContext + @JsonCreator + private constructor( + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun runtime(): Runtime = runtime.getRequired("runtime") fun version(): String = version.getRequired("version") - @JsonProperty("runtime") - @ExcludeMissing - fun _runtime(): JsonField = runtime + @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1442,17 +1381,16 @@ class CodeBundle @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = - apply { - if (validated) { - return@apply - } - - runtime() - version() - validated = true + fun validate(): RuntimeContext = apply { + if (validated) { + return@apply } + runtime() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1461,14 +1399,12 @@ class CodeBundle @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [RuntimeContext]. * * The following fields are required: - * * ```java * .runtime() * .version() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1479,80 +1415,59 @@ class CodeBundle @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = - apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = - apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired( - "runtime", runtime - ), - checkRequired( - "version", version - ), - additionalProperties.toImmutable(), + checkRequired("runtime", runtime), + checkRequired("version", version), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Runtime @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1573,17 +1488,17 @@ class CodeBundle @JsonCreator private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] 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 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 { NODE, PYTHON, - /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Runtime] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1591,8 +1506,8 @@ class CodeBundle @JsonCreator private constructor( * 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. + * 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) { @@ -1608,7 +1523,7 @@ class CodeBundle @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1623,17 +1538,20 @@ class CodeBundle @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1642,11 +1560,11 @@ class CodeBundle @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1655,15 +1573,16 @@ class CodeBundle @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CodeBundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CodeBundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1672,5 +1591,6 @@ class CodeBundle @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "CodeBundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, additionalProperties=$additionalProperties}" + override fun toString() = + "CodeBundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index e27dc4bd..ba204bc6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -20,16 +20,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CreateApiKeyOutput @JsonCreator private constructor( +class CreateApiKeyOutput +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("key") @ExcludeMissing private val key: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("preview_name") @ExcludeMissing private val previewName: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("preview_name") + @ExcludeMissing + private val previewName: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the api key */ @@ -53,38 +60,26 @@ class CreateApiKeyOutput @JsonCreator private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the api key */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The raw API key. It will only be exposed this one time */ - @JsonProperty("key") - @ExcludeMissing - fun _key(): JsonField = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** Name of the api key */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("preview_name") @ExcludeMissing fun _previewName(): JsonField = previewName /** Date of api key creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Unique identifier for the user */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -92,22 +87,21 @@ class CreateApiKeyOutput @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): CreateApiKeyOutput = - apply { - if (validated) { - return@apply - } - - id() - key() - name() - previewName() - created() - orgId() - userId() - validated = true + fun validate(): CreateApiKeyOutput = apply { + if (validated) { + return@apply } + id() + key() + name() + previewName() + created() + orgId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -116,7 +110,6 @@ class CreateApiKeyOutput @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [CreateApiKeyOutput]. * * The following fields are required: - * * ```java * .id() * .key() @@ -124,8 +117,7 @@ class CreateApiKeyOutput @JsonCreator private constructor( * .previewName() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [CreateApiKeyOutput]. */ @@ -141,51 +133,38 @@ class CreateApiKeyOutput @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(createApiKeyOutput: CreateApiKeyOutput) = - apply { - id = createApiKeyOutput.id - key = createApiKeyOutput.key - name = createApiKeyOutput.name - previewName = createApiKeyOutput.previewName - created = createApiKeyOutput.created - orgId = createApiKeyOutput.orgId - userId = createApiKeyOutput.userId - additionalProperties = createApiKeyOutput.additionalProperties.toMutableMap() - } + internal fun from(createApiKeyOutput: CreateApiKeyOutput) = apply { + id = createApiKeyOutput.id + key = createApiKeyOutput.key + name = createApiKeyOutput.name + previewName = createApiKeyOutput.previewName + created = createApiKeyOutput.created + orgId = createApiKeyOutput.orgId + userId = createApiKeyOutput.userId + additionalProperties = createApiKeyOutput.additionalProperties.toMutableMap() + } /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** The raw API key. It will only be exposed this one time */ fun key(key: String) = key(JsonField.of(key)) /** The raw API key. It will only be exposed this one time */ - fun key(key: JsonField) = - apply { - this.key = key - } + fun key(key: JsonField) = apply { this.key = key } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) /** Name of the api key */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - fun previewName(previewName: JsonField) = - apply { - this.previewName = previewName - } + fun previewName(previewName: JsonField) = apply { this.previewName = previewName } /** Date of api key creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -194,10 +173,7 @@ class CreateApiKeyOutput @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of api key creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the organization */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) @@ -206,10 +182,7 @@ class CreateApiKeyOutput @JsonCreator private constructor( fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the user */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -218,64 +191,46 @@ class CreateApiKeyOutput @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Unique identifier for the user */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CreateApiKeyOutput = CreateApiKeyOutput( - checkRequired( - "id", id - ), - checkRequired( - "key", key - ), - checkRequired( - "name", name - ), - checkRequired( - "previewName", previewName - ), - created, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("key", key), + checkRequired("name", name), + checkRequired("previewName", previewName), + created, + orgId, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && key == other.key && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateApiKeyOutput && id == other.id && key == other.key && name == other.name && previewName == other.previewName && created == other.created && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -284,5 +239,6 @@ class CreateApiKeyOutput @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "CreateApiKeyOutput{id=$id, key=$key, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "CreateApiKeyOutput{id=$id, key=$key, name=$name, previewName=$previewName, created=$created, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index d2255c0a..b6a00359 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -18,27 +18,34 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class CrossObjectInsertResponse @JsonCreator private constructor( - @JsonProperty("dataset") @ExcludeMissing private val dataset: JsonField = JsonMissing.of(), - @JsonProperty("experiment") @ExcludeMissing private val experiment: JsonField = JsonMissing.of(), - @JsonProperty("project_logs") @ExcludeMissing private val projectLogs: JsonField = JsonMissing.of(), +class CrossObjectInsertResponse +@JsonCreator +private constructor( + @JsonProperty("dataset") + @ExcludeMissing + private val dataset: JsonField = JsonMissing.of(), + @JsonProperty("experiment") + @ExcludeMissing + private val experiment: JsonField = JsonMissing.of(), + @JsonProperty("project_logs") + @ExcludeMissing + private val projectLogs: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(): Optional = Optional.ofNullable(dataset.getNullable("dataset")) /** A mapping from experiment id to row ids for inserted `events` */ - fun experiment(): Optional = Optional.ofNullable(experiment.getNullable("experiment")) + fun experiment(): Optional = + Optional.ofNullable(experiment.getNullable("experiment")) /** A mapping from project id to row ids for inserted `events` */ - fun projectLogs(): Optional = Optional.ofNullable(projectLogs.getNullable("project_logs")) + fun projectLogs(): Optional = + Optional.ofNullable(projectLogs.getNullable("project_logs")) /** A mapping from dataset id to row ids for inserted `events` */ - @JsonProperty("dataset") - @ExcludeMissing - fun _dataset(): JsonField = dataset + @JsonProperty("dataset") @ExcludeMissing fun _dataset(): JsonField = dataset /** A mapping from experiment id to row ids for inserted `events` */ @JsonProperty("experiment") @@ -56,28 +63,25 @@ class CrossObjectInsertResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): CrossObjectInsertResponse = - apply { - if (validated) { - return@apply - } - - dataset().ifPresent { it.validate() } - experiment().ifPresent { it.validate() } - projectLogs().ifPresent { it.validate() } - validated = true + fun validate(): CrossObjectInsertResponse = apply { + if (validated) { + return@apply } + dataset().ifPresent { it.validate() } + experiment().ifPresent { it.validate() } + projectLogs().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [CrossObjectInsertResponse]. + * Returns a mutable builder for constructing an instance of [CrossObjectInsertResponse]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [CrossObjectInsertResponse]. */ @@ -89,13 +93,12 @@ class CrossObjectInsertResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(crossObjectInsertResponse: CrossObjectInsertResponse) = - apply { - dataset = crossObjectInsertResponse.dataset - experiment = crossObjectInsertResponse.experiment - projectLogs = crossObjectInsertResponse.projectLogs - additionalProperties = crossObjectInsertResponse.additionalProperties.toMutableMap() - } + internal fun from(crossObjectInsertResponse: CrossObjectInsertResponse) = apply { + dataset = crossObjectInsertResponse.dataset + experiment = crossObjectInsertResponse.experiment + projectLogs = crossObjectInsertResponse.projectLogs + additionalProperties = crossObjectInsertResponse.additionalProperties.toMutableMap() + } /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(dataset: Dataset?) = dataset(JsonField.ofNullable(dataset)) @@ -104,10 +107,7 @@ class CrossObjectInsertResponse @JsonCreator private constructor( fun dataset(dataset: Optional) = dataset(dataset.getOrNull()) /** A mapping from dataset id to row ids for inserted `events` */ - fun dataset(dataset: JsonField) = - apply { - this.dataset = dataset - } + fun dataset(dataset: JsonField) = apply { this.dataset = dataset } /** A mapping from experiment id to row ids for inserted `events` */ fun experiment(experiment: Experiment?) = experiment(JsonField.ofNullable(experiment)) @@ -116,10 +116,7 @@ class CrossObjectInsertResponse @JsonCreator private constructor( fun experiment(experiment: Optional) = experiment(experiment.getOrNull()) /** A mapping from experiment id to row ids for inserted `events` */ - fun experiment(experiment: JsonField) = - apply { - this.experiment = experiment - } + fun experiment(experiment: JsonField) = apply { this.experiment = experiment } /** A mapping from project id to row ids for inserted `events` */ fun projectLogs(projectLogs: ProjectLogs?) = projectLogs(JsonField.ofNullable(projectLogs)) @@ -128,51 +125,45 @@ class CrossObjectInsertResponse @JsonCreator private constructor( fun projectLogs(projectLogs: Optional) = projectLogs(projectLogs.getOrNull()) /** A mapping from project id to row ids for inserted `events` */ - fun projectLogs(projectLogs: JsonField) = - apply { - this.projectLogs = projectLogs - } + fun projectLogs(projectLogs: JsonField) = apply { + this.projectLogs = projectLogs + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): CrossObjectInsertResponse = CrossObjectInsertResponse( - dataset, - experiment, - projectLogs, - additionalProperties.toImmutable(), + dataset, + experiment, + projectLogs, + additionalProperties.toImmutable(), ) } /** A mapping from dataset id to row ids for inserted `events` */ @NoAutoDetect - class Dataset @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Dataset + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -181,22 +172,20 @@ class CrossObjectInsertResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Dataset = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Dataset = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Dataset]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Dataset]. */ @@ -205,46 +194,38 @@ class CrossObjectInsertResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataset: Dataset) = - apply { - additionalProperties = dataset.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(dataset: Dataset) = apply { + additionalProperties = dataset.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Dataset = Dataset(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Dataset && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -258,9 +239,11 @@ class CrossObjectInsertResponse @JsonCreator private constructor( /** A mapping from experiment id to row ids for inserted `events` */ @NoAutoDetect - class Experiment @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Experiment + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -269,22 +252,20 @@ class CrossObjectInsertResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Experiment = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Experiment = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Experiment]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -293,46 +274,38 @@ class CrossObjectInsertResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = - apply { - additionalProperties = experiment.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(experiment: Experiment) = apply { + additionalProperties = experiment.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -346,9 +319,11 @@ class CrossObjectInsertResponse @JsonCreator private constructor( /** A mapping from project id to row ids for inserted `events` */ @NoAutoDetect - class ProjectLogs @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class ProjectLogs + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -357,22 +332,20 @@ class CrossObjectInsertResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ProjectLogs = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): ProjectLogs = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectLogs]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectLogs]. */ @@ -381,46 +354,38 @@ class CrossObjectInsertResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogs: ProjectLogs) = - apply { - additionalProperties = projectLogs.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(projectLogs: ProjectLogs) = apply { + additionalProperties = projectLogs.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectLogs = ProjectLogs(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogs && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -433,11 +398,11 @@ class CrossObjectInsertResponse @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is CrossObjectInsertResponse && dataset == other.dataset && experiment == other.experiment && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CrossObjectInsertResponse && dataset == other.dataset && experiment == other.experiment && projectLogs == other.projectLogs && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -446,5 +411,6 @@ class CrossObjectInsertResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "CrossObjectInsertResponse{dataset=$dataset, experiment=$experiment, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" + override fun toString() = + "CrossObjectInsertResponse{dataset=$dataset, experiment=$experiment, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index fc846ec3..25297bb3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -18,10 +18,13 @@ import java.util.Objects /** Summary of a dataset's data */ @NoAutoDetect -class DataSummary @JsonCreator private constructor( - @JsonProperty("total_records") @ExcludeMissing private val totalRecords: JsonField = JsonMissing.of(), +class DataSummary +@JsonCreator +private constructor( + @JsonProperty("total_records") + @ExcludeMissing + private val totalRecords: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Total number of records in the dataset */ @@ -38,16 +41,15 @@ class DataSummary @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): DataSummary = - apply { - if (validated) { - return@apply - } - - totalRecords() - validated = true + fun validate(): DataSummary = apply { + if (validated) { + return@apply } + totalRecords() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -56,13 +58,11 @@ class DataSummary @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [DataSummary]. * * The following fields are required: - * * ```java * .totalRecords() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DataSummary]. */ @@ -72,61 +72,49 @@ class DataSummary @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataSummary: DataSummary) = - apply { - totalRecords = dataSummary.totalRecords - additionalProperties = dataSummary.additionalProperties.toMutableMap() - } + internal fun from(dataSummary: DataSummary) = apply { + totalRecords = dataSummary.totalRecords + additionalProperties = dataSummary.additionalProperties.toMutableMap() + } /** Total number of records in the dataset */ fun totalRecords(totalRecords: Long) = totalRecords(JsonField.of(totalRecords)) /** Total number of records in the dataset */ - fun totalRecords(totalRecords: JsonField) = - apply { - this.totalRecords = totalRecords - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun totalRecords(totalRecords: JsonField) = apply { this.totalRecords = totalRecords } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DataSummary = DataSummary( - checkRequired( - "totalRecords", totalRecords - ), additionalProperties.toImmutable() + checkRequired("totalRecords", totalRecords), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DataSummary && totalRecords == other.totalRecords && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DataSummary && totalRecords == other.totalRecords && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -135,5 +123,6 @@ class DataSummary @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" + override fun toString() = + "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 6a36285e..6a1818a9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -20,17 +20,30 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Dataset @JsonCreator private constructor( +class Dataset +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the dataset */ @@ -46,10 +59,12 @@ class Dataset @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the dataset */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -58,24 +73,16 @@ class Dataset @JsonCreator private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the dataset */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Date of dataset creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of dataset deletion, or null if the dataset is still active */ @JsonProperty("deleted_at") @@ -83,19 +90,13 @@ class Dataset @JsonCreator private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the dataset */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Identifies the user who created the dataset */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -103,23 +104,22 @@ class Dataset @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Dataset = - apply { - if (validated) { - return@apply - } - - id() - name() - projectId() - created() - deletedAt() - description() - metadata().ifPresent { it.validate() } - userId() - validated = true + fun validate(): Dataset = apply { + if (validated) { + return@apply } + id() + name() + projectId() + created() + deletedAt() + description() + metadata().ifPresent { it.validate() } + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -128,15 +128,13 @@ class Dataset @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Dataset]. * * The following fields are required: - * * ```java * .id() * .name() * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Dataset]. */ @@ -153,45 +151,35 @@ class Dataset @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dataset: Dataset) = - apply { - id = dataset.id - name = dataset.name - projectId = dataset.projectId - created = dataset.created - deletedAt = dataset.deletedAt - description = dataset.description - metadata = dataset.metadata - userId = dataset.userId - additionalProperties = dataset.additionalProperties.toMutableMap() - } + internal fun from(dataset: Dataset) = apply { + id = dataset.id + name = dataset.name + projectId = dataset.projectId + created = dataset.created + deletedAt = dataset.deletedAt + description = dataset.description + metadata = dataset.metadata + userId = dataset.userId + additionalProperties = dataset.additionalProperties.toMutableMap() + } /** Unique identifier for the dataset */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the dataset */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Date of dataset creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -200,10 +188,7 @@ class Dataset @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of dataset creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date of dataset deletion, or null if the dataset is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -212,10 +197,7 @@ class Dataset @JsonCreator private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of dataset deletion, or null if the dataset is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -224,10 +206,7 @@ class Dataset @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -236,10 +215,7 @@ class Dataset @JsonCreator private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Identifies the user who created the dataset */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -248,62 +224,48 @@ class Dataset @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the dataset */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Dataset = Dataset( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - created, - deletedAt, - description, - metadata, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + created, + deletedAt, + description, + metadata, + userId, + additionalProperties.toImmutable(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -312,22 +274,20 @@ class Dataset @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -336,46 +296,38 @@ class Dataset @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -388,11 +340,11 @@ class Dataset @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Dataset && id == other.id && name == other.name && projectId == other.projectId && created == other.created && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Dataset && id == other.id && name == other.name && projectId == other.projectId && created == other.created && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -401,5 +353,6 @@ class Dataset @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Dataset{id=$id, name=$name, projectId=$projectId, created=$created, deletedAt=$deletedAt, description=$description, metadata=$metadata, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "Dataset{id=$id, name=$name, projectId=$projectId, created=$created, deletedAt=$deletedAt, description=$description, metadata=$metadata, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 7930ddda..be5669c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -22,15 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new dataset. If there is an existing dataset in the project with the - * same name as the one specified in the request, will return the existing dataset - * unmodified + * Create a new dataset. If there is an existing dataset in the project with the same name as the + * one specified in the request, will return the existing dataset unmodified */ -class DatasetCreateParams private constructor( +class DatasetCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the dataset. Within a project, dataset names are unique */ @@ -63,21 +62,30 @@ class DatasetCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the dataset. Within a project, dataset names are unique */ @@ -87,20 +95,17 @@ class DatasetCreateParams private constructor( fun projectId(): String = projectId.getRequired("project_id") /** Textual description of the dataset */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Textual description of the dataset */ @JsonProperty("description") @@ -108,9 +113,7 @@ class DatasetCreateParams private constructor( fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing @@ -118,19 +121,18 @@ class DatasetCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - description() - metadata().ifPresent { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + description() + metadata().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -139,14 +141,12 @@ class DatasetCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -159,32 +159,25 @@ class DatasetCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - description = body.description - metadata = body.metadata - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + description = body.description + metadata = body.metadata + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -193,10 +186,9 @@ class DatasetCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -205,57 +197,43 @@ class DatasetCreateParams private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - description, - metadata, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + description, + metadata, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -264,7 +242,8 @@ class DatasetCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -275,14 +254,12 @@ class DatasetCreateParams private constructor( * Returns a mutable builder for constructing an instance of [DatasetCreateParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetCreateParams]. */ @@ -294,231 +271,174 @@ class DatasetCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetCreateParams: DatasetCreateParams) = - apply { - body = datasetCreateParams.body.toBuilder() - additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetCreateParams: DatasetCreateParams) = apply { + body = datasetCreateParams.body.toBuilder() + additionalHeaders = datasetCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetCreateParams.additionalQueryParams.toBuilder() + } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Textual description of the dataset */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the dataset */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata?) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the dataset */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetCreateParams = DatasetCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -527,22 +447,20 @@ class DatasetCreateParams private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -551,46 +469,38 @@ class DatasetCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -603,14 +513,15 @@ class DatasetCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 708741d2..8f43631d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a dataset object by its id */ -class DatasetDeleteParams private constructor( +class DatasetDeleteParams +private constructor( private val datasetId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Dataset id */ @@ -31,17 +31,18 @@ class DatasetDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -52,13 +53,11 @@ class DatasetDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [DatasetDeleteParams]. * * The following fields are required: - * * ```java * .datasetId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetDeleteParams]. */ @@ -71,190 +70,155 @@ class DatasetDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetDeleteParams: DatasetDeleteParams) = - apply { - datasetId = datasetDeleteParams.datasetId - additionalHeaders = datasetDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = datasetDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(datasetDeleteParams: DatasetDeleteParams) = apply { + datasetId = datasetDeleteParams.datasetId + additionalHeaders = datasetDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = datasetDeleteParams.additionalBodyProperties.toMutableMap() + } /** Dataset id */ - fun datasetId(datasetId: String) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): DatasetDeleteParams = DatasetDeleteParams( - checkRequired( - "datasetId", datasetId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("datasetId", datasetId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is DatasetDeleteParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "DatasetDeleteParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 65781e58..9552e3d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -23,35 +23,55 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class DatasetEvent @JsonCreator private constructor( +class DatasetEvent +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("is_root") + @ExcludeMissing + private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the dataset (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -68,38 +88,30 @@ class DatasetEvent @JsonCreator private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full trace. + * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on + * tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected(): JsonValue = expected - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable + * The output of your application, including post-processing (an arbitrary, JSON serializable * object) */ - @JsonProperty("input") - @ExcludeMissing - fun _input(): JsonValue = input + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -110,78 +122,54 @@ class DatasetEvent @JsonCreator private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the dataset (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** A unique identifier for the trace this dataset event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full trace. + * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on + * tracing */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId(): JsonField = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** Whether this span is a root span */ - @JsonProperty("is_root") - @ExcludeMissing - fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Indicates the event was copied from another object. */ - @JsonProperty("origin") - @ExcludeMissing - fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -189,26 +177,25 @@ class DatasetEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): DatasetEvent = - apply { - if (validated) { - return@apply - } - - id() - _xactId() - created() - datasetId() - projectId() - rootSpanId() - spanId() - isRoot() - metadata().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - tags() - validated = true + fun validate(): DatasetEvent = apply { + if (validated) { + return@apply } + id() + _xactId() + created() + datasetId() + projectId() + rootSpanId() + spanId() + isRoot() + metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -217,7 +204,6 @@ class DatasetEvent @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [DatasetEvent]. * * The following fields are required: - * * ```java * .id() * ._xactId() @@ -228,8 +214,7 @@ class DatasetEvent @JsonCreator private constructor( * .spanId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetEvent]. */ @@ -251,130 +236,97 @@ class DatasetEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetEvent: DatasetEvent) = - apply { - id = datasetEvent.id - _xactId = datasetEvent._xactId - created = datasetEvent.created - datasetId = datasetEvent.datasetId - projectId = datasetEvent.projectId - rootSpanId = datasetEvent.rootSpanId - spanId = datasetEvent.spanId - expected = datasetEvent.expected - input = datasetEvent.input - isRoot = datasetEvent.isRoot - metadata = datasetEvent.metadata - origin = datasetEvent.origin - tags = datasetEvent.tags.map { it.toMutableList() } - additionalProperties = datasetEvent.additionalProperties.toMutableMap() - } + internal fun from(datasetEvent: DatasetEvent) = apply { + id = datasetEvent.id + _xactId = datasetEvent._xactId + created = datasetEvent.created + datasetId = datasetEvent.datasetId + projectId = datasetEvent.projectId + rootSpanId = datasetEvent.rootSpanId + spanId = datasetEvent.spanId + expected = datasetEvent.expected + input = datasetEvent.input + isRoot = datasetEvent.isRoot + metadata = datasetEvent.metadata + origin = datasetEvent.origin + tags = datasetEvent.tags.map { it.toMutableList() } + additionalProperties = datasetEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the dataset (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the dataset (see the `version` parameter) */ - fun _xactId(_xactId: JsonField) = - apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the dataset event was created */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the dataset */ fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) /** Unique identifier for the dataset */ - fun datasetId(datasetId: JsonField) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A unique identifier for the trace this dataset event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this dataset event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = - apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different dataset events together as part of a - * full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different dataset events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - fun spanId(spanId: JsonField) = - apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - fun expected(expected: JsonValue) = - apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - fun input(input: JsonValue) = - apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -386,40 +338,34 @@ class DatasetEvent @JsonCreator private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = - apply { - this.isRoot = isRoot - } + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -428,10 +374,7 @@ class DatasetEvent @JsonCreator private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = - apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -440,89 +383,66 @@ class DatasetEvent @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DatasetEvent = DatasetEvent( - checkRequired( - "id", id - ), - checkRequired( - "_xactId", _xactId - ), - checkRequired( - "created", created - ), - checkRequired( - "datasetId", datasetId - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "rootSpanId", rootSpanId - ), - checkRequired( - "spanId", spanId - ), - expected, - input, - isRoot, - metadata, - origin, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("created", created), + checkRequired("datasetId", datasetId), + checkRequired("projectId", projectId), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), + expected, + input, + isRoot, + metadata, + origin, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -531,22 +451,20 @@ class DatasetEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -555,46 +473,38 @@ class DatasetEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -608,13 +518,21 @@ class DatasetEvent @JsonCreator private constructor( /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin @JsonCreator private constructor( + class Origin + @JsonCreator + private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** ID of the original event. */ @@ -630,19 +548,13 @@ class DatasetEvent @JsonCreator private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -655,19 +567,18 @@ class DatasetEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Origin = - apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true + fun validate(): Origin = apply { + if (validated) { + return@apply } + id() + _xactId() + objectId() + objectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -676,7 +587,6 @@ class DatasetEvent @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: - * * ```java * .id() * ._xactId() @@ -684,8 +594,7 @@ class DatasetEvent @JsonCreator private constructor( * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Origin]. */ @@ -698,111 +607,82 @@ class DatasetEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = - apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = - apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = - apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired( - "id", id - ), - checkRequired( - "_xactId", _xactId - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -835,11 +715,9 @@ class DatasetEvent @JsonCreator private constructor( * 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 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 { @@ -860,8 +738,8 @@ class DatasetEvent @JsonCreator private constructor( * 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. + * 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) { @@ -881,7 +759,7 @@ class DatasetEvent @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -900,17 +778,20 @@ class DatasetEvent @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -919,11 +800,11 @@ class DatasetEvent @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -932,15 +813,16 @@ class DatasetEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && datasetId == other.datasetId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && origin == other.origin && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetEvent && id == other.id && _xactId == other._xactId && created == other.created && datasetId == other.datasetId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && origin == other.origin && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -949,5 +831,6 @@ class DatasetEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, datasetId=$datasetId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, origin=$origin, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, datasetId=$datasetId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, origin=$origin, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index fe58a5b8..1b7d0197 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of dataset events */ -class DatasetFeedbackParams private constructor( +class DatasetFeedbackParams +private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Dataset id */ @@ -44,25 +44,28 @@ class DatasetFeedbackParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("feedback") + @ExcludeMissing + private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of dataset feedback items */ @@ -79,16 +82,15 @@ class DatasetFeedbackParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - feedback().forEach { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + feedback().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,13 +99,11 @@ class DatasetFeedbackParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .feedback() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,69 +113,59 @@ class DatasetFeedbackParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of dataset feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of dataset feedback items */ - fun feedback(feedback: JsonField>) = - apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of dataset feedback items */ - fun addFeedback(feedback: FeedbackDatasetItem) = - apply { - this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackDatasetItem) = apply { + this.feedback = + (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "feedback", feedback - ).map { it.toImmutable() }, additionalProperties.toImmutable() + checkRequired("feedback", feedback).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -184,7 +174,8 @@ class DatasetFeedbackParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -192,18 +183,15 @@ class DatasetFeedbackParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [DatasetFeedbackParams]. + * Returns a mutable builder for constructing an instance of [DatasetFeedbackParams]. * * The following fields are required: - * * ```java * .datasetId() * .feedback() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetFeedbackParams]. */ @@ -216,209 +204,163 @@ class DatasetFeedbackParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = - apply { - datasetId = datasetFeedbackParams.datasetId - body = datasetFeedbackParams.body.toBuilder() - additionalHeaders = datasetFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFeedbackParams: DatasetFeedbackParams) = apply { + datasetId = datasetFeedbackParams.datasetId + body = datasetFeedbackParams.body.toBuilder() + additionalHeaders = datasetFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFeedbackParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset feedback items */ - fun feedback(feedback: List) = - apply { - body.feedback(feedback) - } + fun feedback(feedback: List) = apply { body.feedback(feedback) } /** A list of dataset feedback items */ - fun feedback(feedback: JsonField>) = - apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = apply { + body.feedback(feedback) + } /** A list of dataset feedback items */ - fun addFeedback(feedback: FeedbackDatasetItem) = - apply { - body.addFeedback(feedback) - } + fun addFeedback(feedback: FeedbackDatasetItem) = apply { body.addFeedback(feedback) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFeedbackParams = DatasetFeedbackParams( - checkRequired( - "datasetId", datasetId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("datasetId", datasetId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFeedbackParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetFeedbackParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetFeedbackParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index a1612e8b..e045595c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -12,11 +12,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but - * with the parameters in the URL query rather than in the request body. For more - * complex queries, use the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use the + * `POST /btql` endpoint. */ -class DatasetFetchParams private constructor( +class DatasetFetchParams +private constructor( private val datasetId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -24,7 +25,6 @@ class DatasetFetchParams private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Dataset id */ @@ -33,55 +33,52 @@ class DatasetFetchParams private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -92,36 +89,20 @@ class DatasetFetchParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.maxRootSpanId?.let { - queryParams.put( - "max_root_span_id", listOf(it.toString()) - ) - } - this.maxXactId?.let { - queryParams.put( - "max_xact_id", listOf(it.toString()) - ) - } - this.version?.let { - queryParams.put( - "version", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -132,13 +113,11 @@ class DatasetFetchParams private constructor( * Returns a mutable builder for constructing an instance of [DatasetFetchParams]. * * The following fields are required: - * * ```java * .datasetId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetFetchParams]. */ @@ -154,310 +133,263 @@ class DatasetFetchParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFetchParams: DatasetFetchParams) = - apply { - datasetId = datasetFetchParams.datasetId - limit = datasetFetchParams.limit - maxRootSpanId = datasetFetchParams.maxRootSpanId - maxXactId = datasetFetchParams.maxXactId - version = datasetFetchParams.version - additionalHeaders = datasetFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFetchParams: DatasetFetchParams) = apply { + datasetId = datasetFetchParams.datasetId + limit = datasetFetchParams.limit + maxRootSpanId = datasetFetchParams.maxRootSpanId + maxXactId = datasetFetchParams.maxXactId + version = datasetFetchParams.version + additionalHeaders = datasetFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFetchParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = - apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String?) = - apply { - this.version = version - } + fun version(version: String?) = apply { this.version = version } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFetchParams = DatasetFetchParams( - checkRequired( - "datasetId", datasetId - ), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("datasetId", datasetId), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFetchParams && datasetId == other.datasetId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index d0c8d415..02ffad07 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -22,146 +22,138 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but - * with the parameters in the request body rather than in the URL query. For more - * complex queries, use the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use the + * `POST /btql` endpoint. */ -class DatasetFetchPostParams private constructor( +class DatasetFetchPostParams +private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Dataset id */ fun datasetId(): String = datasetId /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun _version(): JsonField = body._version() @@ -171,168 +163,169 @@ class DatasetFetchPostParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") + @ExcludeMissing + private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") + @ExcludeMissing + private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") + @ExcludeMissing + private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = + Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = + Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor(): JsonField = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - @JsonProperty("limit") - @ExcludeMissing - fun _limit(): JsonField = limit + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_xact_id") - @ExcludeMissing - fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -340,27 +333,25 @@ class DatasetFetchPostParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -374,284 +365,261 @@ class DatasetFetchPostParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: JsonField) = - apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ - fun limit(limit: JsonField) = - apply { - this.limit = limit - } + fun limit(limit: JsonField) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = + maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = - apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = - apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ - fun version(version: JsonField) = - apply { - this.version = version - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -660,7 +628,8 @@ class DatasetFetchPostParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -668,17 +637,14 @@ class DatasetFetchPostParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [DatasetFetchPostParams]. + * Returns a mutable builder for constructing an instance of [DatasetFetchPostParams]. * * The following fields are required: - * * ```java * .datasetId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetFetchPostParams]. */ @@ -691,431 +657,358 @@ class DatasetFetchPostParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = - apply { - datasetId = datasetFetchPostParams.datasetId - body = datasetFetchPostParams.body.toBuilder() - additionalHeaders = datasetFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetFetchPostParams: DatasetFetchPostParams) = apply { + datasetId = datasetFetchPostParams.datasetId + body = datasetFetchPostParams.body.toBuilder() + additionalHeaders = datasetFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetFetchPostParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: String?) = - apply { - body.cursor(cursor) - } + fun cursor(cursor: String?) = apply { body.cursor(cursor) } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: JsonField) = - apply { - body.cursor(cursor) - } + fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long?) = - apply { - body.limit(limit) - } + fun limit(limit: Long?) = apply { body.limit(limit) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: JsonField) = - apply { - body.limit(limit) - } + fun limit(limit: JsonField) = apply { body.limit(limit) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = - apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = - apply { - body.maxXactId(maxXactId) - } + fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = - apply { - body.maxXactId(maxXactId) - } + fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String?) = - apply { - body.version(version) - } + fun version(version: String?) = apply { body.version(version) } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: JsonField) = - apply { - body.version(version) - } + fun version(version: JsonField) = apply { body.version(version) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetFetchPostParams = DatasetFetchPostParams( - checkRequired( - "datasetId", datasetId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("datasetId", datasetId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetFetchPostParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetFetchPostParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetFetchPostParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index dc6fca8e..043cce99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the dataset */ -class DatasetInsertParams private constructor( +class DatasetInsertParams +private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Dataset id */ @@ -44,25 +44,28 @@ class DatasetInsertParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of dataset events to insert */ @@ -79,16 +82,15 @@ class DatasetInsertParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - events().forEach { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + events().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,13 +99,11 @@ class DatasetInsertParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,69 +113,59 @@ class DatasetInsertParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of dataset events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of dataset events to insert */ - fun events(events: JsonField>) = - apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } /** A list of dataset events to insert */ - fun addEvent(event: InsertDatasetEvent) = - apply { - events = (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertDatasetEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "events", events - ).map { it.toImmutable() }, additionalProperties.toImmutable() + checkRequired("events", events).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -195,14 +185,12 @@ class DatasetInsertParams private constructor( * Returns a mutable builder for constructing an instance of [DatasetInsertParams]. * * The following fields are required: - * * ```java * .datasetId() * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetInsertParams]. */ @@ -215,209 +203,161 @@ class DatasetInsertParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetInsertParams: DatasetInsertParams) = - apply { - datasetId = datasetInsertParams.datasetId - body = datasetInsertParams.body.toBuilder() - additionalHeaders = datasetInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetInsertParams: DatasetInsertParams) = apply { + datasetId = datasetInsertParams.datasetId + body = datasetInsertParams.body.toBuilder() + additionalHeaders = datasetInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetInsertParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** A list of dataset events to insert */ - fun events(events: List) = - apply { - body.events(events) - } + fun events(events: List) = apply { body.events(events) } /** A list of dataset events to insert */ - fun events(events: JsonField>) = - apply { - body.events(events) - } + fun events(events: JsonField>) = apply { body.events(events) } /** A list of dataset events to insert */ - fun addEvent(event: InsertDatasetEvent) = - apply { - body.addEvent(event) - } + fun addEvent(event: InsertDatasetEvent) = apply { body.addEvent(event) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetInsertParams = DatasetInsertParams( - checkRequired( - "datasetId", datasetId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("datasetId", datasetId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetInsertParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetInsertParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetInsertParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index 6218008e..ae489e32 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.DatasetService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all datasets. The datasets are sorted by creation date, with the most - * recently-created datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most recently-created + * datasets coming first */ -class DatasetListPage private constructor( +class DatasetListPage +private constructor( private val datasetsService: DatasetService, private val params: DatasetListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class DatasetListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListPage && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is DatasetListPage && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ - override fun toString() = "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" + override fun toString() = + "DatasetListPage{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + DatasetListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + DatasetListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { datasetsService.list(it) } + return getNextPageParams().map { datasetsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +84,16 @@ class DatasetListPage private constructor( @JvmStatic fun of(datasetsService: DatasetService, params: DatasetListParams, response: Response) = - DatasetListPage( - datasetsService, - params, - response, - ) + DatasetListPage(datasetsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +107,34 @@ class DatasetListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [DatasetListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +143,39 @@ class DatasetListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: DatasetListPage, + class AutoPager(private val firstPage: DatasetListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index 574330d5..edf89d75 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.DatasetServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all datasets. The datasets are sorted by creation date, with the most - * recently-created datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most recently-created + * datasets coming first */ -class DatasetListPageAsync private constructor( +class DatasetListPageAsync +private constructor( private val datasetsService: DatasetServiceAsync, private val params: DatasetListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class DatasetListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListPageAsync && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is DatasetListPageAsync && datasetsService == other.datasetsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetsService, params, response) /* spotless:on */ - override fun toString() = "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" + override fun toString() = + "DatasetListPageAsync{datasetsService=$datasetsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + DatasetListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + DatasetListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - datasetsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { datasetsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,20 @@ class DatasetListPageAsync private constructor( companion object { @JvmStatic - fun of(datasetsService: DatasetServiceAsync, params: DatasetListParams, response: Response) = - DatasetListPageAsync( - datasetsService, - params, - response, - ) + fun of( + datasetsService: DatasetServiceAsync, + params: DatasetListParams, + response: Response, + ) = DatasetListPageAsync(datasetsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,38 +112,34 @@ class DatasetListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** - * Returns a mutable builder for constructing an instance of - * [DatasetListPageAsync]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [DatasetListPageAsync]. */ + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +148,46 @@ class DatasetListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: DatasetListPageAsync, - - ) { + class AutoPager(private val firstPage: DatasetListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Dataset) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Dataset) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 63b098eb..5ae454e3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all datasets. The datasets are sorted by creation date, with the most - * recently-created datasets coming first + * List out all datasets. The datasets are sorted by creation date, with the most recently-created + * datasets coming first */ -class DatasetListParams private constructor( +class DatasetListParams +private constructor( private val datasetName: String?, private val endingBefore: String?, private val ids: Ids?, @@ -37,7 +38,6 @@ class DatasetListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the dataset to search for */ @@ -46,15 +46,15 @@ class DatasetListParams private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ class DatasetListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,61 +86,27 @@ class DatasetListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.datasetName?.let { - queryParams.put( - "dataset_name", listOf(it.toString()) - ) - } - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.projectId?.let { - queryParams.put( - "project_id", listOf(it.toString()) - ) - } - this.projectName?.let { - queryParams.put( - "project_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.datasetName?.let { queryParams.put("dataset_name", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): DatasetListParams = builder().build() + @JvmStatic fun none(): DatasetListParams = builder().build() /** Returns a mutable builder for constructing an instance of [DatasetListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetListParams]. */ @@ -159,25 +125,21 @@ class DatasetListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetListParams: DatasetListParams) = - apply { - datasetName = datasetListParams.datasetName - endingBefore = datasetListParams.endingBefore - ids = datasetListParams.ids - limit = datasetListParams.limit - orgName = datasetListParams.orgName - projectId = datasetListParams.projectId - projectName = datasetListParams.projectName - startingAfter = datasetListParams.startingAfter - additionalHeaders = datasetListParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetListParams: DatasetListParams) = apply { + datasetName = datasetListParams.datasetName + endingBefore = datasetListParams.endingBefore + ids = datasetListParams.ids + limit = datasetListParams.limit + orgName = datasetListParams.orgName + projectId = datasetListParams.projectId + projectName = datasetListParams.projectName + startingAfter = datasetListParams.startingAfter + additionalHeaders = datasetListParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetListParams.additionalQueryParams.toBuilder() + } /** Name of the dataset to search for */ - fun datasetName(datasetName: String?) = - apply { - this.datasetName = datasetName - } + fun datasetName(datasetName: String?) = apply { this.datasetName = datasetName } /** Name of the dataset to search for */ fun datasetName(datasetName: Optional) = datasetName(datasetName.getOrNull()) @@ -185,56 +147,47 @@ class DatasetListParams private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -243,28 +196,19 @@ class DatasetListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = - apply { - this.projectName = projectName - } + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -272,174 +216,146 @@ class DatasetListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetListParams = DatasetListParams( - datasetName, - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + datasetName, + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -457,19 +373,19 @@ class DatasetListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -484,17 +400,12 @@ class DatasetListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -504,56 +415,60 @@ class DatasetListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetListParams && datasetName == other.datasetName && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetName, endingBefore, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index 96f02be2..a75b190a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a dataset object by its id */ -class DatasetRetrieveParams private constructor( +class DatasetRetrieveParams +private constructor( private val datasetId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Dataset id */ @@ -29,10 +29,10 @@ class DatasetRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class DatasetRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [DatasetRetrieveParams]. + * Returns a mutable builder for constructing an instance of [DatasetRetrieveParams]. * * The following fields are required: - * * ```java * .datasetId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetRetrieveParams]. */ @@ -62,162 +59,131 @@ class DatasetRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = - apply { - datasetId = datasetRetrieveParams.datasetId - additionalHeaders = datasetRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetRetrieveParams: DatasetRetrieveParams) = apply { + datasetId = datasetRetrieveParams.datasetId + additionalHeaders = datasetRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetRetrieveParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetRetrieveParams = DatasetRetrieveParams( - checkRequired( - "datasetId", datasetId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("datasetId", datasetId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetRetrieveParams && datasetId == other.datasetId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetRetrieveParams{datasetId=$datasetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index b1a3a575..bea55242 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -12,21 +12,18 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Summarize dataset */ -class DatasetSummarizeParams private constructor( +class DatasetSummarizeParams +private constructor( private val datasetId: String, private val summarizeData: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Dataset id */ fun datasetId(): String = datasetId - /** - * Whether to summarize the data. If false (or omitted), only the metadata will be - * returned. - */ + /** Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ fun summarizeData(): Optional = Optional.ofNullable(summarizeData) fun _additionalHeaders(): Headers = additionalHeaders @@ -36,21 +33,17 @@ class DatasetSummarizeParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.summarizeData?.let { - queryParams.put( - "summarize_data", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.summarizeData?.let { queryParams.put("summarize_data", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -58,17 +51,14 @@ class DatasetSummarizeParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [DatasetSummarizeParams]. + * Returns a mutable builder for constructing an instance of [DatasetSummarizeParams]. * * The following fields are required: - * * ```java * .datasetId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetSummarizeParams]. */ @@ -81,185 +71,149 @@ class DatasetSummarizeParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = - apply { - datasetId = datasetSummarizeParams.datasetId - summarizeData = datasetSummarizeParams.summarizeData - additionalHeaders = datasetSummarizeParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetSummarizeParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetSummarizeParams: DatasetSummarizeParams) = apply { + datasetId = datasetSummarizeParams.datasetId + summarizeData = datasetSummarizeParams.summarizeData + additionalHeaders = datasetSummarizeParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetSummarizeParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** - * Whether to summarize the data. If false (or omitted), only the metadata will be - * returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ - fun summarizeData(summarizeData: Boolean?) = - apply { - this.summarizeData = summarizeData - } + fun summarizeData(summarizeData: Boolean?) = apply { this.summarizeData = summarizeData } /** - * Whether to summarize the data. If false (or omitted), only the metadata will be - * returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ fun summarizeData(summarizeData: Boolean) = summarizeData(summarizeData as Boolean?) /** - * Whether to summarize the data. If false (or omitted), only the metadata will be - * returned. + * Whether to summarize the data. If false (or omitted), only the metadata will be returned. */ - fun summarizeData(summarizeData: Optional) = summarizeData(summarizeData.getOrNull()) + fun summarizeData(summarizeData: Optional) = + summarizeData(summarizeData.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetSummarizeParams = DatasetSummarizeParams( - checkRequired( - "datasetId", datasetId - ), - summarizeData, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("datasetId", datasetId), + summarizeData, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetSummarizeParams && datasetId == other.datasetId && summarizeData == other.summarizeData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, summarizeData, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index dc748441..a125d34b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a dataset object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. */ -class DatasetUpdateParams private constructor( +class DatasetUpdateParams +private constructor( private val datasetId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Dataset id */ @@ -61,31 +61,39 @@ class DatasetUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Textual description of the dataset */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the dataset */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -99,14 +107,10 @@ class DatasetUpdateParams private constructor( fun _description(): JsonField = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -114,25 +118,23 @@ class DatasetUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - description() - metadata().ifPresent { it.validate() } - name() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + description() + metadata().ifPresent { it.validate() } + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -144,13 +146,12 @@ class DatasetUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - description = body.description - metadata = body.metadata - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + description = body.description + metadata = body.metadata + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -159,10 +160,9 @@ class DatasetUpdateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -171,10 +171,7 @@ class DatasetUpdateParams private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -183,52 +180,37 @@ class DatasetUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = - apply { - this.name = name - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body( - description, - metadata, - name, - additionalProperties.toImmutable(), - ) + Body(description, metadata, name, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -237,7 +219,8 @@ class DatasetUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -248,13 +231,11 @@ class DatasetUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [DatasetUpdateParams]. * * The following fields are required: - * * ```java * .datasetId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetUpdateParams]. */ @@ -267,232 +248,176 @@ class DatasetUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(datasetUpdateParams: DatasetUpdateParams) = - apply { - datasetId = datasetUpdateParams.datasetId - body = datasetUpdateParams.body.toBuilder() - additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(datasetUpdateParams: DatasetUpdateParams) = apply { + datasetId = datasetUpdateParams.datasetId + body = datasetUpdateParams.body.toBuilder() + additionalHeaders = datasetUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = datasetUpdateParams.additionalQueryParams.toBuilder() + } /** Dataset id */ - fun datasetId(datasetId: String) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } /** Textual description of the dataset */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the dataset */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the dataset */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata?) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the dataset */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the dataset */ - fun metadata(metadata: JsonField) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): DatasetUpdateParams = DatasetUpdateParams( - checkRequired( - "datasetId", datasetId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("datasetId", datasetId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the dataset */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -501,22 +426,20 @@ class DatasetUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -525,46 +448,38 @@ class DatasetUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -577,14 +492,15 @@ class DatasetUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is DatasetUpdateParams && datasetId == other.datasetId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "DatasetUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "DatasetUpdateParams{datasetId=$datasetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 7cf44815..10a99c22 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -22,15 +22,24 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class EnvVar @JsonCreator private constructor( +class EnvVar +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("used") @ExcludeMissing private val used: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("used") + @ExcludeMissing + private val used: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the environment variable */ @@ -52,19 +61,13 @@ class EnvVar @JsonCreator private constructor( fun used(): Optional = Optional.ofNullable(used.getNullable("used")) /** Unique identifier for the environment variable */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The name of the environment variable */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -72,14 +75,10 @@ class EnvVar @JsonCreator private constructor( fun _objectType(): JsonField = objectType /** Date of environment variable creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date the environment variable was last used */ - @JsonProperty("used") - @ExcludeMissing - fun _used(): JsonField = used + @JsonProperty("used") @ExcludeMissing fun _used(): JsonField = used @JsonAnyGetter @ExcludeMissing @@ -87,21 +86,20 @@ class EnvVar @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): EnvVar = - apply { - if (validated) { - return@apply - } - - id() - name() - objectId() - objectType() - created() - used() - validated = true + fun validate(): EnvVar = apply { + if (validated) { + return@apply } + id() + name() + objectId() + objectType() + created() + used() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -110,7 +108,6 @@ class EnvVar @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [EnvVar]. * * The following fields are required: - * * ```java * .id() * .name() @@ -118,8 +115,7 @@ class EnvVar @JsonCreator private constructor( * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EnvVar]. */ @@ -134,52 +130,39 @@ class EnvVar @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVar: EnvVar) = - apply { - id = envVar.id - name = envVar.name - objectId = envVar.objectId - objectType = envVar.objectType - created = envVar.created - used = envVar.used - additionalProperties = envVar.additionalProperties.toMutableMap() - } + internal fun from(envVar: EnvVar) = apply { + id = envVar.id + name = envVar.name + objectId = envVar.objectId + objectType = envVar.objectType + created = envVar.created + used = envVar.used + additionalProperties = envVar.additionalProperties.toMutableMap() + } /** Unique identifier for the environment variable */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the environment variable */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = - apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } /** Date of environment variable creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -188,10 +171,7 @@ class EnvVar @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of environment variable creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date the environment variable was last used */ fun used(used: OffsetDateTime?) = used(JsonField.ofNullable(used)) @@ -200,73 +180,51 @@ class EnvVar @JsonCreator private constructor( fun used(used: Optional) = used(used.getOrNull()) /** Date the environment variable was last used */ - fun used(used: JsonField) = - apply { - this.used = used - } + fun used(used: JsonField) = apply { this.used = used } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): EnvVar = EnvVar( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - created, - used, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + created, + used, + additionalProperties.toImmutable(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -290,11 +248,9 @@ class EnvVar @JsonCreator private constructor( * 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 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 { @@ -302,18 +258,17 @@ class EnvVar @JsonCreator private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -326,11 +281,11 @@ class EnvVar @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -343,20 +298,23 @@ class EnvVar @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -365,11 +323,11 @@ class EnvVar @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVar && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVar && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && created == other.created && used == other.used && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -378,5 +336,6 @@ class EnvVar @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "EnvVar{id=$id, name=$name, objectId=$objectId, objectType=$objectType, created=$created, used=$used, additionalProperties=$additionalProperties}" + override fun toString() = + "EnvVar{id=$id, name=$name, objectId=$objectId, objectType=$objectType, created=$created, used=$used, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 2861902e..b088aebe 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -24,14 +24,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new env_var. If there is an existing env_var with the same name as the - * one specified in the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the one specified in + * the request, will return the existing env_var unmodified */ -class EnvVarCreateParams private constructor( +class EnvVarCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** The name of the environment variable */ @@ -64,21 +64,30 @@ class EnvVarCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the environment variable */ @@ -94,14 +103,10 @@ class EnvVarCreateParams private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -109,9 +114,7 @@ class EnvVarCreateParams private constructor( fun _objectType(): JsonField = objectType /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -119,19 +122,18 @@ class EnvVarCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - objectId() - objectType() - value() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + objectId() + objectType() + value() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -140,15 +142,13 @@ class EnvVarCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -161,41 +161,33 @@ class EnvVarCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = - apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -204,59 +196,43 @@ class EnvVarCreateParams private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = - apply { - this.value = value - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - value, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + value, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -265,7 +241,8 @@ class EnvVarCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -276,15 +253,13 @@ class EnvVarCreateParams private constructor( * Returns a mutable builder for constructing an instance of [EnvVarCreateParams]. * * The following fields are required: - * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EnvVarCreateParams]. */ @@ -296,239 +271,176 @@ class EnvVarCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarCreateParams: EnvVarCreateParams) = - apply { - body = envVarCreateParams.body.toBuilder() - additionalHeaders = envVarCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarCreateParams: EnvVarCreateParams) = apply { + body = envVarCreateParams.body.toBuilder() + additionalHeaders = envVarCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarCreateParams.additionalQueryParams.toBuilder() + } /** The name of the environment variable */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** The name of the environment variable */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: String) = apply { body.objectId(objectId) } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = - apply { - body.objectType(objectType) - } + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = - apply { - body.objectType(objectType) - } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = - apply { - body.value(value) - } + fun value(value: String?) = apply { body.value(value) } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = - apply { - body.value(value) - } + fun value(value: JsonField) = apply { body.value(value) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarCreateParams = EnvVarCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -552,11 +464,9 @@ class EnvVarCreateParams private constructor( * 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 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 { @@ -564,18 +474,17 @@ class EnvVarCreateParams private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -588,11 +497,11 @@ class EnvVarCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -605,20 +514,23 @@ class EnvVarCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -627,14 +539,15 @@ class EnvVarCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "EnvVarCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "EnvVarCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index 2d714d22..d9d09741 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an env_var object by its id */ -class EnvVarDeleteParams private constructor( +class EnvVarDeleteParams +private constructor( private val envVarId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** EnvVar id */ @@ -31,17 +31,18 @@ class EnvVarDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -52,13 +53,11 @@ class EnvVarDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [EnvVarDeleteParams]. * * The following fields are required: - * * ```java * .envVarId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EnvVarDeleteParams]. */ @@ -71,190 +70,155 @@ class EnvVarDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarDeleteParams: EnvVarDeleteParams) = - apply { - envVarId = envVarDeleteParams.envVarId - additionalHeaders = envVarDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = envVarDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(envVarDeleteParams: EnvVarDeleteParams) = apply { + envVarId = envVarDeleteParams.envVarId + additionalHeaders = envVarDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = envVarDeleteParams.additionalBodyProperties.toMutableMap() + } /** EnvVar id */ - fun envVarId(envVarId: String) = - apply { - this.envVarId = envVarId - } + fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): EnvVarDeleteParams = EnvVarDeleteParams( - checkRequired( - "envVarId", envVarId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("envVarId", envVarId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarDeleteParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "EnvVarDeleteParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } 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 53e139bb..b0e9f3c4 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 @@ -26,10 +26,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all env_vars. The env_vars are sorted by creation date, with the most - * recently-created env_vars coming first + * List out all env_vars. The env_vars are sorted by creation date, with the most recently-created + * env_vars coming first */ -class EnvVarListParams private constructor( +class EnvVarListParams +private constructor( private val envVarName: String?, private val ids: Ids?, private val limit: Long?, @@ -37,15 +38,14 @@ class EnvVarListParams private constructor( private val objectType: ObjectType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the env_var to search for */ fun envVarName(): Optional = Optional.ofNullable(envVarName) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,46 +65,24 @@ class EnvVarListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.envVarName?.let { - queryParams.put( - "env_var_name", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.objectId?.let { - queryParams.put( - "object_id", listOf(it.toString()) - ) - } - this.objectType?.let { - queryParams.put( - "object_type", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.envVarName?.let { queryParams.put("env_var_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.objectId?.let { queryParams.put("object_id", listOf(it.toString())) } + this.objectType?.let { queryParams.put("object_type", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): EnvVarListParams = builder().build() + @JvmStatic fun none(): EnvVarListParams = builder().build() /** Returns a mutable builder for constructing an instance of [EnvVarListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EnvVarListParams]. */ @@ -120,58 +98,48 @@ class EnvVarListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarListParams: EnvVarListParams) = - apply { - envVarName = envVarListParams.envVarName - ids = envVarListParams.ids - limit = envVarListParams.limit - objectId = envVarListParams.objectId - objectType = envVarListParams.objectType - additionalHeaders = envVarListParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarListParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarListParams: EnvVarListParams) = apply { + envVarName = envVarListParams.envVarName + ids = envVarListParams.ids + limit = envVarListParams.limit + objectId = envVarListParams.objectId + objectType = envVarListParams.objectType + additionalHeaders = envVarListParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarListParams.additionalQueryParams.toBuilder() + } /** Name of the env_var to search for */ - fun envVarName(envVarName: String?) = - apply { - this.envVarName = envVarName - } + fun envVarName(envVarName: String?) = apply { this.envVarName = envVarName } /** Name of the env_var to search for */ fun envVarName(envVarName: Optional) = envVarName(envVarName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -180,170 +148,138 @@ class EnvVarListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String?) = - apply { - this.objectId = objectId - } + fun objectId(objectId: String?) = apply { this.objectId = objectId } /** The id of the object the environment variable is scoped for */ 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: ObjectType?) = apply { this.objectType = objectType } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: Optional) = objectType(objectType.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarListParams = EnvVarListParams( - envVarName, - ids, - limit, - objectId, - objectType, - additionalHeaders.build(), - additionalQueryParams.build(), + envVarName, + ids, + limit, + objectId, + objectType, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -361,19 +297,19 @@ class EnvVarListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -388,17 +324,12 @@ class EnvVarListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -408,63 +339,62 @@ class EnvVarListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -488,11 +418,9 @@ class EnvVarListParams private constructor( * 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 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 { @@ -500,18 +428,17 @@ class EnvVarListParams private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -524,11 +451,11 @@ class EnvVarListParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -541,20 +468,23 @@ class EnvVarListParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -563,14 +493,15 @@ class EnvVarListParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarListParams && envVarName == other.envVarName && ids == other.ids && limit == other.limit && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarName, ids, limit, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "EnvVarListParams{envVarName=$envVarName, ids=$ids, limit=$limit, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 405f6428..014c0040 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -18,19 +18,20 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class EnvVarListResponse @JsonCreator private constructor( - @JsonProperty("objects") @ExcludeMissing private val objects: JsonField> = JsonMissing.of(), +class EnvVarListResponse +@JsonCreator +private constructor( + @JsonProperty("objects") + @ExcludeMissing + private val objects: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** A list of env_var objects */ fun objects(): List = objects.getRequired("objects") /** A list of env_var objects */ - @JsonProperty("objects") - @ExcludeMissing - fun _objects(): JsonField> = objects + @JsonProperty("objects") @ExcludeMissing fun _objects(): JsonField> = objects @JsonAnyGetter @ExcludeMissing @@ -38,16 +39,15 @@ class EnvVarListResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): EnvVarListResponse = - apply { - if (validated) { - return@apply - } - - objects().forEach { it.validate() } - validated = true + fun validate(): EnvVarListResponse = apply { + if (validated) { + return@apply } + objects().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -56,13 +56,11 @@ class EnvVarListResponse @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [EnvVarListResponse]. * * The following fields are required: - * * ```java * .objects() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EnvVarListResponse]. */ @@ -72,69 +70,59 @@ class EnvVarListResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(envVarListResponse: EnvVarListResponse) = - apply { - objects = envVarListResponse.objects.map { it.toMutableList() } - additionalProperties = envVarListResponse.additionalProperties.toMutableMap() - } + internal fun from(envVarListResponse: EnvVarListResponse) = apply { + objects = envVarListResponse.objects.map { it.toMutableList() } + additionalProperties = envVarListResponse.additionalProperties.toMutableMap() + } /** A list of env_var objects */ fun objects(objects: List) = objects(JsonField.of(objects)) /** A list of env_var objects */ - fun objects(objects: JsonField>) = - apply { - this.objects = objects.map { it.toMutableList() } - } + fun objects(objects: JsonField>) = apply { + this.objects = objects.map { it.toMutableList() } + } /** A list of env_var objects */ - fun addObject(object_: EnvVar) = - apply { - objects = (objects ?: JsonField.of(mutableListOf())).also { + fun addObject(object_: EnvVar) = apply { + objects = + (objects ?: JsonField.of(mutableListOf())).also { checkKnown("objects", it).add(object_) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): EnvVarListResponse = EnvVarListResponse( - checkRequired( - "objects", objects - ).map { it.toImmutable() }, additionalProperties.toImmutable() + checkRequired("objects", objects).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarListResponse && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnvVarListResponse && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -143,5 +131,6 @@ class EnvVarListResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "EnvVarListResponse{objects=$objects, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index 38c2e079..da9d9b85 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -24,15 +24,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace env_var. If there is an existing env_var with the same name as - * the one specified in the request, will replace the existing env_var with the - * provided fields + * Create or replace env_var. If there is an existing env_var with the same name as the one + * specified in the request, will replace the existing env_var with the provided fields */ -class EnvVarReplaceParams private constructor( +class EnvVarReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** The name of the environment variable */ @@ -65,21 +64,30 @@ class EnvVarReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the environment variable */ @@ -95,14 +103,10 @@ class EnvVarReplaceParams private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the environment variable is scoped for */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The type of the object the environment variable is scoped for */ @JsonProperty("object_type") @@ -110,9 +114,7 @@ class EnvVarReplaceParams private constructor( fun _objectType(): JsonField = objectType /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -120,19 +122,18 @@ class EnvVarReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - objectId() - objectType() - value() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + objectId() + objectType() + value() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -141,15 +142,13 @@ class EnvVarReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -162,41 +161,33 @@ class EnvVarReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = - apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -205,59 +196,43 @@ class EnvVarReplaceParams private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = - apply { - this.value = value - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - value, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + value, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -266,7 +241,8 @@ class EnvVarReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, objectId=$objectId, objectType=$objectType, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -277,15 +253,13 @@ class EnvVarReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [EnvVarReplaceParams]. * * The following fields are required: - * * ```java * .name() * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EnvVarReplaceParams]. */ @@ -297,239 +271,176 @@ class EnvVarReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarReplaceParams: EnvVarReplaceParams) = - apply { - body = envVarReplaceParams.body.toBuilder() - additionalHeaders = envVarReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarReplaceParams: EnvVarReplaceParams) = apply { + body = envVarReplaceParams.body.toBuilder() + additionalHeaders = envVarReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarReplaceParams.additionalQueryParams.toBuilder() + } /** The name of the environment variable */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** The name of the environment variable */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: String) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: String) = apply { body.objectId(objectId) } /** The id of the object the environment variable is scoped for */ - fun objectId(objectId: JsonField) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: ObjectType) = - apply { - body.objectType(objectType) - } + fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } /** The type of the object the environment variable is scoped for */ - fun objectType(objectType: JsonField) = - apply { - body.objectType(objectType) - } + fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = - apply { - body.value(value) - } + fun value(value: String?) = apply { body.value(value) } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = - apply { - body.value(value) - } + fun value(value: JsonField) = apply { body.value(value) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarReplaceParams = EnvVarReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the object the environment variable is scoped for */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -553,11 +464,9 @@ class EnvVarReplaceParams private constructor( * 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 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 { @@ -565,18 +474,17 @@ class EnvVarReplaceParams private constructor( PROJECT, FUNCTION, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -589,11 +497,11 @@ class EnvVarReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -606,20 +514,23 @@ class EnvVarReplaceParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -628,14 +539,15 @@ class EnvVarReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "EnvVarReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "EnvVarReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index ef2d0266..0e424916 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an env_var object by its id */ -class EnvVarRetrieveParams private constructor( +class EnvVarRetrieveParams +private constructor( private val envVarId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** EnvVar id */ @@ -29,10 +29,10 @@ class EnvVarRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class EnvVarRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [EnvVarRetrieveParams]. + * Returns a mutable builder for constructing an instance of [EnvVarRetrieveParams]. * * The following fields are required: - * * ```java * .envVarId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EnvVarRetrieveParams]. */ @@ -62,162 +59,131 @@ class EnvVarRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = - apply { - envVarId = envVarRetrieveParams.envVarId - additionalHeaders = envVarRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarRetrieveParams: EnvVarRetrieveParams) = apply { + envVarId = envVarRetrieveParams.envVarId + additionalHeaders = envVarRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarRetrieveParams.additionalQueryParams.toBuilder() + } /** EnvVar id */ - fun envVarId(envVarId: String) = - apply { - this.envVarId = envVarId - } + fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( - checkRequired( - "envVarId", envVarId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("envVarId", envVarId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarRetrieveParams && envVarId == other.envVarId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "EnvVarRetrieveParams{envVarId=$envVarId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index a937e768..11d4bded 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an env_var object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. */ -class EnvVarUpdateParams private constructor( +class EnvVarUpdateParams +private constructor( private val envVarId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** EnvVar id */ @@ -55,26 +55,31 @@ class EnvVarUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> envVarId - else -> "" - } + return when (index) { + 0 -> envVarId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the environment variable */ @@ -84,14 +89,10 @@ class EnvVarUpdateParams private constructor( fun value(): Optional = Optional.ofNullable(value.getNullable("value")) /** The name of the environment variable */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The value of the environment variable. Will be encrypted at rest. */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -99,17 +100,16 @@ class EnvVarUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - value() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + value() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -118,13 +118,11 @@ class EnvVarUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -135,21 +133,17 @@ class EnvVarUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - value = body.value - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + value = body.value + additionalProperties = body.additionalProperties.toMutableMap() + } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) /** The name of the environment variable */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) @@ -158,53 +152,37 @@ class EnvVarUpdateParams private constructor( fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = - apply { - this.value = value - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body( - checkRequired( - "name", name - ), - value, - additionalProperties.toImmutable(), - ) + Body(checkRequired("name", name), value, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -213,7 +191,8 @@ class EnvVarUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, value=$value, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -224,14 +203,12 @@ class EnvVarUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [EnvVarUpdateParams]. * * The following fields are required: - * * ```java * .envVarId() * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EnvVarUpdateParams]. */ @@ -244,218 +221,167 @@ class EnvVarUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(envVarUpdateParams: EnvVarUpdateParams) = - apply { - envVarId = envVarUpdateParams.envVarId - body = envVarUpdateParams.body.toBuilder() - additionalHeaders = envVarUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = envVarUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(envVarUpdateParams: EnvVarUpdateParams) = apply { + envVarId = envVarUpdateParams.envVarId + body = envVarUpdateParams.body.toBuilder() + additionalHeaders = envVarUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = envVarUpdateParams.additionalQueryParams.toBuilder() + } /** EnvVar id */ - fun envVarId(envVarId: String) = - apply { - this.envVarId = envVarId - } + fun envVarId(envVarId: String) = apply { this.envVarId = envVarId } /** The name of the environment variable */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** The name of the environment variable */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: String?) = - apply { - body.value(value) - } + fun value(value: String?) = apply { body.value(value) } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: Optional) = value(value.getOrNull()) /** The value of the environment variable. Will be encrypted at rest. */ - fun value(value: JsonField) = - apply { - body.value(value) - } + fun value(value: JsonField) = apply { body.value(value) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): EnvVarUpdateParams = EnvVarUpdateParams( - checkRequired( - "envVarId", envVarId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("envVarId", envVarId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EnvVarUpdateParams && envVarId == other.envVarId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(envVarId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "EnvVarUpdateParams{envVarId=$envVarId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "EnvVarUpdateParams{envVarId=$envVarId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 63803002..84bb86ae 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -35,18 +35,17 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is - * built into the Braintrust SDK. In the Eval API, you provide pointers to a - * dataset, task function, and scoring functions. The API will then run the - * evaluation, create an experiment, and return the results along with a link to - * the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into the + * Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and scoring + * functions. The API will then run the evaluation, create an experiment, and return the results + * along with a link to the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ -class EvalCreateParams private constructor( +class EvalCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** The dataset to use */ @@ -62,26 +61,26 @@ class EvalCreateParams private constructor( fun task(): Task = body.task() /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ fun baseExperimentId(): Optional = body.baseExperimentId() /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ fun baseExperimentName(): Optional = body.baseExperimentName() /** - * An optional name for the experiment created by this eval. If it conflicts with - * an existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with an existing + * experiment, it will be suffixed with a unique identifier. */ fun experimentName(): Optional = body.experimentName() /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. */ fun gitMetadataSettings(): Optional = body.gitMetadataSettings() @@ -89,14 +88,14 @@ class EvalCreateParams private constructor( fun isPublic(): Optional = body.isPublic() /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in + * which case there is no max concurrency. */ fun maxConcurrency(): Optional = body.maxConcurrency() /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use this to + * slice & dice across experiments. */ fun metadata(): Optional = body.metadata() @@ -104,22 +103,22 @@ class EvalCreateParams private constructor( fun repoInfo(): Optional = body.repoInfo() /** - * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. - * If false, the request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two events: one + * to indicate the experiment has started, and another upon completion. If false, the request + * will return the evaluation's summary upon completion. */ fun stream(): Optional = body.stream() /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which + * case there is no timeout. */ fun timeout(): Optional = body.timeout() /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. */ fun trialCount(): Optional = body.trialCount() @@ -136,26 +135,26 @@ class EvalCreateParams private constructor( fun _task(): JsonField = body._task() /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ fun _baseExperimentId(): JsonField = body._baseExperimentId() /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ fun _baseExperimentName(): JsonField = body._baseExperimentName() /** - * An optional name for the experiment created by this eval. If it conflicts with - * an existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with an existing + * experiment, it will be suffixed with a unique identifier. */ fun _experimentName(): JsonField = body._experimentName() /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. */ fun _gitMetadataSettings(): JsonField = body._gitMetadataSettings() @@ -163,14 +162,14 @@ class EvalCreateParams private constructor( fun _isPublic(): JsonField = body._isPublic() /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in + * which case there is no max concurrency. */ fun _maxConcurrency(): JsonField = body._maxConcurrency() /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use this to + * slice & dice across experiments. */ fun _metadata(): JsonField = body._metadata() @@ -178,22 +177,22 @@ class EvalCreateParams private constructor( fun _repoInfo(): JsonField = body._repoInfo() /** - * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. - * If false, the request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two events: one + * to indicate the experiment has started, and another upon completion. If false, the request + * will return the evaluation's summary upon completion. */ fun _stream(): JsonField = body._stream() /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which + * case there is no timeout. */ fun _timeout(): JsonField = body._timeout() /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. */ fun _trialCount(): JsonField = body._trialCount() @@ -203,32 +202,59 @@ class EvalCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( + class Body + @JsonCreator + private constructor( @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("scores") @ExcludeMissing private val scores: JsonField> = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField> = JsonMissing.of(), @JsonProperty("task") @ExcludeMissing private val task: JsonField = JsonMissing.of(), - @JsonProperty("base_experiment_id") @ExcludeMissing private val baseExperimentId: JsonField = JsonMissing.of(), - @JsonProperty("base_experiment_name") @ExcludeMissing private val baseExperimentName: JsonField = JsonMissing.of(), - @JsonProperty("experiment_name") @ExcludeMissing private val experimentName: JsonField = JsonMissing.of(), - @JsonProperty("git_metadata_settings") @ExcludeMissing private val gitMetadataSettings: JsonField = JsonMissing.of(), - @JsonProperty("is_public") @ExcludeMissing private val isPublic: JsonField = JsonMissing.of(), - @JsonProperty("max_concurrency") @ExcludeMissing private val maxConcurrency: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), - @JsonProperty("stream") @ExcludeMissing private val stream: JsonField = JsonMissing.of(), - @JsonProperty("timeout") @ExcludeMissing private val timeout: JsonField = JsonMissing.of(), - @JsonProperty("trial_count") @ExcludeMissing private val trialCount: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("base_experiment_id") + @ExcludeMissing + private val baseExperimentId: JsonField = JsonMissing.of(), + @JsonProperty("base_experiment_name") + @ExcludeMissing + private val baseExperimentName: JsonField = JsonMissing.of(), + @JsonProperty("experiment_name") + @ExcludeMissing + private val experimentName: JsonField = JsonMissing.of(), + @JsonProperty("git_metadata_settings") + @ExcludeMissing + private val gitMetadataSettings: JsonField = JsonMissing.of(), + @JsonProperty("is_public") + @ExcludeMissing + private val isPublic: JsonField = JsonMissing.of(), + @JsonProperty("max_concurrency") + @ExcludeMissing + private val maxConcurrency: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") + @ExcludeMissing + private val repoInfo: JsonField = JsonMissing.of(), + @JsonProperty("stream") + @ExcludeMissing + private val stream: JsonField = JsonMissing.of(), + @JsonProperty("timeout") + @ExcludeMissing + private val timeout: JsonField = JsonMissing.of(), + @JsonProperty("trial_count") + @ExcludeMissing + private val trialCount: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The dataset to use */ @@ -244,41 +270,46 @@ class EvalCreateParams private constructor( fun task(): Task = task.getRequired("task") /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentId(): Optional = Optional.ofNullable(baseExperimentId.getNullable("base_experiment_id")) + fun baseExperimentId(): Optional = + Optional.ofNullable(baseExperimentId.getNullable("base_experiment_id")) /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentName(): Optional = Optional.ofNullable(baseExperimentName.getNullable("base_experiment_name")) + fun baseExperimentName(): Optional = + Optional.ofNullable(baseExperimentName.getNullable("base_experiment_name")) /** - * An optional name for the experiment created by this eval. If it conflicts with - * an existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(): Optional = Optional.ofNullable(experimentName.getNullable("experiment_name")) + fun experimentName(): Optional = + Optional.ofNullable(experimentName.getNullable("experiment_name")) /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. */ - fun gitMetadataSettings(): Optional = Optional.ofNullable(gitMetadataSettings.getNullable("git_metadata_settings")) + fun gitMetadataSettings(): Optional = + Optional.ofNullable(gitMetadataSettings.getNullable("git_metadata_settings")) /** Whether the experiment should be public. Defaults to false. */ fun isPublic(): Optional = Optional.ofNullable(isPublic.getNullable("is_public")) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ - fun maxConcurrency(): Optional = Optional.ofNullable(maxConcurrency.getNullable("max_concurrency")) + fun maxConcurrency(): Optional = + Optional.ofNullable(maxConcurrency.getNullable("max_concurrency")) /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use this + * to slice & dice across experiments. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -286,124 +317,107 @@ class EvalCreateParams private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** - * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. - * If false, the request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two events: + * one to indicate the experiment has started, and another upon completion. If false, the + * request will return the evaluation's summary upon completion. */ fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. */ fun timeout(): Optional = Optional.ofNullable(timeout.getNullable("timeout")) /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. */ - fun trialCount(): Optional = Optional.ofNullable(trialCount.getNullable("trial_count")) + fun trialCount(): Optional = + Optional.ofNullable(trialCount.getNullable("trial_count")) /** The dataset to use */ - @JsonProperty("data") - @ExcludeMissing - fun _data(): JsonField = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data /** Unique identifier for the project to run the eval in */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** The functions to score the eval on */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores(): JsonField> = scores + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField> = scores /** The function to evaluate */ - @JsonProperty("task") - @ExcludeMissing - fun _task(): JsonField = task + @JsonProperty("task") @ExcludeMissing fun _task(): JsonField = task /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ @JsonProperty("base_experiment_id") @ExcludeMissing fun _baseExperimentId(): JsonField = baseExperimentId /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ @JsonProperty("base_experiment_name") @ExcludeMissing fun _baseExperimentName(): JsonField = baseExperimentName /** - * An optional name for the experiment created by this eval. If it conflicts with - * an existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. */ @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName(): JsonField = experimentName /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. */ @JsonProperty("git_metadata_settings") @ExcludeMissing fun _gitMetadataSettings(): JsonField = gitMetadataSettings /** Whether the experiment should be public. Defaults to false. */ - @JsonProperty("is_public") - @ExcludeMissing - fun _isPublic(): JsonField = isPublic + @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField = isPublic /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ @JsonProperty("max_concurrency") @ExcludeMissing fun _maxConcurrency(): JsonField = maxConcurrency /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use this + * to slice & dice across experiments. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - @ExcludeMissing - fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo /** - * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. - * If false, the request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two events: + * one to indicate the experiment has started, and another upon completion. If false, the + * request will return the evaluation's summary upon completion. */ - @JsonProperty("stream") - @ExcludeMissing - fun _stream(): JsonField = stream + @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. */ - @JsonProperty("timeout") - @ExcludeMissing - fun _timeout(): JsonField = timeout + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. */ @JsonProperty("trial_count") @ExcludeMissing @@ -415,29 +429,28 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - data().validate() - projectId() - scores().forEach { it.validate() } - task().validate() - baseExperimentId() - baseExperimentName() - experimentName() - gitMetadataSettings().ifPresent { it.validate() } - isPublic() - maxConcurrency() - metadata().ifPresent { it.validate() } - repoInfo().ifPresent { it.validate() } - stream() - timeout() - trialCount() - validated = true - } + fun validate(): Body = apply { + if (validated) { + return@apply + } + + data().validate() + projectId() + scores().forEach { it.validate() } + task().validate() + baseExperimentId() + baseExperimentName() + experimentName() + gitMetadataSettings().ifPresent { it.validate() } + isPublic() + maxConcurrency() + metadata().ifPresent { it.validate() } + repoInfo().ifPresent { it.validate() } + stream() + timeout() + trialCount() + validated = true + } fun toBuilder() = Builder().from(this) @@ -447,7 +460,6 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .data() * .projectId() @@ -455,8 +467,7 @@ class EvalCreateParams private constructor( * .task() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -480,93 +491,87 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - data = body.data - projectId = body.projectId - scores = body.scores.map { it.toMutableList() } - task = body.task - baseExperimentId = body.baseExperimentId - baseExperimentName = body.baseExperimentName - experimentName = body.experimentName - gitMetadataSettings = body.gitMetadataSettings - isPublic = body.isPublic - maxConcurrency = body.maxConcurrency - metadata = body.metadata - repoInfo = body.repoInfo - stream = body.stream - timeout = body.timeout - trialCount = body.trialCount - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + data = body.data + projectId = body.projectId + scores = body.scores.map { it.toMutableList() } + task = body.task + baseExperimentId = body.baseExperimentId + baseExperimentName = body.baseExperimentName + experimentName = body.experimentName + gitMetadataSettings = body.gitMetadataSettings + isPublic = body.isPublic + maxConcurrency = body.maxConcurrency + metadata = body.metadata + repoInfo = body.repoInfo + stream = body.stream + timeout = body.timeout + trialCount = body.trialCount + additionalProperties = body.additionalProperties.toMutableMap() + } /** The dataset to use */ fun data(data: Data) = data(JsonField.of(data)) /** The dataset to use */ - fun data(data: JsonField) = - apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } /** Dataset id */ fun data(datasetId: Data.DatasetId) = data(Data.ofDatasetId(datasetId)) /** Project and dataset name */ - fun data(projectDatasetName: Data.ProjectDatasetName) = data(Data.ofProjectDatasetName(projectDatasetName)) + fun data(projectDatasetName: Data.ProjectDatasetName) = + data(Data.ofProjectDatasetName(projectDatasetName)) /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The functions to score the eval on */ fun scores(scores: List) = scores(JsonField.of(scores)) /** The functions to score the eval on */ - fun scores(scores: JsonField>) = - apply { - this.scores = scores.map { it.toMutableList() } - } + fun scores(scores: JsonField>) = apply { + this.scores = scores.map { it.toMutableList() } + } /** The functions to score the eval on */ - fun addScore(score: Score) = - apply { - scores = (scores ?: JsonField.of(mutableListOf())).also { + fun addScore(score: Score) = apply { + scores = + (scores ?: JsonField.of(mutableListOf())).also { checkKnown("scores", it).add(score) } - } + } /** Function id */ fun addScore(functionId: Score.FunctionId) = addScore(Score.ofFunctionId(functionId)) /** Project name and slug */ - fun addScore(projectSlug: Score.ProjectSlug) = addScore(Score.ofProjectSlug(projectSlug)) + fun addScore(projectSlug: Score.ProjectSlug) = + addScore(Score.ofProjectSlug(projectSlug)) /** Global function name */ - fun addScore(globalFunction: Score.GlobalFunction) = addScore(Score.ofGlobalFunction(globalFunction)) + fun addScore(globalFunction: Score.GlobalFunction) = + addScore(Score.ofGlobalFunction(globalFunction)) /** Prompt session id */ - fun addScore(promptSessionId: Score.PromptSessionId) = addScore(Score.ofPromptSessionId(promptSessionId)) + fun addScore(promptSessionId: Score.PromptSessionId) = + addScore(Score.ofPromptSessionId(promptSessionId)) /** Inline code function */ fun addScore(inlineCode: Score.InlineCode) = addScore(Score.ofInlineCode(inlineCode)) /** Inline prompt definition */ - fun addScore(inlinePrompt: Score.InlinePrompt) = addScore(Score.ofInlinePrompt(inlinePrompt)) + fun addScore(inlinePrompt: Score.InlinePrompt) = + addScore(Score.ofInlinePrompt(inlinePrompt)) /** The function to evaluate */ fun task(task: Task) = task(JsonField.of(task)) /** The function to evaluate */ - fun task(task: JsonField) = - apply { - this.task = task - } + fun task(task: JsonField) = apply { this.task = task } /** Function id */ fun task(functionId: Task.FunctionId) = task(Task.ofFunctionId(functionId)) @@ -575,10 +580,12 @@ class EvalCreateParams private constructor( fun task(projectSlug: Task.ProjectSlug) = task(Task.ofProjectSlug(projectSlug)) /** Global function name */ - fun task(globalFunction: Task.GlobalFunction) = task(Task.ofGlobalFunction(globalFunction)) + fun task(globalFunction: Task.GlobalFunction) = + task(Task.ofGlobalFunction(globalFunction)) /** Prompt session id */ - fun task(promptSessionId: Task.PromptSessionId) = task(Task.ofPromptSessionId(promptSessionId)) + fun task(promptSessionId: Task.PromptSessionId) = + task(Task.ofPromptSessionId(promptSessionId)) /** Inline code function */ fun task(inlineCode: Task.InlineCode) = task(Task.ofInlineCode(inlineCode)) @@ -587,82 +594,85 @@ class EvalCreateParams private constructor( fun task(inlinePrompt: Task.InlinePrompt) = task(Task.ofInlinePrompt(inlinePrompt)) /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: String?) = baseExperimentId(JsonField.ofNullable(baseExperimentId)) + fun baseExperimentId(baseExperimentId: String?) = + baseExperimentId(JsonField.ofNullable(baseExperimentId)) /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: Optional) = baseExperimentId(baseExperimentId.getOrNull()) + fun baseExperimentId(baseExperimentId: Optional) = + baseExperimentId(baseExperimentId.getOrNull()) /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: JsonField) = - apply { - this.baseExperimentId = baseExperimentId - } + fun baseExperimentId(baseExperimentId: JsonField) = apply { + this.baseExperimentId = baseExperimentId + } /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will + * be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: String?) = baseExperimentName(JsonField.ofNullable(baseExperimentName)) + fun baseExperimentName(baseExperimentName: String?) = + baseExperimentName(JsonField.ofNullable(baseExperimentName)) /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will + * be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: Optional) = baseExperimentName(baseExperimentName.getOrNull()) + fun baseExperimentName(baseExperimentName: Optional) = + baseExperimentName(baseExperimentName.getOrNull()) /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will + * be summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: JsonField) = - apply { - this.baseExperimentName = baseExperimentName - } + fun baseExperimentName(baseExperimentName: JsonField) = apply { + this.baseExperimentName = baseExperimentName + } /** - * An optional name for the experiment created by this eval. If it conflicts with - * an existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) + fun experimentName(experimentName: String) = + experimentName(JsonField.of(experimentName)) /** - * An optional name for the experiment created by this eval. If it conflicts with - * an existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: JsonField) = - apply { - this.experimentName = experimentName - } + fun experimentName(experimentName: JsonField) = apply { + this.experimentName = experimentName + } /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = gitMetadataSettings(JsonField.ofNullable(gitMetadataSettings)) + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = + gitMetadataSettings(JsonField.ofNullable(gitMetadataSettings)) /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: Optional) = gitMetadataSettings(gitMetadataSettings.getOrNull()) + fun gitMetadataSettings(gitMetadataSettings: Optional) = + gitMetadataSettings(gitMetadataSettings.getOrNull()) /** * Optional settings for collecting git metadata. By default, will collect all git * metadata fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: JsonField) = - apply { - this.gitMetadataSettings = gitMetadataSettings - } + fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { + this.gitMetadataSettings = gitMetadataSettings + } /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: Boolean?) = isPublic(JsonField.ofNullable(isPublic)) @@ -674,16 +684,14 @@ class EvalCreateParams private constructor( fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: JsonField) = - apply { - this.isPublic = isPublic - } + fun isPublic(isPublic: JsonField) = apply { this.isPublic = isPublic } /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Double?) = maxConcurrency(JsonField.ofNullable(maxConcurrency)) + fun maxConcurrency(maxConcurrency: Double?) = + maxConcurrency(JsonField.ofNullable(maxConcurrency)) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to @@ -695,31 +703,28 @@ class EvalCreateParams private constructor( * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Optional) = maxConcurrency(maxConcurrency.getOrNull()) + fun maxConcurrency(maxConcurrency: Optional) = + maxConcurrency(maxConcurrency.getOrNull()) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to * undefined, in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: JsonField) = - apply { - this.maxConcurrency = maxConcurrency - } + fun maxConcurrency(maxConcurrency: JsonField) = apply { + this.maxConcurrency = maxConcurrency + } /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use + * this to slice & dice across experiments. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use + * this to slice & dice across experiments. */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -728,147 +733,120 @@ class EvalCreateParams private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = - apply { - this.repoInfo = repoInfo - } + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } /** * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. - * If false, the request will return the evaluation's summary upon completion. + * events: one to indicate the experiment has started, and another upon completion. If + * false, the request will return the evaluation's summary upon completion. */ fun stream(stream: Boolean) = stream(JsonField.of(stream)) /** * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. - * If false, the request will return the evaluation's summary upon completion. + * events: one to indicate the experiment has started, and another upon completion. If + * false, the request will return the evaluation's summary upon completion. */ - fun stream(stream: JsonField) = - apply { - this.stream = stream - } + fun stream(stream: JsonField) = apply { this.stream = stream } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, + * in which case there is no timeout. */ fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, + * in which case there is no timeout. */ fun timeout(timeout: Double) = timeout(timeout as Double?) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, + * in which case there is no timeout. */ fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, + * in which case there is no timeout. */ - fun timeout(timeout: JsonField) = - apply { - this.timeout = timeout - } + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger + * aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double?) = trialCount(JsonField.ofNullable(trialCount)) /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger + * aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger + * aggregate measure and a sense of the variance in the results. */ fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger + * aggregate measure and a sense of the variance in the results. */ - fun trialCount(trialCount: JsonField) = - apply { - this.trialCount = trialCount - } + fun trialCount(trialCount: JsonField) = apply { this.trialCount = trialCount } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "data", data - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "scores", scores - ).map { it.toImmutable() }, - checkRequired( - "task", task - ), - baseExperimentId, - baseExperimentName, - experimentName, - gitMetadataSettings, - isPublic, - maxConcurrency, - metadata, - repoInfo, - stream, - timeout, - trialCount, - additionalProperties.toImmutable(), + checkRequired("data", data), + checkRequired("projectId", projectId), + checkRequired("scores", scores).map { it.toImmutable() }, + checkRequired("task", task), + baseExperimentId, + baseExperimentName, + experimentName, + gitMetadataSettings, + isPublic, + maxConcurrency, + metadata, + repoInfo, + stream, + timeout, + trialCount, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -877,7 +855,8 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -888,7 +867,6 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [EvalCreateParams]. * * The following fields are required: - * * ```java * .data() * .projectId() @@ -896,8 +874,7 @@ class EvalCreateParams private constructor( * .task() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [EvalCreateParams]. */ @@ -909,246 +886,170 @@ class EvalCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(evalCreateParams: EvalCreateParams) = - apply { - body = evalCreateParams.body.toBuilder() - additionalHeaders = evalCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = evalCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(evalCreateParams: EvalCreateParams) = apply { + body = evalCreateParams.body.toBuilder() + additionalHeaders = evalCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = evalCreateParams.additionalQueryParams.toBuilder() + } /** The dataset to use */ - fun data(data: Data) = - apply { - body.data(data) - } + fun data(data: Data) = apply { body.data(data) } /** The dataset to use */ - fun data(data: JsonField) = - apply { - body.data(data) - } + fun data(data: JsonField) = apply { body.data(data) } /** Dataset id */ - fun data(datasetId: Data.DatasetId) = - apply { - body.data(datasetId) - } + fun data(datasetId: Data.DatasetId) = apply { body.data(datasetId) } /** Project and dataset name */ - fun data(projectDatasetName: Data.ProjectDatasetName) = - apply { - body.data(projectDatasetName) - } + fun data(projectDatasetName: Data.ProjectDatasetName) = apply { + body.data(projectDatasetName) + } /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project to run the eval in */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The functions to score the eval on */ - fun scores(scores: List) = - apply { - body.scores(scores) - } + fun scores(scores: List) = apply { body.scores(scores) } /** The functions to score the eval on */ - fun scores(scores: JsonField>) = - apply { - body.scores(scores) - } + fun scores(scores: JsonField>) = apply { body.scores(scores) } /** The functions to score the eval on */ - fun addScore(score: Score) = - apply { - body.addScore(score) - } + fun addScore(score: Score) = apply { body.addScore(score) } /** Function id */ - fun addScore(functionId: Score.FunctionId) = - apply { - body.addScore(functionId) - } + fun addScore(functionId: Score.FunctionId) = apply { body.addScore(functionId) } /** Project name and slug */ - fun addScore(projectSlug: Score.ProjectSlug) = - apply { - body.addScore(projectSlug) - } + fun addScore(projectSlug: Score.ProjectSlug) = apply { body.addScore(projectSlug) } /** Global function name */ - fun addScore(globalFunction: Score.GlobalFunction) = - apply { - body.addScore(globalFunction) - } + fun addScore(globalFunction: Score.GlobalFunction) = apply { body.addScore(globalFunction) } /** Prompt session id */ - fun addScore(promptSessionId: Score.PromptSessionId) = - apply { - body.addScore(promptSessionId) - } + fun addScore(promptSessionId: Score.PromptSessionId) = apply { + body.addScore(promptSessionId) + } /** Inline code function */ - fun addScore(inlineCode: Score.InlineCode) = - apply { - body.addScore(inlineCode) - } + fun addScore(inlineCode: Score.InlineCode) = apply { body.addScore(inlineCode) } /** Inline prompt definition */ - fun addScore(inlinePrompt: Score.InlinePrompt) = - apply { - body.addScore(inlinePrompt) - } + fun addScore(inlinePrompt: Score.InlinePrompt) = apply { body.addScore(inlinePrompt) } /** The function to evaluate */ - fun task(task: Task) = - apply { - body.task(task) - } + fun task(task: Task) = apply { body.task(task) } /** The function to evaluate */ - fun task(task: JsonField) = - apply { - body.task(task) - } + fun task(task: JsonField) = apply { body.task(task) } /** Function id */ - fun task(functionId: Task.FunctionId) = - apply { - body.task(functionId) - } + fun task(functionId: Task.FunctionId) = apply { body.task(functionId) } /** Project name and slug */ - fun task(projectSlug: Task.ProjectSlug) = - apply { - body.task(projectSlug) - } + fun task(projectSlug: Task.ProjectSlug) = apply { body.task(projectSlug) } /** Global function name */ - fun task(globalFunction: Task.GlobalFunction) = - apply { - body.task(globalFunction) - } + fun task(globalFunction: Task.GlobalFunction) = apply { body.task(globalFunction) } /** Prompt session id */ - fun task(promptSessionId: Task.PromptSessionId) = - apply { - body.task(promptSessionId) - } + fun task(promptSessionId: Task.PromptSessionId) = apply { body.task(promptSessionId) } /** Inline code function */ - fun task(inlineCode: Task.InlineCode) = - apply { - body.task(inlineCode) - } + fun task(inlineCode: Task.InlineCode) = apply { body.task(inlineCode) } /** Inline prompt definition */ - fun task(inlinePrompt: Task.InlinePrompt) = - apply { - body.task(inlinePrompt) - } + fun task(inlinePrompt: Task.InlinePrompt) = apply { body.task(inlinePrompt) } /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: String?) = - apply { - body.baseExperimentId(baseExperimentId) - } + fun baseExperimentId(baseExperimentId: String?) = apply { + body.baseExperimentId(baseExperimentId) + } /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: Optional) = baseExperimentId(baseExperimentId.getOrNull()) + fun baseExperimentId(baseExperimentId: Optional) = + baseExperimentId(baseExperimentId.getOrNull()) /** - * An optional experiment id to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment id to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentId(baseExperimentId: JsonField) = - apply { - body.baseExperimentId(baseExperimentId) - } + fun baseExperimentId(baseExperimentId: JsonField) = apply { + body.baseExperimentId(baseExperimentId) + } /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: String?) = - apply { - body.baseExperimentName(baseExperimentName) - } + fun baseExperimentName(baseExperimentName: String?) = apply { + body.baseExperimentName(baseExperimentName) + } /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: Optional) = baseExperimentName(baseExperimentName.getOrNull()) + fun baseExperimentName(baseExperimentName: Optional) = + baseExperimentName(baseExperimentName.getOrNull()) /** - * An optional experiment name to use as a base. If specified, the new experiment - * will be summarized and compared to this experiment. + * An optional experiment name to use as a base. If specified, the new experiment will be + * summarized and compared to this experiment. */ - fun baseExperimentName(baseExperimentName: JsonField) = - apply { - body.baseExperimentName(baseExperimentName) - } + fun baseExperimentName(baseExperimentName: JsonField) = apply { + body.baseExperimentName(baseExperimentName) + } /** - * An optional name for the experiment created by this eval. If it conflicts with - * an existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: String) = - apply { - body.experimentName(experimentName) - } + fun experimentName(experimentName: String) = apply { body.experimentName(experimentName) } /** - * An optional name for the experiment created by this eval. If it conflicts with - * an existing experiment, it will be suffixed with a unique identifier. + * An optional name for the experiment created by this eval. If it conflicts with an + * existing experiment, it will be suffixed with a unique identifier. */ - fun experimentName(experimentName: JsonField) = - apply { - body.experimentName(experimentName) - } + fun experimentName(experimentName: JsonField) = apply { + body.experimentName(experimentName) + } /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = - apply { - body.gitMetadataSettings(gitMetadataSettings) - } + fun gitMetadataSettings(gitMetadataSettings: GitMetadataSettings?) = apply { + body.gitMetadataSettings(gitMetadataSettings) + } /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: Optional) = gitMetadataSettings(gitMetadataSettings.getOrNull()) + fun gitMetadataSettings(gitMetadataSettings: Optional) = + gitMetadataSettings(gitMetadataSettings.getOrNull()) /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. */ - fun gitMetadataSettings(gitMetadataSettings: JsonField) = - apply { - body.gitMetadataSettings(gitMetadataSettings) - } + fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { + body.gitMetadataSettings(gitMetadataSettings) + } /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: Boolean?) = - apply { - body.isPublic(isPublic) - } + fun isPublic(isPublic: Boolean?) = apply { body.isPublic(isPublic) } /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) @@ -1157,332 +1058,259 @@ class EvalCreateParams private constructor( fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) /** Whether the experiment should be public. Defaults to false. */ - fun isPublic(isPublic: JsonField) = - apply { - body.isPublic(isPublic) - } + fun isPublic(isPublic: JsonField) = apply { body.isPublic(isPublic) } /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Double?) = - apply { - body.maxConcurrency(maxConcurrency) - } + fun maxConcurrency(maxConcurrency: Double?) = apply { body.maxConcurrency(maxConcurrency) } /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ fun maxConcurrency(maxConcurrency: Double) = maxConcurrency(maxConcurrency as Double?) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: Optional) = maxConcurrency(maxConcurrency.getOrNull()) + fun maxConcurrency(maxConcurrency: Optional) = + maxConcurrency(maxConcurrency.getOrNull()) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, + * in which case there is no max concurrency. */ - fun maxConcurrency(maxConcurrency: JsonField) = - apply { - body.maxConcurrency(maxConcurrency) - } + fun maxConcurrency(maxConcurrency: JsonField) = apply { + body.maxConcurrency(maxConcurrency) + } /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use this + * to slice & dice across experiments. */ - fun metadata(metadata: Metadata) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: Metadata) = apply { body.metadata(metadata) } /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use this + * to slice & dice across experiments. */ - fun metadata(metadata: JsonField) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = - apply { - body.repoInfo(repoInfo) - } + fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = - apply { - body.repoInfo(repoInfo) - } + fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } /** - * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. - * If false, the request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two events: + * one to indicate the experiment has started, and another upon completion. If false, the + * request will return the evaluation's summary upon completion. */ - fun stream(stream: Boolean) = - apply { - body.stream(stream) - } + fun stream(stream: Boolean) = apply { body.stream(stream) } /** - * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. - * If false, the request will return the evaluation's summary upon completion. + * Whether to stream the results of the eval. If true, the request will return two events: + * one to indicate the experiment has started, and another upon completion. If false, the + * request will return the evaluation's summary upon completion. */ - fun stream(stream: JsonField) = - apply { - body.stream(stream) - } + fun stream(stream: JsonField) = apply { body.stream(stream) } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. */ - fun timeout(timeout: Double?) = - apply { - body.timeout(timeout) - } + fun timeout(timeout: Double?) = apply { body.timeout(timeout) } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. */ fun timeout(timeout: Double) = timeout(timeout as Double?) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. */ fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to - * undefined, in which case there is no timeout. + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in + * which case there is no timeout. */ - fun timeout(timeout: JsonField) = - apply { - body.timeout(timeout) - } + fun timeout(timeout: JsonField) = apply { body.timeout(timeout) } /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. */ - fun trialCount(trialCount: Double?) = - apply { - body.trialCount(trialCount) - } + fun trialCount(trialCount: Double?) = apply { body.trialCount(trialCount) } /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. */ fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. */ fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** - * The number of times to run the evaluator per input. This is useful for - * evaluating applications that have non-deterministic behavior and gives you both - * a stronger aggregate measure and a sense of the variance in the results. + * The number of times to run the evaluator per input. This is useful for evaluating + * applications that have non-deterministic behavior and gives you both a stronger aggregate + * measure and a sense of the variance in the results. */ - fun trialCount(trialCount: JsonField) = - apply { - body.trialCount(trialCount) - } + fun trialCount(trialCount: JsonField) = apply { body.trialCount(trialCount) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.put(key, value) + this.additionalQueryParams.putAll(additionalQueryParams) } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): EvalCreateParams = - EvalCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + EvalCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } /** The dataset to use */ @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data private constructor( + class Data + private constructor( private val datasetId: DatasetId? = null, private val projectDatasetName: ProjectDatasetName? = null, private val _json: JsonValue? = null, - ) { /** Dataset id */ fun datasetId(): Optional = Optional.ofNullable(datasetId) /** Project and dataset name */ - fun projectDatasetName(): Optional = Optional.ofNullable(projectDatasetName) + fun projectDatasetName(): Optional = + Optional.ofNullable(projectDatasetName) fun isDatasetId(): Boolean = datasetId != null @@ -1492,44 +1320,46 @@ class EvalCreateParams private constructor( fun asDatasetId(): DatasetId = datasetId.getOrThrow("datasetId") /** Project and dataset name */ - fun asProjectDatasetName(): ProjectDatasetName = projectDatasetName.getOrThrow("projectDatasetName") + fun asProjectDatasetName(): ProjectDatasetName = + projectDatasetName.getOrThrow("projectDatasetName") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - datasetId != null -> visitor.visitDatasetId(datasetId) - projectDatasetName != null -> visitor.visitProjectDatasetName(projectDatasetName) - else -> visitor.unknown(_json) - } + return when { + datasetId != null -> visitor.visitDatasetId(datasetId) + projectDatasetName != null -> visitor.visitProjectDatasetName(projectDatasetName) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = - apply { - if (validated) { - return@apply - } + fun validate(): Data = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitDatasetId(datasetId: DatasetId) { - datasetId.validate() + datasetId.validate() } override fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName) { - projectDatasetName.validate() + projectDatasetName.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ + return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, projectDatasetName) /* spotless:on */ @@ -1545,18 +1375,15 @@ class EvalCreateParams private constructor( companion object { /** Dataset id */ - @JvmStatic - fun ofDatasetId(datasetId: DatasetId) = Data(datasetId = datasetId) + @JvmStatic fun ofDatasetId(datasetId: DatasetId) = Data(datasetId = datasetId) /** Project and dataset name */ @JvmStatic - fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = Data(projectDatasetName = projectDatasetName) + fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = + Data(projectDatasetName = projectDatasetName) } - /** - * An interface that defines how to map each variant of [Data] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Data] to a value of type [T]. */ interface Visitor { /** Dataset id */ @@ -1568,52 +1395,62 @@ class EvalCreateParams private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(datasetId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(projectDatasetName = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(datasetId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(projectDatasetName = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.datasetId != null -> generator.writeObject(value.datasetId) - value.projectDatasetName != null -> generator.writeObject(value.projectDatasetName) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize( + value: Data, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.datasetId != null -> generator.writeObject(value.datasetId) + value.projectDatasetName != null -> + generator.writeObject(value.projectDatasetName) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } /** Dataset id */ @NoAutoDetect - class DatasetId @JsonCreator private constructor( - @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class DatasetId + @JsonCreator + private constructor( + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun datasetId(): String = datasetId.getRequired("dataset_id") @@ -1628,16 +1465,15 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): DatasetId = - apply { - if (validated) { - return@apply - } - - datasetId() - validated = true + fun validate(): DatasetId = apply { + if (validated) { + return@apply } + datasetId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1646,13 +1482,11 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [DatasetId]. * * The following fields are required: - * * ```java * .datasetId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [DatasetId]. */ @@ -1662,59 +1496,50 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(datasetId: DatasetId) = - apply { - this.datasetId = datasetId.datasetId - additionalProperties = datasetId.additionalProperties.toMutableMap() - } + internal fun from(datasetId: DatasetId) = apply { + this.datasetId = datasetId.datasetId + additionalProperties = datasetId.additionalProperties.toMutableMap() + } fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - fun datasetId(datasetId: JsonField) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): DatasetId = DatasetId( - checkRequired( - "datasetId", datasetId - ), additionalProperties.toImmutable() + checkRequired("datasetId", datasetId), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1723,16 +1548,23 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" + override fun toString() = + "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" } /** Project and dataset name */ @NoAutoDetect - class ProjectDatasetName @JsonCreator private constructor( - @JsonProperty("dataset_name") @ExcludeMissing private val datasetName: JsonField = JsonMissing.of(), - @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class ProjectDatasetName + @JsonCreator + private constructor( + @JsonProperty("dataset_name") + @ExcludeMissing + private val datasetName: JsonField = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun datasetName(): String = datasetName.getRequired("dataset_name") @@ -1753,17 +1585,16 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): ProjectDatasetName = - apply { - if (validated) { - return@apply - } - - datasetName() - projectName() - validated = true + fun validate(): ProjectDatasetName = apply { + if (validated) { + return@apply } + datasetName() + projectName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1772,14 +1603,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [ProjectDatasetName]. * * The following fields are required: - * * ```java * .datasetName() * .projectName() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectDatasetName]. */ @@ -1790,71 +1619,60 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectDatasetName: ProjectDatasetName) = - apply { - datasetName = projectDatasetName.datasetName - projectName = projectDatasetName.projectName - additionalProperties = projectDatasetName.additionalProperties.toMutableMap() - } + internal fun from(projectDatasetName: ProjectDatasetName) = apply { + datasetName = projectDatasetName.datasetName + projectName = projectDatasetName.projectName + additionalProperties = projectDatasetName.additionalProperties.toMutableMap() + } fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) - fun datasetName(datasetName: JsonField) = - apply { - this.datasetName = datasetName - } + fun datasetName(datasetName: JsonField) = apply { + this.datasetName = datasetName + } fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - fun projectName(projectName: JsonField) = - apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = apply { + this.projectName = projectName + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectDatasetName = ProjectDatasetName( - checkRequired( - "datasetName", datasetName - ), - checkRequired( - "projectName", projectName - ), - additionalProperties.toImmutable(), + checkRequired("datasetName", datasetName), + checkRequired("projectName", projectName), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1863,14 +1681,16 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" } } /** The function to evaluate */ @JsonDeserialize(using = Score.Deserializer::class) @JsonSerialize(using = Score.Serializer::class) - class Score private constructor( + class Score + private constructor( private val functionId: FunctionId? = null, private val projectSlug: ProjectSlug? = null, private val globalFunction: GlobalFunction? = null, @@ -1878,7 +1698,6 @@ class EvalCreateParams private constructor( private val inlineCode: InlineCode? = null, private val inlinePrompt: InlinePrompt? = null, private val _json: JsonValue? = null, - ) { /** Function id */ @@ -1932,59 +1751,60 @@ class EvalCreateParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - functionId != null -> visitor.visitFunctionId(functionId) - projectSlug != null -> visitor.visitProjectSlug(projectSlug) - globalFunction != null -> visitor.visitGlobalFunction(globalFunction) - promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) - inlineCode != null -> visitor.visitInlineCode(inlineCode) - inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) - else -> visitor.unknown(_json) - } + return when { + functionId != null -> visitor.visitFunctionId(functionId) + projectSlug != null -> visitor.visitProjectSlug(projectSlug) + globalFunction != null -> visitor.visitGlobalFunction(globalFunction) + promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) + inlineCode != null -> visitor.visitInlineCode(inlineCode) + inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Score = - apply { - if (validated) { - return@apply - } + fun validate(): Score = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitFunctionId(functionId: FunctionId) { - functionId.validate() + functionId.validate() } override fun visitProjectSlug(projectSlug: ProjectSlug) { - projectSlug.validate() + projectSlug.validate() } override fun visitGlobalFunction(globalFunction: GlobalFunction) { - globalFunction.validate() + globalFunction.validate() } override fun visitPromptSessionId(promptSessionId: PromptSessionId) { - promptSessionId.validate() + promptSessionId.validate() } override fun visitInlineCode(inlineCode: InlineCode) { - inlineCode.validate() + inlineCode.validate() } override fun visitInlinePrompt(inlinePrompt: InlinePrompt) { - inlinePrompt.validate() + inlinePrompt.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Score && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ + return /* spotless:off */ other is Score && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ @@ -2004,8 +1824,7 @@ class EvalCreateParams private constructor( companion object { /** Function id */ - @JvmStatic - fun ofFunctionId(functionId: FunctionId) = Score(functionId = functionId) + @JvmStatic fun ofFunctionId(functionId: FunctionId) = Score(functionId = functionId) /** Project name and slug */ @JvmStatic @@ -2013,25 +1832,23 @@ class EvalCreateParams private constructor( /** Global function name */ @JvmStatic - fun ofGlobalFunction(globalFunction: GlobalFunction) = Score(globalFunction = globalFunction) + fun ofGlobalFunction(globalFunction: GlobalFunction) = + Score(globalFunction = globalFunction) /** Prompt session id */ @JvmStatic - fun ofPromptSessionId(promptSessionId: PromptSessionId) = Score(promptSessionId = promptSessionId) + fun ofPromptSessionId(promptSessionId: PromptSessionId) = + Score(promptSessionId = promptSessionId) /** Inline code function */ - @JvmStatic - fun ofInlineCode(inlineCode: InlineCode) = Score(inlineCode = inlineCode) + @JvmStatic fun ofInlineCode(inlineCode: InlineCode) = Score(inlineCode = inlineCode) /** Inline prompt definition */ @JvmStatic fun ofInlinePrompt(inlinePrompt: InlinePrompt) = Score(inlinePrompt = inlinePrompt) } - /** - * An interface that defines how to map each variant of [Score] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Score] to a value of type [T]. */ interface Visitor { /** Function id */ @@ -2055,69 +1872,85 @@ class EvalCreateParams private constructor( /** * Maps an unknown variant of [Score] to a value of type [T]. * - * An instance of [Score] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Score] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Score: $json") + throw BraintrustInvalidDataException("Unknown Score: $json") } } internal class Deserializer : BaseDeserializer(Score::class) { override fun ObjectCodec.deserialize(node: JsonNode): Score { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Score(functionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Score(projectSlug = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Score(globalFunction = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Score(promptSessionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Score(inlineCode = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Score(inlinePrompt = it, _json = json) - } - - return Score(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Score(functionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Score(projectSlug = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Score(globalFunction = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Score(promptSessionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Score(inlineCode = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Score(inlinePrompt = it, _json = json) + } + + return Score(_json = json) } } internal class Serializer : BaseSerializer(Score::class) { - override fun serialize(value: Score, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.functionId != null -> generator.writeObject(value.functionId) - value.projectSlug != null -> generator.writeObject(value.projectSlug) - value.globalFunction != null -> generator.writeObject(value.globalFunction) - value.promptSessionId != null -> generator.writeObject(value.promptSessionId) - value.inlineCode != null -> generator.writeObject(value.inlineCode) - value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Score") - } + override fun serialize( + value: Score, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.functionId != null -> generator.writeObject(value.functionId) + value.projectSlug != null -> generator.writeObject(value.projectSlug) + value.globalFunction != null -> generator.writeObject(value.globalFunction) + value.promptSessionId != null -> generator.writeObject(value.promptSessionId) + value.inlineCode != null -> generator.writeObject(value.inlineCode) + value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Score") + } } } /** Function id */ @NoAutoDetect - class FunctionId @JsonCreator private constructor( - @JsonProperty("function_id") @ExcludeMissing private val functionId: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class FunctionId + @JsonCreator + private constructor( + @JsonProperty("function_id") + @ExcludeMissing + private val functionId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The ID of the function */ @@ -2132,9 +1965,7 @@ class EvalCreateParams private constructor( fun _functionId(): JsonField = functionId /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2142,17 +1973,16 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): FunctionId = - apply { - if (validated) { - return@apply - } - - functionId() - version() - validated = true + fun validate(): FunctionId = apply { + if (validated) { + return@apply } + functionId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2161,13 +1991,11 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [FunctionId]. * * The following fields are required: - * * ```java * .functionId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionId]. */ @@ -2178,73 +2006,62 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionId: FunctionId) = - apply { - this.functionId = functionId.functionId - version = functionId.version - additionalProperties = functionId.additionalProperties.toMutableMap() - } + internal fun from(functionId: FunctionId) = apply { + this.functionId = functionId.functionId + version = functionId.version + additionalProperties = functionId.additionalProperties.toMutableMap() + } /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) /** The ID of the function */ - fun functionId(functionId: JsonField) = - apply { - this.functionId = functionId - } + fun functionId(functionId: JsonField) = apply { + this.functionId = functionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionId = FunctionId( - checkRequired( - "functionId", functionId - ), - version, - additionalProperties.toImmutable(), + checkRequired("functionId", functionId), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2253,17 +2070,26 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" } /** Project name and slug */ @NoAutoDetect - class ProjectSlug @JsonCreator private constructor( - @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class ProjectSlug + @JsonCreator + private constructor( + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the project containing the function */ @@ -2281,14 +2107,10 @@ class EvalCreateParams private constructor( fun _projectName(): JsonField = projectName /** The slug of the function */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2296,18 +2118,17 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): ProjectSlug = - apply { - if (validated) { - return@apply - } - - projectName() - slug() - version() - validated = true + fun validate(): ProjectSlug = apply { + if (validated) { + return@apply } + projectName() + slug() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2316,14 +2137,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [ProjectSlug]. * * The following fields are required: - * * ```java * .projectName() * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectSlug]. */ @@ -2335,86 +2154,70 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSlug: ProjectSlug) = - apply { - projectName = projectSlug.projectName - slug = projectSlug.slug - version = projectSlug.version - additionalProperties = projectSlug.additionalProperties.toMutableMap() - } + internal fun from(projectSlug: ProjectSlug) = apply { + projectName = projectSlug.projectName + slug = projectSlug.slug + version = projectSlug.version + additionalProperties = projectSlug.additionalProperties.toMutableMap() + } /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** The name of the project containing the function */ - fun projectName(projectName: JsonField) = - apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = apply { + this.projectName = projectName + } /** The slug of the function */ fun slug(slug: String) = slug(JsonField.of(slug)) /** The slug of the function */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSlug = ProjectSlug( - checkRequired( - "projectName", projectName - ), - checkRequired( - "slug", slug - ), - version, - additionalProperties.toImmutable(), + checkRequired("projectName", projectName), + checkRequired("slug", slug), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2423,15 +2226,20 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" } /** Global function name */ @NoAutoDetect - class GlobalFunction @JsonCreator private constructor( - @JsonProperty("global_function") @ExcludeMissing private val globalFunction: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class GlobalFunction + @JsonCreator + private constructor( + @JsonProperty("global_function") + @ExcludeMissing + private val globalFunction: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -2454,16 +2262,15 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): GlobalFunction = - apply { - if (validated) { - return@apply - } - - globalFunction() - validated = true + fun validate(): GlobalFunction = apply { + if (validated) { + return@apply } + globalFunction() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2472,13 +2279,11 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [GlobalFunction]. * * The following fields are required: - * * ```java * .globalFunction() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GlobalFunction]. */ @@ -2488,67 +2293,61 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(globalFunction: GlobalFunction) = - apply { - this.globalFunction = globalFunction.globalFunction - additionalProperties = globalFunction.additionalProperties.toMutableMap() - } + internal fun from(globalFunction: GlobalFunction) = apply { + this.globalFunction = globalFunction.globalFunction + additionalProperties = globalFunction.additionalProperties.toMutableMap() + } /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: String) = globalFunction(JsonField.of(globalFunction)) + fun globalFunction(globalFunction: String) = + globalFunction(JsonField.of(globalFunction)) /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: JsonField) = - apply { - this.globalFunction = globalFunction - } + fun globalFunction(globalFunction: JsonField) = apply { + this.globalFunction = globalFunction + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GlobalFunction = GlobalFunction( - checkRequired( - "globalFunction", globalFunction - ), additionalProperties.toImmutable() + checkRequired("globalFunction", globalFunction), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2557,21 +2356,31 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" + override fun toString() = + "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" } /** Prompt session id */ @NoAutoDetect - class PromptSessionId @JsonCreator private constructor( - @JsonProperty("prompt_session_function_id") @ExcludeMissing private val promptSessionFunctionId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_session_id") @ExcludeMissing private val promptSessionId: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class PromptSessionId + @JsonCreator + private constructor( + @JsonProperty("prompt_session_function_id") + @ExcludeMissing + private val promptSessionFunctionId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_session_id") + @ExcludeMissing + private val promptSessionId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") + fun promptSessionFunctionId(): String = + promptSessionFunctionId.getRequired("prompt_session_function_id") /** The ID of the prompt session */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") @@ -2590,9 +2399,7 @@ class EvalCreateParams private constructor( fun _promptSessionId(): JsonField = promptSessionId /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2600,18 +2407,17 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): PromptSessionId = - apply { - if (validated) { - return@apply - } - - promptSessionFunctionId() - promptSessionId() - version() - validated = true + fun validate(): PromptSessionId = apply { + if (validated) { + return@apply } + promptSessionFunctionId() + promptSessionId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2620,14 +2426,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [PromptSessionId]. * * The following fields are required: - * * ```java * .promptSessionFunctionId() * .promptSessionId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptSessionId]. */ @@ -2639,86 +2443,74 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptSessionId: PromptSessionId) = - apply { - promptSessionFunctionId = promptSessionId.promptSessionFunctionId - this.promptSessionId = promptSessionId.promptSessionId - version = promptSessionId.version - additionalProperties = promptSessionId.additionalProperties.toMutableMap() - } + internal fun from(promptSessionId: PromptSessionId) = apply { + promptSessionFunctionId = promptSessionId.promptSessionFunctionId + this.promptSessionId = promptSessionId.promptSessionId + version = promptSessionId.version + additionalProperties = promptSessionId.additionalProperties.toMutableMap() + } /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: String) = promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) + fun promptSessionFunctionId(promptSessionFunctionId: String) = + promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = - apply { - this.promptSessionFunctionId = promptSessionFunctionId - } + fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { + this.promptSessionFunctionId = promptSessionFunctionId + } /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: String) = promptSessionId(JsonField.of(promptSessionId)) + fun promptSessionId(promptSessionId: String) = + promptSessionId(JsonField.of(promptSessionId)) /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: JsonField) = - apply { - this.promptSessionId = promptSessionId - } + fun promptSessionId(promptSessionId: JsonField) = apply { + this.promptSessionId = promptSessionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptSessionId = PromptSessionId( - checkRequired( - "promptSessionFunctionId", promptSessionFunctionId - ), - checkRequired( - "promptSessionId", promptSessionId - ), - version, - additionalProperties.toImmutable(), + checkRequired("promptSessionFunctionId", promptSessionFunctionId), + checkRequired("promptSessionId", promptSessionId), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2727,17 +2519,26 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ @NoAutoDetect - class InlineCode @JsonCreator private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("inline_context") @ExcludeMissing private val inlineContext: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InlineCode + @JsonCreator + private constructor( + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("inline_context") + @ExcludeMissing + private val inlineContext: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The inline code to execute */ @@ -2749,18 +2550,14 @@ class EvalCreateParams private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The inline code to execute */ - @JsonProperty("code") - @ExcludeMissing - fun _code(): JsonField = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext(): JsonField = inlineContext /** The name of the inline code function */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2768,18 +2565,17 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): InlineCode = - apply { - if (validated) { - return@apply - } - - code() - inlineContext().validate() - name() - validated = true + fun validate(): InlineCode = apply { + if (validated) { + return@apply } + code() + inlineContext().validate() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2788,14 +2584,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [InlineCode]. * * The following fields are required: - * * ```java * .code() * .inlineContext() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InlineCode]. */ @@ -2807,29 +2601,25 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineCode: InlineCode) = - apply { - code = inlineCode.code - inlineContext = inlineCode.inlineContext - name = inlineCode.name - additionalProperties = inlineCode.additionalProperties.toMutableMap() - } + internal fun from(inlineCode: InlineCode) = apply { + code = inlineCode.code + inlineContext = inlineCode.inlineContext + name = inlineCode.name + additionalProperties = inlineCode.additionalProperties.toMutableMap() + } /** The inline code to execute */ fun code(code: String) = code(JsonField.of(code)) /** The inline code to execute */ - fun code(code: JsonField) = - apply { - this.code = code - } + fun code(code: JsonField) = apply { this.code = code } - fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) + fun inlineContext(inlineContext: InlineContext) = + inlineContext(JsonField.of(inlineContext)) - fun inlineContext(inlineContext: JsonField) = - apply { - this.inlineContext = inlineContext - } + fun inlineContext(inlineContext: JsonField) = apply { + this.inlineContext = inlineContext + } /** The name of the inline code function */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -2838,56 +2628,51 @@ class EvalCreateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline code function */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineCode = InlineCode( - checkRequired( - "code", code - ), - checkRequired( - "inlineContext", inlineContext - ), - name, - additionalProperties.toImmutable(), + checkRequired("code", code), + checkRequired("inlineContext", inlineContext), + name, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InlineContext @JsonCreator private constructor( - @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InlineContext + @JsonCreator + private constructor( + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -2898,9 +2683,7 @@ class EvalCreateParams private constructor( @ExcludeMissing fun _runtime(): JsonField = runtime - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -2908,17 +2691,16 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): InlineContext = - apply { - if (validated) { - return@apply - } - - runtime() - version() - validated = true + fun validate(): InlineContext = apply { + if (validated) { + return@apply } + runtime() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2927,14 +2709,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [InlineContext]. * * The following fields are required: - * * ```java * .runtime() * .version() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InlineContext]. */ @@ -2945,77 +2725,61 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineContext: InlineContext) = - apply { - runtime = inlineContext.runtime - version = inlineContext.version - additionalProperties = inlineContext.additionalProperties.toMutableMap() - } + internal fun from(inlineContext: InlineContext) = apply { + runtime = inlineContext.runtime + version = inlineContext.version + additionalProperties = inlineContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = - apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineContext = InlineContext( - checkRequired( - "runtime", runtime - ), - checkRequired( - "version", version - ), - additionalProperties.toImmutable(), + checkRequired("runtime", runtime), + checkRequired("version", version), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Runtime + @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. + * 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 @@ -3039,17 +2803,18 @@ class EvalCreateParams private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] 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 { NODE, PYTHON, - /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Runtime] was instantiated with an unknown + * value. + */ _UNKNOWN, } @@ -3057,8 +2822,8 @@ class EvalCreateParams private constructor( * 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. + * 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) { @@ -3070,11 +2835,11 @@ class EvalCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a + * not a known member. */ fun known(): Known = when (this) { @@ -3089,17 +2854,20 @@ class EvalCreateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3108,11 +2876,11 @@ class EvalCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3121,15 +2889,16 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3138,20 +2907,28 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ @NoAutoDetect - class InlinePrompt @JsonCreator private constructor( - @JsonProperty("inline_prompt") @ExcludeMissing private val inlinePrompt: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InlinePrompt + @JsonCreator + private constructor( + @JsonProperty("inline_prompt") + @ExcludeMissing + private val inlinePrompt: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The prompt, model, and its parameters */ - fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) + fun inlinePrompt(): Optional = + Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) /** The name of the inline prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -3162,9 +2939,7 @@ class EvalCreateParams private constructor( fun _inlinePrompt(): JsonField = inlinePrompt /** The name of the inline prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -3172,17 +2947,16 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): InlinePrompt = - apply { - if (validated) { - return@apply - } - - inlinePrompt().ifPresent { it.validate() } - name() - validated = true + fun validate(): InlinePrompt = apply { + if (validated) { + return@apply } + inlinePrompt().ifPresent { it.validate() } + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3191,13 +2965,11 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [InlinePrompt]. * * The following fields are required: - * * ```java * .inlinePrompt() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InlinePrompt]. */ @@ -3208,24 +2980,24 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlinePrompt: InlinePrompt) = - apply { - this.inlinePrompt = inlinePrompt.inlinePrompt - name = inlinePrompt.name - additionalProperties = inlinePrompt.additionalProperties.toMutableMap() - } + internal fun from(inlinePrompt: InlinePrompt) = apply { + this.inlinePrompt = inlinePrompt.inlinePrompt + name = inlinePrompt.name + additionalProperties = inlinePrompt.additionalProperties.toMutableMap() + } /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: PromptData?) = inlinePrompt(JsonField.ofNullable(inlinePrompt)) + fun inlinePrompt(inlinePrompt: PromptData?) = + inlinePrompt(JsonField.ofNullable(inlinePrompt)) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: Optional) = inlinePrompt(inlinePrompt.getOrNull()) + fun inlinePrompt(inlinePrompt: Optional) = + inlinePrompt(inlinePrompt.getOrNull()) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: JsonField) = - apply { - this.inlinePrompt = inlinePrompt - } + fun inlinePrompt(inlinePrompt: JsonField) = apply { + this.inlinePrompt = inlinePrompt + } /** The name of the inline prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -3234,53 +3006,44 @@ class EvalCreateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlinePrompt = InlinePrompt( - checkRequired( - "inlinePrompt", inlinePrompt - ), - name, - additionalProperties.toImmutable(), + checkRequired("inlinePrompt", inlinePrompt), + name, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3289,14 +3052,16 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" } } /** The function to evaluate */ @JsonDeserialize(using = Task.Deserializer::class) @JsonSerialize(using = Task.Serializer::class) - class Task private constructor( + class Task + private constructor( private val functionId: FunctionId? = null, private val projectSlug: ProjectSlug? = null, private val globalFunction: GlobalFunction? = null, @@ -3304,7 +3069,6 @@ class EvalCreateParams private constructor( private val inlineCode: InlineCode? = null, private val inlinePrompt: InlinePrompt? = null, private val _json: JsonValue? = null, - ) { /** Function id */ @@ -3358,59 +3122,60 @@ class EvalCreateParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - functionId != null -> visitor.visitFunctionId(functionId) - projectSlug != null -> visitor.visitProjectSlug(projectSlug) - globalFunction != null -> visitor.visitGlobalFunction(globalFunction) - promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) - inlineCode != null -> visitor.visitInlineCode(inlineCode) - inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) - else -> visitor.unknown(_json) - } + return when { + functionId != null -> visitor.visitFunctionId(functionId) + projectSlug != null -> visitor.visitProjectSlug(projectSlug) + globalFunction != null -> visitor.visitGlobalFunction(globalFunction) + promptSessionId != null -> visitor.visitPromptSessionId(promptSessionId) + inlineCode != null -> visitor.visitInlineCode(inlineCode) + inlinePrompt != null -> visitor.visitInlinePrompt(inlinePrompt) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Task = - apply { - if (validated) { - return@apply - } + fun validate(): Task = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitFunctionId(functionId: FunctionId) { - functionId.validate() + functionId.validate() } override fun visitProjectSlug(projectSlug: ProjectSlug) { - projectSlug.validate() + projectSlug.validate() } override fun visitGlobalFunction(globalFunction: GlobalFunction) { - globalFunction.validate() + globalFunction.validate() } override fun visitPromptSessionId(promptSessionId: PromptSessionId) { - promptSessionId.validate() + promptSessionId.validate() } override fun visitInlineCode(inlineCode: InlineCode) { - inlineCode.validate() + inlineCode.validate() } override fun visitInlinePrompt(inlinePrompt: InlinePrompt) { - inlinePrompt.validate() + inlinePrompt.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Task && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ + return /* spotless:off */ other is Task && functionId == other.functionId && projectSlug == other.projectSlug && globalFunction == other.globalFunction && promptSessionId == other.promptSessionId && inlineCode == other.inlineCode && inlinePrompt == other.inlinePrompt /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, projectSlug, globalFunction, promptSessionId, inlineCode, inlinePrompt) /* spotless:on */ @@ -3430,34 +3195,30 @@ class EvalCreateParams private constructor( companion object { /** Function id */ - @JvmStatic - fun ofFunctionId(functionId: FunctionId) = Task(functionId = functionId) + @JvmStatic fun ofFunctionId(functionId: FunctionId) = Task(functionId = functionId) /** Project name and slug */ - @JvmStatic - fun ofProjectSlug(projectSlug: ProjectSlug) = Task(projectSlug = projectSlug) + @JvmStatic fun ofProjectSlug(projectSlug: ProjectSlug) = Task(projectSlug = projectSlug) /** Global function name */ @JvmStatic - fun ofGlobalFunction(globalFunction: GlobalFunction) = Task(globalFunction = globalFunction) + fun ofGlobalFunction(globalFunction: GlobalFunction) = + Task(globalFunction = globalFunction) /** Prompt session id */ @JvmStatic - fun ofPromptSessionId(promptSessionId: PromptSessionId) = Task(promptSessionId = promptSessionId) + fun ofPromptSessionId(promptSessionId: PromptSessionId) = + Task(promptSessionId = promptSessionId) /** Inline code function */ - @JvmStatic - fun ofInlineCode(inlineCode: InlineCode) = Task(inlineCode = inlineCode) + @JvmStatic fun ofInlineCode(inlineCode: InlineCode) = Task(inlineCode = inlineCode) /** Inline prompt definition */ @JvmStatic fun ofInlinePrompt(inlinePrompt: InlinePrompt) = Task(inlinePrompt = inlinePrompt) } - /** - * An interface that defines how to map each variant of [Task] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Task] to a value of type [T]. */ interface Visitor { /** Function id */ @@ -3481,69 +3242,84 @@ class EvalCreateParams private constructor( /** * Maps an unknown variant of [Task] to a value of type [T]. * - * An instance of [Task] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Task] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Task: $json") + throw BraintrustInvalidDataException("Unknown Task: $json") } } internal class Deserializer : BaseDeserializer(Task::class) { override fun ObjectCodec.deserialize(node: JsonNode): Task { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Task(functionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Task(projectSlug = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Task(globalFunction = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Task(promptSessionId = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Task(inlineCode = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Task(inlinePrompt = it, _json = json) - } - - return Task(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Task(functionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Task(projectSlug = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Task(globalFunction = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Task(promptSessionId = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Task(inlineCode = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Task(inlinePrompt = it, _json = json) + } + + return Task(_json = json) } } internal class Serializer : BaseSerializer(Task::class) { - override fun serialize(value: Task, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.functionId != null -> generator.writeObject(value.functionId) - value.projectSlug != null -> generator.writeObject(value.projectSlug) - value.globalFunction != null -> generator.writeObject(value.globalFunction) - value.promptSessionId != null -> generator.writeObject(value.promptSessionId) - value.inlineCode != null -> generator.writeObject(value.inlineCode) - value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Task") - } + override fun serialize( + value: Task, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.functionId != null -> generator.writeObject(value.functionId) + value.projectSlug != null -> generator.writeObject(value.projectSlug) + value.globalFunction != null -> generator.writeObject(value.globalFunction) + value.promptSessionId != null -> generator.writeObject(value.promptSessionId) + value.inlineCode != null -> generator.writeObject(value.inlineCode) + value.inlinePrompt != null -> generator.writeObject(value.inlinePrompt) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Task") + } } } /** Function id */ @NoAutoDetect - class FunctionId @JsonCreator private constructor( - @JsonProperty("function_id") @ExcludeMissing private val functionId: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class FunctionId + @JsonCreator + private constructor( + @JsonProperty("function_id") + @ExcludeMissing + private val functionId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The ID of the function */ @@ -3558,9 +3334,7 @@ class EvalCreateParams private constructor( fun _functionId(): JsonField = functionId /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -3568,17 +3342,16 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): FunctionId = - apply { - if (validated) { - return@apply - } - - functionId() - version() - validated = true + fun validate(): FunctionId = apply { + if (validated) { + return@apply } + functionId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3587,13 +3360,11 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [FunctionId]. * * The following fields are required: - * * ```java * .functionId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionId]. */ @@ -3604,73 +3375,62 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionId: FunctionId) = - apply { - this.functionId = functionId.functionId - version = functionId.version - additionalProperties = functionId.additionalProperties.toMutableMap() - } + internal fun from(functionId: FunctionId) = apply { + this.functionId = functionId.functionId + version = functionId.version + additionalProperties = functionId.additionalProperties.toMutableMap() + } /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) /** The ID of the function */ - fun functionId(functionId: JsonField) = - apply { - this.functionId = functionId - } + fun functionId(functionId: JsonField) = apply { + this.functionId = functionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionId = FunctionId( - checkRequired( - "functionId", functionId - ), - version, - additionalProperties.toImmutable(), + checkRequired("functionId", functionId), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionId && functionId == other.functionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3679,17 +3439,26 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionId{functionId=$functionId, version=$version, additionalProperties=$additionalProperties}" } /** Project name and slug */ @NoAutoDetect - class ProjectSlug @JsonCreator private constructor( - @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class ProjectSlug + @JsonCreator + private constructor( + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the project containing the function */ @@ -3707,14 +3476,10 @@ class EvalCreateParams private constructor( fun _projectName(): JsonField = projectName /** The slug of the function */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -3722,18 +3487,17 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): ProjectSlug = - apply { - if (validated) { - return@apply - } - - projectName() - slug() - version() - validated = true + fun validate(): ProjectSlug = apply { + if (validated) { + return@apply } + projectName() + slug() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3742,14 +3506,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [ProjectSlug]. * * The following fields are required: - * * ```java * .projectName() * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectSlug]. */ @@ -3761,86 +3523,70 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSlug: ProjectSlug) = - apply { - projectName = projectSlug.projectName - slug = projectSlug.slug - version = projectSlug.version - additionalProperties = projectSlug.additionalProperties.toMutableMap() - } + internal fun from(projectSlug: ProjectSlug) = apply { + projectName = projectSlug.projectName + slug = projectSlug.slug + version = projectSlug.version + additionalProperties = projectSlug.additionalProperties.toMutableMap() + } /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** The name of the project containing the function */ - fun projectName(projectName: JsonField) = - apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = apply { + this.projectName = projectName + } /** The slug of the function */ fun slug(slug: String) = slug(JsonField.of(slug)) /** The slug of the function */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSlug = ProjectSlug( - checkRequired( - "projectName", projectName - ), - checkRequired( - "slug", slug - ), - version, - additionalProperties.toImmutable(), + checkRequired("projectName", projectName), + checkRequired("slug", slug), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSlug && projectName == other.projectName && slug == other.slug && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3849,15 +3595,20 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectSlug{projectName=$projectName, slug=$slug, version=$version, additionalProperties=$additionalProperties}" } /** Global function name */ @NoAutoDetect - class GlobalFunction @JsonCreator private constructor( - @JsonProperty("global_function") @ExcludeMissing private val globalFunction: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class GlobalFunction + @JsonCreator + private constructor( + @JsonProperty("global_function") + @ExcludeMissing + private val globalFunction: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** @@ -3880,16 +3631,15 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): GlobalFunction = - apply { - if (validated) { - return@apply - } - - globalFunction() - validated = true + fun validate(): GlobalFunction = apply { + if (validated) { + return@apply } + globalFunction() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3898,13 +3648,11 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [GlobalFunction]. * * The following fields are required: - * * ```java * .globalFunction() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GlobalFunction]. */ @@ -3914,67 +3662,61 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(globalFunction: GlobalFunction) = - apply { - this.globalFunction = globalFunction.globalFunction - additionalProperties = globalFunction.additionalProperties.toMutableMap() - } + internal fun from(globalFunction: GlobalFunction) = apply { + this.globalFunction = globalFunction.globalFunction + additionalProperties = globalFunction.additionalProperties.toMutableMap() + } /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: String) = globalFunction(JsonField.of(globalFunction)) + fun globalFunction(globalFunction: String) = + globalFunction(JsonField.of(globalFunction)) /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals */ - fun globalFunction(globalFunction: JsonField) = - apply { - this.globalFunction = globalFunction - } + fun globalFunction(globalFunction: JsonField) = apply { + this.globalFunction = globalFunction + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GlobalFunction = GlobalFunction( - checkRequired( - "globalFunction", globalFunction - ), additionalProperties.toImmutable() + checkRequired("globalFunction", globalFunction), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GlobalFunction && globalFunction == other.globalFunction && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3983,21 +3725,31 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" + override fun toString() = + "GlobalFunction{globalFunction=$globalFunction, additionalProperties=$additionalProperties}" } /** Prompt session id */ @NoAutoDetect - class PromptSessionId @JsonCreator private constructor( - @JsonProperty("prompt_session_function_id") @ExcludeMissing private val promptSessionFunctionId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_session_id") @ExcludeMissing private val promptSessionId: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class PromptSessionId + @JsonCreator + private constructor( + @JsonProperty("prompt_session_function_id") + @ExcludeMissing + private val promptSessionFunctionId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_session_id") + @ExcludeMissing + private val promptSessionId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") + fun promptSessionFunctionId(): String = + promptSessionFunctionId.getRequired("prompt_session_function_id") /** The ID of the prompt session */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") @@ -4016,9 +3768,7 @@ class EvalCreateParams private constructor( fun _promptSessionId(): JsonField = promptSessionId /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -4026,18 +3776,17 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): PromptSessionId = - apply { - if (validated) { - return@apply - } - - promptSessionFunctionId() - promptSessionId() - version() - validated = true + fun validate(): PromptSessionId = apply { + if (validated) { + return@apply } + promptSessionFunctionId() + promptSessionId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -4046,14 +3795,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [PromptSessionId]. * * The following fields are required: - * * ```java * .promptSessionFunctionId() * .promptSessionId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptSessionId]. */ @@ -4065,86 +3812,74 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptSessionId: PromptSessionId) = - apply { - promptSessionFunctionId = promptSessionId.promptSessionFunctionId - this.promptSessionId = promptSessionId.promptSessionId - version = promptSessionId.version - additionalProperties = promptSessionId.additionalProperties.toMutableMap() - } + internal fun from(promptSessionId: PromptSessionId) = apply { + promptSessionFunctionId = promptSessionId.promptSessionFunctionId + this.promptSessionId = promptSessionId.promptSessionId + version = promptSessionId.version + additionalProperties = promptSessionId.additionalProperties.toMutableMap() + } /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: String) = promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) + fun promptSessionFunctionId(promptSessionFunctionId: String) = + promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) /** The ID of the function in the prompt session */ - fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = - apply { - this.promptSessionFunctionId = promptSessionFunctionId - } + fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { + this.promptSessionFunctionId = promptSessionFunctionId + } /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: String) = promptSessionId(JsonField.of(promptSessionId)) + fun promptSessionId(promptSessionId: String) = + promptSessionId(JsonField.of(promptSessionId)) - /** The ID of the prompt session */ - fun promptSessionId(promptSessionId: JsonField) = - apply { - this.promptSessionId = promptSessionId - } + /** The ID of the prompt session */ + fun promptSessionId(promptSessionId: JsonField) = apply { + this.promptSessionId = promptSessionId + } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptSessionId = PromptSessionId( - checkRequired( - "promptSessionFunctionId", promptSessionFunctionId - ), - checkRequired( - "promptSessionId", promptSessionId - ), - version, - additionalProperties.toImmutable(), + checkRequired("promptSessionFunctionId", promptSessionFunctionId), + checkRequired("promptSessionId", promptSessionId), + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptSessionId && promptSessionFunctionId == other.promptSessionFunctionId && promptSessionId == other.promptSessionId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4153,17 +3888,26 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptSessionId{promptSessionFunctionId=$promptSessionFunctionId, promptSessionId=$promptSessionId, version=$version, additionalProperties=$additionalProperties}" } /** Inline code function */ @NoAutoDetect - class InlineCode @JsonCreator private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("inline_context") @ExcludeMissing private val inlineContext: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InlineCode + @JsonCreator + private constructor( + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("inline_context") + @ExcludeMissing + private val inlineContext: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The inline code to execute */ @@ -4175,18 +3919,14 @@ class EvalCreateParams private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The inline code to execute */ - @JsonProperty("code") - @ExcludeMissing - fun _code(): JsonField = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext(): JsonField = inlineContext /** The name of the inline code function */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -4194,18 +3934,17 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): InlineCode = - apply { - if (validated) { - return@apply - } - - code() - inlineContext().validate() - name() - validated = true + fun validate(): InlineCode = apply { + if (validated) { + return@apply } + code() + inlineContext().validate() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -4214,14 +3953,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [InlineCode]. * * The following fields are required: - * * ```java * .code() * .inlineContext() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InlineCode]. */ @@ -4233,29 +3970,25 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineCode: InlineCode) = - apply { - code = inlineCode.code - inlineContext = inlineCode.inlineContext - name = inlineCode.name - additionalProperties = inlineCode.additionalProperties.toMutableMap() - } + internal fun from(inlineCode: InlineCode) = apply { + code = inlineCode.code + inlineContext = inlineCode.inlineContext + name = inlineCode.name + additionalProperties = inlineCode.additionalProperties.toMutableMap() + } /** The inline code to execute */ fun code(code: String) = code(JsonField.of(code)) /** The inline code to execute */ - fun code(code: JsonField) = - apply { - this.code = code - } + fun code(code: JsonField) = apply { this.code = code } - fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) + fun inlineContext(inlineContext: InlineContext) = + inlineContext(JsonField.of(inlineContext)) - fun inlineContext(inlineContext: JsonField) = - apply { - this.inlineContext = inlineContext - } + fun inlineContext(inlineContext: JsonField) = apply { + this.inlineContext = inlineContext + } /** The name of the inline code function */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -4264,56 +3997,51 @@ class EvalCreateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline code function */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineCode = InlineCode( - checkRequired( - "code", code - ), - checkRequired( - "inlineContext", inlineContext - ), - name, - additionalProperties.toImmutable(), + checkRequired("code", code), + checkRequired("inlineContext", inlineContext), + name, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InlineContext @JsonCreator private constructor( - @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InlineContext + @JsonCreator + private constructor( + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -4324,9 +4052,7 @@ class EvalCreateParams private constructor( @ExcludeMissing fun _runtime(): JsonField = runtime - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -4334,17 +4060,16 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): InlineContext = - apply { - if (validated) { - return@apply - } - - runtime() - version() - validated = true + fun validate(): InlineContext = apply { + if (validated) { + return@apply } + runtime() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -4353,14 +4078,12 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [InlineContext]. * * The following fields are required: - * * ```java * .runtime() * .version() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InlineContext]. */ @@ -4371,77 +4094,61 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlineContext: InlineContext) = - apply { - runtime = inlineContext.runtime - version = inlineContext.version - additionalProperties = inlineContext.additionalProperties.toMutableMap() - } + internal fun from(inlineContext: InlineContext) = apply { + runtime = inlineContext.runtime + version = inlineContext.version + additionalProperties = inlineContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = - apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlineContext = InlineContext( - checkRequired( - "runtime", runtime - ), - checkRequired( - "version", version - ), - additionalProperties.toImmutable(), + checkRequired("runtime", runtime), + checkRequired("version", version), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Runtime + @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. + * 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 @@ -4465,17 +4172,18 @@ class EvalCreateParams private constructor( * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Runtime] 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 { NODE, PYTHON, - /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Runtime] was instantiated with an unknown + * value. + */ _UNKNOWN, } @@ -4483,8 +4191,8 @@ class EvalCreateParams private constructor( * 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. + * 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) { @@ -4496,11 +4204,11 @@ class EvalCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a + * not a known member. */ fun known(): Known = when (this) { @@ -4515,17 +4223,20 @@ class EvalCreateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4534,11 +4245,11 @@ class EvalCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4547,15 +4258,16 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "InlineContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlineCode && code == other.code && inlineContext == other.inlineContext && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4564,20 +4276,28 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "InlineCode{code=$code, inlineContext=$inlineContext, name=$name, additionalProperties=$additionalProperties}" } /** Inline prompt definition */ @NoAutoDetect - class InlinePrompt @JsonCreator private constructor( - @JsonProperty("inline_prompt") @ExcludeMissing private val inlinePrompt: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InlinePrompt + @JsonCreator + private constructor( + @JsonProperty("inline_prompt") + @ExcludeMissing + private val inlinePrompt: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The prompt, model, and its parameters */ - fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) + fun inlinePrompt(): Optional = + Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) /** The name of the inline prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -4588,9 +4308,7 @@ class EvalCreateParams private constructor( fun _inlinePrompt(): JsonField = inlinePrompt /** The name of the inline prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -4598,17 +4316,16 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): InlinePrompt = - apply { - if (validated) { - return@apply - } - - inlinePrompt().ifPresent { it.validate() } - name() - validated = true + fun validate(): InlinePrompt = apply { + if (validated) { + return@apply } + inlinePrompt().ifPresent { it.validate() } + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -4617,13 +4334,11 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [InlinePrompt]. * * The following fields are required: - * * ```java * .inlinePrompt() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InlinePrompt]. */ @@ -4634,24 +4349,24 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inlinePrompt: InlinePrompt) = - apply { - this.inlinePrompt = inlinePrompt.inlinePrompt - name = inlinePrompt.name - additionalProperties = inlinePrompt.additionalProperties.toMutableMap() - } + internal fun from(inlinePrompt: InlinePrompt) = apply { + this.inlinePrompt = inlinePrompt.inlinePrompt + name = inlinePrompt.name + additionalProperties = inlinePrompt.additionalProperties.toMutableMap() + } /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: PromptData?) = inlinePrompt(JsonField.ofNullable(inlinePrompt)) + fun inlinePrompt(inlinePrompt: PromptData?) = + inlinePrompt(JsonField.ofNullable(inlinePrompt)) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: Optional) = inlinePrompt(inlinePrompt.getOrNull()) + fun inlinePrompt(inlinePrompt: Optional) = + inlinePrompt(inlinePrompt.getOrNull()) /** The prompt, model, and its parameters */ - fun inlinePrompt(inlinePrompt: JsonField) = - apply { - this.inlinePrompt = inlinePrompt - } + fun inlinePrompt(inlinePrompt: JsonField) = apply { + this.inlinePrompt = inlinePrompt + } /** The name of the inline prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -4660,53 +4375,44 @@ class EvalCreateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** The name of the inline prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InlinePrompt = InlinePrompt( - checkRequired( - "inlinePrompt", inlinePrompt - ), - name, - additionalProperties.toImmutable(), + checkRequired("inlinePrompt", inlinePrompt), + name, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InlinePrompt && inlinePrompt == other.inlinePrompt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4715,33 +4421,36 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "InlinePrompt{inlinePrompt=$inlinePrompt, name=$name, additionalProperties=$additionalProperties}" } } /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Optional settings for collecting git metadata. By default, will collect all git metadata + * fields allowed in org-level settings. */ @NoAutoDetect - class GitMetadataSettings @JsonCreator private constructor( - @JsonProperty("collect") @ExcludeMissing private val collect: JsonField = JsonMissing.of(), - @JsonProperty("fields") @ExcludeMissing private val fields: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class GitMetadataSettings + @JsonCreator + private constructor( + @JsonProperty("collect") + @ExcludeMissing + private val collect: JsonField = JsonMissing.of(), + @JsonProperty("fields") + @ExcludeMissing + private val fields: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun collect(): Collect = collect.getRequired("collect") fun fields(): Optional> = Optional.ofNullable(fields.getNullable("fields")) - @JsonProperty("collect") - @ExcludeMissing - fun _collect(): JsonField = collect + @JsonProperty("collect") @ExcludeMissing fun _collect(): JsonField = collect - @JsonProperty("fields") - @ExcludeMissing - fun _fields(): JsonField> = fields + @JsonProperty("fields") @ExcludeMissing fun _fields(): JsonField> = fields @JsonAnyGetter @ExcludeMissing @@ -4749,17 +4458,16 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): GitMetadataSettings = - apply { - if (validated) { - return@apply - } - - collect() - fields() - validated = true + fun validate(): GitMetadataSettings = apply { + if (validated) { + return@apply } + collect() + fields() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -4768,13 +4476,11 @@ class EvalCreateParams private constructor( * Returns a mutable builder for constructing an instance of [GitMetadataSettings]. * * The following fields are required: - * * ```java * .collect() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GitMetadataSettings]. */ @@ -4785,85 +4491,68 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(gitMetadataSettings: GitMetadataSettings) = - apply { - collect = gitMetadataSettings.collect - fields = gitMetadataSettings.fields.map { it.toMutableList() } - additionalProperties = gitMetadataSettings.additionalProperties.toMutableMap() - } + internal fun from(gitMetadataSettings: GitMetadataSettings) = apply { + collect = gitMetadataSettings.collect + fields = gitMetadataSettings.fields.map { it.toMutableList() } + additionalProperties = gitMetadataSettings.additionalProperties.toMutableMap() + } fun collect(collect: Collect) = collect(JsonField.of(collect)) - fun collect(collect: JsonField) = - apply { - this.collect = collect - } + fun collect(collect: JsonField) = apply { this.collect = collect } fun fields(fields: List) = fields(JsonField.of(fields)) - fun fields(fields: JsonField>) = - apply { - this.fields = fields.map { it.toMutableList() } - } + fun fields(fields: JsonField>) = apply { + this.fields = fields.map { it.toMutableList() } + } - fun addField(field: Field) = - apply { - fields = (fields ?: JsonField.of(mutableListOf())).also { + fun addField(field: Field) = apply { + fields = + (fields ?: JsonField.of(mutableListOf())).also { checkKnown("fields", it).add(field) } - } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GitMetadataSettings = GitMetadataSettings( - checkRequired( - "collect", collect - ), - (fields ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("collect", collect), + (fields ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Collect @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Collect @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -4887,18 +4576,18 @@ class EvalCreateParams private constructor( * An enum containing [Collect]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Collect] 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 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 { ALL, NONE, SOME, - /** An enum member indicating that [Collect] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Collect] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -4906,8 +4595,8 @@ class EvalCreateParams private constructor( * 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. + * 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) { @@ -4924,7 +4613,7 @@ class EvalCreateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -4940,17 +4629,20 @@ class EvalCreateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ + return /* spotless:off */ other is Collect && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4958,21 +4650,17 @@ class EvalCreateParams private constructor( override fun toString() = value.toString() } - class Field @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Field @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -5014,11 +4702,9 @@ class EvalCreateParams private constructor( * An enum containing [Field]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Field] 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 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 { @@ -5031,7 +4717,9 @@ class EvalCreateParams private constructor( COMMIT_MESSAGE, COMMIT_TIME, GIT_DIFF, - /** An enum member indicating that [Field] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Field] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -5039,8 +4727,8 @@ class EvalCreateParams private constructor( * 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. + * 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) { @@ -5063,7 +4751,7 @@ class EvalCreateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -5085,17 +4773,20 @@ class EvalCreateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Field && value == other.value /* spotless:on */ + return /* spotless:off */ other is Field && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -5104,11 +4795,11 @@ class EvalCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GitMetadataSettings && collect == other.collect && fields == other.fields && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GitMetadataSettings && collect == other.collect && fields == other.fields && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5117,17 +4808,20 @@ class EvalCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "GitMetadataSettings{collect=$collect, fields=$fields, additionalProperties=$additionalProperties}" + override fun toString() = + "GitMetadataSettings{collect=$collect, fields=$fields, additionalProperties=$additionalProperties}" } /** - * Optional experiment-level metadata to store about the evaluation. You can later - * use this to slice & dice across experiments. + * Optional experiment-level metadata to store about the evaluation. You can later use this to + * slice & dice across experiments. */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -5136,22 +4830,20 @@ class EvalCreateParams private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -5160,46 +4852,38 @@ class EvalCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5212,14 +4896,15 @@ class EvalCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is EvalCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is EvalCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "EvalCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "EvalCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 8fd15406..15cc8fb6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -20,23 +20,48 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Experiment @JsonCreator private constructor( +class Experiment +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), - @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("commit") @ExcludeMissing private val commit: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("public") + @ExcludeMissing + private val public_: JsonField = JsonMissing.of(), + @JsonProperty("base_exp_id") + @ExcludeMissing + private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("commit") + @ExcludeMissing + private val commit: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") + @ExcludeMissing + private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") + @ExcludeMissing + private val repoInfo: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the experiment */ @@ -49,8 +74,8 @@ class Experiment @JsonCreator private constructor( fun projectId(): String = projectId.getRequired("project_id") /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization */ fun public_(): Boolean = public_.getRequired("public") @@ -63,23 +88,23 @@ class Experiment @JsonCreator private constructor( /** Date of experiment creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = + Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the experiment */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -91,54 +116,35 @@ class Experiment @JsonCreator private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the experiment */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization */ - @JsonProperty("public") - @ExcludeMissing - fun _public_(): JsonField = public_ + @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - @ExcludeMissing - fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId /** Commit, taken directly from `repo_info.commit` */ - @JsonProperty("commit") - @ExcludeMissing - fun _commit(): JsonField = commit + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit /** Date of experiment creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun _datasetId(): JsonField = datasetId + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -150,24 +156,16 @@ class Experiment @JsonCreator private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the experiment */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - @ExcludeMissing - fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo /** Identifies the user who created the experiment */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -175,29 +173,28 @@ class Experiment @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Experiment = - apply { - if (validated) { - return@apply - } - - id() - name() - projectId() - public_() - baseExpId() - commit() - created() - datasetId() - datasetVersion() - deletedAt() - description() - metadata().ifPresent { it.validate() } - repoInfo().ifPresent { it.validate() } - userId() - validated = true + fun validate(): Experiment = apply { + if (validated) { + return@apply } + id() + name() + projectId() + public_() + baseExpId() + commit() + created() + datasetId() + datasetVersion() + deletedAt() + description() + metadata().ifPresent { it.validate() } + repoInfo().ifPresent { it.validate() } + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -206,7 +203,6 @@ class Experiment @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Experiment]. * * The following fields are required: - * * ```java * .id() * .name() @@ -214,8 +210,7 @@ class Experiment @JsonCreator private constructor( * .public_() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Experiment]. */ @@ -238,66 +233,53 @@ class Experiment @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experiment: Experiment) = - apply { - id = experiment.id - name = experiment.name - projectId = experiment.projectId - public_ = experiment.public_ - baseExpId = experiment.baseExpId - commit = experiment.commit - created = experiment.created - datasetId = experiment.datasetId - datasetVersion = experiment.datasetVersion - deletedAt = experiment.deletedAt - description = experiment.description - metadata = experiment.metadata - repoInfo = experiment.repoInfo - userId = experiment.userId - additionalProperties = experiment.additionalProperties.toMutableMap() - } + internal fun from(experiment: Experiment) = apply { + id = experiment.id + name = experiment.name + projectId = experiment.projectId + public_ = experiment.public_ + baseExpId = experiment.baseExpId + commit = experiment.commit + created = experiment.created + datasetId = experiment.datasetId + datasetVersion = experiment.datasetVersion + deletedAt = experiment.deletedAt + description = experiment.description + metadata = experiment.metadata + repoInfo = experiment.repoInfo + userId = experiment.userId + additionalProperties = experiment.additionalProperties.toMutableMap() + } /** Unique identifier for the experiment */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the experiment */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String) = name(JsonField.of(name)) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Boolean) = public_(JsonField.of(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: JsonField) = - apply { - this.public_ = public_ - } + fun public_(public_: JsonField) = apply { this.public_ = public_ } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -306,10 +288,7 @@ class Experiment @JsonCreator private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = - apply { - this.baseExpId = baseExpId - } + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } /** Commit, taken directly from `repo_info.commit` */ fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) @@ -318,10 +297,7 @@ class Experiment @JsonCreator private constructor( fun commit(commit: Optional) = commit(commit.getOrNull()) /** Commit, taken directly from `repo_info.commit` */ - fun commit(commit: JsonField) = - apply { - this.commit = commit - } + fun commit(commit: JsonField) = apply { this.commit = commit } /** Date of experiment creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -330,52 +306,44 @@ class Experiment @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of experiment creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: JsonField) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = + datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = - apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = apply { + this.datasetVersion = datasetVersion + } /** Date of experiment deletion, or null if the experiment is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -384,10 +352,7 @@ class Experiment @JsonCreator private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of experiment deletion, or null if the experiment is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -396,10 +361,7 @@ class Experiment @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -408,10 +370,7 @@ class Experiment @JsonCreator private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -420,10 +379,7 @@ class Experiment @JsonCreator private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = - apply { - this.repoInfo = repoInfo - } + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } /** Identifies the user who created the experiment */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -432,70 +388,54 @@ class Experiment @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the experiment */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Experiment = Experiment( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "public_", public_ - ), - baseExpId, - commit, - created, - datasetId, - datasetVersion, - deletedAt, - description, - metadata, - repoInfo, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("public_", public_), + baseExpId, + commit, + created, + datasetId, + datasetVersion, + deletedAt, + description, + metadata, + repoInfo, + userId, + additionalProperties.toImmutable(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -504,22 +444,20 @@ class Experiment @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -528,46 +466,38 @@ class Experiment @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -580,11 +510,11 @@ class Experiment @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Experiment && id == other.id && name == other.name && projectId == other.projectId && public_ == other.public_ && baseExpId == other.baseExpId && commit == other.commit && created == other.created && datasetId == other.datasetId && datasetVersion == other.datasetVersion && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && repoInfo == other.repoInfo && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Experiment && id == other.id && name == other.name && projectId == other.projectId && public_ == other.public_ && baseExpId == other.baseExpId && commit == other.commit && created == other.created && datasetId == other.datasetId && datasetVersion == other.datasetVersion && deletedAt == other.deletedAt && description == other.description && metadata == other.metadata && repoInfo == other.repoInfo && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -593,5 +523,6 @@ class Experiment @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Experiment{id=$id, name=$name, projectId=$projectId, public_=$public_, baseExpId=$baseExpId, commit=$commit, created=$created, datasetId=$datasetId, datasetVersion=$datasetVersion, deletedAt=$deletedAt, description=$description, metadata=$metadata, repoInfo=$repoInfo, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "Experiment{id=$id, name=$name, projectId=$projectId, public_=$public_, baseExpId=$baseExpId, commit=$commit, created=$created, datasetId=$datasetId, datasetVersion=$datasetVersion, deletedAt=$deletedAt, description=$description, metadata=$metadata, repoInfo=$repoInfo, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index 8a9b0ec5..ae017556 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -22,15 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new experiment. If there is an existing experiment in the project with - * the same name as the one specified in the request, will return the existing - * experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with the same name as + * the one specified in the request, will return the existing experiment unmodified */ -class ExperimentCreateParams private constructor( +class ExperimentCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Unique identifier for the project that the experiment belongs under */ @@ -39,15 +38,12 @@ class ExperimentCreateParams private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(): Optional = body.baseExpId() - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(): Optional = body.datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ fun datasetVersion(): Optional = body.datasetVersion() @@ -55,10 +51,9 @@ class ExperimentCreateParams private constructor( fun description(): Optional = body.description() /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return the + * existing one un-modified. But if `ensure_new` is true, registration will generate a new + * experiment with a unique name in case of a conflict. */ fun ensureNew(): Optional = body.ensureNew() @@ -69,8 +64,8 @@ class ExperimentCreateParams private constructor( fun name(): Optional = body.name() /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization */ fun public_(): Optional = body.public_() @@ -83,15 +78,12 @@ class ExperimentCreateParams private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun _baseExpId(): JsonField = body._baseExpId() - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun _datasetId(): JsonField = body._datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ fun _datasetVersion(): JsonField = body._datasetVersion() @@ -99,10 +91,9 @@ class ExperimentCreateParams private constructor( fun _description(): JsonField = body._description() /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return the + * existing one un-modified. But if `ensure_new` is true, registration will generate a new + * experiment with a unique name in case of a conflict. */ fun _ensureNew(): JsonField = body._ensureNew() @@ -113,8 +104,8 @@ class ExperimentCreateParams private constructor( fun _name(): JsonField = body._name() /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization */ fun _public_(): JsonField = body._public_() @@ -127,57 +118,80 @@ class ExperimentCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("ensure_new") @ExcludeMissing private val ensureNew: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("base_exp_id") + @ExcludeMissing + private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") + @ExcludeMissing + private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("ensure_new") + @ExcludeMissing + private val ensureNew: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("public") + @ExcludeMissing + private val public_: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") + @ExcludeMissing + private val repoInfo: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Unique identifier for the project that the experiment belongs under */ fun projectId(): String = projectId.getRequired("project_id") /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + fun baseExpId(): Optional = + Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = + Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Textual description of the experiment */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. */ - fun ensureNew(): Optional = Optional.ofNullable(ensureNew.getNullable("ensure_new")) + fun ensureNew(): Optional = + Optional.ofNullable(ensureNew.getNullable("ensure_new")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -186,8 +200,8 @@ class ExperimentCreateParams private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) @@ -195,26 +209,19 @@ class ExperimentCreateParams private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - @ExcludeMissing - fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -226,37 +233,26 @@ class ExperimentCreateParams private constructor( fun _description(): JsonField = description /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. */ - @JsonProperty("ensure_new") - @ExcludeMissing - fun _ensureNew(): JsonField = ensureNew + @JsonProperty("ensure_new") @ExcludeMissing fun _ensureNew(): JsonField = ensureNew /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - @JsonProperty("public") - @ExcludeMissing - fun _public_(): JsonField = public_ + @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - @ExcludeMissing - fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @ExcludeMissing @@ -264,24 +260,23 @@ class ExperimentCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - projectId() - baseExpId() - datasetId() - datasetVersion() - description() - ensureNew() - metadata().ifPresent { it.validate() } - name() - public_() - repoInfo().ifPresent { it.validate() } - validated = true - } + fun validate(): Body = apply { + if (validated) { + return@apply + } + + projectId() + baseExpId() + datasetId() + datasetVersion() + description() + ensureNew() + metadata().ifPresent { it.validate() } + name() + public_() + repoInfo().ifPresent { it.validate() } + validated = true + } fun toBuilder() = Builder().from(this) @@ -291,13 +286,11 @@ class ExperimentCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -316,29 +309,25 @@ class ExperimentCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - projectId = body.projectId - baseExpId = body.baseExpId - datasetId = body.datasetId - datasetVersion = body.datasetVersion - description = body.description - ensureNew = body.ensureNew - metadata = body.metadata - name = body.name - public_ = body.public_ - repoInfo = body.repoInfo - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + projectId = body.projectId + baseExpId = body.baseExpId + datasetId = body.datasetId + datasetVersion = body.datasetVersion + description = body.description + ensureNew = body.ensureNew + metadata = body.metadata + name = body.name + public_ = body.public_ + repoInfo = body.repoInfo + additionalProperties = body.additionalProperties.toMutableMap() + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -347,10 +336,7 @@ class ExperimentCreateParams private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = - apply { - this.baseExpId = baseExpId - } + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } /** * Identifier of the linked dataset, or null if the experiment is not linked to a @@ -368,31 +354,29 @@ class ExperimentCreateParams private constructor( * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - fun datasetId(datasetId: JsonField) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = + datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = - apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = apply { + this.datasetVersion = datasetVersion + } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -401,45 +385,37 @@ class ExperimentCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will + * return the existing one un-modified. But if `ensure_new` is true, registration will + * generate a new experiment with a unique name in case of a conflict. */ fun ensureNew(ensureNew: Boolean?) = ensureNew(JsonField.ofNullable(ensureNew)) /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will + * return the existing one un-modified. But if `ensure_new` is true, registration will + * generate a new experiment with a unique name in case of a conflict. */ fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will + * return the existing one un-modified. But if `ensure_new` is true, registration will + * generate a new experiment with a unique name in case of a conflict. */ fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will + * return the existing one un-modified. But if `ensure_new` is true, registration will + * generate a new experiment with a unique name in case of a conflict. */ - fun ensureNew(ensureNew: JsonField) = - apply { - this.ensureNew = ensureNew - } + fun ensureNew(ensureNew: JsonField) = apply { this.ensureNew = ensureNew } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -448,10 +424,7 @@ class ExperimentCreateParams private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -460,37 +433,31 @@ class ExperimentCreateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: JsonField) = - apply { - this.public_ = public_ - } + fun public_(public_: JsonField) = apply { this.public_ = public_ } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -499,61 +466,49 @@ class ExperimentCreateParams private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = - apply { - this.repoInfo = repoInfo - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "projectId", projectId - ), - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties.toImmutable(), + checkRequired("projectId", projectId), + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && projectId == other.projectId && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && ensureNew == other.ensureNew && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -562,7 +517,8 @@ class ExperimentCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -570,17 +526,14 @@ class ExperimentCreateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentCreateParams]. + * Returns a mutable builder for constructing an instance of [ExperimentCreateParams]. * * The following fields are required: - * * ```java * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentCreateParams]. */ @@ -592,380 +545,283 @@ class ExperimentCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentCreateParams: ExperimentCreateParams) = - apply { - body = experimentCreateParams.body.toBuilder() - additionalHeaders = experimentCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentCreateParams: ExperimentCreateParams) = apply { + body = experimentCreateParams.body.toBuilder() + additionalHeaders = experimentCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentCreateParams.additionalQueryParams.toBuilder() + } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String?) = - apply { - body.baseExpId(baseExpId) - } + fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = - apply { - body.baseExpId(baseExpId) - } + fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: String?) = - apply { - body.datasetId(datasetId) - } + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: JsonField) = - apply { - body.datasetId(datasetId) - } + fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = - apply { - body.datasetVersion(datasetVersion) - } + fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = - apply { - body.datasetVersion(datasetVersion) - } + fun datasetVersion(datasetVersion: JsonField) = apply { + body.datasetVersion(datasetVersion) + } /** Textual description of the experiment */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the experiment */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. */ - fun ensureNew(ensureNew: Boolean?) = - apply { - body.ensureNew(ensureNew) - } + fun ensureNew(ensureNew: Boolean?) = apply { body.ensureNew(ensureNew) } /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. */ fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. */ fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** - * Normally, creating an experiment with the same name as an existing experiment - * will return the existing one un-modified. But if `ensure_new` is true, - * registration will generate a new experiment with a unique name in case of a - * conflict. + * Normally, creating an experiment with the same name as an existing experiment will return + * the existing one un-modified. But if `ensure_new` is true, registration will generate a + * new experiment with a unique name in case of a conflict. */ - fun ensureNew(ensureNew: JsonField) = - apply { - body.ensureNew(ensureNew) - } + fun ensureNew(ensureNew: JsonField) = apply { body.ensureNew(ensureNew) } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata?) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the experiment */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: Boolean?) = - apply { - body.public_(public_) - } + fun public_(public_: Boolean?) = apply { body.public_(public_) } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: JsonField) = - apply { - body.public_(public_) - } + fun public_(public_: JsonField) = apply { body.public_(public_) } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = - apply { - body.repoInfo(repoInfo) - } + fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = - apply { - body.repoInfo(repoInfo) - } + fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentCreateParams = ExperimentCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -974,22 +830,20 @@ class ExperimentCreateParams private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -998,46 +852,38 @@ class ExperimentCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1050,14 +896,15 @@ class ExperimentCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 15fd2523..6239af74 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an experiment object by its id */ -class ExperimentDeleteParams private constructor( +class ExperimentDeleteParams +private constructor( private val experimentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Experiment id */ @@ -31,17 +31,18 @@ class ExperimentDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -49,17 +50,14 @@ class ExperimentDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentDeleteParams]. + * Returns a mutable builder for constructing an instance of [ExperimentDeleteParams]. * * The following fields are required: - * * ```java * .experimentId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentDeleteParams]. */ @@ -72,190 +70,156 @@ class ExperimentDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentDeleteParams: ExperimentDeleteParams) = - apply { - experimentId = experimentDeleteParams.experimentId - additionalHeaders = experimentDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = experimentDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(experimentDeleteParams: ExperimentDeleteParams) = apply { + experimentId = experimentDeleteParams.experimentId + additionalHeaders = experimentDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + experimentDeleteParams.additionalBodyProperties.toMutableMap() + } /** Experiment id */ - fun experimentId(experimentId: String) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ExperimentDeleteParams = ExperimentDeleteParams( - checkRequired( - "experimentId", experimentId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("experimentId", experimentId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentDeleteParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ExperimentDeleteParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index e764766b..e49339eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -23,43 +23,75 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ExperimentEvent @JsonCreator private constructor( +class ExperimentEvent +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("experiment_id") @ExcludeMissing private val experimentId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") @ExcludeMissing private val datasetRecordId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("experiment_id") + @ExcludeMissing + private val experimentId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + private val context: JsonField = JsonMissing.of(), + @JsonProperty("dataset_record_id") + @ExcludeMissing + private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("is_root") + @ExcludeMissing + private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") + @ExcludeMissing + private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the experiment (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -76,72 +108,63 @@ class ExperimentEvent @JsonCreator private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun _error(): JsonValue = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate your experiments while + * digging into analyses. However, we may later use these values to re-score outputs or + * fine-tune your models */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected(): JsonValue = expected + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical */ - @JsonProperty("input") - @ExcludeMissing - fun _input(): JsonValue = input + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -149,63 +172,54 @@ class ExperimentEvent @JsonCreator private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question */ - @JsonProperty("output") - @ExcludeMissing - fun _output(): JsonValue = output + @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the root + * span of a trace, and should most often contain just one parent element for subspans */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the experiment (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Unique identifier for the experiment */ @JsonProperty("experiment_id") @@ -213,86 +227,65 @@ class ExperimentEvent @JsonCreator private constructor( fun _experimentId(): JsonField = experimentId /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** A unique identifier for the trace this experiment event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId(): JsonField = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event */ - @JsonProperty("context") - @ExcludeMissing - fun _context(): JsonField = context + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId(): JsonField = datasetRecordId /** Whether this span is a root span */ - @JsonProperty("is_root") - @ExcludeMissing - fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics(): JsonField = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") - @ExcludeMissing - fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores(): JsonField = scores + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -300,18 +293,15 @@ class ExperimentEvent @JsonCreator private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the root + * span of a trace, and should most often contain just one parent element for subspans */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -319,32 +309,31 @@ class ExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ExperimentEvent = - apply { - if (validated) { - return@apply - } - - id() - _xactId() - created() - experimentId() - projectId() - rootSpanId() - spanId() - context().ifPresent { it.validate() } - datasetRecordId() - isRoot() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanParents() - tags() - validated = true + fun validate(): ExperimentEvent = apply { + if (validated) { + return@apply } + id() + _xactId() + created() + experimentId() + projectId() + rootSpanId() + spanId() + context().ifPresent { it.validate() } + datasetRecordId() + isRoot() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanParents() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -353,7 +342,6 @@ class ExperimentEvent @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [ExperimentEvent]. * * The following fields are required: - * * ```java * .id() * ._xactId() @@ -364,8 +352,7 @@ class ExperimentEvent @JsonCreator private constructor( * .spanId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentEvent]. */ @@ -395,200 +382,160 @@ class ExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(experimentEvent: ExperimentEvent) = - apply { - id = experimentEvent.id - _xactId = experimentEvent._xactId - created = experimentEvent.created - experimentId = experimentEvent.experimentId - projectId = experimentEvent.projectId - rootSpanId = experimentEvent.rootSpanId - spanId = experimentEvent.spanId - context = experimentEvent.context - datasetRecordId = experimentEvent.datasetRecordId - error = experimentEvent.error - expected = experimentEvent.expected - input = experimentEvent.input - isRoot = experimentEvent.isRoot - metadata = experimentEvent.metadata - metrics = experimentEvent.metrics - origin = experimentEvent.origin - output = experimentEvent.output - scores = experimentEvent.scores - spanAttributes = experimentEvent.spanAttributes - spanParents = experimentEvent.spanParents.map { it.toMutableList() } - tags = experimentEvent.tags.map { it.toMutableList() } - additionalProperties = experimentEvent.additionalProperties.toMutableMap() - } + internal fun from(experimentEvent: ExperimentEvent) = apply { + id = experimentEvent.id + _xactId = experimentEvent._xactId + created = experimentEvent.created + experimentId = experimentEvent.experimentId + projectId = experimentEvent.projectId + rootSpanId = experimentEvent.rootSpanId + spanId = experimentEvent.spanId + context = experimentEvent.context + datasetRecordId = experimentEvent.datasetRecordId + error = experimentEvent.error + expected = experimentEvent.expected + input = experimentEvent.input + isRoot = experimentEvent.isRoot + metadata = experimentEvent.metadata + metrics = experimentEvent.metrics + origin = experimentEvent.origin + output = experimentEvent.output + scores = experimentEvent.scores + spanAttributes = experimentEvent.spanAttributes + spanParents = experimentEvent.spanParents.map { it.toMutableList() } + tags = experimentEvent.tags.map { it.toMutableList() } + additionalProperties = experimentEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the experiment (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the experiment (see the `version` parameter) */ - fun _xactId(_xactId: JsonField) = - apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the experiment event was created */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the experiment */ fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) /** Unique identifier for the experiment */ - fun experimentId(experimentId: JsonField) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: JsonField) = apply { + this.experimentId = experimentId + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A unique identifier for the trace this experiment event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this experiment event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = - apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different experiment events together as part of - * a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different experiment events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - fun spanId(spanId: JsonField) = - apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ - fun context(context: JsonField) = - apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String?) = datasetRecordId(JsonField.ofNullable(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String?) = + datasetRecordId(JsonField.ofNullable(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(datasetRecordId: Optional) = datasetRecordId(datasetRecordId.getOrNull()) + fun datasetRecordId(datasetRecordId: Optional) = + datasetRecordId(datasetRecordId.getOrNull()) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(datasetRecordId: JsonField) = - apply { - this.datasetRecordId = datasetRecordId - } + fun datasetRecordId(datasetRecordId: JsonField) = apply { + this.datasetRecordId = datasetRecordId + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = - apply { - this.error = error - } + fun error(error: JsonValue) = apply { this.error = error } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models */ - fun expected(expected: JsonValue) = - apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical */ - fun input(input: JsonValue) = - apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -600,64 +547,55 @@ class ExperimentEvent @JsonCreator private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = - apply { - this.isRoot = isRoot - } + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ - fun metrics(metrics: JsonField) = - apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -666,109 +604,93 @@ class ExperimentEvent @JsonCreator private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = - apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question */ - fun output(output: JsonValue) = - apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - fun scores(scores: JsonField) = - apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = + spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = + spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = - apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ - fun spanParents(spanParents: JsonField>) = - apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** - * An array of the parent `span_ids` of this experiment event. This should be empty - * for the root span of a trace, and should most often contain just one parent - * element for subspans + * An array of the parent `span_ids` of this experiment event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ - fun addSpanParent(spanParent: String) = - apply { - spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -777,109 +699,94 @@ class ExperimentEvent @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ExperimentEvent = ExperimentEvent( - checkRequired( - "id", id - ), - checkRequired( - "_xactId", _xactId - ), - checkRequired( - "created", created - ), - checkRequired( - "experimentId", experimentId - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "rootSpanId", rootSpanId - ), - checkRequired( - "spanId", spanId - ), - context, - datasetRecordId, - error, - expected, - input, - isRoot, - metadata, - metrics, - origin, - output, - scores, - spanAttributes, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("created", created), + checkRequired("experimentId", experimentId), + checkRequired("projectId", projectId), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), + context, + datasetRecordId, + error, + expected, + input, + isRoot, + metadata, + metrics, + origin, + output, + scores, + spanAttributes, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event */ @NoAutoDetect - class Context @JsonCreator private constructor( - @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Context + @JsonCreator + private constructor( + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -902,25 +809,23 @@ class ExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Context = - apply { - if (validated) { - return@apply - } - - callerFilename() - callerFunctionname() - callerLineno() - validated = true + fun validate(): Context = apply { + if (validated) { + return@apply } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Context]. */ @@ -932,37 +837,38 @@ class ExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = - apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = + callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = + callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: JsonField) = - apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = + callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = + callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: JsonField) = - apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -974,52 +880,44 @@ class ExperimentEvent @JsonCreator private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: JsonField) = - apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1028,20 +926,23 @@ class ExperimentEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1050,22 +951,20 @@ class ExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1074,46 +973,38 @@ class ExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1126,22 +1017,38 @@ class ExperimentEvent @JsonCreator private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ @NoAutoDetect - class Metrics @JsonCreator private constructor( - @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), + class Metrics + @JsonCreator + private constructor( + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("prompt_tokens") + @ExcludeMissing + private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") + @ExcludeMissing + private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** This metric is deprecated */ @@ -1155,31 +1062,31 @@ class ExperimentEvent @JsonCreator private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment event + * finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment event + * started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1187,41 +1094,35 @@ class ExperimentEvent @JsonCreator private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment event + * finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end(): JsonField = end + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment event + * started */ - @JsonProperty("start") - @ExcludeMissing - fun _start(): JsonField = start + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens(): JsonField = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1229,27 +1130,25 @@ class ExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metrics = - apply { - if (validated) { - return@apply - } - - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true + fun validate(): Metrics = apply { + if (validated) { + return@apply } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1266,144 +1165,133 @@ class ExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = - apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = - apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = - apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = - apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: JsonField) = - apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ - fun end(end: JsonField) = - apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = - apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - fun start(start: JsonField) = - apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1415,57 +1303,47 @@ class ExperimentEvent @JsonCreator private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: JsonField) = - apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1474,18 +1352,27 @@ class ExperimentEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin @JsonCreator private constructor( + class Origin + @JsonCreator + private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** ID of the original event. */ @@ -1501,19 +1388,13 @@ class ExperimentEvent @JsonCreator private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -1526,19 +1407,18 @@ class ExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Origin = - apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true + fun validate(): Origin = apply { + if (validated) { + return@apply } + id() + _xactId() + objectId() + objectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1547,7 +1427,6 @@ class ExperimentEvent @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: - * * ```java * .id() * ._xactId() @@ -1555,8 +1434,7 @@ class ExperimentEvent @JsonCreator private constructor( * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Origin]. */ @@ -1569,111 +1447,82 @@ class ExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = - apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = - apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = - apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired( - "id", id - ), - checkRequired( - "_xactId", _xactId - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1706,11 +1555,9 @@ class ExperimentEvent @JsonCreator private constructor( * 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 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 { @@ -1731,8 +1578,8 @@ class ExperimentEvent @JsonCreator private constructor( * 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. + * 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) { @@ -1752,7 +1599,7 @@ class ExperimentEvent @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1771,17 +1618,20 @@ class ExperimentEvent @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1790,11 +1640,11 @@ class ExperimentEvent @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1803,23 +1653,25 @@ class ExperimentEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ @NoAutoDetect - class Scores @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Scores + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1828,22 +1680,20 @@ class ExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Scores = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Scores = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1852,46 +1702,38 @@ class ExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = - apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1904,11 +1746,11 @@ class ExperimentEvent @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1917,5 +1759,6 @@ class ExperimentEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 4aba5528..b4b3324a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of experiment events */ -class ExperimentFeedbackParams private constructor( +class ExperimentFeedbackParams +private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Experiment id */ @@ -44,25 +44,28 @@ class ExperimentFeedbackParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("feedback") + @ExcludeMissing + private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of experiment feedback items */ @@ -79,16 +82,15 @@ class ExperimentFeedbackParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - feedback().forEach { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + feedback().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,13 +99,11 @@ class ExperimentFeedbackParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .feedback() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,69 +113,59 @@ class ExperimentFeedbackParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of experiment feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of experiment feedback items */ - fun feedback(feedback: JsonField>) = - apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of experiment feedback items */ - fun addFeedback(feedback: FeedbackExperimentItem) = - apply { - this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackExperimentItem) = apply { + this.feedback = + (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "feedback", feedback - ).map { it.toImmutable() }, additionalProperties.toImmutable() + checkRequired("feedback", feedback).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -184,7 +174,8 @@ class ExperimentFeedbackParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -192,18 +183,15 @@ class ExperimentFeedbackParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentFeedbackParams]. + * Returns a mutable builder for constructing an instance of [ExperimentFeedbackParams]. * * The following fields are required: - * * ```java * .experimentId() * .feedback() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentFeedbackParams]. */ @@ -216,209 +204,163 @@ class ExperimentFeedbackParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = - apply { - experimentId = experimentFeedbackParams.experimentId - body = experimentFeedbackParams.body.toBuilder() - additionalHeaders = experimentFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFeedbackParams: ExperimentFeedbackParams) = apply { + experimentId = experimentFeedbackParams.experimentId + body = experimentFeedbackParams.body.toBuilder() + additionalHeaders = experimentFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFeedbackParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment feedback items */ - fun feedback(feedback: List) = - apply { - body.feedback(feedback) - } + fun feedback(feedback: List) = apply { body.feedback(feedback) } /** A list of experiment feedback items */ - fun feedback(feedback: JsonField>) = - apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = apply { + body.feedback(feedback) + } /** A list of experiment feedback items */ - fun addFeedback(feedback: FeedbackExperimentItem) = - apply { - body.addFeedback(feedback) - } + fun addFeedback(feedback: FeedbackExperimentItem) = apply { body.addFeedback(feedback) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( - checkRequired( - "experimentId", experimentId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("experimentId", experimentId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFeedbackParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentFeedbackParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentFeedbackParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 611e5817..53ca3670 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -12,11 +12,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, - * but with the parameters in the URL query rather than in the request body. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use the + * `POST /btql` endpoint. */ -class ExperimentFetchParams private constructor( +class ExperimentFetchParams +private constructor( private val experimentId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -24,7 +25,6 @@ class ExperimentFetchParams private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Experiment id */ @@ -33,55 +33,52 @@ class ExperimentFetchParams private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -92,36 +89,20 @@ class ExperimentFetchParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.maxRootSpanId?.let { - queryParams.put( - "max_root_span_id", listOf(it.toString()) - ) - } - this.maxXactId?.let { - queryParams.put( - "max_xact_id", listOf(it.toString()) - ) - } - this.version?.let { - queryParams.put( - "version", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -129,17 +110,14 @@ class ExperimentFetchParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentFetchParams]. + * Returns a mutable builder for constructing an instance of [ExperimentFetchParams]. * * The following fields are required: - * * ```java * .experimentId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentFetchParams]. */ @@ -155,310 +133,263 @@ class ExperimentFetchParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFetchParams: ExperimentFetchParams) = - apply { - experimentId = experimentFetchParams.experimentId - limit = experimentFetchParams.limit - maxRootSpanId = experimentFetchParams.maxRootSpanId - maxXactId = experimentFetchParams.maxXactId - version = experimentFetchParams.version - additionalHeaders = experimentFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFetchParams: ExperimentFetchParams) = apply { + experimentId = experimentFetchParams.experimentId + limit = experimentFetchParams.limit + maxRootSpanId = experimentFetchParams.maxRootSpanId + maxXactId = experimentFetchParams.maxXactId + version = experimentFetchParams.version + additionalHeaders = experimentFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFetchParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = - apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String?) = - apply { - this.version = version - } + fun version(version: String?) = apply { this.version = version } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFetchParams = ExperimentFetchParams( - checkRequired( - "experimentId", experimentId - ), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("experimentId", experimentId), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchParams && experimentId == other.experimentId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index a1838a8c..b6cde61b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -22,146 +22,138 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use the + * `POST /btql` endpoint. */ -class ExperimentFetchPostParams private constructor( +class ExperimentFetchPostParams +private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Experiment id */ fun experimentId(): String = experimentId /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun _version(): JsonField = body._version() @@ -171,168 +163,169 @@ class ExperimentFetchPostParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") + @ExcludeMissing + private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") + @ExcludeMissing + private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") + @ExcludeMissing + private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = + Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = + Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor(): JsonField = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - @JsonProperty("limit") - @ExcludeMissing - fun _limit(): JsonField = limit + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_xact_id") - @ExcludeMissing - fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -340,27 +333,25 @@ class ExperimentFetchPostParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -374,284 +365,261 @@ class ExperimentFetchPostParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: JsonField) = - apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ - fun limit(limit: JsonField) = - apply { - this.limit = limit - } + fun limit(limit: JsonField) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = + maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = - apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = - apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ - fun version(version: JsonField) = - apply { - this.version = version - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -660,7 +628,8 @@ class ExperimentFetchPostParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -668,17 +637,14 @@ class ExperimentFetchPostParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentFetchPostParams]. + * Returns a mutable builder for constructing an instance of [ExperimentFetchPostParams]. * * The following fields are required: - * * ```java * .experimentId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentFetchPostParams]. */ @@ -691,431 +657,358 @@ class ExperimentFetchPostParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = - apply { - experimentId = experimentFetchPostParams.experimentId - body = experimentFetchPostParams.body.toBuilder() - additionalHeaders = experimentFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentFetchPostParams: ExperimentFetchPostParams) = apply { + experimentId = experimentFetchPostParams.experimentId + body = experimentFetchPostParams.body.toBuilder() + additionalHeaders = experimentFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentFetchPostParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: String?) = - apply { - body.cursor(cursor) - } + fun cursor(cursor: String?) = apply { body.cursor(cursor) } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: JsonField) = - apply { - body.cursor(cursor) - } + fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long?) = - apply { - body.limit(limit) - } + fun limit(limit: Long?) = apply { body.limit(limit) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: JsonField) = - apply { - body.limit(limit) - } + fun limit(limit: JsonField) = apply { body.limit(limit) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = - apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = - apply { - body.maxXactId(maxXactId) - } + fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = - apply { - body.maxXactId(maxXactId) - } + fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String?) = - apply { - body.version(version) - } + fun version(version: String?) = apply { body.version(version) } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: JsonField) = - apply { - body.version(version) - } + fun version(version: JsonField) = apply { body.version(version) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentFetchPostParams = ExperimentFetchPostParams( - checkRequired( - "experimentId", experimentId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("experimentId", experimentId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentFetchPostParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentFetchPostParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentFetchPostParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 5dc9dc79..e04423cf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the experiment */ -class ExperimentInsertParams private constructor( +class ExperimentInsertParams +private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Experiment id */ @@ -44,25 +44,28 @@ class ExperimentInsertParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of experiment events to insert */ @@ -79,16 +82,15 @@ class ExperimentInsertParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - events().forEach { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + events().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,13 +99,11 @@ class ExperimentInsertParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,69 +113,59 @@ class ExperimentInsertParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of experiment events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of experiment events to insert */ - fun events(events: JsonField>) = - apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } /** A list of experiment events to insert */ - fun addEvent(event: InsertExperimentEvent) = - apply { - events = (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertExperimentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "events", events - ).map { it.toImmutable() }, additionalProperties.toImmutable() + checkRequired("events", events).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -192,18 +182,15 @@ class ExperimentInsertParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentInsertParams]. + * Returns a mutable builder for constructing an instance of [ExperimentInsertParams]. * * The following fields are required: - * * ```java * .experimentId() * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentInsertParams]. */ @@ -216,209 +203,161 @@ class ExperimentInsertParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentInsertParams: ExperimentInsertParams) = - apply { - experimentId = experimentInsertParams.experimentId - body = experimentInsertParams.body.toBuilder() - additionalHeaders = experimentInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentInsertParams: ExperimentInsertParams) = apply { + experimentId = experimentInsertParams.experimentId + body = experimentInsertParams.body.toBuilder() + additionalHeaders = experimentInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentInsertParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** A list of experiment events to insert */ - fun events(events: List) = - apply { - body.events(events) - } + fun events(events: List) = apply { body.events(events) } /** A list of experiment events to insert */ - fun events(events: JsonField>) = - apply { - body.events(events) - } + fun events(events: JsonField>) = apply { body.events(events) } /** A list of experiment events to insert */ - fun addEvent(event: InsertExperimentEvent) = - apply { - body.addEvent(event) - } + fun addEvent(event: InsertExperimentEvent) = apply { body.addEvent(event) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentInsertParams = ExperimentInsertParams( - checkRequired( - "experimentId", experimentId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("experimentId", experimentId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentInsertParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentInsertParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentInsertParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 78769b47..246697bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.ExperimentService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ -class ExperimentListPage private constructor( +class ExperimentListPage +private constructor( private val experimentsService: ExperimentService, private val params: ExperimentListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class ExperimentListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListPage && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ExperimentListPage && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ - override fun toString() = "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" + override fun toString() = + "ExperimentListPage{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ExperimentListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ExperimentListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { experimentsService.list(it) } + return getNextPageParams().map { experimentsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -73,19 +83,21 @@ class ExperimentListPage private constructor( companion object { @JvmStatic - fun of(experimentsService: ExperimentService, params: ExperimentListParams, response: Response) = - ExperimentListPage( - experimentsService, - params, - response, - ) + fun of( + experimentsService: ExperimentService, + params: ExperimentListParams, + response: Response, + ) = ExperimentListPage(experimentsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +111,34 @@ class ExperimentListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ExperimentListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +147,39 @@ class ExperimentListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ExperimentListPage, + class AutoPager(private val firstPage: ExperimentListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index 05812b0f..a47c0c97 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.ExperimentServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ -class ExperimentListPageAsync private constructor( +class ExperimentListPageAsync +private constructor( private val experimentsService: ExperimentServiceAsync, private val params: ExperimentListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class ExperimentListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListPageAsync && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ExperimentListPageAsync && experimentsService == other.experimentsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentsService, params, response) /* spotless:on */ - override fun toString() = "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" + override fun toString() = + "ExperimentListPageAsync{experimentsService=$experimentsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ExperimentListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ExperimentListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - experimentsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { experimentsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,21 @@ class ExperimentListPageAsync private constructor( companion object { @JvmStatic - fun of(experimentsService: ExperimentServiceAsync, params: ExperimentListParams, response: Response) = - ExperimentListPageAsync( - experimentsService, - params, - response, - ) + fun of( + experimentsService: ExperimentServiceAsync, + params: ExperimentListParams, + response: Response, + ) = ExperimentListPageAsync(experimentsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,38 +113,36 @@ class ExperimentListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentListPageAsync]. + * Returns a mutable builder for constructing an instance of [ExperimentListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +151,46 @@ class ExperimentListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ExperimentListPageAsync, - - ) { + class AutoPager(private val firstPage: ExperimentListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Experiment) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Experiment) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index e52715df..2b4b05c0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ -class ExperimentListParams private constructor( +class ExperimentListParams +private constructor( private val endingBefore: String?, private val experimentName: String?, private val ids: Ids?, @@ -37,15 +38,14 @@ class ExperimentListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -53,8 +53,8 @@ class ExperimentListParams private constructor( fun experimentName(): Optional = Optional.ofNullable(experimentName) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ class ExperimentListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,64 +86,27 @@ class ExperimentListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.experimentName?.let { - queryParams.put( - "experiment_name", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.projectId?.let { - queryParams.put( - "project_id", listOf(it.toString()) - ) - } - this.projectName?.let { - queryParams.put( - "project_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.experimentName?.let { queryParams.put("experiment_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): ExperimentListParams = builder().build() + @JvmStatic fun none(): ExperimentListParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of - * [ExperimentListParams]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [ExperimentListParams]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentListParams]. */ @@ -162,82 +125,70 @@ class ExperimentListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentListParams: ExperimentListParams) = - apply { - endingBefore = experimentListParams.endingBefore - experimentName = experimentListParams.experimentName - ids = experimentListParams.ids - limit = experimentListParams.limit - orgName = experimentListParams.orgName - projectId = experimentListParams.projectId - projectName = experimentListParams.projectName - startingAfter = experimentListParams.startingAfter - additionalHeaders = experimentListParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentListParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentListParams: ExperimentListParams) = apply { + endingBefore = experimentListParams.endingBefore + experimentName = experimentListParams.experimentName + ids = experimentListParams.ids + limit = experimentListParams.limit + orgName = experimentListParams.orgName + projectId = experimentListParams.projectId + projectName = experimentListParams.projectName + startingAfter = experimentListParams.startingAfter + additionalHeaders = experimentListParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the experiment to search for */ - fun experimentName(experimentName: String?) = - apply { - this.experimentName = experimentName - } + fun experimentName(experimentName: String?) = apply { this.experimentName = experimentName } /** Name of the experiment to search for */ - fun experimentName(experimentName: Optional) = experimentName(experimentName.getOrNull()) + fun experimentName(experimentName: Optional) = + experimentName(experimentName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -246,28 +197,19 @@ class ExperimentListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = - apply { - this.projectName = projectName - } + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -275,174 +217,146 @@ class ExperimentListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentListParams = ExperimentListParams( - endingBefore, - experimentName, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + experimentName, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -460,19 +374,19 @@ class ExperimentListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -487,17 +401,12 @@ class ExperimentListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -507,56 +416,60 @@ class ExperimentListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentListParams && endingBefore == other.endingBefore && experimentName == other.experimentName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, experimentName, ids, limit, orgName, projectId, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index bf3d01fd..042891d4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an experiment object by its id */ -class ExperimentRetrieveParams private constructor( +class ExperimentRetrieveParams +private constructor( private val experimentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Experiment id */ @@ -29,10 +29,10 @@ class ExperimentRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class ExperimentRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentRetrieveParams]. + * Returns a mutable builder for constructing an instance of [ExperimentRetrieveParams]. * * The following fields are required: - * * ```java * .experimentId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentRetrieveParams]. */ @@ -62,162 +59,131 @@ class ExperimentRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = - apply { - experimentId = experimentRetrieveParams.experimentId - additionalHeaders = experimentRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentRetrieveParams: ExperimentRetrieveParams) = apply { + experimentId = experimentRetrieveParams.experimentId + additionalHeaders = experimentRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentRetrieveParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( - checkRequired( - "experimentId", experimentId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("experimentId", experimentId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentRetrieveParams && experimentId == other.experimentId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentRetrieveParams{experimentId=$experimentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 663d7cd0..c988c73a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -12,29 +12,28 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Summarize experiment */ -class ExperimentSummarizeParams private constructor( +class ExperimentSummarizeParams +private constructor( private val experimentId: String, private val comparisonExperimentId: String?, private val summarizeScores: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Experiment id */ fun experimentId(): String = experimentId /** - * The experiment to compare against, if summarizing scores and metrics. If - * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, - * and then to the most recent experiment run in the same project. Must pass - * `summarize_scores=true` for this id to be used + * The experiment to compare against, if summarizing scores and metrics. If omitted, will fall + * back to the `base_exp_id` stored in the experiment metadata, and then to the most recent + * experiment run in the same project. Must pass `summarize_scores=true` for this id to be used */ fun comparisonExperimentId(): Optional = Optional.ofNullable(comparisonExperimentId) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the - * metadata will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the metadata will be + * returned. */ fun summarizeScores(): Optional = Optional.ofNullable(summarizeScores) @@ -45,26 +44,20 @@ class ExperimentSummarizeParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.comparisonExperimentId?.let { - queryParams.put( - "comparison_experiment_id", listOf(it.toString()) - ) - } - this.summarizeScores?.let { - queryParams.put( - "summarize_scores", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.comparisonExperimentId?.let { + queryParams.put("comparison_experiment_id", listOf(it.toString())) + } + this.summarizeScores?.let { queryParams.put("summarize_scores", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -72,17 +65,14 @@ class ExperimentSummarizeParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentSummarizeParams]. + * Returns a mutable builder for constructing an instance of [ExperimentSummarizeParams]. * * The following fields are required: - * * ```java * .experimentId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentSummarizeParams]. */ @@ -96,206 +86,175 @@ class ExperimentSummarizeParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = - apply { - experimentId = experimentSummarizeParams.experimentId - comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId - summarizeScores = experimentSummarizeParams.summarizeScores - additionalHeaders = experimentSummarizeParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentSummarizeParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentSummarizeParams: ExperimentSummarizeParams) = apply { + experimentId = experimentSummarizeParams.experimentId + comparisonExperimentId = experimentSummarizeParams.comparisonExperimentId + summarizeScores = experimentSummarizeParams.summarizeScores + additionalHeaders = experimentSummarizeParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentSummarizeParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** - * The experiment to compare against, if summarizing scores and metrics. If - * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, - * and then to the most recent experiment run in the same project. Must pass - * `summarize_scores=true` for this id to be used + * The experiment to compare against, if summarizing scores and metrics. If omitted, will + * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most + * recent experiment run in the same project. Must pass `summarize_scores=true` for this id + * to be used */ - fun comparisonExperimentId(comparisonExperimentId: String?) = - apply { - this.comparisonExperimentId = comparisonExperimentId - } + fun comparisonExperimentId(comparisonExperimentId: String?) = apply { + this.comparisonExperimentId = comparisonExperimentId + } /** - * The experiment to compare against, if summarizing scores and metrics. If - * omitted, will fall back to the `base_exp_id` stored in the experiment metadata, - * and then to the most recent experiment run in the same project. Must pass - * `summarize_scores=true` for this id to be used + * The experiment to compare against, if summarizing scores and metrics. If omitted, will + * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most + * recent experiment run in the same project. Must pass `summarize_scores=true` for this id + * to be used */ - fun comparisonExperimentId(comparisonExperimentId: Optional) = comparisonExperimentId(comparisonExperimentId.getOrNull()) + fun comparisonExperimentId(comparisonExperimentId: Optional) = + comparisonExperimentId(comparisonExperimentId.getOrNull()) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the - * metadata will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the metadata + * will be returned. */ - fun summarizeScores(summarizeScores: Boolean?) = - apply { - this.summarizeScores = summarizeScores - } + fun summarizeScores(summarizeScores: Boolean?) = apply { + this.summarizeScores = summarizeScores + } /** - * Whether to summarize the scores and metrics. If false (or omitted), only the - * metadata will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the metadata + * will be returned. */ fun summarizeScores(summarizeScores: Boolean) = summarizeScores(summarizeScores as Boolean?) /** - * Whether to summarize the scores and metrics. If false (or omitted), only the - * metadata will be returned. + * Whether to summarize the scores and metrics. If false (or omitted), only the metadata + * will be returned. */ - fun summarizeScores(summarizeScores: Optional) = summarizeScores(summarizeScores.getOrNull()) + fun summarizeScores(summarizeScores: Optional) = + summarizeScores(summarizeScores.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( - checkRequired( - "experimentId", experimentId - ), - comparisonExperimentId, - summarizeScores, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("experimentId", experimentId), + comparisonExperimentId, + summarizeScores, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentSummarizeParams && experimentId == other.experimentId && comparisonExperimentId == other.comparisonExperimentId && summarizeScores == other.summarizeScores && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, comparisonExperimentId, summarizeScores, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index eca783dd..1f99550c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an experiment object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ -class ExperimentUpdateParams private constructor( +class ExperimentUpdateParams +private constructor( private val experimentId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Experiment id */ @@ -40,15 +40,12 @@ class ExperimentUpdateParams private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(): Optional = body.baseExpId() - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(): Optional = body.datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ fun datasetVersion(): Optional = body.datasetVersion() @@ -62,8 +59,8 @@ class ExperimentUpdateParams private constructor( fun name(): Optional = body.name() /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization */ fun public_(): Optional = body.public_() @@ -73,15 +70,12 @@ class ExperimentUpdateParams private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun _baseExpId(): JsonField = body._baseExpId() - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ + /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun _datasetId(): JsonField = body._datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ fun _datasetVersion(): JsonField = body._datasetVersion() @@ -95,8 +89,8 @@ class ExperimentUpdateParams private constructor( fun _name(): JsonField = body._name() /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside + * or outside the organization */ fun _public_(): JsonField = body._public_() @@ -109,51 +103,70 @@ class ExperimentUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("base_exp_id") @ExcludeMissing private val baseExpId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), - @JsonProperty("dataset_version") @ExcludeMissing private val datasetVersion: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("public") @ExcludeMissing private val public_: JsonField = JsonMissing.of(), - @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("base_exp_id") + @ExcludeMissing + private val baseExpId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_id") + @ExcludeMissing + private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("dataset_version") + @ExcludeMissing + private val datasetVersion: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("public") + @ExcludeMissing + private val public_: JsonField = JsonMissing.of(), + @JsonProperty("repo_info") + @ExcludeMissing + private val repoInfo: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) + fun baseExpId(): Optional = + Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) + fun datasetVersion(): Optional = + Optional.ofNullable(datasetVersion.getNullable("dataset_version")) /** Textual description of the experiment */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** User-controlled metadata about the experiment */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -162,8 +175,8 @@ class ExperimentUpdateParams private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) @@ -171,21 +184,16 @@ class ExperimentUpdateParams private constructor( fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - @ExcludeMissing - fun _baseExpId(): JsonField = baseExpId + @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun _datasetId(): JsonField = datasetId + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -197,27 +205,19 @@ class ExperimentUpdateParams private constructor( fun _description(): JsonField = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - @JsonProperty("public") - @ExcludeMissing - fun _public_(): JsonField = public_ + @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - @ExcludeMissing - fun _repoInfo(): JsonField = repoInfo + @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @ExcludeMissing @@ -225,30 +225,28 @@ class ExperimentUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - baseExpId() - datasetId() - datasetVersion() - description() - metadata().ifPresent { it.validate() } - name() - public_() - repoInfo().ifPresent { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + baseExpId() + datasetId() + datasetVersion() + description() + metadata().ifPresent { it.validate() } + name() + public_() + repoInfo().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -265,18 +263,17 @@ class ExperimentUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - baseExpId = body.baseExpId - datasetId = body.datasetId - datasetVersion = body.datasetVersion - description = body.description - metadata = body.metadata - name = body.name - public_ = body.public_ - repoInfo = body.repoInfo - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + baseExpId = body.baseExpId + datasetId = body.datasetId + datasetVersion = body.datasetVersion + description = body.description + metadata = body.metadata + name = body.name + public_ = body.public_ + repoInfo = body.repoInfo + additionalProperties = body.additionalProperties.toMutableMap() + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) @@ -285,10 +282,7 @@ class ExperimentUpdateParams private constructor( fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = - apply { - this.baseExpId = baseExpId - } + fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } /** * Identifier of the linked dataset, or null if the experiment is not linked to a @@ -306,31 +300,29 @@ class ExperimentUpdateParams private constructor( * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ - fun datasetId(datasetId: JsonField) = - apply { - this.datasetId = datasetId - } + fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) + fun datasetVersion(datasetVersion: String?) = + datasetVersion(JsonField.ofNullable(datasetVersion)) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used + * to reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = - apply { - this.datasetVersion = datasetVersion - } + fun datasetVersion(datasetVersion: JsonField) = apply { + this.datasetVersion = datasetVersion + } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -339,10 +331,9 @@ class ExperimentUpdateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -351,10 +342,7 @@ class ExperimentUpdateParams private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -363,37 +351,31 @@ class ExperimentUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: JsonField) = - apply { - this.public_ = public_ - } + fun public_(public_: JsonField) = apply { this.public_ = public_ } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -402,57 +384,47 @@ class ExperimentUpdateParams private constructor( fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = - apply { - this.repoInfo = repoInfo - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalProperties.toImmutable(), + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && baseExpId == other.baseExpId && datasetId == other.datasetId && datasetVersion == other.datasetVersion && description == other.description && metadata == other.metadata && name == other.name && public_ == other.public_ && repoInfo == other.repoInfo && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -461,7 +433,8 @@ class ExperimentUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -469,17 +442,14 @@ class ExperimentUpdateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExperimentUpdateParams]. + * Returns a mutable builder for constructing an instance of [ExperimentUpdateParams]. * * The following fields are required: - * * ```java * .experimentId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ExperimentUpdateParams]. */ @@ -492,340 +462,254 @@ class ExperimentUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(experimentUpdateParams: ExperimentUpdateParams) = - apply { - experimentId = experimentUpdateParams.experimentId - body = experimentUpdateParams.body.toBuilder() - additionalHeaders = experimentUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = experimentUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(experimentUpdateParams: ExperimentUpdateParams) = apply { + experimentId = experimentUpdateParams.experimentId + body = experimentUpdateParams.body.toBuilder() + additionalHeaders = experimentUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = experimentUpdateParams.additionalQueryParams.toBuilder() + } /** Experiment id */ - fun experimentId(experimentId: String) = - apply { - this.experimentId = experimentId - } + fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String?) = - apply { - body.baseExpId(baseExpId) - } + fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: JsonField) = - apply { - body.baseExpId(baseExpId) - } + fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: String?) = - apply { - body.datasetId(datasetId) - } + fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(datasetId: JsonField) = - apply { - body.datasetId(datasetId) - } + fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: String?) = - apply { - body.datasetVersion(datasetVersion) - } + fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) + fun datasetVersion(datasetVersion: Optional) = + datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be - * used to reproduce the experiment after the dataset has been modified. + * Version number of the linked dataset the experiment was run against. This can be used to + * reproduce the experiment after the dataset has been modified. */ - fun datasetVersion(datasetVersion: JsonField) = - apply { - body.datasetVersion(datasetVersion) - } + fun datasetVersion(datasetVersion: JsonField) = apply { + body.datasetVersion(datasetVersion) + } /** Textual description of the experiment */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the experiment */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the experiment */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata?) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } /** User-controlled metadata about the experiment */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the experiment */ - fun metadata(metadata: JsonField) = - apply { - body.metadata(metadata) - } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: Boolean?) = - apply { - body.public_(public_) - } + fun public_(public_: Boolean?) = apply { body.public_(public_) } /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Boolean) = public_(public_ as Boolean?) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by - * anybody inside or outside the organization + * Whether or not the experiment is public. Public experiments can be viewed by anybody + * inside or outside the organization */ - fun public_(public_: JsonField) = - apply { - body.public_(public_) - } + fun public_(public_: JsonField) = apply { body.public_(public_) } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo?) = - apply { - body.repoInfo(repoInfo) - } + fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: JsonField) = - apply { - body.repoInfo(repoInfo) - } + fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ExperimentUpdateParams = ExperimentUpdateParams( - checkRequired( - "experimentId", experimentId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("experimentId", experimentId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** User-controlled metadata about the experiment */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -834,22 +718,20 @@ class ExperimentUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -858,46 +740,38 @@ class ExperimentUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -910,14 +784,15 @@ class ExperimentUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ExperimentUpdateParams && experimentId == other.experimentId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(experimentId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ExperimentUpdateParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ExperimentUpdateParams{experimentId=$experimentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 1181a618..887cdc58 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -22,19 +22,28 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackDatasetItem @JsonCreator private constructor( +class FeedbackDatasetItem +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("comment") + @ExcludeMissing + private val comment: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * The id of the dataset event to log feedback for. This is the row `id` returned - * by `POST /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` */ fun id(): String = id.getRequired("id") @@ -42,10 +51,9 @@ class FeedbackDatasetItem @JsonCreator private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -56,37 +64,26 @@ class FeedbackDatasetItem @JsonCreator private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the dataset event to log feedback for. This is the row `id` returned - * by `POST /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") - @ExcludeMissing - fun _comment(): JsonField = comment + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - @ExcludeMissing - fun _source(): JsonField = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -94,20 +91,19 @@ class FeedbackDatasetItem @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FeedbackDatasetItem = - apply { - if (validated) { - return@apply - } - - id() - comment() - metadata().ifPresent { it.validate() } - source() - tags() - validated = true + fun validate(): FeedbackDatasetItem = apply { + if (validated) { + return@apply } + id() + comment() + metadata().ifPresent { it.validate() } + source() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -116,13 +112,11 @@ class FeedbackDatasetItem @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [FeedbackDatasetItem]. * * The following fields are required: - * * ```java * .id() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FeedbackDatasetItem]. */ @@ -136,30 +130,26 @@ class FeedbackDatasetItem @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackDatasetItem: FeedbackDatasetItem) = - apply { - id = feedbackDatasetItem.id - comment = feedbackDatasetItem.comment - metadata = feedbackDatasetItem.metadata - source = feedbackDatasetItem.source - tags = feedbackDatasetItem.tags.map { it.toMutableList() } - additionalProperties = feedbackDatasetItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackDatasetItem: FeedbackDatasetItem) = apply { + id = feedbackDatasetItem.id + comment = feedbackDatasetItem.comment + metadata = feedbackDatasetItem.metadata + source = feedbackDatasetItem.source + tags = feedbackDatasetItem.tags.map { it.toMutableList() } + additionalProperties = feedbackDatasetItem.additionalProperties.toMutableMap() + } /** - * The id of the dataset event to log feedback for. This is the row `id` returned - * by `POST /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the dataset event to log feedback for. This is the row `id` returned - * by `POST /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned by `POST + * /v1/dataset/{dataset_id}/insert` */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** An optional comment string to log about the dataset event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -168,37 +158,28 @@ class FeedbackDatasetItem @JsonCreator private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the dataset event */ - fun comment(comment: JsonField) = - apply { - this.comment = comment - } + fun comment(comment: JsonField) = apply { this.comment = comment } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -207,10 +188,7 @@ class FeedbackDatasetItem @JsonCreator private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = - apply { - this.source = source - } + fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -219,68 +197,56 @@ class FeedbackDatasetItem @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackDatasetItem = FeedbackDatasetItem( - checkRequired( - "id", id - ), - comment, - metadata, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("id", id), + comment, + metadata, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -289,22 +255,20 @@ class FeedbackDatasetItem @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -313,46 +277,38 @@ class FeedbackDatasetItem @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -365,21 +321,17 @@ class FeedbackDatasetItem @JsonCreator private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Source @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -403,11 +355,9 @@ class FeedbackDatasetItem @JsonCreator private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] 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 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 { @@ -419,11 +369,11 @@ class FeedbackDatasetItem @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -436,11 +386,11 @@ class FeedbackDatasetItem @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -453,20 +403,23 @@ class FeedbackDatasetItem @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -475,11 +428,11 @@ class FeedbackDatasetItem @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackDatasetItem && id == other.id && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackDatasetItem && id == other.id && comment == other.comment && metadata == other.metadata && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -488,5 +441,6 @@ class FeedbackDatasetItem @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index 704af01b..a30bbcd2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -22,21 +22,32 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackExperimentItem @JsonCreator private constructor( +class FeedbackExperimentItem +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), + @JsonProperty("comment") + @ExcludeMissing + private val comment: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * The id of the experiment event to log feedback for. This is the row `id` - * returned by `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` returned by `POST + * /v1/experiment/{experiment_id}/insert` */ fun id(): String = id.getRequired("id") @@ -44,24 +55,21 @@ class FeedbackExperimentItem @JsonCreator private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected(): JsonValue = expected + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the experiment event */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) @@ -72,45 +80,32 @@ class FeedbackExperimentItem @JsonCreator private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the experiment event to log feedback for. This is the row `id` - * returned by `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` returned by `POST + * /v1/experiment/{experiment_id}/insert` */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") - @ExcludeMissing - fun _comment(): JsonField = comment + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the experiment event */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores(): JsonField = scores + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - @ExcludeMissing - fun _source(): JsonField = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -118,37 +113,33 @@ class FeedbackExperimentItem @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FeedbackExperimentItem = - apply { - if (validated) { - return@apply - } - - id() - comment() - metadata().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - source() - tags() - validated = true + fun validate(): FeedbackExperimentItem = apply { + if (validated) { + return@apply } + id() + comment() + metadata().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + source() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [FeedbackExperimentItem]. + * Returns a mutable builder for constructing an instance of [FeedbackExperimentItem]. * * The following fields are required: - * * ```java * .id() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FeedbackExperimentItem]. */ @@ -164,32 +155,28 @@ class FeedbackExperimentItem @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackExperimentItem: FeedbackExperimentItem) = - apply { - id = feedbackExperimentItem.id - comment = feedbackExperimentItem.comment - expected = feedbackExperimentItem.expected - metadata = feedbackExperimentItem.metadata - scores = feedbackExperimentItem.scores - source = feedbackExperimentItem.source - tags = feedbackExperimentItem.tags.map { it.toMutableList() } - additionalProperties = feedbackExperimentItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackExperimentItem: FeedbackExperimentItem) = apply { + id = feedbackExperimentItem.id + comment = feedbackExperimentItem.comment + expected = feedbackExperimentItem.expected + metadata = feedbackExperimentItem.metadata + scores = feedbackExperimentItem.scores + source = feedbackExperimentItem.source + tags = feedbackExperimentItem.tags.map { it.toMutableList() } + additionalProperties = feedbackExperimentItem.additionalProperties.toMutableMap() + } /** - * The id of the experiment event to log feedback for. This is the row `id` - * returned by `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` returned by + * `POST /v1/experiment/{experiment_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the experiment event to log feedback for. This is the row `id` - * returned by `POST /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` returned by + * `POST /v1/experiment/{experiment_id}/insert` */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** An optional comment string to log about the experiment event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -198,67 +185,52 @@ class FeedbackExperimentItem @JsonCreator private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the experiment event */ - fun comment(comment: JsonField) = - apply { - this.comment = comment - } + fun comment(comment: JsonField) = apply { this.comment = comment } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not */ - fun expected(expected: JsonValue) = - apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the experiment event */ - fun scores(scores: JsonField) = - apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -267,10 +239,7 @@ class FeedbackExperimentItem @JsonCreator private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = - apply { - this.source = source - } + fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -279,70 +248,58 @@ class FeedbackExperimentItem @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackExperimentItem = FeedbackExperimentItem( - checkRequired( - "id", id - ), - comment, - expected, - metadata, - scores, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("id", id), + comment, + expected, + metadata, + scores, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -351,22 +308,20 @@ class FeedbackExperimentItem @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -375,46 +330,38 @@ class FeedbackExperimentItem @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -427,13 +374,15 @@ class FeedbackExperimentItem @JsonCreator private constructor( } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the experiment event */ @NoAutoDetect - class Scores @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Scores + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -442,22 +391,20 @@ class FeedbackExperimentItem @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Scores = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Scores = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Scores]. */ @@ -466,46 +413,38 @@ class FeedbackExperimentItem @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = - apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -518,21 +457,17 @@ class FeedbackExperimentItem @JsonCreator private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Source @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -556,11 +491,9 @@ class FeedbackExperimentItem @JsonCreator private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] 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 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 { @@ -572,11 +505,11 @@ class FeedbackExperimentItem @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -589,11 +522,11 @@ class FeedbackExperimentItem @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -606,20 +539,23 @@ class FeedbackExperimentItem @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -628,11 +564,11 @@ class FeedbackExperimentItem @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackExperimentItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -641,5 +577,6 @@ class FeedbackExperimentItem @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FeedbackExperimentItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "FeedbackExperimentItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index e1e18a1d..14572b2f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -22,21 +22,32 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FeedbackProjectLogsItem @JsonCreator private constructor( +class FeedbackProjectLogsItem +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("comment") @ExcludeMissing private val comment: JsonField = JsonMissing.of(), + @JsonProperty("comment") + @ExcludeMissing + private val comment: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing private val source: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + private val source: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * The id of the project logs event to log feedback for. This is the row `id` - * returned by `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` returned by `POST + * /v1/project_logs/{project_id}/insert` */ fun id(): String = id.getRequired("id") @@ -44,24 +55,21 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected(): JsonValue = expected + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the project logs event */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) @@ -72,45 +80,32 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the project logs event to log feedback for. This is the row `id` - * returned by `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` returned by `POST + * /v1/project_logs/{project_id}/insert` */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") - @ExcludeMissing - fun _comment(): JsonField = comment + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the project logs event */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores(): JsonField = scores + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") - @ExcludeMissing - fun _source(): JsonField = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -118,37 +113,33 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FeedbackProjectLogsItem = - apply { - if (validated) { - return@apply - } - - id() - comment() - metadata().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - source() - tags() - validated = true + fun validate(): FeedbackProjectLogsItem = apply { + if (validated) { + return@apply } + id() + comment() + metadata().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + source() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [FeedbackProjectLogsItem]. + * Returns a mutable builder for constructing an instance of [FeedbackProjectLogsItem]. * * The following fields are required: - * * ```java * .id() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FeedbackProjectLogsItem]. */ @@ -164,32 +155,28 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackProjectLogsItem: FeedbackProjectLogsItem) = - apply { - id = feedbackProjectLogsItem.id - comment = feedbackProjectLogsItem.comment - expected = feedbackProjectLogsItem.expected - metadata = feedbackProjectLogsItem.metadata - scores = feedbackProjectLogsItem.scores - source = feedbackProjectLogsItem.source - tags = feedbackProjectLogsItem.tags.map { it.toMutableList() } - additionalProperties = feedbackProjectLogsItem.additionalProperties.toMutableMap() - } + internal fun from(feedbackProjectLogsItem: FeedbackProjectLogsItem) = apply { + id = feedbackProjectLogsItem.id + comment = feedbackProjectLogsItem.comment + expected = feedbackProjectLogsItem.expected + metadata = feedbackProjectLogsItem.metadata + scores = feedbackProjectLogsItem.scores + source = feedbackProjectLogsItem.source + tags = feedbackProjectLogsItem.tags.map { it.toMutableList() } + additionalProperties = feedbackProjectLogsItem.additionalProperties.toMutableMap() + } /** - * The id of the project logs event to log feedback for. This is the row `id` - * returned by `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` returned by + * `POST /v1/project_logs/{project_id}/insert` */ fun id(id: String) = id(JsonField.of(id)) /** - * The id of the project logs event to log feedback for. This is the row `id` - * returned by `POST /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` returned by + * `POST /v1/project_logs/{project_id}/insert` */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** An optional comment string to log about the project logs event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) @@ -198,67 +185,52 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( fun comment(comment: Optional) = comment(comment.getOrNull()) /** An optional comment string to log about the project logs event */ - fun comment(comment: JsonField) = - apply { - this.comment = comment - } + fun comment(comment: JsonField) = apply { this.comment = comment } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not */ - fun expected(expected: JsonValue) = - apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can + * log it here and access it in the Braintrust UI. Note, this metadata does not correspond + * to the main event itself, but rather the audit log attached to the event. */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into + * the existing scores for the project logs event */ - fun scores(scores: JsonField) = - apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) @@ -267,10 +239,7 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( fun source(source: Optional) = source(source.getOrNull()) /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - fun source(source: JsonField) = - apply { - this.source = source - } + fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -279,70 +248,58 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackProjectLogsItem = FeedbackProjectLogsItem( - checkRequired( - "id", id - ), - comment, - expected, - metadata, - scores, - source, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("id", id), + comment, + expected, + metadata, + scores, + source, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the feedback. If you have a `user_id`, - * you can log it here and access it in the Braintrust UI. Note, this metadata does - * not correspond to the main event itself, but rather the audit log attached to - * the event. + * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it + * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main + * event itself, but rather the audit log attached to the event. */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -351,22 +308,20 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -375,46 +330,38 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -427,13 +374,15 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be - * merged into the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the + * existing scores for the project logs event */ @NoAutoDetect - class Scores @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Scores + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -442,22 +391,20 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Scores = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Scores = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Scores]. */ @@ -466,46 +413,38 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = - apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -518,21 +457,17 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - class Source @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Source @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -556,11 +491,9 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Source] 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 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 { @@ -572,11 +505,11 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -589,11 +522,11 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -606,20 +539,23 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ + return /* spotless:off */ other is Source && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -628,11 +564,11 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackProjectLogsItem && id == other.id && comment == other.comment && expected == other.expected && metadata == other.metadata && scores == other.scores && source == other.source && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -641,5 +577,6 @@ class FeedbackProjectLogsItem @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FeedbackProjectLogsItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "FeedbackProjectLogsItem{id=$id, comment=$comment, expected=$expected, metadata=$metadata, scores=$scores, source=$source, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index fe72645f..d4e37e96 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -19,17 +19,18 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class FeedbackResponseSchema @JsonCreator private constructor( - @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), +class FeedbackResponseSchema +@JsonCreator +private constructor( + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun status(): Status = status.getRequired("status") - @JsonProperty("status") - @ExcludeMissing - fun _status(): JsonField = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -37,32 +38,28 @@ class FeedbackResponseSchema @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FeedbackResponseSchema = - apply { - if (validated) { - return@apply - } - - status() - validated = true + fun validate(): FeedbackResponseSchema = apply { + if (validated) { + return@apply } + status() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [FeedbackResponseSchema]. + * Returns a mutable builder for constructing an instance of [FeedbackResponseSchema]. * * The following fields are required: - * * ```java * .status() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FeedbackResponseSchema]. */ @@ -72,68 +69,52 @@ class FeedbackResponseSchema @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(feedbackResponseSchema: FeedbackResponseSchema) = - apply { - status = feedbackResponseSchema.status - additionalProperties = feedbackResponseSchema.additionalProperties.toMutableMap() - } + internal fun from(feedbackResponseSchema: FeedbackResponseSchema) = apply { + status = feedbackResponseSchema.status + additionalProperties = feedbackResponseSchema.additionalProperties.toMutableMap() + } fun status(status: Status) = status(JsonField.of(status)) - fun status(status: JsonField) = - apply { - this.status = status - } + fun status(status: JsonField) = apply { this.status = status } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FeedbackResponseSchema = FeedbackResponseSchema( - checkRequired( - "status", status - ), additionalProperties.toImmutable() + checkRequired("status", status), + additionalProperties.toImmutable(), ) } - class Status @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Status @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -144,18 +125,16 @@ class FeedbackResponseSchema @JsonCreator private constructor( /** An enum containing [Status]'s known values. */ enum class Known { - SUCCESS, + SUCCESS } /** * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Status] 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 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 { @@ -165,11 +144,11 @@ class FeedbackResponseSchema @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -180,11 +159,11 @@ class FeedbackResponseSchema @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -195,20 +174,23 @@ class FeedbackResponseSchema @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -217,11 +199,11 @@ class FeedbackResponseSchema @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FeedbackResponseSchema && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FeedbackResponseSchema && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -230,5 +212,6 @@ class FeedbackResponseSchema @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" + override fun toString() = + "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 4dac3d22..93503c6a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -20,11 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchDatasetEventsResponse @JsonCreator private constructor( - @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), +class FetchDatasetEventsResponse +@JsonCreator +private constructor( + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** A list of fetched events */ @@ -33,25 +38,21 @@ class FetchDatasetEventsResponse @JsonCreator private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun _events(): JsonField> = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor(): JsonField = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -59,33 +60,29 @@ class FetchDatasetEventsResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FetchDatasetEventsResponse = - apply { - if (validated) { - return@apply - } - - events().forEach { it.validate() } - cursor() - validated = true + fun validate(): FetchDatasetEventsResponse = apply { + if (validated) { + return@apply } + events().forEach { it.validate() } + cursor() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [FetchDatasetEventsResponse]. + * Returns a mutable builder for constructing an instance of [FetchDatasetEventsResponse]. * * The following fields are required: - * * ```java * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FetchDatasetEventsResponse]. */ @@ -96,99 +93,85 @@ class FetchDatasetEventsResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchDatasetEventsResponse: FetchDatasetEventsResponse) = - apply { - events = fetchDatasetEventsResponse.events.map { it.toMutableList() } - cursor = fetchDatasetEventsResponse.cursor - additionalProperties = fetchDatasetEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchDatasetEventsResponse: FetchDatasetEventsResponse) = apply { + events = fetchDatasetEventsResponse.events.map { it.toMutableList() } + cursor = fetchDatasetEventsResponse.cursor + additionalProperties = fetchDatasetEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = - apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: DatasetEvent) = - apply { - events = (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: DatasetEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = - apply { - this.cursor = cursor - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchDatasetEventsResponse = FetchDatasetEventsResponse( - checkRequired( - "events", events - ).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired("events", events).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchDatasetEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchDatasetEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -197,5 +180,6 @@ class FetchDatasetEventsResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = + "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 79cd0295..23656816 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -20,11 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchExperimentEventsResponse @JsonCreator private constructor( - @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), +class FetchExperimentEventsResponse +@JsonCreator +private constructor( + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** A list of fetched events */ @@ -33,25 +38,21 @@ class FetchExperimentEventsResponse @JsonCreator private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun _events(): JsonField> = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor(): JsonField = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -59,17 +60,16 @@ class FetchExperimentEventsResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FetchExperimentEventsResponse = - apply { - if (validated) { - return@apply - } - - events().forEach { it.validate() } - cursor() - validated = true + fun validate(): FetchExperimentEventsResponse = apply { + if (validated) { + return@apply } + events().forEach { it.validate() } + cursor() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -79,13 +79,11 @@ class FetchExperimentEventsResponse @JsonCreator private constructor( * [FetchExperimentEventsResponse]. * * The following fields are required: - * * ```java * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FetchExperimentEventsResponse]. */ @@ -96,99 +94,85 @@ class FetchExperimentEventsResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchExperimentEventsResponse: FetchExperimentEventsResponse) = - apply { - events = fetchExperimentEventsResponse.events.map { it.toMutableList() } - cursor = fetchExperimentEventsResponse.cursor - additionalProperties = fetchExperimentEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchExperimentEventsResponse: FetchExperimentEventsResponse) = apply { + events = fetchExperimentEventsResponse.events.map { it.toMutableList() } + cursor = fetchExperimentEventsResponse.cursor + additionalProperties = fetchExperimentEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = - apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: ExperimentEvent) = - apply { - events = (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: ExperimentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = - apply { - this.cursor = cursor - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchExperimentEventsResponse = FetchExperimentEventsResponse( - checkRequired( - "events", events - ).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired("events", events).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchExperimentEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchExperimentEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -197,5 +181,6 @@ class FetchExperimentEventsResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = + "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 09df951f..1fd8d53c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -20,11 +20,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class FetchProjectLogsEventsResponse @JsonCreator private constructor( - @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), - @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), +class FetchProjectLogsEventsResponse +@JsonCreator +private constructor( + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** A list of fetched events */ @@ -33,8 +38,8 @@ class FetchProjectLogsEventsResponse @JsonCreator private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) @@ -46,12 +51,10 @@ class FetchProjectLogsEventsResponse @JsonCreator private constructor( /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the next + * page of results. Not provided if the returned result set is empty. */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor(): JsonField = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @JsonAnyGetter @ExcludeMissing @@ -59,17 +62,16 @@ class FetchProjectLogsEventsResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FetchProjectLogsEventsResponse = - apply { - if (validated) { - return@apply - } - - events().forEach { it.validate() } - cursor() - validated = true + fun validate(): FetchProjectLogsEventsResponse = apply { + if (validated) { + return@apply } + events().forEach { it.validate() } + cursor() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -79,13 +81,11 @@ class FetchProjectLogsEventsResponse @JsonCreator private constructor( * [FetchProjectLogsEventsResponse]. * * The following fields are required: - * * ```java * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FetchProjectLogsEventsResponse]. */ @@ -96,99 +96,86 @@ class FetchProjectLogsEventsResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fetchProjectLogsEventsResponse: FetchProjectLogsEventsResponse) = - apply { - events = fetchProjectLogsEventsResponse.events.map { it.toMutableList() } - cursor = fetchProjectLogsEventsResponse.cursor - additionalProperties = fetchProjectLogsEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(fetchProjectLogsEventsResponse: FetchProjectLogsEventsResponse) = apply { + events = fetchProjectLogsEventsResponse.events.map { it.toMutableList() } + cursor = fetchProjectLogsEventsResponse.cursor + additionalProperties = + fetchProjectLogsEventsResponse.additionalProperties.toMutableMap() + } /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) /** A list of fetched events */ - fun events(events: JsonField>) = - apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } /** A list of fetched events */ - fun addEvent(event: ProjectLogsEvent) = - apply { - events = (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: ProjectLogsEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } + } /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** * Pagination cursor * - * Pass this string directly as the `cursor` param to your next fetch request to - * get the next page of results. Not provided if the returned result set is empty. + * Pass this string directly as the `cursor` param to your next fetch request to get the + * next page of results. Not provided if the returned result set is empty. */ - fun cursor(cursor: JsonField) = - apply { - this.cursor = cursor - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse( - checkRequired( - "events", events - ).map { it.toImmutable() }, - cursor, - additionalProperties.toImmutable(), + checkRequired("events", events).map { it.toImmutable() }, + cursor, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FetchProjectLogsEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FetchProjectLogsEventsResponse && events == other.events && cursor == other.cursor && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -197,5 +184,6 @@ class FetchProjectLogsEventsResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = + "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" } 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 34c094de..57056d70 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 @@ -33,35 +33,57 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Function @JsonCreator private constructor( +class Function +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("function_data") + @ExcludeMissing + private val functionData: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") + @ExcludeMissing + private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the prompt (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -86,12 +108,15 @@ class Function @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = + Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) /** User-controlled metadata about the prompt */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -99,64 +124,46 @@ class Function @JsonCreator private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Unique identifier for the prompt */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the prompt (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId @JsonProperty("function_data") @ExcludeMissing fun _functionData(): JsonField = functionData /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun _logId(): JsonField = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** JSON schema for the function's parameters and return type */ @JsonProperty("function_schema") @@ -168,13 +175,9 @@ class Function @JsonCreator private constructor( fun _functionType(): JsonField = functionType /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("origin") - @ExcludeMissing - fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -182,9 +185,7 @@ class Function @JsonCreator private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -192,31 +193,30 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - id() - _xactId() - functionData().validate() - logId() - name() - orgId() - projectId() - slug() - created() - description() - functionSchema().ifPresent { it.validate() } - functionType() - metadata().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + id() + _xactId() + functionData().validate() + logId() + name() + orgId() + projectId() + slug() + created() + description() + functionSchema().ifPresent { it.validate() } + functionType() + metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -225,7 +225,6 @@ class Function @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .id() * ._xactId() @@ -237,8 +236,7 @@ class Function @JsonCreator private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ @@ -263,61 +261,51 @@ class Function @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - id = function.id - _xactId = function._xactId - functionData = function.functionData - logId = function.logId - name = function.name - orgId = function.orgId - projectId = function.projectId - slug = function.slug - created = function.created - description = function.description - functionSchema = function.functionSchema - functionType = function.functionType - metadata = function.metadata - origin = function.origin - promptData = function.promptData - tags = function.tags.map { it.toMutableList() } - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + id = function.id + _xactId = function._xactId + functionData = function.functionData + logId = function.logId + name = function.name + orgId = function.orgId + projectId = function.projectId + slug = function.slug + created = function.created + description = function.description + functionSchema = function.functionSchema + functionType = function.functionType + metadata = function.metadata + origin = function.origin + promptData = function.promptData + tags = function.tags.map { it.toMutableList() } + additionalProperties = function.additionalProperties.toMutableMap() + } /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ - fun _xactId(_xactId: JsonField) = - apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = - apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = apply { + this.functionData = functionData + } fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) @@ -329,46 +317,31 @@ class Function @JsonCreator private constructor( fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: JsonField) = - apply { - this.logId = logId - } + fun logId(logId: JsonField) = apply { this.logId = logId } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** Date of prompt creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -377,10 +350,7 @@ class Function @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of prompt creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -389,31 +359,30 @@ class Function @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = + functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = - apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = apply { + this.functionType = functionType + } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -422,19 +391,13 @@ class Function @JsonCreator private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the prompt */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = - apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -443,10 +406,7 @@ class Function @JsonCreator private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -455,91 +415,64 @@ class Function @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "id", id - ), - checkRequired( - "_xactId", _xactId - ), - checkRequired( - "functionData", functionData - ), - checkRequired( - "logId", logId - ), - checkRequired( - "name", name - ), - checkRequired( - "orgId", orgId - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "slug", slug - ), - created, - description, - functionSchema, - functionType, - metadata, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("functionData", functionData), + checkRequired("logId", logId), + checkRequired("name", name), + checkRequired("orgId", orgId), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + created, + description, + functionSchema, + functionType, + metadata, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData private constructor( + class FunctionData + private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, - ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -563,44 +496,45 @@ class Function @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = - apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -616,19 +550,16 @@ class Function @JsonCreator private constructor( companion object { - @JvmStatic - fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic - fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic - fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value - * of type [T]. + * An interface that defines how to map each variant of [FunctionData] to a value of type + * [T]. */ interface Visitor { @@ -641,62 +572,71 @@ class Function @JsonCreator private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Prompt + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -704,16 +644,15 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Prompt = - apply { - if (validated) { - return@apply - } - - type() - validated = true + fun validate(): Prompt = apply { + if (validated) { + return@apply } + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -722,13 +661,11 @@ class Function @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: - * * ```java * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -738,57 +675,43 @@ class Function @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = - apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt( - checkRequired( - "type", type - ), additionalProperties.toImmutable() - ) + Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -798,8 +721,7 @@ class Function @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -810,23 +732,23 @@ class Function @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT, + PROMPT } /** * 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 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 { PROMPT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -850,7 +772,7 @@ class Function @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -865,16 +787,19 @@ class Function @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -883,11 +808,11 @@ class Function @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -896,28 +821,31 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code @JsonCreator private constructor( - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Code + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") - @ExcludeMissing - fun _data(): JsonField = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -925,17 +853,16 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Code = - apply { - if (validated) { - return@apply - } - - data().validate() - type() - validated = true + fun validate(): Code = apply { + if (validated) { + return@apply } + data().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -944,14 +871,12 @@ class Function @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: - * * ```java * .data() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Code]. */ @@ -962,19 +887,15 @@ class Function @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = - apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = - apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -982,56 +903,45 @@ class Function @JsonCreator private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired( - "data", data - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("data", data), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data private constructor( + class Data + private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, - ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1049,39 +959,40 @@ class Function @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = - apply { - if (validated) { - return@apply - } + fun validate(): Data = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1096,11 +1007,9 @@ class Function @JsonCreator private constructor( companion object { - @JvmStatic - fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic - fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1116,65 +1025,86 @@ class Function @JsonCreator private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize( + value: Data, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle @JsonCreator private constructor( - @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Bundle + @JsonCreator + private constructor( + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = + JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = + runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = + Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1195,9 +1125,7 @@ class Function @JsonCreator private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1213,20 +1141,19 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Bundle = - apply { - if (validated) { - return@apply - } - - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true + fun validate(): Bundle = apply { + if (validated) { + return@apply } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1235,7 +1162,6 @@ class Function @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: - * * ```java * .bundleId() * .location() @@ -1243,8 +1169,7 @@ class Function @JsonCreator private constructor( * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1255,38 +1180,40 @@ class Function @JsonCreator private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = - apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = - apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = + location(JsonField.of(location)) - fun location(location: JsonField) = - apply { - this.location = location - } + fun location(location: JsonField) = apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = + location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = + location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1300,17 +1227,11 @@ class Function @JsonCreator private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = - apply { - this.preview = preview - } + fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1318,57 +1239,44 @@ class Function @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired( - "bundleId", bundleId - ), - checkRequired( - "location", location - ), - checkRequired( - "runtimeContext", runtimeContext - ), - preview, - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), + preview, + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -1382,23 +1290,25 @@ class Function @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE, + BUNDLE } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { BUNDLE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1406,8 +1316,8 @@ class Function @JsonCreator private constructor( * 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. + * 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) { @@ -1418,11 +1328,11 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1433,20 +1343,23 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1455,11 +1368,11 @@ class Function @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1468,35 +1381,41 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline @JsonCreator private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Inline + @JsonCreator + private constructor( + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = + runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") - @ExcludeMissing - fun _code(): JsonField = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1504,18 +1423,17 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Inline = - apply { - if (validated) { - return@apply - } - - code() - runtimeContext().validate() - type() - validated = true + fun validate(): Inline = apply { + if (validated) { + return@apply } + code() + runtimeContext().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1524,15 +1442,13 @@ class Function @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: - * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1541,37 +1457,31 @@ class Function @JsonCreator private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = - apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = - apply { - this.code = code - } + fun code(code: JsonField) = apply { this.code = code } - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = - apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1579,47 +1489,44 @@ class Function @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired( - "code", code - ), - checkRequired( - "runtimeContext", runtimeContext - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("code", code), + checkRequired("runtimeContext", runtimeContext), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext @JsonCreator private constructor( - @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RuntimeContext + @JsonCreator + private constructor( + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1640,33 +1547,31 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = - apply { - if (validated) { - return@apply - } - - runtime() - version() - validated = true + fun validate(): RuntimeContext = apply { + if (validated) { + return@apply } + runtime() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [RuntimeContext]. + * Returns a mutable builder for constructing an instance of + * [RuntimeContext]. * * The following fields are required: - * * ```java * .runtime() * .version() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1674,29 +1579,28 @@ class Function @JsonCreator private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = - apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = + runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = - apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1704,50 +1608,41 @@ class Function @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired( - "runtime", runtime - ), - checkRequired( - "version", version - ), - additionalProperties.toImmutable(), + checkRequired("runtime", runtime), + checkRequired("version", version), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Runtime + @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. + * 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 @@ -1768,29 +1663,33 @@ class Function @JsonCreator private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Runtime] 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. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] + * member. * + * An instance of [Runtime] 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 { NODE, PYTHON, - /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Runtime] 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. + * 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. + * 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) { @@ -1802,36 +1701,42 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value + * is a not a known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + else -> + throw BraintrustInvalidDataException( + "Unknown Runtime: $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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1840,11 +1745,11 @@ class Function @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1853,21 +1758,21 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -1881,23 +1786,25 @@ class Function @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE, + INLINE } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { INLINE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1905,8 +1812,8 @@ class Function @JsonCreator private constructor( * 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. + * 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) { @@ -1917,11 +1824,11 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1932,20 +1839,23 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1954,11 +1864,11 @@ class Function @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1967,14 +1877,13 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1984,8 +1893,7 @@ class Function @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1996,23 +1904,23 @@ class Function @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE, + CODE } /** * 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 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 { CODE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2036,7 +1944,7 @@ class Function @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2051,16 +1959,19 @@ class Function @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2069,11 +1980,11 @@ class Function @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2082,28 +1993,31 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Global + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2111,17 +2025,16 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Global = - apply { - if (validated) { - return@apply - } - - name() - type() - validated = true + fun validate(): Global = apply { + if (validated) { + return@apply } + name() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2130,14 +2043,12 @@ class Function @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: - * * ```java * .name() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Global]. */ @@ -2148,69 +2059,52 @@ class Function @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = - apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired( - "name", name - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2220,8 +2114,7 @@ class Function @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2232,23 +2125,23 @@ class Function @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** * 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 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 { GLOBAL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2272,7 +2165,7 @@ class Function @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2287,16 +2180,19 @@ class Function @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2305,11 +2201,11 @@ class Function @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2318,26 +2214,23 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** A literal 'p' which identifies the object as a project prompt */ - class LogId @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class LogId @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2348,18 +2241,16 @@ class Function @JsonCreator private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - P, + P } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] 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 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 { @@ -2369,11 +2260,11 @@ class Function @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -2384,11 +2275,11 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -2399,20 +2290,23 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2422,20 +2316,20 @@ class Function @JsonCreator private constructor( /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema @JsonCreator private constructor( - @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema + @JsonCreator + private constructor( + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters - @JsonProperty("returns") - @ExcludeMissing - fun _returns(): JsonValue = returns + @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2443,22 +2337,20 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): FunctionSchema = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2469,63 +2361,45 @@ class Function @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = - apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = - apply { - this.parameters = parameters - } + fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } - fun returns(returns: JsonValue) = - apply { - this.returns = returns - } + fun returns(returns: JsonValue) = apply { this.returns = returns } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema( - parameters, - returns, - additionalProperties.toImmutable(), - ) + FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2534,24 +2408,22 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2575,15 +2447,12 @@ class Function @JsonCreator private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [FunctionType] 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 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 { @@ -2592,18 +2461,17 @@ class Function @JsonCreator private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown - * value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -2617,11 +2485,11 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -2635,20 +2503,23 @@ class Function @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2658,9 +2529,11 @@ class Function @JsonCreator private constructor( /** User-controlled metadata about the prompt */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -2669,22 +2542,20 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -2693,46 +2564,38 @@ class Function @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2745,12 +2608,20 @@ class Function @JsonCreator private constructor( } @NoAutoDetect - class Origin @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Origin + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") + @ExcludeMissing + private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Id of the object the function is originating from */ @@ -2760,15 +2631,13 @@ class Function @JsonCreator private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2776,12 +2645,10 @@ class Function @JsonCreator private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ - @JsonProperty("internal") - @ExcludeMissing - fun _internal_(): JsonField = internal_ + @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2789,18 +2656,17 @@ class Function @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Origin = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - internal_() - validated = true + fun validate(): Origin = apply { + if (validated) { + return@apply } + objectId() + objectType() + internal_() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2809,14 +2675,12 @@ class Function @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2828,114 +2692,92 @@ class Function @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = - apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ - fun internal_(internal_: JsonField) = - apply { - this.internal_ = internal_ - } + fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - internal_, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2983,11 +2825,9 @@ class Function @JsonCreator private constructor( * 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 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 { @@ -3013,8 +2853,8 @@ class Function @JsonCreator private constructor( * 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. + * 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) { @@ -3039,7 +2879,7 @@ class Function @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3063,17 +2903,20 @@ class Function @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3082,11 +2925,11 @@ class Function @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3095,15 +2938,16 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && functionData == other.functionData && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && metadata == other.metadata && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && _xactId == other._xactId && functionData == other.functionData && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && metadata == other.metadata && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3112,5 +2956,6 @@ class Function @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{id=$id, _xactId=$_xactId, functionData=$functionData, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionSchema=$functionSchema, functionType=$functionType, metadata=$metadata, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{id=$id, _xactId=$_xactId, functionData=$functionData, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionSchema=$functionSchema, functionType=$functionType, metadata=$metadata, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } 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 09a7057d..16db9180 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 @@ -36,15 +36,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new function. If there is an existing function in the project with the - * same slug as the one specified in the request, will return the existing function - * unmodified + * Create a new function. If there is an existing function in the project with the same slug as the + * one specified in the request, will return the existing function unmodified */ -class FunctionCreateParams private constructor( +class FunctionCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { fun functionData(): FunctionData = body.functionData() @@ -107,27 +106,48 @@ class FunctionCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("function_data") + @ExcludeMissing + private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") + @ExcludeMissing + private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun functionData(): FunctionData = functionData.getRequired("function_data") @@ -142,17 +162,21 @@ class FunctionCreateParams private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = + Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -162,19 +186,13 @@ class FunctionCreateParams private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -190,9 +208,7 @@ class FunctionCreateParams private constructor( @ExcludeMissing fun _functionType(): JsonField = functionType - @JsonProperty("origin") - @ExcludeMissing - fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -200,9 +216,7 @@ class FunctionCreateParams private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -210,24 +224,23 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - functionData().validate() - name() - projectId() - slug() - description() - functionSchema().ifPresent { it.validate() } - functionType() - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + fun validate(): Body = apply { + if (validated) { + return@apply + } + + functionData().validate() + name() + projectId() + slug() + description() + functionSchema().ifPresent { it.validate() } + functionType() + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -237,7 +250,6 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .functionData() * .name() @@ -245,8 +257,7 @@ class FunctionCreateParams private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -265,60 +276,51 @@ class FunctionCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - functionData = body.functionData - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionSchema = body.functionSchema - functionType = body.functionType - origin = body.origin - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + functionData = body.functionData + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionSchema = body.functionSchema + functionType = body.functionType + origin = body.origin + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = - apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = + functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = + functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -327,40 +329,38 @@ class FunctionCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = + functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = - apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = apply { + this.functionType = functionType + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = - apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -369,10 +369,9 @@ class FunctionCreateParams private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -381,75 +380,57 @@ class FunctionCreateParams private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "functionData", functionData - ), - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "slug", slug - ), - description, - functionSchema, - functionType, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("functionData", functionData), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + description, + functionSchema, + functionType, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -458,7 +439,8 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -466,11 +448,9 @@ class FunctionCreateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionCreateParams]. + * Returns a mutable builder for constructing an instance of [FunctionCreateParams]. * * The following fields are required: - * * ```java * .functionData() * .name() @@ -478,8 +458,7 @@ class FunctionCreateParams private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionCreateParams]. */ @@ -491,331 +470,234 @@ class FunctionCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionCreateParams: FunctionCreateParams) = - apply { - body = functionCreateParams.body.toBuilder() - additionalHeaders = functionCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = functionCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(functionCreateParams: FunctionCreateParams) = apply { + body = functionCreateParams.body.toBuilder() + additionalHeaders = functionCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = functionCreateParams.additionalQueryParams.toBuilder() + } - fun functionData(functionData: FunctionData) = - apply { - body.functionData(functionData) - } + fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } - fun functionData(functionData: JsonField) = - apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = - apply { - body.functionData(prompt) - } + fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } - fun functionData(code: FunctionData.Code) = - apply { - body.functionData(code) - } + fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } - fun functionData(global: FunctionData.Global) = - apply { - body.functionData(global) - } + fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } /** Name of the prompt */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Unique identifier for the prompt */ - fun slug(slug: String) = - apply { - body.slug(slug) - } + fun slug(slug: String) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - body.slug(slug) - } + fun slug(slug: JsonField) = apply { body.slug(slug) } /** Textual description of the prompt */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = - apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: FunctionSchema?) = apply { + body.functionSchema(functionSchema) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = - apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: JsonField) = apply { + body.functionSchema(functionSchema) + } - fun functionType(functionType: FunctionType?) = - apply { - body.functionType(functionType) - } + fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = apply { + body.functionType(functionType) + } - fun origin(origin: Origin?) = - apply { - body.origin(origin) - } + fun origin(origin: Origin?) = apply { body.origin(origin) } fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = - apply { - body.origin(origin) - } + fun origin(origin: JsonField) = apply { body.origin(origin) } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List?) = - apply { - body.tags(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - body.tags(tags) - } + fun tags(tags: JsonField>) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - body.addTag(tag) - } + fun addTag(tag: String) = apply { body.addTag(tag) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionCreateParams = FunctionCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData private constructor( + class FunctionData + private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, - ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -839,44 +721,45 @@ class FunctionCreateParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = - apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -892,19 +775,16 @@ class FunctionCreateParams private constructor( companion object { - @JvmStatic - fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic - fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic - fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value - * of type [T]. + * An interface that defines how to map each variant of [FunctionData] to a value of type + * [T]. */ interface Visitor { @@ -917,62 +797,71 @@ class FunctionCreateParams private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Prompt + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -980,16 +869,15 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): Prompt = - apply { - if (validated) { - return@apply - } - - type() - validated = true + fun validate(): Prompt = apply { + if (validated) { + return@apply } + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -998,13 +886,11 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: - * * ```java * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -1014,57 +900,43 @@ class FunctionCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = - apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt( - checkRequired( - "type", type - ), additionalProperties.toImmutable() - ) + Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1074,8 +946,7 @@ class FunctionCreateParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1086,23 +957,23 @@ class FunctionCreateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT, + PROMPT } /** * 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 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 { PROMPT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1126,7 +997,7 @@ class FunctionCreateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1141,16 +1012,19 @@ class FunctionCreateParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1159,11 +1033,11 @@ class FunctionCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1172,28 +1046,31 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code @JsonCreator private constructor( - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Code + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") - @ExcludeMissing - fun _data(): JsonField = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1201,17 +1078,16 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): Code = - apply { - if (validated) { - return@apply - } - - data().validate() - type() - validated = true + fun validate(): Code = apply { + if (validated) { + return@apply } + data().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1220,14 +1096,12 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: - * * ```java * .data() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Code]. */ @@ -1238,19 +1112,15 @@ class FunctionCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = - apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = - apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -1258,56 +1128,45 @@ class FunctionCreateParams private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired( - "data", data - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("data", data), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data private constructor( + class Data + private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, - ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1325,39 +1184,40 @@ class FunctionCreateParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = - apply { - if (validated) { - return@apply - } + fun validate(): Data = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1372,11 +1232,9 @@ class FunctionCreateParams private constructor( companion object { - @JvmStatic - fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic - fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1392,65 +1250,86 @@ class FunctionCreateParams private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize( + value: Data, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle @JsonCreator private constructor( - @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Bundle + @JsonCreator + private constructor( + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = + JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = + runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = + Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1471,9 +1350,7 @@ class FunctionCreateParams private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1489,20 +1366,19 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): Bundle = - apply { - if (validated) { - return@apply - } - - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true + fun validate(): Bundle = apply { + if (validated) { + return@apply } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1511,7 +1387,6 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: - * * ```java * .bundleId() * .location() @@ -1519,8 +1394,7 @@ class FunctionCreateParams private constructor( * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1531,38 +1405,40 @@ class FunctionCreateParams private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = - apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = - apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = + location(JsonField.of(location)) - fun location(location: JsonField) = - apply { - this.location = location - } + fun location(location: JsonField) = apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = + location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = + location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1576,17 +1452,11 @@ class FunctionCreateParams private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = - apply { - this.preview = preview - } + fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1594,57 +1464,44 @@ class FunctionCreateParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired( - "bundleId", bundleId - ), - checkRequired( - "location", location - ), - checkRequired( - "runtimeContext", runtimeContext - ), - preview, - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), + preview, + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -1658,23 +1515,25 @@ class FunctionCreateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE, + BUNDLE } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { BUNDLE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1682,8 +1541,8 @@ class FunctionCreateParams private constructor( * 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. + * 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) { @@ -1694,11 +1553,11 @@ class FunctionCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1709,20 +1568,23 @@ class FunctionCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1731,11 +1593,11 @@ class FunctionCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1744,35 +1606,41 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline @JsonCreator private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Inline + @JsonCreator + private constructor( + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = + runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") - @ExcludeMissing - fun _code(): JsonField = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1780,18 +1648,17 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): Inline = - apply { - if (validated) { - return@apply - } - - code() - runtimeContext().validate() - type() - validated = true + fun validate(): Inline = apply { + if (validated) { + return@apply } + code() + runtimeContext().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1800,15 +1667,13 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: - * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1817,37 +1682,31 @@ class FunctionCreateParams private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = - apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = - apply { - this.code = code - } + fun code(code: JsonField) = apply { this.code = code } - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = - apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1855,47 +1714,44 @@ class FunctionCreateParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired( - "code", code - ), - checkRequired( - "runtimeContext", runtimeContext - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("code", code), + checkRequired("runtimeContext", runtimeContext), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext @JsonCreator private constructor( - @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RuntimeContext + @JsonCreator + private constructor( + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1916,33 +1772,31 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = - apply { - if (validated) { - return@apply - } - - runtime() - version() - validated = true + fun validate(): RuntimeContext = apply { + if (validated) { + return@apply } + runtime() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [RuntimeContext]. + * Returns a mutable builder for constructing an instance of + * [RuntimeContext]. * * The following fields are required: - * * ```java * .runtime() * .version() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1950,29 +1804,28 @@ class FunctionCreateParams private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = - apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = + runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = - apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1980,50 +1833,41 @@ class FunctionCreateParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired( - "runtime", runtime - ), - checkRequired( - "version", version - ), - additionalProperties.toImmutable(), + checkRequired("runtime", runtime), + checkRequired("version", version), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Runtime + @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. + * 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 @@ -2044,29 +1888,33 @@ class FunctionCreateParams private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Runtime] 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. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] + * member. * + * An instance of [Runtime] 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 { NODE, PYTHON, - /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Runtime] 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. + * 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. + * 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) { @@ -2078,36 +1926,42 @@ class FunctionCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value + * is a not a known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + else -> + throw BraintrustInvalidDataException( + "Unknown Runtime: $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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2116,11 +1970,11 @@ class FunctionCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2129,21 +1983,21 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -2157,23 +2011,25 @@ class FunctionCreateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE, + INLINE } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { INLINE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -2181,8 +2037,8 @@ class FunctionCreateParams private constructor( * 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. + * 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) { @@ -2193,11 +2049,11 @@ class FunctionCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -2208,20 +2064,23 @@ class FunctionCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2230,11 +2089,11 @@ class FunctionCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2243,14 +2102,13 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2260,8 +2118,7 @@ class FunctionCreateParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2272,23 +2129,23 @@ class FunctionCreateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE, + CODE } /** * 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 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 { CODE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2312,7 +2169,7 @@ class FunctionCreateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2327,16 +2184,19 @@ class FunctionCreateParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2345,11 +2205,11 @@ class FunctionCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2358,28 +2218,31 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Global + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2387,17 +2250,16 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): Global = - apply { - if (validated) { - return@apply - } - - name() - type() - validated = true + fun validate(): Global = apply { + if (validated) { + return@apply } + name() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2406,14 +2268,12 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: - * * ```java * .name() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Global]. */ @@ -2424,69 +2284,52 @@ class FunctionCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = - apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired( - "name", name - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2496,8 +2339,7 @@ class FunctionCreateParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2508,23 +2350,23 @@ class FunctionCreateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** * 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 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 { GLOBAL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2548,7 +2390,7 @@ class FunctionCreateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2563,16 +2405,19 @@ class FunctionCreateParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2581,11 +2426,11 @@ class FunctionCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2594,26 +2439,27 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema @JsonCreator private constructor( - @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema + @JsonCreator + private constructor( + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters - @JsonProperty("returns") - @ExcludeMissing - fun _returns(): JsonValue = returns + @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2621,22 +2467,20 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): FunctionSchema = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2647,63 +2491,45 @@ class FunctionCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = - apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = - apply { - this.parameters = parameters - } + fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } - fun returns(returns: JsonValue) = - apply { - this.returns = returns - } + fun returns(returns: JsonValue) = apply { this.returns = returns } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema( - parameters, - returns, - additionalProperties.toImmutable(), - ) + FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2712,24 +2538,22 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2753,15 +2577,12 @@ class FunctionCreateParams private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [FunctionType] 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 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 { @@ -2770,18 +2591,17 @@ class FunctionCreateParams private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown - * value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -2795,11 +2615,11 @@ class FunctionCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -2813,20 +2633,23 @@ class FunctionCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2835,12 +2658,20 @@ class FunctionCreateParams private constructor( } @NoAutoDetect - class Origin @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Origin + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") + @ExcludeMissing + private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Id of the object the function is originating from */ @@ -2850,15 +2681,13 @@ class FunctionCreateParams private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2866,12 +2695,10 @@ class FunctionCreateParams private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ - @JsonProperty("internal") - @ExcludeMissing - fun _internal_(): JsonField = internal_ + @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2879,18 +2706,17 @@ class FunctionCreateParams private constructor( private var validated: Boolean = false - fun validate(): Origin = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - internal_() - validated = true + fun validate(): Origin = apply { + if (validated) { + return@apply } + objectId() + objectType() + internal_() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2899,14 +2725,12 @@ class FunctionCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2918,114 +2742,92 @@ class FunctionCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = - apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ - fun internal_(internal_: JsonField) = - apply { - this.internal_ = internal_ - } + fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - internal_, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -3073,11 +2875,9 @@ class FunctionCreateParams private constructor( * 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 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 { @@ -3103,8 +2903,8 @@ class FunctionCreateParams private constructor( * 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. + * 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) { @@ -3129,7 +2929,7 @@ class FunctionCreateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3153,17 +2953,20 @@ class FunctionCreateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3172,11 +2975,11 @@ class FunctionCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3185,18 +2988,20 @@ class FunctionCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "FunctionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "FunctionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index 8076213e..f2070a12 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a function object by its id */ -class FunctionDeleteParams private constructor( +class FunctionDeleteParams +private constructor( private val functionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Function id */ @@ -31,17 +31,18 @@ class FunctionDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -49,17 +50,14 @@ class FunctionDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionDeleteParams]. + * Returns a mutable builder for constructing an instance of [FunctionDeleteParams]. * * The following fields are required: - * * ```java * .functionId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionDeleteParams]. */ @@ -72,190 +70,155 @@ class FunctionDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionDeleteParams: FunctionDeleteParams) = - apply { - functionId = functionDeleteParams.functionId - additionalHeaders = functionDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = functionDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = functionDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(functionDeleteParams: FunctionDeleteParams) = apply { + functionId = functionDeleteParams.functionId + additionalHeaders = functionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = functionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = functionDeleteParams.additionalBodyProperties.toMutableMap() + } /** Function id */ - fun functionId(functionId: String) = - apply { - this.functionId = functionId - } + fun functionId(functionId: String) = apply { this.functionId = functionId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): FunctionDeleteParams = FunctionDeleteParams( - checkRequired( - "functionId", functionId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("functionId", functionId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FunctionDeleteParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "FunctionDeleteParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 16df2c1f..2792f617 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -35,12 +35,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Invoke a function. */ -class FunctionInvokeParams private constructor( +class FunctionInvokeParams +private constructor( private val functionId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Function id */ @@ -59,8 +59,8 @@ class FunctionInvokeParams private constructor( fun parent(): Optional = body.parent() /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. */ fun stream(): Optional = body.stream() @@ -77,8 +77,8 @@ class FunctionInvokeParams private constructor( fun _parent(): JsonField = body._parent() /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. */ fun _stream(): JsonField = body._stream() @@ -91,40 +91,48 @@ class FunctionInvokeParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } /** The request to invoke a function */ @NoAutoDetect - class Body @JsonCreator private constructor( + class Body + @JsonCreator + private constructor( @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("messages") @ExcludeMissing private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("messages") + @ExcludeMissing + private val messages: JsonField> = JsonMissing.of(), @JsonProperty("mode") @ExcludeMissing private val mode: JsonField = JsonMissing.of(), - @JsonProperty("parent") @ExcludeMissing private val parent: JsonField = JsonMissing.of(), - @JsonProperty("stream") @ExcludeMissing private val stream: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonProperty("stream") + @ExcludeMissing + private val stream: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Argument to the function, which can be any JSON serializable value */ - @JsonProperty("input") - @ExcludeMissing - fun _input(): JsonValue = input + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input /** If the function is an LLM, additional messages to pass along to it */ - fun messages(): Optional> = Optional.ofNullable(messages.getNullable("messages")) + fun messages(): Optional> = + Optional.ofNullable(messages.getNullable("messages")) /** The mode format of the returned value (defaults to 'auto') */ fun mode(): Optional = Optional.ofNullable(mode.getNullable("mode")) @@ -133,8 +141,8 @@ class FunctionInvokeParams private constructor( fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. */ fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) @@ -147,27 +155,19 @@ class FunctionInvokeParams private constructor( fun _messages(): JsonField> = messages /** The mode format of the returned value (defaults to 'auto') */ - @JsonProperty("mode") - @ExcludeMissing - fun _mode(): JsonField = mode + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode /** Options for tracing the function call */ - @JsonProperty("parent") - @ExcludeMissing - fun _parent(): JsonField = parent + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. */ - @JsonProperty("stream") - @ExcludeMissing - fun _stream(): JsonField = stream + @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream /** The version of the function */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -175,27 +175,25 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - messages().ifPresent { it.forEach { it.validate() } } - mode() - parent().ifPresent { it.validate() } - stream() - version() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + messages().ifPresent { it.forEach { it.validate() } } + mode() + parent().ifPresent { it.validate() } + stream() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -210,39 +208,34 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - input = body.input - messages = body.messages.map { it.toMutableList() } - mode = body.mode - parent = body.parent - stream = body.stream - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + input = body.input + messages = body.messages.map { it.toMutableList() } + mode = body.mode + parent = body.parent + stream = body.stream + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** Argument to the function, which can be any JSON serializable value */ - fun input(input: JsonValue) = - apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** If the function is an LLM, additional messages to pass along to it */ fun messages(messages: List) = messages(JsonField.of(messages)) /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: JsonField>) = - apply { - this.messages = messages.map { it.toMutableList() } - } + fun messages(messages: JsonField>) = apply { + this.messages = messages.map { it.toMutableList() } + } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: Message) = - apply { - messages = (messages ?: JsonField.of(mutableListOf())).also { + fun addMessage(message: Message) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).also { checkKnown("messages", it).add(message) } - } + } /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) @@ -251,7 +244,8 @@ class FunctionInvokeParams private constructor( fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(assistant: Message.Assistant) = addMessage(Message.ofAssistant(assistant)) + fun addMessage(assistant: Message.Assistant) = + addMessage(Message.ofAssistant(assistant)) /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) @@ -269,106 +263,88 @@ class FunctionInvokeParams private constructor( fun mode(mode: Optional) = mode(mode.getOrNull()) /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: JsonField) = - apply { - this.mode = mode - } + fun mode(mode: JsonField) = apply { this.mode = mode } /** Options for tracing the function call */ fun parent(parent: Parent) = parent(JsonField.of(parent)) /** Options for tracing the function call */ - fun parent(parent: JsonField) = - apply { - this.parent = parent - } + fun parent(parent: JsonField) = apply { this.parent = parent } /** Span parent properties */ - fun parent(spanParentStruct: Parent.SpanParentStruct) = parent(Parent.ofSpanParentStruct(spanParentStruct)) + fun parent(spanParentStruct: Parent.SpanParentStruct) = + parent(Parent.ofSpanParentStruct(spanParentStruct)) /** The parent's span identifier, created by calling `.export()` on a span */ fun parent(string: String) = parent(Parent.ofString(string)) /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust + * SSE format. */ fun stream(stream: Boolean?) = stream(JsonField.ofNullable(stream)) /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust + * SSE format. */ fun stream(stream: Boolean) = stream(stream as Boolean?) /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust + * SSE format. */ fun stream(stream: Optional) = stream(stream.getOrNull()) /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust + * SSE format. */ - fun stream(stream: JsonField) = - apply { - this.stream = stream - } + fun stream(stream: JsonField) = apply { this.stream = stream } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) /** The version of the function */ - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - input, - (messages ?: JsonMissing.of()).map { it.toImmutable() }, - mode, - parent, - stream, - version, - additionalProperties.toImmutable(), + input, + (messages ?: JsonMissing.of()).map { it.toImmutable() }, + mode, + parent, + stream, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -377,7 +353,8 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -385,17 +362,14 @@ class FunctionInvokeParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionInvokeParams]. + * Returns a mutable builder for constructing an instance of [FunctionInvokeParams]. * * The following fields are required: - * * ```java * .functionId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionInvokeParams]. */ @@ -408,326 +382,229 @@ class FunctionInvokeParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionInvokeParams: FunctionInvokeParams) = - apply { - functionId = functionInvokeParams.functionId - body = functionInvokeParams.body.toBuilder() - additionalHeaders = functionInvokeParams.additionalHeaders.toBuilder() - additionalQueryParams = functionInvokeParams.additionalQueryParams.toBuilder() - } + internal fun from(functionInvokeParams: FunctionInvokeParams) = apply { + functionId = functionInvokeParams.functionId + body = functionInvokeParams.body.toBuilder() + additionalHeaders = functionInvokeParams.additionalHeaders.toBuilder() + additionalQueryParams = functionInvokeParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = - apply { - this.functionId = functionId - } + fun functionId(functionId: String) = apply { this.functionId = functionId } /** Argument to the function, which can be any JSON serializable value */ - fun input(input: JsonValue) = - apply { - body.input(input) - } + fun input(input: JsonValue) = apply { body.input(input) } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: List) = - apply { - body.messages(messages) - } + fun messages(messages: List) = apply { body.messages(messages) } /** If the function is an LLM, additional messages to pass along to it */ - fun messages(messages: JsonField>) = - apply { - body.messages(messages) - } + fun messages(messages: JsonField>) = apply { body.messages(messages) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(message: Message) = - apply { - body.addMessage(message) - } + fun addMessage(message: Message) = apply { body.addMessage(message) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(system: Message.System) = - apply { - body.addMessage(system) - } + fun addMessage(system: Message.System) = apply { body.addMessage(system) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(user: Message.User) = - apply { - body.addMessage(user) - } + fun addMessage(user: Message.User) = apply { body.addMessage(user) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(assistant: Message.Assistant) = - apply { - body.addMessage(assistant) - } + fun addMessage(assistant: Message.Assistant) = apply { body.addMessage(assistant) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(tool: Message.Tool) = - apply { - body.addMessage(tool) - } + fun addMessage(tool: Message.Tool) = apply { body.addMessage(tool) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(function: Message.Function) = - apply { - body.addMessage(function) - } + fun addMessage(function: Message.Function) = apply { body.addMessage(function) } /** If the function is an LLM, additional messages to pass along to it */ - fun addMessage(fallback: Message.Fallback) = - apply { - body.addMessage(fallback) - } + fun addMessage(fallback: Message.Fallback) = apply { body.addMessage(fallback) } /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: Mode?) = - apply { - body.mode(mode) - } + fun mode(mode: Mode?) = apply { body.mode(mode) } /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Optional) = mode(mode.getOrNull()) /** The mode format of the returned value (defaults to 'auto') */ - fun mode(mode: JsonField) = - apply { - body.mode(mode) - } + fun mode(mode: JsonField) = apply { body.mode(mode) } /** Options for tracing the function call */ - fun parent(parent: Parent) = - apply { - body.parent(parent) - } + fun parent(parent: Parent) = apply { body.parent(parent) } /** Options for tracing the function call */ - fun parent(parent: JsonField) = - apply { - body.parent(parent) - } + fun parent(parent: JsonField) = apply { body.parent(parent) } /** Span parent properties */ - fun parent(spanParentStruct: Parent.SpanParentStruct) = - apply { - body.parent(spanParentStruct) - } + fun parent(spanParentStruct: Parent.SpanParentStruct) = apply { + body.parent(spanParentStruct) + } /** The parent's span identifier, created by calling `.export()` on a span */ - fun parent(string: String) = - apply { - body.parent(string) - } + fun parent(string: String) = apply { body.parent(string) } /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. */ - fun stream(stream: Boolean?) = - apply { - body.stream(stream) - } + fun stream(stream: Boolean?) = apply { body.stream(stream) } /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. */ fun stream(stream: Boolean) = stream(stream as Boolean?) /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. */ fun stream(stream: Optional) = stream(stream.getOrNull()) /** - * Whether to stream the response. If true, results will be returned in the - * Braintrust SSE format. + * Whether to stream the response. If true, results will be returned in the Braintrust SSE + * format. */ - fun stream(stream: JsonField) = - apply { - body.stream(stream) - } + fun stream(stream: JsonField) = apply { body.stream(stream) } /** The version of the function */ - fun version(version: String) = - apply { - body.version(version) - } + fun version(version: String) = apply { body.version(version) } /** The version of the function */ - fun version(version: JsonField) = - apply { - body.version(version) - } + fun version(version: JsonField) = apply { body.version(version) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionInvokeParams = FunctionInvokeParams( - checkRequired( - "functionId", functionId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("functionId", functionId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( + class Message + private constructor( private val system: System? = null, private val user: User? = null, private val assistant: Assistant? = null, @@ -735,7 +612,6 @@ class FunctionInvokeParams private constructor( private val function: Function? = null, private val fallback: Fallback? = null, private val _json: JsonValue? = null, - ) { fun system(): Optional = Optional.ofNullable(system) @@ -777,59 +653,60 @@ class FunctionInvokeParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Message = - apply { - if (validated) { - return@apply - } + fun validate(): Message = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitSystem(system: System) { - system.validate() + system.validate() } override fun visitUser(user: User) { - user.validate() + user.validate() } override fun visitAssistant(assistant: Assistant) { - assistant.validate() + assistant.validate() } override fun visitTool(tool: Tool) { - tool.validate() + tool.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitFallback(fallback: Fallback) { - fallback.validate() + fallback.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ + return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ @@ -848,28 +725,21 @@ class FunctionInvokeParams private constructor( companion object { - @JvmStatic - fun ofSystem(system: System) = Message(system = system) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUser(user: User) = Message(user = user) + @JvmStatic fun ofUser(user: User) = Message(user = user) - @JvmStatic - fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) + @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofTool(tool: Tool) = Message(tool = tool) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofFunction(function: Function) = Message(function = function) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } /** - * An interface that defines how to map each variant of [Message] to a value of - * type [T]. + * An interface that defines how to map each variant of [Message] to a value of type [T]. */ interface Visitor { @@ -888,69 +758,87 @@ class FunctionInvokeParams private constructor( /** * Maps an unknown variant of [Message] to a value of type [T]. * - * An instance of [Message] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Message] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } internal class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } internal class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } @NoAutoDetect - class System @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class System + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") @@ -959,17 +847,11 @@ class FunctionInvokeParams private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") - @ExcludeMissing - fun _content(): JsonField = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -977,18 +859,17 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): System = - apply { - if (validated) { - return@apply - } - - role() - content() - name() - validated = true + fun validate(): System = apply { + if (validated) { + return@apply } + role() + content() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -997,13 +878,11 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [System]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [System]. */ @@ -1015,76 +894,58 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(system: System) = - apply { - role = system.role - content = system.content - name = system.name - additionalProperties = system.additionalProperties.toMutableMap() - } + internal fun from(system: System) = apply { + role = system.role + content = system.content + name = system.name + additionalProperties = system.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): System = System( - checkRequired( - "role", role - ), - content, - name, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + name, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1094,8 +955,7 @@ class FunctionInvokeParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1106,23 +966,23 @@ class FunctionInvokeParams private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - SYSTEM, + SYSTEM } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { SYSTEM, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1146,7 +1006,7 @@ class FunctionInvokeParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1161,16 +1021,19 @@ class FunctionInvokeParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1179,11 +1042,11 @@ class FunctionInvokeParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1192,16 +1055,25 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class User @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class User + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") @@ -1210,17 +1082,11 @@ class FunctionInvokeParams private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") - @ExcludeMissing - fun _content(): JsonField = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1228,18 +1094,17 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): User = - apply { - if (validated) { - return@apply - } - - role() - content().ifPresent { it.validate() } - name() - validated = true + fun validate(): User = apply { + if (validated) { + return@apply } + role() + content().ifPresent { it.validate() } + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1248,13 +1113,11 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [User]. */ @@ -1266,80 +1129,63 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(user: User) = - apply { - role = user.role - content = user.content - name = user.name - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = apply { + role = user.role + content = user.content + name = user.name + additionalProperties = user.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: Content) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun content(text: String) = content(Content.ofText(text)) - fun contentOfArray(array: List) = content(Content.ofArray(array)) + fun contentOfArray(array: List) = + content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired( - "role", role - ), - content, - name, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + name, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1349,8 +1195,7 @@ class FunctionInvokeParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1361,23 +1206,23 @@ class FunctionInvokeParams private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - USER, + USER } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { USER, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1401,7 +1246,7 @@ class FunctionInvokeParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1416,16 +1261,19 @@ class FunctionInvokeParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1435,11 +1283,11 @@ class FunctionInvokeParams private constructor( @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor( + class Content + private constructor( private val text: String? = null, private val array: List? = null, private val _json: JsonValue? = null, - ) { fun text(): Optional = Optional.ofNullable(text) @@ -1457,39 +1305,38 @@ class FunctionInvokeParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } } - private var validated: Boolean = false - - fun validate(): Content = - apply { - if (validated) { - return@apply - } - - accept(object : Visitor { - override fun visitText(text: String) { + private var validated: Boolean = false - } + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitText(text: String) {} override fun visitArray(array: List) { - array.forEach { it.validate() } + array.forEach { it.validate() } } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, array) /* spotless:on */ @@ -1504,16 +1351,15 @@ class FunctionInvokeParams private constructor( companion object { - @JvmStatic - fun ofText(text: String) = Content(text = text) + @JvmStatic fun ofText(text: String) = Content(text = text) @JvmStatic fun ofArray(array: List) = Content(array = array) } /** - * An interface that defines how to map each variant of [Content] to a value of - * type [T]. + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. */ interface Visitor { @@ -1524,58 +1370,66 @@ class FunctionInvokeParams private constructor( /** * Maps an unknown variant of [Content] to a value of type [T]. * - * An instance of [Content] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } internal class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Content(array = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Content(array = it, _json = json) + } - return Content(_json = json) + return Content(_json = json) } } internal class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart private constructor( + class ChatCompletionContentPart + private constructor( private val text: ChatCompletionContentPartText? = null, private val image: ChatCompletionContentPartImage? = null, private val _json: JsonValue? = null, - ) { fun text(): Optional = Optional.ofNullable(text) - fun image(): Optional = Optional.ofNullable(image) + fun image(): Optional = + Optional.ofNullable(image) fun isText(): Boolean = text != null @@ -1588,39 +1442,40 @@ class FunctionInvokeParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - image != null -> visitor.visitImage(image) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ChatCompletionContentPart = - apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPart = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitText(text: ChatCompletionContentPartText) { - text.validate() + text.validate() } override fun visitImage(image: ChatCompletionContentPartImage) { - image.validate() + image.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, image) /* spotless:on */ @@ -1636,15 +1491,17 @@ class FunctionInvokeParams private constructor( companion object { @JvmStatic - fun ofText(text: ChatCompletionContentPartText) = ChatCompletionContentPart(text = text) + fun ofText(text: ChatCompletionContentPartText) = + ChatCompletionContentPart(text = text) @JvmStatic - fun ofImage(image: ChatCompletionContentPartImage) = ChatCompletionContentPart(image = image) + fun ofImage(image: ChatCompletionContentPartImage) = + ChatCompletionContentPart(image = image) } /** - * An interface that defines how to map each variant of [ChatCompletionContentPart] - * to a value of type [T]. + * An interface that defines how to map each variant of + * [ChatCompletionContentPart] to a value of type [T]. */ interface Visitor { @@ -1653,56 +1510,78 @@ class FunctionInvokeParams private constructor( fun visitImage(image: ChatCompletionContentPartImage): T /** - * Maps an unknown variant of [ChatCompletionContentPart] to a value of type [T]. + * Maps an unknown variant of [ChatCompletionContentPart] to a value of type + * [T]. * - * An instance of [ChatCompletionContentPart] can contain an unknown variant if it - * was deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [ChatCompletionContentPart] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. + * For example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) } } - internal class Deserializer : BaseDeserializer(ChatCompletionContentPart::class) { + internal class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ChatCompletionContentPart(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ChatCompletionContentPart(image = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return ChatCompletionContentPart(image = it, _json = json) + } - return ChatCompletionContentPart(_json = json) + return ChatCompletionContentPart(_json = json) } } - internal class Serializer : BaseSerializer(ChatCompletionContentPart::class) { - - override fun serialize(value: ChatCompletionContentPart, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.text != null -> generator.writeObject(value.text) - value.image != null -> generator.writeObject(value.image) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } + internal class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid ChatCompletionContentPart") + } } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1711,45 +1590,55 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Assistant @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("tool_calls") @ExcludeMissing private val toolCalls: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Assistant + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tool_calls") + @ExcludeMissing + private val toolCalls: JsonField> = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") - @ExcludeMissing - fun _content(): JsonField = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall(): JsonField = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tool_calls") @ExcludeMissing @@ -1761,20 +1650,19 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): Assistant = - apply { - if (validated) { - return@apply - } - - role() - content() - functionCall().ifPresent { it.validate() } - name() - toolCalls().ifPresent { it.forEach { it.validate() } } - validated = true + fun validate(): Assistant = apply { + if (validated) { + return@apply } + role() + content() + functionCall().ifPresent { it.validate() } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1783,13 +1671,11 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [Assistant]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Assistant]. */ @@ -1803,109 +1689,93 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(assistant: Assistant) = - apply { - role = assistant.role - content = assistant.content - functionCall = assistant.functionCall - name = assistant.name - toolCalls = assistant.toolCalls.map { it.toMutableList() } - additionalProperties = assistant.additionalProperties.toMutableMap() - } + internal fun from(assistant: Assistant) = apply { + role = assistant.role + content = assistant.content + functionCall = assistant.functionCall + name = assistant.name + toolCalls = assistant.toolCalls.map { it.toMutableList() } + additionalProperties = assistant.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } - fun functionCall(functionCall: FunctionCall?) = functionCall(JsonField.ofNullable(functionCall)) + fun functionCall(functionCall: FunctionCall?) = + functionCall(JsonField.ofNullable(functionCall)) - fun functionCall(functionCall: Optional) = functionCall(functionCall.getOrNull()) + fun functionCall(functionCall: Optional) = + functionCall(functionCall.getOrNull()) - fun functionCall(functionCall: JsonField) = - apply { - this.functionCall = functionCall - } + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.getOrNull()) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List?) = toolCalls(JsonField.ofNullable(toolCalls)) + fun toolCalls(toolCalls: List?) = + toolCalls(JsonField.ofNullable(toolCalls)) - fun toolCalls(toolCalls: Optional>) = toolCalls(toolCalls.getOrNull()) + fun toolCalls(toolCalls: Optional>) = + toolCalls(toolCalls.getOrNull()) - fun toolCalls(toolCalls: JsonField>) = - apply { - this.toolCalls = toolCalls.map { it.toMutableList() } - } + fun toolCalls(toolCalls: JsonField>) = apply { + this.toolCalls = toolCalls.map { it.toMutableList() } + } - fun addToolCall(toolCall: ChatCompletionMessageToolCall) = - apply { - toolCalls = (toolCalls ?: JsonField.of(mutableListOf())).also { + fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { + toolCalls = + (toolCalls ?: JsonField.of(mutableListOf())).also { checkKnown("toolCalls", it).add(toolCall) } - } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Assistant = Assistant( - checkRequired( - "role", role - ), - content, - functionCall, - name, - (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + functionCall, + name, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1915,8 +1785,7 @@ class FunctionInvokeParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1927,23 +1796,23 @@ class FunctionInvokeParams private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - ASSISTANT, + ASSISTANT } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 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 { ASSISTANT, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1967,7 +1836,7 @@ class FunctionInvokeParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1982,16 +1851,19 @@ class FunctionInvokeParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2000,11 +1872,17 @@ class FunctionInvokeParams private constructor( } @NoAutoDetect - class FunctionCall @JsonCreator private constructor( - @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class FunctionCall + @JsonCreator + private constructor( + @JsonProperty("arguments") + @ExcludeMissing + private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun arguments(): String = arguments.getRequired("arguments") @@ -2015,9 +1893,7 @@ class FunctionInvokeParams private constructor( @ExcludeMissing fun _arguments(): JsonField = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2025,17 +1901,16 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): FunctionCall = - apply { - if (validated) { - return@apply - } - - arguments() - name() - validated = true + fun validate(): FunctionCall = apply { + if (validated) { + return@apply } + arguments() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2044,14 +1919,12 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [FunctionCall]. * * The following fields are required: - * * ```java * .arguments() * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionCall]. */ @@ -2062,71 +1935,58 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionCall: FunctionCall) = - apply { - arguments = functionCall.arguments - name = functionCall.name - additionalProperties = functionCall.additionalProperties.toMutableMap() - } + internal fun from(functionCall: FunctionCall) = apply { + arguments = functionCall.arguments + name = functionCall.name + additionalProperties = functionCall.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = - apply { - this.arguments = arguments - } + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionCall = FunctionCall( - checkRequired( - "arguments", arguments - ), - checkRequired( - "name", name - ), - additionalProperties.toImmutable(), + checkRequired("arguments", arguments), + checkRequired("name", name), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2135,15 +1995,16 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2152,31 +2013,37 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Tool @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("tool_call_id") @ExcludeMissing private val toolCallId: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Tool + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + private val toolCallId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") - @ExcludeMissing - fun _content(): JsonField = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @JsonProperty("tool_call_id") @ExcludeMissing @@ -2188,18 +2055,17 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): Tool = - apply { - if (validated) { - return@apply - } - - role() - content() - toolCallId() - validated = true + fun validate(): Tool = apply { + if (validated) { + return@apply } + role() + content() + toolCallId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2208,13 +2074,11 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [Tool]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Tool]. */ @@ -2226,76 +2090,60 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tool: Tool) = - apply { - role = tool.role - content = tool.content - toolCallId = tool.toolCallId - additionalProperties = tool.additionalProperties.toMutableMap() - } + internal fun from(tool: Tool) = apply { + role = tool.role + content = tool.content + toolCallId = tool.toolCallId + additionalProperties = tool.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - fun toolCallId(toolCallId: JsonField) = - apply { - this.toolCallId = toolCallId - } + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Tool = Tool( - checkRequired( - "role", role - ), - content, - toolCallId, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + toolCallId, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2305,8 +2153,7 @@ class FunctionInvokeParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2317,23 +2164,23 @@ class FunctionInvokeParams private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - TOOL, + TOOL } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 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 { TOOL, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2357,7 +2204,7 @@ class FunctionInvokeParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2372,16 +2219,19 @@ class FunctionInvokeParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2390,11 +2240,11 @@ class FunctionInvokeParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2403,16 +2253,25 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Function + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") @@ -2421,17 +2280,11 @@ class FunctionInvokeParams private constructor( fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") - @ExcludeMissing - fun _content(): JsonField = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing @@ -2439,18 +2292,17 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - name() - role() - content() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + name() + role() + content() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2459,14 +2311,12 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .name() * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ @@ -2478,78 +2328,58 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - name = function.name - role = function.role - content = function.content - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + name = function.name + role = function.role + content = function.content + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "name", name - ), - checkRequired( - "role", role - ), - content, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("role", role), + content, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2559,8 +2389,7 @@ class FunctionInvokeParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2571,23 +2400,23 @@ class FunctionInvokeParams private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 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 { FUNCTION, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2611,7 +2440,7 @@ class FunctionInvokeParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2626,16 +2455,19 @@ class FunctionInvokeParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2644,11 +2476,11 @@ class FunctionInvokeParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2657,28 +2489,31 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Fallback @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Fallback + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role - @JsonProperty("content") - @ExcludeMissing - fun _content(): JsonField = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @JsonAnyGetter @ExcludeMissing @@ -2686,17 +2521,16 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): Fallback = - apply { - if (validated) { - return@apply - } - - role() - content() - validated = true + fun validate(): Fallback = apply { + if (validated) { + return@apply } + role() + content() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2705,13 +2539,11 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [Fallback]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Fallback]. */ @@ -2722,69 +2554,54 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fallback: Fallback) = - apply { - role = fallback.role - content = fallback.content - additionalProperties = fallback.additionalProperties.toMutableMap() - } + internal fun from(fallback: Fallback) = apply { + role = fallback.role + content = fallback.content + additionalProperties = fallback.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Fallback = Fallback( - checkRequired( - "role", role - ), - content, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2794,8 +2611,7 @@ class FunctionInvokeParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2806,23 +2622,23 @@ class FunctionInvokeParams private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - MODEL, + MODEL } /** * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Role] 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 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 { MODEL, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2846,7 +2662,7 @@ class FunctionInvokeParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2861,16 +2677,19 @@ class FunctionInvokeParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2879,11 +2698,11 @@ class FunctionInvokeParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2892,26 +2711,23 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" } } /** The mode format of the returned value (defaults to 'auto') */ - class Mode @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Mode @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2932,11 +2748,9 @@ class FunctionInvokeParams private constructor( * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Mode] 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 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 { @@ -2947,11 +2761,11 @@ class FunctionInvokeParams private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -2963,11 +2777,11 @@ class FunctionInvokeParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -2979,20 +2793,23 @@ class FunctionInvokeParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ + return /* spotless:off */ other is Mode && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3003,11 +2820,11 @@ class FunctionInvokeParams private constructor( /** Options for tracing the function call */ @JsonDeserialize(using = Parent.Deserializer::class) @JsonSerialize(using = Parent.Serializer::class) - class Parent private constructor( + class Parent + private constructor( private val spanParentStruct: SpanParentStruct? = null, private val string: String? = null, private val _json: JsonValue? = null, - ) { /** Span parent properties */ @@ -3029,39 +2846,38 @@ class FunctionInvokeParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - spanParentStruct != null -> visitor.visitSpanParentStruct(spanParentStruct) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + return when { + spanParentStruct != null -> visitor.visitSpanParentStruct(spanParentStruct) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Parent = - apply { - if (validated) { - return@apply - } + fun validate(): Parent = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitSpanParentStruct(spanParentStruct: SpanParentStruct) { - spanParentStruct.validate() + spanParentStruct.validate() } - override fun visitString(string: String) { - - } - }) - validated = true - } + override fun visitString(string: String) {} + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ + return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanParentStruct, string) /* spotless:on */ @@ -3078,17 +2894,14 @@ class FunctionInvokeParams private constructor( /** Span parent properties */ @JvmStatic - fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = Parent(spanParentStruct = spanParentStruct) + fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = + Parent(spanParentStruct = spanParentStruct) /** The parent's span identifier, created by calling `.export()` on a span */ - @JvmStatic - fun ofString(string: String) = Parent(string = string) + @JvmStatic fun ofString(string: String) = Parent(string = string) } - /** - * An interface that defines how to map each variant of [Parent] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Parent] to a value of type [T]. */ interface Visitor { /** Span parent properties */ @@ -3100,55 +2913,70 @@ class FunctionInvokeParams private constructor( /** * Maps an unknown variant of [Parent] to a value of type [T]. * - * An instance of [Parent] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Parent] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Parent: $json") + throw BraintrustInvalidDataException("Unknown Parent: $json") } } internal class Deserializer : BaseDeserializer(Parent::class) { override fun ObjectCodec.deserialize(node: JsonNode): Parent { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Parent(spanParentStruct = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Parent(string = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Parent(spanParentStruct = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Parent(string = it, _json = json) + } - return Parent(_json = json) + return Parent(_json = json) } } internal class Serializer : BaseSerializer(Parent::class) { - override fun serialize(value: Parent, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parent") - } + override fun serialize( + value: Parent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Parent") + } } } /** Span parent properties */ @NoAutoDetect - class SpanParentStruct @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("propagated_event") @ExcludeMissing private val propagatedEvent: JsonField = JsonMissing.of(), - @JsonProperty("row_ids") @ExcludeMissing private val rowIds: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class SpanParentStruct + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("propagated_event") + @ExcludeMissing + private val propagatedEvent: JsonField = JsonMissing.of(), + @JsonProperty("row_ids") + @ExcludeMissing + private val rowIds: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the container object you are logging to */ @@ -3157,15 +2985,14 @@ class FunctionInvokeParams private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** Include these properties in every span created under this parent */ - fun propagatedEvent(): Optional = Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) + fun propagatedEvent(): Optional = + Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) /** Identifiers for the row to to log a subspan under */ fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) /** The id of the container object you are logging to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId @JsonProperty("object_type") @ExcludeMissing @@ -3177,9 +3004,7 @@ class FunctionInvokeParams private constructor( fun _propagatedEvent(): JsonField = propagatedEvent /** Identifiers for the row to to log a subspan under */ - @JsonProperty("row_ids") - @ExcludeMissing - fun _rowIds(): JsonField = rowIds + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField = rowIds @JsonAnyGetter @ExcludeMissing @@ -3187,19 +3012,18 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): SpanParentStruct = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - propagatedEvent().ifPresent { it.validate() } - rowIds().ifPresent { it.validate() } - validated = true + fun validate(): SpanParentStruct = apply { + if (validated) { + return@apply } + objectId() + objectType() + propagatedEvent().ifPresent { it.validate() } + rowIds().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3208,14 +3032,12 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [SpanParentStruct]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SpanParentStruct]. */ @@ -3228,42 +3050,38 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanParentStruct: SpanParentStruct) = - apply { - objectId = spanParentStruct.objectId - objectType = spanParentStruct.objectType - propagatedEvent = spanParentStruct.propagatedEvent - rowIds = spanParentStruct.rowIds - additionalProperties = spanParentStruct.additionalProperties.toMutableMap() - } + internal fun from(spanParentStruct: SpanParentStruct) = apply { + objectId = spanParentStruct.objectId + objectType = spanParentStruct.objectType + propagatedEvent = spanParentStruct.propagatedEvent + rowIds = spanParentStruct.rowIds + additionalProperties = spanParentStruct.additionalProperties.toMutableMap() + } /** The id of the container object you are logging to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the container object you are logging to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - fun objectType(objectType: JsonField) = - apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: PropagatedEvent?) = propagatedEvent(JsonField.ofNullable(propagatedEvent)) + fun propagatedEvent(propagatedEvent: PropagatedEvent?) = + propagatedEvent(JsonField.ofNullable(propagatedEvent)) /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: Optional) = propagatedEvent(propagatedEvent.getOrNull()) + fun propagatedEvent(propagatedEvent: Optional) = + propagatedEvent(propagatedEvent.getOrNull()) /** Include these properties in every span created under this parent */ - fun propagatedEvent(propagatedEvent: JsonField) = - apply { - this.propagatedEvent = propagatedEvent - } + fun propagatedEvent(propagatedEvent: JsonField) = apply { + this.propagatedEvent = propagatedEvent + } /** Identifiers for the row to to log a subspan under */ fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) @@ -3272,55 +3090,43 @@ class FunctionInvokeParams private constructor( fun rowIds(rowIds: Optional) = rowIds(rowIds.getOrNull()) /** Identifiers for the row to to log a subspan under */ - fun rowIds(rowIds: JsonField) = - apply { - this.rowIds = rowIds - } + fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SpanParentStruct = SpanParentStruct( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - propagatedEvent, - rowIds, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + propagatedEvent, + rowIds, + additionalProperties.toImmutable(), ) } - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class ObjectType + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -3330,8 +3136,7 @@ class FunctionInvokeParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -3352,11 +3157,9 @@ class FunctionInvokeParams private constructor( * 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 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 { @@ -3390,7 +3193,7 @@ class FunctionInvokeParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3406,16 +3209,19 @@ class FunctionInvokeParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3425,9 +3231,11 @@ class FunctionInvokeParams private constructor( /** Include these properties in every span created under this parent */ @NoAutoDetect - class PropagatedEvent @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class PropagatedEvent + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -3436,22 +3244,22 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): PropagatedEvent = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): PropagatedEvent = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [PropagatedEvent]. */ - @JvmStatic - fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of [PropagatedEvent]. + */ + @JvmStatic fun builder() = Builder() } /** A builder for [PropagatedEvent]. */ @@ -3460,46 +3268,42 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(propagatedEvent: PropagatedEvent) = - apply { - additionalProperties = propagatedEvent.additionalProperties.toMutableMap() - } + internal fun from(propagatedEvent: PropagatedEvent) = apply { + additionalProperties = propagatedEvent.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): PropagatedEvent = PropagatedEvent(additionalProperties.toImmutable()) + fun build(): PropagatedEvent = + PropagatedEvent(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3508,17 +3312,26 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "PropagatedEvent{additionalProperties=$additionalProperties}" + override fun toString() = + "PropagatedEvent{additionalProperties=$additionalProperties}" } /** Identifiers for the row to to log a subspan under */ @NoAutoDetect - class RowIds @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RowIds + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the row */ @@ -3531,9 +3344,7 @@ class FunctionInvokeParams private constructor( fun spanId(): String = spanId.getRequired("span_id") /** The id of the row */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The root_span_id of the row */ @JsonProperty("root_span_id") @@ -3541,9 +3352,7 @@ class FunctionInvokeParams private constructor( fun _rootSpanId(): JsonField = rootSpanId /** The span_id of the row */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId(): JsonField = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId @JsonAnyGetter @ExcludeMissing @@ -3551,18 +3360,17 @@ class FunctionInvokeParams private constructor( private var validated: Boolean = false - fun validate(): RowIds = - apply { - if (validated) { - return@apply - } - - id() - rootSpanId() - spanId() - validated = true + fun validate(): RowIds = apply { + if (validated) { + return@apply } + id() + rootSpanId() + spanId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3571,15 +3379,13 @@ class FunctionInvokeParams private constructor( * Returns a mutable builder for constructing an instance of [RowIds]. * * The following fields are required: - * * ```java * .id() * .rootSpanId() * .spanId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RowIds]. */ @@ -3591,88 +3397,70 @@ class FunctionInvokeParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(rowIds: RowIds) = - apply { - id = rowIds.id - rootSpanId = rowIds.rootSpanId - spanId = rowIds.spanId - additionalProperties = rowIds.additionalProperties.toMutableMap() - } + internal fun from(rowIds: RowIds) = apply { + id = rowIds.id + rootSpanId = rowIds.rootSpanId + spanId = rowIds.spanId + additionalProperties = rowIds.additionalProperties.toMutableMap() + } /** The id of the row */ fun id(id: String) = id(JsonField.of(id)) /** The id of the row */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** The root_span_id of the row */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** The root_span_id of the row */ - fun rootSpanId(rootSpanId: JsonField) = - apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { + this.rootSpanId = rootSpanId + } /** The span_id of the row */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** The span_id of the row */ - fun spanId(spanId: JsonField) = - apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RowIds = RowIds( - checkRequired( - "id", id - ), - checkRequired( - "rootSpanId", rootSpanId - ), - checkRequired( - "spanId", spanId - ), - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3681,15 +3469,16 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" + override fun toString() = + "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3698,19 +3487,21 @@ class FunctionInvokeParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "FunctionInvokeParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "FunctionInvokeParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 721e7224..3320310c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -13,9 +13,10 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects @NoAutoDetect -class FunctionInvokeResponse @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - +class FunctionInvokeResponse +@JsonCreator +private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -24,25 +25,20 @@ class FunctionInvokeResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FunctionInvokeResponse = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): FunctionInvokeResponse = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of - * [FunctionInvokeResponse]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [FunctionInvokeResponse]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionInvokeResponse]. */ @@ -51,46 +47,39 @@ class FunctionInvokeResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionInvokeResponse: FunctionInvokeResponse) = - apply { - additionalProperties = functionInvokeResponse.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): FunctionInvokeResponse = FunctionInvokeResponse(additionalProperties.toImmutable()) + internal fun from(functionInvokeResponse: FunctionInvokeResponse) = apply { + additionalProperties = functionInvokeResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): FunctionInvokeResponse = + FunctionInvokeResponse(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionInvokeResponse && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionInvokeResponse && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 27c52924..1ed3037c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.FunctionService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all functions. The functions are sorted by creation date, with the most - * recently-created functions coming first + * List out all functions. The functions are sorted by creation date, with the most recently-created + * functions coming first */ -class FunctionListPage private constructor( +class FunctionListPage +private constructor( private val functionsService: FunctionService, private val params: FunctionListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class FunctionListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListPage && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is FunctionListPage && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ - override fun toString() = "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" + override fun toString() = + "FunctionListPage{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + FunctionListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + FunctionListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { functionsService.list(it) } + return getNextPageParams().map { functionsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +84,16 @@ class FunctionListPage private constructor( @JvmStatic fun of(functionsService: FunctionService, params: FunctionListParams, response: Response) = - FunctionListPage( - functionsService, - params, - response, - ) + FunctionListPage(functionsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +107,34 @@ class FunctionListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [FunctionListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +143,39 @@ class FunctionListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: FunctionListPage, + class AutoPager(private val firstPage: FunctionListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 636c7970..4b4eebea 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.FunctionServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all functions. The functions are sorted by creation date, with the most - * recently-created functions coming first + * List out all functions. The functions are sorted by creation date, with the most recently-created + * functions coming first */ -class FunctionListPageAsync private constructor( +class FunctionListPageAsync +private constructor( private val functionsService: FunctionServiceAsync, private val params: FunctionListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class FunctionListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListPageAsync && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is FunctionListPageAsync && functionsService == other.functionsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionsService, params, response) /* spotless:on */ - override fun toString() = "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" + override fun toString() = + "FunctionListPageAsync{functionsService=$functionsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + FunctionListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + FunctionListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - functionsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { functionsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,20 @@ class FunctionListPageAsync private constructor( companion object { @JvmStatic - fun of(functionsService: FunctionServiceAsync, params: FunctionListParams, response: Response) = - FunctionListPageAsync( - functionsService, - params, - response, - ) + fun of( + functionsService: FunctionServiceAsync, + params: FunctionListParams, + response: Response, + ) = FunctionListPageAsync(functionsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,38 +112,36 @@ class FunctionListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionListPageAsync]. + * Returns a mutable builder for constructing an instance of [FunctionListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +150,46 @@ class FunctionListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: FunctionListPageAsync, - - ) { + class AutoPager(private val firstPage: FunctionListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Function) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Function) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index f40f98e3..aaf2b9ca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all functions. The functions are sorted by creation date, with the most - * recently-created functions coming first + * List out all functions. The functions are sorted by creation date, with the most recently-created + * functions coming first */ -class FunctionListParams private constructor( +class FunctionListParams +private constructor( private val endingBefore: String?, private val functionName: String?, private val ids: Ids?, @@ -39,15 +40,14 @@ class FunctionListParams private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -55,8 +55,8 @@ class FunctionListParams private constructor( fun functionName(): Optional = Optional.ofNullable(functionName) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -78,17 +78,17 @@ class FunctionListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a - * version identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). */ fun version(): Optional = Optional.ofNullable(version) @@ -99,71 +99,29 @@ class FunctionListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.functionName?.let { - queryParams.put( - "function_name", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.projectId?.let { - queryParams.put( - "project_id", listOf(it.toString()) - ) - } - this.projectName?.let { - queryParams.put( - "project_name", listOf(it.toString()) - ) - } - this.slug?.let { - queryParams.put( - "slug", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - this.version?.let { - queryParams.put( - "version", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.functionName?.let { queryParams.put("function_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.slug?.let { queryParams.put("slug", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): FunctionListParams = builder().build() + @JvmStatic fun none(): FunctionListParams = builder().build() /** Returns a mutable builder for constructing an instance of [FunctionListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionListParams]. */ @@ -184,84 +142,71 @@ class FunctionListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionListParams: FunctionListParams) = - apply { - endingBefore = functionListParams.endingBefore - functionName = functionListParams.functionName - ids = functionListParams.ids - limit = functionListParams.limit - orgName = functionListParams.orgName - projectId = functionListParams.projectId - projectName = functionListParams.projectName - slug = functionListParams.slug - startingAfter = functionListParams.startingAfter - version = functionListParams.version - additionalHeaders = functionListParams.additionalHeaders.toBuilder() - additionalQueryParams = functionListParams.additionalQueryParams.toBuilder() - } + internal fun from(functionListParams: FunctionListParams) = apply { + endingBefore = functionListParams.endingBefore + functionName = functionListParams.functionName + ids = functionListParams.ids + limit = functionListParams.limit + orgName = functionListParams.orgName + projectId = functionListParams.projectId + projectName = functionListParams.projectName + slug = functionListParams.slug + startingAfter = functionListParams.startingAfter + version = functionListParams.version + additionalHeaders = functionListParams.additionalHeaders.toBuilder() + additionalQueryParams = functionListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the function to search for */ - fun functionName(functionName: String?) = - apply { - this.functionName = functionName - } + fun functionName(functionName: String?) = apply { this.functionName = functionName } /** Name of the function to search for */ fun functionName(functionName: Optional) = functionName(functionName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -270,37 +215,25 @@ class FunctionListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = - apply { - this.projectName = projectName - } + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Retrieve prompt with a specific slug */ - fun slug(slug: String?) = - apply { - this.slug = slug - } + fun slug(slug: String?) = apply { this.slug = slug } /** Retrieve prompt with a specific slug */ fun slug(slug: Optional) = slug(slug.getOrNull()) @@ -308,195 +241,164 @@ class FunctionListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a - * version identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String?) = - apply { - this.version = version - } + fun version(version: String?) = apply { this.version = version } /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a - * version identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionListParams = FunctionListParams( - endingBefore, - functionName, - ids, - limit, - orgName, - projectId, - projectName, - slug, - startingAfter, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + functionName, + ids, + limit, + orgName, + projectId, + projectName, + slug, + startingAfter, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -514,19 +416,19 @@ class FunctionListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -541,17 +443,12 @@ class FunctionListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -561,56 +458,60 @@ class FunctionListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionListParams && endingBefore == other.endingBefore && functionName == other.functionName && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, functionName, ids, limit, orgName, projectId, projectName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 ce2d221b..bd9be34c 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 @@ -36,15 +36,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace function. If there is an existing function in the project with - * the same slug as the one specified in the request, will replace the existing - * function with the provided fields + * Create or replace function. If there is an existing function in the project with the same slug as + * the one specified in the request, will replace the existing function with the provided fields */ -class FunctionReplaceParams private constructor( +class FunctionReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { fun functionData(): FunctionData = body.functionData() @@ -107,27 +106,48 @@ class FunctionReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_schema") @ExcludeMissing private val functionSchema: JsonField = JsonMissing.of(), - @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("function_data") + @ExcludeMissing + private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_schema") + @ExcludeMissing + private val functionSchema: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun functionData(): FunctionData = functionData.getRequired("function_data") @@ -142,17 +162,21 @@ class FunctionReplaceParams private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** JSON schema for the function's parameters and return type */ - fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) + fun functionSchema(): Optional = + Optional.ofNullable(functionSchema.getNullable("function_schema")) - fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -162,19 +186,13 @@ class FunctionReplaceParams private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -190,9 +208,7 @@ class FunctionReplaceParams private constructor( @ExcludeMissing fun _functionType(): JsonField = functionType - @JsonProperty("origin") - @ExcludeMissing - fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -200,9 +216,7 @@ class FunctionReplaceParams private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -210,24 +224,23 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - functionData().validate() - name() - projectId() - slug() - description() - functionSchema().ifPresent { it.validate() } - functionType() - origin().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true - } + fun validate(): Body = apply { + if (validated) { + return@apply + } + + functionData().validate() + name() + projectId() + slug() + description() + functionSchema().ifPresent { it.validate() } + functionType() + origin().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } fun toBuilder() = Builder().from(this) @@ -237,7 +250,6 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .functionData() * .name() @@ -245,8 +257,7 @@ class FunctionReplaceParams private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -265,60 +276,51 @@ class FunctionReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - functionData = body.functionData - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionSchema = body.functionSchema - functionType = body.functionType - origin = body.origin - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + functionData = body.functionData + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionSchema = body.functionSchema + functionType = body.functionType + origin = body.origin + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = - apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = + functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = + functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -327,40 +329,38 @@ class FunctionReplaceParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) + fun functionSchema(functionSchema: FunctionSchema?) = + functionSchema(JsonField.ofNullable(functionSchema)) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = - apply { - this.functionSchema = functionSchema - } + fun functionSchema(functionSchema: JsonField) = apply { + this.functionSchema = functionSchema + } - fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = apply { + this.functionType = functionType + } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = - apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -369,10 +369,9 @@ class FunctionReplaceParams private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -381,75 +380,57 @@ class FunctionReplaceParams private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "functionData", functionData - ), - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "slug", slug - ), - description, - functionSchema, - functionType, - origin, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("functionData", functionData), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + description, + functionSchema, + functionType, + origin, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && functionData == other.functionData && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionSchema == other.functionSchema && functionType == other.functionType && origin == other.origin && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -458,7 +439,8 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionSchema=$functionSchema, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -466,11 +448,9 @@ class FunctionReplaceParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionReplaceParams]. + * Returns a mutable builder for constructing an instance of [FunctionReplaceParams]. * * The following fields are required: - * * ```java * .functionData() * .name() @@ -478,8 +458,7 @@ class FunctionReplaceParams private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionReplaceParams]. */ @@ -491,331 +470,234 @@ class FunctionReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionReplaceParams: FunctionReplaceParams) = - apply { - body = functionReplaceParams.body.toBuilder() - additionalHeaders = functionReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = functionReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(functionReplaceParams: FunctionReplaceParams) = apply { + body = functionReplaceParams.body.toBuilder() + additionalHeaders = functionReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = functionReplaceParams.additionalQueryParams.toBuilder() + } - fun functionData(functionData: FunctionData) = - apply { - body.functionData(functionData) - } + fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } - fun functionData(functionData: JsonField) = - apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = - apply { - body.functionData(prompt) - } + fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } - fun functionData(code: FunctionData.Code) = - apply { - body.functionData(code) - } + fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } - fun functionData(global: FunctionData.Global) = - apply { - body.functionData(global) - } + fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } /** Name of the prompt */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Unique identifier for the prompt */ - fun slug(slug: String) = - apply { - body.slug(slug) - } + fun slug(slug: String) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - body.slug(slug) - } + fun slug(slug: JsonField) = apply { body.slug(slug) } /** Textual description of the prompt */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: FunctionSchema?) = - apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: FunctionSchema?) = apply { + body.functionSchema(functionSchema) + } /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) + fun functionSchema(functionSchema: Optional) = + functionSchema(functionSchema.getOrNull()) /** JSON schema for the function's parameters and return type */ - fun functionSchema(functionSchema: JsonField) = - apply { - body.functionSchema(functionSchema) - } + fun functionSchema(functionSchema: JsonField) = apply { + body.functionSchema(functionSchema) + } - fun functionType(functionType: FunctionType?) = - apply { - body.functionType(functionType) - } + fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = apply { + body.functionType(functionType) + } - fun origin(origin: Origin?) = - apply { - body.origin(origin) - } + fun origin(origin: Origin?) = apply { body.origin(origin) } fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = - apply { - body.origin(origin) - } + fun origin(origin: JsonField) = apply { body.origin(origin) } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List?) = - apply { - body.tags(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - body.tags(tags) - } + fun tags(tags: JsonField>) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - body.addTag(tag) - } + fun addTag(tag: String) = apply { body.addTag(tag) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionReplaceParams = FunctionReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData private constructor( + class FunctionData + private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val _json: JsonValue? = null, - ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -839,44 +721,45 @@ class FunctionReplaceParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = - apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ @@ -892,19 +775,16 @@ class FunctionReplaceParams private constructor( companion object { - @JvmStatic - fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic - fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic - fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) } /** - * An interface that defines how to map each variant of [FunctionData] to a value - * of type [T]. + * An interface that defines how to map each variant of [FunctionData] to a value of type + * [T]. */ interface Visitor { @@ -917,62 +797,71 @@ class FunctionReplaceParams private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(global = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Prompt + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -980,16 +869,15 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Prompt = - apply { - if (validated) { - return@apply - } - - type() - validated = true + fun validate(): Prompt = apply { + if (validated) { + return@apply } + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -998,13 +886,11 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: - * * ```java * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -1014,57 +900,43 @@ class FunctionReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = - apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt( - checkRequired( - "type", type - ), additionalProperties.toImmutable() - ) + Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1074,8 +946,7 @@ class FunctionReplaceParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1086,23 +957,23 @@ class FunctionReplaceParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT, + PROMPT } /** * 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 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 { PROMPT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1126,7 +997,7 @@ class FunctionReplaceParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1141,16 +1012,19 @@ class FunctionReplaceParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1159,11 +1033,11 @@ class FunctionReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1172,28 +1046,31 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code @JsonCreator private constructor( - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Code + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") - @ExcludeMissing - fun _data(): JsonField = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1201,17 +1078,16 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Code = - apply { - if (validated) { - return@apply - } - - data().validate() - type() - validated = true + fun validate(): Code = apply { + if (validated) { + return@apply } + data().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1220,14 +1096,12 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: - * * ```java * .data() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Code]. */ @@ -1238,19 +1112,15 @@ class FunctionReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = - apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = - apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -1258,56 +1128,45 @@ class FunctionReplaceParams private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired( - "data", data - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("data", data), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data private constructor( + class Data + private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, - ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1325,39 +1184,40 @@ class FunctionReplaceParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = - apply { - if (validated) { - return@apply - } + fun validate(): Data = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() + inline.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1372,11 +1232,9 @@ class FunctionReplaceParams private constructor( companion object { - @JvmStatic - fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic - fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1392,65 +1250,86 @@ class FunctionReplaceParams private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize( + value: Data, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle @JsonCreator private constructor( - @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Bundle + @JsonCreator + private constructor( + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = + JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = + runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = + Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1471,9 +1350,7 @@ class FunctionReplaceParams private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1489,20 +1366,19 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Bundle = - apply { - if (validated) { - return@apply - } - - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true + fun validate(): Bundle = apply { + if (validated) { + return@apply } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1511,7 +1387,6 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: - * * ```java * .bundleId() * .location() @@ -1519,8 +1394,7 @@ class FunctionReplaceParams private constructor( * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1531,38 +1405,40 @@ class FunctionReplaceParams private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = - apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = - apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = + location(JsonField.of(location)) - fun location(location: JsonField) = - apply { - this.location = location - } + fun location(location: JsonField) = apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = + location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = + location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1576,17 +1452,11 @@ class FunctionReplaceParams private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = - apply { - this.preview = preview - } + fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1594,57 +1464,44 @@ class FunctionReplaceParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired( - "bundleId", bundleId - ), - checkRequired( - "location", location - ), - checkRequired( - "runtimeContext", runtimeContext - ), - preview, - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), + preview, + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -1658,23 +1515,25 @@ class FunctionReplaceParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE, + BUNDLE } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { BUNDLE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1682,8 +1541,8 @@ class FunctionReplaceParams private constructor( * 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. + * 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) { @@ -1694,11 +1553,11 @@ class FunctionReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1709,20 +1568,23 @@ class FunctionReplaceParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1731,11 +1593,11 @@ class FunctionReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1744,35 +1606,41 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline @JsonCreator private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Inline + @JsonCreator + private constructor( + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = + runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") - @ExcludeMissing - fun _code(): JsonField = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1780,18 +1648,17 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Inline = - apply { - if (validated) { - return@apply - } - - code() - runtimeContext().validate() - type() - validated = true + fun validate(): Inline = apply { + if (validated) { + return@apply } + code() + runtimeContext().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1800,15 +1667,13 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: - * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1817,37 +1682,31 @@ class FunctionReplaceParams private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = - apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = - apply { - this.code = code - } + fun code(code: JsonField) = apply { this.code = code } - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = - apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1855,47 +1714,44 @@ class FunctionReplaceParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired( - "code", code - ), - checkRequired( - "runtimeContext", runtimeContext - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("code", code), + checkRequired("runtimeContext", runtimeContext), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext @JsonCreator private constructor( - @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RuntimeContext + @JsonCreator + private constructor( + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1916,33 +1772,31 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = - apply { - if (validated) { - return@apply - } - - runtime() - version() - validated = true + fun validate(): RuntimeContext = apply { + if (validated) { + return@apply } + runtime() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [RuntimeContext]. + * Returns a mutable builder for constructing an instance of + * [RuntimeContext]. * * The following fields are required: - * * ```java * .runtime() * .version() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1950,29 +1804,28 @@ class FunctionReplaceParams private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = - apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = + runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = - apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1980,50 +1833,41 @@ class FunctionReplaceParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired( - "runtime", runtime - ), - checkRequired( - "version", version - ), - additionalProperties.toImmutable(), + checkRequired("runtime", runtime), + checkRequired("version", version), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Runtime + @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. + * 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 @@ -2044,29 +1888,33 @@ class FunctionReplaceParams private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Runtime] 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. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] + * member. * + * An instance of [Runtime] 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 { NODE, PYTHON, - /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Runtime] 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. + * 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. + * 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) { @@ -2078,36 +1926,42 @@ class FunctionReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value + * is a not a known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + else -> + throw BraintrustInvalidDataException( + "Unknown Runtime: $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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2116,11 +1970,11 @@ class FunctionReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2129,21 +1983,21 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -2157,23 +2011,25 @@ class FunctionReplaceParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE, + INLINE } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { INLINE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -2181,8 +2037,8 @@ class FunctionReplaceParams private constructor( * 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. + * 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) { @@ -2193,11 +2049,11 @@ class FunctionReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -2208,20 +2064,23 @@ class FunctionReplaceParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2230,11 +2089,11 @@ class FunctionReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2243,14 +2102,13 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2260,8 +2118,7 @@ class FunctionReplaceParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2272,23 +2129,23 @@ class FunctionReplaceParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE, + CODE } /** * 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 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 { CODE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2312,7 +2169,7 @@ class FunctionReplaceParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2327,16 +2184,19 @@ class FunctionReplaceParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2345,11 +2205,11 @@ class FunctionReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2358,28 +2218,31 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Global + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2387,17 +2250,16 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Global = - apply { - if (validated) { - return@apply - } - - name() - type() - validated = true + fun validate(): Global = apply { + if (validated) { + return@apply } + name() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2406,14 +2268,12 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: - * * ```java * .name() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Global]. */ @@ -2424,69 +2284,52 @@ class FunctionReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = - apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired( - "name", name - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2496,8 +2339,7 @@ class FunctionReplaceParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2508,23 +2350,23 @@ class FunctionReplaceParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** * 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 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 { GLOBAL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2548,7 +2390,7 @@ class FunctionReplaceParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2563,16 +2405,19 @@ class FunctionReplaceParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2581,11 +2426,11 @@ class FunctionReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2594,26 +2439,27 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } /** JSON schema for the function's parameters and return type */ @NoAutoDetect - class FunctionSchema @JsonCreator private constructor( - @JsonProperty("parameters") @ExcludeMissing private val parameters: JsonValue = JsonMissing.of(), + class FunctionSchema + @JsonCreator + private constructor( + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonValue = JsonMissing.of(), @JsonProperty("returns") @ExcludeMissing private val returns: JsonValue = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonValue = parameters + @JsonProperty("parameters") @ExcludeMissing fun _parameters(): JsonValue = parameters - @JsonProperty("returns") - @ExcludeMissing - fun _returns(): JsonValue = returns + @JsonProperty("returns") @ExcludeMissing fun _returns(): JsonValue = returns @JsonAnyGetter @ExcludeMissing @@ -2621,22 +2467,20 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): FunctionSchema = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): FunctionSchema = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [FunctionSchema]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionSchema]. */ @@ -2647,63 +2491,45 @@ class FunctionReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(functionSchema: FunctionSchema) = - apply { - parameters = functionSchema.parameters - returns = functionSchema.returns - additionalProperties = functionSchema.additionalProperties.toMutableMap() - } + internal fun from(functionSchema: FunctionSchema) = apply { + parameters = functionSchema.parameters + returns = functionSchema.returns + additionalProperties = functionSchema.additionalProperties.toMutableMap() + } - fun parameters(parameters: JsonValue) = - apply { - this.parameters = parameters - } + fun parameters(parameters: JsonValue) = apply { this.parameters = parameters } - fun returns(returns: JsonValue) = - apply { - this.returns = returns - } + fun returns(returns: JsonValue) = apply { this.returns = returns } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionSchema = - FunctionSchema( - parameters, - returns, - additionalProperties.toImmutable(), - ) + FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionSchema && parameters == other.parameters && returns == other.returns && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2712,24 +2538,22 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionSchema{parameters=$parameters, returns=$returns, additionalProperties=$additionalProperties}" } - class FunctionType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2753,15 +2577,12 @@ class FunctionReplaceParams private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [FunctionType] 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 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 { @@ -2770,18 +2591,17 @@ class FunctionReplaceParams private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown - * value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -2795,11 +2615,11 @@ class FunctionReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -2813,20 +2633,23 @@ class FunctionReplaceParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2835,12 +2658,20 @@ class FunctionReplaceParams private constructor( } @NoAutoDetect - class Origin @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("internal") @ExcludeMissing private val internal_: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Origin + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("internal") + @ExcludeMissing + private val internal_: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Id of the object the function is originating from */ @@ -2850,15 +2681,13 @@ class FunctionReplaceParams private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) /** Id of the object the function is originating from */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -2866,12 +2695,10 @@ class FunctionReplaceParams private constructor( fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ - @JsonProperty("internal") - @ExcludeMissing - fun _internal_(): JsonField = internal_ + @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @JsonAnyGetter @ExcludeMissing @@ -2879,18 +2706,17 @@ class FunctionReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Origin = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - internal_() - validated = true + fun validate(): Origin = apply { + if (validated) { + return@apply } + objectId() + objectType() + internal_() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2899,14 +2725,12 @@ class FunctionReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Origin]. */ @@ -2918,114 +2742,92 @@ class FunctionReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = - apply { - objectId = origin.objectId - objectType = origin.objectType - internal_ = origin.internal_ - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = apply { + objectId = origin.objectId + objectType = origin.objectType + internal_ = origin.internal_ + additionalProperties = origin.additionalProperties.toMutableMap() + } /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** Id of the object the function is originating from */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the - * list of functions. + * The function exists for internal purposes and should not be displayed in the list of + * functions. */ - fun internal_(internal_: JsonField) = - apply { - this.internal_ = internal_ - } + fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - internal_, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + internal_, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -3073,11 +2875,9 @@ class FunctionReplaceParams private constructor( * 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 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 { @@ -3103,8 +2903,8 @@ class FunctionReplaceParams private constructor( * 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. + * 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) { @@ -3129,7 +2929,7 @@ class FunctionReplaceParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3153,17 +2953,20 @@ class FunctionReplaceParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3172,11 +2975,11 @@ class FunctionReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && objectId == other.objectId && objectType == other.objectType && internal_ == other.internal_ && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3185,18 +2988,20 @@ class FunctionReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{objectId=$objectId, objectType=$objectType, internal_=$internal_, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "FunctionReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "FunctionReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index f0fc93e6..a1ec37a0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a function object by its id */ -class FunctionRetrieveParams private constructor( +class FunctionRetrieveParams +private constructor( private val functionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Function id */ @@ -29,10 +29,10 @@ class FunctionRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class FunctionRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionRetrieveParams]. + * Returns a mutable builder for constructing an instance of [FunctionRetrieveParams]. * * The following fields are required: - * * ```java * .functionId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionRetrieveParams]. */ @@ -62,162 +59,131 @@ class FunctionRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionRetrieveParams: FunctionRetrieveParams) = - apply { - functionId = functionRetrieveParams.functionId - additionalHeaders = functionRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = functionRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(functionRetrieveParams: FunctionRetrieveParams) = apply { + functionId = functionRetrieveParams.functionId + additionalHeaders = functionRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = functionRetrieveParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = - apply { - this.functionId = functionId - } + fun functionId(functionId: String) = apply { this.functionId = functionId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionRetrieveParams = FunctionRetrieveParams( - checkRequired( - "functionId", functionId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("functionId", functionId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionRetrieveParams && functionId == other.functionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "FunctionRetrieveParams{functionId=$functionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index ead95502..1f55b477 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -36,16 +36,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a function object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. */ -class FunctionUpdateParams private constructor( +class FunctionUpdateParams +private constructor( private val functionId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Function id */ @@ -85,41 +85,55 @@ class FunctionUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_data") @ExcludeMissing private val functionData: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_data") + @ExcludeMissing + private val functionData: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) - fun functionData(): Optional = Optional.ofNullable(functionData.getNullable("function_data")) + fun functionData(): Optional = + Optional.ofNullable(functionData.getNullable("function_data")) /** Name of the prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -134,9 +148,7 @@ class FunctionUpdateParams private constructor( fun _functionData(): JsonField = functionData /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -144,9 +156,7 @@ class FunctionUpdateParams private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -154,27 +164,25 @@ class FunctionUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - description() - functionData().ifPresent { it.validate() } - name() - promptData().ifPresent { it.validate() } - tags() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + description() + functionData().ifPresent { it.validate() } + name() + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -188,15 +196,14 @@ class FunctionUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - description = body.description - functionData = body.functionData - name = body.name - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + description = body.description + functionData = body.functionData + name = body.name + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -205,25 +212,26 @@ class FunctionUpdateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - fun functionData(functionData: JsonField) = - apply { - this.functionData = functionData - } + fun functionData(functionData: JsonField) = apply { + this.functionData = functionData + } - fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) + fun functionData(prompt: FunctionData.Prompt) = + functionData(FunctionData.ofPrompt(prompt)) fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) - fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) + fun functionData(global: FunctionData.Global) = + functionData(FunctionData.ofGlobal(global)) - fun functionData(nullableVariant: FunctionData.NullableVariant) = functionData(FunctionData.ofNullableVariant(nullableVariant)) + fun functionData(nullableVariant: FunctionData.NullableVariant) = + functionData(FunctionData.ofNullableVariant(nullableVariant)) /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -232,10 +240,7 @@ class FunctionUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -244,10 +249,9 @@ class FunctionUpdateParams private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -256,62 +260,52 @@ class FunctionUpdateParams private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - description, - functionData, - name, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + description, + functionData, + name, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && functionData == other.functionData && name == other.name && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -320,7 +314,8 @@ class FunctionUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -328,17 +323,14 @@ class FunctionUpdateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [FunctionUpdateParams]. + * Returns a mutable builder for constructing an instance of [FunctionUpdateParams]. * * The following fields are required: - * * ```java * .functionId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionUpdateParams]. */ @@ -351,287 +343,206 @@ class FunctionUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(functionUpdateParams: FunctionUpdateParams) = - apply { - functionId = functionUpdateParams.functionId - body = functionUpdateParams.body.toBuilder() - additionalHeaders = functionUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = functionUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(functionUpdateParams: FunctionUpdateParams) = apply { + functionId = functionUpdateParams.functionId + body = functionUpdateParams.body.toBuilder() + additionalHeaders = functionUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = functionUpdateParams.additionalQueryParams.toBuilder() + } /** Function id */ - fun functionId(functionId: String) = - apply { - this.functionId = functionId - } + fun functionId(functionId: String) = apply { this.functionId = functionId } /** Textual description of the prompt */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } - fun functionData(functionData: FunctionData) = - apply { - body.functionData(functionData) - } + fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } - fun functionData(functionData: JsonField) = - apply { - body.functionData(functionData) - } + fun functionData(functionData: JsonField) = apply { + body.functionData(functionData) + } - fun functionData(prompt: FunctionData.Prompt) = - apply { - body.functionData(prompt) - } + fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } - fun functionData(code: FunctionData.Code) = - apply { - body.functionData(code) - } + fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } - fun functionData(global: FunctionData.Global) = - apply { - body.functionData(global) - } + fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } - fun functionData(nullableVariant: FunctionData.NullableVariant) = - apply { - body.functionData(nullableVariant) - } + fun functionData(nullableVariant: FunctionData.NullableVariant) = apply { + body.functionData(nullableVariant) + } /** Name of the prompt */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the prompt */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List?) = - apply { - body.tags(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - body.tags(tags) - } + fun tags(tags: JsonField>) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - body.addTag(tag) - } + fun addTag(tag: String) = apply { body.addTag(tag) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): FunctionUpdateParams = FunctionUpdateParams( - checkRequired( - "functionId", functionId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("functionId", functionId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData private constructor( + class FunctionData + private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, - ) { fun prompt(): Optional = Optional.ofNullable(prompt) @@ -661,49 +572,50 @@ class FunctionUpdateParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - prompt != null -> visitor.visitPrompt(prompt) - code != null -> visitor.visitCode(code) - global != null -> visitor.visitGlobal(global) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + prompt != null -> visitor.visitPrompt(prompt) + code != null -> visitor.visitCode(code) + global != null -> visitor.visitGlobal(global) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionData = - apply { - if (validated) { - return@apply - } + fun validate(): FunctionData = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitPrompt(prompt: Prompt) { - prompt.validate() + prompt.validate() } override fun visitCode(code: Code) { - code.validate() + code.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global, nullableVariant) /* spotless:on */ @@ -720,22 +632,20 @@ class FunctionUpdateParams private constructor( companion object { - @JvmStatic - fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) + @JvmStatic fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - @JvmStatic - fun ofCode(code: Code) = FunctionData(code = code) + @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) - @JvmStatic - fun ofGlobal(global: Global) = FunctionData(global = global) + @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = FunctionData(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = + FunctionData(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [FunctionData] to a value - * of type [T]. + * An interface that defines how to map each variant of [FunctionData] to a value of type + * [T]. */ interface Visitor { @@ -750,66 +660,76 @@ class FunctionUpdateParams private constructor( /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * - * An instance of [FunctionData] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [FunctionData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } internal class Deserializer : BaseDeserializer(FunctionData::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionData { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(prompt = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(code = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(global = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionData(nullableVariant = it, _json = json) - } - - return FunctionData(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(prompt = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(code = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(global = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionData(nullableVariant = it, _json = json) + } + + return FunctionData(_json = json) } } internal class Serializer : BaseSerializer(FunctionData::class) { - override fun serialize(value: FunctionData, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.prompt != null -> generator.writeObject(value.prompt) - value.code != null -> generator.writeObject(value.code) - value.global != null -> generator.writeObject(value.global) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionData") - } + override fun serialize( + value: FunctionData, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.prompt != null -> generator.writeObject(value.prompt) + value.code != null -> generator.writeObject(value.code) + value.global != null -> generator.writeObject(value.global) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionData") + } } } @NoAutoDetect - class Prompt @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Prompt + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -817,16 +737,15 @@ class FunctionUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Prompt = - apply { - if (validated) { - return@apply - } - - type() - validated = true + fun validate(): Prompt = apply { + if (validated) { + return@apply } + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -835,13 +754,11 @@ class FunctionUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: - * * ```java * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -851,57 +768,43 @@ class FunctionUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = - apply { - type = prompt.type - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = apply { + type = prompt.type + additionalProperties = prompt.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = - Prompt( - checkRequired( - "type", type - ), additionalProperties.toImmutable() - ) + Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -911,8 +814,7 @@ class FunctionUpdateParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -923,23 +825,23 @@ class FunctionUpdateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - PROMPT, + PROMPT } /** * 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 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 { PROMPT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -963,7 +865,7 @@ class FunctionUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -978,16 +880,19 @@ class FunctionUpdateParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -996,11 +901,11 @@ class FunctionUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1009,28 +914,31 @@ class FunctionUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Code @JsonCreator private constructor( - @JsonProperty("data") @ExcludeMissing private val data: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Code + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun data(): Data = data.getRequired("data") fun type(): Type = type.getRequired("type") - @JsonProperty("data") - @ExcludeMissing - fun _data(): JsonField = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1038,17 +946,16 @@ class FunctionUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Code = - apply { - if (validated) { - return@apply - } - - data().validate() - type() - validated = true + fun validate(): Code = apply { + if (validated) { + return@apply } + data().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1057,14 +964,12 @@ class FunctionUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [Code]. * * The following fields are required: - * * ```java * .data() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Code]. */ @@ -1075,19 +980,15 @@ class FunctionUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(code: Code) = - apply { - data = code.data - type = code.type - additionalProperties = code.additionalProperties.toMutableMap() - } + internal fun from(code: Code) = apply { + data = code.data + type = code.type + additionalProperties = code.additionalProperties.toMutableMap() + } fun data(data: Data) = data(JsonField.of(data)) - fun data(data: JsonField) = - apply { - this.data = data - } + fun data(data: JsonField) = apply { this.data = data } fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) @@ -1095,56 +996,45 @@ class FunctionUpdateParams private constructor( fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Code = Code( - checkRequired( - "data", data - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("data", data), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data private constructor( + class Data + private constructor( private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, - ) { fun bundle(): Optional = Optional.ofNullable(bundle) @@ -1162,39 +1052,40 @@ class FunctionUpdateParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - bundle != null -> visitor.visitBundle(bundle) - inline != null -> visitor.visitInline(inline) - else -> visitor.unknown(_json) - } + return when { + bundle != null -> visitor.visitBundle(bundle) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Data = - apply { - if (validated) { - return@apply - } + fun validate(): Data = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitBundle(bundle: Bundle) { - bundle.validate() + bundle.validate() } override fun visitInline(inline: Inline) { - inline.validate() - } - }) - validated = true - } + inline.validate() + } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ + return /* spotless:off */ other is Data && bundle == other.bundle && inline == other.inline /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(bundle, inline) /* spotless:on */ @@ -1209,11 +1100,9 @@ class FunctionUpdateParams private constructor( companion object { - @JvmStatic - fun ofBundle(bundle: Bundle) = Data(bundle = bundle) + @JvmStatic fun ofBundle(bundle: Bundle) = Data(bundle = bundle) - @JvmStatic - fun ofInline(inline: Inline) = Data(inline = inline) + @JvmStatic fun ofInline(inline: Inline) = Data(inline = inline) } /** @@ -1229,65 +1118,86 @@ class FunctionUpdateParams private constructor( /** * Maps an unknown variant of [Data] to a value of type [T]. * - * An instance of [Data] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Data] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } internal class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(bundle = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Data(inline = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(bundle = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(inline = it, _json = json) + } - return Data(_json = json) + return Data(_json = json) } } internal class Serializer : BaseSerializer(Data::class) { - override fun serialize(value: Data, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.bundle != null -> generator.writeObject(value.bundle) - value.inline != null -> generator.writeObject(value.inline) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Data") - } + override fun serialize( + value: Data, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.bundle != null -> generator.writeObject(value.bundle) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } } } @NoAutoDetect - class Bundle @JsonCreator private constructor( - @JsonProperty("bundle_id") @ExcludeMissing private val bundleId: JsonField = JsonMissing.of(), - @JsonProperty("location") @ExcludeMissing private val location: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("preview") @ExcludeMissing private val preview: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Bundle + @JsonCreator + private constructor( + @JsonProperty("bundle_id") + @ExcludeMissing + private val bundleId: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = + JsonMissing.of(), + @JsonProperty("preview") + @ExcludeMissing + private val preview: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun bundleId(): String = bundleId.getRequired("bundle_id") fun location(): CodeBundle.Location = location.getRequired("location") - fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") + fun runtimeContext(): CodeBundle.RuntimeContext = + runtimeContext.getRequired("runtime_context") /** A preview of the code */ - fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + fun preview(): Optional = + Optional.ofNullable(preview.getNullable("preview")) fun type(): Type = type.getRequired("type") @@ -1308,9 +1218,7 @@ class FunctionUpdateParams private constructor( @ExcludeMissing fun _preview(): JsonField = preview - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1326,20 +1234,19 @@ class FunctionUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Bundle = - apply { - if (validated) { - return@apply - } - - bundleId() - location().validate() - runtimeContext().validate() - preview() - type() - validated = true + fun validate(): Bundle = apply { + if (validated) { + return@apply } + bundleId() + location().validate() + runtimeContext().validate() + preview() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1348,7 +1255,6 @@ class FunctionUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [Bundle]. * * The following fields are required: - * * ```java * .bundleId() * .location() @@ -1356,8 +1262,7 @@ class FunctionUpdateParams private constructor( * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Bundle]. */ @@ -1368,38 +1273,40 @@ class FunctionUpdateParams private constructor( private var runtimeContext: JsonField? = null private var preview: JsonField = JsonMissing.of() private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(bundle: Bundle) = - apply { - bundleId = bundle.bundleId - location = bundle.location - runtimeContext = bundle.runtimeContext - preview = bundle.preview - type = bundle.type - additionalProperties = bundle.additionalProperties.toMutableMap() - } + internal fun from(bundle: Bundle) = apply { + bundleId = bundle.bundleId + location = bundle.location + runtimeContext = bundle.runtimeContext + preview = bundle.preview + type = bundle.type + additionalProperties = bundle.additionalProperties.toMutableMap() + } fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - fun bundleId(bundleId: JsonField) = - apply { - this.bundleId = bundleId - } + fun bundleId(bundleId: JsonField) = apply { + this.bundleId = bundleId + } - fun location(location: CodeBundle.Location) = location(JsonField.of(location)) + fun location(location: CodeBundle.Location) = + location(JsonField.of(location)) - fun location(location: JsonField) = - apply { - this.location = location - } + fun location(location: JsonField) = apply { + this.location = location + } - fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) + fun location(experiment: CodeBundle.Location.Experiment) = + location(CodeBundle.Location.ofExperiment(experiment)) - fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) + fun location(function: CodeBundle.Location.Function) = + location(CodeBundle.Location.ofFunction(function)) - fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) fun runtimeContext(runtimeContext: JsonField) = apply { @@ -1413,17 +1320,11 @@ class FunctionUpdateParams private constructor( fun preview(preview: Optional) = preview(preview.getOrNull()) /** A preview of the code */ - fun preview(preview: JsonField) = - apply { - this.preview = preview - } + fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1431,57 +1332,44 @@ class FunctionUpdateParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Bundle = Bundle( - checkRequired( - "bundleId", bundleId - ), - checkRequired( - "location", location - ), - checkRequired( - "runtimeContext", runtimeContext - ), - preview, - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("bundleId", bundleId), + checkRequired("location", location), + checkRequired("runtimeContext", runtimeContext), + preview, + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -1495,23 +1383,25 @@ class FunctionUpdateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - BUNDLE, + BUNDLE } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { BUNDLE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1519,8 +1409,8 @@ class FunctionUpdateParams private constructor( * 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. + * 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) { @@ -1531,11 +1421,11 @@ class FunctionUpdateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1546,20 +1436,23 @@ class FunctionUpdateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1568,11 +1461,11 @@ class FunctionUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bundle && bundleId == other.bundleId && location == other.location && runtimeContext == other.runtimeContext && preview == other.preview && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1581,35 +1474,41 @@ class FunctionUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Bundle{bundleId=$bundleId, location=$location, runtimeContext=$runtimeContext, preview=$preview, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Inline @JsonCreator private constructor( - @JsonProperty("code") @ExcludeMissing private val code: JsonField = JsonMissing.of(), - @JsonProperty("runtime_context") @ExcludeMissing private val runtimeContext: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Inline + @JsonCreator + private constructor( + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("runtime_context") + @ExcludeMissing + private val runtimeContext: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun code(): String = code.getRequired("code") - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = + runtimeContext.getRequired("runtime_context") fun type(): Type = type.getRequired("type") - @JsonProperty("code") - @ExcludeMissing - fun _code(): JsonField = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1617,18 +1516,17 @@ class FunctionUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Inline = - apply { - if (validated) { - return@apply - } - - code() - runtimeContext().validate() - type() - validated = true + fun validate(): Inline = apply { + if (validated) { + return@apply } + code() + runtimeContext().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1637,15 +1535,13 @@ class FunctionUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [Inline]. * * The following fields are required: - * * ```java * .code() * .runtimeContext() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Inline]. */ @@ -1654,37 +1550,31 @@ class FunctionUpdateParams private constructor( private var code: JsonField? = null private var runtimeContext: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(inline: Inline) = - apply { - code = inline.code - runtimeContext = inline.runtimeContext - type = inline.type - additionalProperties = inline.additionalProperties.toMutableMap() - } + internal fun from(inline: Inline) = apply { + code = inline.code + runtimeContext = inline.runtimeContext + type = inline.type + additionalProperties = inline.additionalProperties.toMutableMap() + } fun code(code: String) = code(JsonField.of(code)) - fun code(code: JsonField) = - apply { - this.code = code - } + fun code(code: JsonField) = apply { this.code = code } - fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = + runtimeContext(JsonField.of(runtimeContext)) - fun runtimeContext(runtimeContext: JsonField) = - apply { - this.runtimeContext = runtimeContext - } + fun runtimeContext(runtimeContext: JsonField) = apply { + this.runtimeContext = runtimeContext + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1692,47 +1582,44 @@ class FunctionUpdateParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Inline = Inline( - checkRequired( - "code", code - ), - checkRequired( - "runtimeContext", runtimeContext - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("code", code), + checkRequired("runtimeContext", runtimeContext), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class RuntimeContext @JsonCreator private constructor( - @JsonProperty("runtime") @ExcludeMissing private val runtime: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RuntimeContext + @JsonCreator + private constructor( + @JsonProperty("runtime") + @ExcludeMissing + private val runtime: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { fun runtime(): Runtime = runtime.getRequired("runtime") @@ -1753,33 +1640,31 @@ class FunctionUpdateParams private constructor( private var validated: Boolean = false - fun validate(): RuntimeContext = - apply { - if (validated) { - return@apply - } - - runtime() - version() - validated = true + fun validate(): RuntimeContext = apply { + if (validated) { + return@apply } + runtime() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [RuntimeContext]. + * Returns a mutable builder for constructing an instance of + * [RuntimeContext]. * * The following fields are required: - * * ```java * .runtime() * .version() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RuntimeContext]. */ @@ -1787,29 +1672,28 @@ class FunctionUpdateParams private constructor( private var runtime: JsonField? = null private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(runtimeContext: RuntimeContext) = - apply { - runtime = runtimeContext.runtime - version = runtimeContext.version - additionalProperties = runtimeContext.additionalProperties.toMutableMap() - } + internal fun from(runtimeContext: RuntimeContext) = apply { + runtime = runtimeContext.runtime + version = runtimeContext.version + additionalProperties = + runtimeContext.additionalProperties.toMutableMap() + } fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - fun runtime(runtime: JsonField) = - apply { - this.runtime = runtime - } + fun runtime(runtime: JsonField) = apply { + this.runtime = runtime + } fun version(version: String) = version(JsonField.of(version)) - fun version(version: JsonField) = - apply { - this.version = version - } + fun version(version: JsonField) = apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { @@ -1817,50 +1701,41 @@ class FunctionUpdateParams private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RuntimeContext = RuntimeContext( - checkRequired( - "runtime", runtime - ), - checkRequired( - "version", version - ), - additionalProperties.toImmutable(), + checkRequired("runtime", runtime), + checkRequired("version", version), + additionalProperties.toImmutable(), ) } - class Runtime @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Runtime + @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. + * 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 @@ -1881,29 +1756,33 @@ class FunctionUpdateParams private constructor( } /** - * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Runtime] 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. + * An enum containing [Runtime]'s known values, as well as an [_UNKNOWN] + * member. * + * An instance of [Runtime] 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 { NODE, PYTHON, - /** An enum member indicating that [Runtime] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Runtime] 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. + * 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. + * 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) { @@ -1915,36 +1794,42 @@ class FunctionUpdateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value + * is a not a known member. */ fun known(): Known = when (this) { NODE -> Known.NODE PYTHON -> Known.PYTHON - else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + else -> + throw BraintrustInvalidDataException( + "Unknown Runtime: $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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ + return /* spotless:off */ other is Runtime && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1953,11 +1838,11 @@ class FunctionUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RuntimeContext && runtime == other.runtime && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1966,21 +1851,21 @@ class FunctionUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -1994,23 +1879,25 @@ class FunctionUpdateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - INLINE, + INLINE } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { INLINE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -2018,8 +1905,8 @@ class FunctionUpdateParams private constructor( * 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. + * 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) { @@ -2030,11 +1917,11 @@ class FunctionUpdateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -2045,20 +1932,23 @@ class FunctionUpdateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2067,11 +1957,11 @@ class FunctionUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Inline && code == other.code && runtimeContext == other.runtimeContext && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2080,14 +1970,13 @@ class FunctionUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Inline{code=$code, runtimeContext=$runtimeContext, type=$type, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2097,8 +1986,7 @@ class FunctionUpdateParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2109,23 +1997,23 @@ class FunctionUpdateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CODE, + CODE } /** * 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 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 { CODE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2149,7 +2037,7 @@ class FunctionUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2164,16 +2052,19 @@ class FunctionUpdateParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2182,11 +2073,11 @@ class FunctionUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Code && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2195,28 +2086,31 @@ class FunctionUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Code{data=$data, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Global + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2224,17 +2118,16 @@ class FunctionUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Global = - apply { - if (validated) { - return@apply - } - - name() - type() - validated = true + fun validate(): Global = apply { + if (validated) { + return@apply } + name() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2243,14 +2136,12 @@ class FunctionUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: - * * ```java * .name() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Global]. */ @@ -2261,69 +2152,52 @@ class FunctionUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = - apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired( - "name", name - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -2333,8 +2207,7 @@ class FunctionUpdateParams private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -2345,23 +2218,23 @@ class FunctionUpdateParams private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** * 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 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 { GLOBAL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -2385,7 +2258,7 @@ class FunctionUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -2400,16 +2273,19 @@ class FunctionUpdateParams private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2418,11 +2294,11 @@ class FunctionUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2431,13 +2307,16 @@ class FunctionUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class NullableVariant + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -2446,22 +2325,20 @@ class FunctionUpdateParams private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): NullableVariant = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -2470,46 +2347,41 @@ class FunctionUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = - apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2523,14 +2395,15 @@ class FunctionUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is FunctionUpdateParams && functionId == other.functionId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(functionId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "FunctionUpdateParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "FunctionUpdateParams{functionId=$functionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index c7fbe0c4..2dc72265 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -23,22 +23,34 @@ import kotlin.jvm.optionals.getOrNull /** * A group is a collection of users which can be assigned an ACL * - * Groups can consist of individual users, as well as a set of groups they inherit - * from + * Groups can consist of individual users, as well as a set of groups they inherit from */ @NoAutoDetect -class Group @JsonCreator private constructor( +class Group +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") + @ExcludeMissing + private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") + @ExcludeMissing + private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the group */ @@ -58,48 +70,44 @@ class Group @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the group */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users */ - fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = + Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = + Optional.ofNullable(memberUsers.getNullable("member_users")) /** Identifies the user who created the group */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the group */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the group */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Unique id for the organization that the group belongs under * * It is forbidden to change the org after creating a group */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Date of group creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of group deletion, or null if the group is still active */ @JsonProperty("deleted_at") @@ -107,15 +115,13 @@ class Group @JsonCreator private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the group */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -127,9 +133,7 @@ class Group @JsonCreator private constructor( fun _memberUsers(): JsonField> = memberUsers /** Identifies the user who created the group */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -137,24 +141,23 @@ class Group @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Group = - apply { - if (validated) { - return@apply - } - - id() - name() - orgId() - created() - deletedAt() - description() - memberGroups() - memberUsers() - userId() - validated = true + fun validate(): Group = apply { + if (validated) { + return@apply } + id() + name() + orgId() + created() + deletedAt() + description() + memberGroups() + memberUsers() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -163,15 +166,13 @@ class Group @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Group]. * * The following fields are required: - * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Group]. */ @@ -189,37 +190,30 @@ class Group @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(group: Group) = - apply { - id = group.id - name = group.name - orgId = group.orgId - created = group.created - deletedAt = group.deletedAt - description = group.description - memberGroups = group.memberGroups.map { it.toMutableList() } - memberUsers = group.memberUsers.map { it.toMutableList() } - userId = group.userId - additionalProperties = group.additionalProperties.toMutableMap() - } + internal fun from(group: Group) = apply { + id = group.id + name = group.name + orgId = group.orgId + created = group.created + deletedAt = group.deletedAt + description = group.description + memberGroups = group.memberGroups.map { it.toMutableList() } + memberUsers = group.memberUsers.map { it.toMutableList() } + userId = group.userId + additionalProperties = group.additionalProperties.toMutableMap() + } /** Unique identifier for the group */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the group */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** * Unique id for the organization that the group belongs under @@ -233,10 +227,7 @@ class Group @JsonCreator private constructor( * * It is forbidden to change the org after creating a group */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Date of group creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -245,10 +236,7 @@ class Group @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of group creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date of group deletion, or null if the group is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -257,10 +245,7 @@ class Group @JsonCreator private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of group deletion, or null if the group is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -269,50 +254,48 @@ class Group @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = + memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: JsonField>) = - apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun addMemberGroup(memberGroup: String) = - apply { - memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = apply { + memberGroups = + (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) @@ -321,18 +304,17 @@ class Group @JsonCreator private constructor( fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = - apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = - apply { - memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = apply { + memberUsers = + (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** Identifies the user who created the group */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -341,64 +323,48 @@ class Group @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the group */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Group = Group( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "orgId", orgId - ), - created, - deletedAt, - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("orgId", orgId), + created, + deletedAt, + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Group && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Group && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -407,5 +373,6 @@ class Group @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Group{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "Group{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 18dcc927..492a36c7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -23,14 +23,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new group. If there is an existing group with the same name as the one - * specified in the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one specified in the + * request, will return the existing group unmodified */ -class GroupCreateParams private constructor( +class GroupCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the group */ @@ -42,8 +42,8 @@ class GroupCreateParams private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users */ fun memberGroups(): Optional> = body.memberGroups() @@ -51,9 +51,9 @@ class GroupCreateParams private constructor( fun memberUsers(): Optional> = body.memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. */ fun orgName(): Optional = body.orgName() @@ -66,8 +66,8 @@ class GroupCreateParams private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users */ fun _memberGroups(): JsonField> = body._memberGroups() @@ -75,9 +75,9 @@ class GroupCreateParams private constructor( fun _memberUsers(): JsonField> = body._memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -87,52 +87,64 @@ class GroupCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") + @ExcludeMissing + private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") + @ExcludeMissing + private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the group */ fun name(): String = name.getRequired("name") /** Textual description of the group */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = + Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = + Optional.ofNullable(memberUsers.getNullable("member_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the group */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Textual description of the group */ @JsonProperty("description") @@ -142,8 +154,8 @@ class GroupCreateParams private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -155,13 +167,11 @@ class GroupCreateParams private constructor( fun _memberUsers(): JsonField> = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -169,20 +179,19 @@ class GroupCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - description() - memberGroups() - memberUsers() - orgName() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + description() + memberGroups() + memberUsers() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -191,13 +200,11 @@ class GroupCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -211,24 +218,20 @@ class GroupCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - description = body.description - memberGroups = body.memberGroups.map { it.toMutableList() } - memberUsers = body.memberUsers.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + description = body.description + memberGroups = body.memberGroups.map { it.toMutableList() } + memberUsers = body.memberUsers.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -237,140 +240,129 @@ class GroupCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ - fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = + memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ - fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = - apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ - fun addMemberGroup(memberGroup: String) = - apply { - memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = apply { + memberGroups = + (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) + fun memberUsers(memberUsers: List?) = + memberUsers(JsonField.ofNullable(memberUsers)) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) + fun memberUsers(memberUsers: Optional>) = + memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = - apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = - apply { - memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = apply { + memberUsers = + (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired("name", name), + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -379,7 +371,8 @@ class GroupCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -390,13 +383,11 @@ class GroupCreateParams private constructor( * Returns a mutable builder for constructing an instance of [GroupCreateParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GroupCreateParams]. */ @@ -408,297 +399,232 @@ class GroupCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupCreateParams: GroupCreateParams) = - apply { - body = groupCreateParams.body.toBuilder() - additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(groupCreateParams: GroupCreateParams) = apply { + body = groupCreateParams.body.toBuilder() + additionalHeaders = groupCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupCreateParams.additionalQueryParams.toBuilder() + } /** Name of the group */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the group */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the group */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: List?) = - apply { - body.memberGroups(memberGroups) - } + fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: JsonField>) = - apply { - body.memberGroups(memberGroups) - } + fun memberGroups(memberGroups: JsonField>) = apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun addMemberGroup(memberGroup: String) = - apply { - body.addMemberGroup(memberGroup) - } + fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = - apply { - body.memberUsers(memberUsers) - } + fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = - apply { - body.memberUsers(memberUsers) - } + fun memberUsers(memberUsers: JsonField>) = apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = - apply { - body.addMemberUser(memberUser) - } + fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupCreateParams = GroupCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "GroupCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "GroupCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 4f981e03..52f95360 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a group object by its id */ -class GroupDeleteParams private constructor( +class GroupDeleteParams +private constructor( private val groupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Group id */ @@ -31,17 +31,18 @@ class GroupDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -52,13 +53,11 @@ class GroupDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [GroupDeleteParams]. * * The following fields are required: - * * ```java * .groupId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GroupDeleteParams]. */ @@ -71,190 +70,155 @@ class GroupDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupDeleteParams: GroupDeleteParams) = - apply { - groupId = groupDeleteParams.groupId - additionalHeaders = groupDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = groupDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = groupDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(groupDeleteParams: GroupDeleteParams) = apply { + groupId = groupDeleteParams.groupId + additionalHeaders = groupDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = groupDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = groupDeleteParams.additionalBodyProperties.toMutableMap() + } /** Group id */ - fun groupId(groupId: String) = - apply { - this.groupId = groupId - } + fun groupId(groupId: String) = apply { this.groupId = groupId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): GroupDeleteParams = GroupDeleteParams( - checkRequired( - "groupId", groupId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("groupId", groupId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is GroupDeleteParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "GroupDeleteParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 3b871286..b0123cdf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.GroupService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ -class GroupListPage private constructor( +class GroupListPage +private constructor( private val groupsService: GroupService, private val params: GroupListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,40 @@ class GroupListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListPage && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is GroupListPage && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ - override fun toString() = "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" + override fun toString() = + "GroupListPage{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(GroupListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(GroupListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { groupsService.list(it) } + return getNextPageParams().map { groupsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +78,16 @@ class GroupListPage private constructor( @JvmStatic fun of(groupsService: GroupService, params: GroupListParams, response: Response) = - GroupListPage( - groupsService, - params, - response, - ) + GroupListPage(groupsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +101,34 @@ class GroupListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [GroupListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +137,39 @@ class GroupListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: GroupListPage, + class AutoPager(private val firstPage: GroupListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index 3f84e56e..5a17d75a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.GroupServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ -class GroupListPageAsync private constructor( +class GroupListPageAsync +private constructor( private val groupsService: GroupServiceAsync, private val params: GroupListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,42 @@ class GroupListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListPageAsync && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is GroupListPageAsync && groupsService == other.groupsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupsService, params, response) /* spotless:on */ - override fun toString() = "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" + override fun toString() = + "GroupListPageAsync{groupsService=$groupsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(GroupListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(GroupListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - groupsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { groupsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -81,18 +80,16 @@ class GroupListPageAsync private constructor( @JvmStatic fun of(groupsService: GroupServiceAsync, params: GroupListParams, response: Response) = - GroupListPageAsync( - groupsService, - params, - response, - ) + GroupListPageAsync(groupsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,35 +103,34 @@ class GroupListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [GroupListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -143,63 +139,46 @@ class GroupListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: GroupListPageAsync, - - ) { + class AutoPager(private val firstPage: GroupListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Group) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Group) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index df044bad..d63abcd7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ -class GroupListParams private constructor( +class GroupListParams +private constructor( private val endingBefore: String?, private val groupName: String?, private val ids: Ids?, @@ -35,15 +36,14 @@ class GroupListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) @@ -51,8 +51,8 @@ class GroupListParams private constructor( fun groupName(): Optional = Optional.ofNullable(groupName) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ class GroupListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,51 +78,25 @@ class GroupListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.groupName?.let { - queryParams.put( - "group_name", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.groupName?.let { queryParams.put("group_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): GroupListParams = builder().build() + @JvmStatic fun none(): GroupListParams = builder().build() /** Returns a mutable builder for constructing an instance of [GroupListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GroupListParams]. */ @@ -139,80 +113,67 @@ class GroupListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupListParams: GroupListParams) = - apply { - endingBefore = groupListParams.endingBefore - groupName = groupListParams.groupName - ids = groupListParams.ids - limit = groupListParams.limit - orgName = groupListParams.orgName - startingAfter = groupListParams.startingAfter - additionalHeaders = groupListParams.additionalHeaders.toBuilder() - additionalQueryParams = groupListParams.additionalQueryParams.toBuilder() - } + internal fun from(groupListParams: GroupListParams) = apply { + endingBefore = groupListParams.endingBefore + groupName = groupListParams.groupName + ids = groupListParams.ids + limit = groupListParams.limit + orgName = groupListParams.orgName + startingAfter = groupListParams.startingAfter + additionalHeaders = groupListParams.additionalHeaders.toBuilder() + additionalQueryParams = groupListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the group to search for */ - fun groupName(groupName: String?) = - apply { - this.groupName = groupName - } + fun groupName(groupName: String?) = apply { this.groupName = groupName } /** Name of the group to search for */ fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -221,10 +182,7 @@ class GroupListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -232,172 +190,144 @@ class GroupListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupListParams = GroupListParams( - endingBefore, - groupName, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + groupName, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -415,19 +345,19 @@ class GroupListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -442,17 +372,12 @@ class GroupListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -462,56 +387,60 @@ class GroupListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupListParams && endingBefore == other.endingBefore && groupName == other.groupName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, groupName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 1a856148..add7d123 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -23,15 +23,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace group. If there is an existing group with the same name as the - * one specified in the request, will replace the existing group with the provided - * fields + * Create or replace group. If there is an existing group with the same name as the one specified in + * the request, will replace the existing group with the provided fields */ -class GroupReplaceParams private constructor( +class GroupReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the group */ @@ -43,8 +42,8 @@ class GroupReplaceParams private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users */ fun memberGroups(): Optional> = body.memberGroups() @@ -52,9 +51,9 @@ class GroupReplaceParams private constructor( fun memberUsers(): Optional> = body.memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. */ fun orgName(): Optional = body.orgName() @@ -67,8 +66,8 @@ class GroupReplaceParams private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of their + * inherited users */ fun _memberGroups(): JsonField> = body._memberGroups() @@ -76,9 +75,9 @@ class GroupReplaceParams private constructor( fun _memberUsers(): JsonField> = body._memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * group belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -88,52 +87,64 @@ class GroupReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_groups") @ExcludeMissing private val memberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("member_users") @ExcludeMissing private val memberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_groups") + @ExcludeMissing + private val memberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("member_users") + @ExcludeMissing + private val memberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the group */ fun name(): String = name.getRequired("name") /** Textual description of the group */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) + fun memberGroups(): Optional> = + Optional.ofNullable(memberGroups.getNullable("member_groups")) /** Ids of users which belong to this group */ - fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) + fun memberUsers(): Optional> = + Optional.ofNullable(memberUsers.getNullable("member_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the group */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Textual description of the group */ @JsonProperty("description") @@ -143,8 +154,8 @@ class GroupReplaceParams private constructor( /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ @JsonProperty("member_groups") @ExcludeMissing @@ -156,13 +167,11 @@ class GroupReplaceParams private constructor( fun _memberUsers(): JsonField> = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -170,20 +179,19 @@ class GroupReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - description() - memberGroups() - memberUsers() - orgName() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + description() + memberGroups() + memberUsers() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -192,13 +200,11 @@ class GroupReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -212,24 +218,20 @@ class GroupReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - description = body.description - memberGroups = body.memberGroups.map { it.toMutableList() } - memberUsers = body.memberUsers.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + description = body.description + memberGroups = body.memberGroups.map { it.toMutableList() } + memberUsers = body.memberUsers.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) /** Name of the group */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -238,140 +240,129 @@ class GroupReplaceParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ - fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) + fun memberGroups(memberGroups: List?) = + memberGroups(JsonField.ofNullable(memberGroups)) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ - fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ - fun memberGroups(memberGroups: JsonField>) = - apply { - this.memberGroups = memberGroups.map { it.toMutableList() } - } + fun memberGroups(memberGroups: JsonField>) = apply { + this.memberGroups = memberGroups.map { it.toMutableList() } + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all + * of their inherited users */ - fun addMemberGroup(memberGroup: String) = - apply { - memberGroups = (memberGroups ?: JsonField.of(mutableListOf())).also { + fun addMemberGroup(memberGroup: String) = apply { + memberGroups = + (memberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("memberGroups", it).add(memberGroup) } - } + } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) + fun memberUsers(memberUsers: List?) = + memberUsers(JsonField.ofNullable(memberUsers)) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) + fun memberUsers(memberUsers: Optional>) = + memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = - apply { - this.memberUsers = memberUsers.map { it.toMutableList() } - } + fun memberUsers(memberUsers: JsonField>) = apply { + this.memberUsers = memberUsers.map { it.toMutableList() } + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = - apply { - memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { + fun addMemberUser(memberUser: String) = apply { + memberUsers = + (memberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("memberUsers", it).add(memberUser) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - description, - (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired("name", name), + description, + (memberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (memberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberGroups == other.memberGroups && memberUsers == other.memberUsers && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -380,7 +371,8 @@ class GroupReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -391,13 +383,11 @@ class GroupReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [GroupReplaceParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GroupReplaceParams]. */ @@ -409,297 +399,232 @@ class GroupReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupReplaceParams: GroupReplaceParams) = - apply { - body = groupReplaceParams.body.toBuilder() - additionalHeaders = groupReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = groupReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(groupReplaceParams: GroupReplaceParams) = apply { + body = groupReplaceParams.body.toBuilder() + additionalHeaders = groupReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = groupReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the group */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the group */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the group */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: List?) = - apply { - body.memberGroups(memberGroups) - } + fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) + fun memberGroups(memberGroups: Optional>) = + memberGroups(memberGroups.getOrNull()) /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun memberGroups(memberGroups: JsonField>) = - apply { - body.memberGroups(memberGroups) - } + fun memberGroups(memberGroups: JsonField>) = apply { + body.memberGroups(memberGroups) + } /** * Ids of the groups this group inherits from * - * An inheriting group has all the users contained in its member groups, as well as - * all of their inherited users + * An inheriting group has all the users contained in its member groups, as well as all of + * their inherited users */ - fun addMemberGroup(memberGroup: String) = - apply { - body.addMemberGroup(memberGroup) - } + fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List?) = - apply { - body.memberUsers(memberUsers) - } + fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: JsonField>) = - apply { - body.memberUsers(memberUsers) - } + fun memberUsers(memberUsers: JsonField>) = apply { + body.memberUsers(memberUsers) + } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = - apply { - body.addMemberUser(memberUser) - } + fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the group belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the group belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupReplaceParams = GroupReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "GroupReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "GroupReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index 9430bc01..a3aece35 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a group object by its id */ -class GroupRetrieveParams private constructor( +class GroupRetrieveParams +private constructor( private val groupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Group id */ @@ -29,10 +29,10 @@ class GroupRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,13 +43,11 @@ class GroupRetrieveParams private constructor( * Returns a mutable builder for constructing an instance of [GroupRetrieveParams]. * * The following fields are required: - * * ```java * .groupId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GroupRetrieveParams]. */ @@ -61,162 +59,131 @@ class GroupRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupRetrieveParams: GroupRetrieveParams) = - apply { - groupId = groupRetrieveParams.groupId - additionalHeaders = groupRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = groupRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(groupRetrieveParams: GroupRetrieveParams) = apply { + groupId = groupRetrieveParams.groupId + additionalHeaders = groupRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = groupRetrieveParams.additionalQueryParams.toBuilder() + } /** Group id */ - fun groupId(groupId: String) = - apply { - this.groupId = groupId - } + fun groupId(groupId: String) = apply { this.groupId = groupId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupRetrieveParams = GroupRetrieveParams( - checkRequired( - "groupId", groupId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("groupId", groupId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupRetrieveParams && groupId == other.groupId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "GroupRetrieveParams{groupId=$groupId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 20c8cdf6..5945b26a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -23,16 +23,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a group object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. */ -class GroupUpdateParams private constructor( +class GroupUpdateParams +private constructor( private val groupId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Group id */ @@ -80,49 +80,67 @@ class GroupUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("add_member_groups") @ExcludeMissing private val addMemberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("add_member_users") @ExcludeMissing private val addMemberUsers: JsonField> = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("remove_member_groups") @ExcludeMissing private val removeMemberGroups: JsonField> = JsonMissing.of(), - @JsonProperty("remove_member_users") @ExcludeMissing private val removeMemberUsers: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("add_member_groups") + @ExcludeMissing + private val addMemberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("add_member_users") + @ExcludeMissing + private val addMemberUsers: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("remove_member_groups") + @ExcludeMissing + private val removeMemberGroups: JsonField> = JsonMissing.of(), + @JsonProperty("remove_member_users") + @ExcludeMissing + private val removeMemberUsers: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(): Optional> = Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) + fun addMemberGroups(): Optional> = + Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) /** A list of user IDs to add to the group */ - fun addMemberUsers(): Optional> = Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) + fun addMemberUsers(): Optional> = + Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) /** Textual description of the group */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the group */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(): Optional> = Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) + fun removeMemberGroups(): Optional> = + Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(): Optional> = Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) + fun removeMemberUsers(): Optional> = + Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) /** A list of group IDs to add to the group's inheriting-from set */ @JsonProperty("add_member_groups") @@ -140,9 +158,7 @@ class GroupUpdateParams private constructor( fun _description(): JsonField = description /** Name of the group */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** A list of group IDs to remove from the group's inheriting-from set */ @JsonProperty("remove_member_groups") @@ -160,28 +176,26 @@ class GroupUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - addMemberGroups() - addMemberUsers() - description() - name() - removeMemberGroups() - removeMemberUsers() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + addMemberGroups() + addMemberUsers() + description() + name() + removeMemberGroups() + removeMemberUsers() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -196,56 +210,57 @@ class GroupUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - addMemberGroups = body.addMemberGroups.map { it.toMutableList() } - addMemberUsers = body.addMemberUsers.map { it.toMutableList() } - description = body.description - name = body.name - removeMemberGroups = body.removeMemberGroups.map { it.toMutableList() } - removeMemberUsers = body.removeMemberUsers.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + addMemberGroups = body.addMemberGroups.map { it.toMutableList() } + addMemberUsers = body.addMemberUsers.map { it.toMutableList() } + description = body.description + name = body.name + removeMemberGroups = body.removeMemberGroups.map { it.toMutableList() } + removeMemberUsers = body.removeMemberUsers.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: List?) = addMemberGroups(JsonField.ofNullable(addMemberGroups)) + fun addMemberGroups(addMemberGroups: List?) = + addMemberGroups(JsonField.ofNullable(addMemberGroups)) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: Optional>) = addMemberGroups(addMemberGroups.getOrNull()) + fun addMemberGroups(addMemberGroups: Optional>) = + addMemberGroups(addMemberGroups.getOrNull()) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: JsonField>) = - apply { - this.addMemberGroups = addMemberGroups.map { it.toMutableList() } - } + fun addMemberGroups(addMemberGroups: JsonField>) = apply { + this.addMemberGroups = addMemberGroups.map { it.toMutableList() } + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addAddMemberGroup(addMemberGroup: String) = - apply { - addMemberGroups = (addMemberGroups ?: JsonField.of(mutableListOf())).also { + fun addAddMemberGroup(addMemberGroup: String) = apply { + addMemberGroups = + (addMemberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberGroups", it).add(addMemberGroup) } - } + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: List?) = addMemberUsers(JsonField.ofNullable(addMemberUsers)) + fun addMemberUsers(addMemberUsers: List?) = + addMemberUsers(JsonField.ofNullable(addMemberUsers)) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: Optional>) = addMemberUsers(addMemberUsers.getOrNull()) + fun addMemberUsers(addMemberUsers: Optional>) = + addMemberUsers(addMemberUsers.getOrNull()) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: JsonField>) = - apply { - this.addMemberUsers = addMemberUsers.map { it.toMutableList() } - } + fun addMemberUsers(addMemberUsers: JsonField>) = apply { + this.addMemberUsers = addMemberUsers.map { it.toMutableList() } + } /** A list of user IDs to add to the group */ - fun addAddMemberUser(addMemberUser: String) = - apply { - addMemberUsers = (addMemberUsers ?: JsonField.of(mutableListOf())).also { + fun addAddMemberUser(addMemberUser: String) = apply { + addMemberUsers = + (addMemberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberUsers", it).add(addMemberUser) } - } + } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -254,10 +269,9 @@ class GroupUpdateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** Name of the group */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -266,95 +280,87 @@ class GroupUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the group */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: List?) = removeMemberGroups(JsonField.ofNullable(removeMemberGroups)) + fun removeMemberGroups(removeMemberGroups: List?) = + removeMemberGroups(JsonField.ofNullable(removeMemberGroups)) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: Optional>) = removeMemberGroups(removeMemberGroups.getOrNull()) + fun removeMemberGroups(removeMemberGroups: Optional>) = + removeMemberGroups(removeMemberGroups.getOrNull()) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: JsonField>) = - apply { - this.removeMemberGroups = removeMemberGroups.map { it.toMutableList() } - } + fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { + this.removeMemberGroups = removeMemberGroups.map { it.toMutableList() } + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun addRemoveMemberGroup(removeMemberGroup: String) = - apply { - removeMemberGroups = (removeMemberGroups ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberGroup(removeMemberGroup: String) = apply { + removeMemberGroups = + (removeMemberGroups ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberGroups", it).add(removeMemberGroup) } - } + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: List?) = removeMemberUsers(JsonField.ofNullable(removeMemberUsers)) + fun removeMemberUsers(removeMemberUsers: List?) = + removeMemberUsers(JsonField.ofNullable(removeMemberUsers)) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: Optional>) = removeMemberUsers(removeMemberUsers.getOrNull()) + fun removeMemberUsers(removeMemberUsers: Optional>) = + removeMemberUsers(removeMemberUsers.getOrNull()) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: JsonField>) = - apply { - this.removeMemberUsers = removeMemberUsers.map { it.toMutableList() } - } + fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { + this.removeMemberUsers = removeMemberUsers.map { it.toMutableList() } + } /** A list of user IDs to remove from the group */ - fun addRemoveMemberUser(removeMemberUser: String) = - apply { - removeMemberUsers = (removeMemberUsers ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberUser(removeMemberUser: String) = apply { + removeMemberUsers = + (removeMemberUsers ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberUsers", it).add(removeMemberUser) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (addMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - description, - name, - (removeMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, - (removeMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (addMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + description, + name, + (removeMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, + (removeMemberUsers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addMemberGroups == other.addMemberGroups && addMemberUsers == other.addMemberUsers && description == other.description && name == other.name && removeMemberGroups == other.removeMemberGroups && removeMemberUsers == other.removeMemberUsers && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -363,7 +369,8 @@ class GroupUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -374,13 +381,11 @@ class GroupUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [GroupUpdateParams]. * * The following fields are required: - * * ```java * .groupId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [GroupUpdateParams]. */ @@ -393,305 +398,244 @@ class GroupUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(groupUpdateParams: GroupUpdateParams) = - apply { - groupId = groupUpdateParams.groupId - body = groupUpdateParams.body.toBuilder() - additionalHeaders = groupUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = groupUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(groupUpdateParams: GroupUpdateParams) = apply { + groupId = groupUpdateParams.groupId + body = groupUpdateParams.body.toBuilder() + additionalHeaders = groupUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = groupUpdateParams.additionalQueryParams.toBuilder() + } /** Group id */ - fun groupId(groupId: String) = - apply { - this.groupId = groupId - } + fun groupId(groupId: String) = apply { this.groupId = groupId } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: List?) = - apply { - body.addMemberGroups(addMemberGroups) - } + fun addMemberGroups(addMemberGroups: List?) = apply { + body.addMemberGroups(addMemberGroups) + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: Optional>) = addMemberGroups(addMemberGroups.getOrNull()) + fun addMemberGroups(addMemberGroups: Optional>) = + addMemberGroups(addMemberGroups.getOrNull()) /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: JsonField>) = - apply { - body.addMemberGroups(addMemberGroups) - } + fun addMemberGroups(addMemberGroups: JsonField>) = apply { + body.addMemberGroups(addMemberGroups) + } /** A list of group IDs to add to the group's inheriting-from set */ - fun addAddMemberGroup(addMemberGroup: String) = - apply { - body.addAddMemberGroup(addMemberGroup) - } + fun addAddMemberGroup(addMemberGroup: String) = apply { + body.addAddMemberGroup(addMemberGroup) + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: List?) = - apply { - body.addMemberUsers(addMemberUsers) - } + fun addMemberUsers(addMemberUsers: List?) = apply { + body.addMemberUsers(addMemberUsers) + } /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: Optional>) = addMemberUsers(addMemberUsers.getOrNull()) + fun addMemberUsers(addMemberUsers: Optional>) = + addMemberUsers(addMemberUsers.getOrNull()) /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: JsonField>) = - apply { - body.addMemberUsers(addMemberUsers) - } + fun addMemberUsers(addMemberUsers: JsonField>) = apply { + body.addMemberUsers(addMemberUsers) + } /** A list of user IDs to add to the group */ - fun addAddMemberUser(addMemberUser: String) = - apply { - body.addAddMemberUser(addMemberUser) - } + fun addAddMemberUser(addMemberUser: String) = apply { body.addAddMemberUser(addMemberUser) } /** Textual description of the group */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the group */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the group */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** Name of the group */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the group */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the group */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: List?) = - apply { - body.removeMemberGroups(removeMemberGroups) - } + fun removeMemberGroups(removeMemberGroups: List?) = apply { + body.removeMemberGroups(removeMemberGroups) + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: Optional>) = removeMemberGroups(removeMemberGroups.getOrNull()) + fun removeMemberGroups(removeMemberGroups: Optional>) = + removeMemberGroups(removeMemberGroups.getOrNull()) /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: JsonField>) = - apply { - body.removeMemberGroups(removeMemberGroups) - } + fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { + body.removeMemberGroups(removeMemberGroups) + } /** A list of group IDs to remove from the group's inheriting-from set */ - fun addRemoveMemberGroup(removeMemberGroup: String) = - apply { - body.addRemoveMemberGroup(removeMemberGroup) - } + fun addRemoveMemberGroup(removeMemberGroup: String) = apply { + body.addRemoveMemberGroup(removeMemberGroup) + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: List?) = - apply { - body.removeMemberUsers(removeMemberUsers) - } + fun removeMemberUsers(removeMemberUsers: List?) = apply { + body.removeMemberUsers(removeMemberUsers) + } /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: Optional>) = removeMemberUsers(removeMemberUsers.getOrNull()) + fun removeMemberUsers(removeMemberUsers: Optional>) = + removeMemberUsers(removeMemberUsers.getOrNull()) /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: JsonField>) = - apply { - body.removeMemberUsers(removeMemberUsers) - } + fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { + body.removeMemberUsers(removeMemberUsers) + } /** A list of user IDs to remove from the group */ - fun addRemoveMemberUser(removeMemberUser: String) = - apply { - body.addRemoveMemberUser(removeMemberUser) - } + fun addRemoveMemberUser(removeMemberUser: String) = apply { + body.addRemoveMemberUser(removeMemberUser) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): GroupUpdateParams = GroupUpdateParams( - checkRequired( - "groupId", groupId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("groupId", groupId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is GroupUpdateParams && groupId == other.groupId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(groupId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "GroupUpdateParams{groupId=$groupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "GroupUpdateParams{groupId=$groupId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index ea8bc1c4..c726e52b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -21,81 +21,99 @@ import kotlin.jvm.optionals.getOrNull /** A dataset event */ @NoAutoDetect -class InsertDatasetEvent @JsonCreator private constructor( +class InsertDatasetEvent +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") + @ExcludeMissing + private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") + @ExcludeMissing + private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") + @ExcludeMissing + private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") + @ExcludeMissing + private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ - fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -105,234 +123,203 @@ class InsertDatasetEvent @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected(): JsonValue = expected - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable + * The output of your application, including post-processing (an arbitrary, JSON serializable * object) */ - @JsonProperty("input") - @ExcludeMissing - fun _input(): JsonValue = input + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + + /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate + * one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up + * in subsequent fetches for this dataset */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId(): JsonField = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -341,9 +328,7 @@ class InsertDatasetEvent @JsonCreator private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -351,33 +336,31 @@ class InsertDatasetEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): InsertDatasetEvent = - apply { - if (validated) { - return@apply - } - - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - created() - metadata().ifPresent { it.validate() } - rootSpanId() - spanId() - spanParents() - tags() - validated = true + fun validate(): InsertDatasetEvent = apply { + if (validated) { + return@apply } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + created() + metadata().ifPresent { it.validate() } + rootSpanId() + spanId() + spanParents() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [InsertDatasetEvent]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InsertDatasetEvent]. */ @@ -399,268 +382,241 @@ class InsertDatasetEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertDatasetEvent: InsertDatasetEvent) = - apply { - id = insertDatasetEvent.id - _isMerge = insertDatasetEvent._isMerge - _mergePaths = insertDatasetEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertDatasetEvent._objectDelete - _parentId = insertDatasetEvent._parentId - created = insertDatasetEvent.created - expected = insertDatasetEvent.expected - input = insertDatasetEvent.input - metadata = insertDatasetEvent.metadata - rootSpanId = insertDatasetEvent.rootSpanId - spanId = insertDatasetEvent.spanId - spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } - tags = insertDatasetEvent.tags.map { it.toMutableList() } - additionalProperties = insertDatasetEvent.additionalProperties.toMutableMap() - } + internal fun from(insertDatasetEvent: InsertDatasetEvent) = apply { + id = insertDatasetEvent.id + _isMerge = insertDatasetEvent._isMerge + _mergePaths = insertDatasetEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertDatasetEvent._objectDelete + _parentId = insertDatasetEvent._parentId + created = insertDatasetEvent.created + expected = insertDatasetEvent.expected + input = insertDatasetEvent.input + metadata = insertDatasetEvent.metadata + rootSpanId = insertDatasetEvent.rootSpanId + spanId = insertDatasetEvent.spanId + spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } + tags = insertDatasetEvent.tags.map { it.toMutableList() } + additionalProperties = insertDatasetEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust - * will generate one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust will + * generate one for you */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = - apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = + _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = + _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. - * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. - */ - fun _mergePaths(_mergePaths: JsonField>>) = - apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. - * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. - */ - fun addMergePath(mergePath: List) = - apply { - _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. + * + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. + */ + fun addMergePath(mergePath: List) = apply { + _mergePaths = + (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = + _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = + _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events - * will not show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not + * show up in subsequent fetches for this dataset */ - fun _objectDelete(_objectDelete: JsonField) = - apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = - apply { - this._parentId = _parentId - } + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -669,73 +625,60 @@ class InsertDatasetEvent @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the dataset event was created */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object) */ - fun expected(expected: JsonValue) = - apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - fun input(input: JsonValue) = - apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -743,18 +686,18 @@ class InsertDatasetEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -762,40 +705,37 @@ class InsertDatasetEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = - apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -803,18 +743,18 @@ class InsertDatasetEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -822,40 +762,37 @@ class InsertDatasetEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = - apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -863,18 +800,18 @@ class InsertDatasetEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -882,49 +819,48 @@ class InsertDatasetEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = - apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. - * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = - apply { - spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -933,75 +869,66 @@ class InsertDatasetEvent @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertDatasetEvent = InsertDatasetEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - created, - expected, - input, - metadata, - rootSpanId, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + created, + expected, + input, + metadata, + rootSpanId, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1010,22 +937,20 @@ class InsertDatasetEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1034,46 +959,38 @@ class InsertDatasetEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1086,11 +1003,11 @@ class InsertDatasetEvent @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1099,5 +1016,6 @@ class InsertDatasetEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 56212366..099bcb9a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -18,25 +18,24 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects @NoAutoDetect -class InsertEventsResponse @JsonCreator private constructor( - @JsonProperty("row_ids") @ExcludeMissing private val rowIds: JsonField> = JsonMissing.of(), +class InsertEventsResponse +@JsonCreator +private constructor( + @JsonProperty("row_ids") + @ExcludeMissing + private val rowIds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ fun rowIds(): List = rowIds.getRequired("row_ids") /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input */ - @JsonProperty("row_ids") - @ExcludeMissing - fun _rowIds(): JsonField> = rowIds + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField> = rowIds @JsonAnyGetter @ExcludeMissing @@ -44,32 +43,28 @@ class InsertEventsResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): InsertEventsResponse = - apply { - if (validated) { - return@apply - } - - rowIds() - validated = true + fun validate(): InsertEventsResponse = apply { + if (validated) { + return@apply } + rowIds() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [InsertEventsResponse]. + * Returns a mutable builder for constructing an instance of [InsertEventsResponse]. * * The following fields are required: - * * ```java * .rowIds() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InsertEventsResponse]. */ @@ -79,78 +74,68 @@ class InsertEventsResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertEventsResponse: InsertEventsResponse) = - apply { - rowIds = insertEventsResponse.rowIds.map { it.toMutableList() } - additionalProperties = insertEventsResponse.additionalProperties.toMutableMap() - } + internal fun from(insertEventsResponse: InsertEventsResponse) = apply { + rowIds = insertEventsResponse.rowIds.map { it.toMutableList() } + additionalProperties = insertEventsResponse.additionalProperties.toMutableMap() + } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input */ fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input */ - fun rowIds(rowIds: JsonField>) = - apply { - this.rowIds = rowIds.map { it.toMutableList() } - } + fun rowIds(rowIds: JsonField>) = apply { + this.rowIds = rowIds.map { it.toMutableList() } + } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows - * provided as input + * The ids of all rows that were inserted, aligning one-to-one with the rows provided as + * input */ - fun addRowId(rowId: String) = - apply { - rowIds = (rowIds ?: JsonField.of(mutableListOf())).also { + fun addRowId(rowId: String) = apply { + rowIds = + (rowIds ?: JsonField.of(mutableListOf())).also { checkKnown("rowIds", it).add(rowId) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertEventsResponse = InsertEventsResponse( - checkRequired( - "rowIds", rowIds - ).map { it.toImmutable() }, additionalProperties.toImmutable() + checkRequired("rowIds", rowIds).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertEventsResponse && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertEventsResponse && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -159,5 +144,6 @@ class InsertEventsResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 4f95c38c..3b414e84 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -21,98 +21,125 @@ import kotlin.jvm.optionals.getOrNull /** An experiment event */ @NoAutoDetect -class InsertExperimentEvent @JsonCreator private constructor( +class InsertExperimentEvent +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") @ExcludeMissing private val datasetRecordId: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") + @ExcludeMissing + private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") + @ExcludeMissing + private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") + @ExcludeMissing + private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") + @ExcludeMissing + private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + private val context: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("dataset_record_id") + @ExcludeMissing + private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") + @ExcludeMissing + private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ - fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show + * up in subsequent fetches for this experiment */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) @@ -120,291 +147,254 @@ class InsertExperimentEvent @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(): Optional = Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) + fun datasetRecordId(): Optional = + Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun _error(): JsonValue = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate your experiments while + * digging into analyses. However, we may later use these values to re-score outputs or + * fine-tune your models */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected(): JsonValue = expected + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same between + * experiments, so they should not contain experiment-specific state. A simple rule of thumb is + * that if you run the same experiment twice, the `input` should be identical */ - @JsonProperty("input") - @ExcludeMissing - fun _input(): JsonValue = input + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question */ - @JsonProperty("output") - @ExcludeMissing - fun _output(): JsonValue = output + @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show + * up in subsequent fetches for this experiment */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event */ - @JsonProperty("context") - @ExcludeMissing - fun _context(): JsonField = context + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId(): JsonField = datasetRecordId /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics(): JsonField = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores(): JsonField = scores + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -412,40 +402,36 @@ class InsertExperimentEvent @JsonCreator private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId(): JsonField = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -454,9 +440,7 @@ class InsertExperimentEvent @JsonCreator private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -464,41 +448,36 @@ class InsertExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): InsertExperimentEvent = - apply { - if (validated) { - return@apply - } - - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - context().ifPresent { it.validate() } - created() - datasetRecordId() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - rootSpanId() - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanId() - spanParents() - tags() - validated = true + fun validate(): InsertExperimentEvent = apply { + if (validated) { + return@apply } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + context().ifPresent { it.validate() } + created() + datasetRecordId() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + rootSpanId() + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanId() + spanParents() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of - * [InsertExperimentEvent]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [InsertExperimentEvent]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [InsertExperimentEvent]. */ @@ -527,302 +506,269 @@ class InsertExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertExperimentEvent: InsertExperimentEvent) = - apply { - id = insertExperimentEvent.id - _isMerge = insertExperimentEvent._isMerge - _mergePaths = insertExperimentEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertExperimentEvent._objectDelete - _parentId = insertExperimentEvent._parentId - context = insertExperimentEvent.context - created = insertExperimentEvent.created - datasetRecordId = insertExperimentEvent.datasetRecordId - error = insertExperimentEvent.error - expected = insertExperimentEvent.expected - input = insertExperimentEvent.input - metadata = insertExperimentEvent.metadata - metrics = insertExperimentEvent.metrics - output = insertExperimentEvent.output - rootSpanId = insertExperimentEvent.rootSpanId - scores = insertExperimentEvent.scores - spanAttributes = insertExperimentEvent.spanAttributes - spanId = insertExperimentEvent.spanId - spanParents = insertExperimentEvent.spanParents.map { it.toMutableList() } - tags = insertExperimentEvent.tags.map { it.toMutableList() } - additionalProperties = insertExperimentEvent.additionalProperties.toMutableMap() - } + internal fun from(insertExperimentEvent: InsertExperimentEvent) = apply { + id = insertExperimentEvent.id + _isMerge = insertExperimentEvent._isMerge + _mergePaths = insertExperimentEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertExperimentEvent._objectDelete + _parentId = insertExperimentEvent._parentId + context = insertExperimentEvent.context + created = insertExperimentEvent.created + datasetRecordId = insertExperimentEvent.datasetRecordId + error = insertExperimentEvent.error + expected = insertExperimentEvent.expected + input = insertExperimentEvent.input + metadata = insertExperimentEvent.metadata + metrics = insertExperimentEvent.metrics + output = insertExperimentEvent.output + rootSpanId = insertExperimentEvent.rootSpanId + scores = insertExperimentEvent.scores + spanAttributes = insertExperimentEvent.spanAttributes + spanId = insertExperimentEvent.spanId + spanParents = insertExperimentEvent.spanParents.map { it.toMutableList() } + tags = insertExperimentEvent.tags.map { it.toMutableList() } + additionalProperties = insertExperimentEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the experiment event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the experiment event. If you don't provide one, BrainTrust will + * generate one for you */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = - apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = + _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = + _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: JsonField>>) = - apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun addMergePath(mergePath: List) = - apply { - _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { + fun addMergePath(mergePath: List) = apply { + _mergePaths = + (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = + _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = + _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events - * will not show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not + * show up in subsequent fetches for this experiment */ - fun _objectDelete(_objectDelete: JsonField) = - apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = - apply { - this._parentId = _parentId - } + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the experiment event */ - fun context(context: JsonField) = - apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -831,144 +777,122 @@ class InsertExperimentEvent @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the experiment event was created */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String?) = datasetRecordId(JsonField.ofNullable(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String?) = + datasetRecordId(JsonField.ofNullable(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(datasetRecordId: Optional) = datasetRecordId(datasetRecordId.getOrNull()) + fun datasetRecordId(datasetRecordId: Optional) = + datasetRecordId(datasetRecordId.getOrNull()) /** - * If the experiment is associated to a dataset, this is the event-level dataset id - * this experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id this + * experiment event is tied to */ - fun datasetRecordId(datasetRecordId: JsonField) = - apply { - this.datasetRecordId = datasetRecordId - } + fun datasetRecordId(datasetRecordId: JsonField) = apply { + this.datasetRecordId = datasetRecordId + } /** The error that occurred, if any. */ - fun error(error: JsonValue) = - apply { - this.error = error - } + fun error(error: JsonValue) = apply { this.error = error } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate your experiments while digging into analyses. - * However, we may later use these values to re-score outputs or fine-tune your - * models + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate your experiments + * while digging into analyses. However, we may later use these values to re-score outputs + * or fine-tune your models */ - fun expected(expected: JsonValue) = - apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test - * cases are the same between experiments, so they should not contain - * experiment-specific state. A simple rule of thumb is that if you run the same - * experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). + * Later on, Braintrust will use the `input` to know whether two test cases are the same + * between experiments, so they should not contain experiment-specific state. A simple rule + * of thumb is that if you run the same experiment twice, the `input` should be identical */ - fun input(input: JsonValue) = - apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ - fun metrics(metrics: JsonField) = - apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question */ - fun output(output: JsonValue) = - apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -976,18 +900,18 @@ class InsertExperimentEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -995,91 +919,83 @@ class InsertExperimentEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = - apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare experiments */ - fun scores(scores: JsonField) = - apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = + spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = + spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = - apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1087,18 +1003,18 @@ class InsertExperimentEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1106,40 +1022,37 @@ class InsertExperimentEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = - apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1147,18 +1060,18 @@ class InsertExperimentEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1166,49 +1079,48 @@ class InsertExperimentEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = - apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = - apply { - spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -1217,94 +1129,93 @@ class InsertExperimentEvent @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertExperimentEvent = InsertExperimentEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - context, - created, - datasetRecordId, - error, - expected, - input, - metadata, - metrics, - output, - rootSpanId, - scores, - spanAttributes, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + context, + created, + datasetRecordId, + error, + expected, + input, + metadata, + metrics, + output, + rootSpanId, + scores, + spanAttributes, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the experiment - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the - * experiment event + * Context is additional information about the code that produced the experiment event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the experiment event */ @NoAutoDetect - class Context @JsonCreator private constructor( - @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Context + @JsonCreator + private constructor( + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the file in code where the experiment event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the experiment event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the experiment event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -1327,25 +1238,23 @@ class InsertExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Context = - apply { - if (validated) { - return@apply - } - - callerFilename() - callerFunctionname() - callerLineno() - validated = true + fun validate(): Context = apply { + if (validated) { + return@apply } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Context]. */ @@ -1357,37 +1266,38 @@ class InsertExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = - apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = + callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = + callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: JsonField) = - apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = + callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = + callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: JsonField) = - apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -1399,52 +1309,44 @@ class InsertExperimentEvent @JsonCreator private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: JsonField) = - apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1453,20 +1355,23 @@ class InsertExperimentEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1475,22 +1380,20 @@ class InsertExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1499,46 +1402,38 @@ class InsertExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1551,22 +1446,38 @@ class InsertExperimentEvent @JsonCreator private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the experiment event. Use "start" and "end" to track the time span over - * which the experiment event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * experiment event. Use "start" and "end" to track the time span over which the experiment + * event was produced */ @NoAutoDetect - class Metrics @JsonCreator private constructor( - @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), + class Metrics + @JsonCreator + private constructor( + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("prompt_tokens") + @ExcludeMissing + private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") + @ExcludeMissing + private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** This metric is deprecated */ @@ -1580,31 +1491,31 @@ class InsertExperimentEvent @JsonCreator private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment event + * finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment event + * started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1612,41 +1523,35 @@ class InsertExperimentEvent @JsonCreator private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment event + * finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end(): JsonField = end + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment event + * started */ - @JsonProperty("start") - @ExcludeMissing - fun _start(): JsonField = start + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens(): JsonField = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1654,27 +1559,25 @@ class InsertExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metrics = - apply { - if (validated) { - return@apply - } - - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true + fun validate(): Metrics = apply { + if (validated) { + return@apply } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1691,144 +1594,133 @@ class InsertExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = - apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = - apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = - apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = - apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: JsonField) = - apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the - * experiment event finished + * A unix timestamp recording when the section of code which produced the experiment + * event finished */ - fun end(end: JsonField) = - apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only set if + * this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = - apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the - * experiment event started + * A unix timestamp recording when the section of code which produced the experiment + * event started */ - fun start(start: JsonField) = - apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1840,57 +1732,47 @@ class InsertExperimentEvent @JsonCreator private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: JsonField) = - apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1899,23 +1781,25 @@ class InsertExperimentEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ @NoAutoDetect - class Scores @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Scores + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1924,22 +1808,20 @@ class InsertExperimentEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Scores = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Scores = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1948,46 +1830,38 @@ class InsertExperimentEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = - apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2000,11 +1874,11 @@ class InsertExperimentEvent @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2013,5 +1887,6 @@ class InsertExperimentEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index 0d2bd5ff..abf02697 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -21,97 +21,122 @@ import kotlin.jvm.optionals.getOrNull /** A project logs event */ @NoAutoDetect -class InsertProjectLogsEvent @JsonCreator private constructor( +class InsertProjectLogsEvent +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_is_merge") @ExcludeMissing private val _isMerge: JsonField = JsonMissing.of(), - @JsonProperty("_merge_paths") @ExcludeMissing private val _mergePaths: JsonField>> = JsonMissing.of(), - @JsonProperty("_object_delete") @ExcludeMissing private val _objectDelete: JsonField = JsonMissing.of(), - @JsonProperty("_parent_id") @ExcludeMissing private val _parentId: JsonField = JsonMissing.of(), - @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("_is_merge") + @ExcludeMissing + private val _isMerge: JsonField = JsonMissing.of(), + @JsonProperty("_merge_paths") + @ExcludeMissing + private val _mergePaths: JsonField>> = JsonMissing.of(), + @JsonProperty("_object_delete") + @ExcludeMissing + private val _objectDelete: JsonField = JsonMissing.of(), + @JsonProperty("_parent_id") + @ExcludeMissing + private val _parentId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + private val context: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") + @ExcludeMissing + private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ - fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) + fun _mergePaths(): Optional>> = + Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not + * show up in subsequent fetches for this project logs */ - fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) + fun _objectDelete(): Optional = + Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) @@ -119,273 +144,234 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun _error(): JsonValue = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected(): JsonValue = expected + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - @JsonProperty("input") - @ExcludeMissing - fun _input(): JsonValue = input + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. */ - @JsonProperty("output") - @ExcludeMissing - fun _output(): JsonValue = output + @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same id + * in the DB. By default (or when set to `false`), the existing row is completely replaced by + * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is + * found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") - @ExcludeMissing - fun __isMerge(): JsonField = _isMerge + @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. + * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge + * will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, + * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, + * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, + * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": + * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the + * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and + * `input.c`. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not + * show up in subsequent fetches for this project logs */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent + * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after + * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row + * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this + * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("_parent_id") - @ExcludeMissing - fun __parentId(): JsonField = _parentId + @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event */ - @JsonProperty("context") - @ExcludeMissing - fun _context(): JsonField = context + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics(): JsonField = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores(): JsonField = scores + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -393,40 +379,36 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId(): JsonField = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. + * The span_id is a unique identifier describing the row's place in the a trace, and the + * root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": + * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": + * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root + * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in + * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -435,9 +417,7 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -445,40 +425,35 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): InsertProjectLogsEvent = - apply { - if (validated) { - return@apply - } - - id() - _isMerge() - _mergePaths() - _objectDelete() - _parentId() - context().ifPresent { it.validate() } - created() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - rootSpanId() - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanId() - spanParents() - tags() - validated = true + fun validate(): InsertProjectLogsEvent = apply { + if (validated) { + return@apply } + id() + _isMerge() + _mergePaths() + _objectDelete() + _parentId() + context().ifPresent { it.validate() } + created() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + rootSpanId() + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanId() + spanParents() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of - * [InsertProjectLogsEvent]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [InsertProjectLogsEvent]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [InsertProjectLogsEvent]. */ @@ -506,301 +481,268 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(insertProjectLogsEvent: InsertProjectLogsEvent) = - apply { - id = insertProjectLogsEvent.id - _isMerge = insertProjectLogsEvent._isMerge - _mergePaths = insertProjectLogsEvent._mergePaths.map { it.toMutableList() } - _objectDelete = insertProjectLogsEvent._objectDelete - _parentId = insertProjectLogsEvent._parentId - context = insertProjectLogsEvent.context - created = insertProjectLogsEvent.created - error = insertProjectLogsEvent.error - expected = insertProjectLogsEvent.expected - input = insertProjectLogsEvent.input - metadata = insertProjectLogsEvent.metadata - metrics = insertProjectLogsEvent.metrics - output = insertProjectLogsEvent.output - rootSpanId = insertProjectLogsEvent.rootSpanId - scores = insertProjectLogsEvent.scores - spanAttributes = insertProjectLogsEvent.spanAttributes - spanId = insertProjectLogsEvent.spanId - spanParents = insertProjectLogsEvent.spanParents.map { it.toMutableList() } - tags = insertProjectLogsEvent.tags.map { it.toMutableList() } - additionalProperties = insertProjectLogsEvent.additionalProperties.toMutableMap() - } + internal fun from(insertProjectLogsEvent: InsertProjectLogsEvent) = apply { + id = insertProjectLogsEvent.id + _isMerge = insertProjectLogsEvent._isMerge + _mergePaths = insertProjectLogsEvent._mergePaths.map { it.toMutableList() } + _objectDelete = insertProjectLogsEvent._objectDelete + _parentId = insertProjectLogsEvent._parentId + context = insertProjectLogsEvent.context + created = insertProjectLogsEvent.created + error = insertProjectLogsEvent.error + expected = insertProjectLogsEvent.expected + input = insertProjectLogsEvent.input + metadata = insertProjectLogsEvent.metadata + metrics = insertProjectLogsEvent.metrics + output = insertProjectLogsEvent.output + rootSpanId = insertProjectLogsEvent.rootSpanId + scores = insertProjectLogsEvent.scores + spanAttributes = insertProjectLogsEvent.spanAttributes + spanId = insertProjectLogsEvent.spanId + spanParents = insertProjectLogsEvent.spanParents.map { it.toMutableList() } + tags = insertProjectLogsEvent.tags.map { it.toMutableList() } + additionalProperties = insertProjectLogsEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: String?) = id(JsonField.ofNullable(id)) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with - * the same id in the DB. By default (or when set to `false`), the existing row is - * completely replaced by the new row. When set to `true`, the new row is - * deep-merged into the existing row, if one is found. If no existing row is found, - * the new row is inserted as is. + * The `_is_merge` field controls how the row is merged with any existing row with the same + * id in the DB. By default (or when set to `false`), the existing row is completely + * replaced by the new row. When set to `true`, the new row is deep-merged into the existing + * row, if one is found. If no existing row is found, the new row is inserted as is. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as - * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row - * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the - * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": + * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": + * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we + * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - fun _isMerge(_isMerge: JsonField) = - apply { - this._isMerge = _isMerge - } + fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) + fun _mergePaths(_mergePaths: List>?) = + _mergePaths(JsonField.ofNullable(_mergePaths)) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) + fun _mergePaths(_mergePaths: Optional>>) = + _mergePaths(_mergePaths.getOrNull()) /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun _mergePaths(_mergePaths: JsonField>>) = - apply { - this._mergePaths = _mergePaths.map { it.toMutableList() } - } + fun _mergePaths(_mergePaths: JsonField>>) = apply { + this._mergePaths = _mergePaths.map { it.toMutableList() } + } /** * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list - * of field names. The deep merge will not descend below any of the specified merge - * paths. + * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field + * names. The deep merge will not descend below any of the specified merge paths. * - * For example, say there is an existing row in the DB - * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. - * If we merge a new row as - * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, - * the new row will be - * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. - * In this case, due to the merge paths, we have replaced `input.a` and `output`, - * but have still deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": + * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": + * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": + * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": + * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this + * case, due to the merge paths, we have replaced `input.a` and `output`, but have still + * deep-merged `input` and `input.c`. */ - fun addMergePath(mergePath: List) = - apply { - _mergePaths = (_mergePaths ?: JsonField.of(mutableListOf())).also { + fun addMergePath(mergePath: List) = apply { + _mergePaths = + (_mergePaths ?: JsonField.of(mutableListOf())).also { checkKnown("_mergePaths", it).add(mergePath) } - } + } /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: Boolean?) = _objectDelete(JsonField.ofNullable(_objectDelete)) + fun _objectDelete(_objectDelete: Boolean?) = + _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) + fun _objectDelete(_objectDelete: Optional) = + _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted - * events will not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will + * not show up in subsequent fetches for this project logs */ - fun _objectDelete(_objectDelete: JsonField) = - apply { - this._objectDelete = _objectDelete - } + fun _objectDelete(_objectDelete: JsonField) = apply { + this._objectDelete = _objectDelete + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. - * Tracking hierarchical relationships are important for tracing (see the + * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking + * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row - * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", + * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the + * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What + * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the + * root span row `"abc"` will show up in the summary view. You can view the full trace + * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun _parentId(_parentId: JsonField) = - apply { - this._parentId = _parentId - } + fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ - fun context(context: JsonField) = - apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -809,119 +751,97 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** The timestamp the project logs event was created */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** The error that occurred, if any. */ - fun error(error: JsonValue) = - apply { - this.error = error - } + fun error(error: JsonValue) = apply { this.error = error } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. */ - fun expected(expected: JsonValue) = - apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - fun input(input: JsonValue) = - apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ - fun metrics(metrics: JsonField) = - apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. */ - fun output(output: JsonValue) = - apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -929,18 +849,18 @@ class InsertProjectLogsEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -948,91 +868,83 @@ class InsertProjectLogsEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun rootSpanId(rootSpanId: JsonField) = - apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - fun scores(scores: JsonField) = - apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = + spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = + spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = - apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1040,18 +952,18 @@ class InsertProjectLogsEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1059,40 +971,37 @@ class InsertProjectLogsEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanId(spanId: JsonField) = - apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1100,18 +1009,18 @@ class InsertProjectLogsEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ @@ -1119,49 +1028,48 @@ class InsertProjectLogsEvent @JsonCreator private constructor( /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun spanParents(spanParents: JsonField>) = - apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in - * the a trace, and the root_span_id is a unique identifier for the whole trace. - * See the [guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details. + * \_parent_id. The span_id is a unique identifier describing the row's place in the a + * trace, and the root_span_id is a unique identifier for the whole trace. See the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * - * For example, say we have logged a row - * `{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. - * We can create a sub-span of the parent row by logging - * `{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. - * In the webapp, only the root span row `"abc"` will show up in the summary view. - * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by - * clicking on the "abc" row. + * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": + * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": + * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": + * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], + * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": + * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You + * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the + * "abc" row. * * If the row is being merged into an existing row, this field will be ignored. */ - fun addSpanParent(spanParent: String) = - apply { - spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -1170,93 +1078,92 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InsertProjectLogsEvent = InsertProjectLogsEvent( - id, - _isMerge, - (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, - _objectDelete, - _parentId, - context, - created, - error, - expected, - input, - metadata, - metrics, - output, - rootSpanId, - scores, - spanAttributes, - spanId, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + id, + _isMerge, + (_mergePaths ?: JsonMissing.of()).map { it.toImmutable() }, + _objectDelete, + _parentId, + context, + created, + error, + expected, + input, + metadata, + metrics, + output, + rootSpanId, + scores, + spanAttributes, + spanId, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event */ @NoAutoDetect - class Context @JsonCreator private constructor( - @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Context + @JsonCreator + private constructor( + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -1279,25 +1186,23 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Context = - apply { - if (validated) { - return@apply - } - - callerFilename() - callerFunctionname() - callerLineno() - validated = true + fun validate(): Context = apply { + if (validated) { + return@apply } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Context]. */ @@ -1309,37 +1214,38 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = - apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = + callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = + callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: JsonField) = - apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = + callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = + callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: JsonField) = - apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -1351,52 +1257,44 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: JsonField) = - apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1405,20 +1303,23 @@ class InsertProjectLogsEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1427,22 +1328,20 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1451,46 +1350,38 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1503,22 +1394,38 @@ class InsertProjectLogsEvent @JsonCreator private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced */ @NoAutoDetect - class Metrics @JsonCreator private constructor( - @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), + class Metrics + @JsonCreator + private constructor( + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("prompt_tokens") + @ExcludeMissing + private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") + @ExcludeMissing + private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** This metric is deprecated */ @@ -1532,31 +1439,31 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs event + * finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs event + * started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1564,41 +1471,35 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs event + * finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end(): JsonField = end + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs event + * started */ - @JsonProperty("start") - @ExcludeMissing - fun _start(): JsonField = start + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens(): JsonField = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1606,27 +1507,25 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metrics = - apply { - if (validated) { - return@apply - } - - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true + fun validate(): Metrics = apply { + if (validated) { + return@apply } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1643,144 +1542,133 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = - apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = - apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = - apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = - apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: JsonField) = - apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ - fun end(end: JsonField) = - apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = - apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ - fun start(start: JsonField) = - apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1792,57 +1680,47 @@ class InsertProjectLogsEvent @JsonCreator private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: JsonField) = - apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1851,23 +1729,25 @@ class InsertProjectLogsEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ @NoAutoDetect - class Scores @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Scores + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1876,22 +1756,20 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Scores = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Scores = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1900,46 +1778,38 @@ class InsertProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = - apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1952,11 +1822,11 @@ class InsertProjectLogsEvent @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1965,5 +1835,6 @@ class InsertProjectLogsEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index 8c1b55dc..a7fa4c4d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -19,15 +19,22 @@ import java.util.Optional /** Summary of a metric's performance */ @NoAutoDetect -class MetricSummary @JsonCreator private constructor( - @JsonProperty("improvements") @ExcludeMissing private val improvements: JsonField = JsonMissing.of(), - @JsonProperty("metric") @ExcludeMissing private val metric: JsonField = JsonMissing.of(), +class MetricSummary +@JsonCreator +private constructor( + @JsonProperty("improvements") + @ExcludeMissing + private val improvements: JsonField = JsonMissing.of(), + @JsonProperty("metric") + @ExcludeMissing + private val metric: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("regressions") @ExcludeMissing private val regressions: JsonField = JsonMissing.of(), + @JsonProperty("regressions") + @ExcludeMissing + private val regressions: JsonField = JsonMissing.of(), @JsonProperty("unit") @ExcludeMissing private val unit: JsonField = JsonMissing.of(), @JsonProperty("diff") @ExcludeMissing private val diff: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Number of improvements in the metric */ @@ -54,29 +61,19 @@ class MetricSummary @JsonCreator private constructor( fun _improvements(): JsonField = improvements /** Average metric across all examples */ - @JsonProperty("metric") - @ExcludeMissing - fun _metric(): JsonField = metric + @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric /** Name of the metric */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Number of regressions in the metric */ - @JsonProperty("regressions") - @ExcludeMissing - fun _regressions(): JsonField = regressions + @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions /** Unit label for the metric */ - @JsonProperty("unit") - @ExcludeMissing - fun _unit(): JsonField = unit + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit /** Difference in metric between the current and comparison experiment */ - @JsonProperty("diff") - @ExcludeMissing - fun _diff(): JsonField = diff + @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff @JsonAnyGetter @ExcludeMissing @@ -84,21 +81,20 @@ class MetricSummary @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): MetricSummary = - apply { - if (validated) { - return@apply - } - - improvements() - metric() - name() - regressions() - unit() - diff() - validated = true + fun validate(): MetricSummary = apply { + if (validated) { + return@apply } + improvements() + metric() + name() + regressions() + unit() + diff() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -107,7 +103,6 @@ class MetricSummary @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [MetricSummary]. * * The following fields are required: - * * ```java * .improvements() * .metric() @@ -116,8 +111,7 @@ class MetricSummary @JsonCreator private constructor( * .unit() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [MetricSummary]. */ @@ -132,125 +126,89 @@ class MetricSummary @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metricSummary: MetricSummary) = - apply { - improvements = metricSummary.improvements - metric = metricSummary.metric - name = metricSummary.name - regressions = metricSummary.regressions - unit = metricSummary.unit - diff = metricSummary.diff - additionalProperties = metricSummary.additionalProperties.toMutableMap() - } + internal fun from(metricSummary: MetricSummary) = apply { + improvements = metricSummary.improvements + metric = metricSummary.metric + name = metricSummary.name + regressions = metricSummary.regressions + unit = metricSummary.unit + diff = metricSummary.diff + additionalProperties = metricSummary.additionalProperties.toMutableMap() + } /** Number of improvements in the metric */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) /** Number of improvements in the metric */ - fun improvements(improvements: JsonField) = - apply { - this.improvements = improvements - } + fun improvements(improvements: JsonField) = apply { this.improvements = improvements } /** Average metric across all examples */ fun metric(metric: Double) = metric(JsonField.of(metric)) /** Average metric across all examples */ - fun metric(metric: JsonField) = - apply { - this.metric = metric - } + fun metric(metric: JsonField) = apply { this.metric = metric } /** Name of the metric */ fun name(name: String) = name(JsonField.of(name)) /** Name of the metric */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Number of regressions in the metric */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) /** Number of regressions in the metric */ - fun regressions(regressions: JsonField) = - apply { - this.regressions = regressions - } + fun regressions(regressions: JsonField) = apply { this.regressions = regressions } /** Unit label for the metric */ fun unit(unit: String) = unit(JsonField.of(unit)) /** Unit label for the metric */ - fun unit(unit: JsonField) = - apply { - this.unit = unit - } + fun unit(unit: JsonField) = apply { this.unit = unit } /** Difference in metric between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) /** Difference in metric between the current and comparison experiment */ - fun diff(diff: JsonField) = - apply { - this.diff = diff - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun diff(diff: JsonField) = apply { this.diff = diff } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MetricSummary = MetricSummary( - checkRequired( - "improvements", improvements - ), - checkRequired( - "metric", metric - ), - checkRequired( - "name", name - ), - checkRequired( - "regressions", regressions - ), - checkRequired( - "unit", unit - ), - diff, - additionalProperties.toImmutable(), + checkRequired("improvements", improvements), + checkRequired("metric", metric), + checkRequired("name", name), + checkRequired("regressions", regressions), + checkRequired("unit", unit), + diff, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MetricSummary && improvements == other.improvements && metric == other.metric && name == other.name && regressions == other.regressions && unit == other.unit && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MetricSummary && improvements == other.improvements && metric == other.metric && name == other.name && regressions == other.regressions && unit == other.unit && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -259,5 +217,6 @@ class MetricSummary @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "MetricSummary{improvements=$improvements, metric=$metric, name=$name, regressions=$regressions, unit=$unit, diff=$diff, additionalProperties=$additionalProperties}" + override fun toString() = + "MetricSummary{improvements=$improvements, metric=$metric, name=$name, regressions=$regressions, unit=$unit, diff=$diff, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index f88b718b..6eb781e8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -32,13 +32,22 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class OnlineScoreConfig @JsonCreator private constructor( - @JsonProperty("sampling_rate") @ExcludeMissing private val samplingRate: JsonField = JsonMissing.of(), - @JsonProperty("scorers") @ExcludeMissing private val scorers: JsonField> = JsonMissing.of(), - @JsonProperty("apply_to_root_span") @ExcludeMissing private val applyToRootSpan: JsonField = JsonMissing.of(), - @JsonProperty("apply_to_span_names") @ExcludeMissing private val applyToSpanNames: JsonField> = JsonMissing.of(), +class OnlineScoreConfig +@JsonCreator +private constructor( + @JsonProperty("sampling_rate") + @ExcludeMissing + private val samplingRate: JsonField = JsonMissing.of(), + @JsonProperty("scorers") + @ExcludeMissing + private val scorers: JsonField> = JsonMissing.of(), + @JsonProperty("apply_to_root_span") + @ExcludeMissing + private val applyToRootSpan: JsonField = JsonMissing.of(), + @JsonProperty("apply_to_span_names") + @ExcludeMissing + private val applyToSpanNames: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** The sampling rate for online scoring */ @@ -48,10 +57,12 @@ class OnlineScoreConfig @JsonCreator private constructor( fun scorers(): List = scorers.getRequired("scorers") /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(): Optional = Optional.ofNullable(applyToRootSpan.getNullable("apply_to_root_span")) + fun applyToRootSpan(): Optional = + Optional.ofNullable(applyToRootSpan.getNullable("apply_to_root_span")) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(): Optional> = Optional.ofNullable(applyToSpanNames.getNullable("apply_to_span_names")) + fun applyToSpanNames(): Optional> = + Optional.ofNullable(applyToSpanNames.getNullable("apply_to_span_names")) /** The sampling rate for online scoring */ @JsonProperty("sampling_rate") @@ -59,9 +70,7 @@ class OnlineScoreConfig @JsonCreator private constructor( fun _samplingRate(): JsonField = samplingRate /** The list of scorers to use for online scoring */ - @JsonProperty("scorers") - @ExcludeMissing - fun _scorers(): JsonField> = scorers + @JsonProperty("scorers") @ExcludeMissing fun _scorers(): JsonField> = scorers /** Whether to trigger online scoring on the root span of each trace */ @JsonProperty("apply_to_root_span") @@ -79,19 +88,18 @@ class OnlineScoreConfig @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): OnlineScoreConfig = - apply { - if (validated) { - return@apply - } - - samplingRate() - scorers().forEach { it.validate() } - applyToRootSpan() - applyToSpanNames() - validated = true + fun validate(): OnlineScoreConfig = apply { + if (validated) { + return@apply } + samplingRate() + scorers().forEach { it.validate() } + applyToRootSpan() + applyToSpanNames() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -100,14 +108,12 @@ class OnlineScoreConfig @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [OnlineScoreConfig]. * * The following fields are required: - * * ```java * .samplingRate() * .scorers() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [OnlineScoreConfig]. */ @@ -120,40 +126,37 @@ class OnlineScoreConfig @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(onlineScoreConfig: OnlineScoreConfig) = - apply { - samplingRate = onlineScoreConfig.samplingRate - scorers = onlineScoreConfig.scorers.map { it.toMutableList() } - applyToRootSpan = onlineScoreConfig.applyToRootSpan - applyToSpanNames = onlineScoreConfig.applyToSpanNames.map { it.toMutableList() } - additionalProperties = onlineScoreConfig.additionalProperties.toMutableMap() - } + internal fun from(onlineScoreConfig: OnlineScoreConfig) = apply { + samplingRate = onlineScoreConfig.samplingRate + scorers = onlineScoreConfig.scorers.map { it.toMutableList() } + applyToRootSpan = onlineScoreConfig.applyToRootSpan + applyToSpanNames = onlineScoreConfig.applyToSpanNames.map { it.toMutableList() } + additionalProperties = onlineScoreConfig.additionalProperties.toMutableMap() + } /** The sampling rate for online scoring */ fun samplingRate(samplingRate: Double) = samplingRate(JsonField.of(samplingRate)) /** The sampling rate for online scoring */ - fun samplingRate(samplingRate: JsonField) = - apply { - this.samplingRate = samplingRate - } + fun samplingRate(samplingRate: JsonField) = apply { + this.samplingRate = samplingRate + } /** The list of scorers to use for online scoring */ fun scorers(scorers: List) = scorers(JsonField.of(scorers)) /** The list of scorers to use for online scoring */ - fun scorers(scorers: JsonField>) = - apply { - this.scorers = scorers.map { it.toMutableList() } - } + fun scorers(scorers: JsonField>) = apply { + this.scorers = scorers.map { it.toMutableList() } + } /** The list of scorers to use for online scoring */ - fun addScorer(scorer: Scorer) = - apply { - scorers = (scorers ?: JsonField.of(mutableListOf())).also { + fun addScorer(scorer: Scorer) = apply { + scorers = + (scorers ?: JsonField.of(mutableListOf())).also { checkKnown("scorers", it).add(scorer) } - } + } /** The list of scorers to use for online scoring */ fun addScorer(function: Scorer.Function) = addScorer(Scorer.ofFunction(function)) @@ -162,87 +165,78 @@ class OnlineScoreConfig @JsonCreator private constructor( fun addScorer(global: Scorer.Global) = addScorer(Scorer.ofGlobal(global)) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: Boolean?) = applyToRootSpan(JsonField.ofNullable(applyToRootSpan)) + fun applyToRootSpan(applyToRootSpan: Boolean?) = + applyToRootSpan(JsonField.ofNullable(applyToRootSpan)) /** Whether to trigger online scoring on the root span of each trace */ fun applyToRootSpan(applyToRootSpan: Boolean) = applyToRootSpan(applyToRootSpan as Boolean?) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: Optional) = applyToRootSpan(applyToRootSpan.getOrNull()) + fun applyToRootSpan(applyToRootSpan: Optional) = + applyToRootSpan(applyToRootSpan.getOrNull()) /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: JsonField) = - apply { - this.applyToRootSpan = applyToRootSpan - } + fun applyToRootSpan(applyToRootSpan: JsonField) = apply { + this.applyToRootSpan = applyToRootSpan + } /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: List?) = applyToSpanNames(JsonField.ofNullable(applyToSpanNames)) + fun applyToSpanNames(applyToSpanNames: List?) = + applyToSpanNames(JsonField.ofNullable(applyToSpanNames)) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: Optional>) = applyToSpanNames(applyToSpanNames.getOrNull()) + fun applyToSpanNames(applyToSpanNames: Optional>) = + applyToSpanNames(applyToSpanNames.getOrNull()) /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: JsonField>) = - apply { - this.applyToSpanNames = applyToSpanNames.map { it.toMutableList() } - } + fun applyToSpanNames(applyToSpanNames: JsonField>) = apply { + this.applyToSpanNames = applyToSpanNames.map { it.toMutableList() } + } /** Trigger online scoring on any spans with a name in this list */ - fun addApplyToSpanName(applyToSpanName: String) = - apply { - applyToSpanNames = (applyToSpanNames ?: JsonField.of(mutableListOf())).also { + fun addApplyToSpanName(applyToSpanName: String) = apply { + applyToSpanNames = + (applyToSpanNames ?: JsonField.of(mutableListOf())).also { checkKnown("applyToSpanNames", it).add(applyToSpanName) } - } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): OnlineScoreConfig = OnlineScoreConfig( - checkRequired( - "samplingRate", samplingRate - ), - checkRequired( - "scorers", scorers - ).map { it.toImmutable() }, - applyToRootSpan, - (applyToSpanNames ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("samplingRate", samplingRate), + checkRequired("scorers", scorers).map { it.toImmutable() }, + applyToRootSpan, + (applyToSpanNames ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Scorer.Deserializer::class) @JsonSerialize(using = Scorer.Serializer::class) - class Scorer private constructor( + class Scorer + private constructor( private val function: Function? = null, private val global: Global? = null, private val _json: JsonValue? = null, - ) { fun function(): Optional = Optional.ofNullable(function) @@ -260,39 +254,40 @@ class OnlineScoreConfig @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - function != null -> visitor.visitFunction(function) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + function != null -> visitor.visitFunction(function) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Scorer = - apply { - if (validated) { - return@apply - } + fun validate(): Scorer = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scorer && function == other.function && global == other.global /* spotless:on */ + return /* spotless:off */ other is Scorer && function == other.function && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(function, global) /* spotless:on */ @@ -307,17 +302,12 @@ class OnlineScoreConfig @JsonCreator private constructor( companion object { - @JvmStatic - fun ofFunction(function: Function) = Scorer(function = function) + @JvmStatic fun ofFunction(function: Function) = Scorer(function = function) - @JvmStatic - fun ofGlobal(global: Global) = Scorer(global = global) + @JvmStatic fun ofGlobal(global: Global) = Scorer(global = global) } - /** - * An interface that defines how to map each variant of [Scorer] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Scorer] to a value of type [T]. */ interface Visitor { fun visitFunction(function: Function): T @@ -327,65 +317,73 @@ class OnlineScoreConfig @JsonCreator private constructor( /** * Maps an unknown variant of [Scorer] to a value of type [T]. * - * An instance of [Scorer] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Scorer] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Scorer: $json") + throw BraintrustInvalidDataException("Unknown Scorer: $json") } } internal class Deserializer : BaseDeserializer(Scorer::class) { override fun ObjectCodec.deserialize(node: JsonNode): Scorer { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Scorer(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Scorer(global = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Scorer(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Scorer(global = it, _json = json) + } - return Scorer(_json = json) + return Scorer(_json = json) } } internal class Serializer : BaseSerializer(Scorer::class) { - override fun serialize(value: Scorer, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.function != null -> generator.writeObject(value.function) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Scorer") - } + override fun serialize( + value: Scorer, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.function != null -> generator.writeObject(value.function) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Scorer") + } } } @NoAutoDetect - class Function @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Function + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun id(): String = id.getRequired("id") fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -393,17 +391,16 @@ class OnlineScoreConfig @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - id() - type() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + id() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -412,14 +409,12 @@ class OnlineScoreConfig @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .id() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ @@ -430,69 +425,52 @@ class OnlineScoreConfig @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - id = function.id - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + id = function.id + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "id", id - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -502,8 +480,7 @@ class OnlineScoreConfig @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -514,23 +491,23 @@ class OnlineScoreConfig @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** * 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 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 { FUNCTION, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -554,7 +531,7 @@ class OnlineScoreConfig @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -569,16 +546,19 @@ class OnlineScoreConfig @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -587,11 +567,11 @@ class OnlineScoreConfig @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -600,28 +580,31 @@ class OnlineScoreConfig @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Global + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -629,17 +612,16 @@ class OnlineScoreConfig @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Global = - apply { - if (validated) { - return@apply - } - - name() - type() - validated = true + fun validate(): Global = apply { + if (validated) { + return@apply } + name() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -648,14 +630,12 @@ class OnlineScoreConfig @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: - * * ```java * .name() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Global]. */ @@ -666,69 +646,52 @@ class OnlineScoreConfig @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = - apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired( - "name", name - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -738,8 +701,7 @@ class OnlineScoreConfig @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -750,23 +712,23 @@ class OnlineScoreConfig @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** * 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 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 { GLOBAL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -790,7 +752,7 @@ class OnlineScoreConfig @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -805,16 +767,19 @@ class OnlineScoreConfig @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -823,11 +788,11 @@ class OnlineScoreConfig @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -836,16 +801,17 @@ class OnlineScoreConfig @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OnlineScoreConfig && samplingRate == other.samplingRate && scorers == other.scorers && applyToRootSpan == other.applyToRootSpan && applyToSpanNames == other.applyToSpanNames && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OnlineScoreConfig && samplingRate == other.samplingRate && scorers == other.scorers && applyToRootSpan == other.applyToRootSpan && applyToSpanNames == other.applyToSpanNames && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -854,5 +820,6 @@ class OnlineScoreConfig @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" + override fun toString() = + "OnlineScoreConfig{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 9fc9931a..584931b5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -20,16 +20,27 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Organization @JsonCreator private constructor( +class Organization +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("api_url") @ExcludeMissing private val apiUrl: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("is_universal_api") @ExcludeMissing private val isUniversalApi: JsonField = JsonMissing.of(), - @JsonProperty("proxy_url") @ExcludeMissing private val proxyUrl: JsonField = JsonMissing.of(), - @JsonProperty("realtime_url") @ExcludeMissing private val realtimeUrl: JsonField = JsonMissing.of(), + @JsonProperty("api_url") + @ExcludeMissing + private val apiUrl: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("is_universal_api") + @ExcludeMissing + private val isUniversalApi: JsonField = JsonMissing.of(), + @JsonProperty("proxy_url") + @ExcludeMissing + private val proxyUrl: JsonField = JsonMissing.of(), + @JsonProperty("realtime_url") + @ExcludeMissing + private val realtimeUrl: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the organization */ @@ -43,38 +54,30 @@ class Organization @JsonCreator private constructor( /** Date of organization creation */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + fun isUniversalApi(): Optional = + Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) - fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + fun realtimeUrl(): Optional = + Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) /** Unique identifier for the organization */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the organization */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("api_url") - @ExcludeMissing - fun _apiUrl(): JsonField = apiUrl + @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl /** Date of organization creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi(): JsonField = isUniversalApi - @JsonProperty("proxy_url") - @ExcludeMissing - fun _proxyUrl(): JsonField = proxyUrl + @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl @JsonProperty("realtime_url") @ExcludeMissing @@ -86,22 +89,21 @@ class Organization @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Organization = - apply { - if (validated) { - return@apply - } - - id() - name() - apiUrl() - created() - isUniversalApi() - proxyUrl() - realtimeUrl() - validated = true + fun validate(): Organization = apply { + if (validated) { + return@apply } + id() + name() + apiUrl() + created() + isUniversalApi() + proxyUrl() + realtimeUrl() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -110,14 +112,12 @@ class Organization @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Organization]. * * The following fields are required: - * * ```java * .id() * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Organization]. */ @@ -133,44 +133,34 @@ class Organization @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(organization: Organization) = - apply { - id = organization.id - name = organization.name - apiUrl = organization.apiUrl - created = organization.created - isUniversalApi = organization.isUniversalApi - proxyUrl = organization.proxyUrl - realtimeUrl = organization.realtimeUrl - additionalProperties = organization.additionalProperties.toMutableMap() - } + internal fun from(organization: Organization) = apply { + id = organization.id + name = organization.name + apiUrl = organization.apiUrl + created = organization.created + isUniversalApi = organization.isUniversalApi + proxyUrl = organization.proxyUrl + realtimeUrl = organization.realtimeUrl + additionalProperties = organization.additionalProperties.toMutableMap() + } /** Unique identifier for the organization */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the organization */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the organization */ fun name(name: String) = name(JsonField.of(name)) /** Name of the organization */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = - apply { - this.apiUrl = apiUrl - } + fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } /** Date of organization creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -179,89 +169,70 @@ class Organization @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of organization creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } - fun isUniversalApi(isUniversalApi: Boolean?) = isUniversalApi(JsonField.ofNullable(isUniversalApi)) + fun isUniversalApi(isUniversalApi: Boolean?) = + isUniversalApi(JsonField.ofNullable(isUniversalApi)) fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = + isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = - apply { - this.isUniversalApi = isUniversalApi - } + fun isUniversalApi(isUniversalApi: JsonField) = apply { + this.isUniversalApi = isUniversalApi + } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = - apply { - this.proxyUrl = proxyUrl - } + fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = - apply { - this.realtimeUrl = realtimeUrl - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Organization = Organization( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - apiUrl, - created, - isUniversalApi, - proxyUrl, - realtimeUrl, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + apiUrl, + created, + isUniversalApi, + proxyUrl, + realtimeUrl, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && created == other.created && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Organization && id == other.id && name == other.name && apiUrl == other.apiUrl && created == other.created && isUniversalApi == other.isUniversalApi && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -270,5 +241,6 @@ class Organization @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Organization{id=$id, name=$name, apiUrl=$apiUrl, created=$created, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + override fun toString() = + "Organization{id=$id, name=$name, apiUrl=$apiUrl, created=$created, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index cf0c7530..ba3170a9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete an organization object by its id */ -class OrganizationDeleteParams private constructor( +class OrganizationDeleteParams +private constructor( private val organizationId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Organization id */ @@ -31,17 +31,18 @@ class OrganizationDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -49,17 +50,14 @@ class OrganizationDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [OrganizationDeleteParams]. + * Returns a mutable builder for constructing an instance of [OrganizationDeleteParams]. * * The following fields are required: - * * ```java * .organizationId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [OrganizationDeleteParams]. */ @@ -72,190 +70,156 @@ class OrganizationDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(organizationDeleteParams: OrganizationDeleteParams) = - apply { - organizationId = organizationDeleteParams.organizationId - additionalHeaders = organizationDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = organizationDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(organizationDeleteParams: OrganizationDeleteParams) = apply { + organizationId = organizationDeleteParams.organizationId + additionalHeaders = organizationDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + organizationDeleteParams.additionalBodyProperties.toMutableMap() + } /** Organization id */ - fun organizationId(organizationId: String) = - apply { - this.organizationId = organizationId - } + fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): OrganizationDeleteParams = OrganizationDeleteParams( - checkRequired( - "organizationId", organizationId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("organizationId", organizationId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is OrganizationDeleteParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "OrganizationDeleteParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index ecad5972..8bff63be 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.OrganizationService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ -class OrganizationListPage private constructor( +class OrganizationListPage +private constructor( private val organizationsService: OrganizationService, private val params: OrganizationListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class OrganizationListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListPage && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is OrganizationListPage && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ - override fun toString() = "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" + override fun toString() = + "OrganizationListPage{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + OrganizationListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + OrganizationListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { organizationsService.list(it) } + return getNextPageParams().map { organizationsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -73,19 +83,21 @@ class OrganizationListPage private constructor( companion object { @JvmStatic - fun of(organizationsService: OrganizationService, params: OrganizationListParams, response: Response) = - OrganizationListPage( - organizationsService, - params, - response, - ) + fun of( + organizationsService: OrganizationService, + params: OrganizationListParams, + response: Response, + ) = OrganizationListPage(organizationsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,38 +111,34 @@ class OrganizationListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** - * Returns a mutable builder for constructing an instance of - * [OrganizationListPage]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [OrganizationListPage]. */ + @JvmStatic fun builder() = Builder() } class Builder { @@ -139,48 +147,39 @@ class OrganizationListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: OrganizationListPage, + class AutoPager(private val firstPage: OrganizationListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index 66136ad2..cdc6536a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.OrganizationServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ -class OrganizationListPageAsync private constructor( +class OrganizationListPageAsync +private constructor( private val organizationsService: OrganizationServiceAsync, private val params: OrganizationListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class OrganizationListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListPageAsync && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is OrganizationListPageAsync && organizationsService == other.organizationsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationsService, params, response) /* spotless:on */ - override fun toString() = "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" + override fun toString() = + "OrganizationListPageAsync{organizationsService=$organizationsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + OrganizationListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + OrganizationListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - organizationsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { organizationsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,21 @@ class OrganizationListPageAsync private constructor( companion object { @JvmStatic - fun of(organizationsService: OrganizationServiceAsync, params: OrganizationListParams, response: Response) = - OrganizationListPageAsync( - organizationsService, - params, - response, - ) + fun of( + organizationsService: OrganizationServiceAsync, + params: OrganizationListParams, + response: Response, + ) = OrganizationListPageAsync(organizationsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,29 +113,29 @@ class OrganizationListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -136,8 +143,7 @@ class OrganizationListPageAsync private constructor( * Returns a mutable builder for constructing an instance of * [OrganizationListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +152,46 @@ class OrganizationListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: OrganizationListPageAsync, - - ) { + class AutoPager(private val firstPage: OrganizationListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Organization) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Organization) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 030263de..d01ebbf0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ -class OrganizationListParams private constructor( +class OrganizationListParams +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -34,21 +35,20 @@ class OrganizationListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -61,9 +61,9 @@ class OrganizationListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -74,49 +74,24 @@ class OrganizationListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): OrganizationListParams = builder().build() + @JvmStatic fun none(): OrganizationListParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of - * [OrganizationListParams]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [OrganizationListParams]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [OrganizationListParams]. */ @@ -132,70 +107,60 @@ class OrganizationListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationListParams: OrganizationListParams) = - apply { - endingBefore = organizationListParams.endingBefore - ids = organizationListParams.ids - limit = organizationListParams.limit - orgName = organizationListParams.orgName - startingAfter = organizationListParams.startingAfter - additionalHeaders = organizationListParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationListParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationListParams: OrganizationListParams) = apply { + endingBefore = organizationListParams.endingBefore + ids = organizationListParams.ids + limit = organizationListParams.limit + orgName = organizationListParams.orgName + startingAfter = organizationListParams.startingAfter + additionalHeaders = organizationListParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -204,10 +169,7 @@ class OrganizationListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -215,171 +177,143 @@ class OrganizationListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationListParams = OrganizationListParams( - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -397,19 +331,19 @@ class OrganizationListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -424,17 +358,12 @@ class OrganizationListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -444,56 +373,60 @@ class OrganizationListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 8c4a6abb..f75b1abe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -22,29 +22,27 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Modify organization membership */ -class OrganizationMemberUpdateParams private constructor( +class OrganizationMemberUpdateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Users to invite to the organization */ fun inviteUsers(): Optional = body.inviteUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the id of the organization. */ fun orgId(): Optional = body.orgId() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the name of the organization. */ fun orgName(): Optional = body.orgName() @@ -55,18 +53,16 @@ class OrganizationMemberUpdateParams private constructor( fun _inviteUsers(): JsonField = body._inviteUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the id of the organization. */ fun _orgId(): JsonField = body._orgId() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, or in case you want to explicitly assert the + * organization you are modifying, you may specify the name of the organization. */ fun _orgName(): JsonField = body._orgName() @@ -79,44 +75,53 @@ class OrganizationMemberUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("invite_users") @ExcludeMissing private val inviteUsers: JsonField = JsonMissing.of(), - @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonProperty("remove_users") @ExcludeMissing private val removeUsers: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("invite_users") + @ExcludeMissing + private val inviteUsers: JsonField = JsonMissing.of(), + @JsonProperty("org_id") + @ExcludeMissing + private val orgId: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonProperty("remove_users") + @ExcludeMissing + private val removeUsers: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Users to invite to the organization */ - fun inviteUsers(): Optional = Optional.ofNullable(inviteUsers.getNullable("invite_users")) + fun inviteUsers(): Optional = + Optional.ofNullable(inviteUsers.getNullable("invite_users")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Users to remove from the organization */ - fun removeUsers(): Optional = Optional.ofNullable(removeUsers.getNullable("remove_users")) + fun removeUsers(): Optional = + Optional.ofNullable(removeUsers.getNullable("remove_users")) /** Users to invite to the organization */ @JsonProperty("invite_users") @@ -124,24 +129,18 @@ class OrganizationMemberUpdateParams private constructor( fun _inviteUsers(): JsonField = inviteUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName /** Users to remove from the organization */ @JsonProperty("remove_users") @@ -154,26 +153,24 @@ class OrganizationMemberUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - inviteUsers().ifPresent { it.validate() } - orgId() - orgName() - removeUsers().ifPresent { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + inviteUsers().ifPresent { it.validate() } + orgId() + orgName() + removeUsers().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -186,135 +183,117 @@ class OrganizationMemberUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - inviteUsers = body.inviteUsers - orgId = body.orgId - orgName = body.orgName - removeUsers = body.removeUsers - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + inviteUsers = body.inviteUsers + orgId = body.orgId + orgName = body.orgName + removeUsers = body.removeUsers + additionalProperties = body.additionalProperties.toMutableMap() + } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers?) = inviteUsers(JsonField.ofNullable(inviteUsers)) + fun inviteUsers(inviteUsers: InviteUsers?) = + inviteUsers(JsonField.ofNullable(inviteUsers)) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) + fun inviteUsers(inviteUsers: Optional) = + inviteUsers(inviteUsers.getOrNull()) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: JsonField) = - apply { - this.inviteUsers = inviteUsers - } + fun inviteUsers(inviteUsers: JsonField) = apply { + this.inviteUsers = inviteUsers + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the id of the + * organization. */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the id of the + * organization. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the id of the + * organization. */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the name of the + * organization. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the name of the + * organization. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly + * assert the organization you are modifying, you may specify the name of the + * organization. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers?) = removeUsers(JsonField.ofNullable(removeUsers)) + fun removeUsers(removeUsers: RemoveUsers?) = + removeUsers(JsonField.ofNullable(removeUsers)) /** Users to remove from the organization */ - fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) + fun removeUsers(removeUsers: Optional) = + removeUsers(removeUsers.getOrNull()) /** Users to remove from the organization */ - fun removeUsers(removeUsers: JsonField) = - apply { - this.removeUsers = removeUsers - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeUsers(removeUsers: JsonField) = apply { + this.removeUsers = removeUsers + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalProperties.toImmutable(), - ) + Body(inviteUsers, orgId, orgName, removeUsers, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && inviteUsers == other.inviteUsers && orgId == other.orgId && orgName == other.orgName && removeUsers == other.removeUsers && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -323,22 +302,21 @@ class OrganizationMemberUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): OrganizationMemberUpdateParams = builder().build() + @JvmStatic fun none(): OrganizationMemberUpdateParams = builder().build() /** * Returns a mutable builder for constructing an instance of * [OrganizationMemberUpdateParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [OrganizationMemberUpdateParams]. */ @@ -350,274 +328,229 @@ class OrganizationMemberUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = - apply { - body = organizationMemberUpdateParams.body.toBuilder() - additionalHeaders = organizationMemberUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationMemberUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationMemberUpdateParams: OrganizationMemberUpdateParams) = apply { + body = organizationMemberUpdateParams.body.toBuilder() + additionalHeaders = organizationMemberUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationMemberUpdateParams.additionalQueryParams.toBuilder() + } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers?) = - apply { - body.inviteUsers(inviteUsers) - } + fun inviteUsers(inviteUsers: InviteUsers?) = apply { body.inviteUsers(inviteUsers) } /** Users to invite to the organization */ fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: JsonField) = - apply { - body.inviteUsers(inviteUsers) - } + fun inviteUsers(inviteUsers: JsonField) = apply { + body.inviteUsers(inviteUsers) + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. */ - fun orgId(orgId: String?) = - apply { - body.orgId(orgId) - } + fun orgId(orgId: String?) = apply { body.orgId(orgId) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the id of - * the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the id of the organization. */ - fun orgId(orgId: JsonField) = - apply { - body.orgId(orgId) - } + fun orgId(orgId: JsonField) = apply { body.orgId(orgId) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, or in case you want to - * explicitly assert the organization you are modifying, you may specify the name - * of the organization. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, or in case you want to explicitly assert + * the organization you are modifying, you may specify the name of the organization. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers?) = - apply { - body.removeUsers(removeUsers) - } + fun removeUsers(removeUsers: RemoveUsers?) = apply { body.removeUsers(removeUsers) } /** Users to remove from the organization */ fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) /** Users to remove from the organization */ - fun removeUsers(removeUsers: JsonField) = - apply { - body.removeUsers(removeUsers) - } + fun removeUsers(removeUsers: JsonField) = apply { + body.removeUsers(removeUsers) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationMemberUpdateParams = OrganizationMemberUpdateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** Users to invite to the organization */ @NoAutoDetect - class InviteUsers @JsonCreator private constructor( - @JsonProperty("emails") @ExcludeMissing private val emails: JsonField> = JsonMissing.of(), - @JsonProperty("group_id") @ExcludeMissing private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("group_ids") @ExcludeMissing private val groupIds: JsonField> = JsonMissing.of(), - @JsonProperty("group_name") @ExcludeMissing private val groupName: JsonField = JsonMissing.of(), - @JsonProperty("group_names") @ExcludeMissing private val groupNames: JsonField> = JsonMissing.of(), - @JsonProperty("ids") @ExcludeMissing private val ids: JsonField> = JsonMissing.of(), - @JsonProperty("send_invite_emails") @ExcludeMissing private val sendInviteEmails: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InviteUsers + @JsonCreator + private constructor( + @JsonProperty("emails") + @ExcludeMissing + private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("group_ids") + @ExcludeMissing + private val groupIds: JsonField> = JsonMissing.of(), + @JsonProperty("group_name") + @ExcludeMissing + private val groupName: JsonField = JsonMissing.of(), + @JsonProperty("group_names") + @ExcludeMissing + private val groupNames: JsonField> = JsonMissing.of(), + @JsonProperty("ids") + @ExcludeMissing + private val ids: JsonField> = JsonMissing.of(), + @JsonProperty("send_invite_emails") + @ExcludeMissing + private val sendInviteEmails: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Emails of users to invite */ @@ -627,29 +560,28 @@ class OrganizationMemberUpdateParams private constructor( fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) /** Optional list of group ids to add newly-invited users to. */ - fun groupIds(): Optional> = Optional.ofNullable(groupIds.getNullable("group_ids")) + fun groupIds(): Optional> = + Optional.ofNullable(groupIds.getNullable("group_ids")) /** Singular form of group_names */ fun groupName(): Optional = Optional.ofNullable(groupName.getNullable("group_name")) /** Optional list of group names to add newly-invited users to. */ - fun groupNames(): Optional> = Optional.ofNullable(groupNames.getNullable("group_names")) + fun groupNames(): Optional> = + Optional.ofNullable(groupNames.getNullable("group_names")) /** Ids of existing users to invite */ fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(): Optional = Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) + fun sendInviteEmails(): Optional = + Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) /** Emails of users to invite */ - @JsonProperty("emails") - @ExcludeMissing - fun _emails(): JsonField> = emails + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails /** Singular form of group_ids */ - @JsonProperty("group_id") - @ExcludeMissing - fun _groupId(): JsonField = groupId + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId /** Optional list of group ids to add newly-invited users to. */ @JsonProperty("group_ids") @@ -657,9 +589,7 @@ class OrganizationMemberUpdateParams private constructor( fun _groupIds(): JsonField> = groupIds /** Singular form of group_names */ - @JsonProperty("group_name") - @ExcludeMissing - fun _groupName(): JsonField = groupName + @JsonProperty("group_name") @ExcludeMissing fun _groupName(): JsonField = groupName /** Optional list of group names to add newly-invited users to. */ @JsonProperty("group_names") @@ -667,9 +597,7 @@ class OrganizationMemberUpdateParams private constructor( fun _groupNames(): JsonField> = groupNames /** Ids of existing users to invite */ - @JsonProperty("ids") - @ExcludeMissing - fun _ids(): JsonField> = ids + @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids /** If true, send invite emails to the users who wore actually added */ @JsonProperty("send_invite_emails") @@ -682,29 +610,27 @@ class OrganizationMemberUpdateParams private constructor( private var validated: Boolean = false - fun validate(): InviteUsers = - apply { - if (validated) { - return@apply - } - - emails() - groupId() - groupIds() - groupName() - groupNames() - ids() - sendInviteEmails() - validated = true + fun validate(): InviteUsers = apply { + if (validated) { + return@apply } + emails() + groupId() + groupIds() + groupName() + groupNames() + ids() + sendInviteEmails() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [InviteUsers]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InviteUsers]. */ @@ -720,17 +646,16 @@ class OrganizationMemberUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(inviteUsers: InviteUsers) = - apply { - emails = inviteUsers.emails.map { it.toMutableList() } - groupId = inviteUsers.groupId - groupIds = inviteUsers.groupIds.map { it.toMutableList() } - groupName = inviteUsers.groupName - groupNames = inviteUsers.groupNames.map { it.toMutableList() } - ids = inviteUsers.ids.map { it.toMutableList() } - sendInviteEmails = inviteUsers.sendInviteEmails - additionalProperties = inviteUsers.additionalProperties.toMutableMap() - } + internal fun from(inviteUsers: InviteUsers) = apply { + emails = inviteUsers.emails.map { it.toMutableList() } + groupId = inviteUsers.groupId + groupIds = inviteUsers.groupIds.map { it.toMutableList() } + groupName = inviteUsers.groupName + groupNames = inviteUsers.groupNames.map { it.toMutableList() } + ids = inviteUsers.ids.map { it.toMutableList() } + sendInviteEmails = inviteUsers.sendInviteEmails + additionalProperties = inviteUsers.additionalProperties.toMutableMap() + } /** Emails of users to invite */ fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) @@ -739,18 +664,17 @@ class OrganizationMemberUpdateParams private constructor( fun emails(emails: Optional>) = emails(emails.getOrNull()) /** Emails of users to invite */ - fun emails(emails: JsonField>) = - apply { - this.emails = emails.map { it.toMutableList() } - } + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } /** Emails of users to invite */ - fun addEmail(email: String) = - apply { - emails = (emails ?: JsonField.of(mutableListOf())).also { + fun addEmail(email: String) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).also { checkKnown("emails", it).add(email) } - } + } /** Singular form of group_ids */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) @@ -759,10 +683,7 @@ class OrganizationMemberUpdateParams private constructor( fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** Singular form of group_ids */ - fun groupId(groupId: JsonField) = - apply { - this.groupId = groupId - } + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** Optional list of group ids to add newly-invited users to. */ fun groupIds(groupIds: List?) = groupIds(JsonField.ofNullable(groupIds)) @@ -771,18 +692,17 @@ class OrganizationMemberUpdateParams private constructor( fun groupIds(groupIds: Optional>) = groupIds(groupIds.getOrNull()) /** Optional list of group ids to add newly-invited users to. */ - fun groupIds(groupIds: JsonField>) = - apply { - this.groupIds = groupIds.map { it.toMutableList() } - } + fun groupIds(groupIds: JsonField>) = apply { + this.groupIds = groupIds.map { it.toMutableList() } + } /** Optional list of group ids to add newly-invited users to. */ - fun addGroupId(groupId: String) = - apply { - groupIds = (groupIds ?: JsonField.of(mutableListOf())).also { + fun addGroupId(groupId: String) = apply { + groupIds = + (groupIds ?: JsonField.of(mutableListOf())).also { checkKnown("groupIds", it).add(groupId) } - } + } /** Singular form of group_names */ fun groupName(groupName: String?) = groupName(JsonField.ofNullable(groupName)) @@ -791,10 +711,7 @@ class OrganizationMemberUpdateParams private constructor( fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** Singular form of group_names */ - fun groupName(groupName: JsonField) = - apply { - this.groupName = groupName - } + fun groupName(groupName: JsonField) = apply { this.groupName = groupName } /** Optional list of group names to add newly-invited users to. */ fun groupNames(groupNames: List?) = groupNames(JsonField.ofNullable(groupNames)) @@ -803,18 +720,17 @@ class OrganizationMemberUpdateParams private constructor( fun groupNames(groupNames: Optional>) = groupNames(groupNames.getOrNull()) /** Optional list of group names to add newly-invited users to. */ - fun groupNames(groupNames: JsonField>) = - apply { - this.groupNames = groupNames.map { it.toMutableList() } - } + fun groupNames(groupNames: JsonField>) = apply { + this.groupNames = groupNames.map { it.toMutableList() } + } /** Optional list of group names to add newly-invited users to. */ - fun addGroupName(groupName: String) = - apply { - groupNames = (groupNames ?: JsonField.of(mutableListOf())).also { + fun addGroupName(groupName: String) = apply { + groupNames = + (groupNames ?: JsonField.of(mutableListOf())).also { checkKnown("groupNames", it).add(groupName) } - } + } /** Ids of existing users to invite */ fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) @@ -823,79 +739,70 @@ class OrganizationMemberUpdateParams private constructor( fun ids(ids: Optional>) = ids(ids.getOrNull()) /** Ids of existing users to invite */ - fun ids(ids: JsonField>) = - apply { - this.ids = ids.map { it.toMutableList() } - } + fun ids(ids: JsonField>) = apply { + this.ids = ids.map { it.toMutableList() } + } /** Ids of existing users to invite */ - fun addId(id: String) = - apply { - ids = (ids ?: JsonField.of(mutableListOf())).also { - checkKnown("ids", it).add(id) - } - } + fun addId(id: String) = apply { + ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } + } /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Boolean?) = sendInviteEmails(JsonField.ofNullable(sendInviteEmails)) + fun sendInviteEmails(sendInviteEmails: Boolean?) = + sendInviteEmails(JsonField.ofNullable(sendInviteEmails)) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Boolean) = sendInviteEmails(sendInviteEmails as Boolean?) + fun sendInviteEmails(sendInviteEmails: Boolean) = + sendInviteEmails(sendInviteEmails as Boolean?) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Optional) = sendInviteEmails(sendInviteEmails.getOrNull()) + fun sendInviteEmails(sendInviteEmails: Optional) = + sendInviteEmails(sendInviteEmails.getOrNull()) /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: JsonField) = - apply { - this.sendInviteEmails = sendInviteEmails - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun sendInviteEmails(sendInviteEmails: JsonField) = apply { + this.sendInviteEmails = sendInviteEmails + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InviteUsers = InviteUsers( - (emails ?: JsonMissing.of()).map { it.toImmutable() }, - groupId, - (groupIds ?: JsonMissing.of()).map { it.toImmutable() }, - groupName, - (groupNames ?: JsonMissing.of()).map { it.toImmutable() }, - (ids ?: JsonMissing.of()).map { it.toImmutable() }, - sendInviteEmails, - additionalProperties.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + groupId, + (groupIds ?: JsonMissing.of()).map { it.toImmutable() }, + groupName, + (groupNames ?: JsonMissing.of()).map { it.toImmutable() }, + (ids ?: JsonMissing.of()).map { it.toImmutable() }, + sendInviteEmails, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InviteUsers && emails == other.emails && groupId == other.groupId && groupIds == other.groupIds && groupName == other.groupName && groupNames == other.groupNames && ids == other.ids && sendInviteEmails == other.sendInviteEmails && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InviteUsers && emails == other.emails && groupId == other.groupId && groupIds == other.groupIds && groupName == other.groupName && groupNames == other.groupNames && ids == other.ids && sendInviteEmails == other.sendInviteEmails && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -904,16 +811,23 @@ class OrganizationMemberUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InviteUsers{emails=$emails, groupId=$groupId, groupIds=$groupIds, groupName=$groupName, groupNames=$groupNames, ids=$ids, sendInviteEmails=$sendInviteEmails, additionalProperties=$additionalProperties}" + override fun toString() = + "InviteUsers{emails=$emails, groupId=$groupId, groupIds=$groupIds, groupName=$groupName, groupNames=$groupNames, ids=$ids, sendInviteEmails=$sendInviteEmails, additionalProperties=$additionalProperties}" } /** Users to remove from the organization */ @NoAutoDetect - class RemoveUsers @JsonCreator private constructor( - @JsonProperty("emails") @ExcludeMissing private val emails: JsonField> = JsonMissing.of(), - @JsonProperty("ids") @ExcludeMissing private val ids: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RemoveUsers + @JsonCreator + private constructor( + @JsonProperty("emails") + @ExcludeMissing + private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("ids") + @ExcludeMissing + private val ids: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Emails of users to remove */ @@ -923,14 +837,10 @@ class OrganizationMemberUpdateParams private constructor( fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) /** Emails of users to remove */ - @JsonProperty("emails") - @ExcludeMissing - fun _emails(): JsonField> = emails + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails /** Ids of users to remove */ - @JsonProperty("ids") - @ExcludeMissing - fun _ids(): JsonField> = ids + @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids @JsonAnyGetter @ExcludeMissing @@ -938,24 +848,22 @@ class OrganizationMemberUpdateParams private constructor( private var validated: Boolean = false - fun validate(): RemoveUsers = - apply { - if (validated) { - return@apply - } - - emails() - ids() - validated = true + fun validate(): RemoveUsers = apply { + if (validated) { + return@apply } + emails() + ids() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [RemoveUsers]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RemoveUsers]. */ @@ -966,12 +874,11 @@ class OrganizationMemberUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeUsers: RemoveUsers) = - apply { - emails = removeUsers.emails.map { it.toMutableList() } - ids = removeUsers.ids.map { it.toMutableList() } - additionalProperties = removeUsers.additionalProperties.toMutableMap() - } + internal fun from(removeUsers: RemoveUsers) = apply { + emails = removeUsers.emails.map { it.toMutableList() } + ids = removeUsers.ids.map { it.toMutableList() } + additionalProperties = removeUsers.additionalProperties.toMutableMap() + } /** Emails of users to remove */ fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) @@ -980,18 +887,17 @@ class OrganizationMemberUpdateParams private constructor( fun emails(emails: Optional>) = emails(emails.getOrNull()) /** Emails of users to remove */ - fun emails(emails: JsonField>) = - apply { - this.emails = emails.map { it.toMutableList() } - } + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } /** Emails of users to remove */ - fun addEmail(email: String) = - apply { - emails = (emails ?: JsonField.of(mutableListOf())).also { + fun addEmail(email: String) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).also { checkKnown("emails", it).add(email) } - } + } /** Ids of users to remove */ fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) @@ -1000,59 +906,48 @@ class OrganizationMemberUpdateParams private constructor( fun ids(ids: Optional>) = ids(ids.getOrNull()) /** Ids of users to remove */ - fun ids(ids: JsonField>) = - apply { - this.ids = ids.map { it.toMutableList() } - } + fun ids(ids: JsonField>) = apply { + this.ids = ids.map { it.toMutableList() } + } /** Ids of users to remove */ - fun addId(id: String) = - apply { - ids = (ids ?: JsonField.of(mutableListOf())).also { - checkKnown("ids", it).add(id) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun addId(id: String) = apply { + ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveUsers = RemoveUsers( - (emails ?: JsonMissing.of()).map { it.toImmutable() }, - (ids ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + (ids ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveUsers && emails == other.emails && ids == other.ids && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveUsers && emails == other.emails && ids == other.ids && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1061,18 +956,20 @@ class OrganizationMemberUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RemoveUsers{emails=$emails, ids=$ids, additionalProperties=$additionalProperties}" + override fun toString() = + "RemoveUsers{emails=$emails, ids=$ids, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationMemberUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationMemberUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "OrganizationMemberUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "OrganizationMemberUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 75ac31bf..3d45ef35 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get an organization object by its id */ -class OrganizationRetrieveParams private constructor( +class OrganizationRetrieveParams +private constructor( private val organizationId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Organization id */ @@ -29,10 +29,10 @@ class OrganizationRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class OrganizationRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [OrganizationRetrieveParams]. + * Returns a mutable builder for constructing an instance of [OrganizationRetrieveParams]. * * The following fields are required: - * * ```java * .organizationId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [OrganizationRetrieveParams]. */ @@ -62,162 +59,131 @@ class OrganizationRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = - apply { - organizationId = organizationRetrieveParams.organizationId - additionalHeaders = organizationRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationRetrieveParams: OrganizationRetrieveParams) = apply { + organizationId = organizationRetrieveParams.organizationId + additionalHeaders = organizationRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationRetrieveParams.additionalQueryParams.toBuilder() + } /** Organization id */ - fun organizationId(organizationId: String) = - apply { - this.organizationId = organizationId - } + fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( - checkRequired( - "organizationId", organizationId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("organizationId", organizationId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationRetrieveParams && organizationId == other.organizationId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "OrganizationRetrieveParams{organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 07a403a7..83efeac1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update an organization object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ -class OrganizationUpdateParams private constructor( +class OrganizationUpdateParams +private constructor( private val organizationId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Organization id */ @@ -65,58 +65,65 @@ class OrganizationUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("api_url") @ExcludeMissing private val apiUrl: JsonField = JsonMissing.of(), - @JsonProperty("is_universal_api") @ExcludeMissing private val isUniversalApi: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("proxy_url") @ExcludeMissing private val proxyUrl: JsonField = JsonMissing.of(), - @JsonProperty("realtime_url") @ExcludeMissing private val realtimeUrl: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("api_url") + @ExcludeMissing + private val apiUrl: JsonField = JsonMissing.of(), + @JsonProperty("is_universal_api") + @ExcludeMissing + private val isUniversalApi: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("proxy_url") + @ExcludeMissing + private val proxyUrl: JsonField = JsonMissing.of(), + @JsonProperty("realtime_url") + @ExcludeMissing + private val realtimeUrl: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) - fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + fun isUniversalApi(): Optional = + Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) /** Name of the organization */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) - fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + fun realtimeUrl(): Optional = + Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) - @JsonProperty("api_url") - @ExcludeMissing - fun _apiUrl(): JsonField = apiUrl + @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi(): JsonField = isUniversalApi /** Name of the organization */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("proxy_url") - @ExcludeMissing - fun _proxyUrl(): JsonField = proxyUrl + @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl @JsonProperty("realtime_url") @ExcludeMissing @@ -128,27 +135,25 @@ class OrganizationUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - apiUrl() - isUniversalApi() - name() - proxyUrl() - realtimeUrl() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + apiUrl() + isUniversalApi() + name() + proxyUrl() + realtimeUrl() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -162,35 +167,32 @@ class OrganizationUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - apiUrl = body.apiUrl - isUniversalApi = body.isUniversalApi - name = body.name - proxyUrl = body.proxyUrl - realtimeUrl = body.realtimeUrl - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + apiUrl = body.apiUrl + isUniversalApi = body.isUniversalApi + name = body.name + proxyUrl = body.proxyUrl + realtimeUrl = body.realtimeUrl + additionalProperties = body.additionalProperties.toMutableMap() + } fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = - apply { - this.apiUrl = apiUrl - } + fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } - fun isUniversalApi(isUniversalApi: Boolean?) = isUniversalApi(JsonField.ofNullable(isUniversalApi)) + fun isUniversalApi(isUniversalApi: Boolean?) = + isUniversalApi(JsonField.ofNullable(isUniversalApi)) fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = + isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = - apply { - this.isUniversalApi = isUniversalApi - } + fun isUniversalApi(isUniversalApi: JsonField) = apply { + this.isUniversalApi = isUniversalApi + } /** Name of the organization */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -199,72 +201,58 @@ class OrganizationUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the organization */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = - apply { - this.proxyUrl = proxyUrl - } + fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = - apply { - this.realtimeUrl = realtimeUrl - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun realtimeUrl(realtimeUrl: JsonField) = apply { + this.realtimeUrl = realtimeUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalProperties.toImmutable(), + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && apiUrl == other.apiUrl && isUniversalApi == other.isUniversalApi && name == other.name && proxyUrl == other.proxyUrl && realtimeUrl == other.realtimeUrl && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -273,7 +261,8 @@ class OrganizationUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -281,17 +270,14 @@ class OrganizationUpdateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [OrganizationUpdateParams]. + * Returns a mutable builder for constructing an instance of [OrganizationUpdateParams]. * * The following fields are required: - * * ```java * .organizationId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [OrganizationUpdateParams]. */ @@ -304,256 +290,190 @@ class OrganizationUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(organizationUpdateParams: OrganizationUpdateParams) = - apply { - organizationId = organizationUpdateParams.organizationId - body = organizationUpdateParams.body.toBuilder() - additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(organizationUpdateParams: OrganizationUpdateParams) = apply { + organizationId = organizationUpdateParams.organizationId + body = organizationUpdateParams.body.toBuilder() + additionalHeaders = organizationUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = organizationUpdateParams.additionalQueryParams.toBuilder() + } /** Organization id */ - fun organizationId(organizationId: String) = - apply { - this.organizationId = organizationId - } + fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } - fun apiUrl(apiUrl: String?) = - apply { - body.apiUrl(apiUrl) - } + fun apiUrl(apiUrl: String?) = apply { body.apiUrl(apiUrl) } fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) - fun apiUrl(apiUrl: JsonField) = - apply { - body.apiUrl(apiUrl) - } + fun apiUrl(apiUrl: JsonField) = apply { body.apiUrl(apiUrl) } - fun isUniversalApi(isUniversalApi: Boolean?) = - apply { - body.isUniversalApi(isUniversalApi) - } + fun isUniversalApi(isUniversalApi: Boolean?) = apply { body.isUniversalApi(isUniversalApi) } fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) - fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) + fun isUniversalApi(isUniversalApi: Optional) = + isUniversalApi(isUniversalApi.getOrNull()) - fun isUniversalApi(isUniversalApi: JsonField) = - apply { - body.isUniversalApi(isUniversalApi) - } + fun isUniversalApi(isUniversalApi: JsonField) = apply { + body.isUniversalApi(isUniversalApi) + } /** Name of the organization */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the organization */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the organization */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } - fun proxyUrl(proxyUrl: String?) = - apply { - body.proxyUrl(proxyUrl) - } + fun proxyUrl(proxyUrl: String?) = apply { body.proxyUrl(proxyUrl) } fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) - fun proxyUrl(proxyUrl: JsonField) = - apply { - body.proxyUrl(proxyUrl) - } + fun proxyUrl(proxyUrl: JsonField) = apply { body.proxyUrl(proxyUrl) } - fun realtimeUrl(realtimeUrl: String?) = - apply { - body.realtimeUrl(realtimeUrl) - } + fun realtimeUrl(realtimeUrl: String?) = apply { body.realtimeUrl(realtimeUrl) } fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) - fun realtimeUrl(realtimeUrl: JsonField) = - apply { - body.realtimeUrl(realtimeUrl) - } + fun realtimeUrl(realtimeUrl: JsonField) = apply { body.realtimeUrl(realtimeUrl) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): OrganizationUpdateParams = OrganizationUpdateParams( - checkRequired( - "organizationId", organizationId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("organizationId", organizationId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is OrganizationUpdateParams && organizationId == other.organizationId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(organizationId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "OrganizationUpdateParams{organizationId=$organizationId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "OrganizationUpdateParams{organizationId=$organizationId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index 932a8cd1..c1bb28cb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -21,12 +21,17 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class PatchOrganizationMembersOutput @JsonCreator private constructor( +class PatchOrganizationMembersOutput +@JsonCreator +private constructor( @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), - @JsonProperty("send_email_error") @ExcludeMissing private val sendEmailError: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("send_email_error") + @ExcludeMissing + private val sendEmailError: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** The id of the org that was modified. */ @@ -35,23 +40,20 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( fun status(): Status = status.getRequired("status") /** - * If invite emails failed to send for some reason, the patch operation will still - * complete, but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still complete, but + * we will return an error message here */ - fun sendEmailError(): Optional = Optional.ofNullable(sendEmailError.getNullable("send_email_error")) + fun sendEmailError(): Optional = + Optional.ofNullable(sendEmailError.getNullable("send_email_error")) /** The id of the org that was modified. */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - @JsonProperty("status") - @ExcludeMissing - fun _status(): JsonField = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** - * If invite emails failed to send for some reason, the patch operation will still - * complete, but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still complete, but + * we will return an error message here */ @JsonProperty("send_email_error") @ExcludeMissing @@ -63,18 +65,17 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): PatchOrganizationMembersOutput = - apply { - if (validated) { - return@apply - } - - orgId() - status() - sendEmailError() - validated = true + fun validate(): PatchOrganizationMembersOutput = apply { + if (validated) { + return@apply } + orgId() + status() + sendEmailError() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -84,14 +85,12 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( * [PatchOrganizationMembersOutput]. * * The following fields are required: - * * ```java * .orgId() * .status() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PatchOrganizationMembersOutput]. */ @@ -103,105 +102,85 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = - apply { - orgId = patchOrganizationMembersOutput.orgId - status = patchOrganizationMembersOutput.status - sendEmailError = patchOrganizationMembersOutput.sendEmailError - additionalProperties = patchOrganizationMembersOutput.additionalProperties.toMutableMap() - } + internal fun from(patchOrganizationMembersOutput: PatchOrganizationMembersOutput) = apply { + orgId = patchOrganizationMembersOutput.orgId + status = patchOrganizationMembersOutput.status + sendEmailError = patchOrganizationMembersOutput.sendEmailError + additionalProperties = + patchOrganizationMembersOutput.additionalProperties.toMutableMap() + } /** The id of the org that was modified. */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** The id of the org that was modified. */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } fun status(status: Status) = status(JsonField.of(status)) - fun status(status: JsonField) = - apply { - this.status = status - } + fun status(status: JsonField) = apply { this.status = status } /** - * If invite emails failed to send for some reason, the patch operation will still - * complete, but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still complete, + * but we will return an error message here */ - fun sendEmailError(sendEmailError: String?) = sendEmailError(JsonField.ofNullable(sendEmailError)) + fun sendEmailError(sendEmailError: String?) = + sendEmailError(JsonField.ofNullable(sendEmailError)) /** - * If invite emails failed to send for some reason, the patch operation will still - * complete, but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still complete, + * but we will return an error message here */ - fun sendEmailError(sendEmailError: Optional) = sendEmailError(sendEmailError.getOrNull()) + fun sendEmailError(sendEmailError: Optional) = + sendEmailError(sendEmailError.getOrNull()) /** - * If invite emails failed to send for some reason, the patch operation will still - * complete, but we will return an error message here + * If invite emails failed to send for some reason, the patch operation will still complete, + * but we will return an error message here */ - fun sendEmailError(sendEmailError: JsonField) = - apply { - this.sendEmailError = sendEmailError - } + fun sendEmailError(sendEmailError: JsonField) = apply { + this.sendEmailError = sendEmailError + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PatchOrganizationMembersOutput = PatchOrganizationMembersOutput( - checkRequired( - "orgId", orgId - ), - checkRequired( - "status", status - ), - sendEmailError, - additionalProperties.toImmutable(), + checkRequired("orgId", orgId), + checkRequired("status", status), + sendEmailError, + additionalProperties.toImmutable(), ) } - class Status @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Status @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -212,18 +191,16 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( /** An enum containing [Status]'s known values. */ enum class Known { - SUCCESS, + SUCCESS } /** * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Status] 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 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 { @@ -233,11 +210,11 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -248,11 +225,11 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -263,20 +240,23 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -285,11 +265,11 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PatchOrganizationMembersOutput && orgId == other.orgId && status == other.status && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PatchOrganizationMembersOutput && orgId == other.orgId && status == other.status && sendEmailError == other.sendEmailError && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -298,5 +278,6 @@ class PatchOrganizationMembersOutput @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "PatchOrganizationMembersOutput{orgId=$orgId, status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + override fun toString() = + "PatchOrganizationMembersOutput{orgId=$orgId, status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 698f529c..8da4413e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -20,16 +20,25 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Project @JsonCreator private constructor( +class Project +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("settings") @ExcludeMissing private val settings: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("settings") + @ExcludeMissing + private val settings: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the project */ @@ -45,46 +54,36 @@ class Project @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of project deletion, or null if the project is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) - fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) + fun settings(): Optional = + Optional.ofNullable(settings.getNullable("settings")) /** Identifies the user who created the project */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the project */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the project */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Date of project creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of project deletion, or null if the project is still active */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - @JsonProperty("settings") - @ExcludeMissing - fun _settings(): JsonField = settings + @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonField = settings /** Identifies the user who created the project */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -92,22 +91,21 @@ class Project @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Project = - apply { - if (validated) { - return@apply - } - - id() - name() - orgId() - created() - deletedAt() - settings().ifPresent { it.validate() } - userId() - validated = true + fun validate(): Project = apply { + if (validated) { + return@apply } + id() + name() + orgId() + created() + deletedAt() + settings().ifPresent { it.validate() } + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -116,15 +114,13 @@ class Project @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Project]. * * The following fields are required: - * * ```java * .id() * .name() * .orgId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Project]. */ @@ -140,44 +136,34 @@ class Project @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(project: Project) = - apply { - id = project.id - name = project.name - orgId = project.orgId - created = project.created - deletedAt = project.deletedAt - settings = project.settings - userId = project.userId - additionalProperties = project.additionalProperties.toMutableMap() - } + internal fun from(project: Project) = apply { + id = project.id + name = project.name + orgId = project.orgId + created = project.created + deletedAt = project.deletedAt + settings = project.settings + userId = project.userId + additionalProperties = project.additionalProperties.toMutableMap() + } /** Unique identifier for the project */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique id for the organization that the project belongs under */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Date of project creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -186,10 +172,7 @@ class Project @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date of project deletion, or null if the project is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -198,19 +181,13 @@ class Project @JsonCreator private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of project deletion, or null if the project is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) fun settings(settings: Optional) = settings(settings.getOrNull()) - fun settings(settings: JsonField) = - apply { - this.settings = settings - } + fun settings(settings: JsonField) = apply { this.settings = settings } /** Identifies the user who created the project */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -219,62 +196,46 @@ class Project @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the project */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Project = Project( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "orgId", orgId - ), - created, - deletedAt, - settings, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("orgId", orgId), + created, + deletedAt, + settings, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Project && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && settings == other.settings && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Project && id == other.id && name == other.name && orgId == other.orgId && created == other.created && deletedAt == other.deletedAt && settings == other.settings && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -283,5 +244,6 @@ class Project @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Project{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, settings=$settings, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "Project{id=$id, name=$name, orgId=$orgId, created=$created, deletedAt=$deletedAt, settings=$settings, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 3b391d17..6d92a603 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -22,23 +22,23 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project. If there is an existing project with the same name as the - * one specified in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the one specified in + * the request, will return the existing project unmodified */ -class ProjectCreateParams private constructor( +class ProjectCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the project */ fun name(): String = body.name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * project belongs in. */ fun orgName(): Optional = body.orgName() @@ -46,9 +46,9 @@ class ProjectCreateParams private constructor( fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * project belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -58,44 +58,45 @@ class ProjectCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project */ fun name(): String = name.getRequired("name") /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the project */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -103,17 +104,16 @@ class ProjectCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - orgName() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -122,13 +122,11 @@ class ProjectCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -139,88 +137,68 @@ class ProjectCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = - Body( - checkRequired( - "name", name - ), - orgName, - additionalProperties.toImmutable(), - ) + Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -229,7 +207,8 @@ class ProjectCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -240,13 +219,11 @@ class ProjectCreateParams private constructor( * Returns a mutable builder for constructing an instance of [ProjectCreateParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectCreateParams]. */ @@ -258,220 +235,174 @@ class ProjectCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectCreateParams: ProjectCreateParams) = - apply { - body = projectCreateParams.body.toBuilder() - additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectCreateParams: ProjectCreateParams) = apply { + body = projectCreateParams.body.toBuilder() + additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the project */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the project belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the project belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectCreateParams = ProjectCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 68da5858..969df0a9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project object by its id */ -class ProjectDeleteParams private constructor( +class ProjectDeleteParams +private constructor( private val projectId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Project id */ @@ -31,17 +31,18 @@ class ProjectDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -52,13 +53,11 @@ class ProjectDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [ProjectDeleteParams]. * * The following fields are required: - * * ```java * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectDeleteParams]. */ @@ -71,190 +70,155 @@ class ProjectDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectDeleteParams: ProjectDeleteParams) = - apply { - projectId = projectDeleteParams.projectId - additionalHeaders = projectDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = projectDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectDeleteParams: ProjectDeleteParams) = apply { + projectId = projectDeleteParams.projectId + additionalHeaders = projectDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = projectDeleteParams.additionalBodyProperties.toMutableMap() + } /** Project id */ - fun projectId(projectId: String) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectDeleteParams = ProjectDeleteParams( - checkRequired( - "projectId", projectId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("projectId", projectId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDeleteParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectDeleteParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index c4f4483f..d970247c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.ProjectService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all projects. The projects are sorted by creation date, with the most - * recently-created projects coming first + * List out all projects. The projects are sorted by creation date, with the most recently-created + * projects coming first */ -class ProjectListPage private constructor( +class ProjectListPage +private constructor( private val projectsService: ProjectService, private val params: ProjectListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class ProjectListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListPage && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectListPage && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ - override fun toString() = "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" + override fun toString() = + "ProjectListPage{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectsService.list(it) } + return getNextPageParams().map { projectsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +84,16 @@ class ProjectListPage private constructor( @JvmStatic fun of(projectsService: ProjectService, params: ProjectListParams, response: Response) = - ProjectListPage( - projectsService, - params, - response, - ) + ProjectListPage(projectsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +107,34 @@ class ProjectListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ProjectListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +143,39 @@ class ProjectListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ProjectListPage, + class AutoPager(private val firstPage: ProjectListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 324a224f..2ef21803 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.ProjectServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all projects. The projects are sorted by creation date, with the most - * recently-created projects coming first + * List out all projects. The projects are sorted by creation date, with the most recently-created + * projects coming first */ -class ProjectListPageAsync private constructor( +class ProjectListPageAsync +private constructor( private val projectsService: ProjectServiceAsync, private val params: ProjectListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class ProjectListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListPageAsync && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectListPageAsync && projectsService == other.projectsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectsService, params, response) /* spotless:on */ - override fun toString() = "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" + override fun toString() = + "ProjectListPageAsync{projectsService=$projectsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - projectsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { projectsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,20 @@ class ProjectListPageAsync private constructor( companion object { @JvmStatic - fun of(projectsService: ProjectServiceAsync, params: ProjectListParams, response: Response) = - ProjectListPageAsync( - projectsService, - params, - response, - ) + fun of( + projectsService: ProjectServiceAsync, + params: ProjectListParams, + response: Response, + ) = ProjectListPageAsync(projectsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,38 +112,34 @@ class ProjectListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** - * Returns a mutable builder for constructing an instance of - * [ProjectListPageAsync]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [ProjectListPageAsync]. */ + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +148,46 @@ class ProjectListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ProjectListPageAsync, - - ) { + class AutoPager(private val firstPage: ProjectListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Project) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Project) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index 539d3cbe..c011f50b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all projects. The projects are sorted by creation date, with the most - * recently-created projects coming first + * List out all projects. The projects are sorted by creation date, with the most recently-created + * projects coming first */ -class ProjectListParams private constructor( +class ProjectListParams +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -35,21 +36,20 @@ class ProjectListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ class ProjectListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,51 +78,25 @@ class ProjectListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.projectName?.let { - queryParams.put( - "project_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): ProjectListParams = builder().build() + @JvmStatic fun none(): ProjectListParams = builder().build() /** Returns a mutable builder for constructing an instance of [ProjectListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectListParams]. */ @@ -139,71 +113,61 @@ class ProjectListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectListParams: ProjectListParams) = - apply { - endingBefore = projectListParams.endingBefore - ids = projectListParams.ids - limit = projectListParams.limit - orgName = projectListParams.orgName - projectName = projectListParams.projectName - startingAfter = projectListParams.startingAfter - additionalHeaders = projectListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectListParams: ProjectListParams) = apply { + endingBefore = projectListParams.endingBefore + ids = projectListParams.ids + limit = projectListParams.limit + orgName = projectListParams.orgName + projectName = projectListParams.projectName + startingAfter = projectListParams.startingAfter + additionalHeaders = projectListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -212,19 +176,13 @@ class ProjectListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = - apply { - this.projectName = projectName - } + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) @@ -232,172 +190,144 @@ class ProjectListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectListParams = ProjectListParams( - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -415,19 +345,19 @@ class ProjectListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -442,17 +372,12 @@ class ProjectListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -462,56 +387,60 @@ class ProjectListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectName == other.projectName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index e82d4edf..ea2b6b82 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Log feedback for a set of project logs events */ -class ProjectLogFeedbackParams private constructor( +class ProjectLogFeedbackParams +private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Project id */ @@ -44,25 +44,28 @@ class ProjectLogFeedbackParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("feedback") @ExcludeMissing private val feedback: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("feedback") + @ExcludeMissing + private val feedback: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of project logs feedback items */ @@ -79,16 +82,15 @@ class ProjectLogFeedbackParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - feedback().forEach { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + feedback().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,13 +99,11 @@ class ProjectLogFeedbackParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .feedback() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,69 +113,59 @@ class ProjectLogFeedbackParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - feedback = body.feedback.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + feedback = body.feedback.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of project logs feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) /** A list of project logs feedback items */ - fun feedback(feedback: JsonField>) = - apply { - this.feedback = feedback.map { it.toMutableList() } - } + fun feedback(feedback: JsonField>) = apply { + this.feedback = feedback.map { it.toMutableList() } + } /** A list of project logs feedback items */ - fun addFeedback(feedback: FeedbackProjectLogsItem) = - apply { - this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { + fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { + this.feedback = + (this.feedback ?: JsonField.of(mutableListOf())).also { checkKnown("feedback", it).add(feedback) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "feedback", feedback - ).map { it.toImmutable() }, additionalProperties.toImmutable() + checkRequired("feedback", feedback).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && feedback == other.feedback && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -184,7 +174,8 @@ class ProjectLogFeedbackParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{feedback=$feedback, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -192,18 +183,15 @@ class ProjectLogFeedbackParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectLogFeedbackParams]. + * Returns a mutable builder for constructing an instance of [ProjectLogFeedbackParams]. * * The following fields are required: - * * ```java * .projectId() * .feedback() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectLogFeedbackParams]. */ @@ -216,209 +204,163 @@ class ProjectLogFeedbackParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = - apply { - projectId = projectLogFeedbackParams.projectId - body = projectLogFeedbackParams.body.toBuilder() - additionalHeaders = projectLogFeedbackParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFeedbackParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFeedbackParams: ProjectLogFeedbackParams) = apply { + projectId = projectLogFeedbackParams.projectId + body = projectLogFeedbackParams.body.toBuilder() + additionalHeaders = projectLogFeedbackParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFeedbackParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs feedback items */ - fun feedback(feedback: List) = - apply { - body.feedback(feedback) - } + fun feedback(feedback: List) = apply { body.feedback(feedback) } /** A list of project logs feedback items */ - fun feedback(feedback: JsonField>) = - apply { - body.feedback(feedback) - } + fun feedback(feedback: JsonField>) = apply { + body.feedback(feedback) + } /** A list of project logs feedback items */ - fun addFeedback(feedback: FeedbackProjectLogsItem) = - apply { - body.addFeedback(feedback) - } + fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { body.addFeedback(feedback) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( - checkRequired( - "projectId", projectId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectId", projectId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFeedbackParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectLogFeedbackParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectLogFeedbackParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 6576d624..1d82f560 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -12,11 +12,12 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body. - * For more complex queries, use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use the + * `POST /btql` endpoint. */ -class ProjectLogFetchParams private constructor( +class ProjectLogFetchParams +private constructor( private val projectId: String, private val limit: Long?, private val maxRootSpanId: String?, @@ -24,7 +25,6 @@ class ProjectLogFetchParams private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Project id */ @@ -33,55 +33,52 @@ class ProjectLogFetchParams private constructor( /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun limit(): Optional = Optional.ofNullable(limit) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = Optional.ofNullable(version) @@ -92,36 +89,20 @@ class ProjectLogFetchParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.maxRootSpanId?.let { - queryParams.put( - "max_root_span_id", listOf(it.toString()) - ) - } - this.maxXactId?.let { - queryParams.put( - "max_xact_id", listOf(it.toString()) - ) - } - this.version?.let { - queryParams.put( - "version", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } + this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -129,17 +110,14 @@ class ProjectLogFetchParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectLogFetchParams]. + * Returns a mutable builder for constructing an instance of [ProjectLogFetchParams]. * * The following fields are required: - * * ```java * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectLogFetchParams]. */ @@ -155,310 +133,263 @@ class ProjectLogFetchParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFetchParams: ProjectLogFetchParams) = - apply { - projectId = projectLogFetchParams.projectId - limit = projectLogFetchParams.limit - maxRootSpanId = projectLogFetchParams.maxRootSpanId - maxXactId = projectLogFetchParams.maxXactId - version = projectLogFetchParams.version - additionalHeaders = projectLogFetchParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFetchParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFetchParams: ProjectLogFetchParams) = apply { + projectId = projectLogFetchParams.projectId + limit = projectLogFetchParams.limit + maxRootSpanId = projectLogFetchParams.maxRootSpanId + maxXactId = projectLogFetchParams.maxXactId + version = projectLogFetchParams.version + additionalHeaders = projectLogFetchParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFetchParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = - apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String?) = - apply { - this.version = version - } + fun version(version: String?) = apply { this.version = version } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFetchParams = ProjectLogFetchParams( - checkRequired( - "projectId", projectId - ), - limit, - maxRootSpanId, - maxXactId, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectId", projectId), + limit, + maxRootSpanId, + maxXactId, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchParams && projectId == other.projectId && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, limit, maxRootSpanId, maxXactId, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index aa9256e2..4eb11877 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -22,146 +22,138 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use the + * `POST /btql` endpoint. */ -class ProjectLogFetchPostParams private constructor( +class ProjectLogFetchPostParams +private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Project id */ fun projectId(): String = projectId /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch query */ fun cursor(): Optional = body.cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun limit(): Optional = body.limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxRootSpanId(): Optional = body.maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun maxXactId(): Optional = body.maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from latest to + * earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch query */ fun _cursor(): JsonField = body._cursor() /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later + * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. + * This happens because pagination occurs over the whole version history of the event log. You + * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your + * combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up with + * more individual rows than the specified limit if you are fetching events containing traces. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the + * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument + * going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the cursor + * for the next page can be found as the row with the minimum (earliest) value of the tuple + * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating + * fetch queries. */ fun _maxXactId(): JsonField = body._maxXactId() /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use the + * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun _version(): JsonField = body._version() @@ -171,168 +163,169 @@ class ProjectLogFetchPostParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("cursor") @ExcludeMissing private val cursor: JsonField = JsonMissing.of(), - @JsonProperty("limit") @ExcludeMissing private val limit: JsonField = JsonMissing.of(), - @JsonProperty("max_root_span_id") @ExcludeMissing private val maxRootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("max_xact_id") @ExcludeMissing private val maxXactId: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing private val version: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("cursor") + @ExcludeMissing + private val cursor: JsonField = JsonMissing.of(), + @JsonProperty("limit") + @ExcludeMissing + private val limit: JsonField = JsonMissing.of(), + @JsonProperty("max_root_span_id") + @ExcludeMissing + private val maxRootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("max_xact_id") + @ExcludeMissing + private val maxXactId: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) + fun maxRootSpanId(): Optional = + Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) + fun maxXactId(): Optional = + Optional.ofNullable(maxXactId.getNullable("max_xact_id")) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - @JsonProperty("cursor") - @ExcludeMissing - fun _cursor(): JsonField = cursor + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - @JsonProperty("limit") - @ExcludeMissing - fun _limit(): JsonField = limit + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - @JsonProperty("max_xact_id") - @ExcludeMissing - fun _maxXactId(): JsonField = maxXactId + @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - @JsonProperty("version") - @ExcludeMissing - fun _version(): JsonField = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -340,27 +333,25 @@ class ProjectLogFetchPostParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - cursor() - limit() - maxRootSpanId() - maxXactId() - version() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + cursor() + limit() + maxRootSpanId() + maxXactId() + version() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -374,284 +365,261 @@ class ProjectLogFetchPostParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - cursor = body.cursor - limit = body.limit - maxRootSpanId = body.maxRootSpanId - maxXactId = body.maxXactId - version = body.version - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + cursor = body.cursor + limit = body.limit + maxRootSpanId = body.maxRootSpanId + maxXactId = body.maxXactId + version = body.version + additionalProperties = body.additionalProperties.toMutableMap() + } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: JsonField) = - apply { - this.cursor = cursor - } + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of + * the event log. You will most likely want to exclude any such duplicate, outdated rows + * (by `id`) from your combined result set. * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events + * containing traces. */ - fun limit(limit: JsonField) = - apply { - this.limit = limit - } + fun limit(limit: JsonField) = apply { this.limit = limit } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) + fun maxRootSpanId(maxRootSpanId: String?) = + maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = - apply { - this.maxRootSpanId = maxRootSpanId - } + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + this.maxRootSpanId = maxRootSpanId + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor + * of the explicit 'cursor' returned by object fetch requests. Please prefer the + * 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of + * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an + * overview of paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = - apply { - this.maxXactId = maxXactId - } + fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ fun version(version: String?) = version(JsonField.ofNullable(version)) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can + * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact + * fetch. */ - fun version(version: JsonField) = - apply { - this.version = version - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - cursor, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toImmutable(), + cursor, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && cursor == other.cursor && limit == other.limit && maxRootSpanId == other.maxRootSpanId && maxXactId == other.maxXactId && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -660,7 +628,8 @@ class ProjectLogFetchPostParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{cursor=$cursor, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -668,17 +637,14 @@ class ProjectLogFetchPostParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectLogFetchPostParams]. + * Returns a mutable builder for constructing an instance of [ProjectLogFetchPostParams]. * * The following fields are required: - * * ```java * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectLogFetchPostParams]. */ @@ -691,431 +657,358 @@ class ProjectLogFetchPostParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = - apply { - projectId = projectLogFetchPostParams.projectId - body = projectLogFetchPostParams.body.toBuilder() - additionalHeaders = projectLogFetchPostParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogFetchPostParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogFetchPostParams: ProjectLogFetchPostParams) = apply { + projectId = projectLogFetchPostParams.projectId + body = projectLogFetchPostParams.body.toBuilder() + additionalHeaders = projectLogFetchPostParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogFetchPostParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: String?) = - apply { - body.cursor(cursor) - } + fun cursor(cursor: String?) = apply { body.cursor(cursor) } /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order - * from latest to earliest. + * An opaque string to be used as a cursor for the next page of results, in order from + * latest to earliest. * - * The string can be obtained directly from the `cursor` property of the previous - * fetch query + * The string can be obtained directly from the `cursor` property of the previous fetch + * query */ - fun cursor(cursor: JsonField) = - apply { - body.cursor(cursor) - } + fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: Long?) = - apply { - body.limit(limit) - } + fun limit(limit: Long?) = apply { body.limit(limit) } /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Long) = limit(limit as Long?) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** * limit the number of traces fetched * - * Fetch queries may be paginated if the total result size is expected to be large - * (e.g. project_logs which accumulate over a long time). Note that fetch queries - * only support pagination in descending time order (from latest to earliest - * `_xact_id`. Furthermore, later pages may return rows which showed up in earlier - * pages, except with an earlier `_xact_id`. This happens because pagination occurs - * over the whole version history of the event log. You will most likely want to - * exclude any such duplicate, outdated rows (by `id`) from your combined result - * set. - * - * The `limit` parameter controls the number of full traces to return. So you may - * end up with more individual rows than the specified limit if you are fetching - * events containing traces. + * Fetch queries may be paginated if the total result size is expected to be large (e.g. + * project_logs which accumulate over a long time). Note that fetch queries only support + * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, + * later pages may return rows which showed up in earlier pages, except with an earlier + * `_xact_id`. This happens because pagination occurs over the whole version history of the + * event log. You will most likely want to exclude any such duplicate, outdated rows (by + * `id`) from your combined result set. + * + * The `limit` parameter controls the number of full traces to return. So you may end up + * with more individual rows than the specified limit if you are fetching events containing + * traces. */ - fun limit(limit: JsonField) = - apply { - body.limit(limit) - } + fun limit(limit: JsonField) = apply { body.limit(limit) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: String?) = - apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) + fun maxRootSpanId(maxRootSpanId: Optional) = + maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxRootSpanId(maxRootSpanId: JsonField) = - apply { - body.maxRootSpanId(maxRootSpanId) - } + fun maxRootSpanId(maxRootSpanId: JsonField) = apply { + body.maxRootSpanId(maxRootSpanId) + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: String?) = - apply { - body.maxXactId(maxXactId) - } + fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in - * favor of the explicit 'cursor' returned by object fetch requests. Please prefer - * the 'cursor' argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of + * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' + * argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, - * the cursor for the next page can be found as the row with the minimum (earliest) - * value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` - * for an overview of paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, the + * cursor for the next page can be found as the row with the minimum (earliest) value of the + * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of + * paginating fetch queries. */ - fun maxXactId(maxXactId: JsonField) = - apply { - body.maxXactId(maxXactId) - } + fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: String?) = - apply { - body.version(version) - } + fun version(version: String?) = apply { body.version(version) } /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ fun version(version: Optional) = version(version.getOrNull()) /** * Retrieve a snapshot of events from a past time * - * The version id is essentially a filter on the latest event transaction id. You - * can use the `max_xact_id` returned by a past fetch as the version to reproduce - * that exact fetch. + * The version id is essentially a filter on the latest event transaction id. You can use + * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. */ - fun version(version: JsonField) = - apply { - body.version(version) - } + fun version(version: JsonField) = apply { body.version(version) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogFetchPostParams = ProjectLogFetchPostParams( - checkRequired( - "projectId", projectId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectId", projectId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogFetchPostParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectLogFetchPostParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectLogFetchPostParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index d3e46403..00032977 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -21,12 +21,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Insert a set of events into the project logs */ -class ProjectLogInsertParams private constructor( +class ProjectLogInsertParams +private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Project id */ @@ -44,25 +44,28 @@ class ProjectLogInsertParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("events") @ExcludeMissing private val events: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of project logs events to insert */ @@ -79,16 +82,15 @@ class ProjectLogInsertParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - events().forEach { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + events().forEach { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,13 +99,11 @@ class ProjectLogInsertParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -113,69 +113,59 @@ class ProjectLogInsertParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - events = body.events.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + events = body.events.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of project logs events to insert */ fun events(events: List) = events(JsonField.of(events)) /** A list of project logs events to insert */ - fun events(events: JsonField>) = - apply { - this.events = events.map { it.toMutableList() } - } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } /** A list of project logs events to insert */ - fun addEvent(event: InsertProjectLogsEvent) = - apply { - events = (events ?: JsonField.of(mutableListOf())).also { + fun addEvent(event: InsertProjectLogsEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { checkKnown("events", it).add(event) } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "events", events - ).map { it.toImmutable() }, additionalProperties.toImmutable() + checkRequired("events", events).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && events == other.events && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -192,18 +182,15 @@ class ProjectLogInsertParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectLogInsertParams]. + * Returns a mutable builder for constructing an instance of [ProjectLogInsertParams]. * * The following fields are required: - * * ```java * .projectId() * .events() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectLogInsertParams]. */ @@ -216,209 +203,161 @@ class ProjectLogInsertParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectLogInsertParams: ProjectLogInsertParams) = - apply { - projectId = projectLogInsertParams.projectId - body = projectLogInsertParams.body.toBuilder() - additionalHeaders = projectLogInsertParams.additionalHeaders.toBuilder() - additionalQueryParams = projectLogInsertParams.additionalQueryParams.toBuilder() - } + internal fun from(projectLogInsertParams: ProjectLogInsertParams) = apply { + projectId = projectLogInsertParams.projectId + body = projectLogInsertParams.body.toBuilder() + additionalHeaders = projectLogInsertParams.additionalHeaders.toBuilder() + additionalQueryParams = projectLogInsertParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** A list of project logs events to insert */ - fun events(events: List) = - apply { - body.events(events) - } + fun events(events: List) = apply { body.events(events) } /** A list of project logs events to insert */ - fun events(events: JsonField>) = - apply { - body.events(events) - } + fun events(events: JsonField>) = apply { body.events(events) } /** A list of project logs events to insert */ - fun addEvent(event: InsertProjectLogsEvent) = - apply { - body.addEvent(event) - } + fun addEvent(event: InsertProjectLogsEvent) = apply { body.addEvent(event) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectLogInsertParams = ProjectLogInsertParams( - checkRequired( - "projectId", projectId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectId", projectId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectLogInsertParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectLogInsertParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectLogInsertParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index f1bc7509..94a6ee65 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -23,43 +23,71 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectLogsEvent @JsonCreator private constructor( +class ProjectLogsEvent +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), - @JsonProperty("span_id") @ExcludeMissing private val spanId: JsonField = JsonMissing.of(), - @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + private val context: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), - @JsonProperty("is_root") @ExcludeMissing private val isRoot: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), + @JsonProperty("is_root") + @ExcludeMissing + private val isRoot: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), - @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), - @JsonProperty("span_attributes") @ExcludeMissing private val spanAttributes: JsonField = JsonMissing.of(), - @JsonProperty("span_parents") @ExcludeMissing private val spanParents: JsonField> = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), + @JsonProperty("span_attributes") + @ExcludeMissing + private val spanAttributes: JsonField = JsonMissing.of(), + @JsonProperty("span_parents") + @ExcludeMissing + private val spanParents: JsonField> = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the project logs (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -79,62 +107,51 @@ class ProjectLogsEvent @JsonCreator private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(): String = spanId.getRequired("span_id") /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) /** The error that occurred, if any. */ - @JsonProperty("error") - @ExcludeMissing - fun _error(): JsonValue = error + @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does not + * compare `output` to `expected` for you, since there are so many different ways to do that + * correctly. Instead, these values are just used to help you navigate while digging into + * analyses. However, we may later use these values to re-score outputs or fine-tune your + * models. */ - @JsonProperty("expected") - @ExcludeMissing - fun _expected(): JsonValue = expected + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - @JsonProperty("input") - @ExcludeMissing - fun _input(): JsonValue = input + /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input /** Whether this span is a root span */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -142,147 +159,113 @@ class ProjectLogsEvent @JsonCreator private constructor( fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON serializable + * object), that allows you to determine whether the result is correct or not. For example, in + * an app that generates SQL queries, the `output` should be the _result_ of the SQL query + * generated by the model, not the query itself, because there may be multiple valid queries + * that answer a single question. */ - @JsonProperty("output") - @ExcludeMissing - fun _output(): JsonValue = output + @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) + fun spanAttributes(): Optional = + Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ - fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) + fun spanParents(): Optional> = + Optional.ofNullable(spanParents.getNullable("span_parents")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the project logs (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") - @ExcludeMissing - fun _logId(): JsonField = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Unique identifier for the project */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** A unique identifier for the trace this project logs event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun _rootSpanId(): JsonField = rootSpanId + @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - @JsonProperty("span_id") - @ExcludeMissing - fun _spanId(): JsonField = spanId + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event */ - @JsonProperty("context") - @ExcludeMissing - fun _context(): JsonField = context + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context /** Whether this span is a root span */ - @JsonProperty("is_root") - @ExcludeMissing - fun _isRoot(): JsonField = isRoot + @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics(): JsonField = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") - @ExcludeMissing - fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores(): JsonField = scores + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -290,18 +273,15 @@ class ProjectLogsEvent @JsonCreator private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for the + * root span of a trace, and should most often contain just one parent element for subspans */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -309,32 +289,31 @@ class ProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ProjectLogsEvent = - apply { - if (validated) { - return@apply - } - - id() - _xactId() - created() - logId() - orgId() - projectId() - rootSpanId() - spanId() - context().ifPresent { it.validate() } - isRoot() - metadata().ifPresent { it.validate() } - metrics().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - spanAttributes().ifPresent { it.validate() } - spanParents() - tags() - validated = true + fun validate(): ProjectLogsEvent = apply { + if (validated) { + return@apply } + id() + _xactId() + created() + logId() + orgId() + projectId() + rootSpanId() + spanId() + context().ifPresent { it.validate() } + isRoot() + metadata().ifPresent { it.validate() } + metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + spanAttributes().ifPresent { it.validate() } + spanParents() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -343,7 +322,6 @@ class ProjectLogsEvent @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [ProjectLogsEvent]. * * The following fields are required: - * * ```java * .id() * ._xactId() @@ -355,8 +333,7 @@ class ProjectLogsEvent @JsonCreator private constructor( * .spanId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectLogsEvent]. */ @@ -386,184 +363,139 @@ class ProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectLogsEvent: ProjectLogsEvent) = - apply { - id = projectLogsEvent.id - _xactId = projectLogsEvent._xactId - created = projectLogsEvent.created - logId = projectLogsEvent.logId - orgId = projectLogsEvent.orgId - projectId = projectLogsEvent.projectId - rootSpanId = projectLogsEvent.rootSpanId - spanId = projectLogsEvent.spanId - context = projectLogsEvent.context - error = projectLogsEvent.error - expected = projectLogsEvent.expected - input = projectLogsEvent.input - isRoot = projectLogsEvent.isRoot - metadata = projectLogsEvent.metadata - metrics = projectLogsEvent.metrics - origin = projectLogsEvent.origin - output = projectLogsEvent.output - scores = projectLogsEvent.scores - spanAttributes = projectLogsEvent.spanAttributes - spanParents = projectLogsEvent.spanParents.map { it.toMutableList() } - tags = projectLogsEvent.tags.map { it.toMutableList() } - additionalProperties = projectLogsEvent.additionalProperties.toMutableMap() - } + internal fun from(projectLogsEvent: ProjectLogsEvent) = apply { + id = projectLogsEvent.id + _xactId = projectLogsEvent._xactId + created = projectLogsEvent.created + logId = projectLogsEvent.logId + orgId = projectLogsEvent.orgId + projectId = projectLogsEvent.projectId + rootSpanId = projectLogsEvent.rootSpanId + spanId = projectLogsEvent.spanId + context = projectLogsEvent.context + error = projectLogsEvent.error + expected = projectLogsEvent.expected + input = projectLogsEvent.input + isRoot = projectLogsEvent.isRoot + metadata = projectLogsEvent.metadata + metrics = projectLogsEvent.metrics + origin = projectLogsEvent.origin + output = projectLogsEvent.output + scores = projectLogsEvent.scores + spanAttributes = projectLogsEvent.spanAttributes + spanParents = projectLogsEvent.spanParents.map { it.toMutableList() } + tags = projectLogsEvent.tags.map { it.toMutableList() } + additionalProperties = projectLogsEvent.additionalProperties.toMutableMap() + } /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the project logs event. If you don't provide one, - * BrainTrust will generate one for you + * A unique identifier for the project logs event. If you don't provide one, BrainTrust will + * generate one for you */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the project logs (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the project logs (see the - * `version` parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the project logs (see the `version` parameter) */ - fun _xactId(_xactId: JsonField) = - apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) /** The timestamp the project logs event was created */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** A literal 'g' which identifies the log as a project log */ fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'g' which identifies the log as a project log */ - fun logId(logId: JsonField) = - apply { - this.logId = logId - } + fun logId(logId: JsonField) = apply { this.logId = logId } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique id for the organization that the project belongs under */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A unique identifier for the trace this project logs event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) /** A unique identifier for the trace this project logs event belongs to */ - fun rootSpanId(rootSpanId: JsonField) = - apply { - this.rootSpanId = rootSpanId - } + fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different project logs events together as part - * of a full trace. See the - * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details - * on tracing + * A unique identifier used to link different project logs events together as part of a full + * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full + * details on tracing */ - fun spanId(spanId: JsonField) = - apply { - this.spanId = spanId - } + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ fun context(context: Context?) = context(JsonField.ofNullable(context)) /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It + * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to + * track the location in code which produced the project logs event */ - fun context(context: JsonField) = - apply { - this.context = context - } + fun context(context: JsonField) = apply { this.context = context } /** The error that occurred, if any. */ - fun error(error: JsonValue) = - apply { - this.error = error - } + fun error(error: JsonValue) = apply { this.error = error } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd - * compare to `output` to determine if your `output` value is correct or not. - * Braintrust currently does not compare `output` to `expected` for you, since - * there are so many different ways to do that correctly. Instead, these values are - * just used to help you navigate while digging into analyses. However, we may - * later use these values to re-score outputs or fine-tune your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to + * `output` to determine if your `output` value is correct or not. Braintrust currently does + * not compare `output` to `expected` for you, since there are so many different ways to do + * that correctly. Instead, these values are just used to help you navigate while digging + * into analyses. However, we may later use these values to re-score outputs or fine-tune + * your models. */ - fun expected(expected: JsonValue) = - apply { - this.expected = expected - } + fun expected(expected: JsonValue) = apply { this.expected = expected } /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - fun input(input: JsonValue) = - apply { - this.input = input - } + fun input(input: JsonValue) = apply { this.input = input } /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) @@ -575,64 +507,55 @@ class ProjectLogsEvent @JsonCreator private constructor( fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) /** Whether this span is a root span */ - fun isRoot(isRoot: JsonField) = - apply { - this.isRoot = isRoot - } + fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. + * For example, you could log the `prompt`, example's `id`, or anything else that would be + * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, + * but its keys must be strings */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project + * logs event was produced */ - fun metrics(metrics: JsonField) = - apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) @@ -641,109 +564,97 @@ class ProjectLogsEvent @JsonCreator private constructor( fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = - apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct - * or not. For example, in an app that generates SQL queries, the `output` should - * be the _result_ of the SQL query generated by the model, not the query itself, - * because there may be multiple valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct or not. + * For example, in an app that generates SQL queries, the `output` should be the _result_ of + * the SQL query generated by the model, not the query itself, because there may be multiple + * valid queries that answer a single question. */ - fun output(output: JsonValue) = - apply { - this.output = output - } + fun output(output: JsonValue) = apply { this.output = output } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a + * variety of signals that help you determine how accurate the outputs are compared to what + * you expect and diagnose failures. For example, a summarization app might have one score + * that tells you how accurate the summary is, and another that measures the word similarity + * between the generated and grouth truth summary. The word similarity score could help you + * determine whether the summarization was covering similar concepts or not. You can use + * these scores to help you sort, filter, and compare logs. */ - fun scores(scores: JsonField) = - apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes?) = + spanAttributes(JsonField.ofNullable(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) + fun spanAttributes(spanAttributes: Optional) = + spanAttributes(spanAttributes.getOrNull()) /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: JsonField) = - apply { - this.spanAttributes = spanAttributes - } + fun spanAttributes(spanAttributes: JsonField) = apply { + this.spanAttributes = spanAttributes + } /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ - fun spanParents(spanParents: JsonField>) = - apply { - this.spanParents = spanParents.map { it.toMutableList() } - } + fun spanParents(spanParents: JsonField>) = apply { + this.spanParents = spanParents.map { it.toMutableList() } + } /** - * An array of the parent `span_ids` of this project logs event. This should be - * empty for the root span of a trace, and should most often contain just one - * parent element for subspans + * An array of the parent `span_ids` of this project logs event. This should be empty for + * the root span of a trace, and should most often contain just one parent element for + * subspans */ - fun addSpanParent(spanParent: String) = - apply { - spanParents = (spanParents ?: JsonField.of(mutableListOf())).also { + fun addSpanParent(spanParent: String) = apply { + spanParents = + (spanParents ?: JsonField.of(mutableListOf())).also { checkKnown("spanParents", it).add(spanParent) } - } + } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -752,104 +663,73 @@ class ProjectLogsEvent @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags to log */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags to log */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectLogsEvent = ProjectLogsEvent( - checkRequired( - "id", id - ), - checkRequired( - "_xactId", _xactId - ), - checkRequired( - "created", created - ), - checkRequired( - "logId", logId - ), - checkRequired( - "orgId", orgId - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "rootSpanId", rootSpanId - ), - checkRequired( - "spanId", spanId - ), - context, - error, - expected, - input, - isRoot, - metadata, - metrics, - origin, - output, - scores, - spanAttributes, - (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("created", created), + checkRequired("logId", logId), + checkRequired("orgId", orgId), + checkRequired("projectId", projectId), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), + context, + error, + expected, + input, + isRoot, + metadata, + metrics, + origin, + output, + scores, + spanAttributes, + (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** A literal 'g' which identifies the log as a project log */ - class LogId @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class LogId @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -860,18 +740,16 @@ class ProjectLogsEvent @JsonCreator private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - G, + G } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] 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 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 { @@ -881,11 +759,11 @@ class ProjectLogsEvent @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -896,11 +774,11 @@ class ProjectLogsEvent @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -911,20 +789,23 @@ class ProjectLogsEvent @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -933,28 +814,38 @@ class ProjectLogsEvent @JsonCreator private constructor( } /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the - * `caller_*` attributes to track the location in code which produced the project - * logs event + * Context is additional information about the code that produced the project logs event. It is + * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the + * location in code which produced the project logs event */ @NoAutoDetect - class Context @JsonCreator private constructor( - @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonField = JsonMissing.of(), - @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonField = JsonMissing.of(), - @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Context + @JsonCreator + private constructor( + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonField = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonField = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the file in code where the project logs event was created */ - fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) + fun callerFilename(): Optional = + Optional.ofNullable(callerFilename.getNullable("caller_filename")) /** The function in code which created the project logs event */ - fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) + fun callerFunctionname(): Optional = + Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) /** Line of code where the project logs event was created */ - fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) + fun callerLineno(): Optional = + Optional.ofNullable(callerLineno.getNullable("caller_lineno")) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -977,25 +868,23 @@ class ProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Context = - apply { - if (validated) { - return@apply - } - - callerFilename() - callerFunctionname() - callerLineno() - validated = true + fun validate(): Context = apply { + if (validated) { + return@apply } + callerFilename() + callerFunctionname() + callerLineno() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Context]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Context]. */ @@ -1007,37 +896,38 @@ class ProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(context: Context) = - apply { - callerFilename = context.callerFilename - callerFunctionname = context.callerFunctionname - callerLineno = context.callerLineno - additionalProperties = context.additionalProperties.toMutableMap() - } + internal fun from(context: Context) = apply { + callerFilename = context.callerFilename + callerFunctionname = context.callerFunctionname + callerLineno = context.callerLineno + additionalProperties = context.additionalProperties.toMutableMap() + } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) + fun callerFilename(callerFilename: String?) = + callerFilename(JsonField.ofNullable(callerFilename)) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) + fun callerFilename(callerFilename: Optional) = + callerFilename(callerFilename.getOrNull()) /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: JsonField) = - apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonField) = apply { + this.callerFilename = callerFilename + } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String?) = + callerFunctionname(JsonField.ofNullable(callerFunctionname)) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) + fun callerFunctionname(callerFunctionname: Optional) = + callerFunctionname(callerFunctionname.getOrNull()) /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: JsonField) = - apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonField) = apply { + this.callerFunctionname = callerFunctionname + } /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) @@ -1049,52 +939,44 @@ class ProjectLogsEvent @JsonCreator private constructor( fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: JsonField) = - apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonField) = apply { + this.callerLineno = callerLineno + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Context = Context( - callerFilename, - callerFunctionname, - callerLineno, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Context && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1103,20 +985,23 @@ class ProjectLogsEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = + "Context{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" } /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or - * anything else that would be useful to slice/dice later. The values in `metadata` - * can be any JSON-serializable type, but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just about + * anything else that's relevant, that you can use to help find and analyze examples later. For + * example, you could log the `prompt`, example's `id`, or anything else that would be useful to + * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys + * must be strings */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1125,22 +1010,20 @@ class ProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -1149,46 +1032,38 @@ class ProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1201,22 +1076,38 @@ class ProjectLogsEvent @JsonCreator private constructor( } /** - * Metrics are numerical measurements tracking the execution of the code that - * produced the project logs event. Use "start" and "end" to track the time span - * over which the project logs event was produced + * Metrics are numerical measurements tracking the execution of the code that produced the + * project logs event. Use "start" and "end" to track the time span over which the project logs + * event was produced */ @NoAutoDetect - class Metrics @JsonCreator private constructor( - @JsonProperty("caller_filename") @ExcludeMissing private val callerFilename: JsonValue = JsonMissing.of(), - @JsonProperty("caller_functionname") @ExcludeMissing private val callerFunctionname: JsonValue = JsonMissing.of(), - @JsonProperty("caller_lineno") @ExcludeMissing private val callerLineno: JsonValue = JsonMissing.of(), - @JsonProperty("completion_tokens") @ExcludeMissing private val completionTokens: JsonField = JsonMissing.of(), + class Metrics + @JsonCreator + private constructor( + @JsonProperty("caller_filename") + @ExcludeMissing + private val callerFilename: JsonValue = JsonMissing.of(), + @JsonProperty("caller_functionname") + @ExcludeMissing + private val callerFunctionname: JsonValue = JsonMissing.of(), + @JsonProperty("caller_lineno") + @ExcludeMissing + private val callerLineno: JsonValue = JsonMissing.of(), + @JsonProperty("completion_tokens") + @ExcludeMissing + private val completionTokens: JsonField = JsonMissing.of(), @JsonProperty("end") @ExcludeMissing private val end: JsonField = JsonMissing.of(), - @JsonProperty("prompt_tokens") @ExcludeMissing private val promptTokens: JsonField = JsonMissing.of(), - @JsonProperty("start") @ExcludeMissing private val start: JsonField = JsonMissing.of(), - @JsonProperty("tokens") @ExcludeMissing private val tokens: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("prompt_tokens") + @ExcludeMissing + private val promptTokens: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), + @JsonProperty("tokens") + @ExcludeMissing + private val tokens: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** This metric is deprecated */ @@ -1230,31 +1121,31 @@ class ProjectLogsEvent @JsonCreator private constructor( fun _callerFunctionname(): JsonValue = callerFunctionname /** This metric is deprecated */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun _callerLineno(): JsonValue = callerLineno + @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonValue = callerLineno /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ - fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) + fun completionTokens(): Optional = + Optional.ofNullable(completionTokens.getNullable("completion_tokens")) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs event + * finished */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) */ - fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) + fun promptTokens(): Optional = + Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs event + * started */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) @@ -1262,41 +1153,35 @@ class ProjectLogsEvent @JsonCreator private constructor( fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an LLM + * span) */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs event + * finished */ - @JsonProperty("end") - @ExcludeMissing - fun _end(): JsonField = end + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set if + * this is an LLM span) */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs event + * started */ - @JsonProperty("start") - @ExcludeMissing - fun _start(): JsonField = start + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun _tokens(): JsonField = tokens + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @ExcludeMissing @@ -1304,27 +1189,25 @@ class ProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metrics = - apply { - if (validated) { - return@apply - } - - completionTokens() - end() - promptTokens() - start() - tokens() - validated = true + fun validate(): Metrics = apply { + if (validated) { + return@apply } + completionTokens() + end() + promptTokens() + start() + tokens() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -1341,144 +1224,133 @@ class ProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = - apply { - callerFilename = metrics.callerFilename - callerFunctionname = metrics.callerFunctionname - callerLineno = metrics.callerLineno - completionTokens = metrics.completionTokens - end = metrics.end - promptTokens = metrics.promptTokens - start = metrics.start - tokens = metrics.tokens - additionalProperties = metrics.additionalProperties.toMutableMap() - } + internal fun from(metrics: Metrics) = apply { + callerFilename = metrics.callerFilename + callerFunctionname = metrics.callerFunctionname + callerLineno = metrics.callerLineno + completionTokens = metrics.completionTokens + end = metrics.end + promptTokens = metrics.promptTokens + start = metrics.start + tokens = metrics.tokens + additionalProperties = metrics.additionalProperties.toMutableMap() + } /** This metric is deprecated */ - fun callerFilename(callerFilename: JsonValue) = - apply { - this.callerFilename = callerFilename - } + fun callerFilename(callerFilename: JsonValue) = apply { + this.callerFilename = callerFilename + } /** This metric is deprecated */ - fun callerFunctionname(callerFunctionname: JsonValue) = - apply { - this.callerFunctionname = callerFunctionname - } + fun callerFunctionname(callerFunctionname: JsonValue) = apply { + this.callerFunctionname = callerFunctionname + } /** This metric is deprecated */ - fun callerLineno(callerLineno: JsonValue) = - apply { - this.callerLineno = callerLineno - } + fun callerLineno(callerLineno: JsonValue) = apply { this.callerLineno = callerLineno } /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Long?) = completionTokens(JsonField.ofNullable(completionTokens)) + fun completionTokens(completionTokens: Long?) = + completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) + fun completionTokens(completionTokens: Long) = + completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) + fun completionTokens(completionTokens: Optional) = + completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) + * The number of tokens in the completion generated by the model (only set if this is an + * LLM span) */ - fun completionTokens(completionTokens: JsonField) = - apply { - this.completionTokens = completionTokens - } + fun completionTokens(completionTokens: JsonField) = apply { + this.completionTokens = completionTokens + } /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ fun end(end: Double) = end(end as Double?) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished + * A unix timestamp recording when the section of code which produced the project logs + * event finished */ - fun end(end: JsonField) = - apply { - this.end = end - } + fun end(end: JsonField) = apply { this.end = end } /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only set + * if this is an LLM span) */ - fun promptTokens(promptTokens: JsonField) = - apply { - this.promptTokens = promptTokens - } + fun promptTokens(promptTokens: JsonField) = apply { + this.promptTokens = promptTokens + } /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ fun start(start: Double) = start(start as Double?) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project - * logs event started + * A unix timestamp recording when the section of code which produced the project logs + * event started */ - fun start(start: JsonField) = - apply { - this.start = start - } + fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) @@ -1490,57 +1362,47 @@ class ProjectLogsEvent @JsonCreator private constructor( fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: JsonField) = - apply { - this.tokens = tokens - } + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics( - callerFilename, - callerFunctionname, - callerLineno, - completionTokens, - end, - promptTokens, - start, - tokens, - additionalProperties.toImmutable(), + callerFilename, + callerFunctionname, + callerLineno, + completionTokens, + end, + promptTokens, + start, + tokens, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && callerFilename == other.callerFilename && callerFunctionname == other.callerFunctionname && callerLineno == other.callerLineno && completionTokens == other.completionTokens && end == other.end && promptTokens == other.promptTokens && start == other.start && tokens == other.tokens && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1549,18 +1411,27 @@ class ProjectLogsEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = + "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } /** Indicates the event was copied from another object. */ @NoAutoDetect - class Origin @JsonCreator private constructor( + class Origin + @JsonCreator + private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** ID of the original event. */ @@ -1576,19 +1447,13 @@ class ProjectLogsEvent @JsonCreator private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** ID of the original event. */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** ID of the object the event is originating from. */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** Type of the object the event is originating from. */ @JsonProperty("object_type") @@ -1601,19 +1466,18 @@ class ProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Origin = - apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true + fun validate(): Origin = apply { + if (validated) { + return@apply } + id() + _xactId() + objectId() + objectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1622,7 +1486,6 @@ class ProjectLogsEvent @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Origin]. * * The following fields are required: - * * ```java * .id() * ._xactId() @@ -1630,8 +1493,7 @@ class ProjectLogsEvent @JsonCreator private constructor( * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Origin]. */ @@ -1644,111 +1506,82 @@ class ProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = - apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = apply { + id = origin.id + _xactId = origin._xactId + objectId = origin.objectId + objectType = origin.objectType + additionalProperties = origin.additionalProperties.toMutableMap() + } /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) /** ID of the original event. */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = - apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = - apply { - this.objectType = objectType - } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = Origin( - checkRequired( - "id", id - ), - checkRequired( - "_xactId", _xactId - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + additionalProperties.toImmutable(), ) } /** Type of the object the event is originating from. */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1781,11 +1614,9 @@ class ProjectLogsEvent @JsonCreator private constructor( * 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 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 { @@ -1806,8 +1637,8 @@ class ProjectLogsEvent @JsonCreator private constructor( * 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. + * 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) { @@ -1827,7 +1658,7 @@ class ProjectLogsEvent @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1846,17 +1677,20 @@ class ProjectLogsEvent @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1865,11 +1699,11 @@ class ProjectLogsEvent @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1878,23 +1712,25 @@ class ProjectLogsEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give - * you a variety of signals that help you determine how accurate the outputs are - * compared to what you expect and diagnose failures. For example, a summarization - * app might have one score that tells you how accurate the summary is, and another - * that measures the word similarity between the generated and grouth truth - * summary. The word similarity score could help you determine whether the - * summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety + * of signals that help you determine how accurate the outputs are compared to what you expect + * and diagnose failures. For example, a summarization app might have one score that tells you + * how accurate the summary is, and another that measures the word similarity between the + * generated and grouth truth summary. The word similarity score could help you determine + * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ @NoAutoDetect - class Scores @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Scores + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1903,22 +1739,20 @@ class ProjectLogsEvent @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Scores = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Scores = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Scores]. */ @@ -1927,46 +1761,38 @@ class ProjectLogsEvent @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = - apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } + internal fun from(scores: Scores) = apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1979,11 +1805,11 @@ class ProjectLogsEvent @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && logId == other.logId && orgId == other.orgId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectLogsEvent && id == other.id && _xactId == other._xactId && created == other.created && logId == other.logId && orgId == other.orgId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1992,5 +1818,6 @@ class ProjectLogsEvent @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, logId=$logId, orgId=$orgId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, logId=$logId, orgId=$orgId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index d66db835..6694a858 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project object by its id */ -class ProjectRetrieveParams private constructor( +class ProjectRetrieveParams +private constructor( private val projectId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Project id */ @@ -29,10 +29,10 @@ class ProjectRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class ProjectRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectRetrieveParams]. + * Returns a mutable builder for constructing an instance of [ProjectRetrieveParams]. * * The following fields are required: - * * ```java * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectRetrieveParams]. */ @@ -62,162 +59,131 @@ class ProjectRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectRetrieveParams: ProjectRetrieveParams) = - apply { - projectId = projectRetrieveParams.projectId - additionalHeaders = projectRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectRetrieveParams: ProjectRetrieveParams) = apply { + projectId = projectRetrieveParams.projectId + additionalHeaders = projectRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectRetrieveParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectRetrieveParams = ProjectRetrieveParams( - checkRequired( - "projectId", projectId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectId", projectId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectRetrieveParams && projectId == other.projectId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectRetrieveParams{projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 2ebce579..6144049c 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 @@ -31,24 +31,38 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * A project score is a user-configured score, which can be manually-labeled - * through the UI - */ +/** A project score is a user-configured score, which can be manually-labeled through the UI */ @NoAutoDetect -class ProjectScore @JsonCreator private constructor( +class ProjectScore +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") + @ExcludeMissing + private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + private val config: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the project score */ @@ -66,7 +80,8 @@ class ProjectScore @JsonCreator private constructor( fun userId(): String = userId.getRequired("user_id") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) fun config(): Optional = Optional.ofNullable(config.getNullable("config")) @@ -74,64 +89,41 @@ class ProjectScore @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the project score */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ fun position(): Optional = Optional.ofNullable(position.getNullable("position")) /** Unique identifier for the project score */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the project score */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @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 + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @ExcludeMissing fun _categories(): JsonField = categories - @JsonProperty("config") - @ExcludeMissing - fun _config(): JsonField = config + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config /** Date of project score creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Textual description of the project score */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position @JsonAnyGetter @ExcludeMissing @@ -139,25 +131,24 @@ class ProjectScore @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ProjectScore = - apply { - if (validated) { - return@apply - } - - id() - name() - projectId() - scoreType() - userId() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - created() - description() - position() - validated = true + fun validate(): ProjectScore = apply { + if (validated) { + return@apply } + id() + name() + projectId() + scoreType() + userId() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + created() + description() + position() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -166,7 +157,6 @@ class ProjectScore @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [ProjectScore]. * * The following fields are required: - * * ```java * .id() * .name() @@ -175,8 +165,7 @@ class ProjectScore @JsonCreator private constructor( * .userId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScore]. */ @@ -195,75 +184,57 @@ class ProjectScore @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScore: ProjectScore) = - apply { - id = projectScore.id - name = projectScore.name - projectId = projectScore.projectId - scoreType = projectScore.scoreType - userId = projectScore.userId - categories = projectScore.categories - config = projectScore.config - created = projectScore.created - description = projectScore.description - position = projectScore.position - additionalProperties = projectScore.additionalProperties.toMutableMap() - } + internal fun from(projectScore: ProjectScore) = apply { + id = projectScore.id + name = projectScore.name + projectId = projectScore.projectId + scoreType = projectScore.scoreType + userId = projectScore.userId + categories = projectScore.categories + config = projectScore.config + created = projectScore.created + description = projectScore.description + position = projectScore.position + additionalProperties = projectScore.additionalProperties.toMutableMap() + } /** Unique identifier for the project score */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project score */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = 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)) - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = - apply { - this.categories = categories - } + fun categories(categories: JsonField) = apply { this.categories = categories } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = + categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) @@ -272,16 +243,14 @@ class ProjectScore @JsonCreator private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = + categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = - apply { - this.config = config - } + fun config(config: JsonField) = apply { this.config = config } /** Date of project score creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -290,10 +259,7 @@ class ProjectScore @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project score creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -302,100 +268,64 @@ class ProjectScore @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ fun position(position: String?) = position(JsonField.ofNullable(position)) - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ fun position(position: Optional) = position(position.getOrNull()) - /** - * An optional LexoRank-based string that sets the sort position for the score in - * the UI - */ - fun position(position: JsonField) = - apply { - this.position = position - } + /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + fun position(position: JsonField) = apply { this.position = position } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScore = ProjectScore( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "scoreType", scoreType - ), - checkRequired( - "userId", userId - ), - categories, - config, - created, - description, - position, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("scoreType", scoreType), + checkRequired("userId", userId), + categories, + config, + created, + description, + position, + additionalProperties.toImmutable(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -428,11 +358,9 @@ class ProjectScore @JsonCreator private constructor( * 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 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 { @@ -443,18 +371,17 @@ class ProjectScore @JsonCreator private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -470,11 +397,11 @@ class ProjectScore @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -490,20 +417,23 @@ class ProjectScore @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -514,13 +444,13 @@ class ProjectScore @JsonCreator private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories private constructor( + class Categories + private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, - ) { /** For categorical-type project scores, the list of all categories */ @@ -556,49 +486,48 @@ class ProjectScore @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = - apply { - if (validated) { - return@apply - } + fun validate(): Categories = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) { - - } + override fun visitMinimum(minimum: List) {} override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -617,23 +546,22 @@ class ProjectScore @JsonCreator private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = Categories(categorical = categorical) + fun ofCategorical(categorical: List) = + Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic - fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic - fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of - * type [T]. + * An interface that defines how to map each variant of [Categories] to a value of type [T]. */ interface Visitor { @@ -651,59 +579,70 @@ class ProjectScore @JsonCreator private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [Categories] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Weighted + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -712,22 +651,20 @@ class ProjectScore @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Weighted = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Weighted = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -736,46 +673,41 @@ class ProjectScore @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = - apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -788,9 +720,11 @@ class ProjectScore @JsonCreator private constructor( } @NoAutoDetect - class NullableVariant @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class NullableVariant + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -799,22 +733,20 @@ class ProjectScore @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): NullableVariant = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -823,46 +755,41 @@ class ProjectScore @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = - apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -876,11 +803,11 @@ class ProjectScore @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScore && id == other.id && name == other.name && projectId == other.projectId && scoreType == other.scoreType && userId == other.userId && categories == other.categories && config == other.config && created == other.created && description == other.description && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScore && id == other.id && name == other.name && projectId == other.projectId && scoreType == other.scoreType && userId == other.userId && categories == other.categories && config == other.config && created == other.created && description == other.description && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -889,5 +816,6 @@ class ProjectScore @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectScore{id=$id, name=$name, projectId=$projectId, scoreType=$scoreType, userId=$userId, categories=$categories, config=$config, created=$created, description=$description, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScore{id=$id, name=$name, projectId=$projectId, scoreType=$scoreType, userId=$userId, categories=$categories, config=$config, created=$created, description=$description, position=$position, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index cc936db0..9637cd01 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -18,11 +18,12 @@ import java.util.Objects /** For categorical-type project scores, defines a single category */ @NoAutoDetect -class ProjectScoreCategory @JsonCreator private constructor( +class ProjectScoreCategory +@JsonCreator +private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Name of the category */ @@ -32,14 +33,10 @@ class ProjectScoreCategory @JsonCreator private constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -47,34 +44,30 @@ class ProjectScoreCategory @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreCategory = - apply { - if (validated) { - return@apply - } - - name() - value() - validated = true + fun validate(): ProjectScoreCategory = apply { + if (validated) { + return@apply } + name() + value() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectScoreCategory]. + * Returns a mutable builder for constructing an instance of [ProjectScoreCategory]. * * The following fields are required: - * * ```java * .name() * .value() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScoreCategory]. */ @@ -85,75 +78,57 @@ class ProjectScoreCategory @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreCategory: ProjectScoreCategory) = - apply { - name = projectScoreCategory.name - value = projectScoreCategory.value - additionalProperties = projectScoreCategory.additionalProperties.toMutableMap() - } + internal fun from(projectScoreCategory: ProjectScoreCategory) = apply { + name = projectScoreCategory.name + value = projectScoreCategory.value + additionalProperties = projectScoreCategory.additionalProperties.toMutableMap() + } /** Name of the category */ fun name(name: String) = name(JsonField.of(name)) /** Name of the category */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) /** Numerical value of the category. Must be between 0 and 1, inclusive */ - fun value(value: JsonField) = - apply { - this.value = value - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScoreCategory = ProjectScoreCategory( - checkRequired( - "name", name - ), - checkRequired( - "value", value - ), - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("value", value), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreCategory && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCategory && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -162,5 +137,6 @@ class ProjectScoreCategory @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 5650b1eb..82cf7754 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -20,17 +20,26 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectScoreConfig @JsonCreator private constructor( - @JsonProperty("destination") @ExcludeMissing private val destination: JsonField = JsonMissing.of(), - @JsonProperty("multi_select") @ExcludeMissing private val multiSelect: JsonField = JsonMissing.of(), - @JsonProperty("online") @ExcludeMissing private val online: JsonField = JsonMissing.of(), +class ProjectScoreConfig +@JsonCreator +private constructor( + @JsonProperty("destination") + @ExcludeMissing + private val destination: JsonField = JsonMissing.of(), + @JsonProperty("multi_select") + @ExcludeMissing + private val multiSelect: JsonField = JsonMissing.of(), + @JsonProperty("online") + @ExcludeMissing + private val online: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { - fun destination(): Optional = Optional.ofNullable(destination.getNullable("destination")) + fun destination(): Optional = + Optional.ofNullable(destination.getNullable("destination")) - fun multiSelect(): Optional = Optional.ofNullable(multiSelect.getNullable("multi_select")) + fun multiSelect(): Optional = + Optional.ofNullable(multiSelect.getNullable("multi_select")) fun online(): Optional = Optional.ofNullable(online.getNullable("online")) @@ -42,9 +51,7 @@ class ProjectScoreConfig @JsonCreator private constructor( @ExcludeMissing fun _multiSelect(): JsonField = multiSelect - @JsonProperty("online") - @ExcludeMissing - fun _online(): JsonField = online + @JsonProperty("online") @ExcludeMissing fun _online(): JsonField = online @JsonAnyGetter @ExcludeMissing @@ -52,25 +59,23 @@ class ProjectScoreConfig @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ProjectScoreConfig = - apply { - if (validated) { - return@apply - } - - destination() - multiSelect() - online().ifPresent { it.validate() } - validated = true + fun validate(): ProjectScoreConfig = apply { + if (validated) { + return@apply } + destination() + multiSelect() + online().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectScoreConfig]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScoreConfig]. */ @@ -82,22 +87,20 @@ class ProjectScoreConfig @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreConfig: ProjectScoreConfig) = - apply { - destination = projectScoreConfig.destination - multiSelect = projectScoreConfig.multiSelect - online = projectScoreConfig.online - additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() - } + internal fun from(projectScoreConfig: ProjectScoreConfig) = apply { + destination = projectScoreConfig.destination + multiSelect = projectScoreConfig.multiSelect + online = projectScoreConfig.online + additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() + } fun destination(destination: Destination?) = destination(JsonField.ofNullable(destination)) fun destination(destination: Optional) = destination(destination.getOrNull()) - fun destination(destination: JsonField) = - apply { - this.destination = destination - } + fun destination(destination: JsonField) = apply { + this.destination = destination + } fun multiSelect(multiSelect: Boolean?) = multiSelect(JsonField.ofNullable(multiSelect)) @@ -105,70 +108,49 @@ class ProjectScoreConfig @JsonCreator private constructor( fun multiSelect(multiSelect: Optional) = multiSelect(multiSelect.getOrNull()) - fun multiSelect(multiSelect: JsonField) = - apply { - this.multiSelect = multiSelect - } + fun multiSelect(multiSelect: JsonField) = apply { this.multiSelect = multiSelect } fun online(online: OnlineScoreConfig?) = online(JsonField.ofNullable(online)) fun online(online: Optional) = online(online.getOrNull()) - fun online(online: JsonField) = - apply { - this.online = online - } + fun online(online: JsonField) = apply { this.online = online } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectScoreConfig = - ProjectScoreConfig( - destination, - multiSelect, - online, - additionalProperties.toImmutable(), - ) + ProjectScoreConfig(destination, multiSelect, online, additionalProperties.toImmutable()) } - class Destination @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Destination @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -179,36 +161,32 @@ class ProjectScoreConfig @JsonCreator private constructor( /** An enum containing [Destination]'s known values. */ enum class Known { - EXPECTED, + EXPECTED } /** - * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] member. * * An instance of [Destination] 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 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 { EXPECTED, /** - * An enum member indicating that [Destination] was instantiated with an unknown - * value. + * An enum member indicating that [Destination] 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. + * 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. + * 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) { @@ -219,11 +197,11 @@ class ProjectScoreConfig @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -234,20 +212,23 @@ class ProjectScoreConfig @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ + return /* spotless:off */ other is Destination && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -256,11 +237,11 @@ class ProjectScoreConfig @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreConfig && destination == other.destination && multiSelect == other.multiSelect && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreConfig && destination == other.destination && multiSelect == other.multiSelect && online == other.online && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -269,5 +250,6 @@ class ProjectScoreConfig @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectScoreConfig{destination=$destination, multiSelect=$multiSelect, online=$online, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectScoreConfig{destination=$destination, multiSelect=$multiSelect, online=$online, additionalProperties=$additionalProperties}" } 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 7661dfe8..49401ff2 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 @@ -34,15 +34,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project_score. If there is an existing project_score in the project - * with the same name as the one specified in the request, will return the existing - * project_score unmodified + * Create a new project_score. If there is an existing project_score in the project with the same + * name as the one specified in the request, will return the existing project_score unmodified */ -class ProjectScoreCreateParams private constructor( +class ProjectScoreCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the project score */ @@ -85,27 +84,37 @@ class ProjectScoreCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** - * A project score is a user-configured score, which can be manually-labeled - * through the UI - */ + /** A project score is a user-configured score, which can be manually-labeled through the UI */ @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") + @ExcludeMissing + private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project score */ @@ -118,22 +127,21 @@ class ProjectScoreCreateParams private constructor( fun scoreType(): ScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = + Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** The type of the configured score */ @JsonProperty("score_type") @@ -160,21 +168,20 @@ class ProjectScoreCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - scoreType() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + scoreType() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -183,15 +190,13 @@ class ProjectScoreCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -206,73 +211,63 @@ class ProjectScoreCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - scoreType = body.scoreType - categories = body.categories - config = body.config - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + scoreType = body.scoreType + categories = body.categories + config = body.config + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = 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.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = - apply { - this.categories = categories - } + fun categories(categories: JsonField) = apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = + categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = + categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = + categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = + categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = - apply { - this.config = config - } + fun config(config: JsonField) = apply { this.config = config } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -281,61 +276,47 @@ class ProjectScoreCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "scoreType", scoreType - ), - categories, - config, - description, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("scoreType", scoreType), + categories, + config, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -344,7 +325,8 @@ class ProjectScoreCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -352,19 +334,16 @@ class ProjectScoreCreateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectScoreCreateParams]. + * Returns a mutable builder for constructing an instance of [ProjectScoreCreateParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScoreCreateParams]. */ @@ -376,287 +355,204 @@ class ProjectScoreCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreCreateParams: ProjectScoreCreateParams) = - apply { - body = projectScoreCreateParams.body.toBuilder() - additionalHeaders = projectScoreCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreCreateParams: ProjectScoreCreateParams) = apply { + body = projectScoreCreateParams.body.toBuilder() + additionalHeaders = projectScoreCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project score */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the project score */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + 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: ScoreType) = 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) - } + fun categories(categories: Categories) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = - apply { - body.categories(categories) - } + fun categories(categories: JsonField) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - apply { - body.categories(weighted) - } + fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - apply { - body.categoriesOfMinimum(minimum) - } + fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = - apply { - body.config(config) - } + fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = - apply { - body.config(config) - } + fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreCreateParams = ProjectScoreCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -689,11 +585,9 @@ class ProjectScoreCreateParams private constructor( * 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 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 { @@ -704,18 +598,17 @@ class ProjectScoreCreateParams private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -731,11 +624,11 @@ class ProjectScoreCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -751,20 +644,23 @@ class ProjectScoreCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -775,13 +671,13 @@ class ProjectScoreCreateParams private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories private constructor( + class Categories + private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, - ) { /** For categorical-type project scores, the list of all categories */ @@ -817,49 +713,48 @@ class ProjectScoreCreateParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = - apply { - if (validated) { - return@apply - } + fun validate(): Categories = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) { - - } + override fun visitMinimum(minimum: List) {} override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -878,23 +773,22 @@ class ProjectScoreCreateParams private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = Categories(categorical = categorical) + fun ofCategorical(categorical: List) = + Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic - fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic - fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of - * type [T]. + * An interface that defines how to map each variant of [Categories] to a value of type [T]. */ interface Visitor { @@ -912,59 +806,70 @@ class ProjectScoreCreateParams private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [Categories] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Weighted + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -973,22 +878,20 @@ class ProjectScoreCreateParams private constructor( private var validated: Boolean = false - fun validate(): Weighted = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Weighted = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -997,46 +900,41 @@ class ProjectScoreCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = - apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1049,9 +947,11 @@ class ProjectScoreCreateParams private constructor( } @NoAutoDetect - class NullableVariant @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class NullableVariant + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1060,22 +960,20 @@ class ProjectScoreCreateParams private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): NullableVariant = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -1084,46 +982,41 @@ class ProjectScoreCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = - apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1137,14 +1030,15 @@ class ProjectScoreCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectScoreCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectScoreCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 1ddf0990..291b304d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project_score object by its id */ -class ProjectScoreDeleteParams private constructor( +class ProjectScoreDeleteParams +private constructor( private val projectScoreId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** ProjectScore id */ @@ -31,17 +31,18 @@ class ProjectScoreDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -49,17 +50,14 @@ class ProjectScoreDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectScoreDeleteParams]. + * Returns a mutable builder for constructing an instance of [ProjectScoreDeleteParams]. * * The following fields are required: - * * ```java * .projectScoreId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScoreDeleteParams]. */ @@ -72,190 +70,156 @@ class ProjectScoreDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectScoreDeleteParams: ProjectScoreDeleteParams) = - apply { - projectScoreId = projectScoreDeleteParams.projectScoreId - additionalHeaders = projectScoreDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = projectScoreDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectScoreDeleteParams: ProjectScoreDeleteParams) = apply { + projectScoreId = projectScoreDeleteParams.projectScoreId + additionalHeaders = projectScoreDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectScoreDeleteParams.additionalBodyProperties.toMutableMap() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = - apply { - this.projectScoreId = projectScoreId - } + fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( - checkRequired( - "projectScoreId", projectScoreId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("projectScoreId", projectScoreId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectScoreDeleteParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index e082c718..f0864a38 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.ProjectScoreService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ -class ProjectScoreListPage private constructor( +class ProjectScoreListPage +private constructor( private val projectScoresService: ProjectScoreService, private val params: ProjectScoreListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class ProjectScoreListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListPage && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListPage && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ - override fun toString() = "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" + override fun toString() = + "ProjectScoreListPage{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectScoreListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectScoreListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectScoresService.list(it) } + return getNextPageParams().map { projectScoresService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -73,19 +83,21 @@ class ProjectScoreListPage private constructor( companion object { @JvmStatic - fun of(projectScoresService: ProjectScoreService, params: ProjectScoreListParams, response: Response) = - ProjectScoreListPage( - projectScoresService, - params, - response, - ) + fun of( + projectScoresService: ProjectScoreService, + params: ProjectScoreListParams, + response: Response, + ) = ProjectScoreListPage(projectScoresService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,38 +111,34 @@ class ProjectScoreListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { - /** - * Returns a mutable builder for constructing an instance of - * [ProjectScoreListPage]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [ProjectScoreListPage]. */ + @JvmStatic fun builder() = Builder() } class Builder { @@ -139,48 +147,39 @@ class ProjectScoreListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ProjectScoreListPage, + class AutoPager(private val firstPage: ProjectScoreListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index 342ba7fe..f3328758 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.ProjectScoreServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ -class ProjectScoreListPageAsync private constructor( +class ProjectScoreListPageAsync +private constructor( private val projectScoresService: ProjectScoreServiceAsync, private val params: ProjectScoreListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class ProjectScoreListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListPageAsync && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListPageAsync && projectScoresService == other.projectScoresService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoresService, params, response) /* spotless:on */ - override fun toString() = "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" + override fun toString() = + "ProjectScoreListPageAsync{projectScoresService=$projectScoresService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectScoreListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectScoreListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - projectScoresService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { projectScoresService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,21 @@ class ProjectScoreListPageAsync private constructor( companion object { @JvmStatic - fun of(projectScoresService: ProjectScoreServiceAsync, params: ProjectScoreListParams, response: Response) = - ProjectScoreListPageAsync( - projectScoresService, - params, - response, - ) + fun of( + projectScoresService: ProjectScoreServiceAsync, + params: ProjectScoreListParams, + response: Response, + ) = ProjectScoreListPageAsync(projectScoresService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,29 +113,29 @@ class ProjectScoreListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -136,8 +143,7 @@ class ProjectScoreListPageAsync private constructor( * Returns a mutable builder for constructing an instance of * [ProjectScoreListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +152,46 @@ class ProjectScoreListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ProjectScoreListPageAsync, - - ) { + class AutoPager(private val firstPage: ProjectScoreListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (ProjectScore) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (ProjectScore) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } 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 879f1efa..6f86bc5e 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 @@ -26,10 +26,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ -class ProjectScoreListParams private constructor( +class ProjectScoreListParams +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -41,21 +42,20 @@ class ProjectScoreListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -80,9 +80,9 @@ class ProjectScoreListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -93,69 +93,28 @@ class ProjectScoreListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.projectId?.let { - queryParams.put( - "project_id", listOf(it.toString()) - ) - } - this.projectName?.let { - queryParams.put( - "project_name", listOf(it.toString()) - ) - } - this.projectScoreName?.let { - queryParams.put( - "project_score_name", listOf(it.toString()) - ) - } - this.scoreType?.let { - queryParams.put( - "score_type", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.projectScoreName?.let { queryParams.put("project_score_name", listOf(it.toString())) } + this.scoreType?.let { queryParams.put("score_type", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): ProjectScoreListParams = builder().build() + @JvmStatic fun none(): ProjectScoreListParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of - * [ProjectScoreListParams]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [ProjectScoreListParams]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScoreListParams]. */ @@ -175,74 +134,64 @@ class ProjectScoreListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreListParams: ProjectScoreListParams) = - apply { - endingBefore = projectScoreListParams.endingBefore - ids = projectScoreListParams.ids - limit = projectScoreListParams.limit - orgName = projectScoreListParams.orgName - projectId = projectScoreListParams.projectId - projectName = projectScoreListParams.projectName - projectScoreName = projectScoreListParams.projectScoreName - scoreType = projectScoreListParams.scoreType - startingAfter = projectScoreListParams.startingAfter - additionalHeaders = projectScoreListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreListParams: ProjectScoreListParams) = apply { + endingBefore = projectScoreListParams.endingBefore + ids = projectScoreListParams.ids + limit = projectScoreListParams.limit + orgName = projectScoreListParams.orgName + projectId = projectScoreListParams.projectId + projectName = projectScoreListParams.projectName + projectScoreName = projectScoreListParams.projectScoreName + scoreType = projectScoreListParams.scoreType + startingAfter = projectScoreListParams.startingAfter + additionalHeaders = projectScoreListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -251,46 +200,34 @@ class ProjectScoreListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = - apply { - this.projectName = projectName - } + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_score to search for */ - fun projectScoreName(projectScoreName: String?) = - apply { - this.projectScoreName = projectScoreName - } + fun projectScoreName(projectScoreName: String?) = apply { + this.projectScoreName = projectScoreName + } /** Name of the project_score to search for */ - fun projectScoreName(projectScoreName: Optional) = projectScoreName(projectScoreName.getOrNull()) + fun projectScoreName(projectScoreName: Optional) = + projectScoreName(projectScoreName.getOrNull()) /** The type of the configured score */ - fun scoreType(scoreType: ScoreType?) = - apply { - this.scoreType = scoreType - } + fun scoreType(scoreType: ScoreType?) = apply { this.scoreType = scoreType } /** The type of the configured score */ fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) @@ -299,180 +236,153 @@ class ProjectScoreListParams private constructor( fun scoreType(project: ScoreType.ProjectScoreType) = scoreType(ScoreType.ofProject(project)) /** The type of the configured score */ - fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) + fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = + scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreListParams = ProjectScoreListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectScoreName, - scoreType, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectScoreName, + scoreType, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -490,19 +400,19 @@ class ProjectScoreListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -517,17 +427,12 @@ class ProjectScoreListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -537,43 +442,46 @@ class ProjectScoreListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } @@ -581,18 +489,19 @@ class ProjectScoreListParams private constructor( /** The type of the configured score */ @JsonDeserialize(using = ScoreType.Deserializer::class) @JsonSerialize(using = ScoreType.Serializer::class) - class ScoreType private constructor( + class ScoreType + private constructor( private val project: ProjectScoreType? = null, private val projectScoreTypes: List? = null, private val _json: JsonValue? = null, - ) { /** The type of the configured score */ fun project(): Optional = Optional.ofNullable(project) /** The type of the configured score */ - fun projectScoreTypes(): Optional> = Optional.ofNullable(projectScoreTypes) + fun projectScoreTypes(): Optional> = + Optional.ofNullable(projectScoreTypes) fun isProject(): Boolean = project != null @@ -602,24 +511,25 @@ class ProjectScoreListParams private constructor( fun asProject(): ProjectScoreType = project.getOrThrow("project") /** The type of the configured score */ - fun asProjectScoreTypes(): List = projectScoreTypes.getOrThrow("projectScoreTypes") + fun asProjectScoreTypes(): List = + projectScoreTypes.getOrThrow("projectScoreTypes") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - project != null -> visitor.visitProject(project) - projectScoreTypes != null -> visitor.visitProjectScoreTypes(projectScoreTypes) - else -> visitor.unknown(_json) - } + return when { + project != null -> visitor.visitProject(project) + projectScoreTypes != null -> visitor.visitProjectScoreTypes(projectScoreTypes) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && project == other.project && projectScoreTypes == other.projectScoreTypes /* spotless:on */ + return /* spotless:off */ other is ScoreType && project == other.project && projectScoreTypes == other.projectScoreTypes /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(project, projectScoreTypes) /* spotless:on */ @@ -635,17 +545,16 @@ class ProjectScoreListParams private constructor( companion object { /** The type of the configured score */ - @JvmStatic - fun ofProject(project: ProjectScoreType) = ScoreType(project = project) + @JvmStatic fun ofProject(project: ProjectScoreType) = ScoreType(project = project) /** The type of the configured score */ @JvmStatic - fun ofProjectScoreTypes(projectScoreTypes: List) = ScoreType(projectScoreTypes = projectScoreTypes) + fun ofProjectScoreTypes(projectScoreTypes: List) = + ScoreType(projectScoreTypes = projectScoreTypes) } /** - * An interface that defines how to map each variant of [ScoreType] to a value of - * type [T]. + * An interface that defines how to map each variant of [ScoreType] to a value of type [T]. */ interface Visitor { @@ -658,62 +567,65 @@ class ProjectScoreListParams private constructor( /** * Maps an unknown variant of [ScoreType] to a value of type [T]. * - * An instance of [ScoreType] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [ScoreType] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ScoreType: $json") + throw BraintrustInvalidDataException("Unknown ScoreType: $json") } } internal class Deserializer : BaseDeserializer(ScoreType::class) { override fun ObjectCodec.deserialize(node: JsonNode): ScoreType { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ScoreType(project = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return ScoreType(projectScoreTypes = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return ScoreType(project = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return ScoreType(projectScoreTypes = it, _json = json) + } - return ScoreType(_json = json) + return ScoreType(_json = json) } } internal class Serializer : BaseSerializer(ScoreType::class) { - override fun serialize(value: ScoreType, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.project != null -> generator.writeObject(value.project) - value.projectScoreTypes != null -> generator.writeObject(value.projectScoreTypes) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ScoreType") - } + override fun serialize( + value: ScoreType, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.project != null -> generator.writeObject(value.project) + value.projectScoreTypes != null -> + generator.writeObject(value.projectScoreTypes) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ScoreType") + } } } /** The type of the configured score */ - class ProjectScoreType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -746,13 +658,10 @@ class ProjectScoreListParams private constructor( * 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. - * + * 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 { @@ -773,8 +682,8 @@ class ProjectScoreListParams private constructor( * 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. + * 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) { @@ -794,7 +703,7 @@ class ProjectScoreListParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -813,17 +722,20 @@ class ProjectScoreListParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -832,21 +744,19 @@ class ProjectScoreListParams private constructor( } /** The type of the configured score */ - class ProjectScoreType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -879,13 +789,10 @@ class ProjectScoreListParams private constructor( * 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. - * + * 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 { @@ -906,8 +813,8 @@ class ProjectScoreListParams private constructor( * 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. + * 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) { @@ -927,7 +834,7 @@ class ProjectScoreListParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -946,17 +853,20 @@ class ProjectScoreListParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ProjectScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -966,14 +876,15 @@ class ProjectScoreListParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectScoreName == other.projectScoreName && scoreType == other.scoreType && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectScoreName, scoreType, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 5a2bad2d..8373825d 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 @@ -34,15 +34,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace project_score. If there is an existing project_score in the - * project with the same name as the one specified in the request, will replace the - * existing project_score with the provided fields + * Create or replace project_score. If there is an existing project_score in the project with the + * same name as the one specified in the request, will replace the existing project_score with the + * provided fields */ -class ProjectScoreReplaceParams private constructor( +class ProjectScoreReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the project score */ @@ -85,27 +85,37 @@ class ProjectScoreReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** - * A project score is a user-configured score, which can be manually-labeled - * through the UI - */ + /** A project score is a user-configured score, which can be manually-labeled through the UI */ @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), - @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("score_type") + @ExcludeMissing + private val scoreType: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project score */ @@ -118,22 +128,21 @@ class ProjectScoreReplaceParams private constructor( fun scoreType(): ScoreType = scoreType.getRequired("score_type") /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = + Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** The type of the configured score */ @JsonProperty("score_type") @@ -160,21 +169,20 @@ class ProjectScoreReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - scoreType() - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + scoreType() + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -183,15 +191,13 @@ class ProjectScoreReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -206,73 +212,63 @@ class ProjectScoreReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - scoreType = body.scoreType - categories = body.categories - config = body.config - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + scoreType = body.scoreType + categories = body.categories + config = body.config + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project score */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = 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.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = - apply { - this.categories = categories - } + fun categories(categories: JsonField) = apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = + categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = + categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = + categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = + categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = - apply { - this.config = config - } + fun config(config: JsonField) = apply { this.config = config } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -281,61 +277,47 @@ class ProjectScoreReplaceParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "scoreType", scoreType - ), - categories, - config, - description, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("scoreType", scoreType), + categories, + config, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && scoreType == other.scoreType && categories == other.categories && config == other.config && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -344,7 +326,8 @@ class ProjectScoreReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, config=$config, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -352,19 +335,16 @@ class ProjectScoreReplaceParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectScoreReplaceParams]. + * Returns a mutable builder for constructing an instance of [ProjectScoreReplaceParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * .scoreType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScoreReplaceParams]. */ @@ -376,287 +356,204 @@ class ProjectScoreReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreReplaceParams: ProjectScoreReplaceParams) = - apply { - body = projectScoreReplaceParams.body.toBuilder() - additionalHeaders = projectScoreReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreReplaceParams: ProjectScoreReplaceParams) = apply { + body = projectScoreReplaceParams.body.toBuilder() + additionalHeaders = projectScoreReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the project score */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the project score */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + 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: ScoreType) = 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) - } + fun categories(categories: Categories) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = - apply { - body.categories(categories) - } + fun categories(categories: JsonField) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - apply { - body.categories(weighted) - } + fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - apply { - body.categoriesOfMinimum(minimum) - } + fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = - apply { - body.config(config) - } + fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = - apply { - body.config(config) - } + fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreReplaceParams = ProjectScoreReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -689,11 +586,9 @@ class ProjectScoreReplaceParams private constructor( * 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 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 { @@ -704,18 +599,17 @@ class ProjectScoreReplaceParams private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -731,11 +625,11 @@ class ProjectScoreReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -751,20 +645,23 @@ class ProjectScoreReplaceParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -775,13 +672,13 @@ class ProjectScoreReplaceParams private constructor( /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories private constructor( + class Categories + private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, - ) { /** For categorical-type project scores, the list of all categories */ @@ -817,49 +714,48 @@ class ProjectScoreReplaceParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = - apply { - if (validated) { - return@apply - } + fun validate(): Categories = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) { - - } + override fun visitMinimum(minimum: List) {} override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -878,23 +774,22 @@ class ProjectScoreReplaceParams private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = Categories(categorical = categorical) + fun ofCategorical(categorical: List) = + Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic - fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic - fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of - * type [T]. + * An interface that defines how to map each variant of [Categories] to a value of type [T]. */ interface Visitor { @@ -912,59 +807,70 @@ class ProjectScoreReplaceParams private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [Categories] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Weighted + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -973,22 +879,20 @@ class ProjectScoreReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Weighted = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Weighted = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -997,46 +901,41 @@ class ProjectScoreReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = - apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1049,9 +948,11 @@ class ProjectScoreReplaceParams private constructor( } @NoAutoDetect - class NullableVariant @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class NullableVariant + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -1060,22 +961,20 @@ class ProjectScoreReplaceParams private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): NullableVariant = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -1084,46 +983,41 @@ class ProjectScoreReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = - apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1137,14 +1031,15 @@ class ProjectScoreReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectScoreReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectScoreReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 8370d2d3..9521a052 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project_score object by its id */ -class ProjectScoreRetrieveParams private constructor( +class ProjectScoreRetrieveParams +private constructor( private val projectScoreId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** ProjectScore id */ @@ -29,10 +29,10 @@ class ProjectScoreRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class ProjectScoreRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectScoreRetrieveParams]. + * Returns a mutable builder for constructing an instance of [ProjectScoreRetrieveParams]. * * The following fields are required: - * * ```java * .projectScoreId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScoreRetrieveParams]. */ @@ -62,162 +59,131 @@ class ProjectScoreRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = - apply { - projectScoreId = projectScoreRetrieveParams.projectScoreId - additionalHeaders = projectScoreRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreRetrieveParams: ProjectScoreRetrieveParams) = apply { + projectScoreId = projectScoreRetrieveParams.projectScoreId + additionalHeaders = projectScoreRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreRetrieveParams.additionalQueryParams.toBuilder() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = - apply { - this.projectScoreId = projectScoreId - } + fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( - checkRequired( - "projectScoreId", projectScoreId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectScoreId", projectScoreId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreRetrieveParams && projectScoreId == other.projectScoreId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 2dd1c1c2..4784736c 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 @@ -34,16 +34,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project_score object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ -class ProjectScoreUpdateParams private constructor( +class ProjectScoreUpdateParams +private constructor( private val projectScoreId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** ProjectScore id */ @@ -83,48 +83,60 @@ class ProjectScoreUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } - /** - * A project score is a user-configured score, which can be manually-labeled - * through the UI - */ + /** A project score is a user-configured score, which can be manually-labeled through the UI */ @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("categories") @ExcludeMissing private val categories: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing private val config: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("score_type") @ExcludeMissing private val scoreType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("categories") + @ExcludeMissing + private val categories: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + private val config: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("score_type") + @ExcludeMissing + private val scoreType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** For categorical-type project scores, the list of all categories */ - fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + fun categories(): Optional = + Optional.ofNullable(categories.getNullable("categories")) - fun config(): Optional = Optional.ofNullable(config.getNullable("config")) + fun config(): Optional = + Optional.ofNullable(config.getNullable("config")) /** Textual description of the project score */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the project score */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The type of the configured score */ - fun scoreType(): Optional = Optional.ofNullable(scoreType.getNullable("score_type")) + fun scoreType(): Optional = + Optional.ofNullable(scoreType.getNullable("score_type")) /** For categorical-type project scores, the list of all categories */ @JsonProperty("categories") @@ -141,9 +153,7 @@ class ProjectScoreUpdateParams private constructor( fun _description(): JsonField = description /** Name of the project score */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The type of the configured score */ @JsonProperty("score_type") @@ -156,27 +166,25 @@ class ProjectScoreUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - categories().ifPresent { it.validate() } - config().ifPresent { it.validate() } - description() - name() - scoreType() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + categories().ifPresent { it.validate() } + config().ifPresent { it.validate() } + description() + name() + scoreType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -190,45 +198,44 @@ class ProjectScoreUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - categories = body.categories - config = body.config - description = body.description - name = body.name - scoreType = body.scoreType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + categories = body.categories + config = body.config + description = body.description + name = body.name + scoreType = body.scoreType + additionalProperties = body.additionalProperties.toMutableMap() + } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories) = categories(JsonField.of(categories)) /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = - apply { - this.categories = categories - } + fun categories(categories: JsonField) = apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) + fun categoriesOfCategorical(categorical: List) = + categories(Categories.ofCategorical(categorical)) /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) + fun categories(weighted: Categories.Weighted) = + categories(Categories.ofWeighted(weighted)) /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) + fun categoriesOfMinimum(minimum: List) = + categories(Categories.ofMinimum(minimum)) /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = categories(Categories.ofNullableVariant(nullableVariant)) + fun categories(nullableVariant: Categories.NullableVariant) = + categories(Categories.ofNullableVariant(nullableVariant)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = - apply { - this.config = config - } + fun config(config: JsonField) = apply { this.config = config } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -237,10 +244,9 @@ class ProjectScoreUpdateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** Name of the project score */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -249,10 +255,7 @@ class ProjectScoreUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project score */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The type of the configured score */ fun scoreType(scoreType: ScoreType?) = scoreType(JsonField.ofNullable(scoreType)) @@ -261,54 +264,44 @@ class ProjectScoreUpdateParams private constructor( 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() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - categories, - config, - description, - name, - scoreType, - additionalProperties.toImmutable(), + categories, + config, + description, + name, + scoreType, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && categories == other.categories && config == other.config && description == other.description && name == other.name && scoreType == other.scoreType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -317,7 +310,8 @@ class ProjectScoreUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{categories=$categories, config=$config, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -325,17 +319,14 @@ class ProjectScoreUpdateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectScoreUpdateParams]. + * Returns a mutable builder for constructing an instance of [ProjectScoreUpdateParams]. * * The following fields are required: - * * ```java * .projectScoreId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectScoreUpdateParams]. */ @@ -348,285 +339,207 @@ class ProjectScoreUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectScoreUpdateParams: ProjectScoreUpdateParams) = - apply { - projectScoreId = projectScoreUpdateParams.projectScoreId - body = projectScoreUpdateParams.body.toBuilder() - additionalHeaders = projectScoreUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectScoreUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectScoreUpdateParams: ProjectScoreUpdateParams) = apply { + projectScoreId = projectScoreUpdateParams.projectScoreId + body = projectScoreUpdateParams.body.toBuilder() + additionalHeaders = projectScoreUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectScoreUpdateParams.additionalQueryParams.toBuilder() + } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = - apply { - this.projectScoreId = projectScoreId - } + fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = - apply { - body.categories(categories) - } + fun categories(categories: Categories) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: JsonField) = - apply { - body.categories(categories) - } + fun categories(categories: JsonField) = apply { body.categories(categories) } /** For categorical-type project scores, the list of all categories */ - fun categoriesOfCategorical(categorical: List) = - apply { - body.categoriesOfCategorical(categorical) - } + fun categoriesOfCategorical(categorical: List) = apply { + body.categoriesOfCategorical(categorical) + } /** For weighted-type project scores, the weights of each score */ - fun categories(weighted: Categories.Weighted) = - apply { - body.categories(weighted) - } + fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } /** For minimum-type project scores, the list of included scores */ - fun categoriesOfMinimum(minimum: List) = - apply { - body.categoriesOfMinimum(minimum) - } + fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - apply { - body.categories(nullableVariant) - } + fun categories(nullableVariant: Categories.NullableVariant) = apply { + body.categories(nullableVariant) + } - fun config(config: ProjectScoreConfig?) = - apply { - body.config(config) - } + fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) - fun config(config: JsonField) = - apply { - body.config(config) - } + fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the project score */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project score */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** Name of the project score */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the project score */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project score */ - fun name(name: JsonField) = - apply { - body.name(name) - } + 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: ScoreType?) = apply { body.scoreType(scoreType) } /** The type of the configured score */ 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) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectScoreUpdateParams = ProjectScoreUpdateParams( - checkRequired( - "projectScoreId", projectScoreId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectScoreId", projectScoreId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** For categorical-type project scores, the list of all categories */ @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories private constructor( + class Categories + private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, - ) { /** For categorical-type project scores, the list of all categories */ @@ -662,49 +575,48 @@ class ProjectScoreUpdateParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - categorical != null -> visitor.visitCategorical(categorical) - weighted != null -> visitor.visitWeighted(weighted) - minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + categorical != null -> visitor.visitCategorical(categorical) + weighted != null -> visitor.visitWeighted(weighted) + minimum != null -> visitor.visitMinimum(minimum) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Categories = - apply { - if (validated) { - return@apply - } + fun validate(): Categories = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitCategorical(categorical: List) { - categorical.forEach { it.validate() } + categorical.forEach { it.validate() } } override fun visitWeighted(weighted: Weighted) { - weighted.validate() + weighted.validate() } - override fun visitMinimum(minimum: List) { - - } + override fun visitMinimum(minimum: List) {} override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ @@ -723,23 +635,22 @@ class ProjectScoreUpdateParams private constructor( /** For categorical-type project scores, the list of all categories */ @JvmStatic - fun ofCategorical(categorical: List) = Categories(categorical = categorical) + fun ofCategorical(categorical: List) = + Categories(categorical = categorical) /** For weighted-type project scores, the weights of each score */ - @JvmStatic - fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) + @JvmStatic fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) /** For minimum-type project scores, the list of included scores */ - @JvmStatic - fun ofMinimum(minimum: List) = Categories(minimum = minimum) + @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Categories(nullableVariant = nullableVariant) } /** - * An interface that defines how to map each variant of [Categories] to a value of - * type [T]. + * An interface that defines how to map each variant of [Categories] to a value of type [T]. */ interface Visitor { @@ -757,59 +668,70 @@ class ProjectScoreUpdateParams private constructor( /** * Maps an unknown variant of [Categories] to a value of type [T]. * - * An instance of [Categories] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [Categories] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } internal class Deserializer : BaseDeserializer(Categories::class) { override fun ObjectCodec.deserialize(node: JsonNode): Categories { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Categories(categorical = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(minimum = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef>()) { + it.forEach { it.validate() } + } + ?.let { + return Categories(categorical = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(minimum = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } internal class Serializer : BaseSerializer(Categories::class) { - override fun serialize(value: Categories, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.categorical != null -> generator.writeObject(value.categorical) - value.weighted != null -> generator.writeObject(value.weighted) - value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Categories") - } + override fun serialize( + value: Categories, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.categorical != null -> generator.writeObject(value.categorical) + value.weighted != null -> generator.writeObject(value.weighted) + value.minimum != null -> generator.writeObject(value.minimum) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Categories") + } } } /** For weighted-type project scores, the weights of each score */ @NoAutoDetect - class Weighted @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Weighted + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -818,22 +740,20 @@ class ProjectScoreUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Weighted = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Weighted = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Weighted]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Weighted]. */ @@ -842,46 +762,41 @@ class ProjectScoreUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(weighted: Weighted) = - apply { - additionalProperties = weighted.additionalProperties.toMutableMap() - } + internal fun from(weighted: Weighted) = apply { + additionalProperties = weighted.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Weighted && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -894,9 +809,11 @@ class ProjectScoreUpdateParams private constructor( } @NoAutoDetect - class NullableVariant @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class NullableVariant + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -905,22 +822,20 @@ class ProjectScoreUpdateParams private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): NullableVariant = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -929,46 +844,41 @@ class ProjectScoreUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = - apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -982,21 +892,17 @@ class ProjectScoreUpdateParams private constructor( } /** The type of the configured score */ - class ScoreType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1029,11 +935,9 @@ class ProjectScoreUpdateParams private constructor( * 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 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 { @@ -1044,18 +948,17 @@ class ProjectScoreUpdateParams private constructor( MAXIMUM, ONLINE, /** - * An enum member indicating that [ScoreType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -1071,11 +974,11 @@ class ProjectScoreUpdateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -1091,20 +994,23 @@ class ProjectScoreUpdateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ScoreType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1113,14 +1019,15 @@ class ProjectScoreUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectScoreUpdateParams && projectScoreId == other.projectScoreId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectScoreId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index d786a3cf..9c9bfe47 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -18,14 +18,18 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ProjectSettings @JsonCreator private constructor( - @JsonProperty("comparison_key") @ExcludeMissing private val comparisonKey: JsonField = JsonMissing.of(), +class ProjectSettings +@JsonCreator +private constructor( + @JsonProperty("comparison_key") + @ExcludeMissing + private val comparisonKey: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(): Optional = Optional.ofNullable(comparisonKey.getNullable("comparison_key")) + fun comparisonKey(): Optional = + Optional.ofNullable(comparisonKey.getNullable("comparison_key")) /** The key used to join two experiments (defaults to `input`). */ @JsonProperty("comparison_key") @@ -38,23 +42,21 @@ class ProjectSettings @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ProjectSettings = - apply { - if (validated) { - return@apply - } - - comparisonKey() - validated = true + fun validate(): ProjectSettings = apply { + if (validated) { + return@apply } + comparisonKey() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ProjectSettings]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectSettings]. */ @@ -64,62 +66,53 @@ class ProjectSettings @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectSettings: ProjectSettings) = - apply { - comparisonKey = projectSettings.comparisonKey - additionalProperties = projectSettings.additionalProperties.toMutableMap() - } + internal fun from(projectSettings: ProjectSettings) = apply { + comparisonKey = projectSettings.comparisonKey + additionalProperties = projectSettings.additionalProperties.toMutableMap() + } /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: String?) = comparisonKey(JsonField.ofNullable(comparisonKey)) + fun comparisonKey(comparisonKey: String?) = + comparisonKey(JsonField.ofNullable(comparisonKey)) /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: Optional) = comparisonKey(comparisonKey.getOrNull()) + fun comparisonKey(comparisonKey: Optional) = + comparisonKey(comparisonKey.getOrNull()) /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: JsonField) = - apply { - this.comparisonKey = comparisonKey - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun comparisonKey(comparisonKey: JsonField) = apply { + this.comparisonKey = comparisonKey + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectSettings = - ProjectSettings( - comparisonKey, additionalProperties.toImmutable() - ) + ProjectSettings(comparisonKey, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -128,5 +121,6 @@ class ProjectSettings @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index f2246bf9..69a309f6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -20,20 +20,29 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * A project tag is a user-configured tag for tracking and filtering your - * experiments, logs, and other data + * A project tag is a user-configured tag for tracking and filtering your experiments, logs, and + * other data */ @NoAutoDetect -class ProjectTag @JsonCreator private constructor( +class ProjectTag +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the project tag */ @@ -54,41 +63,28 @@ class ProjectTag @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the project tag */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Unique identifier for the project tag */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the project tag */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** Color of the tag for the UI */ - @JsonProperty("color") - @ExcludeMissing - fun _color(): JsonField = color + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color /** Date of project tag creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Textual description of the project tag */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing @@ -96,22 +92,21 @@ class ProjectTag @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ProjectTag = - apply { - if (validated) { - return@apply - } - - id() - name() - projectId() - userId() - color() - created() - description() - validated = true + fun validate(): ProjectTag = apply { + if (validated) { + return@apply } + id() + name() + projectId() + userId() + color() + created() + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -120,7 +115,6 @@ class ProjectTag @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [ProjectTag]. * * The following fields are required: - * * ```java * .id() * .name() @@ -128,8 +122,7 @@ class ProjectTag @JsonCreator private constructor( * .userId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectTag]. */ @@ -145,51 +138,38 @@ class ProjectTag @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTag: ProjectTag) = - apply { - id = projectTag.id - name = projectTag.name - projectId = projectTag.projectId - userId = projectTag.userId - color = projectTag.color - created = projectTag.created - description = projectTag.description - additionalProperties = projectTag.additionalProperties.toMutableMap() - } + internal fun from(projectTag: ProjectTag) = apply { + id = projectTag.id + name = projectTag.name + projectId = projectTag.projectId + userId = projectTag.userId + color = projectTag.color + created = projectTag.created + description = projectTag.description + additionalProperties = projectTag.additionalProperties.toMutableMap() + } /** Unique identifier for the project tag */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project tag */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } fun userId(userId: String) = userId(JsonField.of(userId)) - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -198,10 +178,7 @@ class ProjectTag @JsonCreator private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = - apply { - this.color = color - } + fun color(color: JsonField) = apply { this.color = color } /** Date of project tag creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -210,10 +187,7 @@ class ProjectTag @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of project tag creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -222,64 +196,46 @@ class ProjectTag @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = - apply { - this.description = description - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = apply { this.description = description } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ProjectTag = ProjectTag( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "userId", userId - ), - color, - created, - description, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("userId", userId), + color, + created, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTag && id == other.id && name == other.name && projectId == other.projectId && userId == other.userId && color == other.color && created == other.created && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTag && id == other.id && name == other.name && projectId == other.projectId && userId == other.userId && color == other.color && created == other.created && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -288,5 +244,6 @@ class ProjectTag @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ProjectTag{id=$id, name=$name, projectId=$projectId, userId=$userId, color=$color, created=$created, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "ProjectTag{id=$id, name=$name, projectId=$projectId, userId=$userId, color=$color, created=$created, description=$description, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index fd9204c5..1944b66e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -22,15 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new project_tag. If there is an existing project_tag in the project - * with the same name as the one specified in the request, will return the existing - * project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project with the same name + * as the one specified in the request, will return the existing project_tag unmodified */ -class ProjectTagCreateParams private constructor( +class ProjectTagCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the project tag */ @@ -63,21 +62,30 @@ class ProjectTagCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project tag */ @@ -90,22 +98,17 @@ class ProjectTagCreateParams private constructor( fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Color of the tag for the UI */ - @JsonProperty("color") - @ExcludeMissing - fun _color(): JsonField = color + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -118,19 +121,18 @@ class ProjectTagCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - color() - description() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + color() + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -139,14 +141,12 @@ class ProjectTagCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -159,32 +159,25 @@ class ProjectTagCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - color = body.color - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + color = body.color + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -193,10 +186,7 @@ class ProjectTagCreateParams private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = - apply { - this.color = color - } + fun color(color: JsonField) = apply { this.color = color } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -205,57 +195,45 @@ class ProjectTagCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = - apply { - this.description = description - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - color, - description, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + color, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -264,7 +242,8 @@ class ProjectTagCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -272,18 +251,15 @@ class ProjectTagCreateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectTagCreateParams]. + * Returns a mutable builder for constructing an instance of [ProjectTagCreateParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectTagCreateParams]. */ @@ -295,235 +271,177 @@ class ProjectTagCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagCreateParams: ProjectTagCreateParams) = - apply { - body = projectTagCreateParams.body.toBuilder() - additionalHeaders = projectTagCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagCreateParams: ProjectTagCreateParams) = apply { + body = projectTagCreateParams.body.toBuilder() + additionalHeaders = projectTagCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagCreateParams.additionalQueryParams.toBuilder() + } /** Name of the project tag */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the project tag */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Color of the tag for the UI */ - fun color(color: String?) = - apply { - body.color(color) - } + fun color(color: String?) = apply { body.color(color) } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = - apply { - body.color(color) - } + fun color(color: JsonField) = apply { body.color(color) } /** Textual description of the project tag */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagCreateParams = ProjectTagCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectTagCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectTagCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index bcdd7f60..1f3d8f1c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a project_tag object by its id */ -class ProjectTagDeleteParams private constructor( +class ProjectTagDeleteParams +private constructor( private val projectTagId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** ProjectTag id */ @@ -31,17 +31,18 @@ class ProjectTagDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -49,17 +50,14 @@ class ProjectTagDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectTagDeleteParams]. + * Returns a mutable builder for constructing an instance of [ProjectTagDeleteParams]. * * The following fields are required: - * * ```java * .projectTagId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectTagDeleteParams]. */ @@ -72,190 +70,156 @@ class ProjectTagDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(projectTagDeleteParams: ProjectTagDeleteParams) = - apply { - projectTagId = projectTagDeleteParams.projectTagId - additionalHeaders = projectTagDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = projectTagDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(projectTagDeleteParams: ProjectTagDeleteParams) = apply { + projectTagId = projectTagDeleteParams.projectTagId + additionalHeaders = projectTagDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + projectTagDeleteParams.additionalBodyProperties.toMutableMap() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = - apply { - this.projectTagId = projectTagId - } + fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( - checkRequired( - "projectTagId", projectTagId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("projectTagId", projectTagId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is ProjectTagDeleteParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 6f5762aa..3fdf0ee1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.ProjectTagService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ -class ProjectTagListPage private constructor( +class ProjectTagListPage +private constructor( private val projectTagsService: ProjectTagService, private val params: ProjectTagListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class ProjectTagListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListPage && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectTagListPage && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ - override fun toString() = "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" + override fun toString() = + "ProjectTagListPage{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectTagListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectTagListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { projectTagsService.list(it) } + return getNextPageParams().map { projectTagsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -73,19 +83,21 @@ class ProjectTagListPage private constructor( companion object { @JvmStatic - fun of(projectTagsService: ProjectTagService, params: ProjectTagListParams, response: Response) = - ProjectTagListPage( - projectTagsService, - params, - response, - ) + fun of( + projectTagsService: ProjectTagService, + params: ProjectTagListParams, + response: Response, + ) = ProjectTagListPage(projectTagsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +111,34 @@ class ProjectTagListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ProjectTagListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +147,39 @@ class ProjectTagListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ProjectTagListPage, + class AutoPager(private val firstPage: ProjectTagListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 12379625..885b7cbe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.ProjectTagServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ -class ProjectTagListPageAsync private constructor( +class ProjectTagListPageAsync +private constructor( private val projectTagsService: ProjectTagServiceAsync, private val params: ProjectTagListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class ProjectTagListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListPageAsync && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ProjectTagListPageAsync && projectTagsService == other.projectTagsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagsService, params, response) /* spotless:on */ - override fun toString() = "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" + override fun toString() = + "ProjectTagListPageAsync{projectTagsService=$projectTagsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ProjectTagListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + ProjectTagListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - projectTagsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { projectTagsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,21 @@ class ProjectTagListPageAsync private constructor( companion object { @JvmStatic - fun of(projectTagsService: ProjectTagServiceAsync, params: ProjectTagListParams, response: Response) = - ProjectTagListPageAsync( - projectTagsService, - params, - response, - ) + fun of( + projectTagsService: ProjectTagServiceAsync, + params: ProjectTagListParams, + response: Response, + ) = ProjectTagListPageAsync(projectTagsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,38 +113,36 @@ class ProjectTagListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectTagListPageAsync]. + * Returns a mutable builder for constructing an instance of [ProjectTagListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +151,46 @@ class ProjectTagListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ProjectTagListPageAsync, - - ) { + class AutoPager(private val firstPage: ProjectTagListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (ProjectTag) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (ProjectTag) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 44d39849..431a8583 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ -class ProjectTagListParams private constructor( +class ProjectTagListParams +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -37,21 +38,20 @@ class ProjectTagListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -73,9 +73,9 @@ class ProjectTagListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -86,64 +86,27 @@ class ProjectTagListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.projectId?.let { - queryParams.put( - "project_id", listOf(it.toString()) - ) - } - this.projectName?.let { - queryParams.put( - "project_name", listOf(it.toString()) - ) - } - this.projectTagName?.let { - queryParams.put( - "project_tag_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.projectTagName?.let { queryParams.put("project_tag_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): ProjectTagListParams = builder().build() + @JvmStatic fun none(): ProjectTagListParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of - * [ProjectTagListParams]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [ProjectTagListParams]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectTagListParams]. */ @@ -162,73 +125,63 @@ class ProjectTagListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagListParams: ProjectTagListParams) = - apply { - endingBefore = projectTagListParams.endingBefore - ids = projectTagListParams.ids - limit = projectTagListParams.limit - orgName = projectTagListParams.orgName - projectId = projectTagListParams.projectId - projectName = projectTagListParams.projectName - projectTagName = projectTagListParams.projectTagName - startingAfter = projectTagListParams.startingAfter - additionalHeaders = projectTagListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagListParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagListParams: ProjectTagListParams) = apply { + endingBefore = projectTagListParams.endingBefore + ids = projectTagListParams.ids + limit = projectTagListParams.limit + orgName = projectTagListParams.orgName + projectId = projectTagListParams.projectId + projectName = projectTagListParams.projectName + projectTagName = projectTagListParams.projectTagName + startingAfter = projectTagListParams.startingAfter + additionalHeaders = projectTagListParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -237,212 +190,173 @@ class ProjectTagListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = - apply { - this.projectName = projectName - } + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_tag to search for */ - fun projectTagName(projectTagName: String?) = - apply { - this.projectTagName = projectTagName - } + fun projectTagName(projectTagName: String?) = apply { this.projectTagName = projectTagName } /** Name of the project_tag to search for */ - fun projectTagName(projectTagName: Optional) = projectTagName(projectTagName.getOrNull()) + fun projectTagName(projectTagName: Optional) = + projectTagName(projectTagName.getOrNull()) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagListParams = ProjectTagListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectTagName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectTagName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -460,19 +374,19 @@ class ProjectTagListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -487,17 +401,12 @@ class ProjectTagListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -507,56 +416,60 @@ class ProjectTagListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && projectTagName == other.projectTagName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, projectTagName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index f9bf8d6e..ab167ca1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -22,15 +22,15 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace project_tag. If there is an existing project_tag in the - * project with the same name as the one specified in the request, will replace the - * existing project_tag with the provided fields + * Create or replace project_tag. If there is an existing project_tag in the project with the same + * name as the one specified in the request, will replace the existing project_tag with the provided + * fields */ -class ProjectTagReplaceParams private constructor( +class ProjectTagReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the project tag */ @@ -63,21 +63,30 @@ class ProjectTagReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project tag */ @@ -90,22 +99,17 @@ class ProjectTagReplaceParams private constructor( fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Color of the tag for the UI */ - @JsonProperty("color") - @ExcludeMissing - fun _color(): JsonField = color + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -118,19 +122,18 @@ class ProjectTagReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - color() - description() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + color() + description() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -139,14 +142,12 @@ class ProjectTagReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -159,32 +160,25 @@ class ProjectTagReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - color = body.color - description = body.description - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + color = body.color + description = body.description + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) /** Name of the project tag */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -193,10 +187,7 @@ class ProjectTagReplaceParams private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = - apply { - this.color = color - } + fun color(color: JsonField) = apply { this.color = color } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -205,57 +196,45 @@ class ProjectTagReplaceParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = - apply { - this.description = description - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun description(description: JsonField) = apply { + this.description = description + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - color, - description, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + color, + description, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && color == other.color && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -264,7 +243,8 @@ class ProjectTagReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -272,18 +252,15 @@ class ProjectTagReplaceParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectTagReplaceParams]. + * Returns a mutable builder for constructing an instance of [ProjectTagReplaceParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectTagReplaceParams]. */ @@ -295,235 +272,177 @@ class ProjectTagReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagReplaceParams: ProjectTagReplaceParams) = - apply { - body = projectTagReplaceParams.body.toBuilder() - additionalHeaders = projectTagReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagReplaceParams: ProjectTagReplaceParams) = apply { + body = projectTagReplaceParams.body.toBuilder() + additionalHeaders = projectTagReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the project tag */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the project tag */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Color of the tag for the UI */ - fun color(color: String?) = - apply { - body.color(color) - } + fun color(color: String?) = apply { body.color(color) } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = - apply { - body.color(color) - } + fun color(color: JsonField) = apply { body.color(color) } /** Textual description of the project tag */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagReplaceParams = ProjectTagReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectTagReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectTagReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 5a5b92f3..90bd6349 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a project_tag object by its id */ -class ProjectTagRetrieveParams private constructor( +class ProjectTagRetrieveParams +private constructor( private val projectTagId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** ProjectTag id */ @@ -29,10 +29,10 @@ class ProjectTagRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class ProjectTagRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectTagRetrieveParams]. + * Returns a mutable builder for constructing an instance of [ProjectTagRetrieveParams]. * * The following fields are required: - * * ```java * .projectTagId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectTagRetrieveParams]. */ @@ -62,162 +59,131 @@ class ProjectTagRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = - apply { - projectTagId = projectTagRetrieveParams.projectTagId - additionalHeaders = projectTagRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagRetrieveParams: ProjectTagRetrieveParams) = apply { + projectTagId = projectTagRetrieveParams.projectTagId + additionalHeaders = projectTagRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagRetrieveParams.additionalQueryParams.toBuilder() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = - apply { - this.projectTagId = projectTagId - } + fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( - checkRequired( - "projectTagId", projectTagId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectTagId", projectTagId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagRetrieveParams && projectTagId == other.projectTagId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 1e44d79d..8a93825d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project_tag object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ -class ProjectTagUpdateParams private constructor( +class ProjectTagUpdateParams +private constructor( private val projectTagId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** ProjectTag id */ @@ -61,42 +61,48 @@ class ProjectTagUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("color") @ExcludeMissing private val color: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("color") + @ExcludeMissing + private val color: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Color of the tag for the UI */ fun color(): Optional = Optional.ofNullable(color.getNullable("color")) /** Textual description of the project tag */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the project tag */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** Color of the tag for the UI */ - @JsonProperty("color") - @ExcludeMissing - fun _color(): JsonField = color + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color /** Textual description of the project tag */ @JsonProperty("description") @@ -104,9 +110,7 @@ class ProjectTagUpdateParams private constructor( fun _description(): JsonField = description /** Name of the project tag */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -114,25 +118,23 @@ class ProjectTagUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - color() - description() - name() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + color() + description() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -144,13 +146,12 @@ class ProjectTagUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - color = body.color - description = body.description - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + color = body.color + description = body.description + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) @@ -159,10 +160,7 @@ class ProjectTagUpdateParams private constructor( fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = - apply { - this.color = color - } + fun color(color: JsonField) = apply { this.color = color } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -171,10 +169,9 @@ class ProjectTagUpdateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** Name of the project tag */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -183,52 +180,36 @@ class ProjectTagUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project tag */ - fun name(name: JsonField) = - apply { - this.name = name - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = - Body( - color, - description, - name, - additionalProperties.toImmutable(), - ) + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = Body(color, description, name, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && color == other.color && description == other.description && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -237,7 +218,8 @@ class ProjectTagUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -245,17 +227,14 @@ class ProjectTagUpdateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ProjectTagUpdateParams]. + * Returns a mutable builder for constructing an instance of [ProjectTagUpdateParams]. * * The following fields are required: - * * ```java * .projectTagId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectTagUpdateParams]. */ @@ -268,236 +247,179 @@ class ProjectTagUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectTagUpdateParams: ProjectTagUpdateParams) = - apply { - projectTagId = projectTagUpdateParams.projectTagId - body = projectTagUpdateParams.body.toBuilder() - additionalHeaders = projectTagUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectTagUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectTagUpdateParams: ProjectTagUpdateParams) = apply { + projectTagId = projectTagUpdateParams.projectTagId + body = projectTagUpdateParams.body.toBuilder() + additionalHeaders = projectTagUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectTagUpdateParams.additionalQueryParams.toBuilder() + } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = - apply { - this.projectTagId = projectTagId - } + fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } /** Color of the tag for the UI */ - fun color(color: String?) = - apply { - body.color(color) - } + fun color(color: String?) = apply { body.color(color) } /** Color of the tag for the UI */ fun color(color: Optional) = color(color.getOrNull()) /** Color of the tag for the UI */ - fun color(color: JsonField) = - apply { - body.color(color) - } + fun color(color: JsonField) = apply { body.color(color) } /** Textual description of the project tag */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the project tag */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the project tag */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** Name of the project tag */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the project tag */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project tag */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectTagUpdateParams = ProjectTagUpdateParams( - checkRequired( - "projectTagId", projectTagId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectTagId", projectTagId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectTagUpdateParams && projectTagId == other.projectTagId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectTagId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectTagUpdateParams{projectTagId=$projectTagId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectTagUpdateParams{projectTagId=$projectTagId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index 7fefab19..f47cf5da 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a project object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. */ -class ProjectUpdateParams private constructor( +class ProjectUpdateParams +private constructor( private val projectId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Project id */ @@ -41,8 +41,8 @@ class ProjectUpdateParams private constructor( fun name(): Optional = body.name() /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ fun settings(): Optional = body.settings() @@ -50,8 +50,8 @@ class ProjectUpdateParams private constructor( fun _name(): JsonField = body._name() /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ fun _settings(): JsonField = body._settings() @@ -61,45 +61,49 @@ class ProjectUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("settings") @ExcludeMissing private val settings: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("settings") + @ExcludeMissing + private val settings: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the project */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ - fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) + fun settings(): Optional = + Optional.ofNullable(settings.getNullable("settings")) /** Name of the project */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ @JsonProperty("settings") @ExcludeMissing @@ -111,24 +115,22 @@ class ProjectUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - settings().ifPresent { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + settings().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -139,12 +141,11 @@ class ProjectUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - settings = body.settings - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + settings = body.settings + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the project */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -153,72 +154,54 @@ class ProjectUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the project */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ fun settings(settings: Optional) = settings(settings.getOrNull()) /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ - fun settings(settings: JsonField) = - apply { - this.settings = settings - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = - Body( - name, - settings, - additionalProperties.toImmutable(), - ) + fun settings(settings: JsonField) = apply { this.settings = settings } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = Body(name, settings, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && settings == other.settings && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -227,7 +210,8 @@ class ProjectUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, settings=$settings, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, settings=$settings, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -238,13 +222,11 @@ class ProjectUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [ProjectUpdateParams]. * * The following fields are required: - * * ```java * .projectId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ProjectUpdateParams]. */ @@ -257,230 +239,179 @@ class ProjectUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectUpdateParams: ProjectUpdateParams) = - apply { - projectId = projectUpdateParams.projectId - body = projectUpdateParams.body.toBuilder() - additionalHeaders = projectUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(projectUpdateParams: ProjectUpdateParams) = apply { + projectId = projectUpdateParams.projectId + body = projectUpdateParams.body.toBuilder() + additionalHeaders = projectUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectUpdateParams.additionalQueryParams.toBuilder() + } /** Project id */ - fun projectId(projectId: String) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String) = apply { this.projectId = projectId } /** Name of the project */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the project */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the project */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ - fun settings(settings: ProjectSettings?) = - apply { - body.settings(settings) - } + fun settings(settings: ProjectSettings?) = apply { body.settings(settings) } /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ fun settings(settings: Optional) = settings(settings.getOrNull()) /** - * Project settings. Patch operations replace all settings, so make sure you - * include all settings you want to keep. + * Project settings. Patch operations replace all settings, so make sure you include all + * settings you want to keep. */ - fun settings(settings: JsonField) = - apply { - body.settings(settings) - } + fun settings(settings: JsonField) = apply { body.settings(settings) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ProjectUpdateParams = ProjectUpdateParams( - checkRequired( - "projectId", projectId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("projectId", projectId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ProjectUpdateParams && projectId == other.projectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ProjectUpdateParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ProjectUpdateParams{projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 13fcc876..5e093784 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -23,32 +23,48 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class Prompt @JsonCreator private constructor( +class Prompt +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") @ExcludeMissing private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), @JsonProperty("log_id") @ExcludeMissing private val logId: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the prompt */ fun id(): String = id.getRequired("id") /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the prompt (see the `version` parameter) */ fun _xactId(): String = _xactId.getRequired("_xact_id") @@ -71,77 +87,59 @@ class Prompt @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) /** User-controlled metadata about the prompt */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Unique identifier for the prompt */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the event + * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve + * a versioned snapshot of the prompt (see the `version` parameter) */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun __xactId(): JsonField = _xactId + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") - @ExcludeMissing - fun _logId(): JsonField = logId + @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Date of prompt creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -149,9 +147,7 @@ class Prompt @JsonCreator private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -159,28 +155,27 @@ class Prompt @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Prompt = - apply { - if (validated) { - return@apply - } - - id() - _xactId() - logId() - name() - orgId() - projectId() - slug() - created() - description() - functionType() - metadata().ifPresent { it.validate() } - promptData().ifPresent { it.validate() } - tags() - validated = true + fun validate(): Prompt = apply { + if (validated) { + return@apply } + id() + _xactId() + logId() + name() + orgId() + projectId() + slug() + created() + description() + functionType() + metadata().ifPresent { it.validate() } + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -189,7 +184,6 @@ class Prompt @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Prompt]. * * The following fields are required: - * * ```java * .id() * ._xactId() @@ -200,8 +194,7 @@ class Prompt @JsonCreator private constructor( * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Prompt]. */ @@ -223,96 +216,72 @@ class Prompt @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(prompt: Prompt) = - apply { - id = prompt.id - _xactId = prompt._xactId - logId = prompt.logId - name = prompt.name - orgId = prompt.orgId - projectId = prompt.projectId - slug = prompt.slug - created = prompt.created - description = prompt.description - functionType = prompt.functionType - metadata = prompt.metadata - promptData = prompt.promptData - tags = prompt.tags.map { it.toMutableList() } - additionalProperties = prompt.additionalProperties.toMutableMap() - } + internal fun from(prompt: Prompt) = apply { + id = prompt.id + _xactId = prompt._xactId + logId = prompt.logId + name = prompt.name + orgId = prompt.orgId + projectId = prompt.projectId + slug = prompt.slug + created = prompt.created + description = prompt.description + functionType = prompt.functionType + metadata = prompt.metadata + promptData = prompt.promptData + tags = prompt.tags.map { it.toMutableList() } + additionalProperties = prompt.additionalProperties.toMutableMap() + } /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed - * the event insertion. Transaction ids are monotonically increasing over time and - * can be used to retrieve a versioned snapshot of the prompt (see the `version` - * parameter) + * The transaction id of an event is unique to the network operation that processed the + * event insertion. Transaction ids are monotonically increasing over time and can be used + * to retrieve a versioned snapshot of the prompt (see the `version` parameter) */ - fun _xactId(_xactId: JsonField) = - apply { - this._xactId = _xactId - } + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) /** A literal 'p' which identifies the object as a project prompt */ - fun logId(logId: JsonField) = - apply { - this.logId = logId - } + fun logId(logId: JsonField) = apply { this.logId = logId } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** Unique identifier for the organization */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** Date of prompt creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -321,10 +290,7 @@ class Prompt @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of prompt creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -333,19 +299,17 @@ class Prompt @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } - fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = apply { + this.functionType = functionType + } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) @@ -354,10 +318,7 @@ class Prompt @JsonCreator private constructor( fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** User-controlled metadata about the prompt */ - fun metadata(metadata: JsonField) = - apply { - this.metadata = metadata - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -366,10 +327,7 @@ class Prompt @JsonCreator private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -378,94 +336,65 @@ class Prompt @JsonCreator private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Prompt = Prompt( - checkRequired( - "id", id - ), - checkRequired( - "_xactId", _xactId - ), - checkRequired( - "logId", logId - ), - checkRequired( - "name", name - ), - checkRequired( - "orgId", orgId - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "slug", slug - ), - created, - description, - functionType, - metadata, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("logId", logId), + checkRequired("name", name), + checkRequired("orgId", orgId), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + created, + description, + functionType, + metadata, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } /** A literal 'p' which identifies the object as a project prompt */ - class LogId @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class LogId @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -476,18 +405,16 @@ class Prompt @JsonCreator private constructor( /** An enum containing [LogId]'s known values. */ enum class Known { - P, + P } /** * An enum containing [LogId]'s known values, as well as an [_UNKNOWN] member. * * An instance of [LogId] 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 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 { @@ -497,11 +424,11 @@ class Prompt @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -512,11 +439,11 @@ class Prompt @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -527,20 +454,23 @@ class Prompt @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ + return /* spotless:off */ other is LogId && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -548,21 +478,18 @@ class Prompt @JsonCreator private constructor( override fun toString() = value.toString() } - class FunctionType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -586,15 +513,12 @@ class Prompt @JsonCreator private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [FunctionType] 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 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 { @@ -603,18 +527,17 @@ class Prompt @JsonCreator private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown - * value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -628,11 +551,11 @@ class Prompt @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -646,20 +569,23 @@ class Prompt @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -669,9 +595,11 @@ class Prompt @JsonCreator private constructor( /** User-controlled metadata about the prompt */ @NoAutoDetect - class Metadata @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -680,22 +608,20 @@ class Prompt @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metadata = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metadata = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ @@ -704,46 +630,38 @@ class Prompt @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metadata: Metadata) = - apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -756,11 +674,11 @@ class Prompt @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionType == other.functionType && metadata == other.metadata && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Prompt && id == other.id && _xactId == other._xactId && logId == other.logId && name == other.name && orgId == other.orgId && projectId == other.projectId && slug == other.slug && created == other.created && description == other.description && functionType == other.functionType && metadata == other.metadata && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -769,5 +687,6 @@ class Prompt @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Prompt{id=$id, _xactId=$_xactId, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionType=$functionType, metadata=$metadata, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "Prompt{id=$id, _xactId=$_xactId, logId=$logId, name=$name, orgId=$orgId, projectId=$projectId, slug=$slug, created=$created, description=$description, functionType=$functionType, metadata=$metadata, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 0a6c199e..3eee9b8f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -25,15 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new prompt. If there is an existing prompt in the project with the same - * slug as the one specified in the request, will return the existing prompt - * unmodified + * Create a new prompt. If there is an existing prompt in the project with the same slug as the one + * specified in the request, will return the existing prompt unmodified */ -class PromptCreateParams private constructor( +class PromptCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the prompt */ @@ -82,24 +81,39 @@ class PromptCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the prompt */ @@ -112,30 +126,27 @@ class PromptCreateParams private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -152,9 +163,7 @@ class PromptCreateParams private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -162,22 +171,21 @@ class PromptCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - slug() - description() - functionType() - promptData().ifPresent { it.validate() } - tags() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + slug() + description() + functionType() + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -186,15 +194,13 @@ class PromptCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -210,44 +216,34 @@ class PromptCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionType = body.functionType - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionType = body.functionType + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -256,19 +252,19 @@ class PromptCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } - fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = apply { + this.functionType = functionType + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -277,10 +273,9 @@ class PromptCreateParams private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -289,70 +284,54 @@ class PromptCreateParams private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "slug", slug - ), - description, - functionType, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + description, + functionType, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -361,7 +340,8 @@ class PromptCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -372,15 +352,13 @@ class PromptCreateParams private constructor( * Returns a mutable builder for constructing an instance of [PromptCreateParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptCreateParams]. */ @@ -392,286 +370,206 @@ class PromptCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptCreateParams: PromptCreateParams) = - apply { - body = promptCreateParams.body.toBuilder() - additionalHeaders = promptCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = promptCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(promptCreateParams: PromptCreateParams) = apply { + body = promptCreateParams.body.toBuilder() + additionalHeaders = promptCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptCreateParams.additionalQueryParams.toBuilder() + } /** Name of the prompt */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Unique identifier for the prompt */ - fun slug(slug: String) = - apply { - body.slug(slug) - } + fun slug(slug: String) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - body.slug(slug) - } + fun slug(slug: JsonField) = apply { body.slug(slug) } /** Textual description of the prompt */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } - fun functionType(functionType: FunctionType?) = - apply { - body.functionType(functionType) - } + fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = apply { + body.functionType(functionType) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List?) = - apply { - body.tags(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - body.tags(tags) - } + fun tags(tags: JsonField>) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - body.addTag(tag) - } + fun addTag(tag: String) = apply { body.addTag(tag) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptCreateParams = PromptCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } - class FunctionType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -695,15 +593,12 @@ class PromptCreateParams private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [FunctionType] 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 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 { @@ -712,18 +607,17 @@ class PromptCreateParams private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown - * value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -737,11 +631,11 @@ class PromptCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -755,20 +649,23 @@ class PromptCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -777,14 +674,15 @@ class PromptCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "PromptCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "PromptCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 7ab2daf4..c9faaa96 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -33,14 +33,25 @@ import kotlin.jvm.optionals.getOrNull /** The prompt, model, and its parameters */ @NoAutoDetect -class PromptData @JsonCreator private constructor( - @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), - @JsonProperty("origin") @ExcludeMissing private val origin: JsonField = JsonMissing.of(), - @JsonProperty("parser") @ExcludeMissing private val parser: JsonField = JsonMissing.of(), - @JsonProperty("prompt") @ExcludeMissing private val prompt: JsonField = JsonMissing.of(), - @JsonProperty("tool_functions") @ExcludeMissing private val toolFunctions: JsonField> = JsonMissing.of(), +class PromptData +@JsonCreator +private constructor( + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), + @JsonProperty("parser") + @ExcludeMissing + private val parser: JsonField = JsonMissing.of(), + @JsonProperty("prompt") + @ExcludeMissing + private val prompt: JsonField = JsonMissing.of(), + @JsonProperty("tool_functions") + @ExcludeMissing + private val toolFunctions: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -51,23 +62,16 @@ class PromptData @JsonCreator private constructor( fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) - fun toolFunctions(): Optional> = Optional.ofNullable(toolFunctions.getNullable("tool_functions")) + fun toolFunctions(): Optional> = + Optional.ofNullable(toolFunctions.getNullable("tool_functions")) - @JsonProperty("options") - @ExcludeMissing - fun _options(): JsonField = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options - @JsonProperty("origin") - @ExcludeMissing - fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin - @JsonProperty("parser") - @ExcludeMissing - fun _parser(): JsonField = parser + @JsonProperty("parser") @ExcludeMissing fun _parser(): JsonField = parser - @JsonProperty("prompt") - @ExcludeMissing - fun _prompt(): JsonField = prompt + @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField = prompt @JsonProperty("tool_functions") @ExcludeMissing @@ -79,27 +83,25 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): PromptData = - apply { - if (validated) { - return@apply - } - - options().ifPresent { it.validate() } - origin().ifPresent { it.validate() } - parser().ifPresent { it.validate() } - prompt().ifPresent { it.validate() } - toolFunctions().ifPresent { it.forEach { it.validate() } } - validated = true + fun validate(): PromptData = apply { + if (validated) { + return@apply } + options().ifPresent { it.validate() } + origin().ifPresent { it.validate() } + parser().ifPresent { it.validate() } + prompt().ifPresent { it.validate() } + toolFunctions().ifPresent { it.forEach { it.validate() } } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [PromptData]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptData]. */ @@ -113,135 +115,124 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptData: PromptData) = - apply { - options = promptData.options - origin = promptData.origin - parser = promptData.parser - prompt = promptData.prompt - toolFunctions = promptData.toolFunctions.map { it.toMutableList() } - additionalProperties = promptData.additionalProperties.toMutableMap() - } + internal fun from(promptData: PromptData) = apply { + options = promptData.options + origin = promptData.origin + parser = promptData.parser + prompt = promptData.prompt + toolFunctions = promptData.toolFunctions.map { it.toMutableList() } + additionalProperties = promptData.additionalProperties.toMutableMap() + } fun options(options: PromptOptions?) = options(JsonField.ofNullable(options)) fun options(options: Optional) = options(options.getOrNull()) - fun options(options: JsonField) = - apply { - this.options = options - } + fun options(options: JsonField) = apply { this.options = options } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) fun origin(origin: Optional) = origin(origin.getOrNull()) - fun origin(origin: JsonField) = - apply { - this.origin = origin - } + fun origin(origin: JsonField) = apply { this.origin = origin } fun parser(parser: Parser?) = parser(JsonField.ofNullable(parser)) fun parser(parser: Optional) = parser(parser.getOrNull()) - fun parser(parser: JsonField) = - apply { - this.parser = parser - } + fun parser(parser: JsonField) = apply { this.parser = parser } fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) - fun prompt(prompt: JsonField) = - apply { - this.prompt = prompt - } + fun prompt(prompt: JsonField) = apply { this.prompt = prompt } fun prompt(completion: Prompt.Completion) = prompt(Prompt.ofCompletion(completion)) fun prompt(chat: Prompt.Chat) = prompt(Prompt.ofChat(chat)) - fun prompt(nullableVariant: Prompt.NullableVariant) = prompt(Prompt.ofNullableVariant(nullableVariant)) + fun prompt(nullableVariant: Prompt.NullableVariant) = + prompt(Prompt.ofNullableVariant(nullableVariant)) - fun toolFunctions(toolFunctions: List?) = toolFunctions(JsonField.ofNullable(toolFunctions)) + fun toolFunctions(toolFunctions: List?) = + toolFunctions(JsonField.ofNullable(toolFunctions)) - fun toolFunctions(toolFunctions: Optional>) = toolFunctions(toolFunctions.getOrNull()) + fun toolFunctions(toolFunctions: Optional>) = + toolFunctions(toolFunctions.getOrNull()) - fun toolFunctions(toolFunctions: JsonField>) = - apply { - this.toolFunctions = toolFunctions.map { it.toMutableList() } - } + fun toolFunctions(toolFunctions: JsonField>) = apply { + this.toolFunctions = toolFunctions.map { it.toMutableList() } + } - fun addToolFunction(toolFunction: ToolFunction) = - apply { - toolFunctions = (toolFunctions ?: JsonField.of(mutableListOf())).also { + fun addToolFunction(toolFunction: ToolFunction) = apply { + toolFunctions = + (toolFunctions ?: JsonField.of(mutableListOf())).also { checkKnown("toolFunctions", it).add(toolFunction) } - } + } - fun addToolFunction(function: ToolFunction.Function) = addToolFunction(ToolFunction.ofFunction(function)) + fun addToolFunction(function: ToolFunction.Function) = + addToolFunction(ToolFunction.ofFunction(function)) - fun addToolFunction(global: ToolFunction.Global) = addToolFunction(ToolFunction.ofGlobal(global)) + fun addToolFunction(global: ToolFunction.Global) = + addToolFunction(ToolFunction.ofGlobal(global)) - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptData = PromptData( - options, - origin, - parser, - prompt, - (toolFunctions ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + options, + origin, + parser, + prompt, + (toolFunctions ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Origin @JsonCreator private constructor( - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_id") @ExcludeMissing private val promptId: JsonField = JsonMissing.of(), - @JsonProperty("prompt_version") @ExcludeMissing private val promptVersion: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Origin + @JsonCreator + private constructor( + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_id") + @ExcludeMissing + private val promptId: JsonField = JsonMissing.of(), + @JsonProperty("prompt_version") + @ExcludeMissing + private val promptVersion: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) fun promptId(): Optional = Optional.ofNullable(promptId.getNullable("prompt_id")) - fun promptVersion(): Optional = Optional.ofNullable(promptVersion.getNullable("prompt_version")) + fun promptVersion(): Optional = + Optional.ofNullable(promptVersion.getNullable("prompt_version")) - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - @JsonProperty("prompt_id") - @ExcludeMissing - fun _promptId(): JsonField = promptId + @JsonProperty("prompt_id") @ExcludeMissing fun _promptId(): JsonField = promptId @JsonProperty("prompt_version") @ExcludeMissing @@ -253,25 +244,23 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Origin = - apply { - if (validated) { - return@apply - } - - projectId() - promptId() - promptVersion() - validated = true + fun validate(): Origin = apply { + if (validated) { + return@apply } + projectId() + promptId() + promptVersion() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Origin]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Origin]. */ @@ -283,76 +272,56 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(origin: Origin) = - apply { - projectId = origin.projectId - promptId = origin.promptId - promptVersion = origin.promptVersion - additionalProperties = origin.additionalProperties.toMutableMap() - } + internal fun from(origin: Origin) = apply { + projectId = origin.projectId + promptId = origin.promptId + promptVersion = origin.promptVersion + additionalProperties = origin.additionalProperties.toMutableMap() + } fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } fun promptId(promptId: String) = promptId(JsonField.of(promptId)) - fun promptId(promptId: JsonField) = - apply { - this.promptId = promptId - } + fun promptId(promptId: JsonField) = apply { this.promptId = promptId } fun promptVersion(promptVersion: String) = promptVersion(JsonField.of(promptVersion)) - fun promptVersion(promptVersion: JsonField) = - apply { - this.promptVersion = promptVersion - } + fun promptVersion(promptVersion: JsonField) = apply { + this.promptVersion = promptVersion + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Origin = - Origin( - projectId, - promptId, - promptVersion, - additionalProperties.toImmutable(), - ) + Origin(projectId, promptId, promptVersion, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Origin && projectId == other.projectId && promptId == other.promptId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Origin && projectId == other.projectId && promptId == other.promptId && promptVersion == other.promptVersion && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -361,16 +330,23 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Origin{projectId=$projectId, promptId=$promptId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = + "Origin{projectId=$projectId, promptId=$promptId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Parser @JsonCreator private constructor( - @JsonProperty("choice_scores") @ExcludeMissing private val choiceScores: JsonField = JsonMissing.of(), + class Parser + @JsonCreator + private constructor( + @JsonProperty("choice_scores") + @ExcludeMissing + private val choiceScores: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("use_cot") @ExcludeMissing private val useCot: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("use_cot") + @ExcludeMissing + private val useCot: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun choiceScores(): ChoiceScores = choiceScores.getRequired("choice_scores") @@ -383,13 +359,9 @@ class PromptData @JsonCreator private constructor( @ExcludeMissing fun _choiceScores(): JsonField = choiceScores - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("use_cot") - @ExcludeMissing - fun _useCot(): JsonField = useCot + @JsonProperty("use_cot") @ExcludeMissing fun _useCot(): JsonField = useCot @JsonAnyGetter @ExcludeMissing @@ -397,18 +369,17 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Parser = - apply { - if (validated) { - return@apply - } - - choiceScores().validate() - type() - useCot() - validated = true + fun validate(): Parser = apply { + if (validated) { + return@apply } + choiceScores().validate() + type() + useCot() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -417,15 +388,13 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Parser]. * * The following fields are required: - * * ```java * .choiceScores() * .type() * .useCot() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Parser]. */ @@ -437,80 +406,61 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(parser: Parser) = - apply { - choiceScores = parser.choiceScores - type = parser.type - useCot = parser.useCot - additionalProperties = parser.additionalProperties.toMutableMap() - } + internal fun from(parser: Parser) = apply { + choiceScores = parser.choiceScores + type = parser.type + useCot = parser.useCot + additionalProperties = parser.additionalProperties.toMutableMap() + } fun choiceScores(choiceScores: ChoiceScores) = choiceScores(JsonField.of(choiceScores)) - fun choiceScores(choiceScores: JsonField) = - apply { - this.choiceScores = choiceScores - } + fun choiceScores(choiceScores: JsonField) = apply { + this.choiceScores = choiceScores + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun useCot(useCot: Boolean) = useCot(JsonField.of(useCot)) - fun useCot(useCot: JsonField) = - apply { - this.useCot = useCot - } + fun useCot(useCot: JsonField) = apply { this.useCot = useCot } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Parser = Parser( - checkRequired( - "choiceScores", choiceScores - ), - checkRequired( - "type", type - ), - checkRequired( - "useCot", useCot - ), - additionalProperties.toImmutable(), + checkRequired("choiceScores", choiceScores), + checkRequired("type", type), + checkRequired("useCot", useCot), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ChoiceScores @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class ChoiceScores + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -519,22 +469,20 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ChoiceScores = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): ChoiceScores = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ChoiceScores]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ChoiceScores]. */ @@ -543,46 +491,41 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(choiceScores: ChoiceScores) = - apply { - additionalProperties = choiceScores.additionalProperties.toMutableMap() - } + internal fun from(choiceScores: ChoiceScores) = apply { + additionalProperties = choiceScores.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ChoiceScores = ChoiceScores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChoiceScores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ChoiceScores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -594,21 +537,17 @@ class PromptData @JsonCreator private constructor( override fun toString() = "ChoiceScores{additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -619,18 +558,16 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - LLM_CLASSIFIER, + LLM_CLASSIFIER } /** * 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 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 { @@ -643,8 +580,8 @@ class PromptData @JsonCreator private constructor( * 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. + * 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) { @@ -659,7 +596,7 @@ class PromptData @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -673,17 +610,20 @@ class PromptData @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -692,11 +632,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Parser && choiceScores == other.choiceScores && type == other.type && useCot == other.useCot && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Parser && choiceScores == other.choiceScores && type == other.type && useCot == other.useCot && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -705,17 +645,18 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Parser{choiceScores=$choiceScores, type=$type, useCot=$useCot, additionalProperties=$additionalProperties}" + override fun toString() = + "Parser{choiceScores=$choiceScores, type=$type, useCot=$useCot, additionalProperties=$additionalProperties}" } @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt private constructor( + class Prompt + private constructor( private val completion: Completion? = null, private val chat: Chat? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, - ) { fun completion(): Optional = Optional.ofNullable(completion) @@ -739,44 +680,45 @@ class PromptData @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - completion != null -> visitor.visitCompletion(completion) - chat != null -> visitor.visitChat(chat) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + completion != null -> visitor.visitCompletion(completion) + chat != null -> visitor.visitChat(chat) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Prompt = - apply { - if (validated) { - return@apply - } + fun validate(): Prompt = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitCompletion(completion: Completion) { - completion.validate() + completion.validate() } override fun visitChat(chat: Chat) { - chat.validate() + chat.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(completion, chat, nullableVariant) /* spotless:on */ @@ -792,20 +734,16 @@ class PromptData @JsonCreator private constructor( companion object { - @JvmStatic - fun ofCompletion(completion: Completion) = Prompt(completion = completion) + @JvmStatic fun ofCompletion(completion: Completion) = Prompt(completion = completion) - @JvmStatic - fun ofChat(chat: Chat) = Prompt(chat = chat) + @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = Prompt(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = + Prompt(nullableVariant = nullableVariant) } - /** - * An interface that defines how to map each variant of [Prompt] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Prompt] to a value of type [T]. */ interface Visitor { fun visitCompletion(completion: Completion): T @@ -817,69 +755,78 @@ class PromptData @JsonCreator private constructor( /** * Maps an unknown variant of [Prompt] to a value of type [T]. * - * An instance of [Prompt] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Prompt] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } internal class Deserializer : BaseDeserializer(Prompt::class) { override fun ObjectCodec.deserialize(node: JsonNode): Prompt { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(completion = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(chat = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Prompt(nullableVariant = it, _json = json) - } - - return Prompt(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(completion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(chat = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Prompt(nullableVariant = it, _json = json) + } + + return Prompt(_json = json) } } internal class Serializer : BaseSerializer(Prompt::class) { - override fun serialize(value: Prompt, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.completion != null -> generator.writeObject(value.completion) - value.chat != null -> generator.writeObject(value.chat) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Prompt") - } + override fun serialize( + value: Prompt, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.completion != null -> generator.writeObject(value.completion) + value.chat != null -> generator.writeObject(value.chat) + value.nullableVariant != null -> generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Prompt") + } } } @NoAutoDetect - class Completion @JsonCreator private constructor( - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Completion + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun content(): String = content.getRequired("content") fun type(): Type = type.getRequired("type") - @JsonProperty("content") - @ExcludeMissing - fun _content(): JsonField = content + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -887,17 +834,16 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Completion = - apply { - if (validated) { - return@apply - } - - content() - type() - validated = true + fun validate(): Completion = apply { + if (validated) { + return@apply } + content() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -906,14 +852,12 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Completion]. * * The following fields are required: - * * ```java * .content() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Completion]. */ @@ -924,69 +868,52 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(completion: Completion) = - apply { - content = completion.content - type = completion.type - additionalProperties = completion.additionalProperties.toMutableMap() - } + internal fun from(completion: Completion) = apply { + content = completion.content + type = completion.type + additionalProperties = completion.additionalProperties.toMutableMap() + } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Completion = Completion( - checkRequired( - "content", content - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("content", content), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -996,8 +923,7 @@ class PromptData @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1008,23 +934,23 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - COMPLETION, + COMPLETION } /** * 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 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 { COMPLETION, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -1048,7 +974,7 @@ class PromptData @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1063,16 +989,19 @@ class PromptData @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1081,11 +1010,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Completion && content == other.content && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Completion && content == other.content && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1094,16 +1023,25 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Completion{content=$content, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Completion{content=$content, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Chat @JsonCreator private constructor( - @JsonProperty("messages") @ExcludeMissing private val messages: JsonField> = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("tools") @ExcludeMissing private val tools: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Chat + @JsonCreator + private constructor( + @JsonProperty("messages") + @ExcludeMissing + private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonProperty("tools") + @ExcludeMissing + private val tools: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun messages(): List = messages.getRequired("messages") @@ -1116,13 +1054,9 @@ class PromptData @JsonCreator private constructor( @ExcludeMissing fun _messages(): JsonField> = messages - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("tools") - @ExcludeMissing - fun _tools(): JsonField = tools + @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField = tools @JsonAnyGetter @ExcludeMissing @@ -1130,18 +1064,17 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Chat = - apply { - if (validated) { - return@apply - } - - messages().forEach { it.validate() } - type() - tools() - validated = true + fun validate(): Chat = apply { + if (validated) { + return@apply } + messages().forEach { it.validate() } + type() + tools() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1150,14 +1083,12 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Chat]. * * The following fields are required: - * * ```java * .messages() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Chat]. */ @@ -1169,96 +1100,84 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(chat: Chat) = - apply { - messages = chat.messages.map { it.toMutableList() } - type = chat.type - tools = chat.tools - additionalProperties = chat.additionalProperties.toMutableMap() - } + internal fun from(chat: Chat) = apply { + messages = chat.messages.map { it.toMutableList() } + type = chat.type + tools = chat.tools + additionalProperties = chat.additionalProperties.toMutableMap() + } fun messages(messages: List) = messages(JsonField.of(messages)) - fun messages(messages: JsonField>) = - apply { - this.messages = messages.map { it.toMutableList() } - } + fun messages(messages: JsonField>) = apply { + this.messages = messages.map { it.toMutableList() } + } - fun addMessage(message: Message) = - apply { - messages = (messages ?: JsonField.of(mutableListOf())).also { + fun addMessage(message: Message) = apply { + messages = + (messages ?: JsonField.of(mutableListOf())).also { checkKnown("messages", it).add(message) } - } + } fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) - fun addMessage(assistant: Message.Assistant) = addMessage(Message.ofAssistant(assistant)) + fun addMessage(assistant: Message.Assistant) = + addMessage(Message.ofAssistant(assistant)) fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) - fun addMessage(function: Message.Function) = addMessage(Message.ofFunction(function)) + fun addMessage(function: Message.Function) = + addMessage(Message.ofFunction(function)) - fun addMessage(fallback: Message.Fallback) = addMessage(Message.ofFallback(fallback)) + fun addMessage(fallback: Message.Fallback) = + addMessage(Message.ofFallback(fallback)) fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun tools(tools: String) = tools(JsonField.of(tools)) - fun tools(tools: JsonField) = - apply { - this.tools = tools - } + fun tools(tools: JsonField) = apply { this.tools = tools } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Chat = Chat( - checkRequired( - "messages", messages - ).map { it.toImmutable() }, - checkRequired( - "type", type - ), - tools, - additionalProperties.toImmutable(), + checkRequired("messages", messages).map { it.toImmutable() }, + checkRequired("type", type), + tools, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message private constructor( + class Message + private constructor( private val system: System? = null, private val user: User? = null, private val assistant: Assistant? = null, @@ -1266,7 +1185,6 @@ class PromptData @JsonCreator private constructor( private val function: Function? = null, private val fallback: Fallback? = null, private val _json: JsonValue? = null, - ) { fun system(): Optional = Optional.ofNullable(system) @@ -1308,59 +1226,60 @@ class PromptData @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - system != null -> visitor.visitSystem(system) - user != null -> visitor.visitUser(user) - assistant != null -> visitor.visitAssistant(assistant) - tool != null -> visitor.visitTool(tool) - function != null -> visitor.visitFunction(function) - fallback != null -> visitor.visitFallback(fallback) - else -> visitor.unknown(_json) - } + return when { + system != null -> visitor.visitSystem(system) + user != null -> visitor.visitUser(user) + assistant != null -> visitor.visitAssistant(assistant) + tool != null -> visitor.visitTool(tool) + function != null -> visitor.visitFunction(function) + fallback != null -> visitor.visitFallback(fallback) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Message = - apply { - if (validated) { - return@apply - } + fun validate(): Message = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitSystem(system: System) { - system.validate() + system.validate() } override fun visitUser(user: User) { - user.validate() + user.validate() } override fun visitAssistant(assistant: Assistant) { - assistant.validate() + assistant.validate() } override fun visitTool(tool: Tool) { - tool.validate() + tool.validate() } override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitFallback(fallback: Fallback) { - fallback.validate() + fallback.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ + return /* spotless:off */ other is Message && system == other.system && user == other.user && assistant == other.assistant && tool == other.tool && function == other.function && fallback == other.fallback /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(system, user, assistant, tool, function, fallback) /* spotless:on */ @@ -1379,28 +1298,23 @@ class PromptData @JsonCreator private constructor( companion object { - @JvmStatic - fun ofSystem(system: System) = Message(system = system) + @JvmStatic fun ofSystem(system: System) = Message(system = system) - @JvmStatic - fun ofUser(user: User) = Message(user = user) + @JvmStatic fun ofUser(user: User) = Message(user = user) @JvmStatic fun ofAssistant(assistant: Assistant) = Message(assistant = assistant) - @JvmStatic - fun ofTool(tool: Tool) = Message(tool = tool) + @JvmStatic fun ofTool(tool: Tool) = Message(tool = tool) - @JvmStatic - fun ofFunction(function: Function) = Message(function = function) + @JvmStatic fun ofFunction(function: Function) = Message(function = function) - @JvmStatic - fun ofFallback(fallback: Fallback) = Message(fallback = fallback) + @JvmStatic fun ofFallback(fallback: Fallback) = Message(fallback = fallback) } /** - * An interface that defines how to map each variant of [Message] to a value of - * type [T]. + * An interface that defines how to map each variant of [Message] to a value of type + * [T]. */ interface Visitor { @@ -1419,88 +1333,103 @@ class PromptData @JsonCreator private constructor( /** * Maps an unknown variant of [Message] to a value of type [T]. * - * An instance of [Message] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Message] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } internal class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } internal class Serializer : BaseSerializer(Message::class) { - override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } @NoAutoDetect - class System @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class System + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1508,18 +1437,17 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): System = - apply { - if (validated) { - return@apply - } - - role() - content() - name() - validated = true + fun validate(): System = apply { + if (validated) { + return@apply } + role() + content() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1528,13 +1456,11 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [System]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [System]. */ @@ -1543,37 +1469,28 @@ class PromptData @JsonCreator private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(system: System) = - apply { - role = system.role - content = system.content - name = system.name - additionalProperties = system.additionalProperties.toMutableMap() - } + internal fun from(system: System) = apply { + role = system.role + content = system.content + name = system.name + additionalProperties = system.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -1581,49 +1498,42 @@ class PromptData @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): System = System( - checkRequired( - "role", role - ), - content, - name, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + name, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role + @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. + * 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 @@ -1637,23 +1547,25 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - SYSTEM, + SYSTEM } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [Role] 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. - * + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { SYSTEM, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1661,8 +1573,8 @@ class PromptData @JsonCreator private constructor( * 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. + * 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) { @@ -1673,11 +1585,11 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1688,20 +1600,23 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1710,11 +1625,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is System && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1723,35 +1638,41 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "System{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class User @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class User + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1759,18 +1680,17 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): User = - apply { - if (validated) { - return@apply - } - - role() - content().ifPresent { it.validate() } - name() - validated = true + fun validate(): User = apply { + if (validated) { + return@apply } + role() + content().ifPresent { it.validate() } + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1779,13 +1699,11 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [User]. */ @@ -1794,41 +1712,33 @@ class PromptData @JsonCreator private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(user: User) = - apply { - role = user.role - content = user.content - name = user.name - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = apply { + role = user.role + content = user.content + name = user.name + additionalProperties = user.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: Content) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun content(text: String) = content(Content.ofText(text)) - fun contentOfArray(array: List) = content(Content.ofArray(array)) + fun contentOfArray(array: List) = + content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -1836,49 +1746,42 @@ class PromptData @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired( - "role", role - ), - content, - name, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + name, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role + @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. + * 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 @@ -1892,23 +1795,25 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - USER, + USER } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [Role] 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. - * + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { USER, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1916,8 +1821,8 @@ class PromptData @JsonCreator private constructor( * 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. + * 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) { @@ -1928,11 +1833,11 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1943,20 +1848,23 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1966,16 +1874,17 @@ class PromptData @JsonCreator private constructor( @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content private constructor( + class Content + private constructor( private val text: String? = null, private val array: List? = null, private val _json: JsonValue? = null, - ) { fun text(): Optional = Optional.ofNullable(text) - fun array(): Optional> = Optional.ofNullable(array) + fun array(): Optional> = + Optional.ofNullable(array) fun isText(): Boolean = text != null @@ -1988,39 +1897,40 @@ class PromptData @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - array != null -> visitor.visitArray(array) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + array != null -> visitor.visitArray(array) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Content = - apply { - if (validated) { - return@apply - } - - accept(object : Visitor { - override fun visitText(text: String) { + fun validate(): Content = apply { + if (validated) { + return@apply + } - } + accept( + object : Visitor { + override fun visitText(text: String) {} - override fun visitArray(array: List) { - array.forEach { it.validate() } + override fun visitArray( + array: List + ) { + array.forEach { it.validate() } } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ + return /* spotless:off */ other is Content && text == other.text && array == other.array /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, array) /* spotless:on */ @@ -2035,16 +1945,16 @@ class PromptData @JsonCreator private constructor( companion object { - @JvmStatic - fun ofText(text: String) = Content(text = text) + @JvmStatic fun ofText(text: String) = Content(text = text) @JvmStatic - fun ofArray(array: List) = Content(array = array) + fun ofArray(array: List) = + Content(array = array) } /** - * An interface that defines how to map each variant of [Content] to a value of - * type [T]. + * An interface that defines how to map each variant of [Content] to a value + * of type [T]. */ interface Visitor { @@ -2055,58 +1965,70 @@ class PromptData @JsonCreator private constructor( /** * Maps an unknown variant of [Content] to a value of type [T]. * - * An instance of [Content] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Content] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } internal class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>()){ it.forEach { it.validate() } }?.let { - return Content(array = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(text = it, _json = json) + } + tryDeserialize( + node, + jacksonTypeRef>(), + ) { + it.forEach { it.validate() } + } + ?.let { + return Content(array = it, _json = json) + } - return Content(_json = json) + return Content(_json = json) } } internal class Serializer : BaseSerializer(Content::class) { - override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.text != null -> generator.writeObject(value.text) - value.array != null -> generator.writeObject(value.array) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.array != null -> generator.writeObject(value.array) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } @JsonDeserialize(using = ChatCompletionContentPart.Deserializer::class) @JsonSerialize(using = ChatCompletionContentPart.Serializer::class) - class ChatCompletionContentPart private constructor( + class ChatCompletionContentPart + private constructor( private val text: ChatCompletionContentPartText? = null, private val image: ChatCompletionContentPartImage? = null, private val _json: JsonValue? = null, - ) { - fun text(): Optional = Optional.ofNullable(text) + fun text(): Optional = + Optional.ofNullable(text) - fun image(): Optional = Optional.ofNullable(image) + fun image(): Optional = + Optional.ofNullable(image) fun isText(): Boolean = text != null @@ -2114,44 +2036,50 @@ class PromptData @JsonCreator private constructor( fun asText(): ChatCompletionContentPartText = text.getOrThrow("text") - fun asImage(): ChatCompletionContentPartImage = image.getOrThrow("image") + fun asImage(): ChatCompletionContentPartImage = + image.getOrThrow("image") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - image != null -> visitor.visitImage(image) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ChatCompletionContentPart = - apply { - if (validated) { - return@apply - } + fun validate(): ChatCompletionContentPart = apply { + if (validated) { + return@apply + } - accept(object : Visitor { - override fun visitText(text: ChatCompletionContentPartText) { - text.validate() + accept( + object : Visitor { + override fun visitText( + text: ChatCompletionContentPartText + ) { + text.validate() } - override fun visitImage(image: ChatCompletionContentPartImage) { - image.validate() + override fun visitImage( + image: ChatCompletionContentPartImage + ) { + image.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ + return /* spotless:off */ other is ChatCompletionContentPart && text == other.text && image == other.image /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(text, image) /* spotless:on */ @@ -2161,21 +2089,26 @@ class PromptData @JsonCreator private constructor( text != null -> "ChatCompletionContentPart{text=$text}" image != null -> "ChatCompletionContentPart{image=$image}" _json != null -> "ChatCompletionContentPart{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") + else -> + throw IllegalStateException( + "Invalid ChatCompletionContentPart" + ) } companion object { @JvmStatic - fun ofText(text: ChatCompletionContentPartText) = ChatCompletionContentPart(text = text) + fun ofText(text: ChatCompletionContentPartText) = + ChatCompletionContentPart(text = text) @JvmStatic - fun ofImage(image: ChatCompletionContentPartImage) = ChatCompletionContentPart(image = image) + fun ofImage(image: ChatCompletionContentPartImage) = + ChatCompletionContentPart(image = image) } /** - * An interface that defines how to map each variant of [ChatCompletionContentPart] - * to a value of type [T]. + * An interface that defines how to map each variant of + * [ChatCompletionContentPart] to a value of type [T]. */ interface Visitor { @@ -2184,56 +2117,94 @@ class PromptData @JsonCreator private constructor( fun visitImage(image: ChatCompletionContentPartImage): T /** - * Maps an unknown variant of [ChatCompletionContentPart] to a value of type [T]. + * Maps an unknown variant of [ChatCompletionContentPart] to a value + * of type [T]. * - * An instance of [ChatCompletionContentPart] can contain an unknown variant if it - * was deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [ChatCompletionContentPart] can contain an unknown + * variant if it was deserialized from data that doesn't match any + * known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the + * SDK is unaware of. * - * @throws BraintrustInvalidDataException in the default implementation. + * @throws BraintrustInvalidDataException in the default + * implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ChatCompletionContentPart: $json") + throw BraintrustInvalidDataException( + "Unknown ChatCompletionContentPart: $json" + ) } } - internal class Deserializer : BaseDeserializer(ChatCompletionContentPart::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ChatCompletionContentPart { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ChatCompletionContentPart(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ChatCompletionContentPart(image = it, _json = json) - } + internal class Deserializer : + BaseDeserializer( + ChatCompletionContentPart::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): ChatCompletionContentPart { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + text = it, + _json = json, + ) + } + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return ChatCompletionContentPart( + image = it, + _json = json, + ) + } - return ChatCompletionContentPart(_json = json) + return ChatCompletionContentPart(_json = json) } } - internal class Serializer : BaseSerializer(ChatCompletionContentPart::class) { - - override fun serialize(value: ChatCompletionContentPart, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.text != null -> generator.writeObject(value.text) - value.image != null -> generator.writeObject(value.image) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ChatCompletionContentPart") - } + internal class Serializer : + BaseSerializer( + ChatCompletionContentPart::class + ) { + + override fun serialize( + value: ChatCompletionContentPart, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid ChatCompletionContentPart" + ) + } } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && role == other.role && content == other.content && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2242,33 +2213,48 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "User{role=$role, content=$content, name=$name, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Assistant @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("tool_calls") @ExcludeMissing private val toolCalls: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Assistant + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tool_calls") + @ExcludeMissing + private val toolCalls: JsonField> = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + fun toolCalls(): Optional> = + Optional.ofNullable(toolCalls.getNullable("tool_calls")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2278,9 +2264,7 @@ class PromptData @JsonCreator private constructor( @ExcludeMissing fun _functionCall(): JsonField = functionCall - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tool_calls") @ExcludeMissing @@ -2292,20 +2276,19 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Assistant = - apply { - if (validated) { - return@apply - } - - role() - content() - functionCall().ifPresent { it.validate() } - name() - toolCalls().ifPresent { it.forEach { it.validate() } } - validated = true + fun validate(): Assistant = apply { + if (validated) { + return@apply } + role() + content() + functionCall().ifPresent { it.validate() } + name() + toolCalls().ifPresent { it.forEach { it.validate() } } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2314,13 +2297,11 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Assistant]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Assistant]. */ @@ -2330,69 +2311,65 @@ class PromptData @JsonCreator private constructor( private var content: JsonField = JsonMissing.of() private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var toolCalls: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var toolCalls: + JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(assistant: Assistant) = - apply { - role = assistant.role - content = assistant.content - functionCall = assistant.functionCall - name = assistant.name - toolCalls = assistant.toolCalls.map { it.toMutableList() } - additionalProperties = assistant.additionalProperties.toMutableMap() - } + internal fun from(assistant: Assistant) = apply { + role = assistant.role + content = assistant.content + functionCall = assistant.functionCall + name = assistant.name + toolCalls = assistant.toolCalls.map { it.toMutableList() } + additionalProperties = assistant.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } - fun functionCall(functionCall: FunctionCall?) = functionCall(JsonField.ofNullable(functionCall)) + fun functionCall(functionCall: FunctionCall?) = + functionCall(JsonField.ofNullable(functionCall)) - fun functionCall(functionCall: Optional) = functionCall(functionCall.getOrNull()) + fun functionCall(functionCall: Optional) = + functionCall(functionCall.getOrNull()) - fun functionCall(functionCall: JsonField) = - apply { - this.functionCall = functionCall - } + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.getOrNull()) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun toolCalls(toolCalls: List?) = toolCalls(JsonField.ofNullable(toolCalls)) + fun toolCalls(toolCalls: List?) = + toolCalls(JsonField.ofNullable(toolCalls)) - fun toolCalls(toolCalls: Optional>) = toolCalls(toolCalls.getOrNull()) + fun toolCalls(toolCalls: Optional>) = + toolCalls(toolCalls.getOrNull()) fun toolCalls(toolCalls: JsonField>) = apply { this.toolCalls = toolCalls.map { it.toMutableList() } } - fun addToolCall(toolCall: ChatCompletionMessageToolCall) = - apply { - toolCalls = (toolCalls ?: JsonField.of(mutableListOf())).also { + fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { + toolCalls = + (toolCalls ?: JsonField.of(mutableListOf())).also { checkKnown("toolCalls", it).add(toolCall) } - } + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2400,51 +2377,44 @@ class PromptData @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Assistant = Assistant( - checkRequired( - "role", role - ), - content, - functionCall, - name, - (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + functionCall, + name, + (toolCalls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role + @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. + * 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 @@ -2458,23 +2428,25 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - ASSISTANT, + ASSISTANT } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [Role] 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. - * + * 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 { ASSISTANT, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -2482,8 +2454,8 @@ class PromptData @JsonCreator private constructor( * 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. + * 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) { @@ -2494,11 +2466,11 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -2509,20 +2481,23 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2531,11 +2506,18 @@ class PromptData @JsonCreator private constructor( } @NoAutoDetect - class FunctionCall @JsonCreator private constructor( - @JsonProperty("arguments") @ExcludeMissing private val arguments: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class FunctionCall + @JsonCreator + private constructor( + @JsonProperty("arguments") + @ExcludeMissing + private val arguments: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { fun arguments(): String = arguments.getRequired("arguments") @@ -2546,9 +2528,7 @@ class PromptData @JsonCreator private constructor( @ExcludeMissing fun _arguments(): JsonField = arguments - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2556,33 +2536,31 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): FunctionCall = - apply { - if (validated) { - return@apply - } - - arguments() - name() - validated = true + fun validate(): FunctionCall = apply { + if (validated) { + return@apply } + arguments() + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [FunctionCall]. + * Returns a mutable builder for constructing an instance of + * [FunctionCall]. * * The following fields are required: - * * ```java * .arguments() * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [FunctionCall]. */ @@ -2590,29 +2568,26 @@ class PromptData @JsonCreator private constructor( private var arguments: JsonField? = null private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(functionCall: FunctionCall) = - apply { - arguments = functionCall.arguments - name = functionCall.name - additionalProperties = functionCall.additionalProperties.toMutableMap() - } + internal fun from(functionCall: FunctionCall) = apply { + arguments = functionCall.arguments + name = functionCall.name + additionalProperties = + functionCall.additionalProperties.toMutableMap() + } fun arguments(arguments: String) = arguments(JsonField.of(arguments)) - fun arguments(arguments: JsonField) = - apply { - this.arguments = arguments - } + fun arguments(arguments: JsonField) = apply { + this.arguments = arguments + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -2620,44 +2595,36 @@ class PromptData @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): FunctionCall = FunctionCall( - checkRequired( - "arguments", arguments - ), - checkRequired( - "name", name - ), - additionalProperties.toImmutable(), + checkRequired("arguments", arguments), + checkRequired("name", name), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is FunctionCall && arguments == other.arguments && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2666,15 +2633,16 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Assistant && role == other.role && content == other.content && functionCall == other.functionCall && name == other.name && toolCalls == other.toolCalls && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2683,27 +2651,36 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = + "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Tool @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonProperty("tool_call_id") @ExcludeMissing private val toolCallId: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Tool + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonProperty("tool_call_id") + @ExcludeMissing + private val toolCallId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + fun toolCallId(): Optional = + Optional.ofNullable(toolCallId.getNullable("tool_call_id")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2719,18 +2696,17 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Tool = - apply { - if (validated) { - return@apply - } - - role() - content() - toolCallId() - validated = true + fun validate(): Tool = apply { + if (validated) { + return@apply } + role() + content() + toolCallId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2739,13 +2715,11 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Tool]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Tool]. */ @@ -2754,37 +2728,30 @@ class PromptData @JsonCreator private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(tool: Tool) = - apply { - role = tool.role - content = tool.content - toolCallId = tool.toolCallId - additionalProperties = tool.additionalProperties.toMutableMap() - } + internal fun from(tool: Tool) = apply { + role = tool.role + content = tool.content + toolCallId = tool.toolCallId + additionalProperties = tool.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) - fun toolCallId(toolCallId: JsonField) = - apply { - this.toolCallId = toolCallId - } + fun toolCallId(toolCallId: JsonField) = apply { + this.toolCallId = toolCallId + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2792,49 +2759,42 @@ class PromptData @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Tool = Tool( - checkRequired( - "role", role - ), - content, - toolCallId, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + toolCallId, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role + @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. + * 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 @@ -2848,23 +2808,25 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - TOOL, + TOOL } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [Role] 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. - * + * 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 { TOOL, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -2872,8 +2834,8 @@ class PromptData @JsonCreator private constructor( * 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. + * 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) { @@ -2884,11 +2846,11 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -2899,20 +2861,23 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2921,11 +2886,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tool && role == other.role && content == other.content && toolCallId == other.toolCallId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2934,31 +2899,37 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = + "Tool{role=$role, content=$content, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Function @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Function + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) - - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -2970,18 +2941,17 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - name() - role() - content() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + name() + role() + content() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2990,14 +2960,12 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .name() * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ @@ -3006,37 +2974,28 @@ class PromptData @JsonCreator private constructor( private var name: JsonField? = null private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - name = function.name - role = function.role - content = function.content - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + name = function.name + role = function.role + content = function.content + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { @@ -3044,51 +3003,42 @@ class PromptData @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "name", name - ), - checkRequired( - "role", role - ), - content, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("role", role), + content, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role + @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. + * 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 @@ -3102,23 +3052,25 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [Role] 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. - * + * 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 { FUNCTION, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -3126,8 +3078,8 @@ class PromptData @JsonCreator private constructor( * 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. + * 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) { @@ -3138,11 +3090,11 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -3153,20 +3105,23 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3175,11 +3130,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3188,24 +3143,30 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, role=$role, content=$content, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Fallback @JsonCreator private constructor( - @JsonProperty("role") @ExcludeMissing private val role: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing private val content: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Fallback + @JsonCreator + private constructor( + @JsonProperty("role") + @ExcludeMissing + private val role: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + private val content: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun role(): Role = role.getRequired("role") - fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + fun content(): Optional = + Optional.ofNullable(content.getNullable("content")) - @JsonProperty("role") - @ExcludeMissing - fun _role(): JsonField = role + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role @JsonProperty("content") @ExcludeMissing @@ -3217,17 +3178,16 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Fallback = - apply { - if (validated) { - return@apply - } - - role() - content() - validated = true + fun validate(): Fallback = apply { + if (validated) { + return@apply } + role() + content() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3236,13 +3196,11 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Fallback]. * * The following fields are required: - * * ```java * .role() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Fallback]. */ @@ -3250,31 +3208,25 @@ class PromptData @JsonCreator private constructor( private var role: JsonField? = null private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(fallback: Fallback) = - apply { - role = fallback.role - content = fallback.content - additionalProperties = fallback.additionalProperties.toMutableMap() - } + internal fun from(fallback: Fallback) = apply { + role = fallback.role + content = fallback.content + additionalProperties = fallback.additionalProperties.toMutableMap() + } fun role(role: Role) = role(JsonField.of(role)) - fun role(role: JsonField) = - apply { - this.role = role - } + fun role(role: JsonField) = apply { this.role = role } fun content(content: String?) = content(JsonField.ofNullable(content)) fun content(content: Optional) = content(content.getOrNull()) - fun content(content: JsonField) = - apply { - this.content = content - } + fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { @@ -3282,48 +3234,41 @@ class PromptData @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Fallback = Fallback( - checkRequired( - "role", role - ), - content, - additionalProperties.toImmutable(), + checkRequired("role", role), + content, + additionalProperties.toImmutable(), ) } - class Role @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Role + @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. + * 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 @@ -3337,23 +3282,25 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Role]'s known values. */ enum class Known { - MODEL, + MODEL } /** - * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] + * member. * * An instance of [Role] 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. - * + * 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 { MODEL, - /** An enum member indicating that [Role] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Role] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -3361,8 +3308,8 @@ class PromptData @JsonCreator private constructor( * 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. + * 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) { @@ -3373,11 +3320,11 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -3388,20 +3335,23 @@ class PromptData @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && value == other.value /* spotless:on */ + return /* spotless:off */ other is Role && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3410,11 +3360,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Fallback && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3423,14 +3373,13 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = + "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" } } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -3440,8 +3389,7 @@ class PromptData @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -3452,23 +3400,23 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - CHAT, + CHAT } /** * 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 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 { CHAT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -3492,7 +3440,7 @@ class PromptData @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3507,16 +3455,19 @@ class PromptData @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3525,11 +3476,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Chat && messages == other.messages && type == other.type && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Chat && messages == other.messages && type == other.type && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3538,13 +3489,16 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = + "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class NullableVariant + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -3553,22 +3507,20 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): NullableVariant = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [NullableVariant]. */ @@ -3577,46 +3529,41 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = - apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties = nullableVariant.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3631,11 +3578,11 @@ class PromptData @JsonCreator private constructor( @JsonDeserialize(using = ToolFunction.Deserializer::class) @JsonSerialize(using = ToolFunction.Serializer::class) - class ToolFunction private constructor( + class ToolFunction + private constructor( private val function: Function? = null, private val global: Global? = null, private val _json: JsonValue? = null, - ) { fun function(): Optional = Optional.ofNullable(function) @@ -3653,39 +3600,40 @@ class PromptData @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - function != null -> visitor.visitFunction(function) - global != null -> visitor.visitGlobal(global) - else -> visitor.unknown(_json) - } + return when { + function != null -> visitor.visitFunction(function) + global != null -> visitor.visitGlobal(global) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ToolFunction = - apply { - if (validated) { - return@apply - } + fun validate(): ToolFunction = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitFunction(function: Function) { - function.validate() + function.validate() } override fun visitGlobal(global: Global) { - global.validate() + global.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ToolFunction && function == other.function && global == other.global /* spotless:on */ + return /* spotless:off */ other is ToolFunction && function == other.function && global == other.global /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(function, global) /* spotless:on */ @@ -3700,16 +3648,14 @@ class PromptData @JsonCreator private constructor( companion object { - @JvmStatic - fun ofFunction(function: Function) = ToolFunction(function = function) + @JvmStatic fun ofFunction(function: Function) = ToolFunction(function = function) - @JvmStatic - fun ofGlobal(global: Global) = ToolFunction(global = global) + @JvmStatic fun ofGlobal(global: Global) = ToolFunction(global = global) } /** - * An interface that defines how to map each variant of [ToolFunction] to a value - * of type [T]. + * An interface that defines how to map each variant of [ToolFunction] to a value of type + * [T]. */ interface Visitor { @@ -3720,65 +3666,73 @@ class PromptData @JsonCreator private constructor( /** * Maps an unknown variant of [ToolFunction] to a value of type [T]. * - * An instance of [ToolFunction] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [ToolFunction] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolFunction: $json") + throw BraintrustInvalidDataException("Unknown ToolFunction: $json") } } internal class Deserializer : BaseDeserializer(ToolFunction::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolFunction { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolFunction(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolFunction(global = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolFunction(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolFunction(global = it, _json = json) + } - return ToolFunction(_json = json) + return ToolFunction(_json = json) } } internal class Serializer : BaseSerializer(ToolFunction::class) { - override fun serialize(value: ToolFunction, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.function != null -> generator.writeObject(value.function) - value.global != null -> generator.writeObject(value.global) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolFunction") - } + override fun serialize( + value: ToolFunction, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.function != null -> generator.writeObject(value.function) + value.global != null -> generator.writeObject(value.global) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolFunction") + } } } @NoAutoDetect - class Function @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Function + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun id(): String = id.getRequired("id") fun type(): Type = type.getRequired("type") - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3786,17 +3740,16 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - id() - type() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + id() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -3805,14 +3758,12 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .id() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ @@ -3823,69 +3774,52 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - id = function.id - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + id = function.id + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "id", id - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -3895,8 +3829,7 @@ class PromptData @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -3907,23 +3840,23 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** * 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 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 { FUNCTION, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -3947,7 +3880,7 @@ class PromptData @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -3962,16 +3895,19 @@ class PromptData @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -3980,11 +3916,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && id == other.id && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3993,28 +3929,31 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{id=$id, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Global @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Global + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") fun type(): Type = type.getRequired("type") - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -4022,17 +3961,16 @@ class PromptData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Global = - apply { - if (validated) { - return@apply - } - - name() - type() - validated = true + fun validate(): Global = apply { + if (validated) { + return@apply } + name() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -4041,14 +3979,12 @@ class PromptData @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Global]. * * The following fields are required: - * * ```java * .name() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Global]. */ @@ -4059,69 +3995,52 @@ class PromptData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(global: Global) = - apply { - name = global.name - type = global.type - additionalProperties = global.additionalProperties.toMutableMap() - } + internal fun from(global: Global) = apply { + name = global.name + type = global.type + additionalProperties = global.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Global = Global( - checkRequired( - "name", name - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -4131,8 +4050,7 @@ class PromptData @JsonCreator private constructor( * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -4143,23 +4061,23 @@ class PromptData @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - GLOBAL, + GLOBAL } /** * 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 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 { GLOBAL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } @@ -4183,7 +4101,7 @@ class PromptData @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -4198,16 +4116,19 @@ class PromptData @JsonCreator private constructor( * debugging and generally doesn't throw. * * @throws BraintrustInvalidDataException if this class instance's value does not - * have the expected primitive type. + * have the expected primitive type. */ - fun asString(): String = _value().asString().orElseThrow { BraintrustInvalidDataException("Value is not a String") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -4216,11 +4137,11 @@ class PromptData @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Global && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4229,16 +4150,17 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptData && options == other.options && origin == other.origin && parser == other.parser && prompt == other.prompt && toolFunctions == other.toolFunctions && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptData && options == other.options && origin == other.origin && parser == other.parser && prompt == other.prompt && toolFunctions == other.toolFunctions && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4247,5 +4169,6 @@ class PromptData @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "PromptData{options=$options, origin=$origin, parser=$parser, prompt=$prompt, toolFunctions=$toolFunctions, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptData{options=$options, origin=$origin, parser=$parser, prompt=$prompt, toolFunctions=$toolFunctions, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 54c1ceb1..a76243f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a prompt object by its id */ -class PromptDeleteParams private constructor( +class PromptDeleteParams +private constructor( private val promptId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Prompt id */ @@ -31,17 +31,18 @@ class PromptDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -52,13 +53,11 @@ class PromptDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [PromptDeleteParams]. * * The following fields are required: - * * ```java * .promptId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptDeleteParams]. */ @@ -71,190 +70,155 @@ class PromptDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptDeleteParams: PromptDeleteParams) = - apply { - promptId = promptDeleteParams.promptId - additionalHeaders = promptDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = promptDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = promptDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(promptDeleteParams: PromptDeleteParams) = apply { + promptId = promptDeleteParams.promptId + additionalHeaders = promptDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = promptDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = promptDeleteParams.additionalBodyProperties.toMutableMap() + } /** Prompt id */ - fun promptId(promptId: String) = - apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): PromptDeleteParams = PromptDeleteParams( - checkRequired( - "promptId", promptId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("promptId", promptId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PromptDeleteParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "PromptDeleteParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index 1054845e..a54dbe4f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.PromptService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ -class PromptListPage private constructor( +class PromptListPage +private constructor( private val promptsService: PromptService, private val params: PromptListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,40 @@ class PromptListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListPage && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is PromptListPage && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ - override fun toString() = "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" + override fun toString() = + "PromptListPage{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(PromptListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(PromptListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { promptsService.list(it) } + return getNextPageParams().map { promptsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +78,16 @@ class PromptListPage private constructor( @JvmStatic fun of(promptsService: PromptService, params: PromptListParams, response: Response) = - PromptListPage( - promptsService, - params, - response, - ) + PromptListPage(promptsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +101,34 @@ class PromptListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [PromptListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +137,39 @@ class PromptListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: PromptListPage, + class AutoPager(private val firstPage: PromptListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index 06a4044a..940430e6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.PromptServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ -class PromptListPageAsync private constructor( +class PromptListPageAsync +private constructor( private val promptsService: PromptServiceAsync, private val params: PromptListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,42 @@ class PromptListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListPageAsync && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is PromptListPageAsync && promptsService == other.promptsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptsService, params, response) /* spotless:on */ - override fun toString() = "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" + override fun toString() = + "PromptListPageAsync{promptsService=$promptsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(PromptListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(PromptListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - promptsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { promptsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -81,18 +80,16 @@ class PromptListPageAsync private constructor( @JvmStatic fun of(promptsService: PromptServiceAsync, params: PromptListParams, response: Response) = - PromptListPageAsync( - promptsService, - params, - response, - ) + PromptListPageAsync(promptsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,35 +103,34 @@ class PromptListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [PromptListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -143,63 +139,46 @@ class PromptListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: PromptListPageAsync, - - ) { + class AutoPager(private val firstPage: PromptListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Prompt) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Prompt) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 725c3bce..ab888cab 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ -class PromptListParams private constructor( +class PromptListParams +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -39,21 +40,20 @@ class PromptListParams private constructor( private val version: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -78,17 +78,17 @@ class PromptListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a - * version identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). */ fun version(): Optional = Optional.ofNullable(version) @@ -99,71 +99,29 @@ class PromptListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.projectId?.let { - queryParams.put( - "project_id", listOf(it.toString()) - ) - } - this.projectName?.let { - queryParams.put( - "project_name", listOf(it.toString()) - ) - } - this.promptName?.let { - queryParams.put( - "prompt_name", listOf(it.toString()) - ) - } - this.slug?.let { - queryParams.put( - "slug", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - this.version?.let { - queryParams.put( - "version", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } + this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } + this.promptName?.let { queryParams.put("prompt_name", listOf(it.toString())) } + this.slug?.let { queryParams.put("slug", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + this.version?.let { queryParams.put("version", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): PromptListParams = builder().build() + @JvmStatic fun none(): PromptListParams = builder().build() /** Returns a mutable builder for constructing an instance of [PromptListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptListParams]. */ @@ -184,75 +142,65 @@ class PromptListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptListParams: PromptListParams) = - apply { - endingBefore = promptListParams.endingBefore - ids = promptListParams.ids - limit = promptListParams.limit - orgName = promptListParams.orgName - projectId = promptListParams.projectId - projectName = promptListParams.projectName - promptName = promptListParams.promptName - slug = promptListParams.slug - startingAfter = promptListParams.startingAfter - version = promptListParams.version - additionalHeaders = promptListParams.additionalHeaders.toBuilder() - additionalQueryParams = promptListParams.additionalQueryParams.toBuilder() - } + internal fun from(promptListParams: PromptListParams) = apply { + endingBefore = promptListParams.endingBefore + ids = promptListParams.ids + limit = promptListParams.limit + orgName = promptListParams.orgName + projectId = promptListParams.projectId + projectName = promptListParams.projectName + promptName = promptListParams.promptName + slug = promptListParams.slug + startingAfter = promptListParams.startingAfter + version = promptListParams.version + additionalHeaders = promptListParams.additionalHeaders.toBuilder() + additionalQueryParams = promptListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -261,46 +209,31 @@ class PromptListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ - fun projectId(projectId: String?) = - apply { - this.projectId = projectId - } + fun projectId(projectId: String?) = apply { this.projectId = projectId } /** Project id */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ - fun projectName(projectName: String?) = - apply { - this.projectName = projectName - } + fun projectName(projectName: String?) = apply { this.projectName = projectName } /** Name of the project to search for */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the prompt to search for */ - fun promptName(promptName: String?) = - apply { - this.promptName = promptName - } + fun promptName(promptName: String?) = apply { this.promptName = promptName } /** Name of the prompt to search for */ fun promptName(promptName: Optional) = promptName(promptName.getOrNull()) /** Retrieve prompt with a specific slug */ - fun slug(slug: String?) = - apply { - this.slug = slug - } + fun slug(slug: String?) = apply { this.slug = slug } /** Retrieve prompt with a specific slug */ fun slug(slug: Optional) = slug(slug.getOrNull()) @@ -308,195 +241,164 @@ class PromptListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a - * version identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). */ - fun version(version: String?) = - apply { - this.version = version - } + fun version(version: String?) = apply { this.version = version } /** * Retrieve prompt at a specific version. * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a - * version identifier (e.g. '81cd05ee665fdfb3'). + * The version id can either be a transaction id (e.g. '1000192656880881099') or a version + * identifier (e.g. '81cd05ee665fdfb3'). */ fun version(version: Optional) = version(version.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptListParams = PromptListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - promptName, - slug, - startingAfter, - version, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + promptName, + slug, + startingAfter, + version, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -514,19 +416,19 @@ class PromptListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -541,17 +443,12 @@ class PromptListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -561,56 +458,60 @@ class PromptListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && projectId == other.projectId && projectName == other.projectName && promptName == other.promptName && slug == other.slug && startingAfter == other.startingAfter && version == other.version && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, projectId, projectName, promptName, slug, startingAfter, version, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 0c5160f5..5ac95496 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -32,12 +32,17 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class PromptOptions @JsonCreator private constructor( +class PromptOptions +@JsonCreator +private constructor( @JsonProperty("model") @ExcludeMissing private val model: JsonField = JsonMissing.of(), - @JsonProperty("params") @ExcludeMissing private val params: JsonField = JsonMissing.of(), - @JsonProperty("position") @ExcludeMissing private val position: JsonField = JsonMissing.of(), + @JsonProperty("params") + @ExcludeMissing + private val params: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun model(): Optional = Optional.ofNullable(model.getNullable("model")) @@ -46,17 +51,11 @@ class PromptOptions @JsonCreator private constructor( fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - @JsonProperty("model") - @ExcludeMissing - fun _model(): JsonField = model + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model - @JsonProperty("params") - @ExcludeMissing - fun _params(): JsonField = params + @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params - @JsonProperty("position") - @ExcludeMissing - fun _position(): JsonField = position + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position @JsonAnyGetter @ExcludeMissing @@ -64,25 +63,23 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): PromptOptions = - apply { - if (validated) { - return@apply - } - - model() - params().ifPresent { it.validate() } - position() - validated = true + fun validate(): PromptOptions = apply { + if (validated) { + return@apply } + model() + params().ifPresent { it.validate() } + position() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [PromptOptions]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptOptions]. */ @@ -94,90 +91,73 @@ class PromptOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(promptOptions: PromptOptions) = - apply { - model = promptOptions.model - params = promptOptions.params - position = promptOptions.position - additionalProperties = promptOptions.additionalProperties.toMutableMap() - } + internal fun from(promptOptions: PromptOptions) = apply { + model = promptOptions.model + params = promptOptions.params + position = promptOptions.position + additionalProperties = promptOptions.additionalProperties.toMutableMap() + } fun model(model: String) = model(JsonField.of(model)) - fun model(model: JsonField) = - apply { - this.model = model - } + fun model(model: JsonField) = apply { this.model = model } fun params(params: Params) = params(JsonField.of(params)) - fun params(params: JsonField) = - apply { - this.params = params - } + fun params(params: JsonField) = apply { this.params = params } - fun params(openaiModel: Params.OpenAIModelParams) = params(Params.ofOpenAIModel(openaiModel)) + fun params(openaiModel: Params.OpenAIModelParams) = + params(Params.ofOpenAIModel(openaiModel)) - fun params(anthropicModel: Params.AnthropicModelParams) = params(Params.ofAnthropicModel(anthropicModel)) + fun params(anthropicModel: Params.AnthropicModelParams) = + params(Params.ofAnthropicModel(anthropicModel)) - fun params(googleModel: Params.GoogleModelParams) = params(Params.ofGoogleModel(googleModel)) + fun params(googleModel: Params.GoogleModelParams) = + params(Params.ofGoogleModel(googleModel)) - fun params(windowAiModel: Params.WindowAiModelParams) = params(Params.ofWindowAiModel(windowAiModel)) + fun params(windowAiModel: Params.WindowAiModelParams) = + params(Params.ofWindowAiModel(windowAiModel)) - fun params(jsCompletion: Params.JsCompletionParams) = params(Params.ofJsCompletion(jsCompletion)) + fun params(jsCompletion: Params.JsCompletionParams) = + params(Params.ofJsCompletion(jsCompletion)) fun position(position: String) = position(JsonField.of(position)) - fun position(position: JsonField) = - apply { - this.position = position - } + fun position(position: JsonField) = apply { this.position = position } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): PromptOptions = - PromptOptions( - model, - params, - position, - additionalProperties.toImmutable(), - ) + PromptOptions(model, params, position, additionalProperties.toImmutable()) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params private constructor( + class Params + private constructor( private val openaiModel: OpenAIModelParams? = null, private val anthropicModel: AnthropicModelParams? = null, private val googleModel: GoogleModelParams? = null, private val windowAiModel: WindowAiModelParams? = null, private val jsCompletion: JsCompletionParams? = null, private val _json: JsonValue? = null, - ) { fun openaiModel(): Optional = Optional.ofNullable(openaiModel) @@ -213,54 +193,55 @@ class PromptOptions @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - openaiModel != null -> visitor.visitOpenAIModel(openaiModel) - anthropicModel != null -> visitor.visitAnthropicModel(anthropicModel) - googleModel != null -> visitor.visitGoogleModel(googleModel) - windowAiModel != null -> visitor.visitWindowAiModel(windowAiModel) - jsCompletion != null -> visitor.visitJsCompletion(jsCompletion) - else -> visitor.unknown(_json) - } + return when { + openaiModel != null -> visitor.visitOpenAIModel(openaiModel) + anthropicModel != null -> visitor.visitAnthropicModel(anthropicModel) + googleModel != null -> visitor.visitGoogleModel(googleModel) + windowAiModel != null -> visitor.visitWindowAiModel(windowAiModel) + jsCompletion != null -> visitor.visitJsCompletion(jsCompletion) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): Params = - apply { - if (validated) { - return@apply - } + fun validate(): Params = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitOpenAIModel(openaiModel: OpenAIModelParams) { - openaiModel.validate() + openaiModel.validate() } override fun visitAnthropicModel(anthropicModel: AnthropicModelParams) { - anthropicModel.validate() + anthropicModel.validate() } override fun visitGoogleModel(googleModel: GoogleModelParams) { - googleModel.validate() + googleModel.validate() } override fun visitWindowAiModel(windowAiModel: WindowAiModelParams) { - windowAiModel.validate() + windowAiModel.validate() } override fun visitJsCompletion(jsCompletion: JsCompletionParams) { - jsCompletion.validate() + jsCompletion.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Params && openaiModel == other.openaiModel && anthropicModel == other.anthropicModel && googleModel == other.googleModel && windowAiModel == other.windowAiModel && jsCompletion == other.jsCompletion /* spotless:on */ + return /* spotless:off */ other is Params && openaiModel == other.openaiModel && anthropicModel == other.anthropicModel && googleModel == other.googleModel && windowAiModel == other.windowAiModel && jsCompletion == other.jsCompletion /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(openaiModel, anthropicModel, googleModel, windowAiModel, jsCompletion) /* spotless:on */ @@ -282,22 +263,22 @@ class PromptOptions @JsonCreator private constructor( fun ofOpenAIModel(openaiModel: OpenAIModelParams) = Params(openaiModel = openaiModel) @JvmStatic - fun ofAnthropicModel(anthropicModel: AnthropicModelParams) = Params(anthropicModel = anthropicModel) + fun ofAnthropicModel(anthropicModel: AnthropicModelParams) = + Params(anthropicModel = anthropicModel) @JvmStatic fun ofGoogleModel(googleModel: GoogleModelParams) = Params(googleModel = googleModel) @JvmStatic - fun ofWindowAiModel(windowAiModel: WindowAiModelParams) = Params(windowAiModel = windowAiModel) + fun ofWindowAiModel(windowAiModel: WindowAiModelParams) = + Params(windowAiModel = windowAiModel) @JvmStatic - fun ofJsCompletion(jsCompletion: JsCompletionParams) = Params(jsCompletion = jsCompletion) + fun ofJsCompletion(jsCompletion: JsCompletionParams) = + Params(jsCompletion = jsCompletion) } - /** - * An interface that defines how to map each variant of [Params] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Params] to a value of type [T]. */ interface Visitor { fun visitOpenAIModel(openaiModel: OpenAIModelParams): T @@ -313,96 +294,135 @@ class PromptOptions @JsonCreator private constructor( /** * Maps an unknown variant of [Params] to a value of type [T]. * - * An instance of [Params] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Params] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } internal class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(openaiModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(anthropicModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(googleModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(windowAiModel = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return Params(jsCompletion = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(openaiModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(anthropicModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(googleModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(windowAiModel = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Params(jsCompletion = it, _json = json) + } + + return Params(_json = json) } } internal class Serializer : BaseSerializer(Params::class) { - override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.openaiModel != null -> generator.writeObject(value.openaiModel) - value.anthropicModel != null -> generator.writeObject(value.anthropicModel) - value.googleModel != null -> generator.writeObject(value.googleModel) - value.windowAiModel != null -> generator.writeObject(value.windowAiModel) - value.jsCompletion != null -> generator.writeObject(value.jsCompletion) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize( + value: Params, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.openaiModel != null -> generator.writeObject(value.openaiModel) + value.anthropicModel != null -> generator.writeObject(value.anthropicModel) + value.googleModel != null -> generator.writeObject(value.googleModel) + value.windowAiModel != null -> generator.writeObject(value.windowAiModel) + value.jsCompletion != null -> generator.writeObject(value.jsCompletion) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } @NoAutoDetect - class OpenAIModelParams @JsonCreator private constructor( - @JsonProperty("frequency_penalty") @ExcludeMissing private val frequencyPenalty: JsonField = JsonMissing.of(), - @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), - @JsonProperty("max_tokens") @ExcludeMissing private val maxTokens: JsonField = JsonMissing.of(), + class OpenAIModelParams + @JsonCreator + private constructor( + @JsonProperty("frequency_penalty") + @ExcludeMissing + private val frequencyPenalty: JsonField = JsonMissing.of(), + @JsonProperty("function_call") + @ExcludeMissing + private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens") + @ExcludeMissing + private val maxTokens: JsonField = JsonMissing.of(), @JsonProperty("n") @ExcludeMissing private val n: JsonField = JsonMissing.of(), - @JsonProperty("presence_penalty") @ExcludeMissing private val presencePenalty: JsonField = JsonMissing.of(), - @JsonProperty("response_format") @ExcludeMissing private val responseFormat: JsonField = JsonMissing.of(), - @JsonProperty("stop") @ExcludeMissing private val stop: JsonField> = JsonMissing.of(), - @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("tool_choice") @ExcludeMissing private val toolChoice: JsonField = JsonMissing.of(), - @JsonProperty("top_p") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("presence_penalty") + @ExcludeMissing + private val presencePenalty: JsonField = JsonMissing.of(), + @JsonProperty("response_format") + @ExcludeMissing + private val responseFormat: JsonField = JsonMissing.of(), + @JsonProperty("stop") + @ExcludeMissing + private val stop: JsonField> = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("tool_choice") + @ExcludeMissing + private val toolChoice: JsonField = JsonMissing.of(), + @JsonProperty("top_p") + @ExcludeMissing + private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + fun frequencyPenalty(): Optional = + Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) - fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + fun functionCall(): Optional = + Optional.ofNullable(functionCall.getNullable("function_call")) - fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + fun maxTokens(): Optional = + Optional.ofNullable(maxTokens.getNullable("max_tokens")) fun n(): Optional = Optional.ofNullable(n.getNullable("n")) - fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun presencePenalty(): Optional = + Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) - fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + fun responseFormat(): Optional = + Optional.ofNullable(responseFormat.getNullable("response_format")) fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) - fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + fun toolChoice(): Optional = + Optional.ofNullable(toolChoice.getNullable("tool_choice")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -416,9 +436,7 @@ class PromptOptions @JsonCreator private constructor( @ExcludeMissing fun _maxTokens(): JsonField = maxTokens - @JsonProperty("n") - @ExcludeMissing - fun _n(): JsonField = n + @JsonProperty("n") @ExcludeMissing fun _n(): JsonField = n @JsonProperty("presence_penalty") @ExcludeMissing @@ -428,9 +446,7 @@ class PromptOptions @JsonCreator private constructor( @ExcludeMissing fun _responseFormat(): JsonField = responseFormat - @JsonProperty("stop") - @ExcludeMissing - fun _stop(): JsonField> = stop + @JsonProperty("stop") @ExcludeMissing fun _stop(): JsonField> = stop @JsonProperty("temperature") @ExcludeMissing @@ -440,9 +456,7 @@ class PromptOptions @JsonCreator private constructor( @ExcludeMissing fun _toolChoice(): JsonField = toolChoice - @JsonProperty("top_p") - @ExcludeMissing - fun _topP(): JsonField = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -454,33 +468,33 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): OpenAIModelParams = - apply { - if (validated) { - return@apply - } - - frequencyPenalty() - functionCall().ifPresent { it.validate() } - maxTokens() - n() - presencePenalty() - responseFormat().ifPresent { it.validate() } - stop() - temperature() - toolChoice().ifPresent { it.validate() } - topP() - useCache() - validated = true + fun validate(): OpenAIModelParams = apply { + if (validated) { + return@apply } + frequencyPenalty() + functionCall().ifPresent { it.validate() } + maxTokens() + n() + presencePenalty() + responseFormat().ifPresent { it.validate() } + stop() + temperature() + toolChoice().ifPresent { it.validate() } + topP() + useCache() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [OpenAIModelParams]. */ - @JvmStatic - fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of [OpenAIModelParams]. + */ + @JvmStatic fun builder() = Builder() } /** A builder for [OpenAIModelParams]. */ @@ -500,172 +514,160 @@ class PromptOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(openaiModelParams: OpenAIModelParams) = - apply { - frequencyPenalty = openaiModelParams.frequencyPenalty - functionCall = openaiModelParams.functionCall - maxTokens = openaiModelParams.maxTokens - n = openaiModelParams.n - presencePenalty = openaiModelParams.presencePenalty - responseFormat = openaiModelParams.responseFormat - stop = openaiModelParams.stop.map { it.toMutableList() } - temperature = openaiModelParams.temperature - toolChoice = openaiModelParams.toolChoice - topP = openaiModelParams.topP - useCache = openaiModelParams.useCache - additionalProperties = openaiModelParams.additionalProperties.toMutableMap() - } - - fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) - - fun frequencyPenalty(frequencyPenalty: JsonField) = - apply { - this.frequencyPenalty = frequencyPenalty - } + internal fun from(openaiModelParams: OpenAIModelParams) = apply { + frequencyPenalty = openaiModelParams.frequencyPenalty + functionCall = openaiModelParams.functionCall + maxTokens = openaiModelParams.maxTokens + n = openaiModelParams.n + presencePenalty = openaiModelParams.presencePenalty + responseFormat = openaiModelParams.responseFormat + stop = openaiModelParams.stop.map { it.toMutableList() } + temperature = openaiModelParams.temperature + toolChoice = openaiModelParams.toolChoice + topP = openaiModelParams.topP + useCache = openaiModelParams.useCache + additionalProperties = openaiModelParams.additionalProperties.toMutableMap() + } - fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + fun frequencyPenalty(frequencyPenalty: Double) = + frequencyPenalty(JsonField.of(frequencyPenalty)) - fun functionCall(functionCall: JsonField) = - apply { - this.functionCall = functionCall - } + fun frequencyPenalty(frequencyPenalty: JsonField) = apply { + this.frequencyPenalty = frequencyPenalty + } + + fun functionCall(functionCall: FunctionCall) = + functionCall(JsonField.of(functionCall)) + + fun functionCall(functionCall: JsonField) = apply { + this.functionCall = functionCall + } - fun functionCall(unionMember0: FunctionCall.UnionMember0) = functionCall(FunctionCall.ofUnionMember0(unionMember0)) + fun functionCall(unionMember0: FunctionCall.UnionMember0) = + functionCall(FunctionCall.ofUnionMember0(unionMember0)) - fun functionCall(function: FunctionCall.Function) = functionCall(FunctionCall.ofFunction(function)) + fun functionCall(function: FunctionCall.Function) = + functionCall(FunctionCall.ofFunction(function)) fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - fun maxTokens(maxTokens: JsonField) = - apply { - this.maxTokens = maxTokens - } + fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } fun n(n: Double) = n(JsonField.of(n)) - fun n(n: JsonField) = - apply { - this.n = n - } + fun n(n: JsonField) = apply { this.n = n } - fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = + presencePenalty(JsonField.of(presencePenalty)) - fun presencePenalty(presencePenalty: JsonField) = - apply { - this.presencePenalty = presencePenalty - } + fun presencePenalty(presencePenalty: JsonField) = apply { + this.presencePenalty = presencePenalty + } - fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = + responseFormat(JsonField.of(responseFormat)) - fun responseFormat(responseFormat: JsonField) = - apply { - this.responseFormat = responseFormat - } + fun responseFormat(responseFormat: JsonField) = apply { + this.responseFormat = responseFormat + } - fun responseFormat(jsonObject: ResponseFormat.JsonObject) = responseFormat(ResponseFormat.ofJsonObject(jsonObject)) + fun responseFormat(jsonObject: ResponseFormat.JsonObject) = + responseFormat(ResponseFormat.ofJsonObject(jsonObject)) - fun responseFormat(jsonSchema: ResponseFormat.JsonSchema) = responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) + fun responseFormat(jsonSchema: ResponseFormat.JsonSchema) = + responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) - fun responseFormat(text: ResponseFormat.Text) = responseFormat(ResponseFormat.ofText(text)) + fun responseFormat(text: ResponseFormat.Text) = + responseFormat(ResponseFormat.ofText(text)) - fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) + fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = + responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) fun stop(stop: List) = stop(JsonField.of(stop)) - fun stop(stop: JsonField>) = - apply { - this.stop = stop.map { it.toMutableList() } - } + fun stop(stop: JsonField>) = apply { + this.stop = stop.map { it.toMutableList() } + } - fun addStop(stop: String) = - apply { - this.stop = (this.stop ?: JsonField.of(mutableListOf())).also { + fun addStop(stop: String) = apply { + this.stop = + (this.stop ?: JsonField.of(mutableListOf())).also { checkKnown("stop", it).add(stop) } - } + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = - apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) - fun toolChoice(toolChoice: JsonField) = - apply { - this.toolChoice = toolChoice - } + fun toolChoice(toolChoice: JsonField) = apply { + this.toolChoice = toolChoice + } - fun toolChoice(unionMember0: ToolChoice.UnionMember0) = toolChoice(ToolChoice.ofUnionMember0(unionMember0)) + fun toolChoice(unionMember0: ToolChoice.UnionMember0) = + toolChoice(ToolChoice.ofUnionMember0(unionMember0)) - fun toolChoice(function: ToolChoice.Function) = toolChoice(ToolChoice.ofFunction(function)) + fun toolChoice(function: ToolChoice.Function) = + toolChoice(ToolChoice.ofFunction(function)) fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = - apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = - apply { - this.useCache = useCache - } + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): OpenAIModelParams = OpenAIModelParams( - frequencyPenalty, - functionCall, - maxTokens, - n, - presencePenalty, - responseFormat, - (stop ?: JsonMissing.of()).map { it.toImmutable() }, - temperature, - toolChoice, - topP, - useCache, - additionalProperties.toImmutable(), + frequencyPenalty, + functionCall, + maxTokens, + n, + presencePenalty, + responseFormat, + (stop ?: JsonMissing.of()).map { it.toImmutable() }, + temperature, + toolChoice, + topP, + useCache, + additionalProperties.toImmutable(), ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall private constructor( + class FunctionCall + private constructor( private val unionMember0: UnionMember0? = null, private val function: Function? = null, private val _json: JsonValue? = null, - ) { fun unionMember0(): Optional = Optional.ofNullable(unionMember0) @@ -683,39 +685,38 @@ class PromptOptions @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): FunctionCall = - apply { - if (validated) { - return@apply - } - - accept(object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { + fun validate(): FunctionCall = apply { + if (validated) { + return@apply + } - } + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) {} override fun visitFunction(function: Function) { - function.validate() + function.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionCall && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ + return /* spotless:off */ other is FunctionCall && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, function) /* spotless:on */ @@ -731,15 +732,16 @@ class PromptOptions @JsonCreator private constructor( companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FunctionCall(unionMember0 = unionMember0) + fun ofUnionMember0(unionMember0: UnionMember0) = + FunctionCall(unionMember0 = unionMember0) @JvmStatic fun ofFunction(function: Function) = FunctionCall(function = function) } /** - * An interface that defines how to map each variant of [FunctionCall] to a value - * of type [T]. + * An interface that defines how to map each variant of [FunctionCall] to a value of + * type [T]. */ interface Visitor { @@ -751,57 +753,61 @@ class PromptOptions @JsonCreator private constructor( * Maps an unknown variant of [FunctionCall] to a value of type [T]. * * An instance of [FunctionCall] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } internal class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return FunctionCall(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } internal class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize( + value: FunctionCall, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class UnionMember0 @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class UnionMember0 + @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. + * 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 @@ -825,20 +831,19 @@ class PromptOptions @JsonCreator private constructor( * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * + * An instance of [UnionMember0] 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 { AUTO, NONE, /** - * An enum member indicating that [UnionMember0] was instantiated with an unknown - * value. + * An enum member indicating that [UnionMember0] was instantiated with an + * unknown value. */ _UNKNOWN, } @@ -847,8 +852,8 @@ class PromptOptions @JsonCreator private constructor( * 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. + * 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) { @@ -860,17 +865,18 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a + * not a known member. */ fun known(): Known = when (this) { AUTO -> Known.AUTO NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") + else -> + throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } /** @@ -879,17 +885,20 @@ class PromptOptions @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -898,17 +907,19 @@ class PromptOptions @JsonCreator private constructor( } @NoAutoDetect - class Function @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Function + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -916,16 +927,15 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - name() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -934,34 +944,29 @@ class PromptOptions @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ class Builder internal constructor() { private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - name = function.name - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + name = function.name + additionalProperties = function.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -969,40 +974,35 @@ class PromptOptions @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "name", name - ), additionalProperties.toImmutable() + checkRequired("name", name), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1011,19 +1011,20 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{name=$name, additionalProperties=$additionalProperties}" } } @JsonDeserialize(using = ResponseFormat.Deserializer::class) @JsonSerialize(using = ResponseFormat.Serializer::class) - class ResponseFormat private constructor( + class ResponseFormat + private constructor( private val jsonObject: JsonObject? = null, private val jsonSchema: JsonSchema? = null, private val text: Text? = null, private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, - ) { fun jsonObject(): Optional = Optional.ofNullable(jsonObject) @@ -1032,7 +1033,8 @@ class PromptOptions @JsonCreator private constructor( fun text(): Optional = Optional.ofNullable(text) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) + fun nullableVariant(): Optional = + Optional.ofNullable(nullableVariant) fun isJsonObject(): Boolean = jsonObject != null @@ -1048,54 +1050,56 @@ class PromptOptions @JsonCreator private constructor( fun asText(): Text = text.getOrThrow("text") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") + fun asNullableVariant(): NullableVariant = + nullableVariant.getOrThrow("nullableVariant") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - jsonObject != null -> visitor.visitJsonObject(jsonObject) - jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) - text != null -> visitor.visitText(text) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + jsonObject != null -> visitor.visitJsonObject(jsonObject) + jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) + text != null -> visitor.visitText(text) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ResponseFormat = - apply { - if (validated) { - return@apply - } + fun validate(): ResponseFormat = apply { + if (validated) { + return@apply + } - accept(object : Visitor { + accept( + object : Visitor { override fun visitJsonObject(jsonObject: JsonObject) { - jsonObject.validate() + jsonObject.validate() } override fun visitJsonSchema(jsonSchema: JsonSchema) { - jsonSchema.validate() + jsonSchema.validate() } override fun visitText(text: Text) { - text.validate() + text.validate() } override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() + nullableVariant.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ @@ -1105,7 +1109,8 @@ class PromptOptions @JsonCreator private constructor( jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" text != null -> "ResponseFormat{text=$text}" - nullableVariant != null -> "ResponseFormat{nullableVariant=$nullableVariant}" + nullableVariant != null -> + "ResponseFormat{nullableVariant=$nullableVariant}" _json != null -> "ResponseFormat{_unknown=$_json}" else -> throw IllegalStateException("Invalid ResponseFormat") } @@ -1113,16 +1118,18 @@ class PromptOptions @JsonCreator private constructor( companion object { @JvmStatic - fun ofJsonObject(jsonObject: JsonObject) = ResponseFormat(jsonObject = jsonObject) + fun ofJsonObject(jsonObject: JsonObject) = + ResponseFormat(jsonObject = jsonObject) @JvmStatic - fun ofJsonSchema(jsonSchema: JsonSchema) = ResponseFormat(jsonSchema = jsonSchema) + fun ofJsonSchema(jsonSchema: JsonSchema) = + ResponseFormat(jsonSchema = jsonSchema) - @JvmStatic - fun ofText(text: Text) = ResponseFormat(text = text) + @JvmStatic fun ofText(text: Text) = ResponseFormat(text = text) @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = ResponseFormat(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = + ResponseFormat(nullableVariant = nullableVariant) } /** @@ -1143,65 +1150,77 @@ class PromptOptions @JsonCreator private constructor( * Maps an unknown variant of [ResponseFormat] to a value of type [T]. * * An instance of [ResponseFormat] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") + throw BraintrustInvalidDataException("Unknown ResponseFormat: $json") } } - internal class Deserializer : BaseDeserializer(ResponseFormat::class) { + internal class Deserializer : + BaseDeserializer(ResponseFormat::class) { override fun ObjectCodec.deserialize(node: JsonNode): ResponseFormat { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ResponseFormat(jsonObject = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ResponseFormat(jsonSchema = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ResponseFormat(text = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ResponseFormat(nullableVariant = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(jsonObject = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(jsonSchema = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ResponseFormat(nullableVariant = it, _json = json) + } - return ResponseFormat(_json = json) + return ResponseFormat(_json = json) } } internal class Serializer : BaseSerializer(ResponseFormat::class) { - override fun serialize(value: ResponseFormat, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.jsonObject != null -> generator.writeObject(value.jsonObject) - value.jsonSchema != null -> generator.writeObject(value.jsonSchema) - value.text != null -> generator.writeObject(value.text) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ResponseFormat") - } + override fun serialize( + value: ResponseFormat, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.jsonObject != null -> generator.writeObject(value.jsonObject) + value.jsonSchema != null -> generator.writeObject(value.jsonSchema) + value.text != null -> generator.writeObject(value.text) + value.nullableVariant != null -> + generator.writeObject(value.nullableVariant) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ResponseFormat") + } } } @NoAutoDetect - class JsonObject @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class JsonObject + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1209,16 +1228,15 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): JsonObject = - apply { - if (validated) { - return@apply - } - - type() - validated = true + fun validate(): JsonObject = apply { + if (validated) { + return@apply } + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1227,34 +1245,29 @@ class PromptOptions @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [JsonObject]. * * The following fields are required: - * * ```java * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [JsonObject]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(jsonObject: JsonObject) = - apply { - type = jsonObject.type - additionalProperties = jsonObject.additionalProperties.toMutableMap() - } + internal fun from(jsonObject: JsonObject) = apply { + type = jsonObject.type + additionalProperties = jsonObject.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1262,46 +1275,40 @@ class PromptOptions @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsonObject = JsonObject( - checkRequired( - "type", type - ), additionalProperties.toImmutable() + checkRequired("type", type), + additionalProperties.toImmutable(), ) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -1315,32 +1322,34 @@ class PromptOptions @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - JSON_OBJECT, + JSON_OBJECT } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { JSON_OBJECT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, + /** + * 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. + * 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) { @@ -1351,11 +1360,11 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1366,20 +1375,23 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1388,11 +1400,11 @@ class PromptOptions @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsonObject && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonObject && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1401,15 +1413,22 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "JsonObject{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "JsonObject{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class JsonSchema @JsonCreator private constructor( - @JsonProperty("json_schema") @ExcludeMissing private val jsonSchema: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class JsonSchema + @JsonCreator + private constructor( + @JsonProperty("json_schema") + @ExcludeMissing + private val jsonSchema: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun jsonSchema(): InnerJsonSchema = jsonSchema.getRequired("json_schema") @@ -1420,9 +1439,7 @@ class PromptOptions @JsonCreator private constructor( @ExcludeMissing fun _jsonSchema(): JsonField = jsonSchema - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1430,17 +1447,16 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): JsonSchema = - apply { - if (validated) { - return@apply - } - - jsonSchema().validate() - type() - validated = true + fun validate(): JsonSchema = apply { + if (validated) { + return@apply } + jsonSchema().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1449,14 +1465,12 @@ class PromptOptions @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [JsonSchema]. * * The following fields are required: - * * ```java * .jsonSchema() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [JsonSchema]. */ @@ -1464,29 +1478,26 @@ class PromptOptions @JsonCreator private constructor( private var jsonSchema: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(jsonSchema: JsonSchema) = - apply { - this.jsonSchema = jsonSchema.jsonSchema - type = jsonSchema.type - additionalProperties = jsonSchema.additionalProperties.toMutableMap() - } + internal fun from(jsonSchema: JsonSchema) = apply { + this.jsonSchema = jsonSchema.jsonSchema + type = jsonSchema.type + additionalProperties = jsonSchema.additionalProperties.toMutableMap() + } - fun jsonSchema(jsonSchema: InnerJsonSchema) = jsonSchema(JsonField.of(jsonSchema)) + fun jsonSchema(jsonSchema: InnerJsonSchema) = + jsonSchema(JsonField.of(jsonSchema)) - fun jsonSchema(jsonSchema: JsonField) = - apply { - this.jsonSchema = jsonSchema - } + fun jsonSchema(jsonSchema: JsonField) = apply { + this.jsonSchema = jsonSchema + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1494,59 +1505,63 @@ class PromptOptions @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsonSchema = JsonSchema( - checkRequired( - "jsonSchema", jsonSchema - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("jsonSchema", jsonSchema), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InnerJsonSchema @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("schema") @ExcludeMissing private val schema: JsonField = JsonMissing.of(), - @JsonProperty("strict") @ExcludeMissing private val strict: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InnerJsonSchema + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("schema") + @ExcludeMissing + private val schema: JsonField = JsonMissing.of(), + @JsonProperty("strict") + @ExcludeMissing + private val strict: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) - fun schema(): Optional = Optional.ofNullable(schema.getNullable("schema")) + fun schema(): Optional = + Optional.ofNullable(schema.getNullable("schema")) - fun strict(): Optional = Optional.ofNullable(strict.getNullable("strict")) + fun strict(): Optional = + Optional.ofNullable(strict.getNullable("strict")) - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("description") @ExcludeMissing @@ -1566,34 +1581,32 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): InnerJsonSchema = - apply { - if (validated) { - return@apply - } - - name() - description() - schema().ifPresent { it.validate() } - strict() - validated = true + fun validate(): InnerJsonSchema = apply { + if (validated) { + return@apply } + name() + description() + schema().ifPresent { it.validate() } + strict() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [InnerJsonSchema]. + * Returns a mutable builder for constructing an instance of + * [InnerJsonSchema]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InnerJsonSchema]. */ @@ -1603,38 +1616,33 @@ class PromptOptions @JsonCreator private constructor( private var description: JsonField = JsonMissing.of() private var schema: JsonField = JsonMissing.of() private var strict: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(innerJsonSchema: InnerJsonSchema) = - apply { - name = innerJsonSchema.name - description = innerJsonSchema.description - schema = innerJsonSchema.schema - strict = innerJsonSchema.strict - additionalProperties = innerJsonSchema.additionalProperties.toMutableMap() - } + internal fun from(innerJsonSchema: InnerJsonSchema) = apply { + name = innerJsonSchema.name + description = innerJsonSchema.description + schema = innerJsonSchema.schema + strict = innerJsonSchema.strict + additionalProperties = + innerJsonSchema.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String) = + description(JsonField.of(description)) - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } fun schema(schema: Schema) = schema(JsonField.of(schema)) - fun schema(schema: JsonField) = - apply { - this.schema = schema - } + fun schema(schema: JsonField) = apply { this.schema = schema } fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict)) @@ -1642,10 +1650,7 @@ class PromptOptions @JsonCreator private constructor( fun strict(strict: Optional) = strict(strict.getOrNull()) - fun strict(strict: JsonField) = - apply { - this.strict = strict - } + fun strict(strict: JsonField) = apply { this.strict = strict } fun additionalProperties(additionalProperties: Map) = apply { @@ -1653,114 +1658,111 @@ class PromptOptions @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InnerJsonSchema = InnerJsonSchema( - checkRequired( - "name", name - ), - description, - schema, - strict, - additionalProperties.toImmutable(), + checkRequired("name", name), + description, + schema, + strict, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class Schema @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Schema + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap() ) { @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + additionalProperties private var validated: Boolean = false - fun validate(): Schema = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Schema = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Schema]. */ - @JvmStatic - fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [Schema]. + */ + @JvmStatic fun builder() = Builder() } /** A builder for [Schema]. */ class Builder internal constructor() { - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(schema: Schema) = - apply { - additionalProperties = schema.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(schema: Schema) = apply { + additionalProperties = + schema.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Schema = Schema(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1769,15 +1771,16 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Schema{additionalProperties=$additionalProperties}" + override fun toString() = + "Schema{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerJsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InnerJsonSchema && name == other.name && description == other.description && schema == other.schema && strict == other.strict && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1786,21 +1789,21 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InnerJsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" + override fun toString() = + "InnerJsonSchema{name=$name, description=$description, schema=$schema, strict=$strict, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -1814,23 +1817,25 @@ class PromptOptions @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - JSON_SCHEMA, + JSON_SCHEMA } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { JSON_SCHEMA, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -1838,8 +1843,8 @@ class PromptOptions @JsonCreator private constructor( * 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. + * 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) { @@ -1850,11 +1855,11 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -1865,20 +1870,23 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1887,11 +1895,11 @@ class PromptOptions @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsonSchema && jsonSchema == other.jsonSchema && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsonSchema && jsonSchema == other.jsonSchema && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1900,21 +1908,24 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "JsonSchema{jsonSchema=$jsonSchema, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "JsonSchema{jsonSchema=$jsonSchema, type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class Text @JsonCreator private constructor( - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Text + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun type(): Type = type.getRequired("type") - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1922,16 +1933,15 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Text = - apply { - if (validated) { - return@apply - } - - type() - validated = true + fun validate(): Text = apply { + if (validated) { + return@apply } + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -1940,34 +1950,29 @@ class PromptOptions @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Text]. * * The following fields are required: - * * ```java * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Text]. */ class Builder internal constructor() { private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(text: Text) = - apply { - type = text.type - additionalProperties = text.additionalProperties.toMutableMap() - } + internal fun from(text: Text) = apply { + type = text.type + additionalProperties = text.additionalProperties.toMutableMap() + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1975,46 +1980,37 @@ class PromptOptions @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Text = - Text( - checkRequired( - "type", type - ), additionalProperties.toImmutable() - ) + Text(checkRequired("type", type), additionalProperties.toImmutable()) } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -2028,23 +2024,25 @@ class PromptOptions @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - TEXT, + TEXT } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { TEXT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -2052,8 +2050,8 @@ class PromptOptions @JsonCreator private constructor( * 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. + * 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) { @@ -2064,11 +2062,11 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -2079,20 +2077,23 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2101,11 +2102,11 @@ class PromptOptions @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2114,13 +2115,16 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Text{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Text{type=$type, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NullableVariant @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class NullableVariant + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -2129,34 +2133,36 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): NullableVariant = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): NullableVariant = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic - fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of + * [NullableVariant]. + */ + @JvmStatic fun builder() = Builder() } /** A builder for [NullableVariant]. */ class Builder internal constructor() { - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = - apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } + internal fun from(nullableVariant: NullableVariant) = apply { + additionalProperties = + nullableVariant.additionalProperties.toMutableMap() + } fun additionalProperties(additionalProperties: Map) = apply { @@ -2164,35 +2170,32 @@ class PromptOptions @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) + fun build(): NullableVariant = + NullableVariant(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2201,17 +2204,18 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" + override fun toString() = + "NullableVariant{additionalProperties=$additionalProperties}" } } @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice private constructor( + class ToolChoice + private constructor( private val unionMember0: UnionMember0? = null, private val function: Function? = null, private val _json: JsonValue? = null, - ) { fun unionMember0(): Optional = Optional.ofNullable(unionMember0) @@ -2229,39 +2233,38 @@ class PromptOptions @JsonCreator private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } private var validated: Boolean = false - fun validate(): ToolChoice = - apply { - if (validated) { - return@apply - } - - accept(object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { + fun validate(): ToolChoice = apply { + if (validated) { + return@apply + } - } + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) {} override fun visitFunction(function: Function) { - function.validate() + function.validate() } - }) - validated = true - } + } + ) + validated = true + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ToolChoice && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ + return /* spotless:off */ other is ToolChoice && unionMember0 == other.unionMember0 && function == other.function /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, function) /* spotless:on */ @@ -2277,10 +2280,10 @@ class PromptOptions @JsonCreator private constructor( companion object { @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ToolChoice(unionMember0 = unionMember0) + fun ofUnionMember0(unionMember0: UnionMember0) = + ToolChoice(unionMember0 = unionMember0) - @JvmStatic - fun ofFunction(function: Function) = ToolChoice(function = function) + @JvmStatic fun ofFunction(function: Function) = ToolChoice(function = function) } /** @@ -2297,57 +2300,61 @@ class PromptOptions @JsonCreator private constructor( * Maps an unknown variant of [ToolChoice] to a value of type [T]. * * An instance of [ToolChoice] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } internal class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { - return ToolChoice(function = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } internal class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize( + value: ToolChoice, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class UnionMember0 @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class UnionMember0 + @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. + * 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 @@ -2374,12 +2381,11 @@ class PromptOptions @JsonCreator private constructor( * An enum containing [UnionMember0]'s known values, as well as an [_UNKNOWN] * member. * - * An instance of [UnionMember0] can contain an unknown value in a couple of cases: - * + * An instance of [UnionMember0] 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 { @@ -2387,8 +2393,8 @@ class PromptOptions @JsonCreator private constructor( NONE, REQUIRED, /** - * An enum member indicating that [UnionMember0] was instantiated with an unknown - * value. + * An enum member indicating that [UnionMember0] was instantiated with an + * unknown value. */ _UNKNOWN, } @@ -2397,8 +2403,8 @@ class PromptOptions @JsonCreator private constructor( * 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. + * 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) { @@ -2411,18 +2417,19 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a + * not a known member. */ fun known(): Known = when (this) { AUTO -> Known.AUTO NONE -> Known.NONE REQUIRED -> Known.REQUIRED - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") + else -> + throw BraintrustInvalidDataException("Unknown UnionMember0: $value") } /** @@ -2431,17 +2438,20 @@ class PromptOptions @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2450,11 +2460,17 @@ class PromptOptions @JsonCreator private constructor( } @NoAutoDetect - class Function @JsonCreator private constructor( - @JsonProperty("function") @ExcludeMissing private val function: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Function + @JsonCreator + private constructor( + @JsonProperty("function") + @ExcludeMissing + private val function: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun function(): InnerFunction = function.getRequired("function") @@ -2465,9 +2481,7 @@ class PromptOptions @JsonCreator private constructor( @ExcludeMissing fun _function(): JsonField = function - @JsonProperty("type") - @ExcludeMissing - fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2475,17 +2489,16 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Function = - apply { - if (validated) { - return@apply - } - - function().validate() - type() - validated = true + fun validate(): Function = apply { + if (validated) { + return@apply } + function().validate() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -2494,14 +2507,12 @@ class PromptOptions @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Function]. * * The following fields are required: - * * ```java * .function() * .type() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Function]. */ @@ -2509,29 +2520,25 @@ class PromptOptions @JsonCreator private constructor( private var function: JsonField? = null private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(function: Function) = - apply { - this.function = function.function - type = function.type - additionalProperties = function.additionalProperties.toMutableMap() - } + internal fun from(function: Function) = apply { + this.function = function.function + type = function.type + additionalProperties = function.additionalProperties.toMutableMap() + } fun function(function: InnerFunction) = function(JsonField.of(function)) - fun function(function: JsonField) = - apply { - this.function = function - } + fun function(function: JsonField) = apply { + this.function = function + } fun type(type: Type) = type(JsonField.of(type)) - fun type(type: JsonField) = - apply { - this.type = type - } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -2539,50 +2546,45 @@ class PromptOptions @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Function = Function( - checkRequired( - "function", function - ), - checkRequired( - "type", type - ), - additionalProperties.toImmutable(), + checkRequired("function", function), + checkRequired("type", type), + additionalProperties.toImmutable(), ) } @NoAutoDetect - class InnerFunction @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class InnerFunction + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap(), ) { fun name(): String = name.getRequired("name") - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2590,52 +2592,48 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): InnerFunction = - apply { - if (validated) { - return@apply - } - - name() - validated = true + fun validate(): InnerFunction = apply { + if (validated) { + return@apply } + name() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [InnerFunction]. + * Returns a mutable builder for constructing an instance of + * [InnerFunction]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [InnerFunction]. */ class Builder internal constructor() { private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private var additionalProperties: MutableMap = + mutableMapOf() @JvmSynthetic - internal fun from(innerFunction: InnerFunction) = - apply { - name = innerFunction.name - additionalProperties = innerFunction.additionalProperties.toMutableMap() - } + internal fun from(innerFunction: InnerFunction) = apply { + name = innerFunction.name + additionalProperties = + innerFunction.additionalProperties.toMutableMap() + } fun name(name: String) = name(JsonField.of(name)) - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -2643,40 +2641,35 @@ class PromptOptions @JsonCreator private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): InnerFunction = InnerFunction( - checkRequired( - "name", name - ), additionalProperties.toImmutable() + checkRequired("name", name), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is InnerFunction && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InnerFunction && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2685,21 +2678,21 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "InnerFunction{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "InnerFunction{name=$name, additionalProperties=$additionalProperties}" } - class Type @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 @@ -2713,23 +2706,25 @@ class PromptOptions @JsonCreator private constructor( /** An enum containing [Type]'s known values. */ enum class Known { - FUNCTION, + FUNCTION } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * 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. - * + * 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 { FUNCTION, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ _UNKNOWN, } @@ -2737,8 +2732,8 @@ class PromptOptions @JsonCreator private constructor( * 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. + * 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) { @@ -2749,11 +2744,11 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is + * a not a known member. */ fun known(): Known = when (this) { @@ -2764,20 +2759,23 @@ class PromptOptions @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -2786,11 +2784,11 @@ class PromptOptions @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Function && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Function && function == other.function && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2799,16 +2797,17 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Function{function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "Function{function=$function, type=$type, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2817,20 +2816,37 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class AnthropicModelParams @JsonCreator private constructor( - @JsonProperty("max_tokens") @ExcludeMissing private val maxTokens: JsonField = JsonMissing.of(), - @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("max_tokens_to_sample") @ExcludeMissing private val maxTokensToSample: JsonField = JsonMissing.of(), - @JsonProperty("stop_sequences") @ExcludeMissing private val stopSequences: JsonField> = JsonMissing.of(), - @JsonProperty("top_k") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), - @JsonProperty("top_p") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class AnthropicModelParams + @JsonCreator + private constructor( + @JsonProperty("max_tokens") + @ExcludeMissing + private val maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("max_tokens_to_sample") + @ExcludeMissing + private val maxTokensToSample: JsonField = JsonMissing.of(), + @JsonProperty("stop_sequences") + @ExcludeMissing + private val stopSequences: JsonField> = JsonMissing.of(), + @JsonProperty("top_k") + @ExcludeMissing + private val topK: JsonField = JsonMissing.of(), + @JsonProperty("top_p") + @ExcludeMissing + private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun maxTokens(): Double = maxTokens.getRequired("max_tokens") @@ -2838,15 +2854,18 @@ class PromptOptions @JsonCreator private constructor( fun temperature(): Double = temperature.getRequired("temperature") /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + fun maxTokensToSample(): Optional = + Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) - fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + fun stopSequences(): Optional> = + Optional.ofNullable(stopSequences.getNullable("stop_sequences")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("max_tokens") @ExcludeMissing @@ -2865,13 +2884,9 @@ class PromptOptions @JsonCreator private constructor( @ExcludeMissing fun _stopSequences(): JsonField> = stopSequences - @JsonProperty("top_k") - @ExcludeMissing - fun _topK(): JsonField = topK + @JsonProperty("top_k") @ExcludeMissing fun _topK(): JsonField = topK - @JsonProperty("top_p") - @ExcludeMissing - fun _topP(): JsonField = topP + @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -2883,39 +2898,35 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): AnthropicModelParams = - apply { - if (validated) { - return@apply - } - - maxTokens() - temperature() - maxTokensToSample() - stopSequences() - topK() - topP() - useCache() - validated = true + fun validate(): AnthropicModelParams = apply { + if (validated) { + return@apply } + maxTokens() + temperature() + maxTokensToSample() + stopSequences() + topK() + topP() + useCache() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [AnthropicModelParams]. + * Returns a mutable builder for constructing an instance of [AnthropicModelParams]. * * The following fields are required: - * * ```java * .maxTokens() * .temperature() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AnthropicModelParams]. */ @@ -2931,125 +2942,103 @@ class PromptOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(anthropicModelParams: AnthropicModelParams) = - apply { - maxTokens = anthropicModelParams.maxTokens - temperature = anthropicModelParams.temperature - maxTokensToSample = anthropicModelParams.maxTokensToSample - stopSequences = anthropicModelParams.stopSequences.map { it.toMutableList() } - topK = anthropicModelParams.topK - topP = anthropicModelParams.topP - useCache = anthropicModelParams.useCache - additionalProperties = anthropicModelParams.additionalProperties.toMutableMap() - } + internal fun from(anthropicModelParams: AnthropicModelParams) = apply { + maxTokens = anthropicModelParams.maxTokens + temperature = anthropicModelParams.temperature + maxTokensToSample = anthropicModelParams.maxTokensToSample + stopSequences = anthropicModelParams.stopSequences.map { it.toMutableList() } + topK = anthropicModelParams.topK + topP = anthropicModelParams.topP + useCache = anthropicModelParams.useCache + additionalProperties = anthropicModelParams.additionalProperties.toMutableMap() + } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) - fun maxTokens(maxTokens: JsonField) = - apply { - this.maxTokens = maxTokens - } + fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = - apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) + fun maxTokensToSample(maxTokensToSample: Double) = + maxTokensToSample(JsonField.of(maxTokensToSample)) /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(maxTokensToSample: JsonField) = - apply { - this.maxTokensToSample = maxTokensToSample - } + fun maxTokensToSample(maxTokensToSample: JsonField) = apply { + this.maxTokensToSample = maxTokensToSample + } - fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = + stopSequences(JsonField.of(stopSequences)) - fun stopSequences(stopSequences: JsonField>) = - apply { - this.stopSequences = stopSequences.map { it.toMutableList() } - } + fun stopSequences(stopSequences: JsonField>) = apply { + this.stopSequences = stopSequences.map { it.toMutableList() } + } - fun addStopSequence(stopSequence: String) = - apply { - stopSequences = (stopSequences ?: JsonField.of(mutableListOf())).also { + fun addStopSequence(stopSequence: String) = apply { + stopSequences = + (stopSequences ?: JsonField.of(mutableListOf())).also { checkKnown("stopSequences", it).add(stopSequence) } - } + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = - apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = - apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = - apply { - this.useCache = useCache - } + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AnthropicModelParams = AnthropicModelParams( - checkRequired( - "maxTokens", maxTokens - ), - checkRequired( - "temperature", temperature - ), - maxTokensToSample, - (stopSequences ?: JsonMissing.of()).map { it.toImmutable() }, - topK, - topP, - useCache, - additionalProperties.toImmutable(), + checkRequired("maxTokens", maxTokens), + checkRequired("temperature", temperature), + maxTokensToSample, + (stopSequences ?: JsonMissing.of()).map { it.toImmutable() }, + topK, + topP, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AnthropicModelParams && maxTokens == other.maxTokens && temperature == other.temperature && maxTokensToSample == other.maxTokensToSample && stopSequences == other.stopSequences && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AnthropicModelParams && maxTokens == other.maxTokens && temperature == other.temperature && maxTokensToSample == other.maxTokensToSample && stopSequences == other.stopSequences && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3058,29 +3047,45 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "AnthropicModelParams{maxTokens=$maxTokens, temperature=$temperature, maxTokensToSample=$maxTokensToSample, stopSequences=$stopSequences, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "AnthropicModelParams{maxTokens=$maxTokens, temperature=$temperature, maxTokensToSample=$maxTokensToSample, stopSequences=$stopSequences, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class GoogleModelParams @JsonCreator private constructor( - @JsonProperty("maxOutputTokens") @ExcludeMissing private val maxOutputTokens: JsonField = JsonMissing.of(), - @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("topK") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), - @JsonProperty("topP") @ExcludeMissing private val topP: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class GoogleModelParams + @JsonCreator + private constructor( + @JsonProperty("maxOutputTokens") + @ExcludeMissing + private val maxOutputTokens: JsonField = JsonMissing.of(), + @JsonProperty("temperature") + @ExcludeMissing + private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("topK") + @ExcludeMissing + private val topK: JsonField = JsonMissing.of(), + @JsonProperty("topP") + @ExcludeMissing + private val topP: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + fun maxOutputTokens(): Optional = + Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -3090,13 +3095,9 @@ class PromptOptions @JsonCreator private constructor( @ExcludeMissing fun _temperature(): JsonField = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK(): JsonField = topK + @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK - @JsonProperty("topP") - @ExcludeMissing - fun _topP(): JsonField = topP + @JsonProperty("topP") @ExcludeMissing fun _topP(): JsonField = topP @JsonProperty("use_cache") @ExcludeMissing @@ -3108,27 +3109,27 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): GoogleModelParams = - apply { - if (validated) { - return@apply - } - - maxOutputTokens() - temperature() - topK() - topP() - useCache() - validated = true + fun validate(): GoogleModelParams = apply { + if (validated) { + return@apply } + maxOutputTokens() + temperature() + topK() + topP() + useCache() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [GoogleModelParams]. */ - @JvmStatic - fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of [GoogleModelParams]. + */ + @JvmStatic fun builder() = Builder() } /** A builder for [GoogleModelParams]. */ @@ -3142,94 +3143,79 @@ class PromptOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(googleModelParams: GoogleModelParams) = - apply { - maxOutputTokens = googleModelParams.maxOutputTokens - temperature = googleModelParams.temperature - topK = googleModelParams.topK - topP = googleModelParams.topP - useCache = googleModelParams.useCache - additionalProperties = googleModelParams.additionalProperties.toMutableMap() - } + internal fun from(googleModelParams: GoogleModelParams) = apply { + maxOutputTokens = googleModelParams.maxOutputTokens + temperature = googleModelParams.temperature + topK = googleModelParams.topK + topP = googleModelParams.topP + useCache = googleModelParams.useCache + additionalProperties = googleModelParams.additionalProperties.toMutableMap() + } - fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = + maxOutputTokens(JsonField.of(maxOutputTokens)) - fun maxOutputTokens(maxOutputTokens: JsonField) = - apply { - this.maxOutputTokens = maxOutputTokens - } + fun maxOutputTokens(maxOutputTokens: JsonField) = apply { + this.maxOutputTokens = maxOutputTokens + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = - apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = - apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } fun topP(topP: Double) = topP(JsonField.of(topP)) - fun topP(topP: JsonField) = - apply { - this.topP = topP - } + fun topP(topP: JsonField) = apply { this.topP = topP } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = - apply { - this.useCache = useCache - } + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): GoogleModelParams = GoogleModelParams( - maxOutputTokens, - temperature, - topK, - topP, - useCache, - additionalProperties.toImmutable(), + maxOutputTokens, + temperature, + topK, + topP, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GoogleModelParams && maxOutputTokens == other.maxOutputTokens && temperature == other.temperature && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GoogleModelParams && maxOutputTokens == other.maxOutputTokens && temperature == other.temperature && topK == other.topK && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3238,31 +3224,40 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "GoogleModelParams{maxOutputTokens=$maxOutputTokens, temperature=$temperature, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "GoogleModelParams{maxOutputTokens=$maxOutputTokens, temperature=$temperature, topK=$topK, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class WindowAiModelParams @JsonCreator private constructor( - @JsonProperty("temperature") @ExcludeMissing private val temperature: JsonField = JsonMissing.of(), - @JsonProperty("topK") @ExcludeMissing private val topK: JsonField = JsonMissing.of(), - @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class WindowAiModelParams + @JsonCreator + private constructor( + @JsonProperty("temperature") + @ExcludeMissing + private val temperature: JsonField = JsonMissing.of(), + @JsonProperty("topK") + @ExcludeMissing + private val topK: JsonField = JsonMissing.of(), + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + fun temperature(): Optional = + Optional.ofNullable(temperature.getNullable("temperature")) fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("temperature") @ExcludeMissing fun _temperature(): JsonField = temperature - @JsonProperty("topK") - @ExcludeMissing - fun _topK(): JsonField = topK + @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK @JsonProperty("use_cache") @ExcludeMissing @@ -3274,25 +3269,25 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): WindowAiModelParams = - apply { - if (validated) { - return@apply - } - - temperature() - topK() - useCache() - validated = true + fun validate(): WindowAiModelParams = apply { + if (validated) { + return@apply } + temperature() + topK() + useCache() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [WindowAiModelParams]. */ - @JvmStatic - fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of [WindowAiModelParams]. + */ + @JvmStatic fun builder() = Builder() } /** A builder for [WindowAiModelParams]. */ @@ -3304,76 +3299,64 @@ class PromptOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(windowAiModelParams: WindowAiModelParams) = - apply { - temperature = windowAiModelParams.temperature - topK = windowAiModelParams.topK - useCache = windowAiModelParams.useCache - additionalProperties = windowAiModelParams.additionalProperties.toMutableMap() - } + internal fun from(windowAiModelParams: WindowAiModelParams) = apply { + temperature = windowAiModelParams.temperature + topK = windowAiModelParams.topK + useCache = windowAiModelParams.useCache + additionalProperties = windowAiModelParams.additionalProperties.toMutableMap() + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) - fun temperature(temperature: JsonField) = - apply { - this.temperature = temperature - } + fun temperature(temperature: JsonField) = apply { + this.temperature = temperature + } fun topK(topK: Double) = topK(JsonField.of(topK)) - fun topK(topK: JsonField) = - apply { - this.topK = topK - } + fun topK(topK: JsonField) = apply { this.topK = topK } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = - apply { - this.useCache = useCache - } + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): WindowAiModelParams = WindowAiModelParams( - temperature, - topK, - useCache, - additionalProperties.toImmutable(), + temperature, + topK, + useCache, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is WindowAiModelParams && temperature == other.temperature && topK == other.topK && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is WindowAiModelParams && temperature == other.temperature && topK == other.topK && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3382,17 +3365,23 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "WindowAiModelParams{temperature=$temperature, topK=$topK, useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "WindowAiModelParams{temperature=$temperature, topK=$topK, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect - class JsCompletionParams @JsonCreator private constructor( - @JsonProperty("use_cache") @ExcludeMissing private val useCache: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class JsCompletionParams + @JsonCreator + private constructor( + @JsonProperty("use_cache") + @ExcludeMissing + private val useCache: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { - fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + fun useCache(): Optional = + Optional.ofNullable(useCache.getNullable("use_cache")) @JsonProperty("use_cache") @ExcludeMissing @@ -3404,23 +3393,23 @@ class PromptOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): JsCompletionParams = - apply { - if (validated) { - return@apply - } - - useCache() - validated = true + fun validate(): JsCompletionParams = apply { + if (validated) { + return@apply } + useCache() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [JsCompletionParams]. */ - @JvmStatic - fun builder() = Builder() + /** + * Returns a mutable builder for constructing an instance of [JsCompletionParams]. + */ + @JvmStatic fun builder() = Builder() } /** A builder for [JsCompletionParams]. */ @@ -3430,57 +3419,47 @@ class PromptOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jsCompletionParams: JsCompletionParams) = - apply { - useCache = jsCompletionParams.useCache - additionalProperties = jsCompletionParams.additionalProperties.toMutableMap() - } + internal fun from(jsCompletionParams: JsCompletionParams) = apply { + useCache = jsCompletionParams.useCache + additionalProperties = jsCompletionParams.additionalProperties.toMutableMap() + } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) - fun useCache(useCache: JsonField) = - apply { - this.useCache = useCache - } + fun useCache(useCache: JsonField) = apply { this.useCache = useCache } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): JsCompletionParams = - JsCompletionParams( - useCache, additionalProperties.toImmutable() - ) + JsCompletionParams(useCache, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is JsCompletionParams && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is JsCompletionParams && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3489,16 +3468,17 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = + "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptOptions && model == other.model && params == other.params && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PromptOptions && model == other.model && params == other.params && position == other.position && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3507,5 +3487,6 @@ class PromptOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "PromptOptions{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = + "PromptOptions{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index fed28c24..cf0797b3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -25,15 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace prompt. If there is an existing prompt in the project with the - * same slug as the one specified in the request, will replace the existing prompt - * with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the same slug as the + * one specified in the request, will replace the existing prompt with the provided fields */ -class PromptReplaceParams private constructor( +class PromptReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the prompt */ @@ -82,24 +81,39 @@ class PromptReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), - @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("function_type") @ExcludeMissing private val functionType: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("function_type") + @ExcludeMissing + private val functionType: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the prompt */ @@ -112,30 +126,27 @@ class PromptReplaceParams private constructor( fun slug(): String = slug.getRequired("slug") /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) - fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) + fun functionType(): Optional = + Optional.ofNullable(functionType.getNullable("function_type")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** A list of tags for the prompt */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** Textual description of the prompt */ @JsonProperty("description") @@ -152,9 +163,7 @@ class PromptReplaceParams private constructor( fun _promptData(): JsonField = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -162,22 +171,21 @@ class PromptReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - slug() - description() - functionType() - promptData().ifPresent { it.validate() } - tags() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + slug() + description() + functionType() + promptData().ifPresent { it.validate() } + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -186,15 +194,13 @@ class PromptReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -210,44 +216,34 @@ class PromptReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - slug = body.slug - description = body.description - functionType = body.functionType - promptData = body.promptData - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + slug = body.slug + description = body.description + functionType = body.functionType + promptData = body.promptData + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -256,19 +252,19 @@ class PromptReplaceParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } - fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + fun functionType(functionType: FunctionType?) = + functionType(JsonField.ofNullable(functionType)) - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - this.functionType = functionType - } + fun functionType(functionType: JsonField) = apply { + this.functionType = functionType + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -277,10 +273,9 @@ class PromptReplaceParams private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -289,70 +284,54 @@ class PromptReplaceParams private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "slug", slug - ), - description, - functionType, - promptData, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + description, + functionType, + promptData, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && slug == other.slug && description == other.description && functionType == other.functionType && promptData == other.promptData && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -361,7 +340,8 @@ class PromptReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -372,15 +352,13 @@ class PromptReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [PromptReplaceParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * .slug() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptReplaceParams]. */ @@ -392,286 +370,206 @@ class PromptReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptReplaceParams: PromptReplaceParams) = - apply { - body = promptReplaceParams.body.toBuilder() - additionalHeaders = promptReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = promptReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(promptReplaceParams: PromptReplaceParams) = apply { + body = promptReplaceParams.body.toBuilder() + additionalHeaders = promptReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = promptReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the prompt */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the prompt */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Unique identifier for the prompt */ - fun slug(slug: String) = - apply { - body.slug(slug) - } + fun slug(slug: String) = apply { body.slug(slug) } /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - body.slug(slug) - } + fun slug(slug: JsonField) = apply { body.slug(slug) } /** Textual description of the prompt */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } - fun functionType(functionType: FunctionType?) = - apply { - body.functionType(functionType) - } + fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } - fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + fun functionType(functionType: Optional) = + functionType(functionType.getOrNull()) - fun functionType(functionType: JsonField) = - apply { - body.functionType(functionType) - } + fun functionType(functionType: JsonField) = apply { + body.functionType(functionType) + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ - fun tags(tags: List?) = - apply { - body.tags(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - body.tags(tags) - } + fun tags(tags: JsonField>) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - body.addTag(tag) - } + fun addTag(tag: String) = apply { body.addTag(tag) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptReplaceParams = PromptReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } - class FunctionType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + class FunctionType @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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -695,15 +593,12 @@ class PromptReplaceParams private constructor( } /** - * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] - * member. + * An enum containing [FunctionType]'s known values, as well as an [_UNKNOWN] member. * * An instance of [FunctionType] 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 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 { @@ -712,18 +607,17 @@ class PromptReplaceParams private constructor( TASK, TOOL, /** - * An enum member indicating that [FunctionType] was instantiated with an unknown - * value. + * An enum member indicating that [FunctionType] 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. + * 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. + * 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) { @@ -737,11 +631,11 @@ class PromptReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -755,20 +649,23 @@ class PromptReplaceParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ + return /* spotless:off */ other is FunctionType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -777,14 +674,15 @@ class PromptReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "PromptReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "PromptReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 0889cb45..039b2d8a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a prompt object by its id */ -class PromptRetrieveParams private constructor( +class PromptRetrieveParams +private constructor( private val promptId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Prompt id */ @@ -29,10 +29,10 @@ class PromptRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class PromptRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PromptRetrieveParams]. + * Returns a mutable builder for constructing an instance of [PromptRetrieveParams]. * * The following fields are required: - * * ```java * .promptId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptRetrieveParams]. */ @@ -62,162 +59,131 @@ class PromptRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptRetrieveParams: PromptRetrieveParams) = - apply { - promptId = promptRetrieveParams.promptId - additionalHeaders = promptRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = promptRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(promptRetrieveParams: PromptRetrieveParams) = apply { + promptId = promptRetrieveParams.promptId + additionalHeaders = promptRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = promptRetrieveParams.additionalQueryParams.toBuilder() + } /** Prompt id */ - fun promptId(promptId: String) = - apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptRetrieveParams = PromptRetrieveParams( - checkRequired( - "promptId", promptId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("promptId", promptId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptRetrieveParams && promptId == other.promptId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "PromptRetrieveParams{promptId=$promptId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index abef1b23..d8447483 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -23,16 +23,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a prompt object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. */ -class PromptUpdateParams private constructor( +class PromptUpdateParams +private constructor( private val promptId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Prompt id */ @@ -74,39 +74,52 @@ class PromptUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("prompt_data") @ExcludeMissing private val promptData: JsonField = JsonMissing.of(), - @JsonProperty("slug") @ExcludeMissing private val slug: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("prompt_data") + @ExcludeMissing + private val promptData: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + private val slug: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + private val tags: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Textual description of the prompt */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the prompt */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The prompt, model, and its parameters */ - fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) + fun promptData(): Optional = + Optional.ofNullable(promptData.getNullable("prompt_data")) /** Unique identifier for the prompt */ fun slug(): Optional = Optional.ofNullable(slug.getNullable("slug")) @@ -120,9 +133,7 @@ class PromptUpdateParams private constructor( fun _description(): JsonField = description /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @@ -130,14 +141,10 @@ class PromptUpdateParams private constructor( fun _promptData(): JsonField = promptData /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun _slug(): JsonField = slug + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun _tags(): JsonField> = tags + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @ExcludeMissing @@ -145,27 +152,25 @@ class PromptUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - description() - name() - promptData().ifPresent { it.validate() } - slug() - tags() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + description() + name() + promptData().ifPresent { it.validate() } + slug() + tags() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -179,15 +184,14 @@ class PromptUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - description = body.description - name = body.name - promptData = body.promptData - slug = body.slug - tags = body.tags.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + description = body.description + name = body.name + promptData = body.promptData + slug = body.slug + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -196,10 +200,9 @@ class PromptUpdateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -208,10 +211,7 @@ class PromptUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) @@ -220,10 +220,9 @@ class PromptUpdateParams private constructor( fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - this.promptData = promptData - } + fun promptData(promptData: JsonField) = apply { + this.promptData = promptData + } /** Unique identifier for the prompt */ fun slug(slug: String?) = slug(JsonField.ofNullable(slug)) @@ -232,10 +231,7 @@ class PromptUpdateParams private constructor( fun slug(slug: Optional) = slug(slug.getOrNull()) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - this.slug = slug - } + fun slug(slug: JsonField) = apply { this.slug = slug } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -244,62 +240,52 @@ class PromptUpdateParams private constructor( fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - this.tags = tags.map { it.toMutableList() } - } + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - tags = (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - description, - name, - promptData, - slug, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + description, + name, + promptData, + slug, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && name == other.name && promptData == other.promptData && slug == other.slug && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -308,7 +294,8 @@ class PromptUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -319,13 +306,11 @@ class PromptUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [PromptUpdateParams]. * * The following fields are required: - * * ```java * .promptId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [PromptUpdateParams]. */ @@ -338,272 +323,200 @@ class PromptUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(promptUpdateParams: PromptUpdateParams) = - apply { - promptId = promptUpdateParams.promptId - body = promptUpdateParams.body.toBuilder() - additionalHeaders = promptUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = promptUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(promptUpdateParams: PromptUpdateParams) = apply { + promptId = promptUpdateParams.promptId + body = promptUpdateParams.body.toBuilder() + additionalHeaders = promptUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = promptUpdateParams.additionalQueryParams.toBuilder() + } /** Prompt id */ - fun promptId(promptId: String) = - apply { - this.promptId = promptId - } + fun promptId(promptId: String) = apply { this.promptId = promptId } /** Textual description of the prompt */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the prompt */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the prompt */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** Name of the prompt */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the prompt */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the prompt */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData?) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } /** The prompt, model, and its parameters */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) /** The prompt, model, and its parameters */ - fun promptData(promptData: JsonField) = - apply { - body.promptData(promptData) - } + fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** Unique identifier for the prompt */ - fun slug(slug: String?) = - apply { - body.slug(slug) - } + fun slug(slug: String?) = apply { body.slug(slug) } /** Unique identifier for the prompt */ fun slug(slug: Optional) = slug(slug.getOrNull()) /** Unique identifier for the prompt */ - fun slug(slug: JsonField) = - apply { - body.slug(slug) - } + fun slug(slug: JsonField) = apply { body.slug(slug) } /** A list of tags for the prompt */ - fun tags(tags: List?) = - apply { - body.tags(tags) - } + fun tags(tags: List?) = apply { body.tags(tags) } /** A list of tags for the prompt */ fun tags(tags: Optional>) = tags(tags.getOrNull()) /** A list of tags for the prompt */ - fun tags(tags: JsonField>) = - apply { - body.tags(tags) - } + fun tags(tags: JsonField>) = apply { body.tags(tags) } /** A list of tags for the prompt */ - fun addTag(tag: String) = - apply { - body.addTag(tag) - } + fun addTag(tag: String) = apply { body.addTag(tag) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): PromptUpdateParams = PromptUpdateParams( - checkRequired( - "promptId", promptId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("promptId", promptId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PromptUpdateParams && promptId == other.promptId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(promptId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "PromptUpdateParams{promptId=$promptId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "PromptUpdateParams{promptId=$promptId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index fda9c97a..a938b801 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -19,22 +19,38 @@ import kotlin.jvm.optionals.getOrNull /** Metadata about the state of the repo when the experiment was created */ @NoAutoDetect -class RepoInfo @JsonCreator private constructor( - @JsonProperty("author_email") @ExcludeMissing private val authorEmail: JsonField = JsonMissing.of(), - @JsonProperty("author_name") @ExcludeMissing private val authorName: JsonField = JsonMissing.of(), - @JsonProperty("branch") @ExcludeMissing private val branch: JsonField = JsonMissing.of(), - @JsonProperty("commit") @ExcludeMissing private val commit: JsonField = JsonMissing.of(), - @JsonProperty("commit_message") @ExcludeMissing private val commitMessage: JsonField = JsonMissing.of(), - @JsonProperty("commit_time") @ExcludeMissing private val commitTime: JsonField = JsonMissing.of(), +class RepoInfo +@JsonCreator +private constructor( + @JsonProperty("author_email") + @ExcludeMissing + private val authorEmail: JsonField = JsonMissing.of(), + @JsonProperty("author_name") + @ExcludeMissing + private val authorName: JsonField = JsonMissing.of(), + @JsonProperty("branch") + @ExcludeMissing + private val branch: JsonField = JsonMissing.of(), + @JsonProperty("commit") + @ExcludeMissing + private val commit: JsonField = JsonMissing.of(), + @JsonProperty("commit_message") + @ExcludeMissing + private val commitMessage: JsonField = JsonMissing.of(), + @JsonProperty("commit_time") + @ExcludeMissing + private val commitTime: JsonField = JsonMissing.of(), @JsonProperty("dirty") @ExcludeMissing private val dirty: JsonField = JsonMissing.of(), - @JsonProperty("git_diff") @ExcludeMissing private val gitDiff: JsonField = JsonMissing.of(), + @JsonProperty("git_diff") + @ExcludeMissing + private val gitDiff: JsonField = JsonMissing.of(), @JsonProperty("tag") @ExcludeMissing private val tag: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Email of the author of the most recent commit */ - fun authorEmail(): Optional = Optional.ofNullable(authorEmail.getNullable("author_email")) + fun authorEmail(): Optional = + Optional.ofNullable(authorEmail.getNullable("author_email")) /** Name of the author of the most recent commit */ fun authorName(): Optional = Optional.ofNullable(authorName.getNullable("author_name")) @@ -46,7 +62,8 @@ class RepoInfo @JsonCreator private constructor( fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) /** Most recent commit message */ - fun commitMessage(): Optional = Optional.ofNullable(commitMessage.getNullable("commit_message")) + fun commitMessage(): Optional = + Optional.ofNullable(commitMessage.getNullable("commit_message")) /** Time of the most recent commit */ fun commitTime(): Optional = Optional.ofNullable(commitTime.getNullable("commit_time")) @@ -55,8 +72,8 @@ class RepoInfo @JsonCreator private constructor( fun dirty(): Optional = Optional.ofNullable(dirty.getNullable("dirty")) /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the repo + * and the most recent commit. */ fun gitDiff(): Optional = Optional.ofNullable(gitDiff.getNullable("git_diff")) @@ -69,19 +86,13 @@ class RepoInfo @JsonCreator private constructor( fun _authorEmail(): JsonField = authorEmail /** Name of the author of the most recent commit */ - @JsonProperty("author_name") - @ExcludeMissing - fun _authorName(): JsonField = authorName + @JsonProperty("author_name") @ExcludeMissing fun _authorName(): JsonField = authorName /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") - @ExcludeMissing - fun _branch(): JsonField = branch + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch /** SHA of most recent commit */ - @JsonProperty("commit") - @ExcludeMissing - fun _commit(): JsonField = commit + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit /** Most recent commit message */ @JsonProperty("commit_message") @@ -89,27 +100,19 @@ class RepoInfo @JsonCreator private constructor( fun _commitMessage(): JsonField = commitMessage /** Time of the most recent commit */ - @JsonProperty("commit_time") - @ExcludeMissing - fun _commitTime(): JsonField = commitTime + @JsonProperty("commit_time") @ExcludeMissing fun _commitTime(): JsonField = commitTime /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") - @ExcludeMissing - fun _dirty(): JsonField = dirty + @JsonProperty("dirty") @ExcludeMissing fun _dirty(): JsonField = dirty /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the repo + * and the most recent commit. */ - @JsonProperty("git_diff") - @ExcludeMissing - fun _gitDiff(): JsonField = gitDiff + @JsonProperty("git_diff") @ExcludeMissing fun _gitDiff(): JsonField = gitDiff /** Name of the tag on the most recent commit */ - @JsonProperty("tag") - @ExcludeMissing - fun _tag(): JsonField = tag + @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField = tag @JsonAnyGetter @ExcludeMissing @@ -117,31 +120,29 @@ class RepoInfo @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): RepoInfo = - apply { - if (validated) { - return@apply - } - - authorEmail() - authorName() - branch() - commit() - commitMessage() - commitTime() - dirty() - gitDiff() - tag() - validated = true + fun validate(): RepoInfo = apply { + if (validated) { + return@apply } + authorEmail() + authorName() + branch() + commit() + commitMessage() + commitTime() + dirty() + gitDiff() + tag() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [RepoInfo]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RepoInfo]. */ @@ -159,19 +160,18 @@ class RepoInfo @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(repoInfo: RepoInfo) = - apply { - authorEmail = repoInfo.authorEmail - authorName = repoInfo.authorName - branch = repoInfo.branch - commit = repoInfo.commit - commitMessage = repoInfo.commitMessage - commitTime = repoInfo.commitTime - dirty = repoInfo.dirty - gitDiff = repoInfo.gitDiff - tag = repoInfo.tag - additionalProperties = repoInfo.additionalProperties.toMutableMap() - } + internal fun from(repoInfo: RepoInfo) = apply { + authorEmail = repoInfo.authorEmail + authorName = repoInfo.authorName + branch = repoInfo.branch + commit = repoInfo.commit + commitMessage = repoInfo.commitMessage + commitTime = repoInfo.commitTime + dirty = repoInfo.dirty + gitDiff = repoInfo.gitDiff + tag = repoInfo.tag + additionalProperties = repoInfo.additionalProperties.toMutableMap() + } /** Email of the author of the most recent commit */ fun authorEmail(authorEmail: String?) = authorEmail(JsonField.ofNullable(authorEmail)) @@ -180,10 +180,7 @@ class RepoInfo @JsonCreator private constructor( fun authorEmail(authorEmail: Optional) = authorEmail(authorEmail.getOrNull()) /** Email of the author of the most recent commit */ - fun authorEmail(authorEmail: JsonField) = - apply { - this.authorEmail = authorEmail - } + fun authorEmail(authorEmail: JsonField) = apply { this.authorEmail = authorEmail } /** Name of the author of the most recent commit */ fun authorName(authorName: String?) = authorName(JsonField.ofNullable(authorName)) @@ -192,10 +189,7 @@ class RepoInfo @JsonCreator private constructor( fun authorName(authorName: Optional) = authorName(authorName.getOrNull()) /** Name of the author of the most recent commit */ - fun authorName(authorName: JsonField) = - apply { - this.authorName = authorName - } + fun authorName(authorName: JsonField) = apply { this.authorName = authorName } /** Name of the branch the most recent commit belongs to */ fun branch(branch: String?) = branch(JsonField.ofNullable(branch)) @@ -204,10 +198,7 @@ class RepoInfo @JsonCreator private constructor( fun branch(branch: Optional) = branch(branch.getOrNull()) /** Name of the branch the most recent commit belongs to */ - fun branch(branch: JsonField) = - apply { - this.branch = branch - } + fun branch(branch: JsonField) = apply { this.branch = branch } /** SHA of most recent commit */ fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) @@ -216,22 +207,20 @@ class RepoInfo @JsonCreator private constructor( fun commit(commit: Optional) = commit(commit.getOrNull()) /** SHA of most recent commit */ - fun commit(commit: JsonField) = - apply { - this.commit = commit - } + fun commit(commit: JsonField) = apply { this.commit = commit } /** Most recent commit message */ - fun commitMessage(commitMessage: String?) = commitMessage(JsonField.ofNullable(commitMessage)) + fun commitMessage(commitMessage: String?) = + commitMessage(JsonField.ofNullable(commitMessage)) /** Most recent commit message */ - fun commitMessage(commitMessage: Optional) = commitMessage(commitMessage.getOrNull()) + fun commitMessage(commitMessage: Optional) = + commitMessage(commitMessage.getOrNull()) /** Most recent commit message */ - fun commitMessage(commitMessage: JsonField) = - apply { - this.commitMessage = commitMessage - } + fun commitMessage(commitMessage: JsonField) = apply { + this.commitMessage = commitMessage + } /** Time of the most recent commit */ fun commitTime(commitTime: String?) = commitTime(JsonField.ofNullable(commitTime)) @@ -240,10 +229,7 @@ class RepoInfo @JsonCreator private constructor( fun commitTime(commitTime: Optional) = commitTime(commitTime.getOrNull()) /** Time of the most recent commit */ - fun commitTime(commitTime: JsonField) = - apply { - this.commitTime = commitTime - } + fun commitTime(commitTime: JsonField) = apply { this.commitTime = commitTime } /** Whether or not the repo had uncommitted changes when snapshotted */ fun dirty(dirty: Boolean?) = dirty(JsonField.ofNullable(dirty)) @@ -255,31 +241,25 @@ class RepoInfo @JsonCreator private constructor( fun dirty(dirty: Optional) = dirty(dirty.getOrNull()) /** Whether or not the repo had uncommitted changes when snapshotted */ - fun dirty(dirty: JsonField) = - apply { - this.dirty = dirty - } + fun dirty(dirty: JsonField) = apply { this.dirty = dirty } /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the + * repo and the most recent commit. */ fun gitDiff(gitDiff: String?) = gitDiff(JsonField.ofNullable(gitDiff)) /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the + * repo and the most recent commit. */ fun gitDiff(gitDiff: Optional) = gitDiff(gitDiff.getOrNull()) /** - * If the repo was dirty when run, this includes the diff between the current state - * of the repo and the most recent commit. + * If the repo was dirty when run, this includes the diff between the current state of the + * repo and the most recent commit. */ - fun gitDiff(gitDiff: JsonField) = - apply { - this.gitDiff = gitDiff - } + fun gitDiff(gitDiff: JsonField) = apply { this.gitDiff = gitDiff } /** Name of the tag on the most recent commit */ fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) @@ -288,58 +268,48 @@ class RepoInfo @JsonCreator private constructor( fun tag(tag: Optional) = tag(tag.getOrNull()) /** Name of the tag on the most recent commit */ - fun tag(tag: JsonField) = - apply { - this.tag = tag - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun tag(tag: JsonField) = apply { this.tag = tag } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RepoInfo = RepoInfo( - authorEmail, - authorName, - branch, - commit, - commitMessage, - commitTime, - dirty, - gitDiff, - tag, - additionalProperties.toImmutable(), + authorEmail, + authorName, + branch, + commit, + commitMessage, + commitTime, + dirty, + gitDiff, + tag, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RepoInfo && authorEmail == other.authorEmail && authorName == other.authorName && branch == other.branch && commit == other.commit && commitMessage == other.commitMessage && commitTime == other.commitTime && dirty == other.dirty && gitDiff == other.gitDiff && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RepoInfo && authorEmail == other.authorEmail && authorName == other.authorName && branch == other.branch && commit == other.commit && commitMessage == other.commitMessage && commitTime == other.commitTime && dirty == other.dirty && gitDiff == other.gitDiff && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -348,5 +318,6 @@ class RepoInfo @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RepoInfo{authorEmail=$authorEmail, authorName=$authorName, branch=$branch, commit=$commit, commitMessage=$commitMessage, commitTime=$commitTime, dirty=$dirty, gitDiff=$gitDiff, tag=$tag, additionalProperties=$additionalProperties}" + override fun toString() = + "RepoInfo{authorEmail=$authorEmail, authorName=$authorName, branch=$branch, commit=$commit, commitMessage=$commitMessage, commitTime=$commitTime, dirty=$dirty, gitDiff=$gitDiff, tag=$tag, additionalProperties=$additionalProperties}" } 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 af3cc656..3af60e1a 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 @@ -25,22 +25,34 @@ import kotlin.jvm.optionals.getOrNull /** * A role is a collection of permissions which can be granted as part of an ACL * - * Roles can consist of individual permissions, as well as a set of roles they - * inherit from + * Roles can consist of individual permissions, as well as a set of roles they inherit from */ @NoAutoDetect -class Role @JsonCreator private constructor( +class Role +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") + @ExcludeMissing + private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") + @ExcludeMissing + private val memberRoles: JsonField> = JsonMissing.of(), @JsonProperty("org_id") @ExcludeMissing private val orgId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the role */ @@ -53,27 +65,31 @@ class Role @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the role */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions */ - fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = + Optional.ofNullable(memberRoles.getNullable("member_roles")) /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by any + * other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -83,19 +99,13 @@ class Role @JsonCreator private constructor( fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the role */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the role */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Date of role creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -103,9 +113,7 @@ class Role @JsonCreator private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the role */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -115,8 +123,8 @@ class Role @JsonCreator private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing @@ -125,19 +133,15 @@ class Role @JsonCreator private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by any + * other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ - @JsonProperty("org_id") - @ExcludeMissing - fun _orgId(): JsonField = orgId + @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** Identifies the user who created the role */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -145,24 +149,23 @@ class Role @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Role = - apply { - if (validated) { - return@apply - } - - id() - name() - created() - deletedAt() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgId() - userId() - validated = true + fun validate(): Role = apply { + if (validated) { + return@apply } + id() + name() + created() + deletedAt() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgId() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -171,14 +174,12 @@ class Role @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [Role]. * * The following fields are required: - * * ```java * .id() * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Role]. */ @@ -196,37 +197,30 @@ class Role @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(role: Role) = - apply { - id = role.id - name = role.name - created = role.created - deletedAt = role.deletedAt - description = role.description - memberPermissions = role.memberPermissions.map { it.toMutableList() } - memberRoles = role.memberRoles.map { it.toMutableList() } - orgId = role.orgId - userId = role.userId - additionalProperties = role.additionalProperties.toMutableMap() - } + internal fun from(role: Role) = apply { + id = role.id + name = role.name + created = role.created + deletedAt = role.deletedAt + description = role.description + memberPermissions = role.memberPermissions.map { it.toMutableList() } + memberRoles = role.memberRoles.map { it.toMutableList() } + orgId = role.orgId + userId = role.userId + additionalProperties = role.additionalProperties.toMutableMap() + } /** Unique identifier for the role */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the role */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Date of role creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -235,10 +229,7 @@ class Role @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of role creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -247,10 +238,7 @@ class Role @JsonCreator private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -259,76 +247,73 @@ class Role @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = + memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = - apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = - apply { - memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = apply { + memberPermissions = + (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = - apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun addMemberRole(memberRole: String) = - apply { - memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = apply { + memberRoles = + (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by + * any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -337,8 +322,8 @@ class Role @JsonCreator private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by + * any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ @@ -347,15 +332,12 @@ class Role @JsonCreator private constructor( /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and - * inherited by any other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and inherited by + * any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ - fun orgId(orgId: JsonField) = - apply { - this.orgId = orgId - } + fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Identifies the user who created the role */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -364,80 +346,71 @@ class Role @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the role */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Role = Role( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - created, - deletedAt, - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgId, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + created, + deletedAt, + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgId, + userId, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class MemberPermission @JsonCreator private constructor( - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class MemberPermission + @JsonCreator + private constructor( + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ @JsonProperty("permission") @ExcludeMissing @@ -454,17 +427,16 @@ class Role @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = - apply { - if (validated) { - return@apply - } - - permission() - restrictObjectType() - validated = true + fun validate(): MemberPermission = apply { + if (validated) { + return@apply } + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -473,13 +445,11 @@ class Role @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: - * * ```java * .permission() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -490,101 +460,87 @@ class Role @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = - apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = - apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired( - "permission", permission - ), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired("permission", permission), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -623,11 +579,9 @@ class Role @JsonCreator private constructor( * 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 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 { @@ -650,8 +604,8 @@ class Role @JsonCreator private constructor( * 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. + * 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) { @@ -673,7 +627,7 @@ class Role @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -694,17 +648,20 @@ class Role @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -713,21 +670,19 @@ class Role @JsonCreator private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -777,11 +732,9 @@ class Role @JsonCreator private constructor( * * 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 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 { @@ -807,8 +760,8 @@ class Role @JsonCreator private constructor( * 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. + * 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) { @@ -833,7 +786,7 @@ class Role @JsonCreator private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -848,7 +801,8 @@ class Role @JsonCreator private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -857,17 +811,20 @@ class Role @JsonCreator private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -876,11 +833,11 @@ class Role @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -889,15 +846,16 @@ class Role @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Role && id == other.id && name == other.name && created == other.created && deletedAt == other.deletedAt && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Role && id == other.id && name == other.name && created == other.created && deletedAt == other.deletedAt && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgId == other.orgId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -906,5 +864,6 @@ class Role @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Role{id=$id, name=$name, created=$created, deletedAt=$deletedAt, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "Role{id=$id, name=$name, created=$created, deletedAt=$deletedAt, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgId=$orgId, userId=$userId, additionalProperties=$additionalProperties}" } 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 8125aad3..9e08f6e4 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 @@ -25,14 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new role. If there is an existing role with the same name as the one - * specified in the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one specified in the + * request, will return the existing role unmodified */ -class RoleCreateParams private constructor( +class RoleCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the role */ @@ -47,15 +47,15 @@ class RoleCreateParams private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions */ fun memberRoles(): Optional> = body.memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. */ fun orgName(): Optional = body.orgName() @@ -71,15 +71,15 @@ class RoleCreateParams private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions */ fun _memberRoles(): JsonField> = body._memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -89,52 +89,64 @@ class RoleCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") + @ExcludeMissing + private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") + @ExcludeMissing + private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the role */ fun name(): String = name.getRequired("name") /** Textual description of the role */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = + Optional.ofNullable(memberRoles.getNullable("member_roles")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the role */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Textual description of the role */ @JsonProperty("description") @@ -149,21 +161,19 @@ class RoleCreateParams private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -171,20 +181,19 @@ class RoleCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgName() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -193,13 +202,11 @@ class RoleCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -213,24 +220,20 @@ class RoleCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - description = body.description - memberPermissions = body.memberPermissions.map { it.toMutableList() } - memberRoles = body.memberRoles.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + description = body.description + memberPermissions = body.memberPermissions.map { it.toMutableList() } + memberRoles = body.memberRoles.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -239,140 +242,129 @@ class RoleCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = + memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = - apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = - apply { - memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = apply { + memberPermissions = + (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) + fun memberRoles(memberRoles: List?) = + memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) + fun memberRoles(memberRoles: Optional>) = + memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = - apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ - fun addMemberRole(memberRole: String) = - apply { - memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = apply { + memberRoles = + (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired("name", name), + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -381,7 +373,8 @@ class RoleCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -392,13 +385,11 @@ class RoleCreateParams private constructor( * Returns a mutable builder for constructing an instance of [RoleCreateParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RoleCreateParams]. */ @@ -410,312 +401,251 @@ class RoleCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleCreateParams: RoleCreateParams) = - apply { - body = roleCreateParams.body.toBuilder() - additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(roleCreateParams: RoleCreateParams) = apply { + body = roleCreateParams.body.toBuilder() + additionalHeaders = roleCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleCreateParams.additionalQueryParams.toBuilder() + } /** Name of the role */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the role */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the role */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = - apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: List?) = apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = - apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: JsonField>) = apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = - apply { - body.addMemberPermission(memberPermission) - } + fun addMemberPermission(memberPermission: MemberPermission) = apply { + body.addMemberPermission(memberPermission) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun memberRoles(memberRoles: List?) = - apply { - body.memberRoles(memberRoles) - } + fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = - apply { - body.memberRoles(memberRoles) - } + fun memberRoles(memberRoles: JsonField>) = apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun addMemberRole(memberRole: String) = - apply { - body.addMemberRole(memberRole) - } + fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleCreateParams = - RoleCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + RoleCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } @NoAutoDetect - class MemberPermission @JsonCreator private constructor( - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class MemberPermission + @JsonCreator + private constructor( + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ @JsonProperty("permission") @ExcludeMissing @@ -732,17 +662,16 @@ class RoleCreateParams private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = - apply { - if (validated) { - return@apply - } - - permission() - restrictObjectType() - validated = true + fun validate(): MemberPermission = apply { + if (validated) { + return@apply } + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -751,13 +680,11 @@ class RoleCreateParams private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: - * * ```java * .permission() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -768,101 +695,87 @@ class RoleCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = - apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = - apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired( - "permission", permission - ), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired("permission", permission), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -901,11 +814,9 @@ class RoleCreateParams private constructor( * 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 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 { @@ -928,8 +839,8 @@ class RoleCreateParams private constructor( * 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. + * 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) { @@ -951,7 +862,7 @@ class RoleCreateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -972,17 +883,20 @@ class RoleCreateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -991,21 +905,19 @@ class RoleCreateParams private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1055,11 +967,9 @@ class RoleCreateParams private constructor( * * 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 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 { @@ -1085,8 +995,8 @@ class RoleCreateParams private constructor( * 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. + * 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) { @@ -1111,7 +1021,7 @@ class RoleCreateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1126,7 +1036,8 @@ class RoleCreateParams private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1135,17 +1046,20 @@ class RoleCreateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1154,11 +1068,11 @@ class RoleCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1167,18 +1081,20 @@ class RoleCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "RoleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "RoleCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 5e64142f..1eae7094 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a role object by its id */ -class RoleDeleteParams private constructor( +class RoleDeleteParams +private constructor( private val roleId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** Role id */ @@ -31,17 +31,18 @@ class RoleDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -52,13 +53,11 @@ class RoleDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [RoleDeleteParams]. * * The following fields are required: - * * ```java * .roleId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RoleDeleteParams]. */ @@ -71,190 +70,155 @@ class RoleDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(roleDeleteParams: RoleDeleteParams) = - apply { - roleId = roleDeleteParams.roleId - additionalHeaders = roleDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = roleDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = roleDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(roleDeleteParams: RoleDeleteParams) = apply { + roleId = roleDeleteParams.roleId + additionalHeaders = roleDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = roleDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = roleDeleteParams.additionalBodyProperties.toMutableMap() + } /** Role id */ - fun roleId(roleId: String) = - apply { - this.roleId = roleId - } + fun roleId(roleId: String) = apply { this.roleId = roleId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): RoleDeleteParams = RoleDeleteParams( - checkRequired( - "roleId", roleId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("roleId", roleId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is RoleDeleteParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "RoleDeleteParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index 12783198..f0957758 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.RoleService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created roles + * coming first */ -class RoleListPage private constructor( +class RoleListPage +private constructor( private val rolesService: RoleService, private val params: RoleListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,40 @@ class RoleListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListPage && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is RoleListPage && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ - override fun toString() = "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" + override fun toString() = + "RoleListPage{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(RoleListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(RoleListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { rolesService.list(it) } + return getNextPageParams().map { rolesService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +78,16 @@ class RoleListPage private constructor( @JvmStatic fun of(rolesService: RoleService, params: RoleListParams, response: Response) = - RoleListPage( - rolesService, - params, - response, - ) + RoleListPage(rolesService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +101,34 @@ class RoleListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [RoleListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +137,39 @@ class RoleListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: RoleListPage, + class AutoPager(private val firstPage: RoleListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index a227e991..baef96f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.RoleServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created roles + * coming first */ -class RoleListPageAsync private constructor( +class RoleListPageAsync +private constructor( private val rolesService: RoleServiceAsync, private val params: RoleListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,42 @@ class RoleListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListPageAsync && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is RoleListPageAsync && rolesService == other.rolesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(rolesService, params, response) /* spotless:on */ - override fun toString() = "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" + override fun toString() = + "RoleListPageAsync{rolesService=$rolesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(RoleListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(RoleListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - rolesService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { rolesService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -81,18 +80,16 @@ class RoleListPageAsync private constructor( @JvmStatic fun of(rolesService: RoleServiceAsync, params: RoleListParams, response: Response) = - RoleListPageAsync( - rolesService, - params, - response, - ) + RoleListPageAsync(rolesService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,35 +103,34 @@ class RoleListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [RoleListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -143,63 +139,46 @@ class RoleListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: RoleListPageAsync, - - ) { + class AutoPager(private val firstPage: RoleListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (Role) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (Role) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 870fb484..df21940e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created roles + * coming first */ -class RoleListParams private constructor( +class RoleListParams +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -35,21 +36,20 @@ class RoleListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ class RoleListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,51 +78,25 @@ class RoleListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.roleName?.let { - queryParams.put( - "role_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.roleName?.let { queryParams.put("role_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): RoleListParams = builder().build() + @JvmStatic fun none(): RoleListParams = builder().build() /** Returns a mutable builder for constructing an instance of [RoleListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RoleListParams]. */ @@ -139,71 +113,61 @@ class RoleListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleListParams: RoleListParams) = - apply { - endingBefore = roleListParams.endingBefore - ids = roleListParams.ids - limit = roleListParams.limit - orgName = roleListParams.orgName - roleName = roleListParams.roleName - startingAfter = roleListParams.startingAfter - additionalHeaders = roleListParams.additionalHeaders.toBuilder() - additionalQueryParams = roleListParams.additionalQueryParams.toBuilder() - } + internal fun from(roleListParams: RoleListParams) = apply { + endingBefore = roleListParams.endingBefore + ids = roleListParams.ids + limit = roleListParams.limit + orgName = roleListParams.orgName + roleName = roleListParams.roleName + startingAfter = roleListParams.startingAfter + additionalHeaders = roleListParams.additionalHeaders.toBuilder() + additionalQueryParams = roleListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -212,19 +176,13 @@ class RoleListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the role to search for */ - fun roleName(roleName: String?) = - apply { - this.roleName = roleName - } + fun roleName(roleName: String?) = apply { this.roleName = roleName } /** Name of the role to search for */ fun roleName(roleName: Optional) = roleName(roleName.getOrNull()) @@ -232,172 +190,144 @@ class RoleListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleListParams = RoleListParams( - endingBefore, - ids, - limit, - orgName, - roleName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + roleName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -415,19 +345,19 @@ class RoleListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -442,17 +372,12 @@ class RoleListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -462,56 +387,60 @@ class RoleListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && roleName == other.roleName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, roleName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 004b08b7..8b9e78ad 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 @@ -25,15 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace role. If there is an existing role with the same name as the - * one specified in the request, will replace the existing role with the provided - * fields + * Create or replace role. If there is an existing role with the same name as the one specified in + * the request, will replace the existing role with the provided fields */ -class RoleReplaceParams private constructor( +class RoleReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the role */ @@ -48,15 +47,15 @@ class RoleReplaceParams private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions */ fun memberRoles(): Optional> = body.memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. */ fun orgName(): Optional = body.orgName() @@ -72,15 +71,15 @@ class RoleReplaceParams private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all of + * their inherited permissions */ fun _memberRoles(): JsonField> = body._memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that your + * API key belongs to multiple organizations, you may specify the name of the organization the + * role belongs in. */ fun _orgName(): JsonField = body._orgName() @@ -90,52 +89,64 @@ class RoleReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("member_permissions") @ExcludeMissing private val memberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("member_roles") @ExcludeMissing private val memberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("org_name") @ExcludeMissing private val orgName: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("member_permissions") + @ExcludeMissing + private val memberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("member_roles") + @ExcludeMissing + private val memberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("org_name") + @ExcludeMissing + private val orgName: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the role */ fun name(): String = name.getRequired("name") /** Textual description of the role */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) + fun memberPermissions(): Optional> = + Optional.ofNullable(memberPermissions.getNullable("member_permissions")) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) + fun memberRoles(): Optional> = + Optional.ofNullable(memberRoles.getNullable("member_roles")) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** Name of the role */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Textual description of the role */ @JsonProperty("description") @@ -150,21 +161,19 @@ class RoleReplaceParams private constructor( /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - @JsonProperty("org_name") - @ExcludeMissing - fun _orgName(): JsonField = orgName + @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @JsonAnyGetter @ExcludeMissing @@ -172,20 +181,19 @@ class RoleReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - description() - memberPermissions().ifPresent { it.forEach { it.validate() } } - memberRoles() - orgName() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + description() + memberPermissions().ifPresent { it.forEach { it.validate() } } + memberRoles() + orgName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -194,13 +202,11 @@ class RoleReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -214,24 +220,20 @@ class RoleReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - description = body.description - memberPermissions = body.memberPermissions.map { it.toMutableList() } - memberRoles = body.memberRoles.map { it.toMutableList() } - orgName = body.orgName - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + description = body.description + memberPermissions = body.memberPermissions.map { it.toMutableList() } + memberRoles = body.memberRoles.map { it.toMutableList() } + orgName = body.orgName + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) /** Name of the role */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -240,140 +242,129 @@ class RoleReplaceParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) + fun memberPermissions(memberPermissions: List?) = + memberPermissions(JsonField.ofNullable(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = - apply { - this.memberPermissions = memberPermissions.map { it.toMutableList() } - } + fun memberPermissions(memberPermissions: JsonField>) = apply { + this.memberPermissions = memberPermissions.map { it.toMutableList() } + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = - apply { - memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { + fun addMemberPermission(memberPermission: MemberPermission) = apply { + memberPermissions = + (memberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("memberPermissions", it).add(memberPermission) } - } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ - fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) + fun memberRoles(memberRoles: List?) = + memberRoles(JsonField.ofNullable(memberRoles)) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ - fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) + fun memberRoles(memberRoles: Optional>) = + memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = - apply { - this.memberRoles = memberRoles.map { it.toMutableList() } - } + fun memberRoles(memberRoles: JsonField>) = apply { + this.memberRoles = memberRoles.map { it.toMutableList() } + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as + * all of their inherited permissions */ - fun addMemberRole(memberRole: String) = - apply { - memberRoles = (memberRoles ?: JsonField.of(mutableListOf())).also { + fun addMemberRole(memberRole: String) = apply { + memberRoles = + (memberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("memberRoles", it).add(memberRole) } - } + } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - fun orgName(orgName: JsonField) = - apply { - this.orgName = orgName - } + fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - description, - (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - orgName, - additionalProperties.toImmutable(), + checkRequired("name", name), + description, + (memberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (memberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + orgName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && description == other.description && memberPermissions == other.memberPermissions && memberRoles == other.memberRoles && orgName == other.orgName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -382,7 +373,8 @@ class RoleReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -393,13 +385,11 @@ class RoleReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [RoleReplaceParams]. * * The following fields are required: - * * ```java * .name() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RoleReplaceParams]. */ @@ -411,312 +401,255 @@ class RoleReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleReplaceParams: RoleReplaceParams) = - apply { - body = roleReplaceParams.body.toBuilder() - additionalHeaders = roleReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = roleReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(roleReplaceParams: RoleReplaceParams) = apply { + body = roleReplaceParams.body.toBuilder() + additionalHeaders = roleReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = roleReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the role */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the role */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the role */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List?) = - apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: List?) = apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) + fun memberPermissions(memberPermissions: Optional>) = + memberPermissions(memberPermissions.getOrNull()) /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: JsonField>) = - apply { - body.memberPermissions(memberPermissions) - } + fun memberPermissions(memberPermissions: JsonField>) = apply { + body.memberPermissions(memberPermissions) + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun addMemberPermission(memberPermission: MemberPermission) = - apply { - body.addMemberPermission(memberPermission) - } + fun addMemberPermission(memberPermission: MemberPermission) = apply { + body.addMemberPermission(memberPermission) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun memberRoles(memberRoles: List?) = - apply { - body.memberRoles(memberRoles) - } + fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun memberRoles(memberRoles: JsonField>) = - apply { - body.memberRoles(memberRoles) - } + fun memberRoles(memberRoles: JsonField>) = apply { + body.memberRoles(memberRoles) + } /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as - * well as all of their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as well as all + * of their inherited permissions */ - fun addMemberRole(memberRole: String) = - apply { - body.addMemberRole(memberRole) - } + fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - fun orgName(orgName: String?) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: String?) = apply { body.orgName(orgName) } /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case - * that your API key belongs to multiple organizations, you may specify the name of - * the organization the role belongs in. + * For nearly all users, this parameter should be unnecessary. But in the rare case that + * your API key belongs to multiple organizations, you may specify the name of the + * organization the role belongs in. */ - fun orgName(orgName: JsonField) = - apply { - body.orgName(orgName) - } + fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleReplaceParams = RoleReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class MemberPermission @JsonCreator private constructor( - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class MemberPermission + @JsonCreator + private constructor( + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ @JsonProperty("permission") @ExcludeMissing @@ -733,17 +666,16 @@ class RoleReplaceParams private constructor( private var validated: Boolean = false - fun validate(): MemberPermission = - apply { - if (validated) { - return@apply - } - - permission() - restrictObjectType() - validated = true + fun validate(): MemberPermission = apply { + if (validated) { + return@apply } + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -752,13 +684,11 @@ class RoleReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [MemberPermission]. * * The following fields are required: - * * ```java * .permission() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [MemberPermission]. */ @@ -769,101 +699,87 @@ class RoleReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(memberPermission: MemberPermission) = - apply { - permission = memberPermission.permission - restrictObjectType = memberPermission.restrictObjectType - additionalProperties = memberPermission.additionalProperties.toMutableMap() - } + internal fun from(memberPermission: MemberPermission) = apply { + permission = memberPermission.permission + restrictObjectType = memberPermission.restrictObjectType + additionalProperties = memberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = - apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): MemberPermission = MemberPermission( - checkRequired( - "permission", permission - ), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired("permission", permission), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -902,11 +818,9 @@ class RoleReplaceParams private constructor( * 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 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 { @@ -929,8 +843,8 @@ class RoleReplaceParams private constructor( * 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. + * 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) { @@ -952,7 +866,7 @@ class RoleReplaceParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -973,17 +887,20 @@ class RoleReplaceParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -992,21 +909,19 @@ class RoleReplaceParams private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1056,11 +971,9 @@ class RoleReplaceParams private constructor( * * 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 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 { @@ -1086,8 +999,8 @@ class RoleReplaceParams private constructor( * 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. + * 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) { @@ -1112,7 +1025,7 @@ class RoleReplaceParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1127,7 +1040,8 @@ class RoleReplaceParams private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1136,17 +1050,20 @@ class RoleReplaceParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1155,11 +1072,11 @@ class RoleReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1168,18 +1085,20 @@ class RoleReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "RoleReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "RoleReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 1bb0b88f..70a23fdd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a role object by its id */ -class RoleRetrieveParams private constructor( +class RoleRetrieveParams +private constructor( private val roleId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Role id */ @@ -29,10 +29,10 @@ class RoleRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,13 +43,11 @@ class RoleRetrieveParams private constructor( * Returns a mutable builder for constructing an instance of [RoleRetrieveParams]. * * The following fields are required: - * * ```java * .roleId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RoleRetrieveParams]. */ @@ -61,162 +59,131 @@ class RoleRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleRetrieveParams: RoleRetrieveParams) = - apply { - roleId = roleRetrieveParams.roleId - additionalHeaders = roleRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = roleRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(roleRetrieveParams: RoleRetrieveParams) = apply { + roleId = roleRetrieveParams.roleId + additionalHeaders = roleRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = roleRetrieveParams.additionalQueryParams.toBuilder() + } /** Role id */ - fun roleId(roleId: String) = - apply { - this.roleId = roleId - } + fun roleId(roleId: String) = apply { this.roleId = roleId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleRetrieveParams = RoleRetrieveParams( - checkRequired( - "roleId", roleId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("roleId", roleId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleRetrieveParams && roleId == other.roleId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "RoleRetrieveParams{roleId=$roleId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 b6b26ea8..ac99a23e 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 @@ -25,16 +25,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a role object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. */ -class RoleUpdateParams private constructor( +class RoleUpdateParams +private constructor( private val roleId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Role id */ @@ -53,7 +53,8 @@ class RoleUpdateParams private constructor( fun name(): Optional = body.name() /** A list of permissions to remove from the role */ - fun removeMemberPermissions(): Optional> = body.removeMemberPermissions() + fun removeMemberPermissions(): Optional> = + body.removeMemberPermissions() /** A list of role IDs to remove from the role's inheriting-from set */ fun removeMemberRoles(): Optional> = body.removeMemberRoles() @@ -71,7 +72,8 @@ class RoleUpdateParams private constructor( fun _name(): JsonField = body._name() /** A list of permissions to remove from the role */ - fun _removeMemberPermissions(): JsonField> = body._removeMemberPermissions() + fun _removeMemberPermissions(): JsonField> = + body._removeMemberPermissions() /** A list of role IDs to remove from the role's inheriting-from set */ fun _removeMemberRoles(): JsonField> = body._removeMemberRoles() @@ -82,49 +84,68 @@ class RoleUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("add_member_permissions") @ExcludeMissing private val addMemberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("add_member_roles") @ExcludeMissing private val addMemberRoles: JsonField> = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("remove_member_permissions") @ExcludeMissing private val removeMemberPermissions: JsonField> = JsonMissing.of(), - @JsonProperty("remove_member_roles") @ExcludeMissing private val removeMemberRoles: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("add_member_permissions") + @ExcludeMissing + private val addMemberPermissions: JsonField> = JsonMissing.of(), + @JsonProperty("add_member_roles") + @ExcludeMissing + private val addMemberRoles: JsonField> = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("remove_member_permissions") + @ExcludeMissing + private val removeMemberPermissions: JsonField> = + JsonMissing.of(), + @JsonProperty("remove_member_roles") + @ExcludeMissing + private val removeMemberRoles: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of permissions to add to the role */ - fun addMemberPermissions(): Optional> = Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) + fun addMemberPermissions(): Optional> = + Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(): Optional> = Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) + fun addMemberRoles(): Optional> = + Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) /** Textual description of the role */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** Name of the role */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** A list of permissions to remove from the role */ - fun removeMemberPermissions(): Optional> = Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) + fun removeMemberPermissions(): Optional> = + Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(): Optional> = Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) + fun removeMemberRoles(): Optional> = + Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) /** A list of permissions to add to the role */ @JsonProperty("add_member_permissions") @@ -142,14 +163,13 @@ class RoleUpdateParams private constructor( fun _description(): JsonField = description /** Name of the role */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** A list of permissions to remove from the role */ @JsonProperty("remove_member_permissions") @ExcludeMissing - fun _removeMemberPermissions(): JsonField> = removeMemberPermissions + fun _removeMemberPermissions(): JsonField> = + removeMemberPermissions /** A list of role IDs to remove from the role's inheriting-from set */ @JsonProperty("remove_member_roles") @@ -162,28 +182,26 @@ class RoleUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - addMemberPermissions().ifPresent { it.forEach { it.validate() } } - addMemberRoles() - description() - name() - removeMemberPermissions().ifPresent { it.forEach { it.validate() } } - removeMemberRoles() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + addMemberPermissions().ifPresent { it.forEach { it.validate() } } + addMemberRoles() + description() + name() + removeMemberPermissions().ifPresent { it.forEach { it.validate() } } + removeMemberRoles() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -193,27 +211,29 @@ class RoleUpdateParams private constructor( private var addMemberRoles: JsonField>? = null private var description: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var removeMemberPermissions: JsonField>? = null + private var removeMemberPermissions: JsonField>? = + null private var removeMemberRoles: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - addMemberPermissions = body.addMemberPermissions.map { it.toMutableList() } - addMemberRoles = body.addMemberRoles.map { it.toMutableList() } - description = body.description - name = body.name - removeMemberPermissions = body.removeMemberPermissions.map { it.toMutableList() } - removeMemberRoles = body.removeMemberRoles.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + addMemberPermissions = body.addMemberPermissions.map { it.toMutableList() } + addMemberRoles = body.addMemberRoles.map { it.toMutableList() } + description = body.description + name = body.name + removeMemberPermissions = body.removeMemberPermissions.map { it.toMutableList() } + removeMemberRoles = body.removeMemberRoles.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: List?) = addMemberPermissions(JsonField.ofNullable(addMemberPermissions)) + fun addMemberPermissions(addMemberPermissions: List?) = + addMemberPermissions(JsonField.ofNullable(addMemberPermissions)) /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: Optional>) = addMemberPermissions(addMemberPermissions.getOrNull()) + fun addMemberPermissions(addMemberPermissions: Optional>) = + addMemberPermissions(addMemberPermissions.getOrNull()) /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: JsonField>) = @@ -222,32 +242,33 @@ class RoleUpdateParams private constructor( } /** A list of permissions to add to the role */ - fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = - apply { - addMemberPermissions = (addMemberPermissions ?: JsonField.of(mutableListOf())).also { + fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { + addMemberPermissions = + (addMemberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberPermissions", it).add(addMemberPermission) } - } + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: List?) = addMemberRoles(JsonField.ofNullable(addMemberRoles)) + fun addMemberRoles(addMemberRoles: List?) = + addMemberRoles(JsonField.ofNullable(addMemberRoles)) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: Optional>) = addMemberRoles(addMemberRoles.getOrNull()) + fun addMemberRoles(addMemberRoles: Optional>) = + addMemberRoles(addMemberRoles.getOrNull()) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: JsonField>) = - apply { - this.addMemberRoles = addMemberRoles.map { it.toMutableList() } - } + fun addMemberRoles(addMemberRoles: JsonField>) = apply { + this.addMemberRoles = addMemberRoles.map { it.toMutableList() } + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addAddMemberRole(addMemberRole: String) = - apply { - addMemberRoles = (addMemberRoles ?: JsonField.of(mutableListOf())).also { + fun addAddMemberRole(addMemberRole: String) = apply { + addMemberRoles = + (addMemberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("addMemberRoles", it).add(addMemberRole) } - } + } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -256,10 +277,9 @@ class RoleUpdateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** Name of the role */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -268,95 +288,90 @@ class RoleUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the role */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: List?) = removeMemberPermissions(JsonField.ofNullable(removeMemberPermissions)) + fun removeMemberPermissions(removeMemberPermissions: List?) = + removeMemberPermissions(JsonField.ofNullable(removeMemberPermissions)) /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: Optional>) = removeMemberPermissions(removeMemberPermissions.getOrNull()) + fun removeMemberPermissions( + removeMemberPermissions: Optional> + ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: JsonField>) = - apply { - this.removeMemberPermissions = removeMemberPermissions.map { it.toMutableList() } - } + fun removeMemberPermissions( + removeMemberPermissions: JsonField> + ) = apply { + this.removeMemberPermissions = removeMemberPermissions.map { it.toMutableList() } + } /** A list of permissions to remove from the role */ - fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = - apply { - removeMemberPermissions = (removeMemberPermissions ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { + removeMemberPermissions = + (removeMemberPermissions ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberPermissions", it).add(removeMemberPermission) } - } + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: List?) = removeMemberRoles(JsonField.ofNullable(removeMemberRoles)) + fun removeMemberRoles(removeMemberRoles: List?) = + removeMemberRoles(JsonField.ofNullable(removeMemberRoles)) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: Optional>) = removeMemberRoles(removeMemberRoles.getOrNull()) + fun removeMemberRoles(removeMemberRoles: Optional>) = + removeMemberRoles(removeMemberRoles.getOrNull()) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: JsonField>) = - apply { - this.removeMemberRoles = removeMemberRoles.map { it.toMutableList() } - } + fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { + this.removeMemberRoles = removeMemberRoles.map { it.toMutableList() } + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun addRemoveMemberRole(removeMemberRole: String) = - apply { - removeMemberRoles = (removeMemberRoles ?: JsonField.of(mutableListOf())).also { + fun addRemoveMemberRole(removeMemberRole: String) = apply { + removeMemberRoles = + (removeMemberRoles ?: JsonField.of(mutableListOf())).also { checkKnown("removeMemberRoles", it).add(removeMemberRole) } - } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (addMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - description, - name, - (removeMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, - (removeMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (addMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + description, + name, + (removeMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, + (removeMemberRoles ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && addMemberPermissions == other.addMemberPermissions && addMemberRoles == other.addMemberRoles && description == other.description && name == other.name && removeMemberPermissions == other.removeMemberPermissions && removeMemberRoles == other.removeMemberRoles && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -365,7 +380,8 @@ class RoleUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -376,13 +392,11 @@ class RoleUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [RoleUpdateParams]. * * The following fields are required: - * * ```java * .roleId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RoleUpdateParams]. */ @@ -395,28 +409,24 @@ class RoleUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(roleUpdateParams: RoleUpdateParams) = - apply { - roleId = roleUpdateParams.roleId - body = roleUpdateParams.body.toBuilder() - additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(roleUpdateParams: RoleUpdateParams) = apply { + roleId = roleUpdateParams.roleId + body = roleUpdateParams.body.toBuilder() + additionalHeaders = roleUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = roleUpdateParams.additionalQueryParams.toBuilder() + } /** Role id */ - fun roleId(roleId: String) = - apply { - this.roleId = roleId - } + fun roleId(roleId: String) = apply { this.roleId = roleId } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: List?) = - apply { - body.addMemberPermissions(addMemberPermissions) - } + fun addMemberPermissions(addMemberPermissions: List?) = apply { + body.addMemberPermissions(addMemberPermissions) + } /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: Optional>) = addMemberPermissions(addMemberPermissions.getOrNull()) + fun addMemberPermissions(addMemberPermissions: Optional>) = + addMemberPermissions(addMemberPermissions.getOrNull()) /** A list of permissions to add to the role */ fun addMemberPermissions(addMemberPermissions: JsonField>) = @@ -425,61 +435,44 @@ class RoleUpdateParams private constructor( } /** A list of permissions to add to the role */ - fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = - apply { - body.addAddMemberPermission(addMemberPermission) - } + fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { + body.addAddMemberPermission(addMemberPermission) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: List?) = - apply { - body.addMemberRoles(addMemberRoles) - } + fun addMemberRoles(addMemberRoles: List?) = apply { + body.addMemberRoles(addMemberRoles) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: Optional>) = addMemberRoles(addMemberRoles.getOrNull()) + fun addMemberRoles(addMemberRoles: Optional>) = + addMemberRoles(addMemberRoles.getOrNull()) /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: JsonField>) = - apply { - body.addMemberRoles(addMemberRoles) - } + fun addMemberRoles(addMemberRoles: JsonField>) = apply { + body.addMemberRoles(addMemberRoles) + } /** A list of role IDs to add to the role's inheriting-from set */ - fun addAddMemberRole(addMemberRole: String) = - apply { - body.addAddMemberRole(addMemberRole) - } + fun addAddMemberRole(addMemberRole: String) = apply { body.addAddMemberRole(addMemberRole) } /** Textual description of the role */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the role */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the role */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** Name of the role */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the role */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the role */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** A list of permissions to remove from the role */ fun removeMemberPermissions(removeMemberPermissions: List?) = @@ -488,227 +481,194 @@ class RoleUpdateParams private constructor( } /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: Optional>) = removeMemberPermissions(removeMemberPermissions.getOrNull()) + fun removeMemberPermissions( + removeMemberPermissions: Optional> + ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: JsonField>) = - apply { - body.removeMemberPermissions(removeMemberPermissions) - } + fun removeMemberPermissions( + removeMemberPermissions: JsonField> + ) = apply { body.removeMemberPermissions(removeMemberPermissions) } /** A list of permissions to remove from the role */ - fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = - apply { - body.addRemoveMemberPermission(removeMemberPermission) - } + fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { + body.addRemoveMemberPermission(removeMemberPermission) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: List?) = - apply { - body.removeMemberRoles(removeMemberRoles) - } + fun removeMemberRoles(removeMemberRoles: List?) = apply { + body.removeMemberRoles(removeMemberRoles) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: Optional>) = removeMemberRoles(removeMemberRoles.getOrNull()) + fun removeMemberRoles(removeMemberRoles: Optional>) = + removeMemberRoles(removeMemberRoles.getOrNull()) /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: JsonField>) = - apply { - body.removeMemberRoles(removeMemberRoles) - } + fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { + body.removeMemberRoles(removeMemberRoles) + } /** A list of role IDs to remove from the role's inheriting-from set */ - fun addRemoveMemberRole(removeMemberRole: String) = - apply { - body.addRemoveMemberRole(removeMemberRole) - } + fun addRemoveMemberRole(removeMemberRole: String) = apply { + body.addRemoveMemberRole(removeMemberRole) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): RoleUpdateParams = RoleUpdateParams( - checkRequired( - "roleId", roleId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("roleId", roleId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } @NoAutoDetect - class AddMemberPermission @JsonCreator private constructor( - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class AddMemberPermission + @JsonCreator + private constructor( + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ @JsonProperty("permission") @ExcludeMissing @@ -725,17 +685,16 @@ class RoleUpdateParams private constructor( private var validated: Boolean = false - fun validate(): AddMemberPermission = - apply { - if (validated) { - return@apply - } - - permission() - restrictObjectType() - validated = true + fun validate(): AddMemberPermission = apply { + if (validated) { + return@apply } + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -744,13 +703,11 @@ class RoleUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [AddMemberPermission]. * * The following fields are required: - * * ```java * .permission() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [AddMemberPermission]. */ @@ -761,101 +718,87 @@ class RoleUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addMemberPermission: AddMemberPermission) = - apply { - permission = addMemberPermission.permission - restrictObjectType = addMemberPermission.restrictObjectType - additionalProperties = addMemberPermission.additionalProperties.toMutableMap() - } + internal fun from(addMemberPermission: AddMemberPermission) = apply { + permission = addMemberPermission.permission + restrictObjectType = addMemberPermission.restrictObjectType + additionalProperties = addMemberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = - apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): AddMemberPermission = AddMemberPermission( - checkRequired( - "permission", permission - ), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired("permission", permission), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -894,11 +837,9 @@ class RoleUpdateParams private constructor( * 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 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 { @@ -921,8 +862,8 @@ class RoleUpdateParams private constructor( * 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. + * 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) { @@ -944,7 +885,7 @@ class RoleUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -965,17 +906,20 @@ class RoleUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -984,21 +928,19 @@ class RoleUpdateParams private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1048,11 +990,9 @@ class RoleUpdateParams private constructor( * * 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 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 { @@ -1078,8 +1018,8 @@ class RoleUpdateParams private constructor( * 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. + * 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) { @@ -1104,7 +1044,7 @@ class RoleUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1119,7 +1059,8 @@ class RoleUpdateParams private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1128,17 +1069,20 @@ class RoleUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1147,11 +1091,11 @@ class RoleUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is AddMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1160,33 +1104,39 @@ class RoleUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } @NoAutoDetect - class RemoveMemberPermission @JsonCreator private constructor( - @JsonProperty("permission") @ExcludeMissing private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") @ExcludeMissing private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class RemoveMemberPermission + @JsonCreator + private constructor( + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ fun permission(): Permission = permission.getRequired("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + fun restrictObjectType(): Optional = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into roles */ @JsonProperty("permission") @ExcludeMissing @@ -1203,33 +1153,29 @@ class RoleUpdateParams private constructor( private var validated: Boolean = false - fun validate(): RemoveMemberPermission = - apply { - if (validated) { - return@apply - } - - permission() - restrictObjectType() - validated = true + fun validate(): RemoveMemberPermission = apply { + if (validated) { + return@apply } + permission() + restrictObjectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [RemoveMemberPermission]. + * Returns a mutable builder for constructing an instance of [RemoveMemberPermission]. * * The following fields are required: - * * ```java * .permission() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [RemoveMemberPermission]. */ @@ -1240,101 +1186,87 @@ class RoleUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(removeMemberPermission: RemoveMemberPermission) = - apply { - permission = removeMemberPermission.permission - restrictObjectType = removeMemberPermission.restrictObjectType - additionalProperties = removeMemberPermission.additionalProperties.toMutableMap() - } + internal fun from(removeMemberPermission: RemoveMemberPermission) = apply { + permission = removeMemberPermission.permission + restrictObjectType = removeMemberPermission.restrictObjectType + additionalProperties = removeMemberPermission.additionalProperties.toMutableMap() + } /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ fun permission(permission: Permission) = permission(JsonField.of(permission)) /** * 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 + * Permissions can be assigned to to objects on an individual basis, or grouped into + * roles */ - fun permission(permission: JsonField) = - apply { - this.permission = permission - } + fun permission(permission: JsonField) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType?) = + restrictObjectType(JsonField.ofNullable(restrictObjectType)) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) + fun restrictObjectType(restrictObjectType: Optional) = + restrictObjectType(restrictObjectType.getOrNull()) /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: JsonField) = - apply { - this.restrictObjectType = restrictObjectType - } + fun restrictObjectType(restrictObjectType: JsonField) = apply { + this.restrictObjectType = restrictObjectType + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): RemoveMemberPermission = RemoveMemberPermission( - checkRequired( - "permission", permission - ), - restrictObjectType, - additionalProperties.toImmutable(), + checkRequired("permission", permission), + restrictObjectType, + additionalProperties.toImmutable(), ) } /** * 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 + * 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1373,11 +1305,9 @@ class RoleUpdateParams private constructor( * 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 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 { @@ -1400,8 +1330,8 @@ class RoleUpdateParams private constructor( * 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. + * 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) { @@ -1423,7 +1353,7 @@ class RoleUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1444,17 +1374,20 @@ class RoleUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ + return /* spotless:off */ other is Permission && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1463,21 +1396,19 @@ class RoleUpdateParams private constructor( } /** The object type that the ACL applies to */ - class RestrictObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1527,11 +1458,9 @@ class RoleUpdateParams private constructor( * * 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 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 { @@ -1557,8 +1486,8 @@ class RoleUpdateParams private constructor( * 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. + * 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) { @@ -1583,7 +1512,7 @@ class RoleUpdateParams private constructor( * don't want to throw for the unknown case. * * @throws BraintrustInvalidDataException if this class instance's value is a not a - * known member. + * known member. */ fun known(): Known = when (this) { @@ -1598,7 +1527,8 @@ class RoleUpdateParams private constructor( ORG_MEMBER -> Known.ORG_MEMBER PROJECT_LOG -> Known.PROJECT_LOG ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + else -> + throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") } /** @@ -1607,17 +1537,20 @@ class RoleUpdateParams private constructor( * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is RestrictObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1626,11 +1559,11 @@ class RoleUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RemoveMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is RemoveMemberPermission && permission == other.permission && restrictObjectType == other.restrictObjectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1639,18 +1572,20 @@ class RoleUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = + "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is RoleUpdateParams && roleId == other.roleId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(roleId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "RoleUpdateParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "RoleUpdateParams{roleId=$roleId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index 6d82da0b..ff05be5e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -19,14 +19,19 @@ import java.util.Optional /** Summary of a score's performance */ @NoAutoDetect -class ScoreSummary @JsonCreator private constructor( - @JsonProperty("improvements") @ExcludeMissing private val improvements: JsonField = JsonMissing.of(), +class ScoreSummary +@JsonCreator +private constructor( + @JsonProperty("improvements") + @ExcludeMissing + private val improvements: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("regressions") @ExcludeMissing private val regressions: JsonField = JsonMissing.of(), + @JsonProperty("regressions") + @ExcludeMissing + private val regressions: JsonField = JsonMissing.of(), @JsonProperty("score") @ExcludeMissing private val score: JsonField = JsonMissing.of(), @JsonProperty("diff") @ExcludeMissing private val diff: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Number of improvements in the score */ @@ -50,24 +55,16 @@ class ScoreSummary @JsonCreator private constructor( fun _improvements(): JsonField = improvements /** Name of the score */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Number of regressions in the score */ - @JsonProperty("regressions") - @ExcludeMissing - fun _regressions(): JsonField = regressions + @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions /** Average score across all examples */ - @JsonProperty("score") - @ExcludeMissing - fun _score(): JsonField = score + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField = score /** Difference in score between the current and comparison experiment */ - @JsonProperty("diff") - @ExcludeMissing - fun _diff(): JsonField = diff + @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff @JsonAnyGetter @ExcludeMissing @@ -75,20 +72,19 @@ class ScoreSummary @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ScoreSummary = - apply { - if (validated) { - return@apply - } - - improvements() - name() - regressions() - score() - diff() - validated = true + fun validate(): ScoreSummary = apply { + if (validated) { + return@apply } + improvements() + name() + regressions() + score() + diff() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,7 +93,6 @@ class ScoreSummary @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [ScoreSummary]. * * The following fields are required: - * * ```java * .improvements() * .name() @@ -105,8 +100,7 @@ class ScoreSummary @JsonCreator private constructor( * .score() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ScoreSummary]. */ @@ -120,112 +114,81 @@ class ScoreSummary @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scoreSummary: ScoreSummary) = - apply { - improvements = scoreSummary.improvements - name = scoreSummary.name - regressions = scoreSummary.regressions - score = scoreSummary.score - diff = scoreSummary.diff - additionalProperties = scoreSummary.additionalProperties.toMutableMap() - } + internal fun from(scoreSummary: ScoreSummary) = apply { + improvements = scoreSummary.improvements + name = scoreSummary.name + regressions = scoreSummary.regressions + score = scoreSummary.score + diff = scoreSummary.diff + additionalProperties = scoreSummary.additionalProperties.toMutableMap() + } /** Number of improvements in the score */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) /** Number of improvements in the score */ - fun improvements(improvements: JsonField) = - apply { - this.improvements = improvements - } + fun improvements(improvements: JsonField) = apply { this.improvements = improvements } /** Name of the score */ fun name(name: String) = name(JsonField.of(name)) /** Name of the score */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Number of regressions in the score */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) /** Number of regressions in the score */ - fun regressions(regressions: JsonField) = - apply { - this.regressions = regressions - } + fun regressions(regressions: JsonField) = apply { this.regressions = regressions } /** Average score across all examples */ fun score(score: Double) = score(JsonField.of(score)) /** Average score across all examples */ - fun score(score: JsonField) = - apply { - this.score = score - } + fun score(score: JsonField) = apply { this.score = score } /** Difference in score between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) /** Difference in score between the current and comparison experiment */ - fun diff(diff: JsonField) = - apply { - this.diff = diff - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun diff(diff: JsonField) = apply { this.diff = diff } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ScoreSummary = ScoreSummary( - checkRequired( - "improvements", improvements - ), - checkRequired( - "name", name - ), - checkRequired( - "regressions", regressions - ), - checkRequired( - "score", score - ), - diff, - additionalProperties.toImmutable(), + checkRequired("improvements", improvements), + checkRequired("name", name), + checkRequired("regressions", regressions), + checkRequired("score", score), + diff, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ScoreSummary && improvements == other.improvements && name == other.name && regressions == other.regressions && score == other.score && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScoreSummary && improvements == other.improvements && name == other.name && regressions == other.regressions && score == other.score && diff == other.diff && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -234,5 +197,6 @@ class ScoreSummary @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ScoreSummary{improvements=$improvements, name=$name, regressions=$regressions, score=$score, diff=$diff, additionalProperties=$additionalProperties}" + override fun toString() = + "ScoreSummary{improvements=$improvements, name=$name, regressions=$regressions, score=$score, diff=$diff, additionalProperties=$additionalProperties}" } 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 25ebb526..c7177997 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 @@ -21,11 +21,12 @@ import kotlin.jvm.optionals.getOrNull /** Human-identifying attributes of the span, such as name, type, etc. */ @NoAutoDetect -class SpanAttributes @JsonCreator private constructor( +class SpanAttributes +@JsonCreator +private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Name of the span, for display purposes only */ @@ -35,14 +36,10 @@ class SpanAttributes @JsonCreator private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @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 @@ -50,24 +47,22 @@ class SpanAttributes @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): SpanAttributes = - apply { - if (validated) { - return@apply - } - - name() - type() - validated = true + fun validate(): SpanAttributes = apply { + if (validated) { + return@apply } + name() + type() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [SpanAttributes]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SpanAttributes]. */ @@ -78,12 +73,11 @@ class SpanAttributes @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanAttributes: SpanAttributes) = - apply { - name = spanAttributes.name - type = spanAttributes.type - additionalProperties = spanAttributes.additionalProperties.toMutableMap() - } + internal fun from(spanAttributes: SpanAttributes) = apply { + name = spanAttributes.name + type = spanAttributes.type + additionalProperties = spanAttributes.additionalProperties.toMutableMap() + } /** Name of the span, for display purposes only */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -92,10 +86,7 @@ class SpanAttributes @JsonCreator private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the span, for display purposes only */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: Type?) = type(JsonField.ofNullable(type)) @@ -104,61 +95,42 @@ class SpanAttributes @JsonCreator private constructor( 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() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toImmutable(), - ) + 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -191,11 +163,9 @@ class SpanAttributes @JsonCreator private constructor( * 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 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 { @@ -210,11 +180,11 @@ class SpanAttributes @JsonCreator private constructor( } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * 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. + * 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) { @@ -230,11 +200,11 @@ class SpanAttributes @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -250,20 +220,23 @@ class SpanAttributes @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -272,11 +245,11 @@ class SpanAttributes @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanAttributes && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanAttributes && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -285,5 +258,6 @@ class SpanAttributes @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index 461560c8..ab9266fa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -20,18 +20,31 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class SpanIFrame @JsonCreator private constructor( +class SpanIFrame +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") + @ExcludeMissing + private val postMessage: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the span iframe */ @@ -50,44 +63,37 @@ class SpanIFrame @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of span iframe deletion, or null if the span iframe is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Textual description of the span iframe */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. */ - fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = + Optional.ofNullable(postMessage.getNullable("post_message")) /** Identifies the user who created the span iframe */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) /** Unique identifier for the span iframe */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the span iframe */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") - @ExcludeMissing - fun _url(): JsonField = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url /** Date of span iframe creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of span iframe deletion, or null if the span iframe is still active */ @JsonProperty("deleted_at") @@ -95,22 +101,18 @@ class SpanIFrame @JsonCreator private constructor( fun _deletedAt(): JsonField = deletedAt /** Textual description of the span iframe */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing fun _postMessage(): JsonField = postMessage /** Identifies the user who created the span iframe */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @ExcludeMissing @@ -118,24 +120,23 @@ class SpanIFrame @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): SpanIFrame = - apply { - if (validated) { - return@apply - } - - id() - name() - projectId() - url() - created() - deletedAt() - description() - postMessage() - userId() - validated = true + fun validate(): SpanIFrame = apply { + if (validated) { + return@apply } + id() + name() + projectId() + url() + created() + deletedAt() + description() + postMessage() + userId() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -144,7 +145,6 @@ class SpanIFrame @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [SpanIFrame]. * * The following fields are required: - * * ```java * .id() * .name() @@ -152,8 +152,7 @@ class SpanIFrame @JsonCreator private constructor( * .url() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SpanIFrame]. */ @@ -171,55 +170,42 @@ class SpanIFrame @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIFrame: SpanIFrame) = - apply { - id = spanIFrame.id - name = spanIFrame.name - projectId = spanIFrame.projectId - url = spanIFrame.url - created = spanIFrame.created - deletedAt = spanIFrame.deletedAt - description = spanIFrame.description - postMessage = spanIFrame.postMessage - userId = spanIFrame.userId - additionalProperties = spanIFrame.additionalProperties.toMutableMap() - } + internal fun from(spanIFrame: SpanIFrame) = apply { + id = spanIFrame.id + name = spanIFrame.name + projectId = spanIFrame.projectId + url = spanIFrame.url + created = spanIFrame.created + deletedAt = spanIFrame.deletedAt + description = spanIFrame.description + postMessage = spanIFrame.postMessage + userId = spanIFrame.userId + additionalProperties = spanIFrame.additionalProperties.toMutableMap() + } /** Unique identifier for the span iframe */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the span iframe */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = - apply { - this.url = url - } + fun url(url: JsonField) = apply { this.url = url } /** Date of span iframe creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -228,10 +214,7 @@ class SpanIFrame @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of span iframe creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date of span iframe deletion, or null if the span iframe is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -240,10 +223,7 @@ class SpanIFrame @JsonCreator private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of span iframe deletion, or null if the span iframe is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -252,37 +232,31 @@ class SpanIFrame @JsonCreator private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { this.description = description } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = - apply { - this.postMessage = postMessage - } + fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage } /** Identifies the user who created the span iframe */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -291,66 +265,48 @@ class SpanIFrame @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the span iframe */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SpanIFrame = SpanIFrame( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "url", url - ), - created, - deletedAt, - description, - postMessage, - userId, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("url", url), + created, + deletedAt, + description, + postMessage, + userId, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIFrame && id == other.id && name == other.name && projectId == other.projectId && url == other.url && created == other.created && deletedAt == other.deletedAt && description == other.description && postMessage == other.postMessage && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SpanIFrame && id == other.id && name == other.name && projectId == other.projectId && url == other.url && created == other.created && deletedAt == other.deletedAt && description == other.description && postMessage == other.postMessage && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -359,5 +315,6 @@ class SpanIFrame @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "SpanIFrame{id=$id, name=$name, projectId=$projectId, url=$url, created=$created, deletedAt=$deletedAt, description=$description, postMessage=$postMessage, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = + "SpanIFrame{id=$id, name=$name, projectId=$projectId, url=$url, created=$created, deletedAt=$deletedAt, description=$description, postMessage=$postMessage, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 29e104af..9f81c14e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -22,15 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new span_iframe. If there is an existing span_iframe with the same name - * as the one specified in the request, will return the existing span_iframe - * unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will return the existing span_iframe unmodified */ -class SpanIframeCreateParams private constructor( +class SpanIframeCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the span iframe */ @@ -46,8 +45,8 @@ class SpanIframeCreateParams private constructor( fun description(): Optional = body.description() /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -64,8 +63,8 @@ class SpanIframeCreateParams private constructor( fun _description(): JsonField = body._description() /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -75,22 +74,31 @@ class SpanIframeCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") + @ExcludeMissing + private val postMessage: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the span iframe */ @@ -103,28 +111,24 @@ class SpanIframeCreateParams private constructor( fun url(): String = url.getRequired("url") /** Textual description of the span iframe */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = + Optional.ofNullable(postMessage.getNullable("post_message")) /** Name of the span iframe */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") - @ExcludeMissing - fun _url(): JsonField = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url /** Textual description of the span iframe */ @JsonProperty("description") @@ -132,8 +136,8 @@ class SpanIframeCreateParams private constructor( fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing @@ -145,20 +149,19 @@ class SpanIframeCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - url() - description() - postMessage() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + url() + description() + postMessage() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -167,15 +170,13 @@ class SpanIframeCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -189,42 +190,32 @@ class SpanIframeCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - url = body.url - description = body.description - postMessage = body.postMessage - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + url = body.url + description = body.description + postMessage = body.postMessage + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = - apply { - this.url = url - } + fun url(url: JsonField) = apply { this.url = url } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -233,87 +224,72 @@ class SpanIframeCreateParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = - apply { - this.postMessage = postMessage - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun postMessage(postMessage: JsonField) = apply { + this.postMessage = postMessage + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "url", url - ), - description, - postMessage, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("url", url), + description, + postMessage, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -322,7 +298,8 @@ class SpanIframeCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -330,19 +307,16 @@ class SpanIframeCreateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [SpanIframeCreateParams]. + * Returns a mutable builder for constructing an instance of [SpanIframeCreateParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SpanIframeCreateParams]. */ @@ -354,262 +328,198 @@ class SpanIframeCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = - apply { - body = spanIframeCreateParams.body.toBuilder() - additionalHeaders = spanIframeCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeCreateParams: SpanIframeCreateParams) = apply { + body = spanIframeCreateParams.body.toBuilder() + additionalHeaders = spanIframeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeCreateParams.additionalQueryParams.toBuilder() + } /** Name of the span iframe */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the span iframe */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = - apply { - body.url(url) - } + fun url(url: String) = apply { body.url(url) } /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = - apply { - body.url(url) - } + fun url(url: JsonField) = apply { body.url(url) } /** Textual description of the span iframe */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the span iframe */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = - apply { - body.postMessage(postMessage) - } + fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = - apply { - body.postMessage(postMessage) - } + fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeCreateParams = SpanIframeCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "SpanIframeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "SpanIframeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt index a39365d1..ca88a657 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -13,12 +13,12 @@ import java.util.Objects import java.util.Optional /** Delete a span_iframe object by its id */ -class SpanIframeDeleteParams private constructor( +class SpanIframeDeleteParams +private constructor( private val spanIframeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, - ) : Params { /** SpanIframe id */ @@ -31,17 +31,18 @@ class SpanIframeDeleteParams private constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + internal fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -49,17 +50,14 @@ class SpanIframeDeleteParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [SpanIframeDeleteParams]. + * Returns a mutable builder for constructing an instance of [SpanIframeDeleteParams]. * * The following fields are required: - * * ```java * .spanIframeId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SpanIframeDeleteParams]. */ @@ -72,190 +70,156 @@ class SpanIframeDeleteParams private constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(spanIframeDeleteParams: SpanIframeDeleteParams) = - apply { - spanIframeId = spanIframeDeleteParams.spanIframeId - additionalHeaders = spanIframeDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = spanIframeDeleteParams.additionalBodyProperties.toMutableMap() - } + internal fun from(spanIframeDeleteParams: SpanIframeDeleteParams) = apply { + spanIframeId = spanIframeDeleteParams.spanIframeId + additionalHeaders = spanIframeDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + spanIframeDeleteParams.additionalBodyProperties.toMutableMap() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = - apply { - this.spanIframeId = spanIframeId - } + fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - additionalBodyProperties.put(key, value) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.putAll(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - additionalBodyProperties.remove(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalBodyProperty) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } fun build(): SpanIframeDeleteParams = SpanIframeDeleteParams( - checkRequired( - "spanIframeId", spanIframeId - ), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), + checkRequired("spanIframeId", spanIframeId), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is SpanIframeDeleteParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - override fun toString() = "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = + "SpanIframeDeleteParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index 2564c749..26329957 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.SpanIframeService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all span_iframes. The span_iframes are sorted by creation date, with - * the most recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first */ -class SpanIframeListPage private constructor( +class SpanIframeListPage +private constructor( private val spanIframesService: SpanIframeService, private val params: SpanIframeListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,46 @@ class SpanIframeListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListPage && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is SpanIframeListPage && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ - override fun toString() = "SpanIframeListPage{spanIframesService=$spanIframesService, params=$params, response=$response}" + override fun toString() = + "SpanIframeListPage{spanIframesService=$spanIframesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(SpanIframeListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(SpanIframeListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + SpanIframeListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + SpanIframeListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { spanIframesService.list(it) } + return getNextPageParams().map { spanIframesService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -73,19 +83,21 @@ class SpanIframeListPage private constructor( companion object { @JvmStatic - fun of(spanIframesService: SpanIframeService, params: SpanIframeListParams, response: Response) = - SpanIframeListPage( - spanIframesService, - params, - response, - ) + fun of( + spanIframesService: SpanIframeService, + params: SpanIframeListParams, + response: Response, + ) = SpanIframeListPage(spanIframesService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +111,34 @@ class SpanIframeListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [SpanIframeListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +147,39 @@ class SpanIframeListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: SpanIframeListPage, + class AutoPager(private val firstPage: SpanIframeListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt index bf9d1da6..b851e390 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.SpanIframeServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all span_iframes. The span_iframes are sorted by creation date, with - * the most recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first */ -class SpanIframeListPageAsync private constructor( +class SpanIframeListPageAsync +private constructor( private val spanIframesService: SpanIframeServiceAsync, private val params: SpanIframeListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,48 @@ class SpanIframeListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListPageAsync && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is SpanIframeListPageAsync && spanIframesService == other.spanIframesService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframesService, params, response) /* spotless:on */ - override fun toString() = "SpanIframeListPageAsync{spanIframesService=$spanIframesService, params=$params, response=$response}" + override fun toString() = + "SpanIframeListPageAsync{spanIframesService=$spanIframesService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(SpanIframeListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(SpanIframeListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + SpanIframeListParams.builder() + .from(params) + .endingBefore(objects().first().id()) + .build() + ) + } else { + Optional.of( + SpanIframeListParams.builder() + .from(params) + .startingAfter(objects().last().id()) + .build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - spanIframesService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { spanIframesService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -80,19 +85,21 @@ class SpanIframeListPageAsync private constructor( companion object { @JvmStatic - fun of(spanIframesService: SpanIframeServiceAsync, params: SpanIframeListParams, response: Response) = - SpanIframeListPageAsync( - spanIframesService, - params, - response, - ) + fun of( + spanIframesService: SpanIframeServiceAsync, + params: SpanIframeListParams, + response: Response, + ) = SpanIframeListPageAsync(spanIframesService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( - @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Response + @JsonCreator + constructor( + @JsonProperty("objects") + private val objects: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,38 +113,36 @@ class SpanIframeListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** - * Returns a mutable builder for constructing an instance of - * [SpanIframeListPageAsync]. + * Returns a mutable builder for constructing an instance of [SpanIframeListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -146,63 +151,46 @@ class SpanIframeListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: SpanIframeListPageAsync, - - ) { + class AutoPager(private val firstPage: SpanIframeListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (SpanIFrame) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (SpanIFrame) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 51eca91e..87ccce77 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all span_iframes. The span_iframes are sorted by creation date, with - * the most recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first */ -class SpanIframeListParams private constructor( +class SpanIframeListParams +private constructor( private val endingBefore: String?, private val ids: Ids?, private val limit: Long?, @@ -35,21 +36,20 @@ class SpanIframeListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -65,9 +65,9 @@ class SpanIframeListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -78,54 +78,25 @@ class SpanIframeListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.spanIframeName?.let { - queryParams.put( - "span_iframe_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.spanIframeName?.let { queryParams.put("span_iframe_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): SpanIframeListParams = builder().build() + @JvmStatic fun none(): SpanIframeListParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of - * [SpanIframeListParams]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [SpanIframeListParams]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [SpanIframeListParams]. */ @@ -142,71 +113,61 @@ class SpanIframeListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeListParams: SpanIframeListParams) = - apply { - endingBefore = spanIframeListParams.endingBefore - ids = spanIframeListParams.ids - limit = spanIframeListParams.limit - orgName = spanIframeListParams.orgName - spanIframeName = spanIframeListParams.spanIframeName - startingAfter = spanIframeListParams.startingAfter - additionalHeaders = spanIframeListParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeListParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeListParams: SpanIframeListParams) = apply { + endingBefore = spanIframeListParams.endingBefore + ids = spanIframeListParams.ids + limit = spanIframeListParams.limit + orgName = spanIframeListParams.orgName + spanIframeName = spanIframeListParams.spanIframeName + startingAfter = spanIframeListParams.startingAfter + additionalHeaders = spanIframeListParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeListParams.additionalQueryParams.toBuilder() + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -215,192 +176,159 @@ class SpanIframeListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the span_iframe to search for */ - fun spanIframeName(spanIframeName: String?) = - apply { - this.spanIframeName = spanIframeName - } + fun spanIframeName(spanIframeName: String?) = apply { this.spanIframeName = spanIframeName } /** Name of the span_iframe to search for */ - fun spanIframeName(spanIframeName: Optional) = spanIframeName(spanIframeName.getOrNull()) + fun spanIframeName(spanIframeName: Optional) = + spanIframeName(spanIframeName.getOrNull()) /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeListParams = SpanIframeListParams( - endingBefore, - ids, - limit, - orgName, - spanIframeName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + endingBefore, + ids, + limit, + orgName, + spanIframeName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -418,19 +346,19 @@ class SpanIframeListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -445,17 +373,12 @@ class SpanIframeListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -465,56 +388,60 @@ class SpanIframeListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeListParams && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && orgName == other.orgName && spanIframeName == other.spanIframeName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(endingBefore, ids, limit, orgName, spanIframeName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "SpanIframeListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, spanIframeName=$spanIframeName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index ae6144aa..d3dc8f16 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -22,15 +22,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace span_iframe. If there is an existing span_iframe with the same - * name as the one specified in the request, will replace the existing span_iframe - * with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will replace the existing span_iframe with the provided fields */ -class SpanIframeReplaceParams private constructor( +class SpanIframeReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the span iframe */ @@ -46,8 +45,8 @@ class SpanIframeReplaceParams private constructor( fun description(): Optional = body.description() /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -64,8 +63,8 @@ class SpanIframeReplaceParams private constructor( fun _description(): JsonField = body._description() /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -75,22 +74,31 @@ class SpanIframeReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing private val projectId: JsonField = JsonMissing.of(), + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") + @ExcludeMissing + private val projectId: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("post_message") + @ExcludeMissing + private val postMessage: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the span iframe */ @@ -103,28 +111,24 @@ class SpanIframeReplaceParams private constructor( fun url(): String = url.getRequired("url") /** Textual description of the span iframe */ - fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = + Optional.ofNullable(postMessage.getNullable("post_message")) /** Name of the span iframe */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Unique identifier for the project that the span iframe belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun _projectId(): JsonField = projectId + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") - @ExcludeMissing - fun _url(): JsonField = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url /** Textual description of the span iframe */ @JsonProperty("description") @@ -132,8 +136,8 @@ class SpanIframeReplaceParams private constructor( fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing @@ -145,20 +149,19 @@ class SpanIframeReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - projectId() - url() - description() - postMessage() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + projectId() + url() + description() + postMessage() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -167,15 +170,13 @@ class SpanIframeReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -189,42 +190,32 @@ class SpanIframeReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - projectId = body.projectId - url = body.url - description = body.description - postMessage = body.postMessage - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + projectId = body.projectId + url = body.url + description = body.description + postMessage = body.postMessage + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) /** Name of the span iframe */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = - apply { - this.projectId = projectId - } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = - apply { - this.url = url - } + fun url(url: JsonField) = apply { this.url = url } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -233,87 +224,72 @@ class SpanIframeReplaceParams private constructor( fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = - apply { - this.description = description - } + fun description(description: JsonField) = apply { + this.description = description + } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = - apply { - this.postMessage = postMessage - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun postMessage(postMessage: JsonField) = apply { + this.postMessage = postMessage + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "projectId", projectId - ), - checkRequired( - "url", url - ), - description, - postMessage, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("projectId", projectId), + checkRequired("url", url), + description, + postMessage, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && projectId == other.projectId && url == other.url && description == other.description && postMessage == other.postMessage && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -322,7 +298,8 @@ class SpanIframeReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, projectId=$projectId, url=$url, description=$description, postMessage=$postMessage, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -330,19 +307,16 @@ class SpanIframeReplaceParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [SpanIframeReplaceParams]. + * Returns a mutable builder for constructing an instance of [SpanIframeReplaceParams]. * * The following fields are required: - * * ```java * .name() * .projectId() * .url() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SpanIframeReplaceParams]. */ @@ -354,262 +328,198 @@ class SpanIframeReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = - apply { - body = spanIframeReplaceParams.body.toBuilder() - additionalHeaders = spanIframeReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeReplaceParams: SpanIframeReplaceParams) = apply { + body = spanIframeReplaceParams.body.toBuilder() + additionalHeaders = spanIframeReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the span iframe */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the span iframe */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: String) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: String) = apply { body.projectId(projectId) } /** Unique identifier for the project that the span iframe belongs under */ - fun projectId(projectId: JsonField) = - apply { - body.projectId(projectId) - } + fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** URL to embed the project viewer in an iframe */ - fun url(url: String) = - apply { - body.url(url) - } + fun url(url: String) = apply { body.url(url) } /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = - apply { - body.url(url) - } + fun url(url: JsonField) = apply { body.url(url) } /** Textual description of the span iframe */ - fun description(description: String?) = - apply { - body.description(description) - } + fun description(description: String?) = apply { body.description(description) } /** Textual description of the span iframe */ fun description(description: Optional) = description(description.getOrNull()) /** Textual description of the span iframe */ - fun description(description: JsonField) = - apply { - body.description(description) - } + fun description(description: JsonField) = apply { body.description(description) } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = - apply { - body.postMessage(postMessage) - } + fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = - apply { - body.postMessage(postMessage) - } + fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeReplaceParams = SpanIframeReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "SpanIframeReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "SpanIframeReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt index 6059ad2c..241438c1 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a span_iframe object by its id */ -class SpanIframeRetrieveParams private constructor( +class SpanIframeRetrieveParams +private constructor( private val spanIframeId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** SpanIframe id */ @@ -29,10 +29,10 @@ class SpanIframeRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -40,17 +40,14 @@ class SpanIframeRetrieveParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [SpanIframeRetrieveParams]. + * Returns a mutable builder for constructing an instance of [SpanIframeRetrieveParams]. * * The following fields are required: - * * ```java * .spanIframeId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SpanIframeRetrieveParams]. */ @@ -62,162 +59,131 @@ class SpanIframeRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeRetrieveParams: SpanIframeRetrieveParams) = - apply { - spanIframeId = spanIframeRetrieveParams.spanIframeId - additionalHeaders = spanIframeRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeRetrieveParams: SpanIframeRetrieveParams) = apply { + spanIframeId = spanIframeRetrieveParams.spanIframeId + additionalHeaders = spanIframeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeRetrieveParams.additionalQueryParams.toBuilder() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = - apply { - this.spanIframeId = spanIframeId - } + fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeRetrieveParams = SpanIframeRetrieveParams( - checkRequired( - "spanIframeId", spanIframeId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("spanIframeId", spanIframeId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeRetrieveParams && spanIframeId == other.spanIframeId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "SpanIframeRetrieveParams{spanIframeId=$spanIframeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 15870507..50735234 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -22,16 +22,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a span_iframe object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ -class SpanIframeUpdateParams private constructor( +class SpanIframeUpdateParams +private constructor( private val spanIframeId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** SpanIframe id */ @@ -41,8 +41,8 @@ class SpanIframeUpdateParams private constructor( fun name(): Optional = body.name() /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. */ fun postMessage(): Optional = body.postMessage() @@ -53,8 +53,8 @@ class SpanIframeUpdateParams private constructor( fun _name(): JsonField = body._name() /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when you + * want to render more data than fits in the URL. */ fun _postMessage(): JsonField = body._postMessage() @@ -67,58 +67,60 @@ class SpanIframeUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> spanIframeId - else -> "" - } + return when (index) { + 0 -> spanIframeId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("post_message") @ExcludeMissing private val postMessage: JsonField = JsonMissing.of(), + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("post_message") + @ExcludeMissing + private val postMessage: JsonField = JsonMissing.of(), @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the span iframe */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) + fun postMessage(): Optional = + Optional.ofNullable(postMessage.getNullable("post_message")) /** URL to embed the project viewer in an iframe */ fun url(): Optional = Optional.ofNullable(url.getNullable("url")) /** Name of the span iframe */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ @JsonProperty("post_message") @ExcludeMissing fun _postMessage(): JsonField = postMessage /** URL to embed the project viewer in an iframe */ - @JsonProperty("url") - @ExcludeMissing - fun _url(): JsonField = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -126,25 +128,23 @@ class SpanIframeUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - postMessage() - url() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + postMessage() + url() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -156,13 +156,12 @@ class SpanIframeUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - postMessage = body.postMessage - url = body.url - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + postMessage = body.postMessage + url = body.url + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the span iframe */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -171,37 +170,33 @@ class SpanIframeUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the span iframe */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful + * when you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = - apply { - this.postMessage = postMessage - } + fun postMessage(postMessage: JsonField) = apply { + this.postMessage = postMessage + } /** URL to embed the project viewer in an iframe */ fun url(url: String?) = url(JsonField.ofNullable(url)) @@ -210,52 +205,36 @@ class SpanIframeUpdateParams private constructor( fun url(url: Optional) = url(url.getOrNull()) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = - apply { - this.url = url - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = - Body( - name, - postMessage, - url, - additionalProperties.toImmutable(), - ) + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = Body(name, postMessage, url, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -264,7 +243,8 @@ class SpanIframeUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -272,17 +252,14 @@ class SpanIframeUpdateParams private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [SpanIframeUpdateParams]. + * Returns a mutable builder for constructing an instance of [SpanIframeUpdateParams]. * * The following fields are required: - * * ```java * .spanIframeId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SpanIframeUpdateParams]. */ @@ -295,251 +272,194 @@ class SpanIframeUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = - apply { - spanIframeId = spanIframeUpdateParams.spanIframeId - body = spanIframeUpdateParams.body.toBuilder() - additionalHeaders = spanIframeUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = spanIframeUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(spanIframeUpdateParams: SpanIframeUpdateParams) = apply { + spanIframeId = spanIframeUpdateParams.spanIframeId + body = spanIframeUpdateParams.body.toBuilder() + additionalHeaders = spanIframeUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = spanIframeUpdateParams.additionalQueryParams.toBuilder() + } /** SpanIframe id */ - fun spanIframeId(spanIframeId: String) = - apply { - this.spanIframeId = spanIframeId - } + fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } /** Name of the span iframe */ - fun name(name: String?) = - apply { - body.name(name) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the span iframe */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the span iframe */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: Boolean?) = - apply { - body.postMessage(postMessage) - } + fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is - * useful when you want to render more data than fits in the URL. + * Whether to post messages to the iframe containing the span's data. This is useful when + * you want to render more data than fits in the URL. */ - fun postMessage(postMessage: JsonField) = - apply { - body.postMessage(postMessage) - } + fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } /** URL to embed the project viewer in an iframe */ - fun url(url: String?) = - apply { - body.url(url) - } + fun url(url: String?) = apply { body.url(url) } /** URL to embed the project viewer in an iframe */ fun url(url: Optional) = url(url.getOrNull()) /** URL to embed the project viewer in an iframe */ - fun url(url: JsonField) = - apply { - body.url(url) - } + fun url(url: JsonField) = apply { body.url(url) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): SpanIframeUpdateParams = SpanIframeUpdateParams( - checkRequired( - "spanIframeId", spanIframeId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("spanIframeId", spanIframeId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is SpanIframeUpdateParams && spanIframeId == other.spanIframeId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanIframeId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "SpanIframeUpdateParams{spanIframeId=$spanIframeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "SpanIframeUpdateParams{spanIframeId=$spanIframeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 9d77823b..949d6300 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -20,14 +20,25 @@ import kotlin.jvm.optionals.getOrNull /** Summary of a dataset */ @NoAutoDetect -class SummarizeDatasetResponse @JsonCreator private constructor( - @JsonProperty("dataset_name") @ExcludeMissing private val datasetName: JsonField = JsonMissing.of(), - @JsonProperty("dataset_url") @ExcludeMissing private val datasetUrl: JsonField = JsonMissing.of(), - @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("project_url") @ExcludeMissing private val projectUrl: JsonField = JsonMissing.of(), - @JsonProperty("data_summary") @ExcludeMissing private val dataSummary: JsonField = JsonMissing.of(), +class SummarizeDatasetResponse +@JsonCreator +private constructor( + @JsonProperty("dataset_name") + @ExcludeMissing + private val datasetName: JsonField = JsonMissing.of(), + @JsonProperty("dataset_url") + @ExcludeMissing + private val datasetUrl: JsonField = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("project_url") + @ExcludeMissing + private val projectUrl: JsonField = JsonMissing.of(), + @JsonProperty("data_summary") + @ExcludeMissing + private val dataSummary: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Name of the dataset */ @@ -43,7 +54,8 @@ class SummarizeDatasetResponse @JsonCreator private constructor( fun projectUrl(): String = projectUrl.getRequired("project_url") /** Summary of a dataset's data */ - fun dataSummary(): Optional = Optional.ofNullable(dataSummary.getNullable("data_summary")) + fun dataSummary(): Optional = + Optional.ofNullable(dataSummary.getNullable("data_summary")) /** Name of the dataset */ @JsonProperty("dataset_name") @@ -51,9 +63,7 @@ class SummarizeDatasetResponse @JsonCreator private constructor( fun _datasetName(): JsonField = datasetName /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") - @ExcludeMissing - fun _datasetUrl(): JsonField = datasetUrl + @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl(): JsonField = datasetUrl /** Name of the project that the dataset belongs to */ @JsonProperty("project_name") @@ -61,9 +71,7 @@ class SummarizeDatasetResponse @JsonCreator private constructor( fun _projectName(): JsonField = projectName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") - @ExcludeMissing - fun _projectUrl(): JsonField = projectUrl + @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl /** Summary of a dataset's data */ @JsonProperty("data_summary") @@ -76,30 +84,27 @@ class SummarizeDatasetResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): SummarizeDatasetResponse = - apply { - if (validated) { - return@apply - } - - datasetName() - datasetUrl() - projectName() - projectUrl() - dataSummary().ifPresent { it.validate() } - validated = true + fun validate(): SummarizeDatasetResponse = apply { + if (validated) { + return@apply } + datasetName() + datasetUrl() + projectName() + projectUrl() + dataSummary().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [SummarizeDatasetResponse]. + * Returns a mutable builder for constructing an instance of [SummarizeDatasetResponse]. * * The following fields are required: - * * ```java * .datasetName() * .datasetUrl() @@ -107,8 +112,7 @@ class SummarizeDatasetResponse @JsonCreator private constructor( * .projectUrl() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SummarizeDatasetResponse]. */ @@ -122,51 +126,38 @@ class SummarizeDatasetResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(summarizeDatasetResponse: SummarizeDatasetResponse) = - apply { - datasetName = summarizeDatasetResponse.datasetName - datasetUrl = summarizeDatasetResponse.datasetUrl - projectName = summarizeDatasetResponse.projectName - projectUrl = summarizeDatasetResponse.projectUrl - dataSummary = summarizeDatasetResponse.dataSummary - additionalProperties = summarizeDatasetResponse.additionalProperties.toMutableMap() - } + internal fun from(summarizeDatasetResponse: SummarizeDatasetResponse) = apply { + datasetName = summarizeDatasetResponse.datasetName + datasetUrl = summarizeDatasetResponse.datasetUrl + projectName = summarizeDatasetResponse.projectName + projectUrl = summarizeDatasetResponse.projectUrl + dataSummary = summarizeDatasetResponse.dataSummary + additionalProperties = summarizeDatasetResponse.additionalProperties.toMutableMap() + } /** Name of the dataset */ fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) /** Name of the dataset */ - fun datasetName(datasetName: JsonField) = - apply { - this.datasetName = datasetName - } + fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } /** URL to the dataset's page in the Braintrust app */ fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) /** URL to the dataset's page in the Braintrust app */ - fun datasetUrl(datasetUrl: JsonField) = - apply { - this.datasetUrl = datasetUrl - } + fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } /** Name of the project that the dataset belongs to */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** Name of the project that the dataset belongs to */ - fun projectName(projectName: JsonField) = - apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = apply { this.projectName = projectName } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: JsonField) = - apply { - this.projectUrl = projectUrl - } + fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } /** Summary of a dataset's data */ fun dataSummary(dataSummary: DataSummary?) = dataSummary(JsonField.ofNullable(dataSummary)) @@ -175,62 +166,46 @@ class SummarizeDatasetResponse @JsonCreator private constructor( fun dataSummary(dataSummary: Optional) = dataSummary(dataSummary.getOrNull()) /** Summary of a dataset's data */ - fun dataSummary(dataSummary: JsonField) = - apply { - this.dataSummary = dataSummary - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun dataSummary(dataSummary: JsonField) = apply { + this.dataSummary = dataSummary + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SummarizeDatasetResponse = SummarizeDatasetResponse( - checkRequired( - "datasetName", datasetName - ), - checkRequired( - "datasetUrl", datasetUrl - ), - checkRequired( - "projectName", projectName - ), - checkRequired( - "projectUrl", projectUrl - ), - dataSummary, - additionalProperties.toImmutable(), + checkRequired("datasetName", datasetName), + checkRequired("datasetUrl", datasetUrl), + checkRequired("projectName", projectName), + checkRequired("projectUrl", projectUrl), + dataSummary, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SummarizeDatasetResponse && datasetName == other.datasetName && datasetUrl == other.datasetUrl && projectName == other.projectName && projectUrl == other.projectUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeDatasetResponse && datasetName == other.datasetName && datasetUrl == other.datasetUrl && projectName == other.projectName && projectUrl == other.projectUrl && dataSummary == other.dataSummary && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -239,5 +214,6 @@ class SummarizeDatasetResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "SummarizeDatasetResponse{datasetName=$datasetName, datasetUrl=$datasetUrl, projectName=$projectName, projectUrl=$projectUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" + override fun toString() = + "SummarizeDatasetResponse{datasetName=$datasetName, datasetUrl=$datasetUrl, projectName=$projectName, projectUrl=$projectUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 05ec4392..b23ca9e9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -20,16 +20,31 @@ import kotlin.jvm.optionals.getOrNull /** Summary of an experiment */ @NoAutoDetect -class SummarizeExperimentResponse @JsonCreator private constructor( - @JsonProperty("experiment_name") @ExcludeMissing private val experimentName: JsonField = JsonMissing.of(), - @JsonProperty("experiment_url") @ExcludeMissing private val experimentUrl: JsonField = JsonMissing.of(), - @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), - @JsonProperty("project_url") @ExcludeMissing private val projectUrl: JsonField = JsonMissing.of(), - @JsonProperty("comparison_experiment_name") @ExcludeMissing private val comparisonExperimentName: JsonField = JsonMissing.of(), - @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), - @JsonProperty("scores") @ExcludeMissing private val scores: JsonField = JsonMissing.of(), +class SummarizeExperimentResponse +@JsonCreator +private constructor( + @JsonProperty("experiment_name") + @ExcludeMissing + private val experimentName: JsonField = JsonMissing.of(), + @JsonProperty("experiment_url") + @ExcludeMissing + private val experimentUrl: JsonField = JsonMissing.of(), + @JsonProperty("project_name") + @ExcludeMissing + private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("project_url") + @ExcludeMissing + private val projectUrl: JsonField = JsonMissing.of(), + @JsonProperty("comparison_experiment_name") + @ExcludeMissing + private val comparisonExperimentName: JsonField = JsonMissing.of(), + @JsonProperty("metrics") + @ExcludeMissing + private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("scores") + @ExcludeMissing + private val scores: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Name of the experiment */ @@ -45,7 +60,8 @@ class SummarizeExperimentResponse @JsonCreator private constructor( fun projectUrl(): String = projectUrl.getRequired("project_url") /** The experiment which scores are baselined against */ - fun comparisonExperimentName(): Optional = Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) + fun comparisonExperimentName(): Optional = + Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) /** Summary of the experiment's metrics */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) @@ -69,9 +85,7 @@ class SummarizeExperimentResponse @JsonCreator private constructor( fun _projectName(): JsonField = projectName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") - @ExcludeMissing - fun _projectUrl(): JsonField = projectUrl + @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl /** The experiment which scores are baselined against */ @JsonProperty("comparison_experiment_name") @@ -79,14 +93,10 @@ class SummarizeExperimentResponse @JsonCreator private constructor( fun _comparisonExperimentName(): JsonField = comparisonExperimentName /** Summary of the experiment's metrics */ - @JsonProperty("metrics") - @ExcludeMissing - fun _metrics(): JsonField = metrics + @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** Summary of the experiment's scores */ - @JsonProperty("scores") - @ExcludeMissing - fun _scores(): JsonField = scores + @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores @JsonAnyGetter @ExcludeMissing @@ -94,32 +104,29 @@ class SummarizeExperimentResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): SummarizeExperimentResponse = - apply { - if (validated) { - return@apply - } - - experimentName() - experimentUrl() - projectName() - projectUrl() - comparisonExperimentName() - metrics().ifPresent { it.validate() } - scores().ifPresent { it.validate() } - validated = true + fun validate(): SummarizeExperimentResponse = apply { + if (validated) { + return@apply } + experimentName() + experimentUrl() + projectName() + projectUrl() + comparisonExperimentName() + metrics().ifPresent { it.validate() } + scores().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of - * [SummarizeExperimentResponse]. + * Returns a mutable builder for constructing an instance of [SummarizeExperimentResponse]. * * The following fields are required: - * * ```java * .experimentName() * .experimentUrl() @@ -127,8 +134,7 @@ class SummarizeExperimentResponse @JsonCreator private constructor( * .projectUrl() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [SummarizeExperimentResponse]. */ @@ -144,65 +150,57 @@ class SummarizeExperimentResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(summarizeExperimentResponse: SummarizeExperimentResponse) = - apply { - experimentName = summarizeExperimentResponse.experimentName - experimentUrl = summarizeExperimentResponse.experimentUrl - projectName = summarizeExperimentResponse.projectName - projectUrl = summarizeExperimentResponse.projectUrl - comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName - metrics = summarizeExperimentResponse.metrics - scores = summarizeExperimentResponse.scores - additionalProperties = summarizeExperimentResponse.additionalProperties.toMutableMap() - } + internal fun from(summarizeExperimentResponse: SummarizeExperimentResponse) = apply { + experimentName = summarizeExperimentResponse.experimentName + experimentUrl = summarizeExperimentResponse.experimentUrl + projectName = summarizeExperimentResponse.projectName + projectUrl = summarizeExperimentResponse.projectUrl + comparisonExperimentName = summarizeExperimentResponse.comparisonExperimentName + metrics = summarizeExperimentResponse.metrics + scores = summarizeExperimentResponse.scores + additionalProperties = summarizeExperimentResponse.additionalProperties.toMutableMap() + } /** Name of the experiment */ fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) /** Name of the experiment */ - fun experimentName(experimentName: JsonField) = - apply { - this.experimentName = experimentName - } + fun experimentName(experimentName: JsonField) = apply { + this.experimentName = experimentName + } /** URL to the experiment's page in the Braintrust app */ fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) /** URL to the experiment's page in the Braintrust app */ - fun experimentUrl(experimentUrl: JsonField) = - apply { - this.experimentUrl = experimentUrl - } + fun experimentUrl(experimentUrl: JsonField) = apply { + this.experimentUrl = experimentUrl + } /** Name of the project that the experiment belongs to */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) /** Name of the project that the experiment belongs to */ - fun projectName(projectName: JsonField) = - apply { - this.projectName = projectName - } + fun projectName(projectName: JsonField) = apply { this.projectName = projectName } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: JsonField) = - apply { - this.projectUrl = projectUrl - } + fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: String?) = comparisonExperimentName(JsonField.ofNullable(comparisonExperimentName)) + fun comparisonExperimentName(comparisonExperimentName: String?) = + comparisonExperimentName(JsonField.ofNullable(comparisonExperimentName)) /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: Optional) = comparisonExperimentName(comparisonExperimentName.getOrNull()) + fun comparisonExperimentName(comparisonExperimentName: Optional) = + comparisonExperimentName(comparisonExperimentName.getOrNull()) /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: JsonField) = - apply { - this.comparisonExperimentName = comparisonExperimentName - } + fun comparisonExperimentName(comparisonExperimentName: JsonField) = apply { + this.comparisonExperimentName = comparisonExperimentName + } /** Summary of the experiment's metrics */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) @@ -211,10 +209,7 @@ class SummarizeExperimentResponse @JsonCreator private constructor( fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** Summary of the experiment's metrics */ - fun metrics(metrics: JsonField) = - apply { - this.metrics = metrics - } + fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Summary of the experiment's scores */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) @@ -223,63 +218,47 @@ class SummarizeExperimentResponse @JsonCreator private constructor( fun scores(scores: Optional) = scores(scores.getOrNull()) /** Summary of the experiment's scores */ - fun scores(scores: JsonField) = - apply { - this.scores = scores - } + fun scores(scores: JsonField) = apply { this.scores = scores } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): SummarizeExperimentResponse = SummarizeExperimentResponse( - checkRequired( - "experimentName", experimentName - ), - checkRequired( - "experimentUrl", experimentUrl - ), - checkRequired( - "projectName", projectName - ), - checkRequired( - "projectUrl", projectUrl - ), - comparisonExperimentName, - metrics, - scores, - additionalProperties.toImmutable(), + checkRequired("experimentName", experimentName), + checkRequired("experimentUrl", experimentUrl), + checkRequired("projectName", projectName), + checkRequired("projectUrl", projectUrl), + comparisonExperimentName, + metrics, + scores, + additionalProperties.toImmutable(), ) } /** Summary of the experiment's metrics */ @NoAutoDetect - class Metrics @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Metrics + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -288,22 +267,20 @@ class SummarizeExperimentResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Metrics = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Metrics = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Metrics]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Metrics]. */ @@ -312,46 +289,38 @@ class SummarizeExperimentResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(metrics: Metrics) = - apply { - additionalProperties = metrics.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(metrics: Metrics) = apply { + additionalProperties = metrics.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Metrics = Metrics(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Metrics && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metrics && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -365,9 +334,11 @@ class SummarizeExperimentResponse @JsonCreator private constructor( /** Summary of the experiment's scores */ @NoAutoDetect - class Scores @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Scores + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -376,22 +347,20 @@ class SummarizeExperimentResponse @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): Scores = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): Scores = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [Scores]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Scores]. */ @@ -400,46 +369,38 @@ class SummarizeExperimentResponse @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scores: Scores) = - apply { - additionalProperties = scores.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + internal fun from(scores: Scores) = apply { + additionalProperties = scores.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Scores = Scores(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -452,11 +413,11 @@ class SummarizeExperimentResponse @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is SummarizeExperimentResponse && experimentName == other.experimentName && experimentUrl == other.experimentUrl && projectName == other.projectName && projectUrl == other.projectUrl && comparisonExperimentName == other.comparisonExperimentName && metrics == other.metrics && scores == other.scores && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SummarizeExperimentResponse && experimentName == other.experimentName && experimentUrl == other.experimentUrl && projectName == other.projectName && projectUrl == other.projectUrl && comparisonExperimentName == other.comparisonExperimentName && metrics == other.metrics && scores == other.scores && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -465,5 +426,6 @@ class SummarizeExperimentResponse @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "SummarizeExperimentResponse{experimentName=$experimentName, experimentUrl=$experimentUrl, projectName=$projectName, projectUrl=$projectUrl, comparisonExperimentName=$comparisonExperimentName, metrics=$metrics, scores=$scores, additionalProperties=$additionalProperties}" + override fun toString() = + "SummarizeExperimentResponse{experimentName=$experimentName, experimentUrl=$experimentUrl, projectName=$projectName, projectUrl=$projectUrl, comparisonExperimentName=$comparisonExperimentName, metrics=$metrics, scores=$scores, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index b8b095b3..a3a17747 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -8,14 +8,11 @@ import com.braintrustdata.api.core.http.Headers import com.braintrustdata.api.core.http.QueryParams import java.util.Objects -/** - * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not - * required - */ -class TopLevelHelloWorldParams private constructor( +/** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ +class TopLevelHelloWorldParams +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { fun _additionalHeaders(): Headers = additionalHeaders @@ -30,15 +27,10 @@ class TopLevelHelloWorldParams private constructor( companion object { - @JvmStatic - fun none(): TopLevelHelloWorldParams = builder().build() + @JvmStatic fun none(): TopLevelHelloWorldParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of - * [TopLevelHelloWorldParams]. - */ - @JvmStatic - fun builder() = Builder() + /** Returns a mutable builder for constructing an instance of [TopLevelHelloWorldParams]. */ + @JvmStatic fun builder() = Builder() } /** A builder for [TopLevelHelloWorldParams]. */ @@ -49,151 +41,123 @@ class TopLevelHelloWorldParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = - apply { - additionalHeaders = topLevelHelloWorldParams.additionalHeaders.toBuilder() - additionalQueryParams = topLevelHelloWorldParams.additionalQueryParams.toBuilder() - } + internal fun from(topLevelHelloWorldParams: TopLevelHelloWorldParams) = apply { + additionalHeaders = topLevelHelloWorldParams.additionalHeaders.toBuilder() + additionalQueryParams = topLevelHelloWorldParams.additionalQueryParams.toBuilder() + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): TopLevelHelloWorldParams = - TopLevelHelloWorldParams( - additionalHeaders.build(), additionalQueryParams.build() - ) + TopLevelHelloWorldParams(additionalHeaders.build(), additionalQueryParams.build()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is TopLevelHelloWorldParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "TopLevelHelloWorldParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index a2e28021..b064f7aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -20,15 +20,24 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class User @JsonCreator private constructor( +class User +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("avatar_url") @ExcludeMissing private val avatarUrl: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), + @JsonProperty("avatar_url") + @ExcludeMissing + private val avatarUrl: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), @JsonProperty("email") @ExcludeMissing private val email: JsonField = JsonMissing.of(), - @JsonProperty("family_name") @ExcludeMissing private val familyName: JsonField = JsonMissing.of(), - @JsonProperty("given_name") @ExcludeMissing private val givenName: JsonField = JsonMissing.of(), + @JsonProperty("family_name") + @ExcludeMissing + private val familyName: JsonField = JsonMissing.of(), + @JsonProperty("given_name") + @ExcludeMissing + private val givenName: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the user */ @@ -50,34 +59,22 @@ class User @JsonCreator private constructor( fun givenName(): Optional = Optional.ofNullable(givenName.getNullable("given_name")) /** Unique identifier for the user */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** URL of the user's Avatar image */ - @JsonProperty("avatar_url") - @ExcludeMissing - fun _avatarUrl(): JsonField = avatarUrl + @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl(): JsonField = avatarUrl /** Date of user creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** The user's email */ - @JsonProperty("email") - @ExcludeMissing - fun _email(): JsonField = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** Family name of the user */ - @JsonProperty("family_name") - @ExcludeMissing - fun _familyName(): JsonField = familyName + @JsonProperty("family_name") @ExcludeMissing fun _familyName(): JsonField = familyName /** Given name of the user */ - @JsonProperty("given_name") - @ExcludeMissing - fun _givenName(): JsonField = givenName + @JsonProperty("given_name") @ExcludeMissing fun _givenName(): JsonField = givenName @JsonAnyGetter @ExcludeMissing @@ -85,21 +82,20 @@ class User @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): User = - apply { - if (validated) { - return@apply - } - - id() - avatarUrl() - created() - email() - familyName() - givenName() - validated = true + fun validate(): User = apply { + if (validated) { + return@apply } + id() + avatarUrl() + created() + email() + familyName() + givenName() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -108,13 +104,11 @@ class User @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [User]. * * The following fields are required: - * * ```java * .id() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [User]. */ @@ -129,25 +123,21 @@ class User @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(user: User) = - apply { - id = user.id - avatarUrl = user.avatarUrl - created = user.created - email = user.email - familyName = user.familyName - givenName = user.givenName - additionalProperties = user.additionalProperties.toMutableMap() - } + internal fun from(user: User) = apply { + id = user.id + avatarUrl = user.avatarUrl + created = user.created + email = user.email + familyName = user.familyName + givenName = user.givenName + additionalProperties = user.additionalProperties.toMutableMap() + } /** Unique identifier for the user */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the user */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** URL of the user's Avatar image */ fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) @@ -156,10 +146,7 @@ class User @JsonCreator private constructor( fun avatarUrl(avatarUrl: Optional) = avatarUrl(avatarUrl.getOrNull()) /** URL of the user's Avatar image */ - fun avatarUrl(avatarUrl: JsonField) = - apply { - this.avatarUrl = avatarUrl - } + fun avatarUrl(avatarUrl: JsonField) = apply { this.avatarUrl = avatarUrl } /** Date of user creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -168,10 +155,7 @@ class User @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of user creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** The user's email */ fun email(email: String?) = email(JsonField.ofNullable(email)) @@ -180,10 +164,7 @@ class User @JsonCreator private constructor( fun email(email: Optional) = email(email.getOrNull()) /** The user's email */ - fun email(email: JsonField) = - apply { - this.email = email - } + fun email(email: JsonField) = apply { this.email = email } /** Family name of the user */ fun familyName(familyName: String?) = familyName(JsonField.ofNullable(familyName)) @@ -192,10 +173,7 @@ class User @JsonCreator private constructor( fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) /** Family name of the user */ - fun familyName(familyName: JsonField) = - apply { - this.familyName = familyName - } + fun familyName(familyName: JsonField) = apply { this.familyName = familyName } /** Given name of the user */ fun givenName(givenName: String?) = givenName(JsonField.ofNullable(givenName)) @@ -204,57 +182,45 @@ class User @JsonCreator private constructor( fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) /** Given name of the user */ - fun givenName(givenName: JsonField) = - apply { - this.givenName = givenName - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun givenName(givenName: JsonField) = apply { this.givenName = givenName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): User = User( - checkRequired( - "id", id - ), - avatarUrl, - created, - email, - familyName, - givenName, - additionalProperties.toImmutable(), + checkRequired("id", id), + avatarUrl, + created, + email, + familyName, + givenName, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is User && id == other.id && avatarUrl == other.avatarUrl && created == other.created && email == other.email && familyName == other.familyName && givenName == other.givenName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is User && id == other.id && avatarUrl == other.avatarUrl && created == other.created && email == other.email && familyName == other.familyName && givenName == other.givenName && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -263,5 +229,6 @@ class User @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "User{id=$id, avatarUrl=$avatarUrl, created=$created, email=$email, familyName=$familyName, givenName=$givenName, additionalProperties=$additionalProperties}" + override fun toString() = + "User{id=$id, avatarUrl=$avatarUrl, created=$created, email=$email, familyName=$familyName, givenName=$givenName, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 0c0f286d..c02d5269 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.UserService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created users + * coming first */ -class UserListPage private constructor( +class UserListPage +private constructor( private val usersService: UserService, private val params: UserListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,40 @@ class UserListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListPage && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is UserListPage && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ - override fun toString() = "UserListPage{usersService=$usersService, params=$params, response=$response}" + override fun toString() = + "UserListPage{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(UserListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(UserListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + UserListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + UserListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { usersService.list(it) } + return getNextPageParams().map { usersService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +78,16 @@ class UserListPage private constructor( @JvmStatic fun of(usersService: UserService, params: UserListParams, response: Response) = - UserListPage( - usersService, - params, - response, - ) + UserListPage(usersService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +101,34 @@ class UserListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [UserListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +137,39 @@ class UserListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: UserListPage, + class AutoPager(private val firstPage: UserListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index baa4ce20..82830d2e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.UserServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created users + * coming first */ -class UserListPageAsync private constructor( +class UserListPageAsync +private constructor( private val usersService: UserServiceAsync, private val params: UserListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,42 @@ class UserListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListPageAsync && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is UserListPageAsync && usersService == other.usersService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(usersService, params, response) /* spotless:on */ - override fun toString() = "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" + override fun toString() = + "UserListPageAsync{usersService=$usersService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(UserListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(UserListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + UserListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + UserListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - usersService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { usersService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -81,18 +80,16 @@ class UserListPageAsync private constructor( @JvmStatic fun of(usersService: UserServiceAsync, params: UserListParams, response: Response) = - UserListPageAsync( - usersService, - params, - response, - ) + UserListPageAsync(usersService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,35 +103,34 @@ class UserListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [UserListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -143,63 +139,46 @@ class UserListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: UserListPageAsync, - - ) { + class AutoPager(private val firstPage: UserListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (User) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (User) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index be008466..d259099e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -23,10 +23,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created users + * coming first */ -class UserListParams private constructor( +class UserListParams +private constructor( private val email: Email?, private val endingBefore: String?, private val familyName: FamilyName?, @@ -37,39 +38,38 @@ class UserListParams private constructor( private val startingAfter: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** - * Email of the user to search for. You may pass the param multiple times to filter - * for more than one email + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email */ fun email(): Optional = Optional.ofNullable(email) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Family name of the user to search for. You may pass the param multiple times to - * filter for more than one family name + * Family name of the user to search for. You may pass the param multiple times to filter for + * more than one family name */ fun familyName(): Optional = Optional.ofNullable(familyName) /** - * Given name of the user to search for. You may pass the param multiple times to - * filter for more than one given name + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name */ fun givenName(): Optional = Optional.ofNullable(givenName) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -82,9 +82,9 @@ class UserListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -95,61 +95,27 @@ class UserListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.email?.let { - queryParams.put( - "email", listOf(it.toString()) - ) - } - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.familyName?.let { - queryParams.put( - "family_name", listOf(it.toString()) - ) - } - this.givenName?.let { - queryParams.put( - "given_name", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.orgName?.let { - queryParams.put( - "org_name", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.email?.let { queryParams.put("email", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.familyName?.let { queryParams.put("family_name", listOf(it.toString())) } + this.givenName?.let { queryParams.put("given_name", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun none(): UserListParams = builder().build() + @JvmStatic fun none(): UserListParams = builder().build() /** Returns a mutable builder for constructing an instance of [UserListParams]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [UserListParams]. */ @@ -168,154 +134,135 @@ class UserListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(userListParams: UserListParams) = - apply { - email = userListParams.email - endingBefore = userListParams.endingBefore - familyName = userListParams.familyName - givenName = userListParams.givenName - ids = userListParams.ids - limit = userListParams.limit - orgName = userListParams.orgName - startingAfter = userListParams.startingAfter - additionalHeaders = userListParams.additionalHeaders.toBuilder() - additionalQueryParams = userListParams.additionalQueryParams.toBuilder() - } + internal fun from(userListParams: UserListParams) = apply { + email = userListParams.email + endingBefore = userListParams.endingBefore + familyName = userListParams.familyName + givenName = userListParams.givenName + ids = userListParams.ids + limit = userListParams.limit + orgName = userListParams.orgName + startingAfter = userListParams.startingAfter + additionalHeaders = userListParams.additionalHeaders.toBuilder() + additionalQueryParams = userListParams.additionalQueryParams.toBuilder() + } /** - * Email of the user to search for. You may pass the param multiple times to filter - * for more than one email + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email */ - fun email(email: Email?) = - apply { - this.email = email - } + fun email(email: Email?) = apply { this.email = email } /** - * Email of the user to search for. You may pass the param multiple times to filter - * for more than one email + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email */ fun email(email: Optional) = email(email.getOrNull()) /** - * Email of the user to search for. You may pass the param multiple times to filter - * for more than one email + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email */ fun email(string: String) = email(Email.ofString(string)) /** - * Email of the user to search for. You may pass the param multiple times to filter - * for more than one email + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email */ fun emailOfStrings(strings: List) = email(Email.ofStrings(strings)) /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Family name of the user to search for. You may pass the param multiple times to - * filter for more than one family name + * Family name of the user to search for. You may pass the param multiple times to filter + * for more than one family name */ - fun familyName(familyName: FamilyName?) = - apply { - this.familyName = familyName - } + fun familyName(familyName: FamilyName?) = apply { this.familyName = familyName } /** - * Family name of the user to search for. You may pass the param multiple times to - * filter for more than one family name + * Family name of the user to search for. You may pass the param multiple times to filter + * for more than one family name */ fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) /** - * Family name of the user to search for. You may pass the param multiple times to - * filter for more than one family name + * Family name of the user to search for. You may pass the param multiple times to filter + * for more than one family name */ fun familyName(string: String) = familyName(FamilyName.ofString(string)) /** - * Family name of the user to search for. You may pass the param multiple times to - * filter for more than one family name + * Family name of the user to search for. You may pass the param multiple times to filter + * for more than one family name */ fun familyNameOfStrings(strings: List) = familyName(FamilyName.ofStrings(strings)) /** - * Given name of the user to search for. You may pass the param multiple times to - * filter for more than one given name + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name */ - fun givenName(givenName: GivenName?) = - apply { - this.givenName = givenName - } + fun givenName(givenName: GivenName?) = apply { this.givenName = givenName } /** - * Given name of the user to search for. You may pass the param multiple times to - * filter for more than one given name + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name */ fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) /** - * Given name of the user to search for. You may pass the param multiple times to - * filter for more than one given name + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name */ fun givenName(string: String) = givenName(GivenName.ofString(string)) /** - * Given name of the user to search for. You may pass the param multiple times to - * filter for more than one given name + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name */ fun givenNameOfStrings(strings: List) = givenName(GivenName.ofStrings(strings)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -324,10 +271,7 @@ class UserListParams private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ - fun orgName(orgName: String?) = - apply { - this.orgName = orgName - } + fun orgName(orgName: String?) = apply { this.orgName = orgName } /** Filter search results to within a particular organization */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) @@ -335,174 +279,146 @@ class UserListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): UserListParams = UserListParams( - email, - endingBefore, - familyName, - givenName, - ids, - limit, - orgName, - startingAfter, - additionalHeaders.build(), - additionalQueryParams.build(), + email, + endingBefore, + familyName, + givenName, + ids, + limit, + orgName, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** - * Email of the user to search for. You may pass the param multiple times to filter - * for more than one email + * Email of the user to search for. You may pass the param multiple times to filter for more + * than one email */ @JsonDeserialize(using = Email.Deserializer::class) @JsonSerialize(using = Email.Serializer::class) - class Email private constructor( + class Email + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -520,19 +436,19 @@ class UserListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Email && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Email && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -547,17 +463,12 @@ class UserListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Email(string = string) + @JvmStatic fun ofString(string: String) = Email(string = string) - @JvmStatic - fun ofStrings(strings: List) = Email(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Email(strings = strings) } - /** - * An interface that defines how to map each variant of [Email] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Email] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -567,58 +478,62 @@ class UserListParams private constructor( /** * Maps an unknown variant of [Email] to a value of type [T]. * - * An instance of [Email] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Email] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Email: $json") + throw BraintrustInvalidDataException("Unknown Email: $json") } } internal class Deserializer : BaseDeserializer(Email::class) { override fun ObjectCodec.deserialize(node: JsonNode): Email { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Email(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Email(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Email(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Email(strings = it, _json = json) + } - return Email(_json = json) + return Email(_json = json) } } internal class Serializer : BaseSerializer(Email::class) { - override fun serialize(value: Email, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Email") - } + override fun serialize( + value: Email, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Email") + } } } } /** - * Family name of the user to search for. You may pass the param multiple times to - * filter for more than one family name + * Family name of the user to search for. You may pass the param multiple times to filter for + * more than one family name */ @JsonDeserialize(using = FamilyName.Deserializer::class) @JsonSerialize(using = FamilyName.Serializer::class) - class FamilyName private constructor( + class FamilyName + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -636,19 +551,19 @@ class UserListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is FamilyName && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is FamilyName && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -663,16 +578,13 @@ class UserListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = FamilyName(string = string) + @JvmStatic fun ofString(string: String) = FamilyName(string = string) - @JvmStatic - fun ofStrings(strings: List) = FamilyName(strings = strings) + @JvmStatic fun ofStrings(strings: List) = FamilyName(strings = strings) } /** - * An interface that defines how to map each variant of [FamilyName] to a value of - * type [T]. + * An interface that defines how to map each variant of [FamilyName] to a value of type [T]. */ interface Visitor { @@ -683,58 +595,62 @@ class UserListParams private constructor( /** * Maps an unknown variant of [FamilyName] to a value of type [T]. * - * An instance of [FamilyName] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * An instance of [FamilyName] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FamilyName: $json") + throw BraintrustInvalidDataException("Unknown FamilyName: $json") } } internal class Deserializer : BaseDeserializer(FamilyName::class) { override fun ObjectCodec.deserialize(node: JsonNode): FamilyName { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FamilyName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return FamilyName(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return FamilyName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return FamilyName(strings = it, _json = json) + } - return FamilyName(_json = json) + return FamilyName(_json = json) } } internal class Serializer : BaseSerializer(FamilyName::class) { - override fun serialize(value: FamilyName, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FamilyName") - } + override fun serialize( + value: FamilyName, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FamilyName") + } } } } /** - * Given name of the user to search for. You may pass the param multiple times to - * filter for more than one given name + * Given name of the user to search for. You may pass the param multiple times to filter for + * more than one given name */ @JsonDeserialize(using = GivenName.Deserializer::class) @JsonSerialize(using = GivenName.Serializer::class) - class GivenName private constructor( + class GivenName + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -752,19 +668,19 @@ class UserListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is GivenName && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is GivenName && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -779,16 +695,13 @@ class UserListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = GivenName(string = string) + @JvmStatic fun ofString(string: String) = GivenName(string = string) - @JvmStatic - fun ofStrings(strings: List) = GivenName(strings = strings) + @JvmStatic fun ofStrings(strings: List) = GivenName(strings = strings) } /** - * An interface that defines how to map each variant of [GivenName] to a value of - * type [T]. + * An interface that defines how to map each variant of [GivenName] to a value of type [T]. */ interface Visitor { @@ -799,58 +712,62 @@ class UserListParams private constructor( /** * Maps an unknown variant of [GivenName] to a value of type [T]. * - * An instance of [GivenName] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [GivenName] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown GivenName: $json") + throw BraintrustInvalidDataException("Unknown GivenName: $json") } } internal class Deserializer : BaseDeserializer(GivenName::class) { override fun ObjectCodec.deserialize(node: JsonNode): GivenName { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return GivenName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return GivenName(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return GivenName(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return GivenName(strings = it, _json = json) + } - return GivenName(_json = json) + return GivenName(_json = json) } } internal class Serializer : BaseSerializer(GivenName::class) { - override fun serialize(value: GivenName, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid GivenName") - } + override fun serialize( + value: GivenName, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid GivenName") + } } } } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -868,19 +785,19 @@ class UserListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -895,17 +812,12 @@ class UserListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -915,56 +827,60 @@ class UserListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is UserListParams && email == other.email && endingBefore == other.endingBefore && familyName == other.familyName && givenName == other.givenName && ids == other.ids && limit == other.limit && orgName == other.orgName && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(email, endingBefore, familyName, givenName, ids, limit, orgName, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index d97040de..b5982ab9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -10,11 +10,11 @@ import com.braintrustdata.api.core.http.QueryParams import java.util.Objects /** Get a user object by its id */ -class UserRetrieveParams private constructor( +class UserRetrieveParams +private constructor( private val userId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** User id */ @@ -29,10 +29,10 @@ class UserRetrieveParams private constructor( override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> userId - else -> "" - } + return when (index) { + 0 -> userId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -43,13 +43,11 @@ class UserRetrieveParams private constructor( * Returns a mutable builder for constructing an instance of [UserRetrieveParams]. * * The following fields are required: - * * ```java * .userId() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [UserRetrieveParams]. */ @@ -61,162 +59,131 @@ class UserRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(userRetrieveParams: UserRetrieveParams) = - apply { - userId = userRetrieveParams.userId - additionalHeaders = userRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = userRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(userRetrieveParams: UserRetrieveParams) = apply { + userId = userRetrieveParams.userId + additionalHeaders = userRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = userRetrieveParams.additionalQueryParams.toBuilder() + } /** User id */ - fun userId(userId: String) = - apply { - this.userId = userId - } + fun userId(userId: String) = apply { this.userId = userId } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): UserRetrieveParams = UserRetrieveParams( - checkRequired( - "userId", userId - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("userId", userId), + additionalHeaders.build(), + additionalQueryParams.build(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is UserRetrieveParams && userId == other.userId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(userId, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "UserRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 07910d51..a8bb266f 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 @@ -22,19 +22,36 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class View @JsonCreator private constructor( +class View +@JsonCreator +private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") + @ExcludeMissing + private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") + @ExcludeMissing + private val viewData: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { /** Unique identifier for the view */ @@ -56,7 +73,8 @@ class View @JsonCreator private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -68,19 +86,13 @@ class View @JsonCreator private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Unique identifier for the view */ - @JsonProperty("id") - @ExcludeMissing - fun _id(): JsonField = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the view */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -88,14 +100,10 @@ class View @JsonCreator private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - @ExcludeMissing - fun _viewType(): JsonField = viewType + @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType /** Date of view creation */ - @JsonProperty("created") - @ExcludeMissing - fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -103,19 +111,13 @@ class View @JsonCreator private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): JsonField = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") - @ExcludeMissing - fun _viewData(): JsonField = viewData + @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -123,25 +125,24 @@ class View @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): View = - apply { - if (validated) { - return@apply - } - - id() - name() - objectId() - objectType() - viewType() - created() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true + fun validate(): View = apply { + if (validated) { + return@apply } + id() + name() + objectId() + objectType() + viewType() + created() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -150,7 +151,6 @@ class View @JsonCreator private constructor( * Returns a mutable builder for constructing an instance of [View]. * * The following fields are required: - * * ```java * .id() * .name() @@ -159,8 +159,7 @@ class View @JsonCreator private constructor( * .viewType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [View]. */ @@ -179,56 +178,43 @@ class View @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(view: View) = - apply { - id = view.id - name = view.name - objectId = view.objectId - objectType = view.objectType - viewType = view.viewType - created = view.created - deletedAt = view.deletedAt - options = view.options - userId = view.userId - viewData = view.viewData - additionalProperties = view.additionalProperties.toMutableMap() - } + internal fun from(view: View) = apply { + id = view.id + name = view.name + objectId = view.objectId + objectType = view.objectType + viewType = view.viewType + created = view.created + deletedAt = view.deletedAt + options = view.options + userId = view.userId + viewData = view.viewData + additionalProperties = view.additionalProperties.toMutableMap() + } /** Unique identifier for the view */ fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the view */ - fun id(id: JsonField) = - apply { - this.id = id - } + fun id(id: JsonField) = apply { this.id = id } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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)) @@ -237,10 +223,7 @@ class View @JsonCreator private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = - apply { - this.viewType = viewType - } + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } /** Date of view creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) @@ -249,10 +232,7 @@ class View @JsonCreator private constructor( fun created(created: Optional) = created(created.getOrNull()) /** Date of view creation */ - fun created(created: JsonField) = - apply { - this.created = created - } + fun created(created: JsonField) = apply { this.created = created } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -261,10 +241,7 @@ class View @JsonCreator private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -273,10 +250,7 @@ class View @JsonCreator private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = - apply { - this.options = options - } + fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -285,10 +259,7 @@ class View @JsonCreator private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -297,79 +268,55 @@ class View @JsonCreator private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = - apply { - this.viewData = viewData - } + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): View = View( - checkRequired( - "id", id - ), - checkRequired( - "name", name - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - checkRequired( - "viewType", viewType - ), - created, - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired("id", id), + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + checkRequired("viewType", viewType), + created, + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -417,11 +364,9 @@ class View @JsonCreator private constructor( * 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 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 { @@ -437,18 +382,17 @@ class View @JsonCreator private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -469,11 +413,11 @@ class View @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -494,20 +438,23 @@ class View @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -516,21 +463,17 @@ class View @JsonCreator private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -569,11 +512,9 @@ class View @JsonCreator private constructor( * 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 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 { @@ -585,19 +526,16 @@ class View @JsonCreator private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** - * An enum member indicating that [ViewType] was instantiated with an unknown - * value. - */ + /** 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. + * 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. + * 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) { @@ -615,11 +553,11 @@ class View @JsonCreator private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -637,20 +575,23 @@ class View @JsonCreator private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -659,11 +600,11 @@ class View @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is View && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && created == other.created && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is View && id == other.id && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && created == other.created && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -672,5 +613,6 @@ class View @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "View{id=$id, name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, created=$created, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = + "View{id=$id, name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, created=$created, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } 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 0e1d6133..0597fc32 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 @@ -25,14 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create a new view. If there is an existing view with the same name as the one - * specified in the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one specified in the + * request, will return the existing view unmodified */ -class ViewCreateParams private constructor( +class ViewCreateParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the view */ @@ -89,25 +89,42 @@ class ViewCreateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") + @ExcludeMissing + private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") + @ExcludeMissing + private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the view */ @@ -123,7 +140,8 @@ class ViewCreateParams private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -135,14 +153,10 @@ class ViewCreateParams private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Name of the view */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -150,9 +164,7 @@ class ViewCreateParams private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - @ExcludeMissing - fun _viewType(): JsonField = viewType + @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -160,19 +172,13 @@ class ViewCreateParams private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): JsonField = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") - @ExcludeMissing - fun _viewData(): JsonField = viewData + @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -180,23 +186,22 @@ class ViewCreateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - objectId() - objectType() - viewType() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + objectId() + objectType() + viewType() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -205,7 +210,6 @@ class ViewCreateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .objectId() @@ -213,8 +217,7 @@ class ViewCreateParams private constructor( * .viewType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -231,45 +234,37 @@ class ViewCreateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - viewType = body.viewType - deletedAt = body.deletedAt - options = body.options - userId = body.userId - viewData = body.viewData - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + viewType = body.viewType + deletedAt = body.deletedAt + options = body.options + userId = body.userId + viewData = body.viewData + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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)) @@ -278,10 +273,7 @@ class ViewCreateParams private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = - apply { - this.viewType = viewType - } + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -290,10 +282,9 @@ class ViewCreateParams private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -302,10 +293,7 @@ class ViewCreateParams private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = - apply { - this.options = options - } + fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -314,10 +302,7 @@ class ViewCreateParams private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -326,65 +311,47 @@ class ViewCreateParams private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = - apply { - this.viewData = viewData - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - checkRequired( - "viewType", viewType - ), - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + checkRequired("viewType", viewType), + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -393,7 +360,8 @@ class ViewCreateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -404,7 +372,6 @@ class ViewCreateParams private constructor( * Returns a mutable builder for constructing an instance of [ViewCreateParams]. * * The following fields are required: - * * ```java * .name() * .objectId() @@ -412,8 +379,7 @@ class ViewCreateParams private constructor( * .viewType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewCreateParams]. */ @@ -425,299 +391,208 @@ class ViewCreateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewCreateParams: ViewCreateParams) = - apply { - body = viewCreateParams.body.toBuilder() - additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() - } + internal fun from(viewCreateParams: ViewCreateParams) = apply { + body = viewCreateParams.body.toBuilder() + additionalHeaders = viewCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewCreateParams.additionalQueryParams.toBuilder() + } /** Name of the view */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the view */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the view applies to */ - fun objectId(objectId: String) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: String) = apply { body.objectId(objectId) } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - body.objectId(objectId) - } + 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: ObjectType) = 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) - } + fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = - apply { - body.viewType(viewType) - } + fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime?) = - apply { - body.deletedAt(deletedAt) - } + fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - body.deletedAt(deletedAt) - } + fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } /** Options for the view in the app */ - fun options(options: ViewOptions?) = - apply { - body.options(options) - } + fun options(options: ViewOptions?) = apply { body.options(options) } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = - apply { - body.options(options) - } + fun options(options: JsonField) = apply { body.options(options) } /** Identifies the user who created the view */ - fun userId(userId: String?) = - apply { - body.userId(userId) - } + fun userId(userId: String?) = apply { body.userId(userId) } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = - apply { - body.userId(userId) - } + fun userId(userId: JsonField) = apply { body.userId(userId) } /** The view definition */ - fun viewData(viewData: ViewData?) = - apply { - body.viewData(viewData) - } + fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = - apply { - body.viewData(viewData) - } + fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewCreateParams = - ViewCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + 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 { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -765,11 +640,9 @@ class ViewCreateParams private constructor( * 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 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 { @@ -785,18 +658,17 @@ class ViewCreateParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -817,11 +689,11 @@ class ViewCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -842,20 +714,23 @@ class ViewCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -864,21 +739,17 @@ class ViewCreateParams private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -917,11 +788,9 @@ class ViewCreateParams private constructor( * 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 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 { @@ -933,19 +802,16 @@ class ViewCreateParams private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** - * An enum member indicating that [ViewType] was instantiated with an unknown - * value. - */ + /** 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. + * 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. + * 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) { @@ -963,11 +829,11 @@ class ViewCreateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -985,20 +851,23 @@ class ViewCreateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1007,14 +876,15 @@ class ViewCreateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ViewCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ViewCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 02851ff5..70d0d8ce 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -19,17 +19,18 @@ import kotlin.jvm.optionals.getOrNull /** The view definition */ @NoAutoDetect -class ViewData @JsonCreator private constructor( - @JsonProperty("search") @ExcludeMissing private val search: JsonField = JsonMissing.of(), +class ViewData +@JsonCreator +private constructor( + @JsonProperty("search") + @ExcludeMissing + private val search: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun search(): Optional = Optional.ofNullable(search.getNullable("search")) - @JsonProperty("search") - @ExcludeMissing - fun _search(): JsonField = search + @JsonProperty("search") @ExcludeMissing fun _search(): JsonField = search @JsonAnyGetter @ExcludeMissing @@ -37,23 +38,21 @@ class ViewData @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ViewData = - apply { - if (validated) { - return@apply - } - - search().ifPresent { it.validate() } - validated = true + fun validate(): ViewData = apply { + if (validated) { + return@apply } + search().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewData]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewData]. */ @@ -63,59 +62,45 @@ class ViewData @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewData: ViewData) = - apply { - search = viewData.search - additionalProperties = viewData.additionalProperties.toMutableMap() - } + internal fun from(viewData: ViewData) = apply { + search = viewData.search + additionalProperties = viewData.additionalProperties.toMutableMap() + } fun search(search: ViewDataSearch?) = search(JsonField.ofNullable(search)) fun search(search: Optional) = search(search.getOrNull()) - fun search(search: JsonField) = - apply { - this.search = search - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ViewData = - ViewData( - search, additionalProperties.toImmutable() - ) + fun search(search: JsonField) = apply { this.search = search } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): ViewData = ViewData(search, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewData && search == other.search && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewData && search == other.search && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 96cfd4d0..6d12484b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -19,13 +19,22 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class ViewDataSearch @JsonCreator private constructor( - @JsonProperty("filter") @ExcludeMissing private val filter: JsonField> = JsonMissing.of(), - @JsonProperty("match") @ExcludeMissing private val match: JsonField> = JsonMissing.of(), - @JsonProperty("sort") @ExcludeMissing private val sort: JsonField> = JsonMissing.of(), - @JsonProperty("tag") @ExcludeMissing private val tag: JsonField> = JsonMissing.of(), +class ViewDataSearch +@JsonCreator +private constructor( + @JsonProperty("filter") + @ExcludeMissing + private val filter: JsonField> = JsonMissing.of(), + @JsonProperty("match") + @ExcludeMissing + private val match: JsonField> = JsonMissing.of(), + @JsonProperty("sort") + @ExcludeMissing + private val sort: JsonField> = JsonMissing.of(), + @JsonProperty("tag") + @ExcludeMissing + private val tag: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { fun filter(): Optional> = Optional.ofNullable(filter.getNullable("filter")) @@ -36,21 +45,13 @@ class ViewDataSearch @JsonCreator private constructor( fun tag(): Optional> = Optional.ofNullable(tag.getNullable("tag")) - @JsonProperty("filter") - @ExcludeMissing - fun _filter(): JsonField> = filter + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField> = filter - @JsonProperty("match") - @ExcludeMissing - fun _match(): JsonField> = match + @JsonProperty("match") @ExcludeMissing fun _match(): JsonField> = match - @JsonProperty("sort") - @ExcludeMissing - fun _sort(): JsonField> = sort + @JsonProperty("sort") @ExcludeMissing fun _sort(): JsonField> = sort - @JsonProperty("tag") - @ExcludeMissing - fun _tag(): JsonField> = tag + @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField> = tag @JsonAnyGetter @ExcludeMissing @@ -58,26 +59,24 @@ class ViewDataSearch @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ViewDataSearch = - apply { - if (validated) { - return@apply - } - - filter() - match() - sort() - tag() - validated = true + fun validate(): ViewDataSearch = apply { + if (validated) { + return@apply } + filter() + match() + sort() + tag() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewDataSearch]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewDataSearch]. */ @@ -90,121 +89,107 @@ class ViewDataSearch @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewDataSearch: ViewDataSearch) = - apply { - filter = viewDataSearch.filter.map { it.toMutableList() } - match = viewDataSearch.match.map { it.toMutableList() } - sort = viewDataSearch.sort.map { it.toMutableList() } - tag = viewDataSearch.tag.map { it.toMutableList() } - additionalProperties = viewDataSearch.additionalProperties.toMutableMap() - } + internal fun from(viewDataSearch: ViewDataSearch) = apply { + filter = viewDataSearch.filter.map { it.toMutableList() } + match = viewDataSearch.match.map { it.toMutableList() } + sort = viewDataSearch.sort.map { it.toMutableList() } + tag = viewDataSearch.tag.map { it.toMutableList() } + additionalProperties = viewDataSearch.additionalProperties.toMutableMap() + } fun filter(filter: List?) = filter(JsonField.ofNullable(filter)) fun filter(filter: Optional>) = filter(filter.getOrNull()) - fun filter(filter: JsonField>) = - apply { - this.filter = filter.map { it.toMutableList() } - } + fun filter(filter: JsonField>) = apply { + this.filter = filter.map { it.toMutableList() } + } - fun addFilter(filter: JsonValue) = - apply { - this.filter = (this.filter ?: JsonField.of(mutableListOf())).also { + fun addFilter(filter: JsonValue) = apply { + this.filter = + (this.filter ?: JsonField.of(mutableListOf())).also { checkKnown("filter", it).add(filter) } - } + } fun match(match: List?) = match(JsonField.ofNullable(match)) fun match(match: Optional>) = match(match.getOrNull()) - fun match(match: JsonField>) = - apply { - this.match = match.map { it.toMutableList() } - } + fun match(match: JsonField>) = apply { + this.match = match.map { it.toMutableList() } + } - fun addMatch(match: JsonValue) = - apply { - this.match = (this.match ?: JsonField.of(mutableListOf())).also { + fun addMatch(match: JsonValue) = apply { + this.match = + (this.match ?: JsonField.of(mutableListOf())).also { checkKnown("match", it).add(match) } - } + } fun sort(sort: List?) = sort(JsonField.ofNullable(sort)) fun sort(sort: Optional>) = sort(sort.getOrNull()) - fun sort(sort: JsonField>) = - apply { - this.sort = sort.map { it.toMutableList() } - } + fun sort(sort: JsonField>) = apply { + this.sort = sort.map { it.toMutableList() } + } - fun addSort(sort: JsonValue) = - apply { - this.sort = (this.sort ?: JsonField.of(mutableListOf())).also { + fun addSort(sort: JsonValue) = apply { + this.sort = + (this.sort ?: JsonField.of(mutableListOf())).also { checkKnown("sort", it).add(sort) } - } + } fun tag(tag: List?) = tag(JsonField.ofNullable(tag)) fun tag(tag: Optional>) = tag(tag.getOrNull()) - fun tag(tag: JsonField>) = - apply { - this.tag = tag.map { it.toMutableList() } - } + fun tag(tag: JsonField>) = apply { + this.tag = tag.map { it.toMutableList() } + } - fun addTag(tag: JsonValue) = - apply { - this.tag = (this.tag ?: JsonField.of(mutableListOf())).also { - checkKnown("tag", it).add(tag) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun addTag(tag: JsonValue) = apply { + this.tag = + (this.tag ?: JsonField.of(mutableListOf())).also { checkKnown("tag", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ViewDataSearch = ViewDataSearch( - (filter ?: JsonMissing.of()).map { it.toImmutable() }, - (match ?: JsonMissing.of()).map { it.toImmutable() }, - (sort ?: JsonMissing.of()).map { it.toImmutable() }, - (tag ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), + (filter ?: JsonMissing.of()).map { it.toImmutable() }, + (match ?: JsonMissing.of()).map { it.toImmutable() }, + (sort ?: JsonMissing.of()).map { it.toImmutable() }, + (tag ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewDataSearch && filter == other.filter && match == other.match && sort == other.sort && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewDataSearch && filter == other.filter && match == other.match && sort == other.sort && tag == other.tag && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -213,5 +198,6 @@ class ViewDataSearch @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ViewDataSearch{filter=$filter, match=$match, sort=$sort, tag=$tag, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewDataSearch{filter=$filter, match=$match, sort=$sort, tag=$tag, additionalProperties=$additionalProperties}" } 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 d6cc9336..fa0585c3 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 @@ -22,12 +22,12 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Objects /** Delete a view object by its id */ -class ViewDeleteParams private constructor( +class ViewDeleteParams +private constructor( private val viewId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** View id */ @@ -51,26 +51,31 @@ class ViewDeleteParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the view applies to */ @@ -80,9 +85,7 @@ class ViewDeleteParams private constructor( fun objectType(): ObjectType = objectType.getRequired("object_type") /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -95,17 +98,16 @@ class ViewDeleteParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + objectId() + objectType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -114,14 +116,12 @@ class ViewDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -132,75 +132,59 @@ class ViewDeleteParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - objectId = body.objectId - objectType = body.objectType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + objectId = body.objectId + objectType = body.objectType + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = - apply { - this.objectType = objectType - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -209,7 +193,8 @@ class ViewDeleteParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -220,15 +205,13 @@ class ViewDeleteParams private constructor( * Returns a mutable builder for constructing an instance of [ViewDeleteParams]. * * The following fields are required: - * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewDeleteParams]. */ @@ -241,222 +224,166 @@ class ViewDeleteParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewDeleteParams: ViewDeleteParams) = - apply { - viewId = viewDeleteParams.viewId - body = viewDeleteParams.body.toBuilder() - additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() - } + internal fun from(viewDeleteParams: ViewDeleteParams) = apply { + viewId = viewDeleteParams.viewId + body = viewDeleteParams.body.toBuilder() + additionalHeaders = viewDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = viewDeleteParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = - apply { - this.viewId = viewId - } + fun viewId(viewId: String) = apply { this.viewId = viewId } /** The id of the object the view applies to */ - fun objectId(objectId: String) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: String) = apply { body.objectId(objectId) } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - body.objectId(objectId) - } + 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: ObjectType) = 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) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewDeleteParams = ViewDeleteParams( - checkRequired( - "viewId", viewId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("viewId", viewId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -504,11 +431,9 @@ class ViewDeleteParams private constructor( * 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 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 { @@ -524,18 +449,17 @@ class ViewDeleteParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -556,11 +480,11 @@ class ViewDeleteParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -581,20 +505,23 @@ class ViewDeleteParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -603,14 +530,15 @@ class ViewDeleteParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewDeleteParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ViewDeleteParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ViewDeleteParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index 5ad0e959..fde4f5ac 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -9,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.models import com.braintrustdata.api.services.blocking.ViewService import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -22,14 +21,14 @@ import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created views + * coming first */ -class ViewListPage private constructor( +class ViewListPage +private constructor( private val viewsService: ViewService, private val params: ViewListParams, private val response: Response, - ) { fun response(): Response = response @@ -37,35 +36,40 @@ class ViewListPage private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListPage && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ViewListPage && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ - override fun toString() = "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" + override fun toString() = + "ViewListPage{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ViewListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ViewListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): Optional { - return getNextPageParams().map { viewsService.list(it) } + return getNextPageParams().map { viewsService.list(it) } } fun autoPager(): AutoPager = AutoPager(this) @@ -74,18 +78,16 @@ class ViewListPage private constructor( @JvmStatic fun of(viewsService: ViewService, params: ViewListParams, response: Response) = - ViewListPage( - viewsService, - params, - response, - ) + ViewListPage(viewsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -99,35 +101,34 @@ class ViewListPage private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ViewListPage]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -136,48 +137,39 @@ class ViewListPage private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ViewListPage, + class AutoPager(private val firstPage: ViewListPage) : Iterable { - ) : Iterable { - - override fun iterator(): Iterator = - iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { yield(page.objects()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 } + page = page.getNextPage().getOrNull() ?: break + index = 0 } + } fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) + return StreamSupport.stream(spliterator(), false) } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index 6fec64a6..0a5f58fb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -9,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.models import com.braintrustdata.api.services.async.ViewServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,19 +19,16 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created views + * coming first */ -class ViewListPageAsync private constructor( +class ViewListPageAsync +private constructor( private val viewsService: ViewServiceAsync, private val params: ViewListParams, private val response: Response, - ) { fun response(): Response = response @@ -40,39 +36,42 @@ class ViewListPageAsync private constructor( fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListPageAsync && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ViewListPageAsync && viewsService == other.viewsService && params == other.params && response == other.response /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewsService, params, response) /* spotless:on */ - override fun toString() = "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" + override fun toString() = + "ViewListPageAsync{viewsService=$viewsService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } - - return if (params.endingBefore().isPresent) { - Optional.of(ViewListParams.builder().from(params).endingBefore(objects().first().id()).build()); - } else { - Optional.of(ViewListParams.builder().from(params).startingAfter(objects().last().id()).build()); - } + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() + ) + } else { + Optional.of( + ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() + ) + } } fun getNextPage(): CompletableFuture> { - return getNextPageParams().map { - viewsService.list(it).thenApply { Optional.of(it) } - }.orElseGet { - CompletableFuture.completedFuture(Optional.empty()) - } + return getNextPageParams() + .map { viewsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } } fun autoPager(): AutoPager = AutoPager(this) @@ -81,18 +80,16 @@ class ViewListPageAsync private constructor( @JvmStatic fun of(viewsService: ViewServiceAsync, params: ViewListParams, response: Response) = - ViewListPageAsync( - viewsService, - params, - response, - ) + ViewListPageAsync(viewsService, params, response) } @NoAutoDetect - class Response @JsonCreator constructor( + class Response + @JsonCreator + constructor( @JsonProperty("objects") private val objects: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { fun objects(): List = objects.getNullable("objects") ?: listOf() @@ -106,35 +103,34 @@ class ViewListPageAsync private constructor( private var validated: Boolean = false - fun validate(): Response = - apply { - if (validated) { - return@apply - } - - objects().map { it.validate() } - validated = true + fun validate(): Response = apply { + if (validated) { + return@apply } + objects().map { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Response && objects == other.objects && additionalProperties == other.additionalProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objects, additionalProperties) /* spotless:on */ - override fun toString() = "Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = + "Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { /** Returns a mutable builder for constructing an instance of [ViewListPageAsync]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } class Builder { @@ -143,63 +139,46 @@ class ViewListPageAsync private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(page: Response) = - apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } + internal fun from(page: Response) = apply { + this.objects = page.objects + this.additionalProperties.putAll(page.additionalProperties) + } fun objects(objects: List) = objects(JsonField.of(objects)) fun objects(objects: JsonField>) = apply { this.objects = objects } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun build() = - Response( - objects, additionalProperties.toImmutable() - ) + fun build() = Response(objects, additionalProperties.toImmutable()) } } - class AutoPager( - private val firstPage: ViewListPageAsync, - - ) { + class AutoPager(private val firstPage: ViewListPageAsync) { fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach(action: (View) -> Boolean, executor: Executor): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { - it.objects().all(action) - } - .map { - it.getNextPage().forEach(action, executor) - } - .orElseGet { - CompletableFuture.completedFuture(null) - } - }, executor - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach( - action::test, executor - ) + fun CompletableFuture>.forEach( + action: (View) -> Boolean, + executor: Executor, + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.objects().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor, + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) } fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach( - values::add, executor - ) - .thenApply { - values - } + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } } } } 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 dc8f6cda..3dd24391 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 @@ -27,10 +27,11 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created views + * coming first */ -class ViewListParams private constructor( +class ViewListParams +private constructor( private val objectId: String, private val objectType: ObjectType, private val endingBefore: String?, @@ -41,7 +42,6 @@ class ViewListParams private constructor( private val viewType: ViewType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** The id of the object the ACL applies to */ @@ -53,15 +53,15 @@ class ViewListParams private constructor( /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ fun ids(): Optional = Optional.ofNullable(ids) @@ -71,9 +71,9 @@ class ViewListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` + * and `ending_before` */ fun startingAfter(): Optional = Optional.ofNullable(startingAfter) @@ -90,49 +90,17 @@ class ViewListParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { - queryParams.put( - "object_id", listOf(it.toString()) - ) - } - this.objectType.let { - queryParams.put( - "object_type", listOf(it.toString()) - ) - } - this.endingBefore?.let { - queryParams.put( - "ending_before", listOf(it.toString()) - ) - } - this.ids?.let { - queryParams.put( - "ids", listOf(it.toString()) - ) - } - this.limit?.let { - queryParams.put( - "limit", listOf(it.toString()) - ) - } - this.startingAfter?.let { - queryParams.put( - "starting_after", listOf(it.toString()) - ) - } - this.viewName?.let { - queryParams.put( - "view_name", listOf(it.toString()) - ) - } - this.viewType?.let { - queryParams.put( - "view_type", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } + this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } + this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } + this.ids?.let { queryParams.put("ids", listOf(it.toString())) } + this.limit?.let { queryParams.put("limit", listOf(it.toString())) } + this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } + this.viewName?.let { queryParams.put("view_name", listOf(it.toString())) } + this.viewType?.let { queryParams.put("view_type", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun toBuilder() = Builder().from(this) @@ -143,14 +111,12 @@ class ViewListParams private constructor( * Returns a mutable builder for constructing an instance of [ViewListParams]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewListParams]. */ @@ -169,85 +135,69 @@ class ViewListParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewListParams: ViewListParams) = - apply { - objectId = viewListParams.objectId - objectType = viewListParams.objectType - endingBefore = viewListParams.endingBefore - ids = viewListParams.ids - limit = viewListParams.limit - startingAfter = viewListParams.startingAfter - viewName = viewListParams.viewName - viewType = viewListParams.viewType - additionalHeaders = viewListParams.additionalHeaders.toBuilder() - additionalQueryParams = viewListParams.additionalQueryParams.toBuilder() - } + internal fun from(viewListParams: ViewListParams) = apply { + objectId = viewListParams.objectId + objectType = viewListParams.objectType + endingBefore = viewListParams.endingBefore + ids = viewListParams.ids + limit = viewListParams.limit + startingAfter = viewListParams.startingAfter + viewName = viewListParams.viewName + viewType = viewListParams.viewType + additionalHeaders = viewListParams.additionalHeaders.toBuilder() + additionalQueryParams = viewListParams.additionalQueryParams.toBuilder() + } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = - apply { - this.objectId = objectId - } + 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: ObjectType) = apply { this.objectType = objectType } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ - fun endingBefore(endingBefore: String?) = - apply { - this.endingBefore = endingBefore - } + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of - * `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only - * pass one of `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an id of `foo`, pass + * `ending_before=foo` to fetch the previous page. Note: you may only pass one of + * `starting_after` and `ending_before` */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ - fun ids(ids: Ids?) = - apply { - this.ids = ids - } + fun ids(ids: Ids?) = apply { this.ids = ids } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(ids: Optional) = ids(ids.getOrNull()) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun ids(string: String) = ids(Ids.ofString(string)) /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, + * include the query param multiple times */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ - fun limit(limit: Long?) = - apply { - this.limit = limit - } + fun limit(limit: Long?) = apply { this.limit = limit } /** Limit the number of objects to return */ fun limit(limit: Long) = limit(limit as Long?) @@ -258,201 +208,159 @@ class ViewListParams private constructor( /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: String?) = - apply { - this.startingAfter = startingAfter - } + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, - * pass `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an id of `foo`, pass + * `starting_after=foo` to fetch the next page. Note: you may only pass one of * `starting_after` and `ending_before` */ - fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) /** Name of the view to search for */ - fun viewName(viewName: String?) = - apply { - this.viewName = viewName - } + fun viewName(viewName: String?) = apply { this.viewName = viewName } /** Name of the view to search for */ fun viewName(viewName: Optional) = viewName(viewName.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType?) = - apply { - this.viewType = viewType - } + fun viewType(viewType: ViewType?) = apply { this.viewType = viewType } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewListParams = ViewListParams( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - endingBefore, - ids, - limit, - startingAfter, - viewName, - viewType, - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + endingBefore, + ids, + limit, + startingAfter, + viewName, + viewType, + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -500,11 +408,9 @@ class ViewListParams private constructor( * 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 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 { @@ -520,18 +426,17 @@ class ViewListParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -552,11 +457,11 @@ class ViewListParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -577,20 +482,23 @@ class ViewListParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -599,16 +507,16 @@ class ViewListParams private constructor( } /** - * Filter search results to a particular set of object IDs. To specify a list of - * IDs, include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of IDs, include + * the query param multiple times */ @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids private constructor( + class Ids + private constructor( private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, - ) { fun string(): Optional = Optional.ofNullable(string) @@ -626,19 +534,19 @@ class ViewListParams private constructor( fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ + return /* spotless:off */ other is Ids && string == other.string && strings == other.strings /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, strings) /* spotless:on */ @@ -653,17 +561,12 @@ class ViewListParams private constructor( companion object { - @JvmStatic - fun ofString(string: String) = Ids(string = string) + @JvmStatic fun ofString(string: String) = Ids(string = string) - @JvmStatic - fun ofStrings(strings: List) = Ids(strings = strings) + @JvmStatic fun ofStrings(strings: List) = Ids(strings = strings) } - /** - * An interface that defines how to map each variant of [Ids] to a value of type - * [T]. - */ + /** An interface that defines how to map each variant of [Ids] to a value of type [T]. */ interface Visitor { fun visitString(string: String): T @@ -673,63 +576,62 @@ class ViewListParams private constructor( /** * Maps an unknown variant of [Ids] to a value of type [T]. * - * An instance of [Ids] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [Ids] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws BraintrustInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } internal class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) + val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } - return Ids(_json = json) + return Ids(_json = json) } } internal class Serializer : BaseSerializer(Ids::class) { - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize( + value: Ids, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -768,11 +670,9 @@ class ViewListParams private constructor( * 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 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 { @@ -784,19 +684,16 @@ class ViewListParams private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** - * An enum member indicating that [ViewType] was instantiated with an unknown - * value. - */ + /** 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. + * 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. + * 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) { @@ -814,11 +711,11 @@ class ViewListParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -836,20 +733,23 @@ class ViewListParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -858,14 +758,15 @@ class ViewListParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewListParams && objectId == other.objectId && objectType == other.objectType && endingBefore == other.endingBefore && ids == other.ids && limit == other.limit && startingAfter == other.startingAfter && viewName == other.viewName && viewType == other.viewType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectId, objectType, endingBefore, ids, limit, startingAfter, viewName, viewType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index c4b9cff4..731eab40 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -20,19 +20,29 @@ import kotlin.jvm.optionals.getOrNull /** Options for the view in the app */ @NoAutoDetect -class ViewOptions @JsonCreator private constructor( - @JsonProperty("columnOrder") @ExcludeMissing private val columnOrder: JsonField> = JsonMissing.of(), - @JsonProperty("columnSizing") @ExcludeMissing private val columnSizing: JsonField = JsonMissing.of(), - @JsonProperty("columnVisibility") @ExcludeMissing private val columnVisibility: JsonField = JsonMissing.of(), +class ViewOptions +@JsonCreator +private constructor( + @JsonProperty("columnOrder") + @ExcludeMissing + private val columnOrder: JsonField> = JsonMissing.of(), + @JsonProperty("columnSizing") + @ExcludeMissing + private val columnSizing: JsonField = JsonMissing.of(), + @JsonProperty("columnVisibility") + @ExcludeMissing + private val columnVisibility: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - ) { - fun columnOrder(): Optional> = Optional.ofNullable(columnOrder.getNullable("columnOrder")) + fun columnOrder(): Optional> = + Optional.ofNullable(columnOrder.getNullable("columnOrder")) - fun columnSizing(): Optional = Optional.ofNullable(columnSizing.getNullable("columnSizing")) + fun columnSizing(): Optional = + Optional.ofNullable(columnSizing.getNullable("columnSizing")) - fun columnVisibility(): Optional = Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) + fun columnVisibility(): Optional = + Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) @JsonProperty("columnOrder") @ExcludeMissing @@ -52,25 +62,23 @@ class ViewOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ViewOptions = - apply { - if (validated) { - return@apply - } - - columnOrder() - columnSizing().ifPresent { it.validate() } - columnVisibility().ifPresent { it.validate() } - validated = true + fun validate(): ViewOptions = apply { + if (validated) { + return@apply } + columnOrder() + columnSizing().ifPresent { it.validate() } + columnVisibility().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ViewOptions]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewOptions]. */ @@ -82,87 +90,82 @@ class ViewOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(viewOptions: ViewOptions) = - apply { - columnOrder = viewOptions.columnOrder.map { it.toMutableList() } - columnSizing = viewOptions.columnSizing - columnVisibility = viewOptions.columnVisibility - additionalProperties = viewOptions.additionalProperties.toMutableMap() - } + internal fun from(viewOptions: ViewOptions) = apply { + columnOrder = viewOptions.columnOrder.map { it.toMutableList() } + columnSizing = viewOptions.columnSizing + columnVisibility = viewOptions.columnVisibility + additionalProperties = viewOptions.additionalProperties.toMutableMap() + } fun columnOrder(columnOrder: List?) = columnOrder(JsonField.ofNullable(columnOrder)) fun columnOrder(columnOrder: Optional>) = columnOrder(columnOrder.getOrNull()) - fun columnOrder(columnOrder: JsonField>) = - apply { - this.columnOrder = columnOrder.map { it.toMutableList() } - } + fun columnOrder(columnOrder: JsonField>) = apply { + this.columnOrder = columnOrder.map { it.toMutableList() } + } - fun addColumnOrder(columnOrder: String) = - apply { - this.columnOrder = (this.columnOrder ?: JsonField.of(mutableListOf())).also { + fun addColumnOrder(columnOrder: String) = apply { + this.columnOrder = + (this.columnOrder ?: JsonField.of(mutableListOf())).also { checkKnown("columnOrder", it).add(columnOrder) } - } + } - fun columnSizing(columnSizing: ColumnSizing?) = columnSizing(JsonField.ofNullable(columnSizing)) + fun columnSizing(columnSizing: ColumnSizing?) = + columnSizing(JsonField.ofNullable(columnSizing)) - fun columnSizing(columnSizing: Optional) = columnSizing(columnSizing.getOrNull()) + fun columnSizing(columnSizing: Optional) = + columnSizing(columnSizing.getOrNull()) - fun columnSizing(columnSizing: JsonField) = - apply { - this.columnSizing = columnSizing - } + fun columnSizing(columnSizing: JsonField) = apply { + this.columnSizing = columnSizing + } - fun columnVisibility(columnVisibility: ColumnVisibility?) = columnVisibility(JsonField.ofNullable(columnVisibility)) + fun columnVisibility(columnVisibility: ColumnVisibility?) = + columnVisibility(JsonField.ofNullable(columnVisibility)) - fun columnVisibility(columnVisibility: Optional) = columnVisibility(columnVisibility.getOrNull()) + fun columnVisibility(columnVisibility: Optional) = + columnVisibility(columnVisibility.getOrNull()) - fun columnVisibility(columnVisibility: JsonField) = - apply { - this.columnVisibility = columnVisibility - } + fun columnVisibility(columnVisibility: JsonField) = apply { + this.columnVisibility = columnVisibility + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ViewOptions = ViewOptions( - (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, - columnSizing, - columnVisibility, - additionalProperties.toImmutable(), + (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, + columnSizing, + columnVisibility, + additionalProperties.toImmutable(), ) } @NoAutoDetect - class ColumnSizing @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class ColumnSizing + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -171,22 +174,20 @@ class ViewOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ColumnSizing = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): ColumnSizing = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ColumnSizing]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ColumnSizing]. */ @@ -195,46 +196,38 @@ class ViewOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(columnSizing: ColumnSizing) = - apply { - additionalProperties = columnSizing.additionalProperties.toMutableMap() - } + internal fun from(columnSizing: ColumnSizing) = apply { + additionalProperties = columnSizing.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ColumnSizing = ColumnSizing(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ColumnSizing && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ColumnSizing && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -247,9 +240,11 @@ class ViewOptions @JsonCreator private constructor( } @NoAutoDetect - class ColumnVisibility @JsonCreator private constructor( - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class ColumnVisibility + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() ) { @JsonAnyGetter @@ -258,22 +253,20 @@ class ViewOptions @JsonCreator private constructor( private var validated: Boolean = false - fun validate(): ColumnVisibility = - apply { - if (validated) { - return@apply - } - - validated = true + fun validate(): ColumnVisibility = apply { + if (validated) { + return@apply } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { /** Returns a mutable builder for constructing an instance of [ColumnVisibility]. */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ColumnVisibility]. */ @@ -282,46 +275,38 @@ class ViewOptions @JsonCreator private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(columnVisibility: ColumnVisibility) = - apply { - additionalProperties = columnVisibility.additionalProperties.toMutableMap() - } + internal fun from(columnVisibility: ColumnVisibility) = apply { + additionalProperties = columnVisibility.additionalProperties.toMutableMap() + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ColumnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ColumnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -334,11 +319,11 @@ class ViewOptions @JsonCreator private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -347,5 +332,6 @@ class ViewOptions @JsonCreator private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" + override fun toString() = + "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" } 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 a6b1c015..d99f4f94 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 @@ -25,15 +25,14 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Create or replace view. If there is an existing view with the same name as the - * one specified in the request, will replace the existing view with the provided - * fields + * Create or replace view. If there is an existing view with the same name as the one specified in + * the request, will replace the existing view with the provided fields */ -class ViewReplaceParams private constructor( +class ViewReplaceParams +private constructor( private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** Name of the view */ @@ -90,25 +89,42 @@ class ViewReplaceParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), - @JsonProperty("deleted_at") @ExcludeMissing private val deletedAt: JsonField = JsonMissing.of(), - @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("view_type") + @ExcludeMissing + private val viewType: JsonField = JsonMissing.of(), + @JsonProperty("deleted_at") + @ExcludeMissing + private val deletedAt: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") + @ExcludeMissing + private val viewData: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** Name of the view */ @@ -124,7 +140,8 @@ class ViewReplaceParams private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + fun deletedAt(): Optional = + Optional.ofNullable(deletedAt.getNullable("deleted_at")) /** Options for the view in the app */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) @@ -136,14 +153,10 @@ class ViewReplaceParams private constructor( fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) /** Name of the view */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -151,9 +164,7 @@ class ViewReplaceParams private constructor( fun _objectType(): JsonField = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - @ExcludeMissing - fun _viewType(): JsonField = viewType + @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @@ -161,19 +172,13 @@ class ViewReplaceParams private constructor( fun _deletedAt(): JsonField = deletedAt /** Options for the view in the app */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): JsonField = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") - @ExcludeMissing - fun _viewData(): JsonField = viewData + @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @ExcludeMissing @@ -181,23 +186,22 @@ class ViewReplaceParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - name() - objectId() - objectType() - viewType() - deletedAt() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + name() + objectId() + objectType() + viewType() + deletedAt() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -206,7 +210,6 @@ class ViewReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .name() * .objectId() @@ -214,8 +217,7 @@ class ViewReplaceParams private constructor( * .viewType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -232,45 +234,37 @@ class ViewReplaceParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - name = body.name - objectId = body.objectId - objectType = body.objectType - viewType = body.viewType - deletedAt = body.deletedAt - options = body.options - userId = body.userId - viewData = body.viewData - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + name = body.name + objectId = body.objectId + objectType = body.objectType + viewType = body.viewType + deletedAt = body.deletedAt + options = body.options + userId = body.userId + viewData = body.viewData + additionalProperties = body.additionalProperties.toMutableMap() + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) /** Name of the view */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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)) @@ -279,10 +273,7 @@ class ViewReplaceParams private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = - apply { - this.viewType = viewType - } + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) @@ -291,10 +282,9 @@ class ViewReplaceParams private constructor( fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - this.deletedAt = deletedAt - } + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -303,10 +293,7 @@ class ViewReplaceParams private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = - apply { - this.options = options - } + fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -315,10 +302,7 @@ class ViewReplaceParams private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -327,65 +311,47 @@ class ViewReplaceParams private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = - apply { - this.viewData = viewData - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "name", name - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - checkRequired( - "viewType", viewType - ), - deletedAt, - options, - userId, - viewData, - additionalProperties.toImmutable(), + checkRequired("name", name), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + checkRequired("viewType", viewType), + deletedAt, + options, + userId, + viewData, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && name == other.name && objectId == other.objectId && objectType == other.objectType && viewType == other.viewType && deletedAt == other.deletedAt && options == other.options && userId == other.userId && viewData == other.viewData && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -394,7 +360,8 @@ class ViewReplaceParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -405,7 +372,6 @@ class ViewReplaceParams private constructor( * Returns a mutable builder for constructing an instance of [ViewReplaceParams]. * * The following fields are required: - * * ```java * .name() * .objectId() @@ -413,8 +379,7 @@ class ViewReplaceParams private constructor( * .viewType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewReplaceParams]. */ @@ -426,299 +391,212 @@ class ViewReplaceParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewReplaceParams: ViewReplaceParams) = - apply { - body = viewReplaceParams.body.toBuilder() - additionalHeaders = viewReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = viewReplaceParams.additionalQueryParams.toBuilder() - } + internal fun from(viewReplaceParams: ViewReplaceParams) = apply { + body = viewReplaceParams.body.toBuilder() + additionalHeaders = viewReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = viewReplaceParams.additionalQueryParams.toBuilder() + } /** Name of the view */ - fun name(name: String) = - apply { - body.name(name) - } + fun name(name: String) = apply { body.name(name) } /** Name of the view */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the view applies to */ - fun objectId(objectId: String) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: String) = apply { body.objectId(objectId) } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - body.objectId(objectId) - } + 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: ObjectType) = 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) - } + fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = - apply { - body.viewType(viewType) - } + fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime?) = - apply { - body.deletedAt(deletedAt) - } + fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: JsonField) = - apply { - body.deletedAt(deletedAt) - } + fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } /** Options for the view in the app */ - fun options(options: ViewOptions?) = - apply { - body.options(options) - } + fun options(options: ViewOptions?) = apply { body.options(options) } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = - apply { - body.options(options) - } + fun options(options: JsonField) = apply { body.options(options) } /** Identifies the user who created the view */ - fun userId(userId: String?) = - apply { - body.userId(userId) - } + fun userId(userId: String?) = apply { body.userId(userId) } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = - apply { - body.userId(userId) - } + fun userId(userId: JsonField) = apply { body.userId(userId) } /** The view definition */ - fun viewData(viewData: ViewData?) = - apply { - body.viewData(viewData) - } + fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = - apply { - body.viewData(viewData) - } + fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewReplaceParams = ViewReplaceParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -766,11 +644,9 @@ class ViewReplaceParams private constructor( * 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 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 { @@ -786,18 +662,17 @@ class ViewReplaceParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -818,11 +693,11 @@ class ViewReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -843,20 +718,23 @@ class ViewReplaceParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -865,21 +743,17 @@ class ViewReplaceParams private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -918,11 +792,9 @@ class ViewReplaceParams private constructor( * 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 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 { @@ -934,19 +806,16 @@ class ViewReplaceParams private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** - * An enum member indicating that [ViewType] was instantiated with an unknown - * value. - */ + /** 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. + * 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. + * 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) { @@ -964,11 +833,11 @@ class ViewReplaceParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -986,20 +855,23 @@ class ViewReplaceParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1008,14 +880,15 @@ class ViewReplaceParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewReplaceParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ViewReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ViewReplaceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 4b814372..84f0af7c 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 @@ -14,13 +14,13 @@ import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects /** Get a view object by its id */ -class ViewRetrieveParams private constructor( +class ViewRetrieveParams +private constructor( private val viewId: String, private val objectId: String, private val objectType: ObjectType, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** View id */ @@ -39,26 +39,18 @@ class ViewRetrieveParams private constructor( override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { - queryParams.put( - "object_id", listOf(it.toString()) - ) - } - this.objectType.let { - queryParams.put( - "object_type", listOf(it.toString()) - ) - } - queryParams.putAll(additionalQueryParams) - return queryParams.build() + val queryParams = QueryParams.builder() + this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } + this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } + queryParams.putAll(additionalQueryParams) + return queryParams.build() } fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } fun toBuilder() = Builder().from(this) @@ -69,15 +61,13 @@ class ViewRetrieveParams private constructor( * Returns a mutable builder for constructing an instance of [ViewRetrieveParams]. * * The following fields are required: - * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewRetrieveParams]. */ @@ -91,189 +81,143 @@ class ViewRetrieveParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewRetrieveParams: ViewRetrieveParams) = - apply { - viewId = viewRetrieveParams.viewId - objectId = viewRetrieveParams.objectId - objectType = viewRetrieveParams.objectType - additionalHeaders = viewRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = viewRetrieveParams.additionalQueryParams.toBuilder() - } + internal fun from(viewRetrieveParams: ViewRetrieveParams) = apply { + viewId = viewRetrieveParams.viewId + objectId = viewRetrieveParams.objectId + objectType = viewRetrieveParams.objectType + additionalHeaders = viewRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = viewRetrieveParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = - apply { - this.viewId = viewId - } + fun viewId(viewId: String) = apply { this.viewId = viewId } /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = - apply { - this.objectId = objectId - } + 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: ObjectType) = apply { this.objectType = objectType } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewRetrieveParams = ViewRetrieveParams( - checkRequired( - "viewId", viewId - ), - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("viewId", viewId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -321,11 +265,9 @@ class ViewRetrieveParams private constructor( * 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 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 { @@ -341,18 +283,17 @@ class ViewRetrieveParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -373,11 +314,11 @@ class ViewRetrieveParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -398,20 +339,23 @@ class ViewRetrieveParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -420,14 +364,15 @@ class ViewRetrieveParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewRetrieveParams && viewId == other.viewId && objectId == other.objectId && objectType == other.objectType && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, objectId, objectType, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 de7d0da8..368c4698 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 @@ -24,16 +24,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * Partially update a view object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields or + * setting them to null. */ -class ViewUpdateParams private constructor( +class ViewUpdateParams +private constructor( private val viewId: String, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - ) : Params { /** View id */ @@ -87,31 +87,46 @@ class ViewUpdateParams private constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic - internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): Body = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @NoAutoDetect - class Body @JsonCreator private constructor( - @JsonProperty("object_id") @ExcludeMissing private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") @ExcludeMissing private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("options") @ExcludeMissing private val options: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing private val userId: JsonField = JsonMissing.of(), - @JsonProperty("view_data") @ExcludeMissing private val viewData: JsonField = JsonMissing.of(), - @JsonProperty("view_type") @ExcludeMissing private val viewType: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), - + class Body + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonProperty("view_data") + @ExcludeMissing + private val viewData: JsonField = JsonMissing.of(), + @JsonProperty("view_type") + @ExcludeMissing + private val viewType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the object the view applies to */ @@ -136,9 +151,7 @@ class ViewUpdateParams private constructor( fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun _objectId(): JsonField = objectId + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId /** The object type that the ACL applies to */ @JsonProperty("object_type") @@ -146,29 +159,19 @@ class ViewUpdateParams private constructor( fun _objectType(): JsonField = objectType /** Name of the view */ - @JsonProperty("name") - @ExcludeMissing - fun _name(): JsonField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Options for the view in the app */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): JsonField = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options /** Identifies the user who created the view */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId /** The view definition */ - @JsonProperty("view_data") - @ExcludeMissing - fun _viewData(): JsonField = viewData + @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - @ExcludeMissing - fun _viewType(): JsonField = viewType + @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType @JsonAnyGetter @ExcludeMissing @@ -176,22 +179,21 @@ class ViewUpdateParams private constructor( private var validated: Boolean = false - fun validate(): Body = - apply { - if (validated) { - return@apply - } - - objectId() - objectType() - name() - options().ifPresent { it.validate() } - userId() - viewData().ifPresent { it.validate() } - viewType() - validated = true + fun validate(): Body = apply { + if (validated) { + return@apply } + objectId() + objectType() + name() + options().ifPresent { it.validate() } + userId() + viewData().ifPresent { it.validate() } + viewType() + validated = true + } + fun toBuilder() = Builder().from(this) companion object { @@ -200,14 +202,12 @@ class ViewUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [Body]. * * The following fields are required: - * * ```java * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ @@ -223,35 +223,30 @@ class ViewUpdateParams private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = - apply { - objectId = body.objectId - objectType = body.objectType - name = body.name - options = body.options - userId = body.userId - viewData = body.viewData - viewType = body.viewType - additionalProperties = body.additionalProperties.toMutableMap() - } + internal fun from(body: Body) = apply { + objectId = body.objectId + objectType = body.objectType + name = body.name + options = body.options + userId = body.userId + viewData = body.viewData + viewType = body.viewType + additionalProperties = body.additionalProperties.toMutableMap() + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - this.objectId = objectId - } + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = 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 + } /** Name of the view */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -260,10 +255,7 @@ class ViewUpdateParams private constructor( fun name(name: Optional) = name(name.getOrNull()) /** Name of the view */ - fun name(name: JsonField) = - apply { - this.name = name - } + fun name(name: JsonField) = apply { this.name = name } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) @@ -272,10 +264,7 @@ class ViewUpdateParams private constructor( fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = - apply { - this.options = options - } + fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) @@ -284,10 +273,7 @@ class ViewUpdateParams private constructor( fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = - apply { - this.userId = userId - } + fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) @@ -296,10 +282,7 @@ class ViewUpdateParams private constructor( fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = - apply { - this.viewData = viewData - } + fun viewData(viewData: JsonField) = apply { this.viewData = viewData } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) @@ -308,60 +291,46 @@ class ViewUpdateParams private constructor( fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = - apply { - this.viewType = viewType - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = - apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = - apply { - keys.forEach(::removeAdditionalProperty) - } + fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } fun build(): Body = Body( - checkRequired( - "objectId", objectId - ), - checkRequired( - "objectType", objectType - ), - name, - options, - userId, - viewData, - viewType, - additionalProperties.toImmutable(), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + name, + options, + userId, + viewData, + viewType, + additionalProperties.toImmutable(), ) } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && objectId == other.objectId && objectType == other.objectType && name == other.name && options == other.options && userId == other.userId && viewData == other.viewData && viewType == other.viewType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -370,7 +339,8 @@ class ViewUpdateParams private constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Body{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -381,15 +351,13 @@ class ViewUpdateParams private constructor( * Returns a mutable builder for constructing an instance of [ViewUpdateParams]. * * The following fields are required: - * * ```java * .viewId() * .objectId() * .objectType() * ``` */ - @JvmStatic - fun builder() = Builder() + @JvmStatic fun builder() = Builder() } /** A builder for [ViewUpdateParams]. */ @@ -402,297 +370,211 @@ class ViewUpdateParams private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(viewUpdateParams: ViewUpdateParams) = - apply { - viewId = viewUpdateParams.viewId - body = viewUpdateParams.body.toBuilder() - additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() - } + internal fun from(viewUpdateParams: ViewUpdateParams) = apply { + viewId = viewUpdateParams.viewId + body = viewUpdateParams.body.toBuilder() + additionalHeaders = viewUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = viewUpdateParams.additionalQueryParams.toBuilder() + } /** View id */ - fun viewId(viewId: String) = - apply { - this.viewId = viewId - } + fun viewId(viewId: String) = apply { this.viewId = viewId } /** The id of the object the view applies to */ - fun objectId(objectId: String) = - apply { - body.objectId(objectId) - } + fun objectId(objectId: String) = apply { body.objectId(objectId) } /** The id of the object the view applies to */ - fun objectId(objectId: JsonField) = - apply { - body.objectId(objectId) - } + 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: ObjectType) = 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) - } + fun name(name: String?) = apply { body.name(name) } /** Name of the view */ fun name(name: Optional) = name(name.getOrNull()) /** Name of the view */ - fun name(name: JsonField) = - apply { - body.name(name) - } + fun name(name: JsonField) = apply { body.name(name) } /** Options for the view in the app */ - fun options(options: ViewOptions?) = - apply { - body.options(options) - } + fun options(options: ViewOptions?) = apply { body.options(options) } /** Options for the view in the app */ fun options(options: Optional) = options(options.getOrNull()) /** Options for the view in the app */ - fun options(options: JsonField) = - apply { - body.options(options) - } + fun options(options: JsonField) = apply { body.options(options) } /** Identifies the user who created the view */ - fun userId(userId: String?) = - apply { - body.userId(userId) - } + fun userId(userId: String?) = apply { body.userId(userId) } /** Identifies the user who created the view */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** Identifies the user who created the view */ - fun userId(userId: JsonField) = - apply { - body.userId(userId) - } + fun userId(userId: JsonField) = apply { body.userId(userId) } /** The view definition */ - fun viewData(viewData: ViewData?) = - apply { - body.viewData(viewData) - } + fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } /** The view definition */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) /** The view definition */ - fun viewData(viewData: JsonField) = - apply { - body.viewData(viewData) - } + fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType?) = - apply { - body.viewType(viewType) - } + fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } /** Type of table that the view corresponds to. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) /** Type of table that the view corresponds to. */ - fun viewType(viewType: JsonField) = - apply { - body.viewType(viewType) - } + fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } - fun additionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.additionalProperties(additionalBodyProperties) - } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - fun putAdditionalBodyProperty(key: String, value: JsonValue) = - apply { - body.putAdditionalProperty( - key, value - ) - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { body.putAllAdditionalProperties(additionalBodyProperties) } - fun removeAdditionalBodyProperty(key: String) = - apply { - body.removeAdditionalProperty(key) - } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAllAdditionalBodyProperties(keys: Set) = - apply { - body.removeAllAdditionalProperties(keys) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun additionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun additionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - fun putAdditionalHeader(name: String, value: String) = - apply { - additionalHeaders.put(name, value) - } + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun putAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.put(name, values) - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - fun putAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun replaceAdditionalHeaders(name: String, value: String) = - apply { - additionalHeaders.replace(name, value) - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = - apply { - additionalHeaders.replace(name, values) - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = - apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - fun removeAdditionalHeaders(name: String) = - apply { - additionalHeaders.remove(name) - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun removeAllAdditionalHeaders(names: Set) = - apply { - additionalHeaders.removeAll(names) - } + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun additionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - fun putAdditionalQueryParam(key: String, value: String) = - apply { - additionalQueryParams.put(key, value) - } + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - fun putAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.put(key, values) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.putAll(additionalQueryParams) } - fun replaceAdditionalQueryParams(key: String, value: String) = - apply { - additionalQueryParams.replace(key, value) - } + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - fun replaceAdditionalQueryParams(key: String, values: Iterable) = - apply { - additionalQueryParams.replace(key, values) - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.replaceAll(additionalQueryParams) } - fun removeAdditionalQueryParams(key: String) = - apply { - additionalQueryParams.remove(key) - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - fun removeAllAdditionalQueryParams(keys: Set) = - apply { - additionalQueryParams.removeAll(keys) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } fun build(): ViewUpdateParams = ViewUpdateParams( - checkRequired( - "viewId", viewId - ), - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), + checkRequired("viewId", viewId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), ) } /** The object type that the ACL applies to */ - class ObjectType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -740,11 +622,9 @@ class ViewUpdateParams private constructor( * 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 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 { @@ -760,18 +640,17 @@ class ViewUpdateParams private constructor( PROJECT_LOG, ORG_PROJECT, /** - * An enum member indicating that [ObjectType] was instantiated with an unknown - * value. + * 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. + * 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. + * 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) { @@ -792,11 +671,11 @@ class ViewUpdateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -817,20 +696,23 @@ class ViewUpdateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ObjectType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -839,21 +721,17 @@ class ViewUpdateParams private constructor( } /** Type of table that the view corresponds to. */ - class ViewType @JsonCreator private constructor( - private val value: JsonField, - - ) : Enum { + 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. + * 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 + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -892,11 +770,9 @@ class ViewUpdateParams private constructor( * 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 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 { @@ -908,19 +784,16 @@ class ViewUpdateParams private constructor( PLAYGROUNDS, EXPERIMENT, DATASET, - /** - * An enum member indicating that [ViewType] was instantiated with an unknown - * value. - */ + /** 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. + * 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. + * 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) { @@ -938,11 +811,11 @@ class ViewUpdateParams private constructor( /** * 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. + * 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. + * @throws BraintrustInvalidDataException if this class instance's value is a not a known + * member. */ fun known(): Known = when (this) { @@ -960,20 +833,23 @@ class ViewUpdateParams private constructor( /** * 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. + * 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. + * @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") } + fun asString(): String = + _value().asString().orElseThrow { + BraintrustInvalidDataException("Value is not a String") + } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ + return /* spotless:off */ other is ViewType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -982,14 +858,15 @@ class ViewUpdateParams private constructor( } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is ViewUpdateParams && viewId == other.viewId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(viewId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ - override fun toString() = "ViewUpdateParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + override fun toString() = + "ViewUpdateParams{viewId=$viewId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 0c4146d5..5138c220 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -19,85 +19,89 @@ import java.util.concurrent.CompletableFuture interface AclServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new acl. If there is an existing acl with the same contents as the one - * specified in the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one specified in + * the request, will return the existing acl unmodified */ fun create(params: AclCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: AclCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get an acl object by its id */ fun retrieve(params: AclRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ fun list(params: AclListParams): CompletableFuture = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: AclListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Delete an acl object by its id */ fun delete(params: AclDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Batch update acls. This operation is idempotent, so adding acls which already - * exist will have no effect, and removing acls which do not exist will have no - * effect. + * Batch update acls. This operation is idempotent, so adding acls which already exist will have + * no effect, and removing acls which do not exist will have no effect. */ - fun batchUpdate(): CompletableFuture = batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): CompletableFuture = + batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ - fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [batchUpdate] */ - fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): CompletableFuture = - batchUpdate( - params, RequestOptions.none() - ) + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): CompletableFuture = batchUpdate(params, RequestOptions.none()) /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture = - findAndDelete( - params, RequestOptions.none() - ) + findAndDelete(params, RequestOptions.none()) /** @see [findAndDelete] */ - fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture - /** - * A view of [AclServiceAsync] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [AclServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -106,27 +110,29 @@ interface AclServiceAsync { */ @MustBeClosed fun create(params: AclCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: AclCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the - * same as [AclServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as + * [AclServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: AclRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as @@ -134,49 +140,58 @@ interface AclServiceAsync { */ @MustBeClosed fun list(params: AclListParams): CompletableFuture> = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: AclListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the - * same as [AclServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as + * [AclServiceAsync.delete]. */ @MustBeClosed fun delete(params: AclDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise - * the same as [AclServiceAsync.batchUpdate]. + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as + * [AclServiceAsync.batchUpdate]. */ @MustBeClosed - fun batchUpdate(): CompletableFuture> = batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): CompletableFuture> = + batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): CompletableFuture> = - batchUpdate( - params, RequestOptions.none() - ) + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): CompletableFuture> = + batchUpdate(params, RequestOptions.none()) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate(requestOptions: RequestOptions): CompletableFuture> = batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate( + requestOptions: RequestOptions + ): CompletableFuture> = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as @@ -184,12 +199,13 @@ interface AclServiceAsync { */ @MustBeClosed fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture> = - findAndDelete( - params, RequestOptions.none() - ) + findAndDelete(params, RequestOptions.none()) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 841e0d36..e99ec877 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -21,201 +21,248 @@ import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams -import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams import java.util.concurrent.CompletableFuture -class AclServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class AclServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AclServiceAsync { -) : AclServiceAsync { - - private val withRawResponse: AclServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: AclServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): AclServiceAsync.WithRawResponse = withRawResponse - override fun create(params: AclCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: AclCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/acl withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/acl/{acl_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list(params: AclListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: AclListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/acl withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/acl/batch-update withRawResponse().batchUpdate(params, requestOptions).thenApply { it.parse() } - override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/acl withRawResponse().findAndDelete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : AclServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AclServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: AclCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: AclCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: AclListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - AclListPageAsync.of(AclServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AclListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AclListPageAsync.of(AclServiceAsyncImpl(clientOptions), params, it) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val batchUpdateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - batchUpdateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val batchUpdateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch-update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { batchUpdateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - findAndDeleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val findAndDeleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt index 9e8a0053..dc90a38c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsync.kt @@ -19,204 +19,225 @@ import java.util.concurrent.CompletableFuture interface AiSecretServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as - * the one specified in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as the one + * specified in the request, will return the existing ai_secret unmodified */ fun create(params: AiSecretCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get an ai_secret object by its id */ fun retrieve(params: AiSecretRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update an ai_secret object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: AiSecretUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the - * most recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first */ fun list(): CompletableFuture = list(AiSecretListParams.none()) /** @see [list] */ - fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: AiSecretListParams = AiSecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: AiSecretListParams = AiSecretListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: AiSecretListParams = AiSecretListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(AiSecretListParams.none(), requestOptions) /** Delete an ai_secret object by its id */ fun delete(params: AiSecretDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Delete a single ai_secret */ fun findAndDelete(params: AiSecretFindAndDeleteParams): CompletableFuture = - findAndDelete( - params, RequestOptions.none() - ) + findAndDelete(params, RequestOptions.none()) /** @see [findAndDelete] */ - fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace ai_secret. If there is an existing ai_secret with the same - * name as the one specified in the request, will replace the existing ai_secret - * with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one + * specified in the request, will replace the existing ai_secret with the provided fields */ fun replace(params: AiSecretReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [AiSecretServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [AiSecretServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same - * as [AiSecretServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.create]. */ @MustBeClosed fun create(params: AiSecretCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is - * otherwise the same as [AiSecretServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the + * same as [AiSecretServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: AiSecretRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is - * otherwise the same as [AiSecretServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise + * the same as [AiSecretServiceAsync.update]. */ @MustBeClosed fun update(params: AiSecretUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same - * as [AiSecretServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(AiSecretListParams.none()) + fun list(): CompletableFuture> = + list(AiSecretListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: AiSecretListParams = AiSecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: AiSecretListParams = AiSecretListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: AiSecretListParams = AiSecretListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(AiSecretListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(AiSecretListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is - * otherwise the same as [AiSecretServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise + * the same as [AiSecretServiceAsync.delete]. */ @MustBeClosed fun delete(params: AiSecretDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the - * same as [AiSecretServiceAsync.findAndDelete]. + * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.findAndDelete]. */ @MustBeClosed - fun findAndDelete(params: AiSecretFindAndDeleteParams): CompletableFuture> = - findAndDelete( - params, RequestOptions.none() - ) + fun findAndDelete( + params: AiSecretFindAndDeleteParams + ): CompletableFuture> = + findAndDelete(params, RequestOptions.none()) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same - * as [AiSecretServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as + * [AiSecretServiceAsync.replace]. */ @MustBeClosed fun replace(params: AiSecretReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt index 92f11347..fbe03e82 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncImpl.kt @@ -19,7 +19,6 @@ import com.braintrustdata.api.models.AISecret import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams -import com.braintrustdata.api.models.AiSecretListPage import com.braintrustdata.api.models.AiSecretListPageAsync import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams @@ -27,224 +26,283 @@ import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams import java.util.concurrent.CompletableFuture -class AiSecretServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class AiSecretServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AiSecretServiceAsync { -) : AiSecretServiceAsync { - - private val withRawResponse: AiSecretServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: AiSecretServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): AiSecretServiceAsync.WithRawResponse = withRawResponse - override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/ai_secret withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/ai_secret/{ai_secret_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/ai_secret/{ai_secret_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: AiSecretListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: AiSecretListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/ai_secret withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/ai_secret/{ai_secret_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/ai_secret withRawResponse().findAndDelete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/ai_secret withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : AiSecretServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AiSecretServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: AiSecretListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - AiSecretListPageAsync.of(AiSecretServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AiSecretListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AiSecretListPageAsync.of( + AiSecretServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - findAndDeleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val findAndDeleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt index efa0446f..94e69910 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt @@ -17,31 +17,32 @@ import java.util.concurrent.CompletableFuture interface ApiKeyServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new api_key. It is possible to have multiple API keys with the same - * name. There is no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same name. There is + * no de-duplication */ fun create(params: ApiKeyCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get an api_key object by its id */ fun retrieve(params: ApiKeyRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** * List out all api_keys. The api_keys are sorted by creation date, with the most @@ -50,29 +51,32 @@ interface ApiKeyServiceAsync { fun list(): CompletableFuture = list(ApiKeyListParams.none()) /** @see [list] */ - fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ApiKeyListParams = ApiKeyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: ApiKeyListParams = ApiKeyListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: ApiKeyListParams = ApiKeyListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ApiKeyListParams.none(), requestOptions) /** Delete an api_key object by its id */ fun delete(params: ApiKeyDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -81,63 +85,75 @@ interface ApiKeyServiceAsync { * [ApiKeyServiceAsync.create]. */ @MustBeClosed - fun create(params: ApiKeyCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + fun create( + params: ApiKeyCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise - * the same as [ApiKeyServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same + * as [ApiKeyServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ApiKeyRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as * [ApiKeyServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(ApiKeyListParams.none()) + fun list(): CompletableFuture> = + list(ApiKeyListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: ApiKeyListParams = ApiKeyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: ApiKeyListParams = ApiKeyListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: ApiKeyListParams = ApiKeyListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(ApiKeyListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ApiKeyListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is - * otherwise the same as [ApiKeyServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the + * same as [ApiKeyServiceAsync.delete]. */ @MustBeClosed fun delete(params: ApiKeyDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt index 8bc1a341..ca00a3e4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -18,144 +18,178 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams -import com.braintrustdata.api.models.ApiKeyListPage import com.braintrustdata.api.models.ApiKeyListPageAsync import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput import java.util.concurrent.CompletableFuture -class ApiKeyServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyServiceAsync { -) : ApiKeyServiceAsync { - - private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ApiKeyServiceAsync.WithRawResponse = withRawResponse - override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/api_key withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/api_key/{api_key_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: ApiKeyListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/api_key withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/api_key/{api_key_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ApiKeyServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ApiKeyListPageAsync.of(ApiKeyServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ApiKeyListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ApiKeyListPageAsync.of( + ApiKeyServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index 9e33a36b..a6d7c52c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -26,45 +26,46 @@ import java.util.concurrent.CompletableFuture interface DatasetServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new dataset. If there is an existing dataset in the project with the - * same name as the one specified in the request, will return the existing dataset - * unmodified + * Create a new dataset. If there is an existing dataset in the project with the same name as + * the one specified in the request, will return the existing dataset unmodified */ fun create(params: DatasetCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a dataset object by its id */ fun retrieve(params: DatasetRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a dataset object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: DatasetUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** * List out all datasets. The datasets are sorted by creation date, with the most @@ -73,82 +74,90 @@ interface DatasetServiceAsync { fun list(): CompletableFuture = list(DatasetListParams.none()) /** @see [list] */ - fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: DatasetListParams = DatasetListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: DatasetListParams = DatasetListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(DatasetListParams.none(), requestOptions) /** Delete a dataset object by its id */ fun delete(params: DatasetDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Log feedback for a set of dataset events */ fun feedback(params: DatasetFeedbackParams): CompletableFuture = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ - fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but - * with the parameters in the URL query rather than in the request body. For more - * complex queries, use the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ fun fetch(params: DatasetFetchParams): CompletableFuture = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ - fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but - * with the parameters in the request body rather than in the URL query. For more - * complex queries, use the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ fun fetchPost(params: DatasetFetchPostParams): CompletableFuture = - fetchPost( - params, RequestOptions.none() - ) + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ - fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Insert a set of events into the dataset */ fun insert(params: DatasetInsertParams): CompletableFuture = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ - fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Summarize dataset */ fun summarize(params: DatasetSummarizeParams): CompletableFuture = - summarize( - params, RequestOptions.none() - ) + summarize(params, RequestOptions.none()) /** @see [summarize] */ - fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [DatasetServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -158,146 +167,172 @@ interface DatasetServiceAsync { */ @MustBeClosed fun create(params: DatasetCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise - * the same as [DatasetServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same + * as [DatasetServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: DatasetRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is - * otherwise the same as [DatasetServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the + * same as [DatasetServiceAsync.update]. */ @MustBeClosed fun update(params: DatasetUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as * [DatasetServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(DatasetListParams.none()) + fun list(): CompletableFuture> = + list(DatasetListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: DatasetListParams = DatasetListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: DatasetListParams = DatasetListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(DatasetListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(DatasetListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is - * otherwise the same as [DatasetServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the + * same as [DatasetServiceAsync.delete]. */ @MustBeClosed fun delete(params: DatasetDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is * otherwise the same as [DatasetServiceAsync.feedback]. */ @MustBeClosed - fun feedback(params: DatasetFeedbackParams): CompletableFuture> = - feedback( - params, RequestOptions.none() - ) + fun feedback( + params: DatasetFeedbackParams + ): CompletableFuture> = + feedback(params, RequestOptions.none()) /** @see [feedback] */ @MustBeClosed - fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is - * otherwise the same as [DatasetServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise + * the same as [DatasetServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: DatasetFetchParams): CompletableFuture> = - fetch( - params, RequestOptions.none() - ) + fun fetch( + params: DatasetFetchParams + ): CompletableFuture> = + fetch(params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed - fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is - * otherwise the same as [DatasetServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise + * the same as [DatasetServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost(params: DatasetFetchPostParams): CompletableFuture> = - fetchPost( - params, RequestOptions.none() - ) + fun fetchPost( + params: DatasetFetchPostParams + ): CompletableFuture> = + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is - * otherwise the same as [DatasetServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise + * the same as [DatasetServiceAsync.insert]. */ @MustBeClosed - fun insert(params: DatasetInsertParams): CompletableFuture> = - insert( - params, RequestOptions.none() - ) + fun insert( + params: DatasetInsertParams + ): CompletableFuture> = + insert(params, RequestOptions.none()) /** @see [insert] */ @MustBeClosed - fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is * otherwise the same as [DatasetServiceAsync.summarize]. */ @MustBeClosed - fun summarize(params: DatasetSummarizeParams): CompletableFuture> = - summarize( - params, RequestOptions.none() - ) + fun summarize( + params: DatasetSummarizeParams + ): CompletableFuture> = + summarize(params, RequestOptions.none()) /** @see [summarize] */ @MustBeClosed - fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index 3b020629..7a5002f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -22,7 +22,6 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetListPage import com.braintrustdata.api.models.DatasetListPageAsync import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams @@ -34,309 +33,397 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse import java.util.concurrent.CompletableFuture -class DatasetServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class DatasetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync { -) : DatasetServiceAsync { - - private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: DatasetServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): DatasetServiceAsync.WithRawResponse = withRawResponse - override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/dataset withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/dataset/{dataset_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/dataset/{dataset_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: DatasetListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/dataset withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/dataset/{dataset_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): CompletableFuture = + override fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/dataset/{dataset_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): CompletableFuture = + override fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/dataset/{dataset_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): CompletableFuture = + override fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/dataset/{dataset_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): CompletableFuture = + override fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/dataset/{dataset_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): CompletableFuture = + override fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/dataset/{dataset_id}/summarize withRawResponse().summarize(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : DatasetServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: DatasetListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - DatasetListPageAsync.of(DatasetServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DatasetListPageAsync.of( + DatasetServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - feedbackHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - fetchHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - fetchPostHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - insertHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - summarizeHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt index 628a4047..49a3693f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsync.kt @@ -18,44 +18,46 @@ import java.util.concurrent.CompletableFuture interface EnvVarServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new env_var. If there is an existing env_var with the same name as the - * one specified in the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the one specified + * in the request, will return the existing env_var unmodified */ fun create(params: EnvVarCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get an env_var object by its id */ fun retrieve(params: EnvVarRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update an env_var object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: EnvVarUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** * List out all env_vars. The env_vars are sorted by creation date, with the most @@ -64,42 +66,45 @@ interface EnvVarServiceAsync { fun list(): CompletableFuture = list(EnvVarListParams.none()) /** @see [list] */ - fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: EnvVarListParams = EnvVarListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: EnvVarListParams = EnvVarListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: EnvVarListParams = EnvVarListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(EnvVarListParams.none(), requestOptions) /** Delete an env_var object by its id */ fun delete(params: EnvVarDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace env_var. If there is an existing env_var with the same name as - * the one specified in the request, will replace the existing env_var with the - * provided fields + * Create or replace env_var. If there is an existing env_var with the same name as the one + * specified in the request, will replace the existing env_var with the provided fields */ fun replace(params: EnvVarReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [EnvVarServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [EnvVarServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -109,77 +114,88 @@ interface EnvVarServiceAsync { */ @MustBeClosed fun create(params: EnvVarCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise - * the same as [EnvVarServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same + * as [EnvVarServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: EnvVarRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is - * otherwise the same as [EnvVarServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the + * same as [EnvVarServiceAsync.update]. */ @MustBeClosed fun update(params: EnvVarUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as * [EnvVarServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(EnvVarListParams.none()) + fun list(): CompletableFuture> = + list(EnvVarListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: EnvVarListParams = EnvVarListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: EnvVarListParams = EnvVarListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: EnvVarListParams = EnvVarListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(EnvVarListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(EnvVarListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is - * otherwise the same as [EnvVarServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the + * same as [EnvVarServiceAsync.delete]. */ @MustBeClosed fun delete(params: EnvVarDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as @@ -187,12 +203,13 @@ interface EnvVarServiceAsync { */ @MustBeClosed fun replace(params: EnvVarReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt index e2f36b30..c4ed7f35 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EnvVarServiceAsyncImpl.kt @@ -25,192 +25,238 @@ import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams import java.util.concurrent.CompletableFuture -class EnvVarServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class EnvVarServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + EnvVarServiceAsync { -) : EnvVarServiceAsync { - - private val withRawResponse: EnvVarServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: EnvVarServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): EnvVarServiceAsync.WithRawResponse = withRawResponse - override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/env_var withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/env_var/{env_var_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/env_var/{env_var_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: EnvVarListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: EnvVarListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/env_var withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/env_var/{env_var_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/env_var withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : EnvVarServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EnvVarServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: EnvVarListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list( + params: EnvVarListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt index 8d84a6a7..69b6f45c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsync.kt @@ -12,31 +12,27 @@ import java.util.concurrent.CompletableFuture interface EvalServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is - * built into the Braintrust SDK. In the Eval API, you provide pointers to a - * dataset, task function, and scoring functions. The API will then run the - * evaluation, create an experiment, and return the results along with a link to - * the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into + * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and + * scoring functions. The API will then run the evaluation, create an experiment, and return the + * results along with a link to the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ fun create(params: EvalCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: EvalCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture - /** - * A view of [EvalServiceAsync] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [EvalServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -44,13 +40,16 @@ interface EvalServiceAsync { * [EvalServiceAsync.create]. */ @MustBeClosed - fun create(params: EvalCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + fun create( + params: EvalCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: EvalCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt index 8a578fb7..d0fc0019 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncImpl.kt @@ -19,49 +19,56 @@ import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture -class EvalServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class EvalServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + EvalServiceAsync { -) : EvalServiceAsync { - - private val withRawResponse: EvalServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: EvalServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): EvalServiceAsync.WithRawResponse = withRawResponse - override fun create(params: EvalCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: EvalCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/eval withRawResponse().create(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : EvalServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EvalServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - override fun create(params: EvalCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "eval") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + override fun create( + params: EvalCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "eval") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index b49f1978..e10046e6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -26,278 +26,317 @@ import java.util.concurrent.CompletableFuture interface ExperimentServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new experiment. If there is an existing experiment in the project with - * the same name as the one specified in the request, will return the existing - * experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with the same name + * as the one specified in the request, will return the existing experiment unmodified */ fun create(params: ExperimentCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get an experiment object by its id */ fun retrieve(params: ExperimentRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update an experiment object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: ExperimentUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ fun list(): CompletableFuture = list(ExperimentListParams.none()) /** @see [list] */ - fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ExperimentListParams = ExperimentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: ExperimentListParams = ExperimentListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: ExperimentListParams = ExperimentListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ExperimentListParams.none(), requestOptions) /** Delete an experiment object by its id */ fun delete(params: ExperimentDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Log feedback for a set of experiment events */ fun feedback(params: ExperimentFeedbackParams): CompletableFuture = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ - fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, - * but with the parameters in the URL query rather than in the request body. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ fun fetch(params: ExperimentFetchParams): CompletableFuture = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ - fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ - fun fetchPost(params: ExperimentFetchPostParams): CompletableFuture = - fetchPost( - params, RequestOptions.none() - ) + fun fetchPost( + params: ExperimentFetchPostParams + ): CompletableFuture = fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ - fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Insert a set of events into the experiment */ fun insert(params: ExperimentInsertParams): CompletableFuture = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ - fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Summarize experiment */ - fun summarize(params: ExperimentSummarizeParams): CompletableFuture = - summarize( - params, RequestOptions.none() - ) + fun summarize( + params: ExperimentSummarizeParams + ): CompletableFuture = summarize(params, RequestOptions.none()) /** @see [summarize] */ - fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [ExperimentServiceAsync] that provides access to raw HTTP responses - * for each method. + * A view of [ExperimentServiceAsync] that provides access to raw HTTP responses for each + * method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same - * as [ExperimentServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as + * [ExperimentServiceAsync.create]. */ @MustBeClosed fun create(params: ExperimentCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is - * otherwise the same as [ExperimentServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve(params: ExperimentRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + fun retrieve( + params: ExperimentRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is - * otherwise the same as [ExperimentServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentServiceAsync.update]. */ @MustBeClosed fun update(params: ExperimentUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same - * as [ExperimentServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as + * [ExperimentServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(ExperimentListParams.none()) + fun list(): CompletableFuture> = + list(ExperimentListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: ExperimentListParams = ExperimentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: ExperimentListParams = ExperimentListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: ExperimentListParams = ExperimentListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(ExperimentListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ExperimentListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is - * otherwise the same as [ExperimentServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentServiceAsync.delete]. */ @MustBeClosed fun delete(params: ExperimentDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, - * but is otherwise the same as [ExperimentServiceAsync.feedback]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is + * otherwise the same as [ExperimentServiceAsync.feedback]. */ @MustBeClosed - fun feedback(params: ExperimentFeedbackParams): CompletableFuture> = - feedback( - params, RequestOptions.none() - ) + fun feedback( + params: ExperimentFeedbackParams + ): CompletableFuture> = + feedback(params, RequestOptions.none()) /** @see [feedback] */ @MustBeClosed - fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but - * is otherwise the same as [ExperimentServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is + * otherwise the same as [ExperimentServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: ExperimentFetchParams): CompletableFuture> = - fetch( - params, RequestOptions.none() - ) + fun fetch( + params: ExperimentFetchParams + ): CompletableFuture> = + fetch(params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed - fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but - * is otherwise the same as [ExperimentServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is + * otherwise the same as [ExperimentServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost(params: ExperimentFetchPostParams): CompletableFuture> = - fetchPost( - params, RequestOptions.none() - ) + fun fetchPost( + params: ExperimentFetchPostParams + ): CompletableFuture> = + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, - * but is otherwise the same as [ExperimentServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is + * otherwise the same as [ExperimentServiceAsync.insert]. */ @MustBeClosed - fun insert(params: ExperimentInsertParams): CompletableFuture> = - insert( - params, RequestOptions.none() - ) + fun insert( + params: ExperimentInsertParams + ): CompletableFuture> = + insert(params, RequestOptions.none()) /** @see [insert] */ @MustBeClosed - fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, - * but is otherwise the same as [ExperimentServiceAsync.summarize]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is + * otherwise the same as [ExperimentServiceAsync.summarize]. */ @MustBeClosed - fun summarize(params: ExperimentSummarizeParams): CompletableFuture> = - summarize( - params, RequestOptions.none() - ) + fun summarize( + params: ExperimentSummarizeParams + ): CompletableFuture> = + summarize(params, RequestOptions.none()) /** @see [summarize] */ @MustBeClosed - fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 0c92d8b0..432baacd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -22,7 +22,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListPageAsync import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams @@ -34,309 +33,397 @@ import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse import java.util.concurrent.CompletableFuture -class ExperimentServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class ExperimentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentServiceAsync { -) : ExperimentServiceAsync { - - private val withRawResponse: ExperimentServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ExperimentServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ExperimentServiceAsync.WithRawResponse = withRawResponse - override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/experiment withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/experiment/{experiment_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/experiment/{experiment_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: ExperimentListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: ExperimentListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/experiment withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/experiment/{experiment_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): CompletableFuture = + override fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/experiment/{experiment_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): CompletableFuture = + override fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/experiment/{experiment_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): CompletableFuture = + override fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/experiment/{experiment_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): CompletableFuture = + override fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/experiment/{experiment_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): CompletableFuture = + override fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/experiment/{experiment_id}/summarize withRawResponse().summarize(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ExperimentServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ExperimentListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ExperimentListPageAsync.of(ExperimentServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ExperimentListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ExperimentListPageAsync.of( + ExperimentServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - feedbackHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - fetchHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - fetchPostHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - insertHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - summarizeHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index 89865299..b625969e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -21,45 +21,46 @@ import java.util.concurrent.CompletableFuture interface FunctionServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new function. If there is an existing function in the project with the - * same slug as the one specified in the request, will return the existing function - * unmodified + * Create a new function. If there is an existing function in the project with the same slug as + * the one specified in the request, will return the existing function unmodified */ fun create(params: FunctionCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a function object by its id */ fun retrieve(params: FunctionRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a function object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: FunctionUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** * List out all functions. The functions are sorted by creation date, with the most @@ -68,145 +69,164 @@ interface FunctionServiceAsync { fun list(): CompletableFuture = list(FunctionListParams.none()) /** @see [list] */ - fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: FunctionListParams = FunctionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: FunctionListParams = FunctionListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: FunctionListParams = FunctionListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(FunctionListParams.none(), requestOptions) /** Delete a function object by its id */ fun delete(params: FunctionDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Invoke a function. */ fun invoke(params: FunctionInvokeParams): CompletableFuture> = - invoke( - params, RequestOptions.none() - ) + invoke(params, RequestOptions.none()) /** @see [invoke] */ - fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Create or replace function. If there is an existing function in the project with - * the same slug as the one specified in the request, will replace the existing - * function with the provided fields + * Create or replace function. If there is an existing function in the project with the same + * slug as the one specified in the request, will replace the existing function with the + * provided fields */ fun replace(params: FunctionReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [FunctionServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [FunctionServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same - * as [FunctionServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as + * [FunctionServiceAsync.create]. */ @MustBeClosed fun create(params: FunctionCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is - * otherwise the same as [FunctionServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the + * same as [FunctionServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: FunctionRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is - * otherwise the same as [FunctionServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the + * same as [FunctionServiceAsync.update]. */ @MustBeClosed fun update(params: FunctionUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as * [FunctionServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(FunctionListParams.none()) + fun list(): CompletableFuture> = + list(FunctionListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: FunctionListParams = FunctionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: FunctionListParams = FunctionListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: FunctionListParams = FunctionListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(FunctionListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(FunctionListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is - * otherwise the same as [FunctionServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the + * same as [FunctionServiceAsync.delete]. */ @MustBeClosed fun delete(params: FunctionDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is * otherwise the same as [FunctionServiceAsync.invoke]. */ @MustBeClosed - fun invoke(params: FunctionInvokeParams): CompletableFuture>> = - invoke( - params, RequestOptions.none() - ) + fun invoke( + params: FunctionInvokeParams + ): CompletableFuture>> = + invoke(params, RequestOptions.none()) /** @see [invoke] */ @MustBeClosed - fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture>> + fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> /** * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as @@ -214,12 +234,13 @@ interface FunctionServiceAsync { */ @MustBeClosed fun replace(params: FunctionReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 09c07695..27377950 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -20,7 +20,6 @@ import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams import com.braintrustdata.api.models.FunctionInvokeResponse -import com.braintrustdata.api.models.FunctionListPage import com.braintrustdata.api.models.FunctionListPageAsync import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams @@ -29,224 +28,284 @@ import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional import java.util.concurrent.CompletableFuture -class FunctionServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class FunctionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FunctionServiceAsync { -) : FunctionServiceAsync { - - private val withRawResponse: FunctionServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: FunctionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): FunctionServiceAsync.WithRawResponse = withRawResponse - override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/function withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/function/{function_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/function/{function_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: FunctionListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: FunctionListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/function withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/function/{function_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): CompletableFuture> = + override fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions, + ): CompletableFuture> = // post /v1/function/{function_id}/invoke withRawResponse().invoke(params, requestOptions).thenApply { it.parse() } - override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/function withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : FunctionServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FunctionServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: FunctionListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - FunctionListPageAsync.of(FunctionServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: FunctionListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + FunctionListPageAsync.of( + FunctionServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val invokeHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): CompletableFuture>> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - invokeHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } - } - } - } } + private val invokeHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function", params.getPathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { invokeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index 04d7d5b7..9c172789 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -18,89 +18,92 @@ import java.util.concurrent.CompletableFuture interface GroupServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new group. If there is an existing group with the same name as the one - * specified in the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one specified in + * the request, will return the existing group unmodified */ fun create(params: GroupCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a group object by its id */ fun retrieve(params: GroupRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a group object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ fun update(params: GroupUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ fun list(): CompletableFuture = list(GroupListParams.none()) /** @see [list] */ - fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: GroupListParams = GroupListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: GroupListParams = GroupListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: GroupListParams = GroupListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(GroupListParams.none(), requestOptions) /** Delete a group object by its id */ fun delete(params: GroupDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace group. If there is an existing group with the same name as the - * one specified in the request, will replace the existing group with the provided - * fields + * Create or replace group. If there is an existing group with the same name as the one + * specified in the request, will replace the existing group with the provided fields */ fun replace(params: GroupReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture - /** - * A view of [GroupServiceAsync] that provides access to raw HTTP responses for - * each method. - */ + /** A view of [GroupServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -109,77 +112,88 @@ interface GroupServiceAsync { */ @MustBeClosed fun create(params: GroupCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the - * same as [GroupServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as + * [GroupServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: GroupRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise - * the same as [GroupServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same + * as [GroupServiceAsync.update]. */ @MustBeClosed fun update(params: GroupUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as * [GroupServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(GroupListParams.none()) + fun list(): CompletableFuture> = + list(GroupListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: GroupListParams = GroupListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: GroupListParams = GroupListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: GroupListParams = GroupListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(GroupListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(GroupListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise - * the same as [GroupServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same + * as [GroupServiceAsync.delete]. */ @MustBeClosed fun delete(params: GroupDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as @@ -187,12 +201,13 @@ interface GroupServiceAsync { */ @MustBeClosed fun replace(params: GroupReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index 7400ac18..db541802 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -18,7 +18,6 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams -import com.braintrustdata.api.models.GroupListPage import com.braintrustdata.api.models.GroupListPageAsync import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams @@ -26,195 +25,246 @@ import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams import java.util.concurrent.CompletableFuture -class GroupServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class GroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + GroupServiceAsync { -) : GroupServiceAsync { - - private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: GroupServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): GroupServiceAsync.WithRawResponse = withRawResponse - override fun create(params: GroupCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/group withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/group/{group_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/group/{group_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: GroupListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: GroupListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/group withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/group/{group_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/group withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : GroupServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + GroupServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: GroupCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: GroupListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - GroupListPageAsync.of(GroupServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: GroupListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + GroupListPageAsync.of( + GroupServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index 42e1be2c..a224dbd9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -17,8 +17,7 @@ import java.util.concurrent.CompletableFuture interface OrganizationServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse @@ -26,56 +25,62 @@ interface OrganizationServiceAsync { /** Get an organization object by its id */ fun retrieve(params: OrganizationRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update an organization object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: OrganizationUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ fun list(): CompletableFuture = list(OrganizationListParams.none()) /** @see [list] */ - fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: OrganizationListParams = OrganizationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: OrganizationListParams = OrganizationListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: OrganizationListParams = OrganizationListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(OrganizationListParams.none(), requestOptions) /** Delete an organization object by its id */ fun delete(params: OrganizationDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [OrganizationServiceAsync] that provides access to raw HTTP responses - * for each method. + * A view of [OrganizationServiceAsync] that provides access to raw HTTP responses for each + * method. */ interface WithRawResponse { @@ -86,63 +91,77 @@ interface OrganizationServiceAsync { * otherwise the same as [OrganizationServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve(params: OrganizationRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + fun retrieve( + params: OrganizationRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but - * is otherwise the same as [OrganizationServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationServiceAsync.update]. */ @MustBeClosed - fun update(params: OrganizationUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + fun update( + params: OrganizationUpdateParams + ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the - * same as [OrganizationServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as + * [OrganizationServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(OrganizationListParams.none()) + fun list(): CompletableFuture> = + list(OrganizationListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: OrganizationListParams = OrganizationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: OrganizationListParams = OrganizationListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: OrganizationListParams = OrganizationListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(OrganizationListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(OrganizationListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but - * is otherwise the same as [OrganizationServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationServiceAsync.delete]. */ @MustBeClosed - fun delete(params: OrganizationDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + fun delete( + params: OrganizationDeleteParams + ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 959bb5c4..08667293 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -17,7 +17,6 @@ import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams -import com.braintrustdata.api.models.OrganizationListPage import com.braintrustdata.api.models.OrganizationListPageAsync import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams @@ -26,12 +25,12 @@ import com.braintrustdata.api.services.async.organizations.MemberServiceAsync import com.braintrustdata.api.services.async.organizations.MemberServiceAsyncImpl import java.util.concurrent.CompletableFuture -class OrganizationServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class OrganizationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + OrganizationServiceAsync { -) : OrganizationServiceAsync { - - private val withRawResponse: OrganizationServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: OrganizationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val members: MemberServiceAsync by lazy { MemberServiceAsyncImpl(clientOptions) } @@ -39,132 +38,169 @@ class OrganizationServiceAsyncImpl internal constructor( override fun members(): MemberServiceAsync = members - override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/organization/{organization_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/organization/{organization_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: OrganizationListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: OrganizationListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/organization withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/organization/{organization_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : OrganizationServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrganizationServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val members: MemberServiceAsync.WithRawResponse by lazy { MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val members: MemberServiceAsync.WithRawResponse by lazy { + MemberServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } override fun members(): MemberServiceAsync.WithRawResponse = members - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: OrganizationListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - OrganizationListPageAsync.of(OrganizationServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: OrganizationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + OrganizationListPageAsync.of( + OrganizationServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index aa644b97..beca7a59 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -18,182 +18,207 @@ import java.util.concurrent.CompletableFuture interface ProjectScoreServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_score. If there is an existing project_score in the project - * with the same name as the one specified in the request, will return the existing - * project_score unmodified + * Create a new project_score. If there is an existing project_score in the project with the + * same name as the one specified in the request, will return the existing project_score + * unmodified */ fun create(params: ProjectScoreCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a project_score object by its id */ fun retrieve(params: ProjectScoreRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a project_score object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: ProjectScoreUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ fun list(): CompletableFuture = list(ProjectScoreListParams.none()) /** @see [list] */ - fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ProjectScoreListParams.none(), requestOptions) /** Delete a project_score object by its id */ fun delete(params: ProjectScoreDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace project_score. If there is an existing project_score in the - * project with the same name as the one specified in the request, will replace the - * existing project_score with the provided fields + * Create or replace project_score. If there is an existing project_score in the project with + * the same name as the one specified in the request, will replace the existing project_score + * with the provided fields */ fun replace(params: ProjectScoreReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [ProjectScoreServiceAsync] that provides access to raw HTTP responses - * for each method. + * A view of [ProjectScoreServiceAsync] that provides access to raw HTTP responses for each + * method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the - * same as [ProjectScoreServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as + * [ProjectScoreServiceAsync.create]. */ @MustBeClosed - fun create(params: ProjectScoreCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + fun create( + params: ProjectScoreCreateParams + ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but - * is otherwise the same as [ProjectScoreServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve(params: ProjectScoreRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + fun retrieve( + params: ProjectScoreRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, - * but is otherwise the same as [ProjectScoreServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreServiceAsync.update]. */ @MustBeClosed - fun update(params: ProjectScoreUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + fun update( + params: ProjectScoreUpdateParams + ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the - * same as [ProjectScoreServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as + * [ProjectScoreServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(ProjectScoreListParams.none()) + fun list(): CompletableFuture> = + list(ProjectScoreListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectScoreListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ProjectScoreListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, - * but is otherwise the same as [ProjectScoreServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreServiceAsync.delete]. */ @MustBeClosed - fun delete(params: ProjectScoreDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + fun delete( + params: ProjectScoreDeleteParams + ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the - * same as [ProjectScoreServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as + * [ProjectScoreServiceAsync.replace]. */ @MustBeClosed - fun replace(params: ProjectScoreReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + fun replace( + params: ProjectScoreReplaceParams + ): CompletableFuture> = replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index 1f2c575c..cde96d23 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -18,7 +18,6 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams -import com.braintrustdata.api.models.ProjectScoreListPage import com.braintrustdata.api.models.ProjectScoreListPageAsync import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams @@ -26,195 +25,246 @@ import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams import java.util.concurrent.CompletableFuture -class ProjectScoreServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class ProjectScoreServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectScoreServiceAsync { -) : ProjectScoreServiceAsync { - - private val withRawResponse: ProjectScoreServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ProjectScoreServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ProjectScoreServiceAsync.WithRawResponse = withRawResponse - override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/project_score withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/project_score/{project_score_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/project_score/{project_score_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/project_score withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/project_score/{project_score_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/project_score withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ProjectScoreServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectScoreServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectScoreListPageAsync.of(ProjectScoreServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectScoreListPageAsync.of( + ProjectScoreServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index 150a37a6..c1c67326 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -18,46 +18,48 @@ import java.util.concurrent.CompletableFuture interface ProjectServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse fun logs(): LogServiceAsync /** - * Create a new project. If there is an existing project with the same name as the - * one specified in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the one specified + * in the request, will return the existing project unmodified */ fun create(params: ProjectCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a project object by its id */ fun retrieve(params: ProjectRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a project object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: ProjectUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** * List out all projects. The projects are sorted by creation date, with the most @@ -66,29 +68,32 @@ interface ProjectServiceAsync { fun list(): CompletableFuture = list(ProjectListParams.none()) /** @see [list] */ - fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: ProjectListParams = ProjectListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectListParams = ProjectListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ProjectListParams.none(), requestOptions) /** Delete a project object by its id */ fun delete(params: ProjectDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [ProjectServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [ProjectServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -100,76 +105,87 @@ interface ProjectServiceAsync { */ @MustBeClosed fun create(params: ProjectCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise - * the same as [ProjectServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same + * as [ProjectServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is - * otherwise the same as [ProjectServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the + * same as [ProjectServiceAsync.update]. */ @MustBeClosed fun update(params: ProjectUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as * [ProjectServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(ProjectListParams.none()) + fun list(): CompletableFuture> = + list(ProjectListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: ProjectListParams = ProjectListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectListParams = ProjectListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ProjectListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is - * otherwise the same as [ProjectServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the + * same as [ProjectServiceAsync.delete]. */ @MustBeClosed fun delete(params: ProjectDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index 53bb7b05..dba161a5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -18,7 +18,6 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams -import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams @@ -27,12 +26,12 @@ import com.braintrustdata.api.services.async.projects.LogServiceAsync import com.braintrustdata.api.services.async.projects.LogServiceAsyncImpl import java.util.concurrent.CompletableFuture -class ProjectServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class ProjectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectServiceAsync { -) : ProjectServiceAsync { - - private val withRawResponse: ProjectServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ProjectServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val logs: LogServiceAsync by lazy { LogServiceAsyncImpl(clientOptions) } @@ -40,161 +39,206 @@ class ProjectServiceAsyncImpl internal constructor( override fun logs(): LogServiceAsync = logs - override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/project withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/project/{project_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/project/{project_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: ProjectListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/project withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/project/{project_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ProjectServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val logs: LogServiceAsync.WithRawResponse by lazy { LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val logs: LogServiceAsync.WithRawResponse by lazy { + LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } override fun logs(): LogServiceAsync.WithRawResponse = logs - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ProjectListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectListPageAsync.of(ProjectServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectListPageAsync.of( + ProjectServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index 7a823a70..6d681309 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -18,119 +18,128 @@ import java.util.concurrent.CompletableFuture interface ProjectTagServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_tag. If there is an existing project_tag in the project - * with the same name as the one specified in the request, will return the existing - * project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project with the same + * name as the one specified in the request, will return the existing project_tag unmodified */ fun create(params: ProjectTagCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a project_tag object by its id */ fun retrieve(params: ProjectTagRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a project_tag object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: ProjectTagUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ fun list(): CompletableFuture = list(ProjectTagListParams.none()) /** @see [list] */ - fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ProjectTagListParams = ProjectTagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: ProjectTagListParams = ProjectTagListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectTagListParams = ProjectTagListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ProjectTagListParams.none(), requestOptions) /** Delete a project_tag object by its id */ fun delete(params: ProjectTagDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace project_tag. If there is an existing project_tag in the - * project with the same name as the one specified in the request, will replace the - * existing project_tag with the provided fields + * Create or replace project_tag. If there is an existing project_tag in the project with the + * same name as the one specified in the request, will replace the existing project_tag with the + * provided fields */ fun replace(params: ProjectTagReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [ProjectTagServiceAsync] that provides access to raw HTTP responses - * for each method. + * A view of [ProjectTagServiceAsync] that provides access to raw HTTP responses for each + * method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the - * same as [ProjectTagServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as + * [ProjectTagServiceAsync.create]. */ @MustBeClosed fun create(params: ProjectTagCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is - * otherwise the same as [ProjectTagServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise + * the same as [ProjectTagServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve(params: ProjectTagRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + fun retrieve( + params: ProjectTagRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is @@ -138,62 +147,73 @@ interface ProjectTagServiceAsync { */ @MustBeClosed fun update(params: ProjectTagUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same - * as [ProjectTagServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as + * [ProjectTagServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(ProjectTagListParams.none()) + fun list(): CompletableFuture> = + list(ProjectTagListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: ProjectTagListParams = ProjectTagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: ProjectTagListParams = ProjectTagListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectTagListParams = ProjectTagListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(ProjectTagListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ProjectTagListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but - * is otherwise the same as [ProjectTagServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagServiceAsync.delete]. */ @MustBeClosed fun delete(params: ProjectTagDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same - * as [ProjectTagServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as + * [ProjectTagServiceAsync.replace]. */ @MustBeClosed - fun replace(params: ProjectTagReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + fun replace( + params: ProjectTagReplaceParams + ): CompletableFuture> = replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index 21850a9d..d12a821a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -18,7 +18,6 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams -import com.braintrustdata.api.models.ProjectTagListPage import com.braintrustdata.api.models.ProjectTagListPageAsync import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams @@ -26,195 +25,246 @@ import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams import java.util.concurrent.CompletableFuture -class ProjectTagServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class ProjectTagServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectTagServiceAsync { -) : ProjectTagServiceAsync { - - private val withRawResponse: ProjectTagServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ProjectTagServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ProjectTagServiceAsync.WithRawResponse = withRawResponse - override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/project_tag withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/project_tag/{project_tag_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/project_tag/{project_tag_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/project_tag withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/project_tag/{project_tag_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/project_tag withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ProjectTagServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectTagServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectTagListPageAsync.of(ProjectTagServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectTagListPageAsync.of( + ProjectTagServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index 9a962e3b..afb7a900 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -18,89 +18,93 @@ import java.util.concurrent.CompletableFuture interface PromptServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new prompt. If there is an existing prompt in the project with the same - * slug as the one specified in the request, will return the existing prompt - * unmodified + * Create a new prompt. If there is an existing prompt in the project with the same slug as the + * one specified in the request, will return the existing prompt unmodified */ fun create(params: PromptCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: PromptCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a prompt object by its id */ fun retrieve(params: PromptRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a prompt object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: PromptUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ fun list(): CompletableFuture = list(PromptListParams.none()) /** @see [list] */ - fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: PromptListParams = PromptListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: PromptListParams = PromptListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: PromptListParams = PromptListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(PromptListParams.none(), requestOptions) /** Delete a prompt object by its id */ fun delete(params: PromptDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace prompt. If there is an existing prompt in the project with the - * same slug as the one specified in the request, will replace the existing prompt - * with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the same slug as + * the one specified in the request, will replace the existing prompt with the provided fields */ fun replace(params: PromptReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [PromptServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [PromptServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -110,77 +114,88 @@ interface PromptServiceAsync { */ @MustBeClosed fun create(params: PromptCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: PromptCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise - * the same as [PromptServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same + * as [PromptServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: PromptRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise - * the same as [PromptServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same + * as [PromptServiceAsync.update]. */ @MustBeClosed fun update(params: PromptUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as * [PromptServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(PromptListParams.none()) + fun list(): CompletableFuture> = + list(PromptListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: PromptListParams = PromptListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: PromptListParams = PromptListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: PromptListParams = PromptListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(PromptListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(PromptListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is - * otherwise the same as [PromptServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the + * same as [PromptServiceAsync.delete]. */ @MustBeClosed fun delete(params: PromptDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as @@ -188,12 +203,13 @@ interface PromptServiceAsync { */ @MustBeClosed fun replace(params: PromptReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index 3a65157b..7772aa68 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -18,7 +18,6 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams -import com.braintrustdata.api.models.PromptListPage import com.braintrustdata.api.models.PromptListPageAsync import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams @@ -26,195 +25,246 @@ import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams import java.util.concurrent.CompletableFuture -class PromptServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class PromptServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PromptServiceAsync { -) : PromptServiceAsync { - - private val withRawResponse: PromptServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: PromptServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): PromptServiceAsync.WithRawResponse = withRawResponse - override fun create(params: PromptCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: PromptCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/prompt withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/prompt/{prompt_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/prompt/{prompt_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: PromptListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: PromptListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/prompt withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/prompt/{prompt_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/prompt withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : PromptServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PromptServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: PromptCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: PromptCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: PromptListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - PromptListPageAsync.of(PromptServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: PromptListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + PromptListPageAsync.of( + PromptServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index 4dc148d9..988acc47 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -18,89 +18,91 @@ import java.util.concurrent.CompletableFuture interface RoleServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new role. If there is an existing role with the same name as the one - * specified in the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one specified in + * the request, will return the existing role unmodified */ fun create(params: RoleCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a role object by its id */ fun retrieve(params: RoleRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a role object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ fun update(params: RoleUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created + * roles coming first */ fun list(): CompletableFuture = list(RoleListParams.none()) /** @see [list] */ - fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ fun list(params: RoleListParams = RoleListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(RoleListParams.none(), requestOptions) /** Delete a role object by its id */ fun delete(params: RoleDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace role. If there is an existing role with the same name as the - * one specified in the request, will replace the existing role with the provided - * fields + * Create or replace role. If there is an existing role with the same name as the one specified + * in the request, will replace the existing role with the provided fields */ fun replace(params: RoleReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture - /** - * A view of [RoleServiceAsync] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [RoleServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -109,77 +111,88 @@ interface RoleServiceAsync { */ @MustBeClosed fun create(params: RoleCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the - * same as [RoleServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as + * [RoleServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: RoleRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the - * same as [RoleServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as + * [RoleServiceAsync.update]. */ @MustBeClosed fun update(params: RoleUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as * [RoleServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(RoleListParams.none()) + fun list(): CompletableFuture> = + list(RoleListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: RoleListParams = RoleListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: RoleListParams = RoleListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(RoleListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(RoleListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise - * the same as [RoleServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as + * [RoleServiceAsync.delete]. */ @MustBeClosed fun delete(params: RoleDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as @@ -187,12 +200,13 @@ interface RoleServiceAsync { */ @MustBeClosed fun replace(params: RoleReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index dec426f5..f4809686 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -18,7 +18,6 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams -import com.braintrustdata.api.models.RoleListPage import com.braintrustdata.api.models.RoleListPageAsync import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams @@ -26,195 +25,246 @@ import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams import java.util.concurrent.CompletableFuture -class RoleServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class RoleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RoleServiceAsync { -) : RoleServiceAsync { - - private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: RoleServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): RoleServiceAsync.WithRawResponse = withRawResponse - override fun create(params: RoleCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/role withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/role/{role_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/role/{role_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: RoleListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: RoleListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/role withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/role/{role_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/role withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : RoleServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoleServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: RoleCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: RoleListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - RoleListPageAsync.of(RoleServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoleListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + RoleListPageAsync.of( + RoleServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt index fce4db78..442357ea 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsync.kt @@ -18,119 +18,127 @@ import java.util.concurrent.CompletableFuture interface SpanIframeServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new span_iframe. If there is an existing span_iframe with the same name - * as the one specified in the request, will return the existing span_iframe - * unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will return the existing span_iframe unmodified */ fun create(params: SpanIframeCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a span_iframe object by its id */ fun retrieve(params: SpanIframeRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a span_iframe object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: SpanIframeUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all span_iframes. The span_iframes are sorted by creation date, with - * the most recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first */ fun list(): CompletableFuture = list(SpanIframeListParams.none()) /** @see [list] */ - fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: SpanIframeListParams = SpanIframeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ - fun list(params: SpanIframeListParams = SpanIframeListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + fun list( + params: SpanIframeListParams = SpanIframeListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(SpanIframeListParams.none(), requestOptions) /** Delete a span_iframe object by its id */ fun delete(params: SpanIframeDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace span_iframe. If there is an existing span_iframe with the same - * name as the one specified in the request, will replace the existing span_iframe - * with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same name as the + * one specified in the request, will replace the existing span_iframe with the provided fields */ fun replace(params: SpanIframeReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * A view of [SpanIframeServiceAsync] that provides access to raw HTTP responses - * for each method. + * A view of [SpanIframeServiceAsync] that provides access to raw HTTP responses for each + * method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the - * same as [SpanIframeServiceAsync.create]. + * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as + * [SpanIframeServiceAsync.create]. */ @MustBeClosed fun create(params: SpanIframeCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is - * otherwise the same as [SpanIframeServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise + * the same as [SpanIframeServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve(params: SpanIframeRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + fun retrieve( + params: SpanIframeRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is @@ -138,62 +146,73 @@ interface SpanIframeServiceAsync { */ @MustBeClosed fun update(params: SpanIframeUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same - * as [SpanIframeServiceAsync.list]. + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as + * [SpanIframeServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(SpanIframeListParams.none()) + fun list(): CompletableFuture> = + list(SpanIframeListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: SpanIframeListParams = SpanIframeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: SpanIframeListParams = SpanIframeListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: SpanIframeListParams = SpanIframeListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(SpanIframeListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(SpanIframeListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but - * is otherwise the same as [SpanIframeServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeServiceAsync.delete]. */ @MustBeClosed fun delete(params: SpanIframeDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same - * as [SpanIframeServiceAsync.replace]. + * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as + * [SpanIframeServiceAsync.replace]. */ @MustBeClosed - fun replace(params: SpanIframeReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + fun replace( + params: SpanIframeReplaceParams + ): CompletableFuture> = replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt index c8752694..6dd3a6b3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncImpl.kt @@ -18,7 +18,6 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.SpanIFrame import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams -import com.braintrustdata.api.models.SpanIframeListPage import com.braintrustdata.api.models.SpanIframeListPageAsync import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams @@ -26,195 +25,246 @@ import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams import java.util.concurrent.CompletableFuture -class SpanIframeServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class SpanIframeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SpanIframeServiceAsync { -) : SpanIframeServiceAsync { - - private val withRawResponse: SpanIframeServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: SpanIframeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): SpanIframeServiceAsync.WithRawResponse = withRawResponse - override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/span_iframe withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/span_iframe/{span_iframe_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/span_iframe/{span_iframe_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/span_iframe withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/span_iframe/{span_iframe_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/span_iframe withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : SpanIframeServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SpanIframeServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - SpanIframeListPageAsync.of(SpanIframeServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SpanIframeListPageAsync.of( + SpanIframeServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index 8f17d844..5411c270 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -11,32 +11,30 @@ import java.util.concurrent.CompletableFuture interface TopLevelServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse - /** - * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not - * required - */ + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ fun helloWorld(): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ - fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [helloWorld] */ - fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): CompletableFuture = - helloWorld( - params, RequestOptions.none() - ) + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() + ): CompletableFuture = helloWorld(params, RequestOptions.none()) /** @see [helloWorld] */ - fun helloWorld(requestOptions: RequestOptions): CompletableFuture = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): CompletableFuture = + helloWorld(TopLevelHelloWorldParams.none(), requestOptions) /** - * A view of [TopLevelServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [TopLevelServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -45,21 +43,25 @@ interface TopLevelServiceAsync { * [TopLevelServiceAsync.helloWorld]. */ @MustBeClosed - fun helloWorld(): CompletableFuture> = helloWorld(TopLevelHelloWorldParams.none()) + fun helloWorld(): CompletableFuture> = + helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): CompletableFuture> = - helloWorld( - params, RequestOptions.none() - ) + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() + ): CompletableFuture> = helloWorld(params, RequestOptions.none()) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(requestOptions: RequestOptions): CompletableFuture> = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): CompletableFuture> = + helloWorld(TopLevelHelloWorldParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index 49f348d0..efc7d4ce 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -17,43 +17,46 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams import java.util.concurrent.CompletableFuture -class TopLevelServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class TopLevelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelServiceAsync { -) : TopLevelServiceAsync { - - private val withRawResponse: TopLevelServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: TopLevelServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): TopLevelServiceAsync.WithRawResponse = withRawResponse - override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): CompletableFuture = + override fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1 withRawResponse().helloWorld(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : TopLevelServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) - - override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - helloWorldHandler.handle(it) - } - } } + private val helloWorldHandler: Handler = + stringHandler().withErrorHandler(errorHandler) + + override fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { response.use { helloWorldHandler.handle(it) } } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index 274de7e7..2bf974c5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -14,78 +14,85 @@ import java.util.concurrent.CompletableFuture interface UserServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** Get a user object by its id */ fun retrieve(params: UserRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created + * users coming first */ fun list(): CompletableFuture = list(UserListParams.none()) /** @see [list] */ - fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: UserListParams = UserListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [list] */ fun list(params: UserListParams = UserListParams.none()): CompletableFuture = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): CompletableFuture = list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): CompletableFuture = + list(UserListParams.none(), requestOptions) - /** - * A view of [UserServiceAsync] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the - * same as [UserServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as + * [UserServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: UserRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as * [UserServiceAsync.list]. */ @MustBeClosed - fun list(): CompletableFuture> = list(UserListParams.none()) + fun list(): CompletableFuture> = + list(UserListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: UserListParams = UserListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [list] */ @MustBeClosed - fun list(params: UserListParams = UserListParams.none()): CompletableFuture> = - list( - params, RequestOptions.none() - ) + fun list( + params: UserListParams = UserListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): CompletableFuture> = list(UserListParams.none(), requestOptions) + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(UserListParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 3041b017..54c73c41 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -15,85 +15,103 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.User -import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListPageAsync import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import java.util.concurrent.CompletableFuture -class UserServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UserServiceAsync { -) : UserServiceAsync { - - private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): UserServiceAsync.WithRawResponse = withRawResponse - override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/user/{user_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list(params: UserListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: UserListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/user withRawResponse().list(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : UserServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UserServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + override fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - override fun list(params: UserListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - UserListPageAsync.of(UserServiceAsyncImpl(clientOptions), params, it) - } - } } + override fun list( + params: UserListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + UserListPageAsync.of( + UserServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index 8134d5a3..f70248e9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -18,83 +18,84 @@ import java.util.concurrent.CompletableFuture interface ViewServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new view. If there is an existing view with the same name as the one - * specified in the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one specified in + * the request, will return the existing view unmodified */ fun create(params: ViewCreateParams): CompletableFuture = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Get a view object by its id */ fun retrieve(params: ViewRetrieveParams): CompletableFuture = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Partially update a view object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ fun update(params: ViewUpdateParams): CompletableFuture = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created + * views coming first */ fun list(params: ViewListParams): CompletableFuture = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Delete a view object by its id */ fun delete(params: ViewDeleteParams): CompletableFuture = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Create or replace view. If there is an existing view with the same name as the - * one specified in the request, will replace the existing view with the provided - * fields + * Create or replace view. If there is an existing view with the same name as the one specified + * in the request, will replace the existing view with the provided fields */ fun replace(params: ViewReplaceParams): CompletableFuture = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture - /** - * A view of [ViewServiceAsync] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [ViewServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -103,41 +104,44 @@ interface ViewServiceAsync { */ @MustBeClosed fun create(params: ViewCreateParams): CompletableFuture> = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the - * same as [ViewServiceAsync.retrieve]. + * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as + * [ViewServiceAsync.retrieve]. */ @MustBeClosed fun retrieve(params: ViewRetrieveParams): CompletableFuture> = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the - * same as [ViewServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as + * [ViewServiceAsync.update]. */ @MustBeClosed fun update(params: ViewUpdateParams): CompletableFuture> = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as @@ -145,27 +149,29 @@ interface ViewServiceAsync { */ @MustBeClosed fun list(params: ViewListParams): CompletableFuture> = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise - * the same as [ViewServiceAsync.delete]. + * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as + * [ViewServiceAsync.delete]. */ @MustBeClosed fun delete(params: ViewDeleteParams): CompletableFuture> = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as @@ -173,12 +179,13 @@ interface ViewServiceAsync { */ @MustBeClosed fun replace(params: ViewReplaceParams): CompletableFuture> = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index 2da433b4..644bd149 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -18,7 +18,6 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams -import com.braintrustdata.api.models.ViewListPage import com.braintrustdata.api.models.ViewListPageAsync import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams @@ -26,195 +25,246 @@ import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams import java.util.concurrent.CompletableFuture -class ViewServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class ViewServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ViewServiceAsync { -) : ViewServiceAsync { - - private val withRawResponse: ViewServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ViewServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ViewServiceAsync.WithRawResponse = withRawResponse - override fun create(params: ViewCreateParams, requestOptions: RequestOptions): CompletableFuture = + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/view withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): CompletableFuture = + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/view/{view_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/view/{view_id} withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list(params: ViewListParams, requestOptions: RequestOptions): CompletableFuture = + override fun list( + params: ViewListParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/view withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): CompletableFuture = + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = // delete /v1/view/{view_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): CompletableFuture = + override fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = // put /v1/view withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ViewServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ViewServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ViewCreateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ViewListParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ViewListPageAsync.of(ViewServiceAsyncImpl(clientOptions), params, it) - } - } } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ViewListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ViewListPageAsync.of( + ViewServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt index e27990ac..78042415 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt @@ -12,52 +12,61 @@ import java.util.concurrent.CompletableFuture interface MemberServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** Modify organization membership */ - fun update(): CompletableFuture = update(OrganizationMemberUpdateParams.none()) + fun update(): CompletableFuture = + update(OrganizationMemberUpdateParams.none()) /** @see [update] */ - fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** @see [update] */ - fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): CompletableFuture = - update( - params, RequestOptions.none() - ) + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() + ): CompletableFuture = update(params, RequestOptions.none()) /** @see [update] */ - fun update(requestOptions: RequestOptions): CompletableFuture = update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): CompletableFuture = + update(OrganizationMemberUpdateParams.none(), requestOptions) /** - * A view of [MemberServiceAsync] that provides access to raw HTTP responses for - * each method. + * A view of [MemberServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `patch /v1/organization/members`, but is - * otherwise the same as [MemberServiceAsync.update]. + * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the + * same as [MemberServiceAsync.update]. */ @MustBeClosed - fun update(): CompletableFuture> = update(OrganizationMemberUpdateParams.none()) + fun update(): CompletableFuture> = + update(OrganizationMemberUpdateParams.none()) /** @see [update] */ @MustBeClosed - fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** @see [update] */ @MustBeClosed - fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): CompletableFuture> = - update( - params, RequestOptions.none() - ) + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() + ): CompletableFuture> = + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(requestOptions: RequestOptions): CompletableFuture> = update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update( + requestOptions: RequestOptions + ): CompletableFuture> = + update(OrganizationMemberUpdateParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt index 82c4ff17..ac1cca4a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt @@ -19,49 +19,56 @@ import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput import java.util.concurrent.CompletableFuture -class MemberServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class MemberServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync { -) : MemberServiceAsync { - - private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: MemberServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): MemberServiceAsync.WithRawResponse = withRawResponse - override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): CompletableFuture = + override fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = // patch /v1/organization/members withRawResponse().update(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : MemberServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + override fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt index 1b67edf9..b1d19e58 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt @@ -17,115 +17,128 @@ import java.util.concurrent.CompletableFuture interface LogServiceAsync { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** Log feedback for a set of project logs events */ fun feedback(params: ProjectLogFeedbackParams): CompletableFuture = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ - fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body. - * For more complex queries, use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ fun fetch(params: ProjectLogFetchParams): CompletableFuture = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ - fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ - fun fetchPost(params: ProjectLogFetchPostParams): CompletableFuture = - fetchPost( - params, RequestOptions.none() - ) + fun fetchPost( + params: ProjectLogFetchPostParams + ): CompletableFuture = fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ - fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** Insert a set of events into the project logs */ fun insert(params: ProjectLogInsertParams): CompletableFuture = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ - fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture + fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture - /** - * A view of [LogServiceAsync] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [LogServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, - * but is otherwise the same as [LogServiceAsync.feedback]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is + * otherwise the same as [LogServiceAsync.feedback]. */ @MustBeClosed - fun feedback(params: ProjectLogFeedbackParams): CompletableFuture> = - feedback( - params, RequestOptions.none() - ) + fun feedback( + params: ProjectLogFeedbackParams + ): CompletableFuture> = + feedback(params, RequestOptions.none()) /** @see [feedback] */ @MustBeClosed - fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but - * is otherwise the same as [LogServiceAsync.fetch]. + * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is + * otherwise the same as [LogServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: ProjectLogFetchParams): CompletableFuture> = - fetch( - params, RequestOptions.none() - ) + fun fetch( + params: ProjectLogFetchParams + ): CompletableFuture> = + fetch(params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed - fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but - * is otherwise the same as [LogServiceAsync.fetchPost]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is + * otherwise the same as [LogServiceAsync.fetchPost]. */ @MustBeClosed - fun fetchPost(params: ProjectLogFetchPostParams): CompletableFuture> = - fetchPost( - params, RequestOptions.none() - ) + fun fetchPost( + params: ProjectLogFetchPostParams + ): CompletableFuture> = + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but - * is otherwise the same as [LogServiceAsync.insert]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is + * otherwise the same as [LogServiceAsync.insert]. */ @MustBeClosed - fun insert(params: ProjectLogInsertParams): CompletableFuture> = - insert( - params, RequestOptions.none() - ) + fun insert( + params: ProjectLogInsertParams + ): CompletableFuture> = + insert(params, RequestOptions.none()) /** @see [insert] */ @MustBeClosed - fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): CompletableFuture> + fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt index abb30573..7c47266f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt @@ -24,135 +24,169 @@ import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams import java.util.concurrent.CompletableFuture -class LogServiceAsyncImpl internal constructor( - private val clientOptions: ClientOptions, +class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LogServiceAsync { -) : LogServiceAsync { - - private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): LogServiceAsync.WithRawResponse = withRawResponse - override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): CompletableFuture = + override fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/project_logs/{project_id}/feedback withRawResponse().feedback(params, requestOptions).thenApply { it.parse() } - override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): CompletableFuture = + override fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture = // get /v1/project_logs/{project_id}/fetch withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): CompletableFuture = + override fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/project_logs/{project_id}/fetch withRawResponse().fetchPost(params, requestOptions).thenApply { it.parse() } - override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): CompletableFuture = + override fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture = // post /v1/project_logs/{project_id}/insert withRawResponse().insert(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : LogServiceAsync.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LogServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - feedbackHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - fetchHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - fetchPostHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } - private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): CompletableFuture> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - return request.thenComposeAsync { clientOptions.httpClient.executeAsync( - it, requestOptions - ) }.thenApply { response -> response.parseable { - response.use { - insertHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } } + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index 70828f20..5d4a4de6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -18,85 +18,78 @@ import com.google.errorprone.annotations.MustBeClosed interface AclService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new acl. If there is an existing acl with the same contents as the one - * specified in the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one specified in + * the request, will return the existing acl unmodified */ - fun create(params: AclCreateParams): Acl = - create( - params, RequestOptions.none() - ) + fun create(params: AclCreateParams): Acl = create(params, RequestOptions.none()) /** @see [create] */ fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** Get an acl object by its id */ - fun retrieve(params: AclRetrieveParams): Acl = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: AclRetrieveParams): Acl = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Acl + fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Acl /** - * List out all acls. The acls are sorted by creation date, with the most - * recently-created acls coming first + * List out all acls. The acls are sorted by creation date, with the most recently-created acls + * coming first */ - fun list(params: AclListParams): AclListPage = - list( - params, RequestOptions.none() - ) + fun list(params: AclListParams): AclListPage = list(params, RequestOptions.none()) /** @see [list] */ - fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): AclListPage + fun list( + params: AclListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AclListPage /** Delete an acl object by its id */ - fun delete(params: AclDeleteParams): Acl = - delete( - params, RequestOptions.none() - ) + fun delete(params: AclDeleteParams): Acl = delete(params, RequestOptions.none()) /** @see [delete] */ fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** - * Batch update acls. This operation is idempotent, so adding acls which already - * exist will have no effect, and removing acls which do not exist will have no - * effect. + * Batch update acls. This operation is idempotent, so adding acls which already exist will have + * no effect, and removing acls which do not exist will have no effect. */ fun batchUpdate(): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ - fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): AclBatchUpdateResponse + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AclBatchUpdateResponse /** @see [batchUpdate] */ - fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): AclBatchUpdateResponse = - batchUpdate( - params, RequestOptions.none() - ) + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): AclBatchUpdateResponse = batchUpdate(params, RequestOptions.none()) /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): Acl = - findAndDelete( - params, RequestOptions.none() - ) + findAndDelete(params, RequestOptions.none()) /** @see [findAndDelete] */ - fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl + fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Acl - /** - * A view of [AclService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [AclService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -105,27 +98,29 @@ interface AclService { */ @MustBeClosed fun create(params: AclCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: AclCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the - * same as [AclService.retrieve]. + * Returns a raw HTTP response for `get /v1/acl/{acl_id}`, but is otherwise the same as + * [AclService.retrieve]. */ @MustBeClosed fun retrieve(params: AclRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/acl`, but is otherwise the same as @@ -133,49 +128,55 @@ interface AclService { */ @MustBeClosed fun list(params: AclListParams): HttpResponseFor = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: AclListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the - * same as [AclService.delete]. + * Returns a raw HTTP response for `delete /v1/acl/{acl_id}`, but is otherwise the same as + * [AclService.delete]. */ @MustBeClosed fun delete(params: AclDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise - * the same as [AclService.batchUpdate]. + * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as + * [AclService.batchUpdate]. */ @MustBeClosed - fun batchUpdate(): HttpResponseFor = batchUpdate(AclBatchUpdateParams.none()) + fun batchUpdate(): HttpResponseFor = + batchUpdate(AclBatchUpdateParams.none()) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate(params: AclBatchUpdateParams = AclBatchUpdateParams.none()): HttpResponseFor = - batchUpdate( - params, RequestOptions.none() - ) + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): HttpResponseFor = batchUpdate(params, RequestOptions.none()) /** @see [batchUpdate] */ @MustBeClosed - fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = batchUpdate(AclBatchUpdateParams.none(), requestOptions) + fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as @@ -183,12 +184,13 @@ interface AclService { */ @MustBeClosed fun findAndDelete(params: AclFindAndDeleteParams): HttpResponseFor = - findAndDelete( - params, RequestOptions.none() - ) + findAndDelete(params, RequestOptions.none()) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index de7b127f..39e18573 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -25,12 +25,11 @@ import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams -class AclServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class AclServiceImpl internal constructor(private val clientOptions: ClientOptions) : AclService { -) : AclService { - - private val withRawResponse: AclService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: AclService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): AclService.WithRawResponse = withRawResponse @@ -50,176 +49,186 @@ class AclServiceImpl internal constructor( // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).parse() - override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): AclBatchUpdateResponse = + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): AclBatchUpdateResponse = // post /v1/acl/batch-update withRawResponse().batchUpdate(params, requestOptions).parse() - override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): Acl = + override fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions, + ): Acl = // delete /v1/acl withRawResponse().findAndDelete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : AclService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AclService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: AclCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: AclCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AclRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: AclListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - AclListPage.of(AclServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AclListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { AclListPage.of(AclServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: AclDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val batchUpdateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun batchUpdate(params: AclBatchUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - batchUpdateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val batchUpdateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch-update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { batchUpdateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete(params: AclFindAndDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - findAndDeleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val findAndDeleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete( + params: AclFindAndDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt index b796ff67..867aab8c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretService.kt @@ -18,204 +18,211 @@ import com.google.errorprone.annotations.MustBeClosed interface AiSecretService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new ai_secret. If there is an existing ai_secret with the same name as - * the one specified in the request, will return the existing ai_secret unmodified + * Create a new ai_secret. If there is an existing ai_secret with the same name as the one + * specified in the request, will return the existing ai_secret unmodified */ - fun create(params: AiSecretCreateParams): AISecret = - create( - params, RequestOptions.none() - ) + fun create(params: AiSecretCreateParams): AISecret = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret + fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AISecret /** Get an ai_secret object by its id */ - fun retrieve(params: AiSecretRetrieveParams): AISecret = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: AiSecretRetrieveParams): AISecret = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret + fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AISecret /** - * Partially update an ai_secret object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an ai_secret object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: AiSecretUpdateParams): AISecret = - update( - params, RequestOptions.none() - ) + fun update(params: AiSecretUpdateParams): AISecret = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret + fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AISecret /** - * List out all ai_secrets. The ai_secrets are sorted by creation date, with the - * most recently-created ai_secrets coming first + * List out all ai_secrets. The ai_secrets are sorted by creation date, with the most + * recently-created ai_secrets coming first */ fun list(): AiSecretListPage = list(AiSecretListParams.none()) /** @see [list] */ - fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): AiSecretListPage + fun list( + params: AiSecretListParams = AiSecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AiSecretListPage /** @see [list] */ fun list(params: AiSecretListParams = AiSecretListParams.none()): AiSecretListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): AiSecretListPage = list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): AiSecretListPage = + list(AiSecretListParams.none(), requestOptions) /** Delete an ai_secret object by its id */ - fun delete(params: AiSecretDeleteParams): AISecret = - delete( - params, RequestOptions.none() - ) + fun delete(params: AiSecretDeleteParams): AISecret = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret + fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AISecret /** Delete a single ai_secret */ fun findAndDelete(params: AiSecretFindAndDeleteParams): AISecret = - findAndDelete( - params, RequestOptions.none() - ) + findAndDelete(params, RequestOptions.none()) /** @see [findAndDelete] */ - fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret + fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AISecret /** - * Create or replace ai_secret. If there is an existing ai_secret with the same - * name as the one specified in the request, will replace the existing ai_secret - * with the provided fields + * Create or replace ai_secret. If there is an existing ai_secret with the same name as the one + * specified in the request, will replace the existing ai_secret with the provided fields */ - fun replace(params: AiSecretReplaceParams): AISecret = - replace( - params, RequestOptions.none() - ) + fun replace(params: AiSecretReplaceParams): AISecret = replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): AISecret + fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AISecret - /** - * A view of [AiSecretService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [AiSecretService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same - * as [AiSecretService.create]. + * Returns a raw HTTP response for `post /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.create]. */ @MustBeClosed fun create(params: AiSecretCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: AiSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is - * otherwise the same as [AiSecretService.retrieve]. + * Returns a raw HTTP response for `get /v1/ai_secret/{ai_secret_id}`, but is otherwise the + * same as [AiSecretService.retrieve]. */ @MustBeClosed fun retrieve(params: AiSecretRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is - * otherwise the same as [AiSecretService.update]. + * Returns a raw HTTP response for `patch /v1/ai_secret/{ai_secret_id}`, but is otherwise + * the same as [AiSecretService.update]. */ @MustBeClosed fun update(params: AiSecretUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same - * as [AiSecretService.list]. + * Returns a raw HTTP response for `get /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(AiSecretListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: AiSecretListParams = AiSecretListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: AiSecretListParams = AiSecretListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: AiSecretListParams = AiSecretListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: AiSecretListParams = AiSecretListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(AiSecretListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(AiSecretListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is - * otherwise the same as [AiSecretService.delete]. + * Returns a raw HTTP response for `delete /v1/ai_secret/{ai_secret_id}`, but is otherwise + * the same as [AiSecretService.delete]. */ @MustBeClosed fun delete(params: AiSecretDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the - * same as [AiSecretService.findAndDelete]. + * Returns a raw HTTP response for `delete /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.findAndDelete]. */ @MustBeClosed fun findAndDelete(params: AiSecretFindAndDeleteParams): HttpResponseFor = - findAndDelete( - params, RequestOptions.none() - ) + findAndDelete(params, RequestOptions.none()) /** @see [findAndDelete] */ @MustBeClosed - fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same - * as [AiSecretService.replace]. + * Returns a raw HTTP response for `put /v1/ai_secret`, but is otherwise the same as + * [AiSecretService.replace]. */ @MustBeClosed fun replace(params: AiSecretReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt index 74bd1cac..8824fdce 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceImpl.kt @@ -25,12 +25,12 @@ import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams -class AiSecretServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class AiSecretServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AiSecretService { -) : AiSecretService { - - private val withRawResponse: AiSecretService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: AiSecretService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): AiSecretService.WithRawResponse = withRawResponse @@ -38,7 +38,10 @@ class AiSecretServiceImpl internal constructor( // post /v1/ai_secret withRawResponse().create(params, requestOptions).parse() - override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): AISecret = + override fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions, + ): AISecret = // get /v1/ai_secret/{ai_secret_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -46,7 +49,10 @@ class AiSecretServiceImpl internal constructor( // patch /v1/ai_secret/{ai_secret_id} withRawResponse().update(params, requestOptions).parse() - override fun list(params: AiSecretListParams, requestOptions: RequestOptions): AiSecretListPage = + override fun list( + params: AiSecretListParams, + requestOptions: RequestOptions, + ): AiSecretListPage = // get /v1/ai_secret withRawResponse().list(params, requestOptions).parse() @@ -54,7 +60,10 @@ class AiSecretServiceImpl internal constructor( // delete /v1/ai_secret/{ai_secret_id} withRawResponse().delete(params, requestOptions).parse() - override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): AISecret = + override fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions, + ): AISecret = // delete /v1/ai_secret withRawResponse().findAndDelete(params, requestOptions).parse() @@ -62,194 +71,198 @@ class AiSecretServiceImpl internal constructor( // put /v1/ai_secret withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : AiSecretService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AiSecretService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: AiSecretCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: AiSecretCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: AiSecretRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AiSecretRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: AiSecretUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: AiSecretUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: AiSecretListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "ai_secret") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - AiSecretListPage.of(AiSecretServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AiSecretListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "ai_secret") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { AiSecretListPage.of(AiSecretServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: AiSecretDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: AiSecretDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun findAndDelete(params: AiSecretFindAndDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - findAndDeleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val findAndDeleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun findAndDelete( + params: AiSecretFindAndDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { findAndDeleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: AiSecretReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "ai_secret") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: AiSecretReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "ai_secret") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt index 7f3aa7e6..7f07d4a8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt @@ -16,31 +16,31 @@ import com.google.errorprone.annotations.MustBeClosed interface ApiKeyService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new api_key. It is possible to have multiple API keys with the same - * name. There is no de-duplication + * Create a new api_key. It is possible to have multiple API keys with the same name. There is + * no de-duplication */ fun create(params: ApiKeyCreateParams): CreateApiKeyOutput = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CreateApiKeyOutput + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CreateApiKeyOutput /** Get an api_key object by its id */ - fun retrieve(params: ApiKeyRetrieveParams): ApiKey = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: ApiKeyRetrieveParams): ApiKey = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey + fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKey /** * List out all api_keys. The api_keys are sorted by creation date, with the most @@ -49,30 +49,29 @@ interface ApiKeyService { fun list(): ApiKeyListPage = list(ApiKeyListParams.none()) /** @see [list] */ - fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ApiKeyListPage + fun list( + params: ApiKeyListParams = ApiKeyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyListPage /** @see [list] */ fun list(params: ApiKeyListParams = ApiKeyListParams.none()): ApiKeyListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): ApiKeyListPage = list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ApiKeyListPage = + list(ApiKeyListParams.none(), requestOptions) /** Delete an api_key object by its id */ - fun delete(params: ApiKeyDeleteParams): ApiKey = - delete( - params, RequestOptions.none() - ) + fun delete(params: ApiKeyDeleteParams): ApiKey = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKey - /** - * A view of [ApiKeyService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [ApiKeyService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -81,62 +80,67 @@ interface ApiKeyService { */ @MustBeClosed fun create(params: ApiKeyCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise - * the same as [ApiKeyService.retrieve]. + * Returns a raw HTTP response for `get /v1/api_key/{api_key_id}`, but is otherwise the same + * as [ApiKeyService.retrieve]. */ @MustBeClosed fun retrieve(params: ApiKeyRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/api_key`, but is otherwise the same as * [ApiKeyService.list]. */ - @MustBeClosed - fun list(): HttpResponseFor = list(ApiKeyListParams.none()) + @MustBeClosed fun list(): HttpResponseFor = list(ApiKeyListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ApiKeyListParams = ApiKeyListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: ApiKeyListParams = ApiKeyListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: ApiKeyListParams = ApiKeyListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: ApiKeyListParams = ApiKeyListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(ApiKeyListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ApiKeyListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is - * otherwise the same as [ApiKeyService.delete]. + * Returns a raw HTTP response for `delete /v1/api_key/{api_key_id}`, but is otherwise the + * same as [ApiKeyService.delete]. */ @MustBeClosed fun delete(params: ApiKeyDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt index 92710f6f..cba100a5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt @@ -23,16 +23,19 @@ import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput -class ApiKeyServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyService { -) : ApiKeyService { - - private val withRawResponse: ApiKeyService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ApiKeyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ApiKeyService.WithRawResponse = withRawResponse - override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): CreateApiKeyOutput = + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): CreateApiKeyOutput = // post /v1/api_key withRawResponse().create(params, requestOptions).parse() @@ -48,116 +51,117 @@ class ApiKeyServiceImpl internal constructor( // delete /v1/api_key/{api_key_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ApiKeyService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ApiKeyCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ApiKeyRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ApiKeyListPage.of(ApiKeyServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ApiKeyListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ApiKeyListPage.of(ApiKeyServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ApiKeyDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 43c28c5e..91a18478 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -25,45 +25,43 @@ import com.google.errorprone.annotations.MustBeClosed interface DatasetService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new dataset. If there is an existing dataset in the project with the - * same name as the one specified in the request, will return the existing dataset - * unmodified + * Create a new dataset. If there is an existing dataset in the project with the same name as + * the one specified in the request, will return the existing dataset unmodified */ - fun create(params: DatasetCreateParams): Dataset = - create( - params, RequestOptions.none() - ) + fun create(params: DatasetCreateParams): Dataset = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Dataset /** Get a dataset object by its id */ - fun retrieve(params: DatasetRetrieveParams): Dataset = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: DatasetRetrieveParams): Dataset = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Dataset /** - * Partially update a dataset object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: DatasetUpdateParams): Dataset = - update( - params, RequestOptions.none() - ) + fun update(params: DatasetUpdateParams): Dataset = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Dataset /** * List out all datasets. The datasets are sorted by creation date, with the most @@ -72,83 +70,87 @@ interface DatasetService { fun list(): DatasetListPage = list(DatasetListParams.none()) /** @see [list] */ - fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): DatasetListPage + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DatasetListPage /** @see [list] */ fun list(params: DatasetListParams = DatasetListParams.none()): DatasetListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): DatasetListPage = list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): DatasetListPage = + list(DatasetListParams.none(), requestOptions) /** Delete a dataset object by its id */ - fun delete(params: DatasetDeleteParams): Dataset = - delete( - params, RequestOptions.none() - ) + fun delete(params: DatasetDeleteParams): Dataset = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Dataset /** Log feedback for a set of dataset events */ fun feedback(params: DatasetFeedbackParams): FeedbackResponseSchema = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ - fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema + fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackResponseSchema /** - * Fetch the events in a dataset. Equivalent to the POST form of the same path, but - * with the parameters in the URL query rather than in the request body. For more - * complex queries, use the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ fun fetch(params: DatasetFetchParams): FetchDatasetEventsResponse = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ - fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchDatasetEventsResponse + fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchDatasetEventsResponse /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but - * with the parameters in the request body rather than in the URL query. For more - * complex queries, use the `POST /btql` endpoint. + * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ fun fetchPost(params: DatasetFetchPostParams): FetchDatasetEventsResponse = - fetchPost( - params, RequestOptions.none() - ) + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ - fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchDatasetEventsResponse + fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchDatasetEventsResponse /** Insert a set of events into the dataset */ fun insert(params: DatasetInsertParams): InsertEventsResponse = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ - fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse + fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsertEventsResponse /** Summarize dataset */ fun summarize(params: DatasetSummarizeParams): SummarizeDatasetResponse = - summarize( - params, RequestOptions.none() - ) + summarize(params, RequestOptions.none()) /** @see [summarize] */ - fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeDatasetResponse + fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SummarizeDatasetResponse - /** - * A view of [DatasetService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [DatasetService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -157,77 +159,83 @@ interface DatasetService { */ @MustBeClosed fun create(params: DatasetCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise - * the same as [DatasetService.retrieve]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}`, but is otherwise the same + * as [DatasetService.retrieve]. */ @MustBeClosed fun retrieve(params: DatasetRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is - * otherwise the same as [DatasetService.update]. + * Returns a raw HTTP response for `patch /v1/dataset/{dataset_id}`, but is otherwise the + * same as [DatasetService.update]. */ @MustBeClosed fun update(params: DatasetUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/dataset`, but is otherwise the same as * [DatasetService.list]. */ - @MustBeClosed - fun list(): HttpResponseFor = list(DatasetListParams.none()) + @MustBeClosed fun list(): HttpResponseFor = list(DatasetListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: DatasetListParams = DatasetListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: DatasetListParams = DatasetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: DatasetListParams = DatasetListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: DatasetListParams = DatasetListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(DatasetListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(DatasetListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is - * otherwise the same as [DatasetService.delete]. + * Returns a raw HTTP response for `delete /v1/dataset/{dataset_id}`, but is otherwise the + * same as [DatasetService.delete]. */ @MustBeClosed fun delete(params: DatasetDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/feedback`, but is @@ -235,55 +243,59 @@ interface DatasetService { */ @MustBeClosed fun feedback(params: DatasetFeedbackParams): HttpResponseFor = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ @MustBeClosed - fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is - * otherwise the same as [DatasetService.fetch]. + * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/fetch`, but is otherwise + * the same as [DatasetService.fetch]. */ @MustBeClosed fun fetch(params: DatasetFetchParams): HttpResponseFor = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed - fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is - * otherwise the same as [DatasetService.fetchPost]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/fetch`, but is otherwise + * the same as [DatasetService.fetchPost]. */ @MustBeClosed fun fetchPost(params: DatasetFetchPostParams): HttpResponseFor = - fetchPost( - params, RequestOptions.none() - ) + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is - * otherwise the same as [DatasetService.insert]. + * Returns a raw HTTP response for `post /v1/dataset/{dataset_id}/insert`, but is otherwise + * the same as [DatasetService.insert]. */ @MustBeClosed fun insert(params: DatasetInsertParams): HttpResponseFor = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ @MustBeClosed - fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/dataset/{dataset_id}/summarize`, but is @@ -291,12 +303,13 @@ interface DatasetService { */ @MustBeClosed fun summarize(params: DatasetSummarizeParams): HttpResponseFor = - summarize( - params, RequestOptions.none() - ) + summarize(params, RequestOptions.none()) /** @see [summarize] */ @MustBeClosed - fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 652d92dc..033ed993 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -32,12 +32,12 @@ import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse -class DatasetServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class DatasetServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService { -) : DatasetService { - - private val withRawResponse: DatasetService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: DatasetService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): DatasetService.WithRawResponse = withRawResponse @@ -61,290 +61,317 @@ class DatasetServiceImpl internal constructor( // delete /v1/dataset/{dataset_id} withRawResponse().delete(params, requestOptions).parse() - override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = + override fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions, + ): FeedbackResponseSchema = // post /v1/dataset/{dataset_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): FetchDatasetEventsResponse = + override fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions, + ): FetchDatasetEventsResponse = // get /v1/dataset/{dataset_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): FetchDatasetEventsResponse = + override fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions, + ): FetchDatasetEventsResponse = // post /v1/dataset/{dataset_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): InsertEventsResponse = + override fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions, + ): InsertEventsResponse = // post /v1/dataset/{dataset_id}/insert withRawResponse().insert(params, requestOptions).parse() - override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): SummarizeDatasetResponse = + override fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions, + ): SummarizeDatasetResponse = // get /v1/dataset/{dataset_id}/summarize withRawResponse().summarize(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : DatasetService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DatasetService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: DatasetCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: DatasetRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: DatasetUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: DatasetListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - DatasetListPage.of(DatasetServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: DatasetListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { DatasetListPage.of(DatasetServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: DatasetDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - feedbackHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: DatasetFeedbackParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - fetchHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: DatasetFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - fetchPostHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: DatasetFetchPostParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - insertHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: DatasetInsertParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - summarizeHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun summarize( + params: DatasetSummarizeParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt index 4c8e6a9a..843a4762 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarService.kt @@ -17,44 +17,43 @@ import com.google.errorprone.annotations.MustBeClosed interface EnvVarService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new env_var. If there is an existing env_var with the same name as the - * one specified in the request, will return the existing env_var unmodified + * Create a new env_var. If there is an existing env_var with the same name as the one specified + * in the request, will return the existing env_var unmodified */ - fun create(params: EnvVarCreateParams): EnvVar = - create( - params, RequestOptions.none() - ) + fun create(params: EnvVarCreateParams): EnvVar = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar + fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EnvVar /** Get an env_var object by its id */ - fun retrieve(params: EnvVarRetrieveParams): EnvVar = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: EnvVarRetrieveParams): EnvVar = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar + fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EnvVar /** - * Partially update an env_var object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update an env_var object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: EnvVarUpdateParams): EnvVar = - update( - params, RequestOptions.none() - ) + fun update(params: EnvVarUpdateParams): EnvVar = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar + fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EnvVar /** * List out all env_vars. The env_vars are sorted by creation date, with the most @@ -63,43 +62,41 @@ interface EnvVarService { fun list(): EnvVarListResponse = list(EnvVarListParams.none()) /** @see [list] */ - fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): EnvVarListResponse + fun list( + params: EnvVarListParams = EnvVarListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EnvVarListResponse /** @see [list] */ fun list(params: EnvVarListParams = EnvVarListParams.none()): EnvVarListResponse = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): EnvVarListResponse = list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): EnvVarListResponse = + list(EnvVarListParams.none(), requestOptions) /** Delete an env_var object by its id */ - fun delete(params: EnvVarDeleteParams): EnvVar = - delete( - params, RequestOptions.none() - ) + fun delete(params: EnvVarDeleteParams): EnvVar = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar + fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EnvVar /** - * Create or replace env_var. If there is an existing env_var with the same name as - * the one specified in the request, will replace the existing env_var with the - * provided fields + * Create or replace env_var. If there is an existing env_var with the same name as the one + * specified in the request, will replace the existing env_var with the provided fields */ - fun replace(params: EnvVarReplaceParams): EnvVar = - replace( - params, RequestOptions.none() - ) + fun replace(params: EnvVarReplaceParams): EnvVar = replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): EnvVar + fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EnvVar - /** - * A view of [EnvVarService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [EnvVarService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -108,41 +105,44 @@ interface EnvVarService { */ @MustBeClosed fun create(params: EnvVarCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: EnvVarCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise - * the same as [EnvVarService.retrieve]. + * Returns a raw HTTP response for `get /v1/env_var/{env_var_id}`, but is otherwise the same + * as [EnvVarService.retrieve]. */ @MustBeClosed fun retrieve(params: EnvVarRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is - * otherwise the same as [EnvVarService.update]. + * Returns a raw HTTP response for `patch /v1/env_var/{env_var_id}`, but is otherwise the + * same as [EnvVarService.update]. */ @MustBeClosed fun update(params: EnvVarUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/env_var`, but is otherwise the same as @@ -153,32 +153,36 @@ interface EnvVarService { /** @see [list] */ @MustBeClosed - fun list(params: EnvVarListParams = EnvVarListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: EnvVarListParams = EnvVarListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: EnvVarListParams = EnvVarListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: EnvVarListParams = EnvVarListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(EnvVarListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(EnvVarListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is - * otherwise the same as [EnvVarService.delete]. + * Returns a raw HTTP response for `delete /v1/env_var/{env_var_id}`, but is otherwise the + * same as [EnvVarService.delete]. */ @MustBeClosed fun delete(params: EnvVarDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/env_var`, but is otherwise the same as @@ -186,12 +190,13 @@ interface EnvVarService { */ @MustBeClosed fun replace(params: EnvVarReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt index 00059edc..aa611b8f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EnvVarServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.EnvVarReplaceParams import com.braintrustdata.api.models.EnvVarRetrieveParams import com.braintrustdata.api.models.EnvVarUpdateParams -class EnvVarServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class EnvVarServiceImpl internal constructor(private val clientOptions: ClientOptions) : + EnvVarService { -) : EnvVarService { - - private val withRawResponse: EnvVarService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: EnvVarService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): EnvVarService.WithRawResponse = withRawResponse @@ -45,7 +45,10 @@ class EnvVarServiceImpl internal constructor( // patch /v1/env_var/{env_var_id} withRawResponse().update(params, requestOptions).parse() - override fun list(params: EnvVarListParams, requestOptions: RequestOptions): EnvVarListResponse = + override fun list( + params: EnvVarListParams, + requestOptions: RequestOptions, + ): EnvVarListResponse = // get /v1/env_var withRawResponse().list(params, requestOptions).parse() @@ -57,165 +60,169 @@ class EnvVarServiceImpl internal constructor( // put /v1/env_var withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : EnvVarService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EnvVarService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: EnvVarCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: EnvVarCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: EnvVarRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: EnvVarRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: EnvVarUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: EnvVarUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: EnvVarListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "env_var") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list( + params: EnvVarListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "env_var") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: EnvVarDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "env_var", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: EnvVarDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "env_var", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: EnvVarReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "env_var") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: EnvVarReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "env_var") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt index 2a8701e1..fa1bcc99 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalService.kt @@ -11,31 +11,27 @@ import com.google.errorprone.annotations.MustBeClosed interface EvalService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Launch an evaluation. This is the API-equivalent of the `Eval` function that is - * built into the Braintrust SDK. In the Eval API, you provide pointers to a - * dataset, task function, and scoring functions. The API will then run the - * evaluation, create an experiment, and return the results along with a link to - * the experiment. To learn more about evals, see the + * Launch an evaluation. This is the API-equivalent of the `Eval` function that is built into + * the Braintrust SDK. In the Eval API, you provide pointers to a dataset, task function, and + * scoring functions. The API will then run the evaluation, create an experiment, and return the + * results along with a link to the experiment. To learn more about evals, see the * [Evals guide](https://www.braintrust.dev/docs/guides/evals). */ fun create(params: EvalCreateParams): SummarizeExperimentResponse = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeExperimentResponse + fun create( + params: EvalCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SummarizeExperimentResponse - /** - * A view of [EvalService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [EvalService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -44,12 +40,13 @@ interface EvalService { */ @MustBeClosed fun create(params: EvalCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: EvalCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: EvalCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt index 124d8a1c..e761eba5 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/EvalServiceImpl.kt @@ -18,50 +18,52 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.EvalCreateParams import com.braintrustdata.api.models.SummarizeExperimentResponse -class EvalServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class EvalServiceImpl internal constructor(private val clientOptions: ClientOptions) : EvalService { -) : EvalService { - - private val withRawResponse: EvalService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: EvalService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): EvalService.WithRawResponse = withRawResponse - override fun create(params: EvalCreateParams, requestOptions: RequestOptions): SummarizeExperimentResponse = + override fun create( + params: EvalCreateParams, + requestOptions: RequestOptions, + ): SummarizeExperimentResponse = // post /v1/eval withRawResponse().create(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : EvalService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EvalService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - override fun create(params: EvalCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "eval") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun create( + params: EvalCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "eval") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index 4a23c31f..17bc351f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -25,278 +25,295 @@ import com.google.errorprone.annotations.MustBeClosed interface ExperimentService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new experiment. If there is an existing experiment in the project with - * the same name as the one specified in the request, will return the existing - * experiment unmodified + * Create a new experiment. If there is an existing experiment in the project with the same name + * as the one specified in the request, will return the existing experiment unmodified */ - fun create(params: ExperimentCreateParams): Experiment = - create( - params, RequestOptions.none() - ) + fun create(params: ExperimentCreateParams): Experiment = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment + fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Experiment /** Get an experiment object by its id */ fun retrieve(params: ExperimentRetrieveParams): Experiment = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment + fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Experiment /** - * Partially update an experiment object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: ExperimentUpdateParams): Experiment = - update( - params, RequestOptions.none() - ) + fun update(params: ExperimentUpdateParams): Experiment = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment + fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Experiment /** - * List out all experiments. The experiments are sorted by creation date, with the - * most recently-created experiments coming first + * List out all experiments. The experiments are sorted by creation date, with the most + * recently-created experiments coming first */ fun list(): ExperimentListPage = list(ExperimentListParams.none()) /** @see [list] */ - fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ExperimentListPage + fun list( + params: ExperimentListParams = ExperimentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ExperimentListPage /** @see [list] */ fun list(params: ExperimentListParams = ExperimentListParams.none()): ExperimentListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): ExperimentListPage = list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ExperimentListPage = + list(ExperimentListParams.none(), requestOptions) /** Delete an experiment object by its id */ - fun delete(params: ExperimentDeleteParams): Experiment = - delete( - params, RequestOptions.none() - ) + fun delete(params: ExperimentDeleteParams): Experiment = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment + fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Experiment /** Log feedback for a set of experiment events */ fun feedback(params: ExperimentFeedbackParams): FeedbackResponseSchema = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ - fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema + fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackResponseSchema /** - * Fetch the events in an experiment. Equivalent to the POST form of the same path, - * but with the parameters in the URL query rather than in the request body. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the + * parameters in the URL query rather than in the request body. For more complex queries, use + * the `POST /btql` endpoint. */ fun fetch(params: ExperimentFetchParams): FetchExperimentEventsResponse = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ - fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchExperimentEventsResponse + fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchExperimentEventsResponse /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ fun fetchPost(params: ExperimentFetchPostParams): FetchExperimentEventsResponse = - fetchPost( - params, RequestOptions.none() - ) + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ - fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchExperimentEventsResponse + fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchExperimentEventsResponse /** Insert a set of events into the experiment */ fun insert(params: ExperimentInsertParams): InsertEventsResponse = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ - fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse + fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsertEventsResponse /** Summarize experiment */ fun summarize(params: ExperimentSummarizeParams): SummarizeExperimentResponse = - summarize( - params, RequestOptions.none() - ) + summarize(params, RequestOptions.none()) /** @see [summarize] */ - fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeExperimentResponse + fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SummarizeExperimentResponse - /** - * A view of [ExperimentService] that provides access to raw HTTP responses for - * each method. - */ + /** A view of [ExperimentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same - * as [ExperimentService.create]. + * Returns a raw HTTP response for `post /v1/experiment`, but is otherwise the same as + * [ExperimentService.create]. */ @MustBeClosed fun create(params: ExperimentCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is - * otherwise the same as [ExperimentService.retrieve]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentService.retrieve]. */ @MustBeClosed fun retrieve(params: ExperimentRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is - * otherwise the same as [ExperimentService.update]. + * Returns a raw HTTP response for `patch /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentService.update]. */ @MustBeClosed fun update(params: ExperimentUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same - * as [ExperimentService.list]. + * Returns a raw HTTP response for `get /v1/experiment`, but is otherwise the same as + * [ExperimentService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ExperimentListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ExperimentListParams = ExperimentListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: ExperimentListParams = ExperimentListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: ExperimentListParams = ExperimentListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: ExperimentListParams = ExperimentListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(ExperimentListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ExperimentListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is - * otherwise the same as [ExperimentService.delete]. + * Returns a raw HTTP response for `delete /v1/experiment/{experiment_id}`, but is otherwise + * the same as [ExperimentService.delete]. */ @MustBeClosed fun delete(params: ExperimentDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, - * but is otherwise the same as [ExperimentService.feedback]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/feedback`, but is + * otherwise the same as [ExperimentService.feedback]. */ @MustBeClosed fun feedback(params: ExperimentFeedbackParams): HttpResponseFor = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ @MustBeClosed - fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but - * is otherwise the same as [ExperimentService.fetch]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/fetch`, but is + * otherwise the same as [ExperimentService.fetch]. */ @MustBeClosed fun fetch(params: ExperimentFetchParams): HttpResponseFor = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed - fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but - * is otherwise the same as [ExperimentService.fetchPost]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/fetch`, but is + * otherwise the same as [ExperimentService.fetchPost]. */ @MustBeClosed - fun fetchPost(params: ExperimentFetchPostParams): HttpResponseFor = - fetchPost( - params, RequestOptions.none() - ) + fun fetchPost( + params: ExperimentFetchPostParams + ): HttpResponseFor = fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, - * but is otherwise the same as [ExperimentService.insert]. + * Returns a raw HTTP response for `post /v1/experiment/{experiment_id}/insert`, but is + * otherwise the same as [ExperimentService.insert]. */ @MustBeClosed fun insert(params: ExperimentInsertParams): HttpResponseFor = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ @MustBeClosed - fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, - * but is otherwise the same as [ExperimentService.summarize]. + * Returns a raw HTTP response for `get /v1/experiment/{experiment_id}/summarize`, but is + * otherwise the same as [ExperimentService.summarize]. */ @MustBeClosed - fun summarize(params: ExperimentSummarizeParams): HttpResponseFor = - summarize( - params, RequestOptions.none() - ) + fun summarize( + params: ExperimentSummarizeParams + ): HttpResponseFor = summarize(params, RequestOptions.none()) /** @see [summarize] */ @MustBeClosed - fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index 2fdf032d..7ec0526e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -32,319 +32,361 @@ import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse -class ExperimentServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class ExperimentServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentService { -) : ExperimentService { - - private val withRawResponse: ExperimentService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ExperimentService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ExperimentService.WithRawResponse = withRawResponse - override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): Experiment = + override fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions, + ): Experiment = // post /v1/experiment withRawResponse().create(params, requestOptions).parse() - override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): Experiment = + override fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions, + ): Experiment = // get /v1/experiment/{experiment_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): Experiment = + override fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions, + ): Experiment = // patch /v1/experiment/{experiment_id} withRawResponse().update(params, requestOptions).parse() - override fun list(params: ExperimentListParams, requestOptions: RequestOptions): ExperimentListPage = + override fun list( + params: ExperimentListParams, + requestOptions: RequestOptions, + ): ExperimentListPage = // get /v1/experiment withRawResponse().list(params, requestOptions).parse() - override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): Experiment = + override fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions, + ): Experiment = // delete /v1/experiment/{experiment_id} withRawResponse().delete(params, requestOptions).parse() - override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = + override fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions, + ): FeedbackResponseSchema = // post /v1/experiment/{experiment_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): FetchExperimentEventsResponse = + override fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions, + ): FetchExperimentEventsResponse = // get /v1/experiment/{experiment_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): FetchExperimentEventsResponse = + override fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions, + ): FetchExperimentEventsResponse = // post /v1/experiment/{experiment_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): InsertEventsResponse = + override fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions, + ): InsertEventsResponse = // post /v1/experiment/{experiment_id}/insert withRawResponse().insert(params, requestOptions).parse() - override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): SummarizeExperimentResponse = + override fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions, + ): SummarizeExperimentResponse = // get /v1/experiment/{experiment_id}/summarize withRawResponse().summarize(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ExperimentService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExperimentService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ExperimentCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ExperimentRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ExperimentUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ExperimentListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ExperimentListPage.of(ExperimentServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ExperimentListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ExperimentListPage.of(ExperimentServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ExperimentDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - feedbackHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: ExperimentFeedbackParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - fetchHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: ExperimentFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - fetchPostHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: ExperimentFetchPostParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - insertHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: ExperimentInsertParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val summarizeHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - summarizeHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val summarizeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun summarize( + params: ExperimentSummarizeParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { summarizeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 0a53085d..2002b104 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -20,45 +20,43 @@ import java.util.Optional interface FunctionService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new function. If there is an existing function in the project with the - * same slug as the one specified in the request, will return the existing function - * unmodified + * Create a new function. If there is an existing function in the project with the same slug as + * the one specified in the request, will return the existing function unmodified */ - fun create(params: FunctionCreateParams): Function = - create( - params, RequestOptions.none() - ) + fun create(params: FunctionCreateParams): Function = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Function /** Get a function object by its id */ - fun retrieve(params: FunctionRetrieveParams): Function = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: FunctionRetrieveParams): Function = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Function /** - * Partially update a function object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: FunctionUpdateParams): Function = - update( - params, RequestOptions.none() - ) + fun update(params: FunctionUpdateParams): Function = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Function /** * List out all functions. The functions are sorted by creation date, with the most @@ -67,95 +65,98 @@ interface FunctionService { fun list(): FunctionListPage = list(FunctionListParams.none()) /** @see [list] */ - fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): FunctionListPage + fun list( + params: FunctionListParams = FunctionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FunctionListPage /** @see [list] */ fun list(params: FunctionListParams = FunctionListParams.none()): FunctionListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): FunctionListPage = list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): FunctionListPage = + list(FunctionListParams.none(), requestOptions) /** Delete a function object by its id */ - fun delete(params: FunctionDeleteParams): Function = - delete( - params, RequestOptions.none() - ) + fun delete(params: FunctionDeleteParams): Function = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Function /** Invoke a function. */ fun invoke(params: FunctionInvokeParams): Optional = - invoke( - params, RequestOptions.none() - ) + invoke(params, RequestOptions.none()) /** @see [invoke] */ - fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): Optional + fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Optional /** - * Create or replace function. If there is an existing function in the project with - * the same slug as the one specified in the request, will replace the existing - * function with the provided fields + * Create or replace function. If there is an existing function in the project with the same + * slug as the one specified in the request, will replace the existing function with the + * provided fields */ - fun replace(params: FunctionReplaceParams): Function = - replace( - params, RequestOptions.none() - ) + fun replace(params: FunctionReplaceParams): Function = replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Function + fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Function - /** - * A view of [FunctionService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [FunctionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same - * as [FunctionService.create]. + * Returns a raw HTTP response for `post /v1/function`, but is otherwise the same as + * [FunctionService.create]. */ @MustBeClosed fun create(params: FunctionCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is - * otherwise the same as [FunctionService.retrieve]. + * Returns a raw HTTP response for `get /v1/function/{function_id}`, but is otherwise the + * same as [FunctionService.retrieve]. */ @MustBeClosed fun retrieve(params: FunctionRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is - * otherwise the same as [FunctionService.update]. + * Returns a raw HTTP response for `patch /v1/function/{function_id}`, but is otherwise the + * same as [FunctionService.update]. */ @MustBeClosed fun update(params: FunctionUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/function`, but is otherwise the same as @@ -166,46 +167,52 @@ interface FunctionService { /** @see [list] */ @MustBeClosed - fun list(params: FunctionListParams = FunctionListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: FunctionListParams = FunctionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: FunctionListParams = FunctionListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: FunctionListParams = FunctionListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(FunctionListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(FunctionListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is - * otherwise the same as [FunctionService.delete]. + * Returns a raw HTTP response for `delete /v1/function/{function_id}`, but is otherwise the + * same as [FunctionService.delete]. */ @MustBeClosed fun delete(params: FunctionDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `post /v1/function/{function_id}/invoke`, but is * otherwise the same as [FunctionService.invoke]. */ @MustBeClosed - fun invoke(params: FunctionInvokeParams): HttpResponseFor> = - invoke( - params, RequestOptions.none() - ) + fun invoke( + params: FunctionInvokeParams + ): HttpResponseFor> = invoke(params, RequestOptions.none()) /** @see [invoke] */ @MustBeClosed - fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor> + fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> /** * Returns a raw HTTP response for `put /v1/function`, but is otherwise the same as @@ -213,12 +220,13 @@ interface FunctionService { */ @MustBeClosed fun replace(params: FunctionReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 0e8d7fb5..cf7eb4ad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -27,12 +27,12 @@ import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams import java.util.Optional -class FunctionServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class FunctionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FunctionService { -) : FunctionService { - - private val withRawResponse: FunctionService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: FunctionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): FunctionService.WithRawResponse = withRawResponse @@ -40,7 +40,10 @@ class FunctionServiceImpl internal constructor( // post /v1/function withRawResponse().create(params, requestOptions).parse() - override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): Function = + override fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions, + ): Function = // get /v1/function/{function_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -48,7 +51,10 @@ class FunctionServiceImpl internal constructor( // patch /v1/function/{function_id} withRawResponse().update(params, requestOptions).parse() - override fun list(params: FunctionListParams, requestOptions: RequestOptions): FunctionListPage = + override fun list( + params: FunctionListParams, + requestOptions: RequestOptions, + ): FunctionListPage = // get /v1/function withRawResponse().list(params, requestOptions).parse() @@ -56,7 +62,10 @@ class FunctionServiceImpl internal constructor( // delete /v1/function/{function_id} withRawResponse().delete(params, requestOptions).parse() - override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): Optional = + override fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions, + ): Optional = // post /v1/function/{function_id}/invoke withRawResponse().invoke(params, requestOptions).parse() @@ -64,194 +73,199 @@ class FunctionServiceImpl internal constructor( // put /v1/function withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : FunctionService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FunctionService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun create( + params: FunctionCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun retrieve( + params: FunctionRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun update( + params: FunctionUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - override fun list(params: FunctionListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - FunctionListPage.of(FunctionServiceImpl(clientOptions), params, it) - } - } + override fun list( + params: FunctionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { FunctionListPage.of(FunctionServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun delete( + params: FunctionDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val invokeHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val invokeHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - override fun invoke(params: FunctionInvokeParams, requestOptions: RequestOptions): HttpResponseFor> { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function", params.getPathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - invokeHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.ifPresent { it.validate() } - } - } - } + override fun invoke( + params: FunctionInvokeParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function", params.getPathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { invokeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.ifPresent { it.validate() } + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun replace( + params: FunctionReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index b5e07be5..5249cbc6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -17,89 +17,86 @@ import com.google.errorprone.annotations.MustBeClosed interface GroupService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new group. If there is an existing group with the same name as the one - * specified in the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one specified in + * the request, will return the existing group unmodified */ - fun create(params: GroupCreateParams): Group = - create( - params, RequestOptions.none() - ) + fun create(params: GroupCreateParams): Group = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Group /** Get a group object by its id */ - fun retrieve(params: GroupRetrieveParams): Group = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: GroupRetrieveParams): Group = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Group /** - * Partially update a group object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ - fun update(params: GroupUpdateParams): Group = - update( - params, RequestOptions.none() - ) + fun update(params: GroupUpdateParams): Group = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Group /** - * List out all groups. The groups are sorted by creation date, with the most - * recently-created groups coming first + * List out all groups. The groups are sorted by creation date, with the most recently-created + * groups coming first */ fun list(): GroupListPage = list(GroupListParams.none()) /** @see [list] */ - fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): GroupListPage + fun list( + params: GroupListParams = GroupListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): GroupListPage /** @see [list] */ fun list(params: GroupListParams = GroupListParams.none()): GroupListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): GroupListPage = list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): GroupListPage = + list(GroupListParams.none(), requestOptions) /** Delete a group object by its id */ - fun delete(params: GroupDeleteParams): Group = - delete( - params, RequestOptions.none() - ) + fun delete(params: GroupDeleteParams): Group = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Group /** - * Create or replace group. If there is an existing group with the same name as the - * one specified in the request, will replace the existing group with the provided - * fields + * Create or replace group. If there is an existing group with the same name as the one + * specified in the request, will replace the existing group with the provided fields */ - fun replace(params: GroupReplaceParams): Group = - replace( - params, RequestOptions.none() - ) + fun replace(params: GroupReplaceParams): Group = replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Group + fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Group - /** - * A view of [GroupService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [GroupService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -108,77 +105,82 @@ interface GroupService { */ @MustBeClosed fun create(params: GroupCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: GroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the - * same as [GroupService.retrieve]. + * Returns a raw HTTP response for `get /v1/group/{group_id}`, but is otherwise the same as + * [GroupService.retrieve]. */ @MustBeClosed fun retrieve(params: GroupRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise - * the same as [GroupService.update]. + * Returns a raw HTTP response for `patch /v1/group/{group_id}`, but is otherwise the same + * as [GroupService.update]. */ @MustBeClosed fun update(params: GroupUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: GroupUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/group`, but is otherwise the same as * [GroupService.list]. */ - @MustBeClosed - fun list(): HttpResponseFor = list(GroupListParams.none()) + @MustBeClosed fun list(): HttpResponseFor = list(GroupListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: GroupListParams = GroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: GroupListParams = GroupListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: GroupListParams = GroupListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(GroupListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(GroupListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise - * the same as [GroupService.delete]. + * Returns a raw HTTP response for `delete /v1/group/{group_id}`, but is otherwise the same + * as [GroupService.delete]. */ @MustBeClosed fun delete(params: GroupDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: GroupDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/group`, but is otherwise the same as @@ -186,12 +188,13 @@ interface GroupService { */ @MustBeClosed fun replace(params: GroupReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 85b6d8c5..84a146af 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams -class GroupServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class GroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : + GroupService { -) : GroupService { - - private val withRawResponse: GroupService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: GroupService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): GroupService.WithRawResponse = withRawResponse @@ -57,168 +57,171 @@ class GroupServiceImpl internal constructor( // put /v1/group withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : GroupService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + GroupService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: GroupCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: GroupCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: GroupRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: GroupUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: GroupListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - GroupListPage.of(GroupServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: GroupListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { GroupListPage.of(GroupServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: GroupDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: GroupReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index 969b1911..b2ddae2c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -16,8 +16,7 @@ import com.google.errorprone.annotations.MustBeClosed interface OrganizationService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse @@ -25,56 +24,60 @@ interface OrganizationService { /** Get an organization object by its id */ fun retrieve(params: OrganizationRetrieveParams): Organization = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Organization + fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Organization /** - * Partially update an organization object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update an organization object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: OrganizationUpdateParams): Organization = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Organization + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Organization /** - * List out all organizations. The organizations are sorted by creation date, with - * the most recently-created organizations coming first + * List out all organizations. The organizations are sorted by creation date, with the most + * recently-created organizations coming first */ fun list(): OrganizationListPage = list(OrganizationListParams.none()) /** @see [list] */ - fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): OrganizationListPage + fun list( + params: OrganizationListParams = OrganizationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationListPage /** @see [list] */ fun list(params: OrganizationListParams = OrganizationListParams.none()): OrganizationListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): OrganizationListPage = list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): OrganizationListPage = + list(OrganizationListParams.none(), requestOptions) /** Delete an organization object by its id */ fun delete(params: OrganizationDeleteParams): Organization = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Organization + fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Organization /** - * A view of [OrganizationService] that provides access to raw HTTP responses for - * each method. + * A view of [OrganizationService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -86,62 +89,68 @@ interface OrganizationService { */ @MustBeClosed fun retrieve(params: OrganizationRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but - * is otherwise the same as [OrganizationService.update]. + * Returns a raw HTTP response for `patch /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationService.update]. */ @MustBeClosed fun update(params: OrganizationUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the - * same as [OrganizationService.list]. + * Returns a raw HTTP response for `get /v1/organization`, but is otherwise the same as + * [OrganizationService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(OrganizationListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: OrganizationListParams = OrganizationListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: OrganizationListParams = OrganizationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: OrganizationListParams = OrganizationListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: OrganizationListParams = OrganizationListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(OrganizationListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(OrganizationListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but - * is otherwise the same as [OrganizationService.delete]. + * Returns a raw HTTP response for `delete /v1/organization/{organization_id}`, but is + * otherwise the same as [OrganizationService.delete]. */ @MustBeClosed fun delete(params: OrganizationDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index e3af7e0b..b6af330b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.OrganizationUpdateParams import com.braintrustdata.api.services.blocking.organizations.MemberService import com.braintrustdata.api.services.blocking.organizations.MemberServiceImpl -class OrganizationServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class OrganizationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + OrganizationService { -) : OrganizationService { - - private val withRawResponse: OrganizationService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: OrganizationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val members: MemberService by lazy { MemberServiceImpl(clientOptions) } @@ -37,136 +37,153 @@ class OrganizationServiceImpl internal constructor( override fun members(): MemberService = members - override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): Organization = + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): Organization = // get /v1/organization/{organization_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): Organization = + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): Organization = // patch /v1/organization/{organization_id} withRawResponse().update(params, requestOptions).parse() - override fun list(params: OrganizationListParams, requestOptions: RequestOptions): OrganizationListPage = + override fun list( + params: OrganizationListParams, + requestOptions: RequestOptions, + ): OrganizationListPage = // get /v1/organization withRawResponse().list(params, requestOptions).parse() - override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): Organization = + override fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions, + ): Organization = // delete /v1/organization/{organization_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : OrganizationService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrganizationService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val members: MemberService.WithRawResponse by lazy { MemberServiceImpl.WithRawResponseImpl(clientOptions) } + private val members: MemberService.WithRawResponse by lazy { + MemberServiceImpl.WithRawResponseImpl(clientOptions) + } override fun members(): MemberService.WithRawResponse = members - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: OrganizationRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: OrganizationUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: OrganizationListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - OrganizationListPage.of(OrganizationServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: OrganizationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + OrganizationListPage.of(OrganizationServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: OrganizationDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index 338717ee..5f9df9bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -17,182 +17,195 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectScoreService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_score. If there is an existing project_score in the project - * with the same name as the one specified in the request, will return the existing - * project_score unmodified + * Create a new project_score. If there is an existing project_score in the project with the + * same name as the one specified in the request, will return the existing project_score + * unmodified */ fun create(params: ProjectScoreCreateParams): ProjectScore = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectScore /** Get a project_score object by its id */ fun retrieve(params: ProjectScoreRetrieveParams): ProjectScore = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectScore /** - * Partially update a project_score object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ fun update(params: ProjectScoreUpdateParams): ProjectScore = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectScore /** - * List out all project_scores. The project_scores are sorted by creation date, - * with the most recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, with the most + * recently-created project_scores coming first */ fun list(): ProjectScoreListPage = list(ProjectScoreListParams.none()) /** @see [list] */ - fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectScoreListPage + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectScoreListPage /** @see [list] */ fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): ProjectScoreListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectScoreListPage = list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectScoreListPage = + list(ProjectScoreListParams.none(), requestOptions) /** Delete a project_score object by its id */ fun delete(params: ProjectScoreDeleteParams): ProjectScore = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectScore /** - * Create or replace project_score. If there is an existing project_score in the - * project with the same name as the one specified in the request, will replace the - * existing project_score with the provided fields + * Create or replace project_score. If there is an existing project_score in the project with + * the same name as the one specified in the request, will replace the existing project_score + * with the provided fields */ fun replace(params: ProjectScoreReplaceParams): ProjectScore = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore + fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectScore /** - * A view of [ProjectScoreService] that provides access to raw HTTP responses for - * each method. + * A view of [ProjectScoreService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the - * same as [ProjectScoreService.create]. + * Returns a raw HTTP response for `post /v1/project_score`, but is otherwise the same as + * [ProjectScoreService.create]. */ @MustBeClosed fun create(params: ProjectScoreCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but - * is otherwise the same as [ProjectScoreService.retrieve]. + * Returns a raw HTTP response for `get /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectScoreRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, - * but is otherwise the same as [ProjectScoreService.update]. + * Returns a raw HTTP response for `patch /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreService.update]. */ @MustBeClosed fun update(params: ProjectScoreUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the - * same as [ProjectScoreService.list]. + * Returns a raw HTTP response for `get /v1/project_score`, but is otherwise the same as + * [ProjectScoreService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ProjectScoreListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ProjectScoreListParams = ProjectScoreListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: ProjectScoreListParams = ProjectScoreListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectScoreListParams = ProjectScoreListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectScoreListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ProjectScoreListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, - * but is otherwise the same as [ProjectScoreService.delete]. + * Returns a raw HTTP response for `delete /v1/project_score/{project_score_id}`, but is + * otherwise the same as [ProjectScoreService.delete]. */ @MustBeClosed fun delete(params: ProjectScoreDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the - * same as [ProjectScoreService.replace]. + * Returns a raw HTTP response for `put /v1/project_score`, but is otherwise the same as + * [ProjectScoreService.replace]. */ @MustBeClosed fun replace(params: ProjectScoreReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index f6dad76f..ec7b0393 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -24,201 +24,224 @@ import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams -class ProjectScoreServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class ProjectScoreServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectScoreService { -) : ProjectScoreService { - - private val withRawResponse: ProjectScoreService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ProjectScoreService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ProjectScoreService.WithRawResponse = withRawResponse - override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): ProjectScore = + override fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions, + ): ProjectScore = // post /v1/project_score withRawResponse().create(params, requestOptions).parse() - override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): ProjectScore = + override fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions, + ): ProjectScore = // get /v1/project_score/{project_score_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): ProjectScore = + override fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions, + ): ProjectScore = // patch /v1/project_score/{project_score_id} withRawResponse().update(params, requestOptions).parse() - override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): ProjectScoreListPage = + override fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions, + ): ProjectScoreListPage = // get /v1/project_score withRawResponse().list(params, requestOptions).parse() - override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): ProjectScore = + override fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions, + ): ProjectScore = // delete /v1/project_score/{project_score_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): ProjectScore = + override fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions, + ): ProjectScore = // put /v1/project_score withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ProjectScoreService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectScoreService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectScoreCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectScoreRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectScoreUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectScoreListPage.of(ProjectScoreServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectScoreListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ProjectScoreListPage.of(ProjectScoreServiceImpl(clientOptions), params, it) + } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectScoreDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ProjectScoreReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index c48696e5..197931d5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -17,46 +17,45 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse fun logs(): LogService /** - * Create a new project. If there is an existing project with the same name as the - * one specified in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the one specified + * in the request, will return the existing project unmodified */ - fun create(params: ProjectCreateParams): Project = - create( - params, RequestOptions.none() - ) + fun create(params: ProjectCreateParams): Project = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Project + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Project /** Get a project object by its id */ - fun retrieve(params: ProjectRetrieveParams): Project = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: ProjectRetrieveParams): Project = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Project + fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Project /** - * Partially update a project object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: ProjectUpdateParams): Project = - update( - params, RequestOptions.none() - ) + fun update(params: ProjectUpdateParams): Project = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Project + fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Project /** * List out all projects. The projects are sorted by creation date, with the most @@ -65,30 +64,29 @@ interface ProjectService { fun list(): ProjectListPage = list(ProjectListParams.none()) /** @see [list] */ - fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectListPage + fun list( + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectListPage /** @see [list] */ fun list(params: ProjectListParams = ProjectListParams.none()): ProjectListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectListPage = list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectListPage = + list(ProjectListParams.none(), requestOptions) /** Delete a project object by its id */ - fun delete(params: ProjectDeleteParams): Project = - delete( - params, RequestOptions.none() - ) + fun delete(params: ProjectDeleteParams): Project = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Project + fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Project - /** - * A view of [ProjectService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [ProjectService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { fun logs(): LogService.WithRawResponse @@ -99,76 +97,82 @@ interface ProjectService { */ @MustBeClosed fun create(params: ProjectCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise - * the same as [ProjectService.retrieve]. + * Returns a raw HTTP response for `get /v1/project/{project_id}`, but is otherwise the same + * as [ProjectService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is - * otherwise the same as [ProjectService.update]. + * Returns a raw HTTP response for `patch /v1/project/{project_id}`, but is otherwise the + * same as [ProjectService.update]. */ @MustBeClosed fun update(params: ProjectUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/project`, but is otherwise the same as * [ProjectService.list]. */ - @MustBeClosed - fun list(): HttpResponseFor = list(ProjectListParams.none()) + @MustBeClosed fun list(): HttpResponseFor = list(ProjectListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ProjectListParams = ProjectListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: ProjectListParams = ProjectListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectListParams = ProjectListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ProjectListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is - * otherwise the same as [ProjectService.delete]. + * Returns a raw HTTP response for `delete /v1/project/{project_id}`, but is otherwise the + * same as [ProjectService.delete]. */ @MustBeClosed fun delete(params: ProjectDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 5f78530d..502035c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -25,12 +25,12 @@ import com.braintrustdata.api.models.ProjectUpdateParams import com.braintrustdata.api.services.blocking.projects.LogService import com.braintrustdata.api.services.blocking.projects.LogServiceImpl -class ProjectServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class ProjectServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectService { -) : ProjectService { - - private val withRawResponse: ProjectService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ProjectService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val logs: LogService by lazy { LogServiceImpl(clientOptions) } @@ -58,146 +58,150 @@ class ProjectServiceImpl internal constructor( // delete /v1/project/{project_id} withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ProjectService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val logs: LogService.WithRawResponse by lazy { LogServiceImpl.WithRawResponseImpl(clientOptions) } + private val logs: LogService.WithRawResponse by lazy { + LogServiceImpl.WithRawResponseImpl(clientOptions) + } override fun logs(): LogService.WithRawResponse = logs - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ProjectListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectListPage.of(ProjectServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ProjectListPage.of(ProjectServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index 8c267908..d06930e4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -17,119 +17,120 @@ import com.google.errorprone.annotations.MustBeClosed interface ProjectTagService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new project_tag. If there is an existing project_tag in the project - * with the same name as the one specified in the request, will return the existing - * project_tag unmodified + * Create a new project_tag. If there is an existing project_tag in the project with the same + * name as the one specified in the request, will return the existing project_tag unmodified */ - fun create(params: ProjectTagCreateParams): ProjectTag = - create( - params, RequestOptions.none() - ) + fun create(params: ProjectTagCreateParams): ProjectTag = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectTag /** Get a project_tag object by its id */ fun retrieve(params: ProjectTagRetrieveParams): ProjectTag = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectTag /** - * Partially update a project_tag object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: ProjectTagUpdateParams): ProjectTag = - update( - params, RequestOptions.none() - ) + fun update(params: ProjectTagUpdateParams): ProjectTag = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectTag /** - * List out all project_tags. The project_tags are sorted by creation date, with - * the most recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with the most + * recently-created project_tags coming first */ fun list(): ProjectTagListPage = list(ProjectTagListParams.none()) /** @see [list] */ - fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): ProjectTagListPage + fun list( + params: ProjectTagListParams = ProjectTagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectTagListPage /** @see [list] */ fun list(params: ProjectTagListParams = ProjectTagListParams.none()): ProjectTagListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): ProjectTagListPage = list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): ProjectTagListPage = + list(ProjectTagListParams.none(), requestOptions) /** Delete a project_tag object by its id */ - fun delete(params: ProjectTagDeleteParams): ProjectTag = - delete( - params, RequestOptions.none() - ) + fun delete(params: ProjectTagDeleteParams): ProjectTag = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectTag /** - * Create or replace project_tag. If there is an existing project_tag in the - * project with the same name as the one specified in the request, will replace the - * existing project_tag with the provided fields + * Create or replace project_tag. If there is an existing project_tag in the project with the + * same name as the one specified in the request, will replace the existing project_tag with the + * provided fields */ fun replace(params: ProjectTagReplaceParams): ProjectTag = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag + fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectTag - /** - * A view of [ProjectTagService] that provides access to raw HTTP responses for - * each method. - */ + /** A view of [ProjectTagService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the - * same as [ProjectTagService.create]. + * Returns a raw HTTP response for `post /v1/project_tag`, but is otherwise the same as + * [ProjectTagService.create]. */ @MustBeClosed fun create(params: ProjectTagCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is - * otherwise the same as [ProjectTagService.retrieve]. + * Returns a raw HTTP response for `get /v1/project_tag/{project_tag_id}`, but is otherwise + * the same as [ProjectTagService.retrieve]. */ @MustBeClosed fun retrieve(params: ProjectTagRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `patch /v1/project_tag/{project_tag_id}`, but is @@ -137,62 +138,68 @@ interface ProjectTagService { */ @MustBeClosed fun update(params: ProjectTagUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same - * as [ProjectTagService.list]. + * Returns a raw HTTP response for `get /v1/project_tag`, but is otherwise the same as + * [ProjectTagService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(ProjectTagListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: ProjectTagListParams = ProjectTagListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: ProjectTagListParams = ProjectTagListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: ProjectTagListParams = ProjectTagListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: ProjectTagListParams = ProjectTagListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(ProjectTagListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ProjectTagListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but - * is otherwise the same as [ProjectTagService.delete]. + * Returns a raw HTTP response for `delete /v1/project_tag/{project_tag_id}`, but is + * otherwise the same as [ProjectTagService.delete]. */ @MustBeClosed fun delete(params: ProjectTagDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same - * as [ProjectTagService.replace]. + * Returns a raw HTTP response for `put /v1/project_tag`, but is otherwise the same as + * [ProjectTagService.replace]. */ @MustBeClosed fun replace(params: ProjectTagReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 94aaba01..79f8d590 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -24,201 +24,222 @@ import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams -class ProjectTagServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class ProjectTagServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectTagService { -) : ProjectTagService { - - private val withRawResponse: ProjectTagService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ProjectTagService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ProjectTagService.WithRawResponse = withRawResponse - override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): ProjectTag = + override fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions, + ): ProjectTag = // post /v1/project_tag withRawResponse().create(params, requestOptions).parse() - override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): ProjectTag = + override fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions, + ): ProjectTag = // get /v1/project_tag/{project_tag_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): ProjectTag = + override fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions, + ): ProjectTag = // patch /v1/project_tag/{project_tag_id} withRawResponse().update(params, requestOptions).parse() - override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): ProjectTagListPage = + override fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions, + ): ProjectTagListPage = // get /v1/project_tag withRawResponse().list(params, requestOptions).parse() - override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): ProjectTag = + override fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions, + ): ProjectTag = // delete /v1/project_tag/{project_tag_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): ProjectTag = + override fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions, + ): ProjectTag = // put /v1/project_tag withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ProjectTagService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectTagService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ProjectTagCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ProjectTagRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ProjectTagUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ProjectTagListPage.of(ProjectTagServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ProjectTagListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ProjectTagListPage.of(ProjectTagServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ProjectTagDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ProjectTagReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index c235c86f..e3d04a03 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -17,90 +17,86 @@ import com.google.errorprone.annotations.MustBeClosed interface PromptService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new prompt. If there is an existing prompt in the project with the same - * slug as the one specified in the request, will return the existing prompt - * unmodified + * Create a new prompt. If there is an existing prompt in the project with the same slug as the + * one specified in the request, will return the existing prompt unmodified */ - fun create(params: PromptCreateParams): Prompt = - create( - params, RequestOptions.none() - ) + fun create(params: PromptCreateParams): Prompt = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun create( + params: PromptCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Prompt /** Get a prompt object by its id */ - fun retrieve(params: PromptRetrieveParams): Prompt = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: PromptRetrieveParams): Prompt = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Prompt /** - * Partially update a prompt object. Specify the fields to update in the payload. - * Any object-type fields will be deep-merged with existing content. Currently we - * do not support removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: PromptUpdateParams): Prompt = - update( - params, RequestOptions.none() - ) + fun update(params: PromptUpdateParams): Prompt = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Prompt /** - * List out all prompts. The prompts are sorted by creation date, with the most - * recently-created prompts coming first + * List out all prompts. The prompts are sorted by creation date, with the most recently-created + * prompts coming first */ fun list(): PromptListPage = list(PromptListParams.none()) /** @see [list] */ - fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): PromptListPage + fun list( + params: PromptListParams = PromptListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PromptListPage /** @see [list] */ fun list(params: PromptListParams = PromptListParams.none()): PromptListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): PromptListPage = list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): PromptListPage = + list(PromptListParams.none(), requestOptions) /** Delete a prompt object by its id */ - fun delete(params: PromptDeleteParams): Prompt = - delete( - params, RequestOptions.none() - ) + fun delete(params: PromptDeleteParams): Prompt = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Prompt /** - * Create or replace prompt. If there is an existing prompt in the project with the - * same slug as the one specified in the request, will replace the existing prompt - * with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the same slug as + * the one specified in the request, will replace the existing prompt with the provided fields */ - fun replace(params: PromptReplaceParams): Prompt = - replace( - params, RequestOptions.none() - ) + fun replace(params: PromptReplaceParams): Prompt = replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt + fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Prompt - /** - * A view of [PromptService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [PromptService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -109,77 +105,83 @@ interface PromptService { */ @MustBeClosed fun create(params: PromptCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: PromptCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise - * the same as [PromptService.retrieve]. + * Returns a raw HTTP response for `get /v1/prompt/{prompt_id}`, but is otherwise the same + * as [PromptService.retrieve]. */ @MustBeClosed fun retrieve(params: PromptRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise - * the same as [PromptService.update]. + * Returns a raw HTTP response for `patch /v1/prompt/{prompt_id}`, but is otherwise the same + * as [PromptService.update]. */ @MustBeClosed fun update(params: PromptUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: PromptUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/prompt`, but is otherwise the same as * [PromptService.list]. */ - @MustBeClosed - fun list(): HttpResponseFor = list(PromptListParams.none()) + @MustBeClosed fun list(): HttpResponseFor = list(PromptListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: PromptListParams = PromptListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: PromptListParams = PromptListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: PromptListParams = PromptListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: PromptListParams = PromptListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(PromptListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(PromptListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is - * otherwise the same as [PromptService.delete]. + * Returns a raw HTTP response for `delete /v1/prompt/{prompt_id}`, but is otherwise the + * same as [PromptService.delete]. */ @MustBeClosed fun delete(params: PromptDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: PromptDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/prompt`, but is otherwise the same as @@ -187,12 +189,13 @@ interface PromptService { */ @MustBeClosed fun replace(params: PromptReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index b8603315..7736249d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -24,12 +24,12 @@ import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams -class PromptServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class PromptServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PromptService { -) : PromptService { - - private val withRawResponse: PromptService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: PromptService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): PromptService.WithRawResponse = withRawResponse @@ -57,168 +57,171 @@ class PromptServiceImpl internal constructor( // put /v1/prompt withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : PromptService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PromptService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: PromptCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: PromptCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: PromptRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PromptUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: PromptListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - PromptListPage.of(PromptServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: PromptListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { PromptListPage.of(PromptServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: PromptDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: PromptReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index b1095a40..a913ecca 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -17,89 +17,86 @@ import com.google.errorprone.annotations.MustBeClosed interface RoleService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new role. If there is an existing role with the same name as the one - * specified in the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one specified in + * the request, will return the existing role unmodified */ - fun create(params: RoleCreateParams): Role = - create( - params, RequestOptions.none() - ) + fun create(params: RoleCreateParams): Role = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role /** Get a role object by its id */ - fun retrieve(params: RoleRetrieveParams): Role = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: RoleRetrieveParams): Role = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role /** - * Partially update a role object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ - fun update(params: RoleUpdateParams): Role = - update( - params, RequestOptions.none() - ) + fun update(params: RoleUpdateParams): Role = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role /** - * List out all roles. The roles are sorted by creation date, with the most - * recently-created roles coming first + * List out all roles. The roles are sorted by creation date, with the most recently-created + * roles coming first */ fun list(): RoleListPage = list(RoleListParams.none()) /** @see [list] */ - fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): RoleListPage + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RoleListPage /** @see [list] */ fun list(params: RoleListParams = RoleListParams.none()): RoleListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): RoleListPage = list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): RoleListPage = + list(RoleListParams.none(), requestOptions) /** Delete a role object by its id */ - fun delete(params: RoleDeleteParams): Role = - delete( - params, RequestOptions.none() - ) + fun delete(params: RoleDeleteParams): Role = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role /** - * Create or replace role. If there is an existing role with the same name as the - * one specified in the request, will replace the existing role with the provided - * fields + * Create or replace role. If there is an existing role with the same name as the one specified + * in the request, will replace the existing role with the provided fields */ - fun replace(params: RoleReplaceParams): Role = - replace( - params, RequestOptions.none() - ) + fun replace(params: RoleReplaceParams): Role = replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Role + fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Role - /** - * A view of [RoleService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [RoleService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -108,77 +105,82 @@ interface RoleService { */ @MustBeClosed fun create(params: RoleCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: RoleCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the - * same as [RoleService.retrieve]. + * Returns a raw HTTP response for `get /v1/role/{role_id}`, but is otherwise the same as + * [RoleService.retrieve]. */ @MustBeClosed fun retrieve(params: RoleRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the - * same as [RoleService.update]. + * Returns a raw HTTP response for `patch /v1/role/{role_id}`, but is otherwise the same as + * [RoleService.update]. */ @MustBeClosed fun update(params: RoleUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: RoleUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/role`, but is otherwise the same as * [RoleService.list]. */ - @MustBeClosed - fun list(): HttpResponseFor = list(RoleListParams.none()) + @MustBeClosed fun list(): HttpResponseFor = list(RoleListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: RoleListParams = RoleListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: RoleListParams = RoleListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: RoleListParams = RoleListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(RoleListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(RoleListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise - * the same as [RoleService.delete]. + * Returns a raw HTTP response for `delete /v1/role/{role_id}`, but is otherwise the same as + * [RoleService.delete]. */ @MustBeClosed fun delete(params: RoleDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: RoleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/role`, but is otherwise the same as @@ -186,12 +188,13 @@ interface RoleService { */ @MustBeClosed fun replace(params: RoleReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 7add91aa..8c0a69cb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -24,12 +24,11 @@ import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams -class RoleServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class RoleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RoleService { -) : RoleService { - - private val withRawResponse: RoleService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: RoleService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): RoleService.WithRawResponse = withRawResponse @@ -57,168 +56,171 @@ class RoleServiceImpl internal constructor( // put /v1/role withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : RoleService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RoleService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: RoleCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: RoleCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: RoleRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: RoleUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: RoleListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - RoleListPage.of(RoleServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: RoleListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { RoleListPage.of(RoleServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: RoleDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: RoleReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt index cd1bc3c5..f8630cc6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeService.kt @@ -17,119 +17,119 @@ import com.google.errorprone.annotations.MustBeClosed interface SpanIframeService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new span_iframe. If there is an existing span_iframe with the same name - * as the one specified in the request, will return the existing span_iframe - * unmodified + * Create a new span_iframe. If there is an existing span_iframe with the same name as the one + * specified in the request, will return the existing span_iframe unmodified */ - fun create(params: SpanIframeCreateParams): SpanIFrame = - create( - params, RequestOptions.none() - ) + fun create(params: SpanIframeCreateParams): SpanIFrame = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame + fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SpanIFrame /** Get a span_iframe object by its id */ fun retrieve(params: SpanIframeRetrieveParams): SpanIFrame = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame + fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SpanIFrame /** - * Partially update a span_iframe object. Specify the fields to update in the - * payload. Any object-type fields will be deep-merged with existing content. - * Currently we do not support removing fields or setting them to null. + * Partially update a span_iframe object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do not support + * removing fields or setting them to null. */ - fun update(params: SpanIframeUpdateParams): SpanIFrame = - update( - params, RequestOptions.none() - ) + fun update(params: SpanIframeUpdateParams): SpanIFrame = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame + fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SpanIFrame /** - * List out all span_iframes. The span_iframes are sorted by creation date, with - * the most recently-created span_iframes coming first + * List out all span_iframes. The span_iframes are sorted by creation date, with the most + * recently-created span_iframes coming first */ fun list(): SpanIframeListPage = list(SpanIframeListParams.none()) /** @see [list] */ - fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): SpanIframeListPage + fun list( + params: SpanIframeListParams = SpanIframeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SpanIframeListPage /** @see [list] */ fun list(params: SpanIframeListParams = SpanIframeListParams.none()): SpanIframeListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): SpanIframeListPage = list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): SpanIframeListPage = + list(SpanIframeListParams.none(), requestOptions) /** Delete a span_iframe object by its id */ - fun delete(params: SpanIframeDeleteParams): SpanIFrame = - delete( - params, RequestOptions.none() - ) + fun delete(params: SpanIframeDeleteParams): SpanIFrame = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame + fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SpanIFrame /** - * Create or replace span_iframe. If there is an existing span_iframe with the same - * name as the one specified in the request, will replace the existing span_iframe - * with the provided fields + * Create or replace span_iframe. If there is an existing span_iframe with the same name as the + * one specified in the request, will replace the existing span_iframe with the provided fields */ fun replace(params: SpanIframeReplaceParams): SpanIFrame = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): SpanIFrame + fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SpanIFrame - /** - * A view of [SpanIframeService] that provides access to raw HTTP responses for - * each method. - */ + /** A view of [SpanIframeService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the - * same as [SpanIframeService.create]. + * Returns a raw HTTP response for `post /v1/span_iframe`, but is otherwise the same as + * [SpanIframeService.create]. */ @MustBeClosed fun create(params: SpanIframeCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is - * otherwise the same as [SpanIframeService.retrieve]. + * Returns a raw HTTP response for `get /v1/span_iframe/{span_iframe_id}`, but is otherwise + * the same as [SpanIframeService.retrieve]. */ @MustBeClosed fun retrieve(params: SpanIframeRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `patch /v1/span_iframe/{span_iframe_id}`, but is @@ -137,62 +137,68 @@ interface SpanIframeService { */ @MustBeClosed fun update(params: SpanIframeUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same - * as [SpanIframeService.list]. + * Returns a raw HTTP response for `get /v1/span_iframe`, but is otherwise the same as + * [SpanIframeService.list]. */ @MustBeClosed fun list(): HttpResponseFor = list(SpanIframeListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: SpanIframeListParams = SpanIframeListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: SpanIframeListParams = SpanIframeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed - fun list(params: SpanIframeListParams = SpanIframeListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + fun list( + params: SpanIframeListParams = SpanIframeListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(SpanIframeListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(SpanIframeListParams.none(), requestOptions) /** - * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but - * is otherwise the same as [SpanIframeService.delete]. + * Returns a raw HTTP response for `delete /v1/span_iframe/{span_iframe_id}`, but is + * otherwise the same as [SpanIframeService.delete]. */ @MustBeClosed fun delete(params: SpanIframeDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same - * as [SpanIframeService.replace]. + * Returns a raw HTTP response for `put /v1/span_iframe`, but is otherwise the same as + * [SpanIframeService.replace]. */ @MustBeClosed fun replace(params: SpanIframeReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt index 0e29471d..33029900 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceImpl.kt @@ -24,201 +24,222 @@ import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams -class SpanIframeServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class SpanIframeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SpanIframeService { -) : SpanIframeService { - - private val withRawResponse: SpanIframeService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: SpanIframeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): SpanIframeService.WithRawResponse = withRawResponse - override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): SpanIFrame = + override fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions, + ): SpanIFrame = // post /v1/span_iframe withRawResponse().create(params, requestOptions).parse() - override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): SpanIFrame = + override fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions, + ): SpanIFrame = // get /v1/span_iframe/{span_iframe_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): SpanIFrame = + override fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions, + ): SpanIFrame = // patch /v1/span_iframe/{span_iframe_id} withRawResponse().update(params, requestOptions).parse() - override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): SpanIframeListPage = + override fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions, + ): SpanIframeListPage = // get /v1/span_iframe withRawResponse().list(params, requestOptions).parse() - override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): SpanIFrame = + override fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions, + ): SpanIFrame = // delete /v1/span_iframe/{span_iframe_id} withRawResponse().delete(params, requestOptions).parse() - override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): SpanIFrame = + override fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions, + ): SpanIFrame = // put /v1/span_iframe withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : SpanIframeService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SpanIframeService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: SpanIframeCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: SpanIframeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: SpanIframeRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: SpanIframeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: SpanIframeUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: SpanIframeUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: SpanIframeListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "span_iframe") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - SpanIframeListPage.of(SpanIframeServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SpanIframeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "span_iframe") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { SpanIframeListPage.of(SpanIframeServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: SpanIframeDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "span_iframe", params.getPathParam(0)) - .apply { params._body().ifPresent{ body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: SpanIframeDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "span_iframe", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: SpanIframeReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "span_iframe") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: SpanIframeReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "span_iframe") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index 831f140a..f7d77d83 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -10,33 +10,28 @@ import com.google.errorprone.annotations.MustBeClosed interface TopLevelService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse - /** - * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not - * required - */ + /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ fun helloWorld(): String = helloWorld(TopLevelHelloWorldParams.none()) /** @see [helloWorld] */ - fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): String + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): String /** @see [helloWorld] */ fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): String = - helloWorld( - params, RequestOptions.none() - ) + helloWorld(params, RequestOptions.none()) /** @see [helloWorld] */ - fun helloWorld(requestOptions: RequestOptions): String = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): String = + helloWorld(TopLevelHelloWorldParams.none(), requestOptions) - /** - * A view of [TopLevelService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [TopLevelService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -48,17 +43,20 @@ interface TopLevelService { /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none()): HttpResponseFor = - helloWorld( - params, RequestOptions.none() - ) + fun helloWorld( + params: TopLevelHelloWorldParams = TopLevelHelloWorldParams.none() + ): HttpResponseFor = helloWorld(params, RequestOptions.none()) /** @see [helloWorld] */ @MustBeClosed - fun helloWorld(requestOptions: RequestOptions): HttpResponseFor = helloWorld(TopLevelHelloWorldParams.none(), requestOptions) + fun helloWorld(requestOptions: RequestOptions): HttpResponseFor = + helloWorld(TopLevelHelloWorldParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 0b9e70ab..2bee0c27 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -16,44 +16,43 @@ import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.TopLevelHelloWorldParams -class TopLevelServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class TopLevelServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelService { -) : TopLevelService { - - private val withRawResponse: TopLevelService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: TopLevelService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): TopLevelService.WithRawResponse = withRawResponse - override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): String = + override fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions, + ): String = // get /v1 withRawResponse().helloWorld(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : TopLevelService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) - - override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - helloWorldHandler.handle(it) - } - } + private val helloWorldHandler: Handler = + stringHandler().withErrorHandler(errorHandler) + + override fun helloWorld( + params: TopLevelHelloWorldParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { response.use { helloWorldHandler.handle(it) } } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index 63bda6ec..8a297070 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -13,78 +13,78 @@ import com.google.errorprone.annotations.MustBeClosed interface UserService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** Get a user object by its id */ - fun retrieve(params: UserRetrieveParams): User = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: UserRetrieveParams): User = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): User + fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): User /** - * List out all users. The users are sorted by creation date, with the most - * recently-created users coming first + * List out all users. The users are sorted by creation date, with the most recently-created + * users coming first */ fun list(): UserListPage = list(UserListParams.none()) /** @see [list] */ - fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): UserListPage + fun list( + params: UserListParams = UserListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UserListPage /** @see [list] */ fun list(params: UserListParams = UserListParams.none()): UserListPage = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ - fun list(requestOptions: RequestOptions): UserListPage = list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): UserListPage = + list(UserListParams.none(), requestOptions) - /** - * A view of [UserService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [UserService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the - * same as [UserService.retrieve]. + * Returns a raw HTTP response for `get /v1/user/{user_id}`, but is otherwise the same as + * [UserService.retrieve]. */ @MustBeClosed fun retrieve(params: UserRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/user`, but is otherwise the same as * [UserService.list]. */ - @MustBeClosed - fun list(): HttpResponseFor = list(UserListParams.none()) + @MustBeClosed fun list(): HttpResponseFor = list(UserListParams.none()) /** @see [list] */ @MustBeClosed - fun list(params: UserListParams = UserListParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: UserListParams = UserListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [list] */ @MustBeClosed fun list(params: UserListParams = UserListParams.none()): HttpResponseFor = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = list(UserListParams.none(), requestOptions) + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(UserListParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 06605588..08e5047d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -19,12 +19,11 @@ import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams -class UserServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { -) : UserService { - - private val withRawResponse: UserService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: UserService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): UserService.WithRawResponse = withRawResponse @@ -36,64 +35,63 @@ class UserServiceImpl internal constructor( // get /v1/user withRawResponse().list(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : UserService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UserService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun retrieve( + params: UserRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - override fun list(params: UserListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - UserListPage.of(UserServiceImpl(clientOptions), params, it) - } - } + override fun list( + params: UserListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { UserListPage.of(UserServiceImpl(clientOptions), params, it) } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index 100b76c5..f997b1b2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -17,83 +17,78 @@ import com.google.errorprone.annotations.MustBeClosed interface ViewService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** - * Create a new view. If there is an existing view with the same name as the one - * specified in the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one specified in + * the request, will return the existing view unmodified */ - fun create(params: ViewCreateParams): View = - create( - params, RequestOptions.none() - ) + fun create(params: ViewCreateParams): View = create(params, RequestOptions.none()) /** @see [create] */ - fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): View /** Get a view object by its id */ - fun retrieve(params: ViewRetrieveParams): View = - retrieve( - params, RequestOptions.none() - ) + fun retrieve(params: ViewRetrieveParams): View = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): View /** - * Partially update a view object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do - * not support removing fields or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any object-type + * fields will be deep-merged with existing content. Currently we do not support removing fields + * or setting them to null. */ - fun update(params: ViewUpdateParams): View = - update( - params, RequestOptions.none() - ) + fun update(params: ViewUpdateParams): View = update(params, RequestOptions.none()) /** @see [update] */ - fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): View /** - * List out all views. The views are sorted by creation date, with the most - * recently-created views coming first + * List out all views. The views are sorted by creation date, with the most recently-created + * views coming first */ - fun list(params: ViewListParams): ViewListPage = - list( - params, RequestOptions.none() - ) + fun list(params: ViewListParams): ViewListPage = list(params, RequestOptions.none()) /** @see [list] */ - fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): ViewListPage + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ViewListPage /** Delete a view object by its id */ - fun delete(params: ViewDeleteParams): View = - delete( - params, RequestOptions.none() - ) + fun delete(params: ViewDeleteParams): View = delete(params, RequestOptions.none()) /** @see [delete] */ - fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): View /** - * Create or replace view. If there is an existing view with the same name as the - * one specified in the request, will replace the existing view with the provided - * fields + * Create or replace view. If there is an existing view with the same name as the one specified + * in the request, will replace the existing view with the provided fields */ - fun replace(params: ViewReplaceParams): View = - replace( - params, RequestOptions.none() - ) + fun replace(params: ViewReplaceParams): View = replace(params, RequestOptions.none()) /** @see [replace] */ - fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): View + fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): View - /** - * A view of [ViewService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [ViewService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** @@ -102,41 +97,44 @@ interface ViewService { */ @MustBeClosed fun create(params: ViewCreateParams): HttpResponseFor = - create( - params, RequestOptions.none() - ) + create(params, RequestOptions.none()) /** @see [create] */ @MustBeClosed - fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun create( + params: ViewCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the - * same as [ViewService.retrieve]. + * Returns a raw HTTP response for `get /v1/view/{view_id}`, but is otherwise the same as + * [ViewService.retrieve]. */ @MustBeClosed fun retrieve(params: ViewRetrieveParams): HttpResponseFor = - retrieve( - params, RequestOptions.none() - ) + retrieve(params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed - fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the - * same as [ViewService.update]. + * Returns a raw HTTP response for `patch /v1/view/{view_id}`, but is otherwise the same as + * [ViewService.update]. */ @MustBeClosed fun update(params: ViewUpdateParams): HttpResponseFor = - update( - params, RequestOptions.none() - ) + update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(params: ViewUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v1/view`, but is otherwise the same as @@ -144,27 +142,29 @@ interface ViewService { */ @MustBeClosed fun list(params: ViewListParams): HttpResponseFor = - list( - params, RequestOptions.none() - ) + list(params, RequestOptions.none()) /** @see [list] */ @MustBeClosed - fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun list( + params: ViewListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise - * the same as [ViewService.delete]. + * Returns a raw HTTP response for `delete /v1/view/{view_id}`, but is otherwise the same as + * [ViewService.delete]. */ @MustBeClosed fun delete(params: ViewDeleteParams): HttpResponseFor = - delete( - params, RequestOptions.none() - ) + delete(params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed - fun delete(params: ViewDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** * Returns a raw HTTP response for `put /v1/view`, but is otherwise the same as @@ -172,12 +172,13 @@ interface ViewService { */ @MustBeClosed fun replace(params: ViewReplaceParams): HttpResponseFor = - replace( - params, RequestOptions.none() - ) + replace(params, RequestOptions.none()) /** @see [replace] */ @MustBeClosed - fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index 1ae3e726..8c11e74f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -24,12 +24,11 @@ import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams -class ViewServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class ViewServiceImpl internal constructor(private val clientOptions: ClientOptions) : ViewService { -) : ViewService { - - private val withRawResponse: ViewService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: ViewService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): ViewService.WithRawResponse = withRawResponse @@ -57,168 +56,171 @@ class ViewServiceImpl internal constructor( // put /v1/view withRawResponse().replace(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : ViewService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ViewService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun create(params: ViewCreateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - createHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ViewCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - retrieveHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: ViewRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ViewUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun list(params: ViewListParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - listHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - ViewListPage.of(ViewServiceImpl(clientOptions), params, it) - } - } + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ViewListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ViewListPage.of(ViewServiceImpl(clientOptions), params, it) } + } } - private val deleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - deleteHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun delete( + params: ViewDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val replaceHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - replaceHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun replace( + params: ViewReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt index 1fc7b5c1..d6298636 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt @@ -11,8 +11,7 @@ import com.google.errorprone.annotations.MustBeClosed interface MemberService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse @@ -20,43 +19,49 @@ interface MemberService { fun update(): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none()) /** @see [update] */ - fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): PatchOrganizationMembersOutput + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PatchOrganizationMembersOutput /** @see [update] */ - fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): PatchOrganizationMembersOutput = - update( - params, RequestOptions.none() - ) + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() + ): PatchOrganizationMembersOutput = update(params, RequestOptions.none()) /** @see [update] */ - fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update(requestOptions: RequestOptions): PatchOrganizationMembersOutput = + update(OrganizationMemberUpdateParams.none(), requestOptions) - /** - * A view of [MemberService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [MemberService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `patch /v1/organization/members`, but is - * otherwise the same as [MemberService.update]. + * Returns a raw HTTP response for `patch /v1/organization/members`, but is otherwise the + * same as [MemberService.update]. */ @MustBeClosed - fun update(): HttpResponseFor = update(OrganizationMemberUpdateParams.none()) + fun update(): HttpResponseFor = + update(OrganizationMemberUpdateParams.none()) /** @see [update] */ @MustBeClosed - fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** @see [update] */ @MustBeClosed - fun update(params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none()): HttpResponseFor = - update( - params, RequestOptions.none() - ) + fun update( + params: OrganizationMemberUpdateParams = OrganizationMemberUpdateParams.none() + ): HttpResponseFor = update(params, RequestOptions.none()) /** @see [update] */ @MustBeClosed - fun update(requestOptions: RequestOptions): HttpResponseFor = update(OrganizationMemberUpdateParams.none(), requestOptions) + fun update( + requestOptions: RequestOptions + ): HttpResponseFor = + update(OrganizationMemberUpdateParams.none(), requestOptions) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt index c46ea290..ffd783ac 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt @@ -18,50 +18,53 @@ import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.PatchOrganizationMembersOutput -class MemberServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class MemberServiceImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService { -) : MemberService { - - private val withRawResponse: MemberService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: MemberService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): MemberService.WithRawResponse = withRawResponse - override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): PatchOrganizationMembersOutput = + override fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions, + ): PatchOrganizationMembersOutput = // patch /v1/organization/members withRawResponse().update(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : MemberService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MemberService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - updateHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + override fun update( + params: OrganizationMemberUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt index d5bd1944..3289dca2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt @@ -16,115 +16,121 @@ import com.google.errorprone.annotations.MustBeClosed interface LogService { /** - * Returns a view of this service that provides access to raw HTTP responses for - * each method. + * Returns a view of this service that provides access to raw HTTP responses for each method. */ fun withRawResponse(): WithRawResponse /** Log feedback for a set of project logs events */ fun feedback(params: ProjectLogFeedbackParams): FeedbackResponseSchema = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ - fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): FeedbackResponseSchema + fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FeedbackResponseSchema /** - * Fetch the events in a project logs. Equivalent to the POST form of the same - * path, but with the parameters in the URL query rather than in the request body. - * For more complex queries, use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with + * the parameters in the URL query rather than in the request body. For more complex queries, + * use the `POST /btql` endpoint. */ fun fetch(params: ProjectLogFetchParams): FetchProjectLogsEventsResponse = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ - fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): FetchProjectLogsEventsResponse + fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchProjectLogsEventsResponse /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, - * but with the parameters in the request body rather than in the URL query. For - * more complex queries, use the `POST /btql` endpoint. + * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the + * parameters in the request body rather than in the URL query. For more complex queries, use + * the `POST /btql` endpoint. */ fun fetchPost(params: ProjectLogFetchPostParams): FetchProjectLogsEventsResponse = - fetchPost( - params, RequestOptions.none() - ) + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ - fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchProjectLogsEventsResponse + fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchProjectLogsEventsResponse /** Insert a set of events into the project logs */ fun insert(params: ProjectLogInsertParams): InsertEventsResponse = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ - fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse + fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InsertEventsResponse - /** - * A view of [LogService] that provides access to raw HTTP responses for each - * method. - */ + /** A view of [LogService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, - * but is otherwise the same as [LogService.feedback]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/feedback`, but is + * otherwise the same as [LogService.feedback]. */ @MustBeClosed fun feedback(params: ProjectLogFeedbackParams): HttpResponseFor = - feedback( - params, RequestOptions.none() - ) + feedback(params, RequestOptions.none()) /** @see [feedback] */ @MustBeClosed - fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but - * is otherwise the same as [LogService.fetch]. + * Returns a raw HTTP response for `get /v1/project_logs/{project_id}/fetch`, but is + * otherwise the same as [LogService.fetch]. */ @MustBeClosed fun fetch(params: ProjectLogFetchParams): HttpResponseFor = - fetch( - params, RequestOptions.none() - ) + fetch(params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed - fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but - * is otherwise the same as [LogService.fetchPost]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/fetch`, but is + * otherwise the same as [LogService.fetchPost]. */ @MustBeClosed - fun fetchPost(params: ProjectLogFetchPostParams): HttpResponseFor = - fetchPost( - params, RequestOptions.none() - ) + fun fetchPost( + params: ProjectLogFetchPostParams + ): HttpResponseFor = + fetchPost(params, RequestOptions.none()) /** @see [fetchPost] */ @MustBeClosed - fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor /** - * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but - * is otherwise the same as [LogService.insert]. + * Returns a raw HTTP response for `post /v1/project_logs/{project_id}/insert`, but is + * otherwise the same as [LogService.insert]. */ @MustBeClosed fun insert(params: ProjectLogInsertParams): HttpResponseFor = - insert( - params, RequestOptions.none() - ) + insert(params, RequestOptions.none()) /** @see [insert] */ @MustBeClosed - fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): HttpResponseFor + fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt index 23884a8a..d060fec8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt @@ -23,139 +23,156 @@ import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams -class LogServiceImpl internal constructor( - private val clientOptions: ClientOptions, +class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { -) : LogService { - - private val withRawResponse: LogService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } + private val withRawResponse: LogService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } override fun withRawResponse(): LogService.WithRawResponse = withRawResponse - override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema = + override fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions, + ): FeedbackResponseSchema = // post /v1/project_logs/{project_id}/feedback withRawResponse().feedback(params, requestOptions).parse() - override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse = + override fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions, + ): FetchProjectLogsEventsResponse = // get /v1/project_logs/{project_id}/fetch withRawResponse().fetch(params, requestOptions).parse() - override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse = + override fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions, + ): FetchProjectLogsEventsResponse = // post /v1/project_logs/{project_id}/fetch withRawResponse().fetchPost(params, requestOptions).parse() - override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): InsertEventsResponse = + override fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions, + ): InsertEventsResponse = // post /v1/project_logs/{project_id}/insert withRawResponse().insert(params, requestOptions).parse() - class WithRawResponseImpl internal constructor( - private val clientOptions: ClientOptions, - - ) : LogService.WithRawResponse { + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LogService.WithRawResponse { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val feedbackHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - feedbackHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val feedbackHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun feedback( + params: ProjectLogFeedbackParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { feedbackHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - fetchHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: ProjectLogFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val fetchPostHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - fetchPostHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val fetchPostHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchPost( + params: ProjectLogFetchPostParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchPostHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } - private val insertHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): HttpResponseFor { - val request = HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions - .applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute( - request, requestOptions - ) - return response.parseable { - response.use { - insertHandler.handle(it) - } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } + private val insertHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun insert( + params: ProjectLogInsertParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { insertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } } } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt index bfb17770..1d2dd2d0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt @@ -36,16 +36,20 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { $ prism mock path/to/your.openapi.yml """ .trimIndent(), - e + e, ) } } override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { - ConditionEvaluationResult.disabled("Environment variable $SKIP_TESTS_ENV is set to true") + ConditionEvaluationResult.disabled( + "Environment variable $SKIP_TESTS_ENV is set to true" + ) } else { - ConditionEvaluationResult.enabled("Environment variable $SKIP_TESTS_ENV is not set to true") + ConditionEvaluationResult.enabled( + "Environment variable $SKIP_TESTS_ENV is not set to true" + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt index afe2bc55..a7a9b514 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/PhantomReachableTest.kt @@ -1,7 +1,7 @@ package com.braintrustdata.api.core -import org.junit.jupiter.api.Test import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test internal class PhantomReachableTest { @@ -11,8 +11,10 @@ internal class PhantomReachableTest { val closeable = AutoCloseable { closed = true } closeWhenPhantomReachable( - // Pass an inline object for the object to observe so that it becomes immediately unreachable. - Any(), closeable + // Pass an inline object for the object to observe so that it becomes immediately + // unreachable. + Any(), + closeable, ) assertThat(closed).isFalse() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt index 5fed9eeb..fcdb9f5c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/ValuesTest.kt @@ -27,55 +27,55 @@ internal class ValuesTest { KNOWN_BOOLEAN( KnownValue.of(true), expectedAsKnown = Optional.of(true), - expectedAsBoolean = Optional.of(true) + expectedAsBoolean = Optional.of(true), ), BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), KNOWN_NUMBER( KnownValue.of(42), expectedAsKnown = Optional.of(42), - expectedAsNumber = Optional.of(42) + expectedAsNumber = Optional.of(42), ), NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), KNOWN_STRING( KnownValue.of("hello"), expectedAsKnown = Optional.of("hello"), - expectedAsString = Optional.of("hello") + expectedAsString = Optional.of("hello"), ), STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), KNOWN_ARRAY_NOT_ALL_JSON( KnownValue.of(listOf("a", "b", NON_JSON)), - expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)) + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), ), KNOWN_ARRAY( KnownValue.of(listOf("a", "b", "c")), expectedAsKnown = Optional.of(listOf("a", "b", "c")), expectedAsArray = - Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))) + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), ), ARRAY( JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), expectedAsArray = - Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))) + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), ), KNOWN_OBJECT_NOT_ALL_STRING_KEYS( KnownValue.of(mapOf("a" to "b", 42 to "c")), - expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")) + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), ), KNOWN_OBJECT_NOT_ALL_JSON( KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), - expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)) + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), ), KNOWN_OBJECT( KnownValue.of(mapOf("a" to "b", "b" to "c")), expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), expectedAsObject = - Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))) + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), ), OBJECT( JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), expectedAsObject = - Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))) - ) + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt index f66d69ea..2a5ed57a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/HeadersTest.kt @@ -1,9 +1,8 @@ package com.braintrustdata.api.core.http -import org.junit.jupiter.api.Test import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat; +import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -12,28 +11,28 @@ internal class HeadersTest { enum class TestCase( val headers: Headers, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( Headers.builder().put("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( Headers.builder().put("name1", "value").put("name2", "value").build(), expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( Headers.builder().put("name", "value1").put("name", "value2").build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( Headers.builder() @@ -41,7 +40,7 @@ internal class HeadersTest { .put("name", listOf("value1", "value2")) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_CASE_INSENSITIVE( Headers.builder() @@ -50,25 +49,25 @@ internal class HeadersTest { .put("nAmE", "value3") .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), PUT_ALL_MAP( Headers.builder() .putAll( mapOf( "name1" to listOf("value1", "value2"), - "name2" to listOf("value1", "value2") + "name2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_ALL_CASE_INSENSITIVE( Headers.builder() @@ -76,32 +75,32 @@ internal class HeadersTest { mapOf( "name" to listOf("value1"), "NAME" to listOf("value2"), - "nAmE" to listOf("value3") + "nAmE" to listOf("value3"), ) ) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), REMOVE_ABSENT( Headers.builder().remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( Headers.builder().put("name", "value").remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_CASE_INSENSITIVE( Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( Headers.builder() @@ -110,7 +109,7 @@ internal class HeadersTest { .removeAll(setOf("name1", "name2", "name3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -119,22 +118,22 @@ internal class HeadersTest { .removeAll(setOf("NAME1", "nAmE3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( Headers.builder().put("name1", "value").put("name2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( Headers.builder().replace("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( Headers.builder().put("name", "value1").replace("name", "value2").build(), expectedMap = mapOf("name" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( Headers.builder() @@ -142,12 +141,12 @@ internal class HeadersTest { .replace("name", "value3") .build(), expectedMap = mapOf("name" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( Headers.builder().replace("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( Headers.builder() @@ -155,7 +154,7 @@ internal class HeadersTest { .replace("name", listOf("value2", "value3")) .build(), expectedMap = mapOf("name" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( Headers.builder() @@ -163,7 +162,7 @@ internal class HeadersTest { .replace("name", listOf("value3", "value4")) .build(), expectedMap = mapOf("name" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_CASE_INSENSITIVE( Headers.builder() @@ -171,7 +170,7 @@ internal class HeadersTest { .replace("NAME", listOf("value2", "value3")) .build(), expectedMap = mapOf("NAME" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( Headers.builder() @@ -184,9 +183,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( Headers.builder() @@ -199,9 +198,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -210,8 +209,8 @@ internal class HeadersTest { .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) .build(), expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), - expectedSize = 2 - ) + expectedSize = 2, + ), } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt index 7fe37959..08e55c66 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/QueryParamsTest.kt @@ -1,9 +1,8 @@ package com.braintrustdata.api.core.http -import org.junit.jupiter.api.Test import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat; +import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -12,28 +11,28 @@ internal class QueryParamsTest { enum class TestCase( val queryParams: QueryParams, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( QueryParams.builder().put("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( QueryParams.builder().put("key1", "value").put("key2", "value").build(), expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( QueryParams.builder().put("key", "value1").put("key", "value2").build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( QueryParams.builder() @@ -41,40 +40,40 @@ internal class QueryParamsTest { .put("key", listOf("value1", "value2")) .build(), expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_MAP( QueryParams.builder() .putAll( mapOf( "key1" to listOf("value1", "value2"), - "key2" to listOf("value1", "value2") + "key2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REMOVE_ABSENT( QueryParams.builder().remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( QueryParams.builder().put("key", "value").remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( QueryParams.builder() @@ -83,22 +82,22 @@ internal class QueryParamsTest { .removeAll(setOf("key1", "key2", "key3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( QueryParams.builder().replace("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( QueryParams.builder().put("key", "value1").replace("key", "value2").build(), expectedMap = mapOf("key" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( QueryParams.builder() @@ -106,12 +105,12 @@ internal class QueryParamsTest { .replace("key", "value3") .build(), expectedMap = mapOf("key" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( QueryParams.builder().replace("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( QueryParams.builder() @@ -119,7 +118,7 @@ internal class QueryParamsTest { .replace("key", listOf("value2", "value3")) .build(), expectedMap = mapOf("key" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( QueryParams.builder() @@ -127,7 +126,7 @@ internal class QueryParamsTest { .replace("key", listOf("value3", "value4")) .build(), expectedMap = mapOf("key" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( QueryParams.builder() @@ -140,9 +139,9 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( QueryParams.builder() @@ -157,10 +156,10 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 - ) + expectedSize = 3, + ), } @ParameterizedTest diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt index 9370b6d7..d538b9b3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt @@ -6,12 +6,12 @@ import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario +import java.io.InputStream +import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource -import java.io.InputStream -import java.util.concurrent.CompletableFuture @WireMockTest internal class RetryingHttpClientTest { @@ -26,12 +26,12 @@ internal class RetryingHttpClientTest { object : HttpClient { override fun execute( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture = okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } @@ -71,7 +71,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) @@ -97,7 +97,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) @@ -140,24 +140,24 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("0")) + .withHeader("x-stainless-retry-count", equalTo("0")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("1")) + .withHeader("x-stainless-retry-count", equalTo("1")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("2")) + .withHeader("x-stainless-retry-count", equalTo("2")), ) assertNoResponseLeaks() } @@ -191,14 +191,14 @@ internal class RetryingHttpClientTest { .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) verify( 2, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("42")) + .withHeader("x-stainless-retry-count", equalTo("42")), ) assertNoResponseLeaks() } @@ -226,7 +226,7 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), - async + async, ) assertThat(response.statusCode()).isEqualTo(200) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt index 3759f563..824c8711 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt @@ -1,13 +1,13 @@ package com.braintrustdata.api.core.http +import com.braintrustdata.api.core.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.braintrustdata.api.core.* +import java.util.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import java.util.* internal class SerializerTest { @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) @@ -23,9 +23,7 @@ internal class SerializerTest { fun isActive(): Boolean? = isActive.getNullable("is_active") - @JsonProperty("is_active") - @ExcludeMissing - fun _isActive() = isActive + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive @JsonAnyGetter @ExcludeMissing @@ -44,21 +42,19 @@ internal class SerializerTest { } return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties + isActive == other.isActive && + additionalProperties == other.additionalProperties } override fun hashCode(): Int { if (hashCode == 0) { - hashCode = Objects.hash( - isActive, - additionalProperties, - ) + hashCode = Objects.hash(isActive, additionalProperties) } return hashCode } - override fun toString() = "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" + override fun toString() = + "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" companion object { fun builder() = Builder() @@ -74,9 +70,7 @@ internal class SerializerTest { @JsonProperty("is_active") @ExcludeMissing - fun isActive(isActive: JsonField) = apply { - this.isActive = isActive - } + fun isActive(isActive: JsonField) = apply { this.isActive = isActive } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -92,14 +86,11 @@ internal class SerializerTest { this.additionalProperties.putAll(additionalProperties) } - fun build(): ClassWithBooleanFieldPrefixedWithIs = ClassWithBooleanFieldPrefixedWithIs( - isActive, - additionalProperties.toImmutable(), - ) + fun build(): ClassWithBooleanFieldPrefixedWithIs = + ClassWithBooleanFieldPrefixedWithIs(isActive, additionalProperties.toImmutable()) } } - @Test fun serializeBooleanPrefixedWithIs() { val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt index 5d5e9323..693b9866 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt @@ -11,26 +11,32 @@ class AISecretTest { @Test fun createAISecret() { - val aiSecret = AISecret.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .metadata(AISecret.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .previewSecret("preview_secret") - .type("type") - .build() - assertThat(aiSecret).isNotNull - assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(aiSecret.name()).isEqualTo("name") - assertThat(aiSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(aiSecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(aiSecret.metadata()).contains(AISecret.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(aiSecret.previewSecret()).contains("preview_secret") - assertThat(aiSecret.type()).contains("type") + val aiSecret = + AISecret.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .metadata( + AISecret.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .previewSecret("preview_secret") + .type("type") + .build() + assertThat(aiSecret).isNotNull + assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aiSecret.name()).isEqualTo("name") + assertThat(aiSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aiSecret.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(aiSecret.metadata()) + .contains( + AISecret.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(aiSecret.previewSecret()).contains("preview_secret") + assertThat(aiSecret.type()).contains("type") } } 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 942ae28c..ce3f43d3 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 @@ -10,80 +10,109 @@ class AclBatchUpdateParamsTest { @Test fun create() { - AclBatchUpdateParams.builder() - .addAddAcl(AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build() + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() } @Test fun body() { - val params = AclBatchUpdateParams.builder() - .addAddAcl(AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build() + val params = + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addAcls()).contains(listOf(AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build())) - assertThat(body.removeAcls()).contains(listOf(AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build())) + assertNotNull(body) + assertThat(body.addAcls()) + .contains( + listOf( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + assertThat(body.removeAcls()) + .contains( + listOf( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) } @Test fun bodyWithoutOptionalFields() { - val params = AclBatchUpdateParams.builder().build() + val params = AclBatchUpdateParams.builder().build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } } 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 b862daca..02a37951 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 @@ -10,56 +10,67 @@ class AclBatchUpdateResponseTest { @Test fun createAclBatchUpdateResponse() { - val aclBatchUpdateResponse = AclBatchUpdateResponse.builder() - .addAddedAcl(Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .addRemovedAcl(Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build() - assertThat(aclBatchUpdateResponse).isNotNull - assertThat(aclBatchUpdateResponse.addedAcls()).containsExactly(Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - assertThat(aclBatchUpdateResponse.removedAcls()).containsExactly(Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val aclBatchUpdateResponse = + AclBatchUpdateResponse.builder() + .addAddedAcl( + Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemovedAcl( + Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + assertThat(aclBatchUpdateResponse).isNotNull + assertThat(aclBatchUpdateResponse.addedAcls()) + .containsExactly( + Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(aclBatchUpdateResponse.removedAcls()) + .containsExactly( + Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.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 33bf5671..2f1cbe6c 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 @@ -10,52 +10,55 @@ class AclCreateParamsTest { @Test fun create() { - AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).contains(AclCreateParams.Permission.CREATE) - assertThat(body.restrictObjectType()).contains(AclCreateParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .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.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).contains(AclCreateParams.Permission.CREATE) + assertThat(body.restrictObjectType()) + .contains(AclCreateParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun bodyWithoutOptionalFields() { - val params = AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .build() + val params = + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt index cd7e95c7..51793459 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt @@ -9,20 +9,16 @@ class AclDeleteParamsTest { @Test fun create() { - AclDeleteParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = AclDeleteParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aclId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "aclId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 335f462e..8c64fe8b 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 @@ -10,52 +10,55 @@ class AclFindAndDeleteParamsTest { @Test fun create() { - AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).contains(AclFindAndDeleteParams.Permission.CREATE) - assertThat(body.restrictObjectType()).contains(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = + AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .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.groupId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).contains(AclFindAndDeleteParams.Permission.CREATE) + assertThat(body.restrictObjectType()) + .contains(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun bodyWithoutOptionalFields() { - val params = AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = + AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclFindAndDeleteParams.ObjectType.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 09d041f2..174747e9 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 @@ -10,45 +10,50 @@ class AclListParamsTest { @Test fun create() { - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", AclListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt index d3e50fea..fd23f612 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt @@ -9,20 +9,17 @@ class AclRetrieveParamsTest { @Test fun create() { - AclRetrieveParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = AclRetrieveParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aclId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "aclId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 2bd881dc..cedb7fe5 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 @@ -10,28 +10,29 @@ class AclTest { @Test fun createAcl() { - val acl = Acl.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Acl.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(Acl.Permission.CREATE) - .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(acl).isNotNull - 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.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.roleId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val acl = + Acl.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._objectOrgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Acl.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(Acl.Permission.CREATE) + .restrictObjectType(Acl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(acl).isNotNull + 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.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.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/AiSecretCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt index d00281be..213130fd 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt @@ -11,50 +11,56 @@ class AiSecretCreateParamsTest { @Test fun create() { - AiSecretCreateParams.builder() - .name("name") - .metadata(AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() + AiSecretCreateParams.builder() + .name("name") + .metadata( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = AiSecretCreateParams.builder() - .name("name") - .metadata(AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()).contains(AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(body.orgName()).contains("org_name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + val params = + AiSecretCreateParams.builder() + .name("name") + .metadata( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.metadata()) + .contains( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.orgName()).contains("org_name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretCreateParams.builder() - .name("name") - .build() + val params = AiSecretCreateParams.builder().name("name").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt index 98eaa5fd..a59725a1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt @@ -9,20 +9,19 @@ class AiSecretDeleteParamsTest { @Test fun create() { - AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AiSecretDeleteParams.builder().aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt index dd00f4fc..f46d2fb2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt @@ -10,35 +10,27 @@ class AiSecretFindAndDeleteParamsTest { @Test fun create() { - AiSecretFindAndDeleteParams.builder() - .name("name") - .orgName("org_name") - .build() + AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() } @Test fun body() { - val params = AiSecretFindAndDeleteParams.builder() - .name("name") - .orgName("org_name") - .build() + val params = AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretFindAndDeleteParams.builder() - .name("name") - .build() + val params = AiSecretFindAndDeleteParams.builder().name("name").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt index 9388f3ff..fff7ec47 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt @@ -10,43 +10,50 @@ class AiSecretListParamsTest { @Test fun create() { - AiSecretListParams.builder() - .aiSecretName("ai_secret_name") - .aiSecretType("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AiSecretListParams.builder() + .aiSecretName("ai_secret_name") + .aiSecretType("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = AiSecretListParams.builder() - .aiSecretName("ai_secret_name") - .aiSecretType("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ai_secret_name", "ai_secret_name") - expected.put("ai_secret_type", AiSecretListParams.AiSecretType.ofString("string").toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + AiSecretListParams.builder() + .aiSecretName("ai_secret_name") + .aiSecretType("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ai_secret_name", "ai_secret_name") + expected.put( + "ai_secret_type", + AiSecretListParams.AiSecretType.ofString("string").toString(), + ) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = AiSecretListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = AiSecretListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt index 96bc3a6a..b716129c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt @@ -11,50 +11,56 @@ class AiSecretReplaceParamsTest { @Test fun create() { - AiSecretReplaceParams.builder() - .name("name") - .metadata(AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() + AiSecretReplaceParams.builder() + .name("name") + .metadata( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = AiSecretReplaceParams.builder() - .name("name") - .metadata(AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()).contains(AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(body.orgName()).contains("org_name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + val params = + AiSecretReplaceParams.builder() + .name("name") + .metadata( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.metadata()) + .contains( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.orgName()).contains("org_name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretReplaceParams.builder() - .name("name") - .build() + val params = AiSecretReplaceParams.builder().name("name").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt index 0eddf89f..5c6d07cc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt @@ -9,20 +9,19 @@ class AiSecretRetrieveParamsTest { @Test fun create() { - AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + AiSecretRetrieveParams.builder().aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt index 17084aa8..b45e1c86 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt @@ -11,60 +11,70 @@ class AiSecretUpdateParamsTest { @Test fun create() { - AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .secret("secret") - .type("type") - .build() + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .secret("secret") + .type("type") + .build() } @Test fun body() { - val params = AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .secret("secret") - .type("type") - .build() + val params = + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .secret("secret") + .type("type") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.metadata()).contains(AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(body.name()).contains("name") - assertThat(body.secret()).contains("secret") - assertThat(body.type()).contains("type") + assertNotNull(body) + assertThat(body.metadata()) + .contains( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.name()).contains("name") + assertThat(body.secret()).contains("secret") + assertThat(body.type()).contains("type") } @Test fun bodyWithoutOptionalFields() { - val params = AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "aiSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "aiSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt index 683112d5..d450a958 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -10,35 +10,27 @@ class ApiKeyCreateParamsTest { @Test fun create() { - ApiKeyCreateParams.builder() - .name("name") - .orgName("org_name") - .build() + ApiKeyCreateParams.builder().name("name").orgName("org_name").build() } @Test fun body() { - val params = ApiKeyCreateParams.builder() - .name("name") - .orgName("org_name") - .build() + val params = ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = ApiKeyCreateParams.builder() - .name("name") - .build() + val params = ApiKeyCreateParams.builder().name("name").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt index 6de59487..0b7c5a7d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt @@ -9,20 +9,17 @@ class ApiKeyDeleteParamsTest { @Test fun create() { - ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "apiKeyId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ApiKeyDeleteParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "apiKeyId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index 9f6485af..41532fd3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -10,40 +10,44 @@ class ApiKeyListParamsTest { @Test fun create() { - ApiKeyListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ApiKeyListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = ApiKeyListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("api_key_name", "api_key_name") - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ApiKeyListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("api_key_name", "api_key_name") + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ApiKeyListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ApiKeyListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt index 29fe0c51..2170ff30 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt @@ -9,20 +9,17 @@ class ApiKeyRetrieveParamsTest { @Test fun create() { - ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "apiKeyId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ApiKeyRetrieveParams.builder().apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "apiKeyId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt index 4893810a..5d9ab3b9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt @@ -10,20 +10,21 @@ class ApiKeyTest { @Test fun createApiKey() { - val apiKey = ApiKey.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .previewName("preview_name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(apiKey).isNotNull - assertThat(apiKey.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKey.name()).isEqualTo("name") - assertThat(apiKey.previewName()).isEqualTo("preview_name") - assertThat(apiKey.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(apiKey.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKey.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val apiKey = + ApiKey.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(apiKey).isNotNull + assertThat(apiKey.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.name()).isEqualTo("name") + assertThat(apiKey.previewName()).isEqualTo("preview_name") + assertThat(apiKey.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKey.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt index dede2dfa..fbf9f7e4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt @@ -9,18 +9,25 @@ class ChatCompletionContentPartImageTest { @Test fun createChatCompletionContentPartImage() { - val chatCompletionContentPartImage = ChatCompletionContentPartImage.builder() - .imageUrl(ChatCompletionContentPartImage.ImageUrl.builder() - .url("url") - .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) - .build()) - .type(ChatCompletionContentPartImage.Type.IMAGE_URL) - .build() - assertThat(chatCompletionContentPartImage).isNotNull - assertThat(chatCompletionContentPartImage.imageUrl()).isEqualTo(ChatCompletionContentPartImage.ImageUrl.builder() - .url("url") - .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) - .build()) - assertThat(chatCompletionContentPartImage.type()).isEqualTo(ChatCompletionContentPartImage.Type.IMAGE_URL) + val chatCompletionContentPartImage = + ChatCompletionContentPartImage.builder() + .imageUrl( + ChatCompletionContentPartImage.ImageUrl.builder() + .url("url") + .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) + .build() + ) + .type(ChatCompletionContentPartImage.Type.IMAGE_URL) + .build() + assertThat(chatCompletionContentPartImage).isNotNull + assertThat(chatCompletionContentPartImage.imageUrl()) + .isEqualTo( + ChatCompletionContentPartImage.ImageUrl.builder() + .url("url") + .detail(ChatCompletionContentPartImage.ImageUrl.Detail.AUTO) + .build() + ) + assertThat(chatCompletionContentPartImage.type()) + .isEqualTo(ChatCompletionContentPartImage.Type.IMAGE_URL) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt index 1ce72db0..5e71c215 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt @@ -9,12 +9,14 @@ class ChatCompletionContentPartTextTest { @Test fun createChatCompletionContentPartText() { - val chatCompletionContentPartText = ChatCompletionContentPartText.builder() - .type(ChatCompletionContentPartText.Type.TEXT) - .text("text") - .build() - assertThat(chatCompletionContentPartText).isNotNull - assertThat(chatCompletionContentPartText.type()).isEqualTo(ChatCompletionContentPartText.Type.TEXT) - assertThat(chatCompletionContentPartText.text()).contains("text") + val chatCompletionContentPartText = + ChatCompletionContentPartText.builder() + .type(ChatCompletionContentPartText.Type.TEXT) + .text("text") + .build() + assertThat(chatCompletionContentPartText).isNotNull + assertThat(chatCompletionContentPartText.type()) + .isEqualTo(ChatCompletionContentPartText.Type.TEXT) + assertThat(chatCompletionContentPartText.text()).contains("text") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt index f5079fc1..c609ef38 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt @@ -9,20 +9,27 @@ class ChatCompletionMessageToolCallTest { @Test fun createChatCompletionMessageToolCall() { - val chatCompletionMessageToolCall = ChatCompletionMessageToolCall.builder() - .id("id") - .function(ChatCompletionMessageToolCall.Function.builder() - .arguments("arguments") - .name("name") - .build()) - .type(ChatCompletionMessageToolCall.Type.FUNCTION) - .build() - assertThat(chatCompletionMessageToolCall).isNotNull - assertThat(chatCompletionMessageToolCall.id()).isEqualTo("id") - assertThat(chatCompletionMessageToolCall.function()).isEqualTo(ChatCompletionMessageToolCall.Function.builder() - .arguments("arguments") - .name("name") - .build()) - assertThat(chatCompletionMessageToolCall.type()).isEqualTo(ChatCompletionMessageToolCall.Type.FUNCTION) + val chatCompletionMessageToolCall = + ChatCompletionMessageToolCall.builder() + .id("id") + .function( + ChatCompletionMessageToolCall.Function.builder() + .arguments("arguments") + .name("name") + .build() + ) + .type(ChatCompletionMessageToolCall.Type.FUNCTION) + .build() + assertThat(chatCompletionMessageToolCall).isNotNull + assertThat(chatCompletionMessageToolCall.id()).isEqualTo("id") + assertThat(chatCompletionMessageToolCall.function()) + .isEqualTo( + ChatCompletionMessageToolCall.Function.builder() + .arguments("arguments") + .name("name") + .build() + ) + assertThat(chatCompletionMessageToolCall.type()) + .isEqualTo(ChatCompletionMessageToolCall.Type.FUNCTION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt index cd737854..7cced6c5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt @@ -9,34 +9,51 @@ class CodeBundleTest { @Test fun createCodeBundle() { - val codeBundle = CodeBundle.builder() - .bundleId("bundle_id") - .location(CodeBundle.Location.Experiment.builder() - .evalName("eval_name") - .position(CodeBundle.Location.Experiment.Position.Type.builder() - .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) - .build()) - .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) - .build()) - .runtimeContext(CodeBundle.RuntimeContext.builder() - .runtime(CodeBundle.RuntimeContext.Runtime.NODE) - .version("version") - .build()) - .preview("preview") - .build() - assertThat(codeBundle).isNotNull - assertThat(codeBundle.bundleId()).isEqualTo("bundle_id") - assertThat(codeBundle.location()).isEqualTo(CodeBundle.Location.ofExperiment(CodeBundle.Location.Experiment.builder() - .evalName("eval_name") - .position(CodeBundle.Location.Experiment.Position.Type.builder() - .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) - .build()) - .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) - .build())) - assertThat(codeBundle.runtimeContext()).isEqualTo(CodeBundle.RuntimeContext.builder() - .runtime(CodeBundle.RuntimeContext.Runtime.NODE) - .version("version") - .build()) - assertThat(codeBundle.preview()).contains("preview") + val codeBundle = + CodeBundle.builder() + .bundleId("bundle_id") + .location( + CodeBundle.Location.Experiment.builder() + .evalName("eval_name") + .position( + CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) + .build() + ) + .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) + .build() + ) + .runtimeContext( + CodeBundle.RuntimeContext.builder() + .runtime(CodeBundle.RuntimeContext.Runtime.NODE) + .version("version") + .build() + ) + .preview("preview") + .build() + assertThat(codeBundle).isNotNull + assertThat(codeBundle.bundleId()).isEqualTo("bundle_id") + assertThat(codeBundle.location()) + .isEqualTo( + CodeBundle.Location.ofExperiment( + CodeBundle.Location.Experiment.builder() + .evalName("eval_name") + .position( + CodeBundle.Location.Experiment.Position.Type.builder() + .type(CodeBundle.Location.Experiment.Position.Type.InnerType.TASK) + .build() + ) + .type(CodeBundle.Location.Experiment.Type.EXPERIMENT) + .build() + ) + ) + assertThat(codeBundle.runtimeContext()) + .isEqualTo( + CodeBundle.RuntimeContext.builder() + .runtime(CodeBundle.RuntimeContext.Runtime.NODE) + .version("version") + .build() + ) + assertThat(codeBundle.preview()).contains("preview") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt index 12fa7a4c..6bfead25 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt @@ -10,22 +10,24 @@ class CreateApiKeyOutputTest { @Test fun createCreateApiKeyOutput() { - val createApiKeyOutput = CreateApiKeyOutput.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .key("key") - .name("name") - .previewName("preview_name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(createApiKeyOutput).isNotNull - assertThat(createApiKeyOutput.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createApiKeyOutput.key()).isEqualTo("key") - assertThat(createApiKeyOutput.name()).isEqualTo("name") - assertThat(createApiKeyOutput.previewName()).isEqualTo("preview_name") - assertThat(createApiKeyOutput.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(createApiKeyOutput.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createApiKeyOutput.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val createApiKeyOutput = + CreateApiKeyOutput.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .key("key") + .name("name") + .previewName("preview_name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(createApiKeyOutput).isNotNull + assertThat(createApiKeyOutput.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.key()).isEqualTo("key") + assertThat(createApiKeyOutput.name()).isEqualTo("name") + assertThat(createApiKeyOutput.previewName()).isEqualTo("preview_name") + assertThat(createApiKeyOutput.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(createApiKeyOutput.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt index e4af5d85..6ce8e5d3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt @@ -10,26 +10,60 @@ class CrossObjectInsertResponseTest { @Test fun createCrossObjectInsertResponse() { - val crossObjectInsertResponse = CrossObjectInsertResponse.builder() - .dataset(CrossObjectInsertResponse.Dataset.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) - .build()) - .experiment(CrossObjectInsertResponse.Experiment.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) - .build()) - .projectLogs(CrossObjectInsertResponse.ProjectLogs.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) - .build()) - .build() - assertThat(crossObjectInsertResponse).isNotNull - assertThat(crossObjectInsertResponse.dataset()).contains(CrossObjectInsertResponse.Dataset.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) - .build()) - assertThat(crossObjectInsertResponse.experiment()).contains(CrossObjectInsertResponse.Experiment.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) - .build()) - assertThat(crossObjectInsertResponse.projectLogs()).contains(CrossObjectInsertResponse.ProjectLogs.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf("row_ids" to listOf("string")))) - .build()) + val crossObjectInsertResponse = + CrossObjectInsertResponse.builder() + .dataset( + CrossObjectInsertResponse.Dataset.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))), + ) + .build() + ) + .experiment( + CrossObjectInsertResponse.Experiment.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))), + ) + .build() + ) + .projectLogs( + CrossObjectInsertResponse.ProjectLogs.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))), + ) + .build() + ) + .build() + assertThat(crossObjectInsertResponse).isNotNull + assertThat(crossObjectInsertResponse.dataset()) + .contains( + CrossObjectInsertResponse.Dataset.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))), + ) + .build() + ) + assertThat(crossObjectInsertResponse.experiment()) + .contains( + CrossObjectInsertResponse.Experiment.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))), + ) + .build() + ) + assertThat(crossObjectInsertResponse.projectLogs()) + .contains( + CrossObjectInsertResponse.ProjectLogs.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("row_ids" to listOf("string"))), + ) + .build() + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt index 2a0381cb..4cc2a2db 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt @@ -9,10 +9,8 @@ class DataSummaryTest { @Test fun createDataSummary() { - val dataSummary = DataSummary.builder() - .totalRecords(0L) - .build() - assertThat(dataSummary).isNotNull - assertThat(dataSummary.totalRecords()).isEqualTo(0L) + val dataSummary = DataSummary.builder().totalRecords(0L).build() + assertThat(dataSummary).isNotNull + assertThat(dataSummary.totalRecords()).isEqualTo(0L) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index 506e2734..53e0d257 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -11,49 +11,58 @@ class DatasetCreateParamsTest { @Test fun create() { - DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .build() + DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() } @Test fun body() { - val params = DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.description()).contains("description") - assertThat(body.metadata()).contains(DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) + val params = + DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.description()).contains("description") + assertThat(body.metadata()) + .contains( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test fun bodyWithoutOptionalFields() { - val params = DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt index b088a25f..8b41dbf4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt @@ -9,20 +9,17 @@ class DatasetDeleteParamsTest { @Test fun create() { - DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetDeleteParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt index d1168c6e..687f05e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -11,48 +11,60 @@ class DatasetEventTest { @Test fun createDatasetEvent() { - val datasetEvent = DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .origin(DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .addTag("string") - .build() - assertThat(datasetEvent).isNotNull - assertThat(datasetEvent.id()).isEqualTo("id") - assertThat(datasetEvent._xactId()).isEqualTo("_xact_id") - assertThat(datasetEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(datasetEvent.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(datasetEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(datasetEvent.spanId()).isEqualTo("span_id") - assertThat(datasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(datasetEvent.isRoot()).contains(true) - assertThat(datasetEvent.metadata()).contains(DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(datasetEvent.origin()).contains(DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build()) - assertThat(datasetEvent.tags().get()).containsExactly("string") + val datasetEvent = + DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .origin( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .addTag("string") + .build() + assertThat(datasetEvent).isNotNull + assertThat(datasetEvent.id()).isEqualTo("id") + assertThat(datasetEvent._xactId()).isEqualTo("_xact_id") + assertThat(datasetEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(datasetEvent.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(datasetEvent.spanId()).isEqualTo("span_id") + assertThat(datasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(datasetEvent.isRoot()).contains(true) + assertThat(datasetEvent.metadata()) + .contains( + DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(datasetEvent.origin()) + .contains( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + assertThat(datasetEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index f91d17c9..512fb176 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -11,78 +11,91 @@ class DatasetFeedbackParamsTest { @Test fun create() { - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build()) - .build() + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + ) + .build() } @Test fun body() { - val params = DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build()) - .build() + val params = + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()).isEqualTo(listOf(FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build())) + assertNotNull(body) + assertThat(body.feedback()) + .isEqualTo( + listOf( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + ) + ) } @Test fun bodyWithoutOptionalFields() { - val params = DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder() - .id("id") - .build()) - .build() + val params = + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder().id("id").build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()).isEqualTo(listOf(FeedbackDatasetItem.builder() - .id("id") - .build())) + assertNotNull(body) + assertThat(body.feedback()) + .isEqualTo(listOf(FeedbackDatasetItem.builder().id("id").build())) } @Test fun getPathParam() { - val params = DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder() - .id("id") - .build()) - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackDatasetItem.builder().id("id").build()) + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index 83be2844..1a2a1725 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -10,50 +10,49 @@ class DatasetFetchParamsTest { @Test fun create() { - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index ab4d88d8..3120e7e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -10,57 +10,60 @@ class DatasetFetchPostParamsTest { @Test fun create() { - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index d0c459e2..9f080dd0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -12,96 +12,114 @@ class DatasetInsertParamsTest { @Test fun create() { - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build() + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() } @Test fun body() { - val params = DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build() + val params = + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build())) + assertNotNull(body) + assertThat(body.events()) + .isEqualTo( + listOf( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + ) } @Test fun bodyWithoutOptionalFields() { - val params = DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder().build()) - .build() + val params = + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertDatasetEvent.builder().build())) } @Test fun getPathParam() { - val params = DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertDatasetEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index e3a35955..de58fd44 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -10,46 +10,50 @@ class DatasetListParamsTest { @Test fun create() { - DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("dataset_name", "dataset_name") - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("dataset_name", "dataset_name") + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = DatasetListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = DatasetListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt index 8473c6ff..95326568 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt @@ -9,20 +9,19 @@ class DatasetRetrieveParamsTest { @Test fun create() { - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetRetrieveParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index d2073c3f..83303cf0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -10,41 +10,44 @@ class DatasetSummarizeParamsTest { @Test fun create() { - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() } @Test fun queryParams() { - val params = DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - val expected = QueryParams.builder() - expected.put("summarize_data", "true") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() + val expected = QueryParams.builder() + expected.put("summarize_data", "true") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt index 5c0ada06..829a918e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt @@ -11,28 +11,34 @@ class DatasetTest { @Test fun createDataset() { - val dataset = Dataset.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata(Dataset.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(dataset).isNotNull - assertThat(dataset.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(dataset.name()).isEqualTo("name") - assertThat(dataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(dataset.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.description()).contains("description") - assertThat(dataset.metadata()).contains(Dataset.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(dataset.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val dataset = + Dataset.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .metadata( + Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(dataset).isNotNull + assertThat(dataset.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.name()).isEqualTo("name") + assertThat(dataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.description()).contains("description") + assertThat(dataset.metadata()) + .contains( + Dataset.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(dataset.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index 4b84f951..c7976ff2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -11,57 +11,63 @@ class DatasetUpdateParamsTest { @Test fun create() { - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .build() + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .build() } @Test fun body() { - val params = DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .build() + val params = + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.metadata()).contains(DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(body.name()).contains("name") + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.metadata()) + .contains( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.name()).contains("name") } @Test fun bodyWithoutOptionalFields() { - val params = DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "datasetId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "datasetId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt index f901f36e..d5e8e9f1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt @@ -10,45 +10,47 @@ class EnvVarCreateParamsTest { @Test fun create() { - EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() + EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() } @Test fun body() { - val params = EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) - assertThat(body.value()).contains("value") + val params = + EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) + val params = + EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarCreateParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt index 6808443f..b6264f9d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt @@ -9,20 +9,17 @@ class EnvVarDeleteParamsTest { @Test fun create() { - EnvVarDeleteParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + EnvVarDeleteParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = EnvVarDeleteParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + EnvVarDeleteParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 1d3b4b4f..4af4a47a 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 @@ -10,37 +10,41 @@ class EnvVarListParamsTest { @Test fun create() { - EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() + EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() } @Test fun queryParams() { - val params = EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("env_var_name", "env_var_name") - expected.put("ids", EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("env_var_name", "env_var_name") + expected.put( + "ids", + EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", EnvVarListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = EnvVarListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = EnvVarListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt index 4e695e38..35b86df1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt @@ -10,24 +10,30 @@ class EnvVarListResponseTest { @Test fun createEnvVarListResponse() { - val envVarListResponse = EnvVarListResponse.builder() - .addObject(EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build()) - .build() - assertThat(envVarListResponse).isNotNull - assertThat(envVarListResponse.objects()).containsExactly(EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build()) + val envVarListResponse = + EnvVarListResponse.builder() + .addObject( + EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + assertThat(envVarListResponse).isNotNull + assertThat(envVarListResponse.objects()) + .containsExactly( + EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt index 53857e16..68d9ebd2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt @@ -10,45 +10,47 @@ class EnvVarReplaceParamsTest { @Test fun create() { - EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() + EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() } @Test fun body() { - val params = EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.value()).contains("value") + val params = + EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) + val params = + EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(EnvVarReplaceParams.ObjectType.ORGANIZATION) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt index 513ce8d5..bca82bdc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt @@ -9,20 +9,17 @@ class EnvVarRetrieveParamsTest { @Test fun create() { - EnvVarRetrieveParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + EnvVarRetrieveParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = EnvVarRetrieveParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + EnvVarRetrieveParams.builder().envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt index f7825f39..224dddbb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt @@ -10,20 +10,21 @@ class EnvVarTest { @Test fun createEnvVar() { - val envVar = EnvVar.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVar.ObjectType.ORGANIZATION) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - assertThat(envVar).isNotNull - assertThat(envVar.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(envVar.name()).isEqualTo("name") - assertThat(envVar.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(envVar.objectType()).isEqualTo(EnvVar.ObjectType.ORGANIZATION) - assertThat(envVar.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(envVar.used()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + val envVar = + EnvVar.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVar.ObjectType.ORGANIZATION) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .used(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(envVar).isNotNull + assertThat(envVar.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(envVar.name()).isEqualTo("name") + assertThat(envVar.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(envVar.objectType()).isEqualTo(EnvVar.ObjectType.ORGANIZATION) + assertThat(envVar.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(envVar.used()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt index 7188655e..e4ad1080 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt @@ -10,51 +10,54 @@ class EnvVarUpdateParamsTest { @Test fun create() { - EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() } @Test fun body() { - val params = EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.value()).contains("value") + val params = + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.value()).contains("value") } @Test fun bodyWithoutOptionalFields() { - val params = EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() + val params = + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") } @Test fun getPathParam() { - val params = EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .build() - assertThat(params).isNotNull - // path param "envVarId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .build() + assertThat(params).isNotNull + // path param "envVarId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index 3381511b..5ac72887 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -11,161 +11,212 @@ class EvalCreateParamsTest { @Test fun create() { - EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder() - .datasetId("dataset_id") - .build()) - .projectId("project_id") - .addScore(EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()) - .task(EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build()) - .isPublic(true) - .maxConcurrency(0.0) - .metadata(EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() + EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .projectId("project_id") + .addScore( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .task( + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build() + ) + .isPublic(true) + .maxConcurrency(0.0) + .metadata( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() } @Test fun body() { - val params = EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder() - .datasetId("dataset_id") - .build()) - .projectId("project_id") - .addScore(EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()) - .task(EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build()) - .isPublic(true) - .maxConcurrency(0.0) - .metadata(EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build() + val params = + EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .projectId("project_id") + .addScore( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .task( + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build() + ) + .isPublic(true) + .maxConcurrency(0.0) + .metadata( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.data()).isEqualTo(EvalCreateParams.Data.ofDatasetId(EvalCreateParams.Data.DatasetId.builder() - .datasetId("dataset_id") - .build())) - assertThat(body.projectId()).isEqualTo("project_id") - assertThat(body.scores()).isEqualTo(listOf(EvalCreateParams.Score.ofFunctionId(EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()))) - assertThat(body.task()).isEqualTo(EvalCreateParams.Task.ofFunctionId(EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build())) - assertThat(body.baseExperimentId()).contains("base_experiment_id") - assertThat(body.baseExperimentName()).contains("base_experiment_name") - assertThat(body.experimentName()).contains("experiment_name") - assertThat(body.gitMetadataSettings()).contains(EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build()) - assertThat(body.isPublic()).contains(true) - assertThat(body.maxConcurrency()).contains(0.0) - assertThat(body.metadata()).contains(EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(body.repoInfo()).contains(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - assertThat(body.stream()).contains(true) - assertThat(body.timeout()).contains(0.0) - assertThat(body.trialCount()).contains(0.0) + assertNotNull(body) + assertThat(body.data()) + .isEqualTo( + EvalCreateParams.Data.ofDatasetId( + EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() + ) + ) + assertThat(body.projectId()).isEqualTo("project_id") + assertThat(body.scores()) + .isEqualTo( + listOf( + EvalCreateParams.Score.ofFunctionId( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + ) + ) + assertThat(body.task()) + .isEqualTo( + EvalCreateParams.Task.ofFunctionId( + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + ) + assertThat(body.baseExperimentId()).contains("base_experiment_id") + assertThat(body.baseExperimentName()).contains("base_experiment_name") + assertThat(body.experimentName()).contains("experiment_name") + assertThat(body.gitMetadataSettings()) + .contains( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build() + ) + assertThat(body.isPublic()).contains(true) + assertThat(body.maxConcurrency()).contains(0.0) + assertThat(body.metadata()) + .contains( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.repoInfo()) + .contains( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + assertThat(body.stream()).contains(true) + assertThat(body.timeout()).contains(0.0) + assertThat(body.trialCount()).contains(0.0) } @Test fun bodyWithoutOptionalFields() { - val params = EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder() - .datasetId("dataset_id") - .build()) - .projectId("project_id") - .addScore(EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .build()) - .task(EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .build()) - .build() + val params = + EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .projectId("project_id") + .addScore( + EvalCreateParams.Score.FunctionId.builder().functionId("function_id").build() + ) + .task(EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.data()).isEqualTo(EvalCreateParams.Data.ofDatasetId(EvalCreateParams.Data.DatasetId.builder() - .datasetId("dataset_id") - .build())) - assertThat(body.projectId()).isEqualTo("project_id") - assertThat(body.scores()).isEqualTo(listOf(EvalCreateParams.Score.ofFunctionId(EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .build()))) - assertThat(body.task()).isEqualTo(EvalCreateParams.Task.ofFunctionId(EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .build())) + assertNotNull(body) + assertThat(body.data()) + .isEqualTo( + EvalCreateParams.Data.ofDatasetId( + EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() + ) + ) + assertThat(body.projectId()).isEqualTo("project_id") + assertThat(body.scores()) + .isEqualTo( + listOf( + EvalCreateParams.Score.ofFunctionId( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .build() + ) + ) + ) + assertThat(body.task()) + .isEqualTo( + EvalCreateParams.Task.ofFunctionId( + EvalCreateParams.Task.FunctionId.builder().functionId("function_id").build() + ) + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 95de1502..0b43f784 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -11,95 +11,111 @@ class ExperimentCreateParamsTest { @Test fun create() { - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("x") - .public_(true) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build() + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("x") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() } @Test fun body() { - val params = ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("x") - .public_(true) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build() + val params = + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("x") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).contains("dataset_version") - assertThat(body.description()).contains("description") - assertThat(body.ensureNew()).contains(true) - assertThat(body.metadata()).contains(ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(body.name()).contains("x") - assertThat(body.public_()).contains(true) - assertThat(body.repoInfo()).contains(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) + assertNotNull(body) + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.description()).contains("description") + assertThat(body.ensureNew()).contains(true) + assertThat(body.metadata()) + .contains( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.name()).contains("x") + assertThat(body.public_()).contains(true) + assertThat(body.repoInfo()) + .contains( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) } @Test fun bodyWithoutOptionalFields() { - val params = ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt index 6a49fc3d..30220ebc 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt @@ -9,20 +9,21 @@ class ExperimentDeleteParamsTest { @Test fun create() { - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 34834679..3830f18c 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 @@ -11,100 +11,124 @@ class ExperimentEventTest { @Test fun createExperimentEvent() { - val experimentEvent = ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context(ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .origin(ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .addSpanParent("string") - .addTag("string") - .build() - assertThat(experimentEvent).isNotNull - assertThat(experimentEvent.id()).isEqualTo("id") - assertThat(experimentEvent._xactId()).isEqualTo("_xact_id") - assertThat(experimentEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experimentEvent.experimentId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experimentEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experimentEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(experimentEvent.spanId()).isEqualTo("span_id") - assertThat(experimentEvent.context()).contains(ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") - assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent.isRoot()).contains(true) - assertThat(experimentEvent.metadata()).contains(ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(experimentEvent.metrics()).contains(ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - assertThat(experimentEvent.origin()).contains(ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build()) - assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent.scores()).contains(ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - assertThat(experimentEvent.spanAttributes()).contains(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - assertThat(experimentEvent.spanParents().get()).containsExactly("string") - assertThat(experimentEvent.tags().get()).containsExactly("string") + val experimentEvent = + ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .origin( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .addSpanParent("string") + .addTag("string") + .build() + assertThat(experimentEvent).isNotNull + assertThat(experimentEvent.id()).isEqualTo("id") + assertThat(experimentEvent._xactId()).isEqualTo("_xact_id") + assertThat(experimentEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experimentEvent.experimentId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experimentEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experimentEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(experimentEvent.spanId()).isEqualTo("span_id") + assertThat(experimentEvent.context()) + .contains( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") + assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.isRoot()).contains(true) + assertThat(experimentEvent.metadata()) + .contains( + ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(experimentEvent.metrics()) + .contains( + ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + assertThat(experimentEvent.origin()) + .contains( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.scores()) + .contains( + ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(experimentEvent.spanAttributes()) + .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.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/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index 99065209..edb22bd0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -11,90 +11,109 @@ class ExperimentFeedbackParamsTest { @Test fun create() { - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build()) - .build() + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + ) + .build() } @Test fun body() { - val params = ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build()) - .build() + val params = + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()).isEqualTo(listOf(FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build())) + assertNotNull(body) + assertThat(body.feedback()) + .isEqualTo( + listOf( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + ) + ) } @Test fun bodyWithoutOptionalFields() { - val params = ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder() - .id("id") - .build()) - .build() + val params = + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder().id("id").build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()).isEqualTo(listOf(FeedbackExperimentItem.builder() - .id("id") - .build())) + assertNotNull(body) + assertThat(body.feedback()) + .isEqualTo(listOf(FeedbackExperimentItem.builder().id("id").build())) } @Test fun getPathParam() { - val params = ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder() - .id("id") - .build()) - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackExperimentItem.builder().id("id").build()) + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index b782831e..a699676d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -10,50 +10,53 @@ class ExperimentFetchParamsTest { @Test fun create() { - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index 001acc2f..f537a14a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -10,57 +10,60 @@ class ExperimentFetchPostParamsTest { @Test fun create() { - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 89d62de4..9627ff9b 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 @@ -12,171 +12,210 @@ class ExperimentInsertParamsTest { @Test fun create() { - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build() + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() } @Test fun body() { - val params = ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build() + val params = + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build())) + assertNotNull(body) + assertThat(body.events()) + .isEqualTo( + listOf( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + ) } @Test fun bodyWithoutOptionalFields() { - val params = ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder().build()) - .build() + val params = + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertExperimentEvent.builder().build())) } @Test fun getPathParam() { - val params = ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertExperimentEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 9e8221f4..06a265e5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -10,46 +10,50 @@ class ExperimentListParamsTest { @Test fun create() { - ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("experiment_name", "experiment_name") - expected.put("ids", ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("experiment_name", "experiment_name") + expected.put( + "ids", + ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ExperimentListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ExperimentListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt index 7a6cd8f1..b9530a24 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt @@ -9,20 +9,21 @@ class ExperimentRetrieveParamsTest { @Test fun create() { - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index 02307eab..257ca247 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -10,44 +10,47 @@ class ExperimentSummarizeParamsTest { @Test fun create() { - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() } @Test fun queryParams() { - val params = ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - val expected = QueryParams.builder() - expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("summarize_scores", "true") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() + val expected = QueryParams.builder() + expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("summarize_scores", "true") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt index 4fa1b102..2d2df4e3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt @@ -11,60 +11,72 @@ class ExperimentTest { @Test fun createExperiment() { - val experiment = Experiment.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .public_(true) - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .commit("commit") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata(Experiment.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(experiment).isNotNull - assertThat(experiment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.name()).isEqualTo("name") - assertThat(experiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.public_()).isEqualTo(true) - assertThat(experiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.commit()).contains("commit") - assertThat(experiment.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.datasetVersion()).contains("dataset_version") - assertThat(experiment.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.description()).contains("description") - assertThat(experiment.metadata()).contains(Experiment.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(experiment.repoInfo()).contains(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - assertThat(experiment.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val experiment = + Experiment.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .public_(true) + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit("commit") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .metadata( + Experiment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(experiment).isNotNull + assertThat(experiment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.name()).isEqualTo("name") + assertThat(experiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.public_()).isEqualTo(true) + assertThat(experiment.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.commit()).contains("commit") + assertThat(experiment.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experiment.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.datasetVersion()).contains("dataset_version") + assertThat(experiment.deletedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experiment.description()).contains("description") + assertThat(experiment.metadata()) + .contains( + Experiment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(experiment.repoInfo()) + .contains( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + assertThat(experiment.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index 7abf3e9b..e7ed2b95 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -11,102 +11,119 @@ class ExperimentUpdateParamsTest { @Test fun create() { - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .public_(true) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build() + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() } @Test fun body() { - val params = ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .public_(true) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build() + val params = + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).contains("dataset_version") - assertThat(body.description()).contains("description") - assertThat(body.metadata()).contains(ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(body.name()).contains("name") - assertThat(body.public_()).contains(true) - assertThat(body.repoInfo()).contains(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) + assertNotNull(body) + assertThat(body.baseExpId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).contains("dataset_version") + assertThat(body.description()).contains("description") + assertThat(body.metadata()) + .contains( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.name()).contains("name") + assertThat(body.public_()).contains(true) + assertThat(body.repoInfo()) + .contains( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) } @Test fun bodyWithoutOptionalFields() { - val params = ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "experimentId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "experimentId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index b803ec6d..6543fca7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -10,22 +10,28 @@ class FeedbackDatasetItemTest { @Test fun createFeedbackDatasetItem() { - val feedbackDatasetItem = FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackDatasetItem).isNotNull - assertThat(feedbackDatasetItem.id()).isEqualTo("id") - assertThat(feedbackDatasetItem.comment()).contains("comment") - assertThat(feedbackDatasetItem.metadata()).contains(FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) - assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") + val feedbackDatasetItem = + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackDatasetItem).isNotNull + assertThat(feedbackDatasetItem.id()).isEqualTo("id") + assertThat(feedbackDatasetItem.comment()).contains("comment") + assertThat(feedbackDatasetItem.metadata()) + .contains( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(feedbackDatasetItem.source()).contains(FeedbackDatasetItem.Source.APP) + assertThat(feedbackDatasetItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index f1fda957..eef4dee8 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -10,30 +10,42 @@ class FeedbackExperimentItemTest { @Test fun createFeedbackExperimentItem() { - val feedbackExperimentItem = FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackExperimentItem).isNotNull - assertThat(feedbackExperimentItem.id()).isEqualTo("id") - assertThat(feedbackExperimentItem.comment()).contains("comment") - assertThat(feedbackExperimentItem._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(feedbackExperimentItem.metadata()).contains(FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(feedbackExperimentItem.scores()).contains(FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) - assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") + val feedbackExperimentItem = + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackExperimentItem).isNotNull + assertThat(feedbackExperimentItem.id()).isEqualTo("id") + assertThat(feedbackExperimentItem.comment()).contains("comment") + assertThat(feedbackExperimentItem._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackExperimentItem.metadata()) + .contains( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(feedbackExperimentItem.scores()) + .contains( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(feedbackExperimentItem.source()).contains(FeedbackExperimentItem.Source.APP) + assertThat(feedbackExperimentItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index 69d0d47b..34f44497 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -10,30 +10,42 @@ class FeedbackProjectLogsItemTest { @Test fun createFeedbackProjectLogsItem() { - val feedbackProjectLogsItem = FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build() - assertThat(feedbackProjectLogsItem).isNotNull - assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") - assertThat(feedbackProjectLogsItem.comment()).contains("comment") - assertThat(feedbackProjectLogsItem._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(feedbackProjectLogsItem.metadata()).contains(FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(feedbackProjectLogsItem.scores()).contains(FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) - assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") + val feedbackProjectLogsItem = + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + assertThat(feedbackProjectLogsItem).isNotNull + assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") + assertThat(feedbackProjectLogsItem.comment()).contains("comment") + assertThat(feedbackProjectLogsItem._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackProjectLogsItem.metadata()) + .contains( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(feedbackProjectLogsItem.scores()) + .contains( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(feedbackProjectLogsItem.source()).contains(FeedbackProjectLogsItem.Source.APP) + assertThat(feedbackProjectLogsItem.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt index daebb6ba..a1b62a0b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt @@ -9,10 +9,9 @@ class FeedbackResponseSchemaTest { @Test fun createFeedbackResponseSchema() { - val feedbackResponseSchema = FeedbackResponseSchema.builder() - .status(FeedbackResponseSchema.Status.SUCCESS) - .build() - assertThat(feedbackResponseSchema).isNotNull - assertThat(feedbackResponseSchema.status()).isEqualTo(FeedbackResponseSchema.Status.SUCCESS) + val feedbackResponseSchema = + FeedbackResponseSchema.builder().status(FeedbackResponseSchema.Status.SUCCESS).build() + assertThat(feedbackResponseSchema).isNotNull + assertThat(feedbackResponseSchema.status()).isEqualTo(FeedbackResponseSchema.Status.SUCCESS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt index 7017147f..ad7d703b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -11,54 +11,68 @@ class FetchDatasetEventsResponseTest { @Test fun createFetchDatasetEventsResponse() { - val fetchDatasetEventsResponse = FetchDatasetEventsResponse.builder() - .addEvent(DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .origin(DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .addTag("string") - .build()) - .cursor("cursor") - .build() - assertThat(fetchDatasetEventsResponse).isNotNull - assertThat(fetchDatasetEventsResponse.events()).containsExactly(DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .origin(DatasetEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .addTag("string") - .build()) - assertThat(fetchDatasetEventsResponse.cursor()).contains("cursor") + val fetchDatasetEventsResponse = + FetchDatasetEventsResponse.builder() + .addEvent( + DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .origin( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .addTag("string") + .build() + ) + .cursor("cursor") + .build() + assertThat(fetchDatasetEventsResponse).isNotNull + assertThat(fetchDatasetEventsResponse.events()) + .containsExactly( + DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + DatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .origin( + DatasetEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .addTag("string") + .build() + ) + assertThat(fetchDatasetEventsResponse.cursor()).contains("cursor") } } 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 fd2b1539..7e95ce35 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 @@ -11,106 +11,133 @@ class FetchExperimentEventsResponseTest { @Test fun createFetchExperimentEventsResponse() { - val fetchExperimentEventsResponse = FetchExperimentEventsResponse.builder() - .addEvent(ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context(ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .origin(ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .addSpanParent("string") - .addTag("string") - .build()) - .cursor("cursor") - .build() - assertThat(fetchExperimentEventsResponse).isNotNull - assertThat(fetchExperimentEventsResponse.events()).containsExactly(ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context(ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(ExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .origin(ExperimentEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .addSpanParent("string") - .addTag("string") - .build()) - assertThat(fetchExperimentEventsResponse.cursor()).contains("cursor") + val fetchExperimentEventsResponse = + FetchExperimentEventsResponse.builder() + .addEvent( + ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .origin( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .addSpanParent("string") + .addTag("string") + .build() + ) + .cursor("cursor") + .build() + assertThat(fetchExperimentEventsResponse).isNotNull + assertThat(fetchExperimentEventsResponse.events()) + .containsExactly( + ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + ExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + ExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .origin( + ExperimentEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .addSpanParent("string") + .addTag("string") + .build() + ) + assertThat(fetchExperimentEventsResponse.cursor()).contains("cursor") } } 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 e99c2e4e..4c35853e 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 @@ -11,106 +11,133 @@ class FetchProjectLogsEventsResponseTest { @Test fun createFetchProjectLogsEventsResponse() { - val fetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse.builder() - .addEvent(ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context(ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .origin(ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .addSpanParent("string") - .addTag("string") - .build()) - .cursor("cursor") - .build() - assertThat(fetchProjectLogsEventsResponse).isNotNull - assertThat(fetchProjectLogsEventsResponse.events()).containsExactly(ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context(ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .origin(ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .addSpanParent("string") - .addTag("string") - .build()) - assertThat(fetchProjectLogsEventsResponse.cursor()).contains("cursor") + val fetchProjectLogsEventsResponse = + FetchProjectLogsEventsResponse.builder() + .addEvent( + ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .origin( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .addSpanParent("string") + .addTag("string") + .build() + ) + .cursor("cursor") + .build() + assertThat(fetchProjectLogsEventsResponse).isNotNull + assertThat(fetchProjectLogsEventsResponse.events()) + .containsExactly( + ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .origin( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .addSpanParent("string") + .addTag("string") + .build() + ) + assertThat(fetchProjectLogsEventsResponse.cursor()).contains("cursor") } } 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 19b3364c..f4114dc7 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 @@ -11,216 +11,351 @@ class FunctionCreateParamsTest { @Test fun create() { - FunctionCreateParams.builder() - .functionData(FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema(FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin(FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin( + FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() } @Test fun body() { - val params = FunctionCreateParams.builder() - .functionData(FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema(FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin(FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + val params = + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin( + FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()).isEqualTo(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build())) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionSchema()).contains(FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - assertThat(body.functionType()).contains(FunctionCreateParams.FunctionType.LLM) - assertThat(body.origin()).contains(FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - assertThat(body.promptData()).contains(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.functionData()) + .isEqualTo( + FunctionCreateParams.FunctionData.ofPrompt( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionSchema()) + .contains( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + assertThat(body.functionType()).contains(FunctionCreateParams.FunctionType.LLM) + assertThat(body.origin()) + .contains( + FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + assertThat(body.promptData()) + .contains( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = FunctionCreateParams.builder() - .functionData(FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()).isEqualTo(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build())) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.functionData()) + .isEqualTo( + FunctionCreateParams.FunctionData.ofPrompt( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt index 0ddf31ef..480affa6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt @@ -9,20 +9,19 @@ class FunctionDeleteParamsTest { @Test fun create() { - FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + FunctionDeleteParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index d494cacb..dcfb6ecc 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -11,105 +11,146 @@ class FunctionInvokeParamsTest { @Test fun create() { - FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage(FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build()) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) - .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build()) - .build()) - .stream(true) - .version("version") - .build() + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent( + FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + .stream(true) + .version("version") + .build() } @Test fun body() { - val params = FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage(FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build()) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) - .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build()) - .build()) - .stream(true) - .version("version") - .build() + val params = + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent( + FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + .stream(true) + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body.messages()).contains(listOf(FunctionInvokeParams.Message.ofSystem(FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build()))) - assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) - assertThat(body.parent()).contains(FunctionInvokeParams.Parent.ofSpanParentStruct(FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) - .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build()) - .build())) - assertThat(body.stream()).contains(true) - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.messages()) + .contains( + listOf( + FunctionInvokeParams.Message.ofSystem( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + ) + ) + assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) + assertThat(body.parent()) + .contains( + FunctionInvokeParams.Parent.ofSpanParentStruct( + FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + ) + assertThat(body.stream()).contains(true) + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 4838dff0..289b3695 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -10,52 +10,56 @@ class FunctionListParamsTest { @Test fun create() { - FunctionListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .functionName("function_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() + FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() } @Test fun queryParams() { - val params = FunctionListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .functionName("function_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("function_name", "function_name") - expected.put("ids", FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("slug", "slug") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("function_name", "function_name") + expected.put( + "ids", + FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("slug", "slug") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = FunctionListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = FunctionListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.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 6e455332..56eba313 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 @@ -11,216 +11,351 @@ class FunctionReplaceParamsTest { @Test fun create() { - FunctionReplaceParams.builder() - .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema(FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin(FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin( + FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() } @Test fun body() { - val params = FunctionReplaceParams.builder() - .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema(FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin(FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + val params = + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin( + FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()).isEqualTo(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build())) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionSchema()).contains(FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - assertThat(body.functionType()).contains(FunctionReplaceParams.FunctionType.LLM) - assertThat(body.origin()).contains(FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - assertThat(body.promptData()).contains(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.functionData()) + .isEqualTo( + FunctionReplaceParams.FunctionData.ofPrompt( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionSchema()) + .contains( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + assertThat(body.functionType()).contains(FunctionReplaceParams.FunctionType.LLM) + assertThat(body.origin()) + .contains( + FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + assertThat(body.promptData()) + .contains( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = FunctionReplaceParams.builder() - .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.functionData()).isEqualTo(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build())) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.functionData()) + .isEqualTo( + FunctionReplaceParams.FunctionData.ofPrompt( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt index 29b1b68a..95d6777e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt @@ -9,20 +9,19 @@ class FunctionRetrieveParamsTest { @Test fun create() { - FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + FunctionRetrieveParams.builder().functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 65ad88e1..b6570597 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 @@ -11,142 +11,234 @@ class FunctionTest { @Test fun createFunction() { - val function = Function.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("_xact_id") - .functionData(Function.FunctionData.Prompt.builder() - .type(Function.FunctionData.Prompt.Type.PROMPT) - .build()) - .logId(Function.LogId.P) - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .functionSchema(Function.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(Function.FunctionType.LLM) - .metadata(Function.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .origin(Function.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() - assertThat(function).isNotNull - assertThat(function.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function._xactId()).isEqualTo("_xact_id") - assertThat(function.functionData()).isEqualTo(Function.FunctionData.ofPrompt(Function.FunctionData.Prompt.builder() - .type(Function.FunctionData.Prompt.Type.PROMPT) - .build())) - assertThat(function.logId()).isEqualTo(Function.LogId.P) - assertThat(function.name()).isEqualTo("name") - assertThat(function.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(function.slug()).isEqualTo("slug") - assertThat(function.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(function.description()).contains("description") - assertThat(function.functionSchema()).contains(Function.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - assertThat(function.functionType()).contains(Function.FunctionType.LLM) - assertThat(function.metadata()).contains(Function.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(function.origin()).contains(Function.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - assertThat(function.promptData()).contains(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - assertThat(function.tags().get()).containsExactly("string") + val function = + Function.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._xactId("_xact_id") + .functionData( + Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .logId(Function.LogId.P) + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .functionSchema( + Function.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(Function.FunctionType.LLM) + .metadata( + Function.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .origin( + Function.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Function.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + assertThat(function).isNotNull + assertThat(function.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function._xactId()).isEqualTo("_xact_id") + assertThat(function.functionData()) + .isEqualTo( + Function.FunctionData.ofPrompt( + Function.FunctionData.Prompt.builder() + .type(Function.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(function.logId()).isEqualTo(Function.LogId.P) + assertThat(function.name()).isEqualTo("name") + assertThat(function.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(function.slug()).isEqualTo("slug") + assertThat(function.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(function.description()).contains("description") + assertThat(function.functionSchema()) + .contains( + Function.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + assertThat(function.functionType()).contains(Function.FunctionType.LLM) + assertThat(function.metadata()) + .contains( + Function.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(function.origin()) + .contains( + Function.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Function.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + assertThat(function.promptData()) + .contains( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + assertThat(function.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index e88bb07d..051c89be 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -11,183 +11,298 @@ class FunctionUpdateParamsTest { @Test fun create() { - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("name") - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() } @Test fun body() { - val params = FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("name") - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + val params = + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.functionData()).contains(FunctionUpdateParams.FunctionData.ofPrompt(FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build())) - assertThat(body.name()).contains("name") - assertThat(body.promptData()).contains(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.functionData()) + .contains( + FunctionUpdateParams.FunctionData.ofPrompt( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + ) + assertThat(body.name()).contains("name") + assertThat(body.promptData()) + .contains( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "functionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "functionId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index e4be7a89..c9d71536 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -10,44 +10,43 @@ class GroupCreateParamsTest { @Test fun create() { - GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = + GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = GroupCreateParams.builder() - .name("x") - .build() + val params = GroupCreateParams.builder().name("x").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt index db4190e4..e7f479a6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt @@ -9,20 +9,17 @@ class GroupDeleteParamsTest { @Test fun create() { - GroupDeleteParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = GroupDeleteParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index 53ff9db9..c5cd5eb4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -10,40 +10,44 @@ class GroupListParamsTest { @Test fun create() { - GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("group_name", "group_name") - expected.put("ids", GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("group_name", "group_name") + expected.put( + "ids", + GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = GroupListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = GroupListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index 1e04ba8f..093c89bc 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -10,44 +10,43 @@ class GroupReplaceParamsTest { @Test fun create() { - GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = + GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = GroupReplaceParams.builder() - .name("x") - .build() + val params = GroupReplaceParams.builder().name("x").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt index b86977bd..289d5b88 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt @@ -9,20 +9,17 @@ class GroupRetrieveParamsTest { @Test fun create() { - GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + GroupRetrieveParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt index 476f11a1..1acccdaa 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt @@ -10,26 +10,29 @@ class GroupTest { @Test fun createGroup() { - val group = Group.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(group).isNotNull - assertThat(group.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.name()).isEqualTo("name") - assertThat(group.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.description()).contains("description") - assertThat(group.memberGroups().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.memberUsers().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val group = + Group.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(group).isNotNull + assertThat(group.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.name()).isEqualTo("name") + assertThat(group.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(group.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(group.description()).contains("description") + assertThat(group.memberGroups().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.memberUsers().get()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index 46d425b2..cb449a6e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -10,60 +10,61 @@ class GroupUpdateParamsTest { @Test fun create() { - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("x") - assertThat(body.removeMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.removeMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertNotNull(body) + assertThat(body.addMemberGroups()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.addMemberUsers()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("x") + assertThat(body.removeMemberGroups()) + .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.removeMemberUsers()) + .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun bodyWithoutOptionalFields() { - val params = GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "groupId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "groupId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt index bc3c26de..53366aec 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt @@ -11,38 +11,45 @@ class InsertDatasetEventTest { @Test fun createInsertDatasetEvent() { - val insertDatasetEvent = InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertDatasetEvent).isNotNull - assertThat(insertDatasetEvent.id()).contains("id") - assertThat(insertDatasetEvent._isMerge()).contains(true) - assertThat(insertDatasetEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertDatasetEvent._objectDelete()).contains(true) - assertThat(insertDatasetEvent._parentId()).contains("_parent_id") - assertThat(insertDatasetEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEvent.metadata()).contains(InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") - assertThat(insertDatasetEvent.spanId()).contains("span_id") - assertThat(insertDatasetEvent.spanParents().get()).containsExactly("string") - assertThat(insertDatasetEvent.tags().get()).containsExactly("string") + val insertDatasetEvent = + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertDatasetEvent).isNotNull + assertThat(insertDatasetEvent.id()).contains("id") + assertThat(insertDatasetEvent._isMerge()).contains(true) + assertThat(insertDatasetEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertDatasetEvent._objectDelete()).contains(true) + assertThat(insertDatasetEvent._parentId()).contains("_parent_id") + assertThat(insertDatasetEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEvent.metadata()) + .contains( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") + assertThat(insertDatasetEvent.spanId()).contains("span_id") + assertThat(insertDatasetEvent.spanParents().get()).containsExactly("string") + assertThat(insertDatasetEvent.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt index 32730c21..96d2a732 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt @@ -9,10 +9,8 @@ class InsertEventsResponseTest { @Test fun createInsertEventsResponse() { - val insertEventsResponse = InsertEventsResponse.builder() - .addRowId("string") - .build() - assertThat(insertEventsResponse).isNotNull - assertThat(insertEventsResponse.rowIds()).containsExactly("string") + val insertEventsResponse = InsertEventsResponse.builder().addRowId("string").build() + assertThat(insertEventsResponse).isNotNull + assertThat(insertEventsResponse.rowIds()).containsExactly("string") } } 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 5135be62..e9425570 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 @@ -11,88 +11,108 @@ class InsertExperimentEventTest { @Test fun createInsertExperimentEvent() { - val insertExperimentEvent = InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertExperimentEvent).isNotNull - assertThat(insertExperimentEvent.id()).contains("id") - assertThat(insertExperimentEvent._isMerge()).contains(true) - assertThat(insertExperimentEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertExperimentEvent._objectDelete()).contains(true) - assertThat(insertExperimentEvent._parentId()).contains("_parent_id") - assertThat(insertExperimentEvent.context()).contains(InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - assertThat(insertExperimentEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") - assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent.metadata()).contains(InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(insertExperimentEvent.metrics()).contains(InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") - assertThat(insertExperimentEvent.scores()).contains(InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - assertThat(insertExperimentEvent.spanAttributes()).contains(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - assertThat(insertExperimentEvent.spanId()).contains("span_id") - assertThat(insertExperimentEvent.spanParents().get()).containsExactly("string") - assertThat(insertExperimentEvent.tags().get()).containsExactly("string") + val insertExperimentEvent = + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertExperimentEvent).isNotNull + assertThat(insertExperimentEvent.id()).contains("id") + assertThat(insertExperimentEvent._isMerge()).contains(true) + assertThat(insertExperimentEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertExperimentEvent._objectDelete()).contains(true) + assertThat(insertExperimentEvent._parentId()).contains("_parent_id") + assertThat(insertExperimentEvent.context()) + .contains( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + assertThat(insertExperimentEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") + assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent.metadata()) + .contains( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(insertExperimentEvent.metrics()) + .contains( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") + assertThat(insertExperimentEvent.scores()) + .contains( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(insertExperimentEvent.spanAttributes()) + .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.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 203cd955..3454b8e9 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 @@ -11,86 +11,106 @@ class InsertProjectLogsEventTest { @Test fun createInsertProjectLogsEvent() { - val insertProjectLogsEvent = InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build() - assertThat(insertProjectLogsEvent).isNotNull - assertThat(insertProjectLogsEvent.id()).contains("id") - assertThat(insertProjectLogsEvent._isMerge()).contains(true) - assertThat(insertProjectLogsEvent._mergePaths().get()).containsExactly(listOf("string")) - assertThat(insertProjectLogsEvent._objectDelete()).contains(true) - assertThat(insertProjectLogsEvent._parentId()).contains("_parent_id") - assertThat(insertProjectLogsEvent.context()).contains(InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - assertThat(insertProjectLogsEvent.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent.metadata()).contains(InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(insertProjectLogsEvent.metrics()).contains(InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") - assertThat(insertProjectLogsEvent.scores()).contains(InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - assertThat(insertProjectLogsEvent.spanAttributes()).contains(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - assertThat(insertProjectLogsEvent.spanId()).contains("span_id") - assertThat(insertProjectLogsEvent.spanParents().get()).containsExactly("string") - assertThat(insertProjectLogsEvent.tags().get()).containsExactly("string") + val insertProjectLogsEvent = + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + assertThat(insertProjectLogsEvent).isNotNull + assertThat(insertProjectLogsEvent.id()).contains("id") + assertThat(insertProjectLogsEvent._isMerge()).contains(true) + assertThat(insertProjectLogsEvent._mergePaths().get()).containsExactly(listOf("string")) + assertThat(insertProjectLogsEvent._objectDelete()).contains(true) + assertThat(insertProjectLogsEvent._parentId()).contains("_parent_id") + assertThat(insertProjectLogsEvent.context()) + .contains( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + assertThat(insertProjectLogsEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertProjectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent._expected()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent.metadata()) + .contains( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(insertProjectLogsEvent.metrics()) + .contains( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") + assertThat(insertProjectLogsEvent.scores()) + .contains( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(insertProjectLogsEvent.spanAttributes()) + .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.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/MetricSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt index df3be6e7..cc848c7c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt @@ -9,20 +9,21 @@ class MetricSummaryTest { @Test fun createMetricSummary() { - val metricSummary = MetricSummary.builder() - .improvements(0L) - .metric(0.0) - .name("name") - .regressions(0L) - .unit("unit") - .diff(0.0) - .build() - assertThat(metricSummary).isNotNull - assertThat(metricSummary.improvements()).isEqualTo(0L) - assertThat(metricSummary.metric()).isEqualTo(0.0) - assertThat(metricSummary.name()).isEqualTo("name") - assertThat(metricSummary.regressions()).isEqualTo(0L) - assertThat(metricSummary.unit()).isEqualTo("unit") - assertThat(metricSummary.diff()).contains(0.0) + val metricSummary = + MetricSummary.builder() + .improvements(0L) + .metric(0.0) + .name("name") + .regressions(0L) + .unit("unit") + .diff(0.0) + .build() + assertThat(metricSummary).isNotNull + assertThat(metricSummary.improvements()).isEqualTo(0L) + assertThat(metricSummary.metric()).isEqualTo(0.0) + assertThat(metricSummary.name()).isEqualTo("name") + assertThat(metricSummary.regressions()).isEqualTo(0L) + assertThat(metricSummary.unit()).isEqualTo("unit") + assertThat(metricSummary.diff()).contains(0.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt index 43f48d74..33f7f133 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt @@ -9,22 +9,30 @@ class OnlineScoreConfigTest { @Test fun createOnlineScoreConfig() { - val onlineScoreConfig = OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build() - assertThat(onlineScoreConfig).isNotNull - assertThat(onlineScoreConfig.samplingRate()).isEqualTo(0.0) - assertThat(onlineScoreConfig.scorers()).containsExactly(OnlineScoreConfig.Scorer.ofFunction(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build())) - assertThat(onlineScoreConfig.applyToRootSpan()).contains(true) - assertThat(onlineScoreConfig.applyToSpanNames().get()).containsExactly("string") + val onlineScoreConfig = + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + assertThat(onlineScoreConfig).isNotNull + assertThat(onlineScoreConfig.samplingRate()).isEqualTo(0.0) + assertThat(onlineScoreConfig.scorers()) + .containsExactly( + OnlineScoreConfig.Scorer.ofFunction( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + ) + assertThat(onlineScoreConfig.applyToRootSpan()).contains(true) + assertThat(onlineScoreConfig.applyToSpanNames().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt index ca6c898c..b86730ee 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt @@ -9,20 +9,21 @@ class OrganizationDeleteParamsTest { @Test fun create() { - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index 989ed6d7..823cdd9c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -10,37 +10,41 @@ class OrganizationListParamsTest { @Test fun create() { - OrganizationListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = OrganizationListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = OrganizationListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = OrganizationListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt index edc65598..ccb97ded 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -10,71 +10,86 @@ class OrganizationMemberUpdateParamsTest { @Test fun create() { - OrganizationMemberUpdateParams.builder() - .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build()) - .orgId("org_id") - .orgName("org_name") - .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build() + OrganizationMemberUpdateParams.builder() + .inviteUsers( + OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() } @Test fun body() { - val params = OrganizationMemberUpdateParams.builder() - .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build()) - .orgId("org_id") - .orgName("org_name") - .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build() + val params = + OrganizationMemberUpdateParams.builder() + .inviteUsers( + OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.inviteUsers()).contains(OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build()) - assertThat(body.orgId()).contains("org_id") - assertThat(body.orgName()).contains("org_name") - assertThat(body.removeUsers()).contains(OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + assertNotNull(body) + assertThat(body.inviteUsers()) + .contains( + OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build() + ) + assertThat(body.orgId()).contains("org_id") + assertThat(body.orgName()).contains("org_name") + assertThat(body.removeUsers()) + .contains( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun bodyWithoutOptionalFields() { - val params = OrganizationMemberUpdateParams.builder().build() + val params = OrganizationMemberUpdateParams.builder().build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt index 3e1619c0..d7faaa14 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt @@ -9,20 +9,21 @@ class OrganizationRetrieveParamsTest { @Test fun create() { - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt index 84924053..d458dc17 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt @@ -10,22 +10,24 @@ class OrganizationTest { @Test fun createOrganization() { - val organization = Organization.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .apiUrl("api_url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .isUniversalApi(true) - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() - assertThat(organization).isNotNull - assertThat(organization.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(organization.name()).isEqualTo("name") - assertThat(organization.apiUrl()).contains("api_url") - assertThat(organization.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(organization.isUniversalApi()).contains(true) - assertThat(organization.proxyUrl()).contains("proxy_url") - assertThat(organization.realtimeUrl()).contains("realtime_url") + val organization = + Organization.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .apiUrl("api_url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isUniversalApi(true) + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + assertThat(organization).isNotNull + assertThat(organization.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(organization.name()).isEqualTo("name") + assertThat(organization.apiUrl()).contains("api_url") + assertThat(organization.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(organization.isUniversalApi()).contains(true) + assertThat(organization.proxyUrl()).contains("proxy_url") + assertThat(organization.realtimeUrl()).contains("realtime_url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt index 4bd931bb..00ff172f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -10,57 +10,60 @@ class OrganizationUpdateParamsTest { @Test fun create() { - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() } @Test fun body() { - val params = OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() + val params = + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.apiUrl()).contains("api_url") - assertThat(body.isUniversalApi()).contains(true) - assertThat(body.name()).contains("name") - assertThat(body.proxyUrl()).contains("proxy_url") - assertThat(body.realtimeUrl()).contains("realtime_url") + assertNotNull(body) + assertThat(body.apiUrl()).contains("api_url") + assertThat(body.isUniversalApi()).contains(true) + assertThat(body.name()).contains("name") + assertThat(body.proxyUrl()).contains("proxy_url") + assertThat(body.realtimeUrl()).contains("realtime_url") } @Test fun bodyWithoutOptionalFields() { - val params = OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "organizationId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "organizationId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt index 0819b00a..dabc2d8c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt @@ -9,14 +9,16 @@ class PatchOrganizationMembersOutputTest { @Test fun createPatchOrganizationMembersOutput() { - val patchOrganizationMembersOutput = PatchOrganizationMembersOutput.builder() - .orgId("org_id") - .status(PatchOrganizationMembersOutput.Status.SUCCESS) - .sendEmailError("send_email_error") - .build() - assertThat(patchOrganizationMembersOutput).isNotNull - assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") - assertThat(patchOrganizationMembersOutput.status()).isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) - assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") + val patchOrganizationMembersOutput = + PatchOrganizationMembersOutput.builder() + .orgId("org_id") + .status(PatchOrganizationMembersOutput.Status.SUCCESS) + .sendEmailError("send_email_error") + .build() + assertThat(patchOrganizationMembersOutput).isNotNull + assertThat(patchOrganizationMembersOutput.orgId()).isEqualTo("org_id") + assertThat(patchOrganizationMembersOutput.status()) + .isEqualTo(PatchOrganizationMembersOutput.Status.SUCCESS) + assertThat(patchOrganizationMembersOutput.sendEmailError()).contains("send_email_error") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index 6636e8d0..32b8bed3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -10,35 +10,27 @@ class ProjectCreateParamsTest { @Test fun create() { - ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build() + ProjectCreateParams.builder().name("x").orgName("org_name").build() } @Test fun body() { - val params = ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build() + val params = ProjectCreateParams.builder().name("x").orgName("org_name").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.orgName()).contains("org_name") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectCreateParams.builder() - .name("x") - .build() + val params = ProjectCreateParams.builder().name("x").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt index de270023..b55b368f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt @@ -9,20 +9,17 @@ class ProjectDeleteParamsTest { @Test fun create() { - ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectDeleteParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 8c574a5d..2f0484be 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -10,40 +10,44 @@ class ProjectListParamsTest { @Test fun create() { - ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_name", "project_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index f32e301e..d7a429e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -11,90 +11,109 @@ class ProjectLogFeedbackParamsTest { @Test fun create() { - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build()) - .build() + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + ) + .build() } @Test fun body() { - val params = ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build()) - .build() + val params = + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()).isEqualTo(listOf(FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build())) + assertNotNull(body) + assertThat(body.feedback()) + .isEqualTo( + listOf( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + ) + ) } @Test fun bodyWithoutOptionalFields() { - val params = ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder() - .id("id") - .build()) - .build() + val params = + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.feedback()).isEqualTo(listOf(FeedbackProjectLogsItem.builder() - .id("id") - .build())) + assertNotNull(body) + assertThat(body.feedback()) + .isEqualTo(listOf(FeedbackProjectLogsItem.builder().id("id").build())) } @Test fun getPathParam() { - val params = ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder() - .id("id") - .build()) - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback(FeedbackProjectLogsItem.builder().id("id").build()) + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index 9909aba6..6e341ea3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -10,50 +10,53 @@ class ProjectLogFetchParamsTest { @Test fun create() { - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun queryParams() { - val params = ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("limit", "0") + expected.put("max_root_span_id", "max_root_span_id") + expected.put("max_xact_id", "max_xact_id") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index e924c459..9d2530b0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -10,57 +10,60 @@ class ProjectLogFetchPostParamsTest { @Test fun create() { - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun body() { - val params = ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + val params = + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.cursor()).contains("cursor") - assertThat(body.limit()).contains(0L) - assertThat(body.maxRootSpanId()).contains("max_root_span_id") - assertThat(body.maxXactId()).contains("max_xact_id") - assertThat(body.version()).contains("version") + assertNotNull(body) + assertThat(body.cursor()).contains("cursor") + assertThat(body.limit()).contains(0L) + assertThat(body.maxRootSpanId()).contains("max_root_span_id") + assertThat(body.maxXactId()).contains("max_xact_id") + assertThat(body.version()).contains("version") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 1e5223c4..24369344 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 @@ -12,168 +12,207 @@ class ProjectLogInsertParamsTest { @Test fun create() { - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build() + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() } @Test fun body() { - val params = ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build() + val params = + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build())) + assertNotNull(body) + assertThat(body.events()) + .isEqualTo( + listOf( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + ) } @Test fun bodyWithoutOptionalFields() { - val params = ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder().build()) - .build() + val params = + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder().build()) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) + assertNotNull(body) + assertThat(body.events()).isEqualTo(listOf(InsertProjectLogsEvent.builder().build())) } @Test fun getPathParam() { - val params = ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder().build()) - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent(InsertProjectLogsEvent.builder().build()) + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 dd167ade..d49aac8a 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 @@ -11,100 +11,124 @@ class ProjectLogsEventTest { @Test fun createProjectLogsEvent() { - val projectLogsEvent = ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context(ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .isRoot(true) - .metadata(ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .origin(ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build()) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .addSpanParent("string") - .addTag("string") - .build() - assertThat(projectLogsEvent).isNotNull - assertThat(projectLogsEvent.id()).isEqualTo("id") - assertThat(projectLogsEvent._xactId()).isEqualTo("_xact_id") - assertThat(projectLogsEvent.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectLogsEvent.logId()).isEqualTo(ProjectLogsEvent.LogId.G) - assertThat(projectLogsEvent.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectLogsEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectLogsEvent.rootSpanId()).isEqualTo("root_span_id") - assertThat(projectLogsEvent.spanId()).isEqualTo("span_id") - assertThat(projectLogsEvent.context()).contains(ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent.isRoot()).contains(true) - assertThat(projectLogsEvent.metadata()).contains(ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(projectLogsEvent.metrics()).contains(ProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - assertThat(projectLogsEvent.origin()).contains(ProjectLogsEvent.Origin.builder() - .id("id") - ._xactId("_xact_id") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) - .build()) - assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent.scores()).contains(ProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - assertThat(projectLogsEvent.spanAttributes()).contains(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - assertThat(projectLogsEvent.spanParents().get()).containsExactly("string") - assertThat(projectLogsEvent.tags().get()).containsExactly("string") + val projectLogsEvent = + ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .isRoot(true) + .metadata( + ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .origin( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + .output(JsonValue.from(mapOf())) + .scores( + ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + ) + .addSpanParent("string") + .addTag("string") + .build() + assertThat(projectLogsEvent).isNotNull + assertThat(projectLogsEvent.id()).isEqualTo("id") + assertThat(projectLogsEvent._xactId()).isEqualTo("_xact_id") + assertThat(projectLogsEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectLogsEvent.logId()).isEqualTo(ProjectLogsEvent.LogId.G) + assertThat(projectLogsEvent.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectLogsEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectLogsEvent.rootSpanId()).isEqualTo("root_span_id") + assertThat(projectLogsEvent.spanId()).isEqualTo("span_id") + assertThat(projectLogsEvent.context()) + .contains( + ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.isRoot()).contains(true) + assertThat(projectLogsEvent.metadata()) + .contains( + ProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(projectLogsEvent.metrics()) + .contains( + ProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + assertThat(projectLogsEvent.origin()) + .contains( + ProjectLogsEvent.Origin.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .build() + ) + assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.scores()) + .contains( + ProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(projectLogsEvent.spanAttributes()) + .contains(SpanAttributes.builder().name("name").type(SpanAttributes.Type.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/ProjectRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt index 7e1485f4..071ceffa 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt @@ -9,20 +9,19 @@ class ProjectRetrieveParamsTest { @Test fun create() { - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectRetrieveParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt index 1ad3a943..95a3b093 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt @@ -9,12 +9,9 @@ class ProjectScoreCategoryTest { @Test fun createProjectScoreCategory() { - val projectScoreCategory = ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build() - assertThat(projectScoreCategory).isNotNull - assertThat(projectScoreCategory.name()).isEqualTo("name") - assertThat(projectScoreCategory.value()).isEqualTo(0.0) + val projectScoreCategory = ProjectScoreCategory.builder().name("name").value(0.0).build() + assertThat(projectScoreCategory).isNotNull + assertThat(projectScoreCategory.name()).isEqualTo("name") + assertThat(projectScoreCategory.value()).isEqualTo(0.0) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt index f91c8470..ebd3f975 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt @@ -9,30 +9,41 @@ class ProjectScoreConfigTest { @Test fun createProjectScoreConfig() { - val projectScoreConfig = ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build() - assertThat(projectScoreConfig).isNotNull - assertThat(projectScoreConfig.destination()).contains(ProjectScoreConfig.Destination.EXPECTED) - assertThat(projectScoreConfig.multiSelect()).contains(true) - assertThat(projectScoreConfig.online()).contains(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) + val projectScoreConfig = + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + assertThat(projectScoreConfig).isNotNull + assertThat(projectScoreConfig.destination()) + .contains(ProjectScoreConfig.Destination.EXPECTED) + assertThat(projectScoreConfig.multiSelect()).contains(true) + assertThat(projectScoreConfig.online()) + .contains( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) } } 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 01e59ccc..f2eb7ba1 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 @@ -10,96 +10,117 @@ class ProjectScoreCreateParamsTest { @Test fun create() { - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .build() + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() } @Test fun body() { - val params = ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .build() + val params = + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() - val body = params._body() + val body = params._body() - 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.categories()).contains(ProjectScoreCreateParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build()))) - assertThat(body.config()).contains(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - assertThat(body.description()).contains("description") + 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.categories()) + .contains( + ProjectScoreCreateParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + ) + assertThat(body.config()) + .contains( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .build() + val params = + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt index 948fc987..f341257a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt @@ -9,20 +9,21 @@ class ProjectScoreDeleteParamsTest { @Test fun create() { - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 8aa8a527..6084f831 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 @@ -10,49 +10,59 @@ class ProjectScoreListParamsTest { @Test fun create() { - ProjectScoreListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectScoreName("project_score_name") + .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = ProjectScoreListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectScoreName("project_score_name") - .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("project_score_name", "project_score_name") - expected.put("score_type", ProjectScoreListParams.ScoreType.ofProject(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString()).toString()) - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectScoreName("project_score_name") + .scoreType(ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("project_score_name", "project_score_name") + expected.put( + "score_type", + ProjectScoreListParams.ScoreType.ofProject( + ProjectScoreListParams.ScoreType.ProjectScoreType.SLIDER.toString() + ) + .toString(), + ) + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectScoreListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectScoreListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } 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 5fc517ab..022d016b 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 @@ -10,96 +10,117 @@ class ProjectScoreReplaceParamsTest { @Test fun create() { - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .build() + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() } @Test fun body() { - val params = ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .build() + val params = + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() - val body = params._body() + val body = params._body() - 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.categories()).contains(ProjectScoreReplaceParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build()))) - assertThat(body.config()).contains(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - assertThat(body.description()).contains("description") + 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.categories()) + .contains( + ProjectScoreReplaceParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + ) + assertThat(body.config()) + .contains( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .build() + val params = + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt index 2e00d311..d5ba83a1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt @@ -9,20 +9,21 @@ class ProjectScoreRetrieveParamsTest { @Test fun create() { - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 74af95f8..888ef861 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 @@ -10,58 +10,74 @@ class ProjectScoreTest { @Test fun createProjectScore() { - val projectScore = ProjectScore.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScore.ScoreType.SLIDER) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .position("position") - .build() - assertThat(projectScore).isNotNull - 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.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectScore.categories()).contains(ProjectScore.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build()))) - assertThat(projectScore.config()).contains(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - assertThat(projectScore.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectScore.description()).contains("description") - assertThat(projectScore.position()).contains("position") + val projectScore = + ProjectScore.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScore.ScoreType.SLIDER) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .position("position") + .build() + assertThat(projectScore).isNotNull + 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.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectScore.categories()) + .contains( + ProjectScore.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + ) + assertThat(projectScore.config()) + .contains( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + assertThat(projectScore.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectScore.description()).contains("description") + assertThat(projectScore.position()).contains("position") } } 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 411468cf..7f153a84 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 @@ -10,102 +10,124 @@ class ProjectScoreUpdateParamsTest { @Test fun create() { - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() } @Test fun body() { - val params = ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() + val params = + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.categories()).contains(ProjectScoreUpdateParams.Categories.ofCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build()))) - assertThat(body.config()).contains(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") - assertThat(body.scoreType()).contains(ProjectScoreUpdateParams.ScoreType.SLIDER) + assertNotNull(body) + assertThat(body.categories()) + .contains( + ProjectScoreUpdateParams.Categories.ofCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + ) + assertThat(body.config()) + .contains( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.scoreType()).contains(ProjectScoreUpdateParams.ScoreType.SLIDER) } @Test fun bodyWithoutOptionalFields() { - val params = ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectScoreId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectScoreId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt index 78b8b0dc..0624066d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt @@ -9,10 +9,8 @@ class ProjectSettingsTest { @Test fun createProjectSettings() { - val projectSettings = ProjectSettings.builder() - .comparisonKey("comparison_key") - .build() - assertThat(projectSettings).isNotNull - assertThat(projectSettings.comparisonKey()).contains("comparison_key") + val projectSettings = ProjectSettings.builder().comparisonKey("comparison_key").build() + assertThat(projectSettings).isNotNull + assertThat(projectSettings.comparisonKey()).contains("comparison_key") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt index f9195ece..04649ccf 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -10,43 +10,45 @@ class ProjectTagCreateParamsTest { @Test fun create() { - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() } @Test fun body() { - val params = ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") + val params = + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt index 6149efa2..30ff07c4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt @@ -9,20 +9,21 @@ class ProjectTagDeleteParamsTest { @Test fun create() { - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index 99c6c2e3..b0008157 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -10,46 +10,50 @@ class ProjectTagListParamsTest { @Test fun create() { - ProjectTagListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectTagName("project_tag_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectTagName("project_tag_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = ProjectTagListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectTagName("project_tag_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("project_tag_name", "project_tag_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectTagName("project_tag_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("project_tag_name", "project_tag_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ProjectTagListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = ProjectTagListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt index 53ca1e92..9e25d87a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -10,43 +10,45 @@ class ProjectTagReplaceParamsTest { @Test fun create() { - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() } @Test fun body() { - val params = ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") + val params = + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt index 041d9af1..a1d9d5ee 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt @@ -9,20 +9,21 @@ class ProjectTagRetrieveParamsTest { @Test fun create() { - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt index d8cdefb8..d9a83759 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt @@ -10,22 +10,23 @@ class ProjectTagTest { @Test fun createProjectTag() { - val projectTag = ProjectTag.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .build() - assertThat(projectTag).isNotNull - assertThat(projectTag.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.name()).isEqualTo("name") - assertThat(projectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(projectTag.color()).contains("color") - assertThat(projectTag.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectTag.description()).contains("description") + val projectTag = + ProjectTag.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .build() + assertThat(projectTag).isNotNull + assertThat(projectTag.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.name()).isEqualTo("name") + assertThat(projectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(projectTag.color()).contains("color") + assertThat(projectTag.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectTag.description()).contains("description") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt index 24144f60..343aa380 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -10,51 +10,54 @@ class ProjectTagUpdateParamsTest { @Test fun create() { - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() } @Test fun body() { - val params = ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.color()).contains("color") - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") + val params = + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.color()).contains("color") + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") } @Test fun bodyWithoutOptionalFields() { - val params = ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectTagId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "projectTagId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt index 0efd6798..390af485 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt @@ -10,26 +10,24 @@ class ProjectTest { @Test fun createProject() { - val project = Project.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(ProjectSettings.builder() - .comparisonKey("comparison_key") - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(project).isNotNull - assertThat(project.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(project.name()).isEqualTo("name") - assertThat(project.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(project.settings()).contains(ProjectSettings.builder() - .comparisonKey("comparison_key") - .build()) - assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val project = + Project.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(project).isNotNull + assertThat(project.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(project.name()).isEqualTo("name") + assertThat(project.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.settings()) + .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) + assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 36d8c5bb..63716ab9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -10,54 +10,48 @@ class ProjectUpdateParamsTest { @Test fun create() { - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder() - .comparisonKey("comparison_key") - .build()) - .build() + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .build() } @Test fun body() { - val params = ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder() - .comparisonKey("comparison_key") - .build()) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).contains("name") - assertThat(body.settings()).contains(ProjectSettings.builder() - .comparisonKey("comparison_key") - .build()) + val params = + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).contains("name") + assertThat(body.settings()) + .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) } @Test fun bodyWithoutOptionalFields() { - val params = ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 81985d29..92e03d0c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -11,174 +11,279 @@ class PromptCreateParamsTest { @Test fun create() { - PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() } @Test fun body() { - val params = PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + val params = + PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionType()).contains(PromptCreateParams.FunctionType.LLM) - assertThat(body.promptData()).contains(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionType()).contains(PromptCreateParams.FunctionType.LLM) + assertThat(body.promptData()) + .contains( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = + PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index 6d419229..f2acf4d6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -10,86 +10,151 @@ class PromptDataTest { @Test fun createPromptData() { - val promptData = PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build() - assertThat(promptData).isNotNull - assertThat(promptData.options()).contains(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - assertThat(promptData.origin()).contains(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - assertThat(promptData.parser()).contains(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - assertThat(promptData.prompt()).contains(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build())) - assertThat(promptData.toolFunctions().get()).containsExactly(PromptData.ToolFunction.ofFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build())) + val promptData = + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + assertThat(promptData).isNotNull + assertThat(promptData.options()) + .contains( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + assertThat(promptData.origin()) + .contains( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + assertThat(promptData.parser()) + .contains( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + assertThat(promptData.prompt()) + .contains( + PromptData.Prompt.ofCompletion( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + ) + assertThat(promptData.toolFunctions().get()) + .containsExactly( + PromptData.ToolFunction.ofFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt index 729e3959..ac1b91bb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt @@ -9,20 +9,17 @@ class PromptDeleteParamsTest { @Test fun create() { - PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + PromptDeleteParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index 9ff476ea..913ef416 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -10,52 +10,56 @@ class PromptListParamsTest { @Test fun create() { - PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .promptName("prompt_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() + PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .promptName("prompt_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() } @Test fun queryParams() { - val params = PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .promptName("prompt_name") - .slug("slug") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .version("version") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("prompt_name", "prompt_name") - expected.put("slug", "slug") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .promptName("prompt_name") + .slug("slug") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .version("version") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("project_name", "project_name") + expected.put("prompt_name", "prompt_name") + expected.put("slug", "slug") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("version", "version") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = PromptListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = PromptListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt index e2f8f9bc..119a47b3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -9,42 +9,72 @@ class PromptOptionsTest { @Test fun createPromptOptions() { - val promptOptions = PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build() - assertThat(promptOptions).isNotNull - assertThat(promptOptions.model()).contains("model") - assertThat(promptOptions.params()).contains(PromptOptions.Params.ofOpenAIModel(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build())) - assertThat(promptOptions.position()).contains("position") + val promptOptions = + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + assertThat(promptOptions).isNotNull + assertThat(promptOptions.model()).contains("model") + assertThat(promptOptions.params()) + .contains( + PromptOptions.Params.ofOpenAIModel( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + ) + assertThat(promptOptions.position()).contains("position") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 22a37bc6..18d87eb2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -11,174 +11,279 @@ class PromptReplaceParamsTest { @Test fun create() { - PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() } @Test fun body() { - val params = PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() + val params = + PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.functionType()).contains(PromptReplaceParams.FunctionType.LLM) - assertThat(body.promptData()).contains(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.functionType()).contains(PromptReplaceParams.FunctionType.LLM) + assertThat(body.promptData()) + .contains( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .build() + val params = + PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt index 322439c4..622fb8c9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt @@ -9,20 +9,17 @@ class PromptRetrieveParamsTest { @Test fun create() { - PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + PromptRetrieveParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index 692fcfe0..c65cd2c6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -11,118 +11,193 @@ class PromptTest { @Test fun createPrompt() { - val prompt = Prompt.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("_xact_id") - .logId(Prompt.LogId.P) - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .functionType(Prompt.FunctionType.LLM) - .metadata(Prompt.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build() - assertThat(prompt).isNotNull - assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt._xactId()).isEqualTo("_xact_id") - assertThat(prompt.logId()).isEqualTo(Prompt.LogId.P) - assertThat(prompt.name()).isEqualTo("name") - assertThat(prompt.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(prompt.slug()).isEqualTo("slug") - assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(prompt.description()).contains("description") - assertThat(prompt.functionType()).contains(Prompt.FunctionType.LLM) - assertThat(prompt.metadata()).contains(Prompt.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - assertThat(prompt.promptData()).contains(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - assertThat(prompt.tags().get()).containsExactly("string") + val prompt = + Prompt.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._xactId("_xact_id") + .logId(Prompt.LogId.P) + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .functionType(Prompt.FunctionType.LLM) + .metadata( + Prompt.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + assertThat(prompt).isNotNull + assertThat(prompt.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt._xactId()).isEqualTo("_xact_id") + assertThat(prompt.logId()).isEqualTo(Prompt.LogId.P) + assertThat(prompt.name()).isEqualTo("name") + assertThat(prompt.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(prompt.slug()).isEqualTo("slug") + assertThat(prompt.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(prompt.description()).contains("description") + assertThat(prompt.functionType()).contains(Prompt.FunctionType.LLM) + assertThat(prompt.metadata()) + .contains( + Prompt.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(prompt.promptData()) + .contains( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + assertThat(prompt.tags().get()).containsExactly("string") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 1212ba35..7dae6fe3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -11,177 +11,279 @@ class PromptUpdateParamsTest { @Test fun create() { - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .slug("slug") - .addTag("string") - .build() + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .slug("slug") + .addTag("string") + .build() } @Test fun body() { - val params = PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .slug("slug") - .addTag("string") - .build() + val params = + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .slug("slug") + .addTag("string") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("name") - assertThat(body.promptData()).contains(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - assertThat(body.slug()).contains("slug") - assertThat(body.tags()).contains(listOf("string")) + assertNotNull(body) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("name") + assertThat(body.promptData()) + .contains( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams.ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + assertThat(body.slug()).contains("slug") + assertThat(body.tags()).contains(listOf("string")) } @Test fun bodyWithoutOptionalFields() { - val params = PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "promptId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "promptId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt index a5d12e34..83eec5e0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt @@ -9,26 +9,27 @@ class RepoInfoTest { @Test fun createRepoInfo() { - val repoInfo = RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - assertThat(repoInfo).isNotNull - assertThat(repoInfo.authorEmail()).contains("author_email") - assertThat(repoInfo.authorName()).contains("author_name") - assertThat(repoInfo.branch()).contains("branch") - assertThat(repoInfo.commit()).contains("commit") - assertThat(repoInfo.commitMessage()).contains("commit_message") - assertThat(repoInfo.commitTime()).contains("commit_time") - assertThat(repoInfo.dirty()).contains(true) - assertThat(repoInfo.gitDiff()).contains("git_diff") - assertThat(repoInfo.tag()).contains("tag") + val repoInfo = + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + assertThat(repoInfo).isNotNull + assertThat(repoInfo.authorEmail()).contains("author_email") + assertThat(repoInfo.authorName()).contains("author_name") + assertThat(repoInfo.branch()).contains("branch") + assertThat(repoInfo.commit()).contains("commit") + assertThat(repoInfo.commitMessage()).contains("commit_message") + assertThat(repoInfo.commitTime()).contains("commit_time") + assertThat(repoInfo.dirty()).contains(true) + assertThat(repoInfo.gitDiff()).contains("git_diff") + assertThat(repoInfo.tag()).contains("tag") } } 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 bfd19a81..2a910fde 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 @@ -10,53 +10,67 @@ class RoleCreateParamsTest { @Test fun create() { - RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission(RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission(RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberPermissions()).contains(listOf(RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = + RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberPermissions()) + .contains( + listOf( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = RoleCreateParams.builder() - .name("x") - .build() + val params = RoleCreateParams.builder().name("x").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt index 55d96c38..3d7f97a5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt @@ -9,20 +9,17 @@ class RoleDeleteParamsTest { @Test fun create() { - RoleDeleteParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = RoleDeleteParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 82eb0ae2..9a390aec 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -10,40 +10,44 @@ class RoleListParamsTest { @Test fun create() { - RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("role_name", "role_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("role_name", "role_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = RoleListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = RoleListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.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 d544cfc4..46264e88 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 @@ -10,53 +10,67 @@ class RoleReplaceParamsTest { @Test fun create() { - RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission(RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() + RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() } @Test fun body() { - val params = RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission(RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") - assertThat(body.description()).contains("description") - assertThat(body.memberPermissions()).contains(listOf(RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).contains("org_name") + val params = + RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") + assertThat(body.description()).contains("description") + assertThat(body.memberPermissions()) + .contains( + listOf( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + assertThat(body.memberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).contains("org_name") } @Test fun bodyWithoutOptionalFields() { - val params = RoleReplaceParams.builder() - .name("x") - .build() + val params = RoleReplaceParams.builder().name("x").build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.name()).isEqualTo("x") + assertNotNull(body) + assertThat(body.name()).isEqualTo("x") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt index 10474e3d..696fe39a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt @@ -9,20 +9,17 @@ class RoleRetrieveParamsTest { @Test fun create() { - RoleRetrieveParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = RoleRetrieveParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 5a7786a9..6187d100 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 @@ -10,32 +10,38 @@ class RoleTest { @Test fun createRole() { - val role = Role.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .addMemberPermission(Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(role).isNotNull - assertThat(role.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.name()).isEqualTo("name") - assertThat(role.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.description()).contains("description") - assertThat(role.memberPermissions().get()).containsExactly(Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - assertThat(role.memberRoles().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val role = + Role.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .addMemberPermission( + Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(role).isNotNull + assertThat(role.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.name()).isEqualTo("name") + assertThat(role.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(role.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(role.description()).contains("description") + assertThat(role.memberPermissions().get()) + .containsExactly( + Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build() + ) + assertThat(role.memberRoles().get()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.orgId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.userId()).contains("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 d20c05b3..ee226d14 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 @@ -10,78 +10,108 @@ class RoleUpdateParamsTest { @Test fun create() { - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun body() { - val params = RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.addMemberPermissions()).contains(listOf(RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - assertThat(body.addMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).contains("description") - assertThat(body.name()).contains("x") - assertThat(body.removeMemberPermissions()).contains(listOf(RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) - .build())) - assertThat(body.removeMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertNotNull(body) + assertThat(body.addMemberPermissions()) + .contains( + listOf( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + assertThat(body.addMemberRoles()).contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).contains("description") + assertThat(body.name()).contains("x") + assertThat(body.removeMemberPermissions()) + .contains( + listOf( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + ) + assertThat(body.removeMemberRoles()) + .contains(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun bodyWithoutOptionalFields() { - val params = RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "roleId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "roleId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt index 08e71773..35c169e5 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt @@ -9,18 +9,19 @@ class ScoreSummaryTest { @Test fun createScoreSummary() { - val scoreSummary = ScoreSummary.builder() - .improvements(0L) - .name("name") - .regressions(0L) - .score(0.0) - .diff(-1.0) - .build() - assertThat(scoreSummary).isNotNull - assertThat(scoreSummary.improvements()).isEqualTo(0L) - assertThat(scoreSummary.name()).isEqualTo("name") - assertThat(scoreSummary.regressions()).isEqualTo(0L) - assertThat(scoreSummary.score()).isEqualTo(0.0) - assertThat(scoreSummary.diff()).contains(-1.0) + val scoreSummary = + ScoreSummary.builder() + .improvements(0L) + .name("name") + .regressions(0L) + .score(0.0) + .diff(-1.0) + .build() + assertThat(scoreSummary).isNotNull + assertThat(scoreSummary.improvements()).isEqualTo(0L) + assertThat(scoreSummary.name()).isEqualTo("name") + assertThat(scoreSummary.regressions()).isEqualTo(0L) + assertThat(scoreSummary.score()).isEqualTo(0.0) + assertThat(scoreSummary.diff()).contains(-1.0) } } 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 83cd4c86..562a0b8a 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,12 +9,10 @@ class SpanAttributesTest { @Test fun createSpanAttributes() { - val spanAttributes = SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build() - assertThat(spanAttributes).isNotNull - assertThat(spanAttributes.name()).contains("name") - assertThat(spanAttributes.type()).contains(SpanAttributes.Type.LLM) + val spanAttributes = + SpanAttributes.builder().name("name").type(SpanAttributes.Type.LLM).build() + assertThat(spanAttributes).isNotNull + assertThat(spanAttributes.name()).contains("name") + assertThat(spanAttributes.type()).contains(SpanAttributes.Type.LLM) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt index e84b0503..a972b937 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt @@ -10,26 +10,28 @@ class SpanIFrameTest { @Test fun createSpanIFrame() { - val spanIFrame = SpanIFrame.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .postMessage(true) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(spanIFrame).isNotNull - assertThat(spanIFrame.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(spanIFrame.name()).isEqualTo("name") - assertThat(spanIFrame.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(spanIFrame.url()).isEqualTo("url") - assertThat(spanIFrame.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(spanIFrame.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(spanIFrame.description()).contains("description") - assertThat(spanIFrame.postMessage()).contains(true) - assertThat(spanIFrame.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val spanIFrame = + SpanIFrame.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("description") + .postMessage(true) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(spanIFrame).isNotNull + assertThat(spanIFrame.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(spanIFrame.name()).isEqualTo("name") + assertThat(spanIFrame.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(spanIFrame.url()).isEqualTo("url") + assertThat(spanIFrame.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(spanIFrame.deletedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(spanIFrame.description()).contains("description") + assertThat(spanIFrame.postMessage()).contains(true) + assertThat(spanIFrame.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt index 6f3e3abe..baf7a58f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt @@ -10,48 +10,50 @@ class SpanIframeCreateParamsTest { @Test fun create() { - SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() } @Test fun body() { - val params = SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") - assertThat(body.description()).contains("description") - assertThat(body.postMessage()).contains(true) + val params = + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + assertThat(body.description()).contains("description") + assertThat(body.postMessage()).contains(true) } @Test fun bodyWithoutOptionalFields() { - val params = SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") + val params = + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt index dd3daa38..a1a4a437 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt @@ -9,20 +9,21 @@ class SpanIframeDeleteParamsTest { @Test fun create() { - SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt index 7d25f092..50d720b8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt @@ -10,40 +10,44 @@ class SpanIframeListParamsTest { @Test fun create() { - SpanIframeListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .spanIframeName("span_iframe_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .spanIframeName("span_iframe_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = SpanIframeListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .spanIframeName("span_iframe_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("span_iframe_name", "span_iframe_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + SpanIframeListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .spanIframeName("span_iframe_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("span_iframe_name", "span_iframe_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = SpanIframeListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = SpanIframeListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt index 10f992e8..305c97ad 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt @@ -10,48 +10,50 @@ class SpanIframeReplaceParamsTest { @Test fun create() { - SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() } @Test fun body() { - val params = SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") - assertThat(body.description()).contains("description") - assertThat(body.postMessage()).contains(true) + val params = + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") + assertThat(body.description()).contains("description") + assertThat(body.postMessage()).contains(true) } @Test fun bodyWithoutOptionalFields() { - val params = SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.url()).isEqualTo("url") + val params = + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.url()).isEqualTo("url") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt index 153e172c..ad6927a4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt @@ -9,20 +9,21 @@ class SpanIframeRetrieveParamsTest { @Test fun create() { - SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index 575579e0..57fce4c2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -10,51 +10,54 @@ class SpanIframeUpdateParamsTest { @Test fun create() { - SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() } @Test fun body() { - val params = SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.name()).contains("name") - assertThat(body.postMessage()).contains(true) - assertThat(body.url()).contains("url") + val params = + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.name()).contains("name") + assertThat(body.postMessage()).contains(true) + assertThat(body.url()).contains("url") } @Test fun bodyWithoutOptionalFields() { - val params = SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val params = + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) + assertNotNull(body) } @Test fun getPathParam() { - val params = SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "spanIframeId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "spanIframeId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt index 8a1b1547..a9675505 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt @@ -9,22 +9,20 @@ class SummarizeDatasetResponseTest { @Test fun createSummarizeDatasetResponse() { - val summarizeDatasetResponse = SummarizeDatasetResponse.builder() - .datasetName("dataset_name") - .datasetUrl("https://example.com") - .projectName("project_name") - .projectUrl("https://example.com") - .dataSummary(DataSummary.builder() - .totalRecords(0L) - .build()) - .build() - assertThat(summarizeDatasetResponse).isNotNull - assertThat(summarizeDatasetResponse.datasetName()).isEqualTo("dataset_name") - assertThat(summarizeDatasetResponse.datasetUrl()).isEqualTo("https://example.com") - assertThat(summarizeDatasetResponse.projectName()).isEqualTo("project_name") - assertThat(summarizeDatasetResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(summarizeDatasetResponse.dataSummary()).contains(DataSummary.builder() - .totalRecords(0L) - .build()) + val summarizeDatasetResponse = + SummarizeDatasetResponse.builder() + .datasetName("dataset_name") + .datasetUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .dataSummary(DataSummary.builder().totalRecords(0L).build()) + .build() + assertThat(summarizeDatasetResponse).isNotNull + assertThat(summarizeDatasetResponse.datasetName()).isEqualTo("dataset_name") + assertThat(summarizeDatasetResponse.datasetUrl()).isEqualTo("https://example.com") + assertThat(summarizeDatasetResponse.projectName()).isEqualTo("project_name") + assertThat(summarizeDatasetResponse.projectUrl()).isEqualTo("https://example.com") + assertThat(summarizeDatasetResponse.dataSummary()) + .contains(DataSummary.builder().totalRecords(0L).build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt index 60d9d9a2..35580e00 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt @@ -10,56 +10,88 @@ class SummarizeExperimentResponseTest { @Test fun createSummarizeExperimentResponse() { - val summarizeExperimentResponse = SummarizeExperimentResponse.builder() - .experimentName("experiment_name") - .experimentUrl("https://example.com") - .projectName("project_name") - .projectUrl("https://example.com") - .comparisonExperimentName("comparison_experiment_name") - .metrics(SummarizeExperimentResponse.Metrics.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf( - "improvements" to 0, - "metric" to 0, - "name" to "name", - "regressions" to 0, - "unit" to "unit", - "diff" to 0, - ))) - .build()) - .scores(SummarizeExperimentResponse.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf( - "improvements" to 0, - "name" to "name", - "regressions" to 0, - "score" to 0, - "diff" to -1, - ))) - .build()) - .build() - assertThat(summarizeExperimentResponse).isNotNull - assertThat(summarizeExperimentResponse.experimentName()).isEqualTo("experiment_name") - assertThat(summarizeExperimentResponse.experimentUrl()).isEqualTo("https://example.com") - assertThat(summarizeExperimentResponse.projectName()).isEqualTo("project_name") - assertThat(summarizeExperimentResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(summarizeExperimentResponse.comparisonExperimentName()).contains("comparison_experiment_name") - assertThat(summarizeExperimentResponse.metrics()).contains(SummarizeExperimentResponse.Metrics.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf( - "improvements" to 0, - "metric" to 0, - "name" to "name", - "regressions" to 0, - "unit" to "unit", - "diff" to 0, - ))) - .build()) - assertThat(summarizeExperimentResponse.scores()).contains(SummarizeExperimentResponse.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(mapOf( - "improvements" to 0, - "name" to "name", - "regressions" to 0, - "score" to 0, - "diff" to -1, - ))) - .build()) + val summarizeExperimentResponse = + SummarizeExperimentResponse.builder() + .experimentName("experiment_name") + .experimentUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .comparisonExperimentName("comparison_experiment_name") + .metrics( + SummarizeExperimentResponse.Metrics.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improvements" to 0, + "metric" to 0, + "name" to "name", + "regressions" to 0, + "unit" to "unit", + "diff" to 0, + ) + ), + ) + .build() + ) + .scores( + SummarizeExperimentResponse.Scores.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improvements" to 0, + "name" to "name", + "regressions" to 0, + "score" to 0, + "diff" to -1, + ) + ), + ) + .build() + ) + .build() + assertThat(summarizeExperimentResponse).isNotNull + assertThat(summarizeExperimentResponse.experimentName()).isEqualTo("experiment_name") + assertThat(summarizeExperimentResponse.experimentUrl()).isEqualTo("https://example.com") + assertThat(summarizeExperimentResponse.projectName()).isEqualTo("project_name") + assertThat(summarizeExperimentResponse.projectUrl()).isEqualTo("https://example.com") + assertThat(summarizeExperimentResponse.comparisonExperimentName()) + .contains("comparison_experiment_name") + assertThat(summarizeExperimentResponse.metrics()) + .contains( + SummarizeExperimentResponse.Metrics.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improvements" to 0, + "metric" to 0, + "name" to "name", + "regressions" to 0, + "unit" to "unit", + "diff" to 0, + ) + ), + ) + .build() + ) + assertThat(summarizeExperimentResponse.scores()) + .contains( + SummarizeExperimentResponse.Scores.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "improvements" to 0, + "name" to "name", + "regressions" to 0, + "score" to 0, + "diff" to -1, + ) + ), + ) + .build() + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt index 7dd57e85..56273dcf 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt @@ -8,6 +8,6 @@ class TopLevelHelloWorldParamsTest { @Test fun create() { - TopLevelHelloWorldParams.builder().build() + TopLevelHelloWorldParams.builder().build() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 3ad7d36d..02f28453 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -10,46 +10,50 @@ class UserListParamsTest { @Test fun create() { - UserListParams.builder() - .email("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName("string") - .givenName("string") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + UserListParams.builder() + .email("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName("string") + .givenName("string") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun queryParams() { - val params = UserListParams.builder() - .email("string") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName("string") - .givenName("string") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - expected.put("email", UserListParams.Email.ofString("string").toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("family_name", UserListParams.FamilyName.ofString("string").toString()) - expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) - expected.put("ids", UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + UserListParams.builder() + .email("string") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName("string") + .givenName("string") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = QueryParams.builder() + expected.put("email", UserListParams.Email.ofString("string").toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("family_name", UserListParams.FamilyName.ofString("string").toString()) + expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) + expected.put( + "ids", + UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + expected.put("limit", "0") + expected.put("org_name", "org_name") + expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = UserListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = UserListParams.builder().build() + val expected = QueryParams.builder() + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt index 8d679477..f1686cc4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt @@ -9,20 +9,17 @@ class UserRetrieveParamsTest { @Test fun create() { - UserRetrieveParams.builder() - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() } @Test fun getPathParam() { - val params = UserRetrieveParams.builder() - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "userId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "userId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt index 5de80102..fe6f4802 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt @@ -10,20 +10,21 @@ class UserTest { @Test fun createUser() { - val user = User.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .avatarUrl("avatar_url") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .email("email") - .familyName("family_name") - .givenName("given_name") - .build() - assertThat(user).isNotNull - assertThat(user.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(user.avatarUrl()).contains("avatar_url") - assertThat(user.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(user.email()).contains("email") - assertThat(user.familyName()).contains("family_name") - assertThat(user.givenName()).contains("given_name") + val user = + User.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .avatarUrl("avatar_url") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("email") + .familyName("family_name") + .givenName("given_name") + .build() + assertThat(user).isNotNull + assertThat(user.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(user.avatarUrl()).contains("avatar_url") + assertThat(user.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(user.email()).contains("email") + assertThat(user.familyName()).contains("family_name") + assertThat(user.givenName()).contains("given_name") } } 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 19223c9d..1f09c824 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 @@ -12,104 +12,138 @@ class ViewCreateParamsTest { @Test fun create() { - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build() + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() } @Test fun body() { - val params = ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build() + val params = + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() - val body = params._body() + val body = params._body() - 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.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.options()).contains(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()).contains(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) + 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.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()) + .contains( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()) + .contains( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) } @Test fun bodyWithoutOptionalFields() { - val params = ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .build() + val params = + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - 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.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) + 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.viewType()).contains(ViewCreateParams.ViewType.PROJECTS) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt index 17b06040..7d1baa55 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt @@ -10,16 +10,20 @@ class ViewDataSearchTest { @Test fun createViewDataSearch() { - val viewDataSearch = ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build() - assertThat(viewDataSearch).isNotNull - assertThat(viewDataSearch.filter().get()).containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.match().get()).containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.sort().get()).containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.tag().get()).containsExactly(JsonValue.from(mapOf())) + val viewDataSearch = + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + assertThat(viewDataSearch).isNotNull + assertThat(viewDataSearch.filter().get()) + .containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.match().get()) + .containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.sort().get()) + .containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.tag().get()).containsExactly(JsonValue.from(mapOf())) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt index 86ef2bc6..10157eee 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt @@ -10,20 +10,26 @@ class ViewDataTest { @Test fun createViewData() { - val viewData = ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build() - assertThat(viewData).isNotNull - assertThat(viewData.search()).contains(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) + val viewData = + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + assertThat(viewData).isNotNull + assertThat(viewData.search()) + .contains( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) } } 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 fba424b7..20ab82f1 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 @@ -10,54 +10,57 @@ class ViewDeleteParamsTest { @Test fun create() { - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() } @Test fun body() { - val params = ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @Test fun bodyWithoutOptionalFields() { - val params = ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() + val params = + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @Test fun getPathParam() { - val params = ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 56b75c4d..35c71549 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 @@ -10,51 +10,56 @@ class ViewListParamsTest { @Test fun create() { - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.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) - .build() + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.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) + .build() } @Test fun queryParams() { - val params = ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.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) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("ids", ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - 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()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.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) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put( + "ids", + ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), + ) + 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()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewListParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt index 09ead451..3d6989ba 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt @@ -10,22 +10,33 @@ class ViewOptionsTest { @Test fun createViewOptions() { - val viewOptions = ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build() - assertThat(viewOptions).isNotNull - assertThat(viewOptions.columnOrder().get()).containsExactly("string") - assertThat(viewOptions.columnSizing()).contains(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - assertThat(viewOptions.columnVisibility()).contains(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) + val viewOptions = + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + assertThat(viewOptions).isNotNull + assertThat(viewOptions.columnOrder().get()).containsExactly("string") + assertThat(viewOptions.columnSizing()) + .contains( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(viewOptions.columnVisibility()) + .contains( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .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 cc4d9372..069dcccd 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 @@ -12,104 +12,138 @@ class ViewReplaceParamsTest { @Test fun create() { - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build() + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() } @Test fun body() { - val params = ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build() + val params = + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() - val body = params._body() + val body = params._body() - 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.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.options()).contains(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()).contains(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) + 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.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()) + .contains( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()) + .contains( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) } @Test fun bodyWithoutOptionalFields() { - val params = ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .build() + val params = + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - 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.viewType()).contains(ViewReplaceParams.ViewType.PROJECTS) + 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.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 ed35155f..31fdf385 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 @@ -10,50 +10,53 @@ class ViewRetrieveParamsTest { @Test fun create() { - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() } @Test fun queryParams() { - val params = ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun queryParamsWithoutOptionalFields() { - val params = ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + val params = + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + val expected = QueryParams.builder() + expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + expected.put("object_type", ViewRetrieveParams.ObjectType.ORGANIZATION.toString()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test fun getPathParam() { - val params = ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } 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 4ebef9a9..fd19dbb6 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 @@ -11,58 +11,81 @@ class ViewTest { @Test fun createView() { - val view = View.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(View.ObjectType.ORGANIZATION) - .viewType(View.ViewType.PROJECTS) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build() - assertThat(view).isNotNull - 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.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")) - assertThat(view.options()).contains(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(view.viewData()).contains(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) + val view = + View.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(View.ObjectType.ORGANIZATION) + .viewType(View.ViewType.PROJECTS) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + assertThat(view).isNotNull + 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.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")) + assertThat(view.options()) + .contains( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.viewData()) + .contains( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) } } 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 6208c9bb..67d83174 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 @@ -11,114 +11,149 @@ class ViewUpdateParamsTest { @Test fun create() { - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() } @Test fun body() { - val params = ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() + val params = + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) - assertThat(body.name()).contains("name") - assertThat(body.options()).contains(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()).contains(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - assertThat(body.viewType()).contains(ViewUpdateParams.ViewType.PROJECTS) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertThat(body.name()).contains("name") + assertThat(body.options()) + .contains( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()) + .contains( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + assertThat(body.viewType()).contains(ViewUpdateParams.ViewType.PROJECTS) } @Test fun bodyWithoutOptionalFields() { - val params = ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .build() + val params = + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .build() - val body = params._body() + val body = params._body() - assertNotNull(body) - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertNotNull(body) + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) } @Test fun getPathParam() { - val params = ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .build() - assertThat(params).isNotNull - // path param "viewId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .build() + assertThat(params).isNotNull + // path param "viewId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 76b08329..1d611bfb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -35,9 +35,10 @@ class ErrorHandlingTest { companion object { - private val ERROR: BraintrustError = BraintrustError.builder() - .putAdditionalProperty("errorProperty", JsonValue.from("42")) - .build() + private val ERROR: BraintrustError = + BraintrustError.builder() + .putAdditionalProperty("errorProperty", JsonValue.from("42")) + .build() private val ERROR_JSON: ByteArray = jsonMapper().writeValueAsBytes(ERROR) @@ -52,231 +53,189 @@ class ErrorHandlingTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - client = BraintrustOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.httpBaseUrl) - .apiKey("My API Key") - .build() + client = + BraintrustOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() } @Test fun projectsCreate400() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(400) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(ERROR_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains( - entry(HEADER_NAME, listOf(HEADER_VALUE)) - ) + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate401() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(401) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(ERROR_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains( - entry(HEADER_NAME, listOf(HEADER_VALUE)) - ) + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate403() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(403) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(ERROR_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains( - entry(HEADER_NAME, listOf(HEADER_VALUE)) - ) + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate404() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(404) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(ERROR_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains( - entry(HEADER_NAME, listOf(HEADER_VALUE)) - ) + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate422() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(422) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(ERROR_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains( - entry(HEADER_NAME, listOf(HEADER_VALUE)) - ) + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate429() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(429) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(ERROR_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains( - entry(HEADER_NAME, listOf(HEADER_VALUE)) - ) + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate500() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(500) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(ERROR_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains( - entry(HEADER_NAME, listOf(HEADER_VALUE)) - ) + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreate999() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(999) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(ERROR_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e.statusCode()).isEqualTo(999) - assertThat(e.error()).isEqualTo(ERROR) - assertThat(e.headers().toMap()).contains( - entry(HEADER_NAME, listOf(HEADER_VALUE)) - ) + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun projectsCreateInvalidJsonBody() { - val projectService = client.projects() - stubFor( - post(anyUrl()).willReturn( - status(200) - .withHeader(HEADER_NAME, HEADER_VALUE) - .withBody(NOT_JSON) - ) - ) - - val e = assertThrows { - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - } - - assertThat(e).hasMessage("Error reading response") + val projectService = client.projects() + stubFor( + post(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) + + val e = + assertThrows { + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + } + + assertThat(e).hasMessage("Error reading response") } private fun Headers.toMap(): Map> = diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt index b65e3e95..9e25370e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt @@ -26,30 +26,33 @@ internal class ServiceParamsTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - client = BraintrustOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.httpBaseUrl) - .apiKey("My API Key") - .build() + client = + BraintrustOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() } @Test fun create() { - val projectService = client.projects() - stubFor(post(anyUrl()).willReturn(ok("{}"))) - - projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .putAdditionalHeader("Secret-Header", "42") - .putAdditionalQueryParam("secret_query_param", "42") - .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) - .build()) - - verify( - postRequestedFor(anyUrl()) - .withHeader("Secret-Header", equalTo("42")) - .withQueryParam("secret_query_param", equalTo("42")) - .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) - ) + val projectService = client.projects() + stubFor(post(anyUrl()).willReturn(ok("{}"))) + + projectService.create( + ProjectCreateParams.builder() + .name("x") + .orgName("org_name") + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build() + ) + + verify( + postRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) + ) } } 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 7c23deb9..5df9416c 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 @@ -18,127 +18,155 @@ class AclServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = aclServiceAsync.create(AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val acl = aclFuture.get() - acl.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = + aclServiceAsync.create( + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val acl = aclFuture.get() + acl.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = aclServiceAsync.retrieve(AclRetrieveParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val acl = aclFuture.get() - acl.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = + aclServiceAsync.retrieve( + AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val acl = aclFuture.get() + acl.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val pageFuture = aclServiceAsync.list(AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build()) - - val page = pageFuture.get() - page.response().validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val pageFuture = + aclServiceAsync.list( + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build() + ) + + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = aclServiceAsync.delete(AclDeleteParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val acl = aclFuture.get() - acl.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = + aclServiceAsync.delete( + AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val acl = aclFuture.get() + acl.validate() } @Test fun batchUpdate() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclBatchUpdateResponseFuture = aclServiceAsync.batchUpdate(AclBatchUpdateParams.builder() - .addAddAcl(AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build()) - - val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() - aclBatchUpdateResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclBatchUpdateResponseFuture = + aclServiceAsync.batchUpdate( + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() + aclBatchUpdateResponse.validate() } @Test fun findAndDelete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclFuture = aclServiceAsync.findAndDelete(AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val acl = aclFuture.get() - acl.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclFuture = + aclServiceAsync.findAndDelete( + AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val acl = aclFuture.get() + acl.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt index c7a4be39..cc5d3c0a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams -import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams @@ -20,130 +19,158 @@ class AiSecretServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = aiSecretServiceAsync.create(AiSecretCreateParams.builder() - .name("name") - .metadata(AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build()) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.create( + AiSecretCreateParams.builder() + .name("name") + .metadata( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = aiSecretServiceAsync.retrieve(AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.retrieve( + AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = aiSecretServiceAsync.update(AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .secret("secret") - .type("type") - .build()) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.update( + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .secret("secret") + .type("type") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() - val pageFuture = aiSecretServiceAsync.list() + val pageFuture = aiSecretServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = aiSecretServiceAsync.delete(AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.delete( + AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun findAndDelete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = aiSecretServiceAsync.findAndDelete(AiSecretFindAndDeleteParams.builder() - .name("name") - .orgName("org_name") - .build()) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.findAndDelete( + AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretServiceAsync = client.aiSecrets() - - val aISecretFuture = aiSecretServiceAsync.replace(AiSecretReplaceParams.builder() - .name("name") - .metadata(AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build()) - - val aISecret = aISecretFuture.get() - aISecret.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretServiceAsync = client.aiSecrets() + + val aISecretFuture = + aiSecretServiceAsync.replace( + AiSecretReplaceParams.builder() + .name("name") + .metadata( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + ) + + val aISecret = aISecretFuture.get() + aISecret.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt index ab12b91e..f7d5a9ac 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams -import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -16,64 +15,74 @@ class ApiKeyServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val createApiKeyOutputFuture = apiKeyServiceAsync.create(ApiKeyCreateParams.builder() - .name("name") - .orgName("org_name") - .build()) + val createApiKeyOutputFuture = + apiKeyServiceAsync.create( + ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + ) - val createApiKeyOutput = createApiKeyOutputFuture.get() - createApiKeyOutput.validate() + val createApiKeyOutput = createApiKeyOutputFuture.get() + createApiKeyOutput.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val apiKeyFuture = apiKeyServiceAsync.retrieve(ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val apiKeyFuture = + apiKeyServiceAsync.retrieve( + ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - val apiKey = apiKeyFuture.get() - apiKey.validate() + val apiKey = apiKeyFuture.get() + apiKey.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val pageFuture = apiKeyServiceAsync.list() + val pageFuture = apiKeyServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyServiceAsync = client.apiKeys() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.apiKeys() - val apiKeyFuture = apiKeyServiceAsync.delete(ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val apiKeyFuture = + apiKeyServiceAsync.delete( + ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - val apiKey = apiKeyFuture.get() - apiKey.validate() + val apiKey = apiKeyFuture.get() + apiKey.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt index 6dfc687d..4e6b2e1f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt @@ -11,7 +11,6 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams @@ -26,205 +25,254 @@ class DatasetServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = datasetServiceAsync.create(DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .build()) - - val dataset = datasetFuture.get() - dataset.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = + datasetServiceAsync.create( + DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = datasetServiceAsync.retrieve(DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val dataset = datasetFuture.get() - dataset.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = + datasetServiceAsync.retrieve( + DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = datasetServiceAsync.update(DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .build()) - - val dataset = datasetFuture.get() - dataset.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = + datasetServiceAsync.update( + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() - val pageFuture = datasetServiceAsync.list() + val pageFuture = datasetServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val datasetFuture = datasetServiceAsync.delete(DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val dataset = datasetFuture.get() - dataset.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val datasetFuture = + datasetServiceAsync.delete( + DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val dataset = datasetFuture.get() + dataset.validate() } @Test fun feedback() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val feedbackResponseSchemaFuture = datasetServiceAsync.feedback(DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build()) - .build()) - - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val feedbackResponseSchemaFuture = + datasetServiceAsync.feedback( + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val fetchDatasetEventsResponseFuture = datasetServiceAsync.fetch(DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) - - val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() - fetchDatasetEventsResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val fetchDatasetEventsResponseFuture = + datasetServiceAsync.fetch( + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() + fetchDatasetEventsResponse.validate() } @Test fun fetchPost() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val fetchDatasetEventsResponseFuture = datasetServiceAsync.fetchPost(DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) - - val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() - fetchDatasetEventsResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val fetchDatasetEventsResponseFuture = + datasetServiceAsync.fetchPost( + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchDatasetEventsResponse = fetchDatasetEventsResponseFuture.get() + fetchDatasetEventsResponse.validate() } @Test fun insert() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val insertEventsResponseFuture = datasetServiceAsync.insert(DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build()) - - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val insertEventsResponseFuture = + datasetServiceAsync.insert( + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } @Test fun summarize() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetServiceAsync = client.datasets() - - val summarizeDatasetResponseFuture = datasetServiceAsync.summarize(DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build()) - - val summarizeDatasetResponse = summarizeDatasetResponseFuture.get() - summarizeDatasetResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetServiceAsync = client.datasets() + + val summarizeDatasetResponseFuture = + datasetServiceAsync.summarize( + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() + ) + + val summarizeDatasetResponse = summarizeDatasetResponseFuture.get() + summarizeDatasetResponse.validate() } } 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 1d393bb4..b64fa2df 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 @@ -18,109 +18,133 @@ class EnvVarServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = envVarServiceAsync.create(EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build()) - - val envVar = envVarFuture.get() - envVar.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.create( + EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = envVarServiceAsync.retrieve(EnvVarRetrieveParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val envVar = envVarFuture.get() - envVar.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.retrieve( + EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = envVarServiceAsync.update(EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build()) - - val envVar = envVarFuture.get() - envVar.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.update( + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = envVarServiceAsync.list(EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build()) - - val envVar = envVarFuture.get() - envVar.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.list( + EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = envVarServiceAsync.delete(EnvVarDeleteParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val envVar = envVarFuture.get() - envVar.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.delete( + EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarServiceAsync = client.envVars() - - val envVarFuture = envVarServiceAsync.replace(EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build()) - - val envVar = envVarFuture.get() - envVar.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarServiceAsync = client.envVars() + + val envVarFuture = + envVarServiceAsync.replace( + EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() + ) + + val envVar = envVarFuture.get() + envVar.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt index 2dbf5ef8..406d7f7b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt @@ -15,54 +15,66 @@ class EvalServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val evalServiceAsync = client.evals() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val evalServiceAsync = client.evals() - val summarizeExperimentResponseFuture = evalServiceAsync.create(EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder() - .datasetId("dataset_id") - .build()) - .projectId("project_id") - .addScore(EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()) - .task(EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build()) - .isPublic(true) - .maxConcurrency(0.0) - .metadata(EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build()) + val summarizeExperimentResponseFuture = + evalServiceAsync.create( + EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .projectId("project_id") + .addScore( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .task( + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build() + ) + .isPublic(true) + .maxConcurrency(0.0) + .metadata( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() + ) - val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() - summarizeExperimentResponse.validate() + val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() + summarizeExperimentResponse.validate() } } 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 d9925d89..e4ab67f2 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 @@ -11,7 +11,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams @@ -28,266 +27,329 @@ class ExperimentServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = experimentServiceAsync.create(ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("x") - .public_(true) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build()) - - val experiment = experimentFuture.get() - experiment.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = + experimentServiceAsync.create( + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("x") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + ) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = experimentServiceAsync.retrieve(ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val experiment = experimentFuture.get() - experiment.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = + experimentServiceAsync.retrieve( + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = experimentServiceAsync.update(ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .public_(true) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build()) - - val experiment = experimentFuture.get() - experiment.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = + experimentServiceAsync.update( + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + ) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() - val pageFuture = experimentServiceAsync.list() + val pageFuture = experimentServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val experimentFuture = experimentServiceAsync.delete(ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val experiment = experimentFuture.get() - experiment.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val experimentFuture = + experimentServiceAsync.delete( + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val experiment = experimentFuture.get() + experiment.validate() } @Test fun feedback() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val feedbackResponseSchemaFuture = experimentServiceAsync.feedback(ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build()) - .build()) - - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val feedbackResponseSchemaFuture = + experimentServiceAsync.feedback( + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) + + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val fetchExperimentEventsResponseFuture = experimentServiceAsync.fetch(ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) - - val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() - fetchExperimentEventsResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val fetchExperimentEventsResponseFuture = + experimentServiceAsync.fetch( + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() + fetchExperimentEventsResponse.validate() } @Test fun fetchPost() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val fetchExperimentEventsResponseFuture = experimentServiceAsync.fetchPost(ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) - - val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() - fetchExperimentEventsResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val fetchExperimentEventsResponseFuture = + experimentServiceAsync.fetchPost( + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + val fetchExperimentEventsResponse = fetchExperimentEventsResponseFuture.get() + fetchExperimentEventsResponse.validate() } @Test fun insert() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val insertEventsResponseFuture = experimentServiceAsync.insert(ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build()) - - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val insertEventsResponseFuture = + experimentServiceAsync.insert( + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) + + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } @Test fun summarize() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentServiceAsync = client.experiments() - - val summarizeExperimentResponseFuture = experimentServiceAsync.summarize(ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build()) - - val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() - summarizeExperimentResponse.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentServiceAsync = client.experiments() + + val summarizeExperimentResponseFuture = + experimentServiceAsync.summarize( + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() + ) + + val summarizeExperimentResponse = summarizeExperimentResponseFuture.get() + summarizeExperimentResponse.validate() } } 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 852d1e77..58578b30 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 @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams -import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams @@ -24,297 +23,452 @@ class FunctionServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = functionServiceAsync.create(FunctionCreateParams.builder() - .functionData(FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema(FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin(FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) + val functionFuture = + functionServiceAsync.create( + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin( + FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = functionServiceAsync.retrieve(FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val functionFuture = + functionServiceAsync.retrieve( + FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = functionServiceAsync.update(FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("name") - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) + val functionFuture = + functionServiceAsync.update( + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val pageFuture = functionServiceAsync.list() + val pageFuture = functionServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = functionServiceAsync.delete(FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val functionFuture = + functionServiceAsync.delete( + FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } @Test fun invoke() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val responseFuture = functionServiceAsync.invoke(FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage(FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build()) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) - .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build()) - .build()) - .stream(true) - .version("version") - .build()) + val responseFuture = + functionServiceAsync.invoke( + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent( + FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + .stream(true) + .version("version") + .build() + ) - val response = responseFuture.get() - val unwrappedResponse = response.getOrNull() - assertNotNull(unwrappedResponse) - unwrappedResponse.validate() + val response = responseFuture.get() + val unwrappedResponse = response.getOrNull() + assertNotNull(unwrappedResponse) + unwrappedResponse.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionServiceAsync = client.functions() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionServiceAsync = client.functions() - val functionFuture = functionServiceAsync.replace(FunctionReplaceParams.builder() - .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema(FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin(FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) + val functionFuture = + functionServiceAsync.replace( + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin( + FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) - val function = functionFuture.get() - function.validate() + val function = functionFuture.get() + function.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt index d14aa978..314e7023 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams -import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams @@ -18,109 +17,128 @@ class GroupServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = groupServiceAsync.create(GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build()) - - val group = groupFuture.get() - group.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.create( + GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + val group = groupFuture.get() + group.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = groupServiceAsync.retrieve(GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val group = groupFuture.get() - group.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.retrieve( + GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val group = groupFuture.get() + group.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = groupServiceAsync.update(GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val group = groupFuture.get() - group.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.update( + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val group = groupFuture.get() + group.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() - val pageFuture = groupServiceAsync.list() + val pageFuture = groupServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = groupServiceAsync.delete(GroupDeleteParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val group = groupFuture.get() - group.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.delete( + GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val group = groupFuture.get() + group.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupServiceAsync = client.groups() - - val groupFuture = groupServiceAsync.replace(GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build()) - - val group = groupFuture.get() - group.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupServiceAsync = client.groups() + + val groupFuture = + groupServiceAsync.replace( + GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + val group = groupFuture.get() + group.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt index d6f423f1..b89247bd 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.OrganizationDeleteParams -import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import org.junit.jupiter.api.Test @@ -16,68 +15,81 @@ class OrganizationServiceAsyncTest { @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = organizationServiceAsync.retrieve(OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val organizationFuture = + organizationServiceAsync.retrieve( + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = organizationServiceAsync.update(OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build()) + val organizationFuture = + organizationServiceAsync.update( + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + ) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val pageFuture = organizationServiceAsync.list() + val pageFuture = organizationServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationServiceAsync = client.organizations() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationServiceAsync = client.organizations() - val organizationFuture = organizationServiceAsync.delete(OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val organizationFuture = + organizationServiceAsync.delete( + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - val organization = organizationFuture.get() - organization.validate() + val organization = organizationFuture.get() + organization.validate() } } 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 7ed089bb..efa55642 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 @@ -9,7 +9,6 @@ import com.braintrustdata.api.models.ProjectScoreCategory import com.braintrustdata.api.models.ProjectScoreConfig import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams -import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams @@ -21,155 +20,191 @@ class ProjectScoreServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = projectScoreServiceAsync.create(ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .build()) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.create( + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = projectScoreServiceAsync.retrieve(ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.retrieve( + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = projectScoreServiceAsync.update(ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build()) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.update( + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() - val pageFuture = projectScoreServiceAsync.list() + val pageFuture = projectScoreServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = projectScoreServiceAsync.delete(ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.delete( + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreServiceAsync = client.projectScores() - - val projectScoreFuture = projectScoreServiceAsync.replace(ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .build()) - - val projectScore = projectScoreFuture.get() - projectScore.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreServiceAsync = client.projectScores() + + val projectScoreFuture = + projectScoreServiceAsync.replace( + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() + ) + + val projectScore = projectScoreFuture.get() + projectScore.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt index b1b29862..85f07a6a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams -import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectSettings import com.braintrustdata.api.models.ProjectUpdateParams @@ -18,84 +17,96 @@ class ProjectServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = projectServiceAsync.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - - val project = projectFuture.get() - project.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + + val project = projectFuture.get() + project.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = projectServiceAsync.retrieve(ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val project = projectFuture.get() - project.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.retrieve( + ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val project = projectFuture.get() + project.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = projectServiceAsync.update(ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder() - .comparisonKey("comparison_key") - .build()) - .build()) - - val project = projectFuture.get() - project.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.update( + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .build() + ) + + val project = projectFuture.get() + project.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() - val pageFuture = projectServiceAsync.list() + val pageFuture = projectServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectServiceAsync = client.projects() - - val projectFuture = projectServiceAsync.delete(ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val project = projectFuture.get() - project.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.delete( + ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val project = projectFuture.get() + project.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt index 36d9a445..8105ac95 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams -import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams @@ -18,104 +17,125 @@ class ProjectTagServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = projectTagServiceAsync.create(ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build()) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.create( + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = projectTagServiceAsync.retrieve(ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.retrieve( + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = projectTagServiceAsync.update(ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build()) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.update( + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() - val pageFuture = projectTagServiceAsync.list() + val pageFuture = projectTagServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = projectTagServiceAsync.delete(ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.delete( + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagServiceAsync = client.projectTags() - - val projectTagFuture = projectTagServiceAsync.replace(ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build()) - - val projectTag = projectTagFuture.get() - projectTag.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagServiceAsync = client.projectTags() + + val projectTagFuture = + projectTagServiceAsync.replace( + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + ) + + val projectTag = projectTagFuture.get() + projectTag.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt index a59c59a5..2535012d 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptDeleteParams -import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptOptions import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams @@ -21,232 +20,358 @@ class PromptServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = promptServiceAsync.create(PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) - - val prompt = promptFuture.get() - prompt.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.create( + PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = promptServiceAsync.retrieve(PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val prompt = promptFuture.get() - prompt.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.retrieve( + PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = promptServiceAsync.update(PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .slug("slug") - .addTag("string") - .build()) - - val prompt = promptFuture.get() - prompt.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.update( + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .slug("slug") + .addTag("string") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() - val pageFuture = promptServiceAsync.list() + val pageFuture = promptServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = promptServiceAsync.delete(PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val prompt = promptFuture.get() - prompt.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.delete( + PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptServiceAsync = client.prompts() - - val promptFuture = promptServiceAsync.replace(PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) - - val prompt = promptFuture.get() - prompt.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptServiceAsync = client.prompts() + + val promptFuture = + promptServiceAsync.replace( + PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + val prompt = promptFuture.get() + prompt.validate() } } 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 5f27b17c..140fdec7 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 @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams -import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams @@ -18,121 +17,155 @@ class RoleServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = roleServiceAsync.create(RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission(RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build()) - - val role = roleFuture.get() - role.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.create( + RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + val role = roleFuture.get() + role.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = roleServiceAsync.retrieve(RoleRetrieveParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val role = roleFuture.get() - role.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.retrieve( + RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val role = roleFuture.get() + role.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = roleServiceAsync.update(RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val role = roleFuture.get() - role.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.update( + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() + ) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val role = roleFuture.get() + role.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() - val pageFuture = roleServiceAsync.list() + val pageFuture = roleServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = roleServiceAsync.delete(RoleDeleteParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val role = roleFuture.get() - role.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.delete( + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val role = roleFuture.get() + role.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleServiceAsync = client.roles() - - val roleFuture = roleServiceAsync.replace(RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission(RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build()) - - val role = roleFuture.get() - role.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleServiceAsync = client.roles() + + val roleFuture = + roleServiceAsync.replace( + RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + val role = roleFuture.get() + role.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt index b9d4a0bb..8d448a50 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams -import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams @@ -18,106 +17,127 @@ class SpanIframeServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = spanIframeServiceAsync.create(SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build()) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.create( + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = spanIframeServiceAsync.retrieve(SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.retrieve( + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = spanIframeServiceAsync.update(SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build()) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.update( + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() - val pageFuture = spanIframeServiceAsync.list() + val pageFuture = spanIframeServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = spanIframeServiceAsync.delete(SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.delete( + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeServiceAsync = client.spanIframes() - - val spanIFrameFuture = spanIframeServiceAsync.replace(SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build()) - - val spanIFrame = spanIFrameFuture.get() - spanIFrame.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeServiceAsync = client.spanIframes() + + val spanIFrameFuture = + spanIframeServiceAsync.replace( + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + ) + + val spanIFrame = spanIFrameFuture.get() + spanIFrame.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt index 8ac4b613..dee09b2e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync -import com.braintrustdata.api.models.TopLevelHelloWorldParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -13,14 +12,15 @@ class TopLevelServiceAsyncTest { @Test fun helloWorld() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val topLevelServiceAsync = client.topLevel() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val topLevelServiceAsync = client.topLevel() - val responseFuture = topLevelServiceAsync.helloWorld() + val responseFuture = topLevelServiceAsync.helloWorld() - val response = responseFuture.get() + val response = responseFuture.get() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt index 082c2586..38f452e7 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync -import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -14,31 +13,34 @@ class UserServiceAsyncTest { @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userServiceAsync = client.users() - - val userFuture = userServiceAsync.retrieve(UserRetrieveParams.builder() - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - val user = userFuture.get() - user.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userServiceAsync = client.users() + + val userFuture = + userServiceAsync.retrieve( + UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + val user = userFuture.get() + user.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userServiceAsync = client.users() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userServiceAsync = client.users() - val pageFuture = userServiceAsync.list() + val pageFuture = userServiceAsync.list() - val page = pageFuture.get() - page.response().validate() + val page = pageFuture.get() + page.response().validate() } } 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 d86d5880..8a7b3bfb 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 @@ -23,168 +23,222 @@ class ViewServiceAsyncTest { @Test fun create() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = viewServiceAsync.create(ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build()) - - val view = viewFuture.get() - view.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.create( + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + + val view = viewFuture.get() + view.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = viewServiceAsync.retrieve(ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build()) - - val view = viewFuture.get() - view.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.retrieve( + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + ) + + val view = viewFuture.get() + view.validate() } @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = viewServiceAsync.update(ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build()) - - val view = viewFuture.get() - view.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.update( + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() + ) + + val view = viewFuture.get() + view.validate() } @Test fun list() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val pageFuture = viewServiceAsync.list(ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build()) - - val page = pageFuture.get() - page.response().validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val pageFuture = + viewServiceAsync.list( + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build() + ) + + val page = pageFuture.get() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = viewServiceAsync.delete(ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build()) - - val view = viewFuture.get() - view.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.delete( + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + ) + + val view = viewFuture.get() + view.validate() } @Test fun replace() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewServiceAsync = client.views() - - val viewFuture = viewServiceAsync.replace(ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build()) - - val view = viewFuture.get() - view.validate() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewServiceAsync = client.views() + + val viewFuture = + viewServiceAsync.replace( + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + + val view = viewFuture.get() + view.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt index 4710a3ed..12efbd59 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt @@ -13,31 +13,39 @@ class MemberServiceAsyncTest { @Test fun update() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val memberServiceAsync = client.organizations().members() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberServiceAsync = client.organizations().members() - val patchOrganizationMembersOutputFuture = memberServiceAsync.update(OrganizationMemberUpdateParams.builder() - .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build()) - .orgId("org_id") - .orgName("org_name") - .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build()) + val patchOrganizationMembersOutputFuture = + memberServiceAsync.update( + OrganizationMemberUpdateParams.builder() + .inviteUsers( + OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) - val patchOrganizationMembersOutput = patchOrganizationMembersOutputFuture.get() - patchOrganizationMembersOutput.validate() + val patchOrganizationMembersOutput = patchOrganizationMembersOutputFuture.get() + patchOrganizationMembersOutput.validate() } } 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 492d6f27..fec1f6b8 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 @@ -21,128 +21,162 @@ class LogServiceAsyncTest { @Test fun feedback() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val feedbackResponseSchemaFuture = logServiceAsync.feedback(ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build()) - .build()) + val feedbackResponseSchemaFuture = + logServiceAsync.feedback( + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) - val feedbackResponseSchema = feedbackResponseSchemaFuture.get() - feedbackResponseSchema.validate() + val feedbackResponseSchema = feedbackResponseSchemaFuture.get() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val fetchProjectLogsEventsResponseFuture = logServiceAsync.fetch(ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) + val fetchProjectLogsEventsResponseFuture = + logServiceAsync.fetch( + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) - val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() - fetchProjectLogsEventsResponse.validate() + val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() + fetchProjectLogsEventsResponse.validate() } @Test fun fetchPost() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val fetchProjectLogsEventsResponseFuture = logServiceAsync.fetchPost(ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) + val fetchProjectLogsEventsResponseFuture = + logServiceAsync.fetchPost( + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) - val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() - fetchProjectLogsEventsResponse.validate() + val fetchProjectLogsEventsResponse = fetchProjectLogsEventsResponseFuture.get() + fetchProjectLogsEventsResponse.validate() } @Test fun insert() { - val client = BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logServiceAsync = client.projects().logs() + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.projects().logs() - val insertEventsResponseFuture = logServiceAsync.insert(ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build()) + val insertEventsResponseFuture = + logServiceAsync.insert( + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) - val insertEventsResponse = insertEventsResponseFuture.get() - insertEventsResponse.validate() + val insertEventsResponse = insertEventsResponseFuture.get() + insertEventsResponse.validate() } } 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 606645e8..499ca976 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 @@ -18,121 +18,149 @@ class AclServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = aclService.create(AclCreateParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclCreateParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclCreateParams.Permission.CREATE) - .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - acl.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = + aclService.create( + AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclCreateParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclCreateParams.Permission.CREATE) + .restrictObjectType(AclCreateParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + acl.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = aclService.retrieve(AclRetrieveParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - acl.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = + aclService.retrieve( + AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + acl.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val page = aclService.list(AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .build()) - - page.response().validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val page = + aclService.list( + AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .build() + ) + + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = aclService.delete(AclDeleteParams.builder() - .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - acl.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = + aclService.delete( + AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + acl.validate() } @Test fun batchUpdate() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val aclBatchUpdateResponse = aclService.batchUpdate(AclBatchUpdateParams.builder() - .addAddAcl(AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .addRemoveAcl(AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build()) - - aclBatchUpdateResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val aclBatchUpdateResponse = + aclService.batchUpdate( + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + aclBatchUpdateResponse.validate() } @Test fun findAndDelete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val acl = aclService.findAndDelete(AclFindAndDeleteParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclFindAndDeleteParams.Permission.CREATE) - .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - acl.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val acl = + aclService.findAndDelete( + AclFindAndDeleteParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclFindAndDeleteParams.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclFindAndDeleteParams.Permission.CREATE) + .restrictObjectType(AclFindAndDeleteParams.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + acl.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt index e3d4c517..6da192a1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.AiSecretCreateParams import com.braintrustdata.api.models.AiSecretDeleteParams import com.braintrustdata.api.models.AiSecretFindAndDeleteParams -import com.braintrustdata.api.models.AiSecretListParams import com.braintrustdata.api.models.AiSecretReplaceParams import com.braintrustdata.api.models.AiSecretRetrieveParams import com.braintrustdata.api.models.AiSecretUpdateParams @@ -20,123 +19,151 @@ class AiSecretServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = aiSecretService.create(AiSecretCreateParams.builder() - .name("name") - .metadata(AiSecretCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build()) - - aISecret.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = + aiSecretService.create( + AiSecretCreateParams.builder() + .name("name") + .metadata( + AiSecretCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + ) + + aISecret.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = aiSecretService.retrieve(AiSecretRetrieveParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - aISecret.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = + aiSecretService.retrieve( + AiSecretRetrieveParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + aISecret.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = aiSecretService.update(AiSecretUpdateParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(AiSecretUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .secret("secret") - .type("type") - .build()) - - aISecret.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = + aiSecretService.update( + AiSecretUpdateParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata( + AiSecretUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .secret("secret") + .type("type") + .build() + ) + + aISecret.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() - val page = aiSecretService.list() + val page = aiSecretService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = aiSecretService.delete(AiSecretDeleteParams.builder() - .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - aISecret.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = + aiSecretService.delete( + AiSecretDeleteParams.builder() + .aiSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + aISecret.validate() } @Test fun findAndDelete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = aiSecretService.findAndDelete(AiSecretFindAndDeleteParams.builder() - .name("name") - .orgName("org_name") - .build()) - - aISecret.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = + aiSecretService.findAndDelete( + AiSecretFindAndDeleteParams.builder().name("name").orgName("org_name").build() + ) + + aISecret.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aiSecretService = client.aiSecrets() - - val aISecret = aiSecretService.replace(AiSecretReplaceParams.builder() - .name("name") - .metadata(AiSecretReplaceParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build()) - - aISecret.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aiSecretService = client.aiSecrets() + + val aISecret = + aiSecretService.replace( + AiSecretReplaceParams.builder() + .name("name") + .metadata( + AiSecretReplaceParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + ) + + aISecret.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index 3392aae9..46eefb44 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ApiKeyCreateParams import com.braintrustdata.api.models.ApiKeyDeleteParams -import com.braintrustdata.api.models.ApiKeyListParams import com.braintrustdata.api.models.ApiKeyRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -16,60 +15,70 @@ class ApiKeyServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val createApiKeyOutput = apiKeyService.create(ApiKeyCreateParams.builder() - .name("name") - .orgName("org_name") - .build()) + val createApiKeyOutput = + apiKeyService.create( + ApiKeyCreateParams.builder().name("name").orgName("org_name").build() + ) - createApiKeyOutput.validate() + createApiKeyOutput.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val apiKey = apiKeyService.retrieve(ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val apiKey = + apiKeyService.retrieve( + ApiKeyRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - apiKey.validate() + apiKey.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val page = apiKeyService.list() + val page = apiKeyService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.apiKeys() - val apiKey = apiKeyService.delete(ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val apiKey = + apiKeyService.delete( + ApiKeyDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - apiKey.validate() + apiKey.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index 62712f54..a9bae5c4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -11,7 +11,6 @@ import com.braintrustdata.api.models.DatasetFeedbackParams import com.braintrustdata.api.models.DatasetFetchParams import com.braintrustdata.api.models.DatasetFetchPostParams import com.braintrustdata.api.models.DatasetInsertParams -import com.braintrustdata.api.models.DatasetListParams import com.braintrustdata.api.models.DatasetRetrieveParams import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams @@ -26,195 +25,244 @@ class DatasetServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = datasetService.create(DatasetCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .build()) - - dataset.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = + datasetService.create( + DatasetCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + dataset.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = datasetService.retrieve(DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - dataset.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = + datasetService.retrieve( + DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + dataset.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = datasetService.update(DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .build()) - - dataset.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = + datasetService.update( + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata( + DatasetUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .build() + ) + + dataset.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() - val page = datasetService.list() + val page = datasetService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val dataset = datasetService.delete(DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - dataset.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val dataset = + datasetService.delete( + DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + dataset.validate() } @Test fun feedback() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val feedbackResponseSchema = datasetService.feedback(DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .source(FeedbackDatasetItem.Source.APP) - .addTag("string") - .build()) - .build()) - - feedbackResponseSchema.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val feedbackResponseSchema = + datasetService.feedback( + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata( + FeedbackDatasetItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source(FeedbackDatasetItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) + + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val fetchDatasetEventsResponse = datasetService.fetch(DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) - - fetchDatasetEventsResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val fetchDatasetEventsResponse = + datasetService.fetch( + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + fetchDatasetEventsResponse.validate() } @Test fun fetchPost() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val fetchDatasetEventsResponse = datasetService.fetchPost(DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) - - fetchDatasetEventsResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val fetchDatasetEventsResponse = + datasetService.fetchPost( + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + fetchDatasetEventsResponse.validate() } @Test fun insert() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val insertEventsResponse = datasetService.insert(DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertDatasetEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rootSpanId("root_span_id") - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build()) - - insertEventsResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val insertEventsResponse = + datasetService.insert( + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertDatasetEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertDatasetEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rootSpanId("root_span_id") + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) + + insertEventsResponse.validate() } @Test fun summarize() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.datasets() - - val summarizeDatasetResponse = datasetService.summarize(DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build()) - - summarizeDatasetResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.datasets() + + val summarizeDatasetResponse = + datasetService.summarize( + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() + ) + + summarizeDatasetResponse.validate() } } 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 45209f68..94340681 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 @@ -18,103 +18,127 @@ class EnvVarServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = envVarService.create(EnvVarCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) - .value("value") - .build()) - - envVar.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = + envVarService.create( + EnvVarCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarCreateParams.ObjectType.ORGANIZATION) + .value("value") + .build() + ) + + envVar.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = envVarService.retrieve(EnvVarRetrieveParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - envVar.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = + envVarService.retrieve( + EnvVarRetrieveParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + envVar.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = envVarService.update(EnvVarUpdateParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .value("value") - .build()) - - envVar.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = + envVarService.update( + EnvVarUpdateParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .value("value") + .build() + ) + + envVar.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = envVarService.list(EnvVarListParams.builder() - .envVarName("env_var_name") - .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarListParams.ObjectType.ORGANIZATION) - .build()) - - envVar.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = + envVarService.list( + EnvVarListParams.builder() + .envVarName("env_var_name") + .ids("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarListParams.ObjectType.ORGANIZATION) + .build() + ) + + envVar.validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = envVarService.delete(EnvVarDeleteParams.builder() - .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - envVar.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = + envVarService.delete( + EnvVarDeleteParams.builder() + .envVarId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + envVar.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val envVarService = client.envVars() - - val envVar = envVarService.replace(EnvVarReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) - .value("value") - .build()) - - envVar.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val envVarService = client.envVars() + + val envVar = + envVarService.replace( + EnvVarReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(EnvVarReplaceParams.ObjectType.ORGANIZATION) + .value("value") + .build() + ) + + envVar.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index 73833227..feaa3f95 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -15,53 +15,65 @@ class EvalServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val evalService = client.evals() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val evalService = client.evals() - val summarizeExperimentResponse = evalService.create(EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder() - .datasetId("dataset_id") - .build()) - .projectId("project_id") - .addScore(EvalCreateParams.Score.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()) - .task(EvalCreateParams.Task.FunctionId.builder() - .functionId("function_id") - .version("version") - .build()) - .baseExperimentId("base_experiment_id") - .baseExperimentName("base_experiment_name") - .experimentName("experiment_name") - .gitMetadataSettings(EvalCreateParams.GitMetadataSettings.builder() - .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) - .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) - .build()) - .isPublic(true) - .maxConcurrency(0.0) - .metadata(EvalCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .stream(true) - .timeout(0.0) - .trialCount(0.0) - .build()) + val summarizeExperimentResponse = + evalService.create( + EvalCreateParams.builder() + .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .projectId("project_id") + .addScore( + EvalCreateParams.Score.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .task( + EvalCreateParams.Task.FunctionId.builder() + .functionId("function_id") + .version("version") + .build() + ) + .baseExperimentId("base_experiment_id") + .baseExperimentName("base_experiment_name") + .experimentName("experiment_name") + .gitMetadataSettings( + EvalCreateParams.GitMetadataSettings.builder() + .collect(EvalCreateParams.GitMetadataSettings.Collect.ALL) + .addField(EvalCreateParams.GitMetadataSettings.Field.COMMIT) + .build() + ) + .isPublic(true) + .maxConcurrency(0.0) + .metadata( + EvalCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .stream(true) + .timeout(0.0) + .trialCount(0.0) + .build() + ) - summarizeExperimentResponse.validate() + summarizeExperimentResponse.validate() } } 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 a80c4a0c..b4e00567 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 @@ -11,7 +11,6 @@ import com.braintrustdata.api.models.ExperimentFeedbackParams import com.braintrustdata.api.models.ExperimentFetchParams import com.braintrustdata.api.models.ExperimentFetchPostParams import com.braintrustdata.api.models.ExperimentInsertParams -import com.braintrustdata.api.models.ExperimentListParams import com.braintrustdata.api.models.ExperimentRetrieveParams import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams @@ -28,256 +27,319 @@ class ExperimentServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = experimentService.create(ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .ensureNew(true) - .metadata(ExperimentCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("x") - .public_(true) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build()) - - experiment.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = + experimentService.create( + ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .ensureNew(true) + .metadata( + ExperimentCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("x") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + ) + + experiment.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = experimentService.retrieve(ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - experiment.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = + experimentService.retrieve( + ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + experiment.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = experimentService.update(ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .name("name") - .public_(true) - .repoInfo(RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build()) - .build()) - - experiment.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = + experimentService.update( + ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .datasetVersion("dataset_version") + .description("description") + .metadata( + ExperimentUpdateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .name("name") + .public_(true) + .repoInfo( + RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build() + ) + .build() + ) + + experiment.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() - val page = experimentService.list() + val page = experimentService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val experiment = experimentService.delete(ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - experiment.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val experiment = + experimentService.delete( + ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + experiment.validate() } @Test fun feedback() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val feedbackResponseSchema = experimentService.feedback(ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackExperimentItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackExperimentItem.Source.APP) - .addTag("string") - .build()) - .build()) - - feedbackResponseSchema.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val feedbackResponseSchema = + experimentService.feedback( + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackExperimentItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackExperimentItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackExperimentItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) + + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val fetchExperimentEventsResponse = experimentService.fetch(ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) - - fetchExperimentEventsResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val fetchExperimentEventsResponse = + experimentService.fetch( + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + fetchExperimentEventsResponse.validate() } @Test fun fetchPost() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val fetchExperimentEventsResponse = experimentService.fetchPost(ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) - - fetchExperimentEventsResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val fetchExperimentEventsResponse = + experimentService.fetchPost( + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) + + fetchExperimentEventsResponse.validate() } @Test fun insert() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val insertEventsResponse = experimentService.insert(ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertExperimentEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertExperimentEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertExperimentEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build()) - - insertEventsResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val insertEventsResponse = + experimentService.insert( + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertExperimentEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertExperimentEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertExperimentEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertExperimentEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) + + insertEventsResponse.validate() } @Test fun summarize() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiments() - - val summarizeExperimentResponse = experimentService.summarize(ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build()) - - summarizeExperimentResponse.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiments() + + val summarizeExperimentResponse = + experimentService.summarize( + ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() + ) + + summarizeExperimentResponse.validate() } } 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 2097fbb1..d5caebf7 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 @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams import com.braintrustdata.api.models.FunctionInvokeParams -import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams @@ -24,290 +23,445 @@ class FunctionServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = functionService.create(FunctionCreateParams.builder() - .functionData(FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema(FunctionCreateParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(FunctionCreateParams.FunctionType.LLM) - .origin(FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) + val function = + functionService.create( + FunctionCreateParams.builder() + .functionData( + FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionCreateParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionCreateParams.FunctionType.LLM) + .origin( + FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) - function.validate() + function.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = functionService.retrieve(FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val function = + functionService.retrieve( + FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - function.validate() + function.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = functionService.update(FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData(FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("name") - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) + val function = + functionService.update( + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData( + FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) - function.validate() + function.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val page = functionService.list() + val page = functionService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = functionService.delete(FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val function = + functionService.delete( + FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - function.validate() + function.validate() } @Test fun invoke() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val response = functionService.invoke(FunctionInvokeParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .input(JsonValue.from(mapOf())) - .addMessage(FunctionInvokeParams.Message.System.builder() - .role(FunctionInvokeParams.Message.System.Role.SYSTEM) - .content("content") - .name("name") - .build()) - .mode(FunctionInvokeParams.Mode.AUTO) - .parent(FunctionInvokeParams.Parent.SpanParentStruct.builder() - .objectId("object_id") - .objectType(FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) - .propagatedEvent(FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .rowIds(FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() - .id("id") - .rootSpanId("root_span_id") - .spanId("span_id") - .build()) - .build()) - .stream(true) - .version("version") - .build()) + val response = + functionService.invoke( + FunctionInvokeParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .input(JsonValue.from(mapOf())) + .addMessage( + FunctionInvokeParams.Message.System.builder() + .role(FunctionInvokeParams.Message.System.Role.SYSTEM) + .content("content") + .name("name") + .build() + ) + .mode(FunctionInvokeParams.Mode.AUTO) + .parent( + FunctionInvokeParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + FunctionInvokeParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + FunctionInvokeParams.Parent.SpanParentStruct.PropagatedEvent + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + FunctionInvokeParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + .stream(true) + .version("version") + .build() + ) - val unwrappedResponse = response.getOrNull() - assertNotNull(unwrappedResponse) - unwrappedResponse.validate() + val unwrappedResponse = response.getOrNull() + assertNotNull(unwrappedResponse) + unwrappedResponse.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.functions() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.functions() - val function = functionService.replace(FunctionReplaceParams.builder() - .functionData(FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build()) - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionSchema(FunctionReplaceParams.FunctionSchema.builder() - .parameters(JsonValue.from(mapOf())) - .returns(JsonValue.from(mapOf())) - .build()) - .functionType(FunctionReplaceParams.FunctionType.LLM) - .origin(FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build()) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) + val function = + functionService.replace( + FunctionReplaceParams.builder() + .functionData( + FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build() + ) + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionSchema( + FunctionReplaceParams.FunctionSchema.builder() + .parameters(JsonValue.from(mapOf())) + .returns(JsonValue.from(mapOf())) + .build() + ) + .functionType(FunctionReplaceParams.FunctionType.LLM) + .origin( + FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build() + ) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) - function.validate() + function.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index 26f5904b..5bb132ad 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams -import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams @@ -18,103 +17,122 @@ class GroupServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = groupService.create(GroupCreateParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build()) - - group.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = + groupService.create( + GroupCreateParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + group.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = groupService.retrieve(GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - group.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = + groupService.retrieve( + GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + group.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = groupService.update(GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - group.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = + groupService.update( + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addRemoveMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + group.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() - val page = groupService.list() + val page = groupService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = groupService.delete(GroupDeleteParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - group.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = + groupService.delete( + GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + group.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.groups() - - val group = groupService.replace(GroupReplaceParams.builder() - .name("x") - .description("description") - .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build()) - - group.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.groups() + + val group = + groupService.replace( + GroupReplaceParams.builder() + .name("x") + .description("description") + .addMemberGroup("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberUser("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + group.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt index a1dd9aeb..97c88d5c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt @@ -5,7 +5,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.OrganizationDeleteParams -import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams import org.junit.jupiter.api.Test @@ -16,64 +15,77 @@ class OrganizationServiceTest { @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = organizationService.retrieve(OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val organization = + organizationService.retrieve( + OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - organization.validate() + organization.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = organizationService.update(OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build()) + val organization = + organizationService.update( + OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .apiUrl("api_url") + .isUniversalApi(true) + .name("name") + .proxyUrl("proxy_url") + .realtimeUrl("realtime_url") + .build() + ) - organization.validate() + organization.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val page = organizationService.list() + val page = organizationService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organizations() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organizations() - val organization = organizationService.delete(OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val organization = + organizationService.delete( + OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - organization.validate() + organization.validate() } } 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 b9d3d052..0f7d4d1c 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 @@ -9,7 +9,6 @@ import com.braintrustdata.api.models.ProjectScoreCategory import com.braintrustdata.api.models.ProjectScoreConfig import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams -import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams @@ -21,149 +20,185 @@ class ProjectScoreServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = projectScoreService.create(ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .build()) - - projectScore.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = + projectScoreService.create( + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() + ) + + projectScore.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = projectScoreService.retrieve(ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - projectScore.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = + projectScoreService.retrieve( + ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + projectScore.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = projectScoreService.update(ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build()) - - projectScore.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = + projectScoreService.update( + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() + ) + + projectScore.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() - val page = projectScoreService.list() + val page = projectScoreService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = projectScoreService.delete(ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - projectScore.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = + projectScoreService.delete( + ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + projectScore.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScores() - - val projectScore = projectScoreService.replace(ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categoriesOfCategorical(listOf(ProjectScoreCategory.builder() - .name("name") - .value(0.0) - .build())) - .config(ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) - .multiSelect(true) - .online(OnlineScoreConfig.builder() - .samplingRate(0.0) - .addScorer(OnlineScoreConfig.Scorer.Function.builder() - .id("id") - .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) - .build()) - .applyToRootSpan(true) - .addApplyToSpanName("string") - .build()) - .build()) - .description("description") - .build()) - - projectScore.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScores() + + val projectScore = + projectScoreService.replace( + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categoriesOfCategorical( + listOf(ProjectScoreCategory.builder().name("name").value(0.0).build()) + ) + .config( + ProjectScoreConfig.builder() + .destination(ProjectScoreConfig.Destination.EXPECTED) + .multiSelect(true) + .online( + OnlineScoreConfig.builder() + .samplingRate(0.0) + .addScorer( + OnlineScoreConfig.Scorer.Function.builder() + .id("id") + .type(OnlineScoreConfig.Scorer.Function.Type.FUNCTION) + .build() + ) + .applyToRootSpan(true) + .addApplyToSpanName("string") + .build() + ) + .build() + ) + .description("description") + .build() + ) + + projectScore.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 0759010d..9b95d382 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams -import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectSettings import com.braintrustdata.api.models.ProjectUpdateParams @@ -18,79 +17,91 @@ class ProjectServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = projectService.create(ProjectCreateParams.builder() - .name("x") - .orgName("org_name") - .build()) - - project.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = + projectService.create( + ProjectCreateParams.builder().name("x").orgName("org_name").build() + ) + + project.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = projectService.retrieve(ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - project.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = + projectService.retrieve( + ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + project.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = projectService.update(ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings(ProjectSettings.builder() - .comparisonKey("comparison_key") - .build()) - .build()) - - project.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = + projectService.update( + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .build() + ) + + project.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() - val page = projectService.list() + val page = projectService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.projects() - - val project = projectService.delete(ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - project.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + + val project = + projectService.delete( + ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + project.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt index dac7a1eb..503f9390 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams -import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams @@ -18,98 +17,119 @@ class ProjectTagServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = projectTagService.create(ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build()) - - projectTag.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = + projectTagService.create( + ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + ) + + projectTag.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = projectTagService.retrieve(ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - projectTag.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = + projectTagService.retrieve( + ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + projectTag.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = projectTagService.update(ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build()) - - projectTag.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = + projectTagService.update( + ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + ) + + projectTag.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() - val page = projectTagService.list() + val page = projectTagService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = projectTagService.delete(ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - projectTag.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = + projectTagService.delete( + ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + projectTag.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTags() - - val projectTag = projectTagService.replace(ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build()) - - projectTag.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTags() + + val projectTag = + projectTagService.replace( + ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + ) + + projectTag.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 3edea5b3..68eff58c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -8,7 +8,6 @@ import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptDeleteParams -import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptOptions import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams @@ -21,226 +20,352 @@ class PromptServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = promptService.create(PromptCreateParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptCreateParams.FunctionType.LLM) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) - - prompt.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = + promptService.create( + PromptCreateParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptCreateParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + prompt.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val prompt = promptService.retrieve(PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val prompt = + promptService.retrieve( + PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - prompt.validate() + prompt.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = promptService.update(PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .slug("slug") - .addTag("string") - .build()) - - prompt.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = + promptService.update( + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .slug("slug") + .addTag("string") + .build() + ) + + prompt.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val page = promptService.list() + val page = promptService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() - val prompt = promptService.delete(PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) + val prompt = + promptService.delete( + PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) - prompt.validate() + prompt.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompts() - - val prompt = promptService.replace(PromptReplaceParams.builder() - .name("x") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("x") - .description("description") - .functionType(PromptReplaceParams.FunctionType.LLM) - .promptData(PromptData.builder() - .options(PromptOptions.builder() - .model("model") - .params(PromptOptions.Params.OpenAIModelParams.builder() - .frequencyPenalty(0.0) - .functionCall(PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO) - .maxTokens(0.0) - .n(0.0) - .presencePenalty(0.0) - .responseFormat(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.builder() - .type(PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject.Type.JSON_OBJECT) - .build()) - .addStop("string") - .temperature(0.0) - .toolChoice(PromptOptions.Params.OpenAIModelParams.ToolChoice.UnionMember0.AUTO) - .topP(0.0) - .useCache(true) - .build()) - .position("position") - .build()) - .origin(PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build()) - .parser(PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build()) - .prompt(PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build()) - .addToolFunction(PromptData.ToolFunction.Function.builder() - .id("id") - .type(PromptData.ToolFunction.Function.Type.FUNCTION) - .build()) - .build()) - .addTag("string") - .build()) - - prompt.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompts() + + val prompt = + promptService.replace( + PromptReplaceParams.builder() + .name("x") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("x") + .description("description") + .functionType(PromptReplaceParams.FunctionType.LLM) + .promptData( + PromptData.builder() + .options( + PromptOptions.builder() + .model("model") + .params( + PromptOptions.Params.OpenAIModelParams.builder() + .frequencyPenalty(0.0) + .functionCall( + PromptOptions.Params.OpenAIModelParams.FunctionCall + .UnionMember0 + .AUTO + ) + .maxTokens(0.0) + .n(0.0) + .presencePenalty(0.0) + .responseFormat( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .builder() + .type( + PromptOptions.Params.OpenAIModelParams + .ResponseFormat + .JsonObject + .Type + .JSON_OBJECT + ) + .build() + ) + .addStop("string") + .temperature(0.0) + .toolChoice( + PromptOptions.Params.OpenAIModelParams.ToolChoice + .UnionMember0 + .AUTO + ) + .topP(0.0) + .useCache(true) + .build() + ) + .position("position") + .build() + ) + .origin( + PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build() + ) + .parser( + PromptData.Parser.builder() + .choiceScores( + PromptData.Parser.ChoiceScores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build() + ) + .prompt( + PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build() + ) + .addToolFunction( + PromptData.ToolFunction.Function.builder() + .id("id") + .type(PromptData.ToolFunction.Function.Type.FUNCTION) + .build() + ) + .build() + ) + .addTag("string") + .build() + ) + + prompt.validate() } } 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 b480a17c..87471933 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 @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams -import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams @@ -18,115 +17,149 @@ class RoleServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = roleService.create(RoleCreateParams.builder() - .name("x") - .description("description") - .addMemberPermission(RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build()) - - role.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = + roleService.create( + RoleCreateParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + role.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = roleService.retrieve(RoleRetrieveParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - role.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = + roleService.retrieve( + RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + role.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = roleService.update(RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAddMemberPermission(RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("x") - .addRemoveMemberPermission(RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - role.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = + roleService.update( + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAddMemberPermission( + RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addAddMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("x") + .addRemoveMemberPermission( + RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType( + RoleUpdateParams.RemoveMemberPermission.RestrictObjectType + .ORGANIZATION + ) + .build() + ) + .addRemoveMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + role.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() - val page = roleService.list() + val page = roleService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = roleService.delete(RoleDeleteParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - role.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = + roleService.delete( + RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + role.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.roles() - - val role = roleService.replace(RoleReplaceParams.builder() - .name("x") - .description("description") - .addMemberPermission(RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) - .build()) - .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .orgName("org_name") - .build()) - - role.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.roles() + + val role = + roleService.replace( + RoleReplaceParams.builder() + .name("x") + .description("description") + .addMemberPermission( + RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType( + RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION + ) + .build() + ) + .addMemberRole("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .orgName("org_name") + .build() + ) + + role.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index 158d05e0..0f18d989 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -6,7 +6,6 @@ import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.models.SpanIframeCreateParams import com.braintrustdata.api.models.SpanIframeDeleteParams -import com.braintrustdata.api.models.SpanIframeListParams import com.braintrustdata.api.models.SpanIframeReplaceParams import com.braintrustdata.api.models.SpanIframeRetrieveParams import com.braintrustdata.api.models.SpanIframeUpdateParams @@ -18,100 +17,121 @@ class SpanIframeServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = spanIframeService.create(SpanIframeCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build()) - - spanIFrame.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = + spanIframeService.create( + SpanIframeCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + ) + + spanIFrame.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = spanIframeService.retrieve(SpanIframeRetrieveParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - spanIFrame.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = + spanIframeService.retrieve( + SpanIframeRetrieveParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + spanIFrame.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = spanIframeService.update(SpanIframeUpdateParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .postMessage(true) - .url("url") - .build()) - - spanIFrame.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = + spanIframeService.update( + SpanIframeUpdateParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .postMessage(true) + .url("url") + .build() + ) + + spanIFrame.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() - val page = spanIframeService.list() + val page = spanIframeService.list() - page.response().validate() + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = spanIframeService.delete(SpanIframeDeleteParams.builder() - .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - spanIFrame.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = + spanIframeService.delete( + SpanIframeDeleteParams.builder() + .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + spanIFrame.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val spanIframeService = client.spanIframes() - - val spanIFrame = spanIframeService.replace(SpanIframeReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .url("url") - .description("description") - .postMessage(true) - .build()) - - spanIFrame.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val spanIframeService = client.spanIframes() + + val spanIFrame = + spanIframeService.replace( + SpanIframeReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .url("url") + .description("description") + .postMessage(true) + .build() + ) + + spanIFrame.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt index b454e134..a1e4f554 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.TopLevelHelloWorldParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -13,12 +12,13 @@ class TopLevelServiceTest { @Test fun helloWorld() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val topLevelService = client.topLevel() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val topLevelService = client.topLevel() - topLevelService.helloWorld() + topLevelService.helloWorld() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index ca790444..bdf88104 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -14,29 +13,32 @@ class UserServiceTest { @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userService = client.users() - - val user = userService.retrieve(UserRetrieveParams.builder() - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - - user.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userService = client.users() + + val user = + userService.retrieve( + UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + ) + + user.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userService = client.users() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userService = client.users() - val page = userService.list() + val page = userService.list() - page.response().validate() + page.response().validate() } } 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 4fb57c0c..888e7466 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 @@ -23,162 +23,216 @@ class ViewServiceTest { @Test fun create() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = viewService.create(ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewCreateParams.ObjectType.ORGANIZATION) - .viewType(ViewCreateParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build()) - - view.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = + viewService.create( + ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewCreateParams.ObjectType.ORGANIZATION) + .viewType(ViewCreateParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + + view.validate() } @Test fun retrieve() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = viewService.retrieve(ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build()) - - view.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = + viewService.retrieve( + ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + ) + + view.validate() } @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = viewService.update(ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build()) - - view.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = + viewService.update( + ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) + .name("name") + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() + ) + + view.validate() } @Test fun list() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val page = viewService.list(ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .build()) - - page.response().validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val page = + viewService.list( + ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .build() + ) + + page.response().validate() } @Test fun delete() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = viewService.delete(ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build()) - - view.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = + viewService.delete( + ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + ) + + view.validate() } @Test fun replace() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.views() - - val view = viewService.replace(ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) - .viewType(ViewReplaceParams.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options(ViewOptions.builder() - .addColumnOrder("string") - .columnSizing(ViewOptions.ColumnSizing.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder() - .putAdditionalProperty("foo", JsonValue.from(true)) - .build()) - .build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData(ViewData.builder() - .search(ViewDataSearch.builder() - .addFilter(JsonValue.from(mapOf())) - .addMatch(JsonValue.from(mapOf())) - .addSort(JsonValue.from(mapOf())) - .addTag(JsonValue.from(mapOf())) - .build()) - .build()) - .build()) - - view.validate() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.views() + + val view = + viewService.replace( + ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewReplaceParams.ObjectType.ORGANIZATION) + .viewType(ViewReplaceParams.ViewType.PROJECTS) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .options( + ViewOptions.builder() + .addColumnOrder("string") + .columnSizing( + ViewOptions.ColumnSizing.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .columnVisibility( + ViewOptions.ColumnVisibility.builder() + .putAdditionalProperty("foo", JsonValue.from(true)) + .build() + ) + .build() + ) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData( + ViewData.builder() + .search( + ViewDataSearch.builder() + .addFilter(JsonValue.from(mapOf())) + .addMatch(JsonValue.from(mapOf())) + .addSort(JsonValue.from(mapOf())) + .addTag(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + + view.validate() } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt index 47cb2e31..d23dacb9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt @@ -13,30 +13,38 @@ class MemberServiceTest { @Test fun update() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val memberService = client.organizations().members() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberService = client.organizations().members() - val patchOrganizationMembersOutput = memberService.update(OrganizationMemberUpdateParams.builder() - .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() - .addEmail("string") - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .addGroupName("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sendInviteEmails(true) - .build()) - .orgId("org_id") - .orgName("org_name") - .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() - .addEmail("string") - .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build()) - .build()) + val patchOrganizationMembersOutput = + memberService.update( + OrganizationMemberUpdateParams.builder() + .inviteUsers( + OrganizationMemberUpdateParams.InviteUsers.builder() + .addEmail("string") + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addGroupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .addGroupName("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sendInviteEmails(true) + .build() + ) + .orgId("org_id") + .orgName("org_name") + .removeUsers( + OrganizationMemberUpdateParams.RemoveUsers.builder() + .addEmail("string") + .addId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) - patchOrganizationMembersOutput.validate() + patchOrganizationMembersOutput.validate() } } 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 128d5225..fca0f5f6 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 @@ -21,124 +21,158 @@ class LogServiceTest { @Test fun feedback() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val feedbackResponseSchema = logService.feedback(ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addFeedback(FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .scores(FeedbackProjectLogsItem.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .source(FeedbackProjectLogsItem.Source.APP) - .addTag("string") - .build()) - .build()) + val feedbackResponseSchema = + logService.feedback( + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFeedback( + FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata( + FeedbackProjectLogsItem.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .scores( + FeedbackProjectLogsItem.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .source(FeedbackProjectLogsItem.Source.APP) + .addTag("string") + .build() + ) + .build() + ) - feedbackResponseSchema.validate() + feedbackResponseSchema.validate() } @Test fun fetch() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val fetchProjectLogsEventsResponse = logService.fetch(ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) + val fetchProjectLogsEventsResponse = + logService.fetch( + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) - fetchProjectLogsEventsResponse.validate() + fetchProjectLogsEventsResponse.validate() } @Test fun fetchPost() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val fetchProjectLogsEventsResponse = logService.fetchPost(ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .limit(0L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build()) + val fetchProjectLogsEventsResponse = + logService.fetchPost( + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .limit(0L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + ) - fetchProjectLogsEventsResponse.validate() + fetchProjectLogsEventsResponse.validate() } @Test fun insert() { - val client = BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.projects().logs() - val insertEventsResponse = logService.insert(ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent(InsertProjectLogsEvent.builder() - .id("id") - ._isMerge(true) - .addMergePath(listOf("string")) - ._objectDelete(true) - ._parentId("_parent_id") - .context(InsertProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(0L) - .build()) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build()) - .metrics(InsertProjectLogsEvent.Metrics.builder() - .callerFilename(JsonValue.from(mapOf())) - .callerFunctionname(JsonValue.from(mapOf())) - .callerLineno(JsonValue.from(mapOf())) - .completionTokens(0L) - .end(0.0) - .promptTokens(0L) - .start(0.0) - .tokens(0L) - .build()) - .output(JsonValue.from(mapOf())) - .rootSpanId("root_span_id") - .scores(InsertProjectLogsEvent.Scores.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build()) - .spanAttributes(SpanAttributes.builder() - .name("name") - .type(SpanAttributes.Type.LLM) - .build()) - .spanId("span_id") - .addSpanParent("string") - .addTag("string") - .build()) - .build()) + val insertEventsResponse = + logService.insert( + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + InsertProjectLogsEvent.builder() + .id("id") + ._isMerge(true) + .addMergePath(listOf("string")) + ._objectDelete(true) + ._parentId("_parent_id") + .context( + InsertProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(0L) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata( + InsertProjectLogsEvent.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .metrics( + InsertProjectLogsEvent.Metrics.builder() + .callerFilename(JsonValue.from(mapOf())) + .callerFunctionname(JsonValue.from(mapOf())) + .callerLineno(JsonValue.from(mapOf())) + .completionTokens(0L) + .end(0.0) + .promptTokens(0L) + .start(0.0) + .tokens(0L) + .build() + ) + .output(JsonValue.from(mapOf())) + .rootSpanId("root_span_id") + .scores( + InsertProjectLogsEvent.Scores.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .spanAttributes( + SpanAttributes.builder() + .name("name") + .type(SpanAttributes.Type.LLM) + .build() + ) + .spanId("span_id") + .addSpanParent("string") + .addTag("string") + .build() + ) + .build() + ) - insertEventsResponse.validate() + insertEventsResponse.validate() } } From 6eee2722878aa0bfd85f8f11b6a99fb5aa2b4036 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 07:46:50 +0000 Subject: [PATCH 77/87] chore(internal): remove unused script (#147) --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 121ace97..94046873 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,4 +52,3 @@ jobs: - name: Run tests run: ./scripts/test - From 03f4bce0a262fd275057a74fc5cc6736e9df6a70 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 18:07:59 +0000 Subject: [PATCH 78/87] feat(api): manual updates (#148) --- .stats.yml | 4 +- .../com/braintrustdata/api/models/AISecret.kt | 31 +- .../api/models/AclBatchUpdateParams.kt | 2216 ----------------- .../braintrustdata/api/models/DatasetEvent.kt | 341 +-- .../api/models/EvalCreateParams.kt | 1189 ++++++++- .../api/models/ExperimentEvent.kt | 399 +-- .../api/models/FunctionInvokeParams.kt | 147 +- .../api/models/FunctionUpdateParams.kt | 128 +- .../api/models/InsertDatasetEvent.kt | 176 +- .../api/models/InsertExperimentEvent.kt | 220 +- .../api/models/InsertProjectLogsEvent.kt | 176 +- .../api/models/ObjectReference.kt | 339 +++ .../api/models/ProjectLogsEvent.kt | 347 +-- .../braintrustdata/api/models/ProjectScore.kt | 125 +- .../api/models/ProjectScoreConfig.kt | 117 +- .../api/models/ProjectScoreCreateParams.kt | 135 +- .../api/models/ProjectScoreListParams.kt | 12 + .../api/models/ProjectScoreReplaceParams.kt | 135 +- .../api/models/ProjectScoreUpdateParams.kt | 135 +- .../api/models/ProjectSettings.kt | 349 ++- .../braintrustdata/api/models/PromptData.kt | 117 +- .../api/models/PromptOptions.kt | 547 ++-- .../api/models/SpanIframeUpdateParams.kt | 50 +- .../com/braintrustdata/api/models/View.kt | 60 +- .../api/models/ViewCreateParams.kt | 60 +- .../api/models/ViewListParams.kt | 60 +- .../braintrustdata/api/models/ViewOptions.kt | 57 +- .../api/models/ViewReplaceParams.kt | 60 +- .../api/models/ViewUpdateParams.kt | 60 +- .../api/services/async/AclServiceAsync.kt | 53 - .../api/services/async/AclServiceAsyncImpl.kt | 40 - .../api/services/blocking/AclService.kt | 49 - .../api/services/blocking/AclServiceImpl.kt | 37 - .../braintrustdata/api/models/AISecretTest.kt | 2 + .../api/models/AclBatchUpdateParamsTest.kt | 118 - .../api/models/DatasetEventTest.kt | 22 +- .../api/models/DatasetInsertParamsTest.kt | 33 +- .../api/models/EvalCreateParamsTest.kt | 95 +- .../api/models/ExperimentEventTest.kt | 24 +- .../api/models/ExperimentInsertParamsTest.kt | 48 +- .../models/FetchDatasetEventsResponseTest.kt | 22 +- .../FetchExperimentEventsResponseTest.kt | 24 +- .../FetchProjectLogsEventsResponseTest.kt | 22 +- .../api/models/FunctionCreateParamsTest.kt | 13 + .../api/models/FunctionInvokeParamsTest.kt | 19 + .../api/models/FunctionReplaceParamsTest.kt | 13 + .../braintrustdata/api/models/FunctionTest.kt | 9 + .../api/models/FunctionUpdateParamsTest.kt | 13 + .../api/models/InsertDatasetEventTest.kt | 21 +- .../api/models/InsertExperimentEventTest.kt | 33 +- .../api/models/InsertProjectLogsEventTest.kt | 31 +- .../api/models/ObjectReferenceTest.kt | 27 + .../api/models/ProjectLogInsertParamsTest.kt | 45 +- .../api/models/ProjectLogsEventTest.kt | 22 +- .../api/models/ProjectScoreConfigTest.kt | 5 +- .../models/ProjectScoreCreateParamsTest.kt | 6 +- .../models/ProjectScoreReplaceParamsTest.kt | 6 +- .../api/models/ProjectScoreTest.kt | 4 +- .../models/ProjectScoreUpdateParamsTest.kt | 6 +- .../api/models/ProjectSettingsTest.kt | 25 +- .../braintrustdata/api/models/ProjectTest.kt | 30 +- .../api/models/ProjectUpdateParamsTest.kt | 45 +- .../api/models/PromptCreateParamsTest.kt | 13 + .../api/models/PromptDataTest.kt | 8 + .../api/models/PromptOptionsTest.kt | 4 + .../api/models/PromptReplaceParamsTest.kt | 13 + .../braintrustdata/api/models/PromptTest.kt | 9 + .../api/models/PromptUpdateParamsTest.kt | 13 + .../api/models/SpanIframeUpdateParamsTest.kt | 3 + .../api/models/ViewCreateParamsTest.kt | 9 + .../api/models/ViewOptionsTest.kt | 6 + .../api/models/ViewReplaceParamsTest.kt | 9 + .../com/braintrustdata/api/models/ViewTest.kt | 6 + .../api/models/ViewUpdateParamsTest.kt | 9 + .../api/services/async/AclServiceAsyncTest.kt | 46 - .../services/async/DatasetServiceAsyncTest.kt | 12 +- .../services/async/EvalServiceAsyncTest.kt | 32 +- .../async/ExperimentServiceAsyncTest.kt | 15 +- .../async/FunctionServiceAsyncTest.kt | 24 + .../async/ProjectScoreServiceAsyncTest.kt | 6 +- .../services/async/ProjectServiceAsyncTest.kt | 15 +- .../services/async/PromptServiceAsyncTest.kt | 18 + .../async/SpanIframeServiceAsyncTest.kt | 1 + .../services/async/ViewServiceAsyncTest.kt | 9 + .../async/projects/LogServiceAsyncTest.kt | 14 +- .../api/services/blocking/AclServiceTest.kt | 45 - .../services/blocking/DatasetServiceTest.kt | 12 +- .../api/services/blocking/EvalServiceTest.kt | 32 +- .../blocking/ExperimentServiceTest.kt | 15 +- .../services/blocking/FunctionServiceTest.kt | 24 + .../blocking/ProjectScoreServiceTest.kt | 6 +- .../services/blocking/ProjectServiceTest.kt | 15 +- .../services/blocking/PromptServiceTest.kt | 18 + .../blocking/SpanIframeServiceTest.kt | 1 + .../api/services/blocking/ViewServiceTest.kt | 9 + .../blocking/projects/LogServiceTest.kt | 14 +- 96 files changed, 4066 insertions(+), 5173 deletions(-) delete mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt delete mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt diff --git a/.stats.yml b/.stats.yml index bb136169..d949f1f0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-ce135a587d4ea037e39949984ed8f98578043e8c3a90fa203d24f28d234d8675.yml +configured_endpoints: 109 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-f5b152de2bdc5370d7c823d3ca415e1b914897ad98b117f1f0db213f44c0798f.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index baafa57f..b0cad87e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -36,6 +36,9 @@ private constructor( @ExcludeMissing private val previewSecret: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + private val updatedAt: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -58,6 +61,10 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + /** Date of last AI secret update */ + fun updatedAt(): Optional = + Optional.ofNullable(updatedAt.getNullable("updated_at")) + /** Unique identifier for the AI secret */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @@ -78,6 +85,11 @@ private constructor( @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** Date of last AI secret update */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -96,6 +108,7 @@ private constructor( metadata().ifPresent { it.validate() } previewSecret() type() + updatedAt() validated = true } @@ -126,6 +139,7 @@ private constructor( private var metadata: JsonField = JsonMissing.of() private var previewSecret: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -137,6 +151,7 @@ private constructor( metadata = aiSecret.metadata previewSecret = aiSecret.previewSecret type = aiSecret.type + updatedAt = aiSecret.updatedAt additionalProperties = aiSecret.additionalProperties.toMutableMap() } @@ -189,6 +204,15 @@ private constructor( fun type(type: JsonField) = apply { this.type = type } + /** Date of last AI secret update */ + fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) + + /** Date of last AI secret update */ + fun updatedAt(updatedAt: Optional) = updatedAt(updatedAt.getOrNull()) + + /** Date of last AI secret update */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -217,6 +241,7 @@ private constructor( metadata, previewSecret, type, + updatedAt, additionalProperties.toImmutable(), ) } @@ -305,15 +330,15 @@ private constructor( return true } - return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AISecret && id == other.id && name == other.name && orgId == other.orgId && created == other.created && metadata == other.metadata && previewSecret == other.previewSecret && type == other.type && updatedAt == other.updatedAt && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, orgId, created, metadata, previewSecret, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, name, orgId, created, metadata, previewSecret, type, updatedAt, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, additionalProperties=$additionalProperties}" + "AISecret{id=$id, name=$name, orgId=$orgId, created=$created, metadata=$metadata, previewSecret=$previewSecret, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } 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 deleted file mode 100644 index c7232bb9..00000000 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt +++ /dev/null @@ -1,2216 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -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 -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.Params -import com.braintrustdata.api.core.checkKnown -import com.braintrustdata.api.core.checkRequired -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 -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have no - * effect, and removing acls which do not exist will have no effect. - */ -class AclBatchUpdateParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. - */ - fun addAcls(): Optional> = body.addAcls() - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. - */ - fun removeAcls(): Optional> = body.removeAcls() - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. - */ - fun _addAcls(): JsonField> = body._addAcls() - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. - */ - fun _removeAcls(): JsonField> = body._removeAcls() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - @JvmSynthetic internal fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("add_acls") - @ExcludeMissing - private val addAcls: JsonField> = JsonMissing.of(), - @JsonProperty("remove_acls") - @ExcludeMissing - private val removeAcls: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun addAcls(): Optional> = Optional.ofNullable(addAcls.getNullable("add_acls")) - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun removeAcls(): Optional> = - Optional.ofNullable(removeAcls.getNullable("remove_acls")) - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - @JsonProperty("add_acls") @ExcludeMissing fun _addAcls(): JsonField> = addAcls - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - @JsonProperty("remove_acls") - @ExcludeMissing - fun _removeAcls(): JsonField> = removeAcls - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - addAcls().ifPresent { it.forEach { it.validate() } } - removeAcls().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var addAcls: JsonField>? = null - private var removeAcls: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - addAcls = body.addAcls.map { it.toMutableList() } - removeAcls = body.removeAcls.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ - fun addAcls(addAcls: List?) = addAcls(JsonField.ofNullable(addAcls)) - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ - fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ - fun addAcls(addAcls: JsonField>) = apply { - this.addAcls = addAcls.map { it.toMutableList() } - } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ - fun addAddAcl(addAcl: AddAcl) = apply { - addAcls = - (addAcls ?: JsonField.of(mutableListOf())).also { - checkKnown("addAcls", it).add(addAcl) - } - } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ - fun removeAcls(removeAcls: List?) = - removeAcls(JsonField.ofNullable(removeAcls)) - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ - fun removeAcls(removeAcls: Optional>) = - removeAcls(removeAcls.getOrNull()) - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ - fun removeAcls(removeAcls: JsonField>) = apply { - this.removeAcls = removeAcls.map { it.toMutableList() } - } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { - removeAcls = - (removeAcls ?: JsonField.of(mutableListOf())).also { - checkKnown("removeAcls", it).add(removeAcl) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Body = - Body( - (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, - (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(addAcls, removeAcls, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AclBatchUpdateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AclBatchUpdateParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AclBatchUpdateParams]. */ - @NoAutoDetect - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { - body = aclBatchUpdateParams.body.toBuilder() - additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() - } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun addAcls(addAcls: List?) = apply { body.addAcls(addAcls) } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun addAcls(addAcls: JsonField>) = apply { body.addAcls(addAcls) } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun addAddAcl(addAcl: AddAcl) = apply { body.addAddAcl(addAcl) } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun removeAcls(removeAcls: List?) = apply { body.removeAcls(removeAcls) } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun removeAcls(removeAcls: JsonField>) = apply { - body.removeAcls(removeAcls) - } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ - fun addRemoveAcl(removeAcl: RemoveAcl) = apply { body.addRemoveAcl(removeAcl) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun build(): AclBatchUpdateParams = - AclBatchUpdateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. - */ - @NoAutoDetect - class AddAcl - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the object the ACL applies to */ - fun objectId(): String = objectId.getRequired("object_id") - - /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) - - /** - * 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 = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - @ExcludeMissing - fun _permission(): JsonField = permission - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - 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 - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddAcl = apply { - if (validated) { - return@apply - } - - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AddAcl]. - * - * The following fields are required: - * ```java - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddAcl]. */ - class Builder internal constructor() { - - private var objectId: 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 roleId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addAcl: AddAcl) = apply { - objectId = addAcl.objectId - objectType = addAcl.objectType - groupId = addAcl.groupId - permission = addAcl.permission - restrictObjectType = addAcl.restrictObjectType - roleId = addAcl.roleId - userId = addAcl.userId - additionalProperties = addAcl.additionalProperties.toMutableMap() - } - - /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun permission(permission: Optional) = permission(permission.getOrNull()) - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } - - /** - * 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?) = - 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) = - 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 { - this.restrictObjectType = restrictObjectType - } - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): AddAcl = - AddAcl( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), - ) - } - - /** 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 - } - - return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" - } - - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. - */ - @NoAutoDetect - class RemoveAcl - @JsonCreator - private constructor( - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonProperty("group_id") - @ExcludeMissing - private val groupId: JsonField = JsonMissing.of(), - @JsonProperty("permission") - @ExcludeMissing - private val permission: JsonField = JsonMissing.of(), - @JsonProperty("restrict_object_type") - @ExcludeMissing - private val restrictObjectType: JsonField = JsonMissing.of(), - @JsonProperty("role_id") - @ExcludeMissing - private val roleId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - private val userId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the object the ACL applies to */ - fun objectId(): String = objectId.getRequired("object_id") - - /** The object type that the ACL applies to */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Optional = - Optional.ofNullable(permission.getNullable("permission")) - - /** - * 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 = - Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - @ExcludeMissing - fun _permission(): JsonField = permission - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - 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 - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RemoveAcl = apply { - if (validated) { - return@apply - } - - objectId() - objectType() - groupId() - permission() - restrictObjectType() - roleId() - userId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RemoveAcl]. - * - * The following fields are required: - * ```java - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveAcl]. */ - class Builder internal constructor() { - - private var objectId: 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 roleId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removeAcl: RemoveAcl) = apply { - objectId = removeAcl.objectId - objectType = removeAcl.objectType - groupId = removeAcl.groupId - permission = removeAcl.permission - restrictObjectType = removeAcl.restrictObjectType - roleId = removeAcl.roleId - userId = removeAcl.userId - additionalProperties = removeAcl.additionalProperties.toMutableMap() - } - - /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** The id of the object the ACL applies to */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** The object type that the ACL applies to */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun permission(permission: Optional) = permission(permission.getOrNull()) - - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun permission(permission: JsonField) = apply { - this.permission = permission - } - - /** - * 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?) = - 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) = - 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 { - this.restrictObjectType = restrictObjectType - } - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): RemoveAcl = - RemoveAcl( - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toImmutable(), - ) - } - - /** 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 - } - - return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 9552e3d7..b60821c8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.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 @@ -55,7 +53,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("origin") @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + private val origin: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing private val tags: JsonField> = JsonMissing.of(), @@ -116,7 +114,7 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** Indicates the event was copied from another object. */ - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** A list of tags to log */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) @@ -166,7 +164,7 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @@ -231,7 +229,7 @@ private constructor( private var input: JsonValue = JsonMissing.of() private var isRoot: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -368,13 +366,13 @@ private constructor( fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Indicates the event was copied from another object. */ - fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.getOrNull()) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = apply { this.origin = origin } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) @@ -441,10 +439,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -456,6 +463,7 @@ private constructor( return@apply } + model() validated = true } @@ -470,176 +478,23 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** Indicates the event was copied from another object. */ - @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** ID of the original event. */ - fun id(): String = id.getRequired("id") - - /** Transaction ID of the original event. */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Origin = apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Origin]. - * - * The following fields are required: - * ```java - * .id() - * ._xactId() - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Origin]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var _xactId: JsonField? = null - private var objectId: JsonField? = null - private var objectType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } - - /** ID of the original event. */ - fun id(id: String) = id(JsonField.of(id)) - - /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) - /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -660,143 +515,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Origin = - Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), - ) - } - - /** Type of the object the event is originating from. */ - 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 EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val FUNCTION = of("function") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val PROJECT_LOGS = of("project_logs") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - } - - /** - * 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 { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - /** - * 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) { - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - FUNCTION -> Value.FUNCTION - PROMPT_SESSION -> Value.PROMPT_SESSION - PROJECT_LOGS -> Value.PROJECT_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) { - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - FUNCTION -> Known.FUNCTION - PROMPT_SESSION -> Known.PROMPT_SESSION - PROJECT_LOGS -> Known.PROJECT_LOGS - 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() + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -804,17 +523,17 @@ private constructor( return true } - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + "Metadata{model=$model, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 84bb86ae..13823ba0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -99,6 +99,9 @@ private constructor( */ fun metadata(): Optional = body.metadata() + /** Options for tracing the evaluation */ + fun parent(): Optional = body.parent() + /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(): Optional = body.repoInfo() @@ -173,6 +176,9 @@ private constructor( */ fun _metadata(): JsonField = body._metadata() + /** Options for tracing the evaluation */ + fun _parent(): JsonField = body._parent() + /** Metadata about the state of the repo when the experiment was created */ fun _repoInfo(): JsonField = body._repoInfo() @@ -241,6 +247,9 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), @JsonProperty("repo_info") @ExcludeMissing private val repoInfo: JsonField = JsonMissing.of(), @@ -313,6 +322,9 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** Options for tracing the evaluation */ + fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) + /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) @@ -398,6 +410,9 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** Options for tracing the evaluation */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + /** Metadata about the state of the repo when the experiment was created */ @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo @@ -445,6 +460,7 @@ private constructor( isPublic() maxConcurrency() metadata().ifPresent { it.validate() } + parent().ifPresent { it.validate() } repoInfo().ifPresent { it.validate() } stream() timeout() @@ -484,6 +500,7 @@ private constructor( private var isPublic: JsonField = JsonMissing.of() private var maxConcurrency: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var parent: JsonField = JsonMissing.of() private var repoInfo: JsonField = JsonMissing.of() private var stream: JsonField = JsonMissing.of() private var timeout: JsonField = JsonMissing.of() @@ -503,6 +520,7 @@ private constructor( isPublic = body.isPublic maxConcurrency = body.maxConcurrency metadata = body.metadata + parent = body.parent repoInfo = body.repoInfo stream = body.stream timeout = body.timeout @@ -523,6 +541,9 @@ private constructor( fun data(projectDatasetName: Data.ProjectDatasetName) = data(Data.ofProjectDatasetName(projectDatasetName)) + /** Dataset rows */ + fun data(datasetRows: Data.DatasetRows) = data(Data.ofDatasetRows(datasetRows)) + /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -726,6 +747,19 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Options for tracing the evaluation */ + fun parent(parent: Parent) = parent(JsonField.of(parent)) + + /** Options for tracing the evaluation */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + /** Span parent properties */ + fun parent(spanParentStruct: Parent.SpanParentStruct) = + parent(Parent.ofSpanParentStruct(spanParentStruct)) + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun parent(string: String) = parent(Parent.ofString(string)) + /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) @@ -833,6 +867,7 @@ private constructor( isPublic, maxConcurrency, metadata, + parent, repoInfo, stream, timeout, @@ -846,17 +881,17 @@ private constructor( return true } - return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && data == other.data && projectId == other.projectId && scores == other.scores && task == other.task && baseExperimentId == other.baseExperimentId && baseExperimentName == other.baseExperimentName && experimentName == other.experimentName && gitMetadataSettings == other.gitMetadataSettings && isPublic == other.isPublic && maxConcurrency == other.maxConcurrency && metadata == other.metadata && parent == other.parent && repoInfo == other.repoInfo && stream == other.stream && timeout == other.timeout && trialCount == other.trialCount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, repoInfo, stream, timeout, trialCount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(data, projectId, scores, task, baseExperimentId, baseExperimentName, experimentName, gitMetadataSettings, isPublic, maxConcurrency, metadata, parent, repoInfo, stream, timeout, trialCount, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" + "Body{data=$data, projectId=$projectId, scores=$scores, task=$task, baseExperimentId=$baseExperimentId, baseExperimentName=$baseExperimentName, experimentName=$experimentName, gitMetadataSettings=$gitMetadataSettings, isPublic=$isPublic, maxConcurrency=$maxConcurrency, metadata=$metadata, parent=$parent, repoInfo=$repoInfo, stream=$stream, timeout=$timeout, trialCount=$trialCount, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -906,6 +941,9 @@ private constructor( body.data(projectDatasetName) } + /** Dataset rows */ + fun data(datasetRows: Data.DatasetRows) = apply { body.data(datasetRows) } + /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = apply { body.projectId(projectId) } @@ -1099,6 +1137,20 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** Options for tracing the evaluation */ + fun parent(parent: Parent) = apply { body.parent(parent) } + + /** Options for tracing the evaluation */ + fun parent(parent: JsonField) = apply { body.parent(parent) } + + /** Span parent properties */ + fun parent(spanParentStruct: Parent.SpanParentStruct) = apply { + body.parent(spanParentStruct) + } + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun parent(string: String) = apply { body.parent(string) } + /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } @@ -1302,6 +1354,7 @@ private constructor( private constructor( private val datasetId: DatasetId? = null, private val projectDatasetName: ProjectDatasetName? = null, + private val datasetRows: DatasetRows? = null, private val _json: JsonValue? = null, ) { @@ -1312,10 +1365,15 @@ private constructor( fun projectDatasetName(): Optional = Optional.ofNullable(projectDatasetName) + /** Dataset rows */ + fun datasetRows(): Optional = Optional.ofNullable(datasetRows) + fun isDatasetId(): Boolean = datasetId != null fun isProjectDatasetName(): Boolean = projectDatasetName != null + fun isDatasetRows(): Boolean = datasetRows != null + /** Dataset id */ fun asDatasetId(): DatasetId = datasetId.getOrThrow("datasetId") @@ -1323,12 +1381,16 @@ private constructor( fun asProjectDatasetName(): ProjectDatasetName = projectDatasetName.getOrThrow("projectDatasetName") + /** Dataset rows */ + fun asDatasetRows(): DatasetRows = datasetRows.getOrThrow("datasetRows") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { datasetId != null -> visitor.visitDatasetId(datasetId) projectDatasetName != null -> visitor.visitProjectDatasetName(projectDatasetName) + datasetRows != null -> visitor.visitDatasetRows(datasetRows) else -> visitor.unknown(_json) } } @@ -1349,6 +1411,10 @@ private constructor( override fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName) { projectDatasetName.validate() } + + override fun visitDatasetRows(datasetRows: DatasetRows) { + datasetRows.validate() + } } ) validated = true @@ -1359,15 +1425,16 @@ private constructor( return true } - return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName /* spotless:on */ + return /* spotless:off */ other is Data && datasetId == other.datasetId && projectDatasetName == other.projectDatasetName && datasetRows == other.datasetRows /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, projectDatasetName) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(datasetId, projectDatasetName, datasetRows) /* spotless:on */ override fun toString(): String = when { datasetId != null -> "Data{datasetId=$datasetId}" projectDatasetName != null -> "Data{projectDatasetName=$projectDatasetName}" + datasetRows != null -> "Data{datasetRows=$datasetRows}" _json != null -> "Data{_unknown=$_json}" else -> throw IllegalStateException("Invalid Data") } @@ -1381,6 +1448,9 @@ private constructor( @JvmStatic fun ofProjectDatasetName(projectDatasetName: ProjectDatasetName) = Data(projectDatasetName = projectDatasetName) + + /** Dataset rows */ + @JvmStatic fun ofDatasetRows(datasetRows: DatasetRows) = Data(datasetRows = datasetRows) } /** An interface that defines how to map each variant of [Data] to a value of type [T]. */ @@ -1392,6 +1462,9 @@ private constructor( /** Project and dataset name */ fun visitProjectDatasetName(projectDatasetName: ProjectDatasetName): T + /** Dataset rows */ + fun visitDatasetRows(datasetRows: DatasetRows): T + /** * Maps an unknown variant of [Data] to a value of type [T]. * @@ -1419,6 +1492,10 @@ private constructor( ?.let { return Data(projectDatasetName = it, _json = json) } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Data(datasetRows = it, _json = json) + } return Data(_json = json) } @@ -1435,6 +1512,7 @@ private constructor( value.datasetId != null -> generator.writeObject(value.datasetId) value.projectDatasetName != null -> generator.writeObject(value.projectDatasetName) + value.datasetRows != null -> generator.writeObject(value.datasetRows) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Data") } @@ -1449,16 +1527,26 @@ private constructor( @JsonProperty("dataset_id") @ExcludeMissing private val datasetId: JsonField = JsonMissing.of(), + @JsonProperty("_internal_btql") + @ExcludeMissing + private val _internalBtql: JsonField<_InternalBtql> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { fun datasetId(): String = datasetId.getRequired("dataset_id") + fun _internalBtql(): Optional<_InternalBtql> = + Optional.ofNullable(_internalBtql.getNullable("_internal_btql")) + @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + @JsonProperty("_internal_btql") + @ExcludeMissing + fun __internalBtql(): JsonField<_InternalBtql> = _internalBtql + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1471,6 +1559,7 @@ private constructor( } datasetId() + _internalBtql().ifPresent { it.validate() } validated = true } @@ -1493,11 +1582,13 @@ private constructor( class Builder internal constructor() { private var datasetId: JsonField? = null + private var _internalBtql: JsonField<_InternalBtql> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(datasetId: DatasetId) = apply { this.datasetId = datasetId.datasetId + _internalBtql = datasetId._internalBtql additionalProperties = datasetId.additionalProperties.toMutableMap() } @@ -1505,6 +1596,16 @@ private constructor( fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun _internalBtql(_internalBtql: _InternalBtql?) = + _internalBtql(JsonField.ofNullable(_internalBtql)) + + fun _internalBtql(_internalBtql: Optional<_InternalBtql>) = + _internalBtql(_internalBtql.getOrNull()) + + fun _internalBtql(_internalBtql: JsonField<_InternalBtql>) = apply { + this._internalBtql = _internalBtql + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1530,26 +1631,112 @@ private constructor( fun build(): DatasetId = DatasetId( checkRequired("datasetId", datasetId), + _internalBtql, additionalProperties.toImmutable(), ) } + @NoAutoDetect + class _InternalBtql + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): _InternalBtql = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [_InternalBtql]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [_InternalBtql]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_internalBtql: _InternalBtql) = apply { + additionalProperties = _internalBtql.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): _InternalBtql = _InternalBtql(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is _InternalBtql && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "_InternalBtql{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is DatasetId && datasetId == other.datasetId && _internalBtql == other._internalBtql && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(datasetId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(datasetId, _internalBtql, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "DatasetId{datasetId=$datasetId, additionalProperties=$additionalProperties}" + "DatasetId{datasetId=$datasetId, _internalBtql=$_internalBtql, additionalProperties=$additionalProperties}" } /** Project and dataset name */ @@ -1563,6 +1750,9 @@ private constructor( @JsonProperty("project_name") @ExcludeMissing private val projectName: JsonField = JsonMissing.of(), + @JsonProperty("_internal_btql") + @ExcludeMissing + private val _internalBtql: JsonField<_InternalBtql> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1571,6 +1761,9 @@ private constructor( fun projectName(): String = projectName.getRequired("project_name") + fun _internalBtql(): Optional<_InternalBtql> = + Optional.ofNullable(_internalBtql.getNullable("_internal_btql")) + @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName(): JsonField = datasetName @@ -1579,6 +1772,10 @@ private constructor( @ExcludeMissing fun _projectName(): JsonField = projectName + @JsonProperty("_internal_btql") + @ExcludeMissing + fun __internalBtql(): JsonField<_InternalBtql> = _internalBtql + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1592,6 +1789,7 @@ private constructor( datasetName() projectName() + _internalBtql().ifPresent { it.validate() } validated = true } @@ -1616,12 +1814,14 @@ private constructor( private var datasetName: JsonField? = null private var projectName: JsonField? = null + private var _internalBtql: JsonField<_InternalBtql> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectDatasetName: ProjectDatasetName) = apply { datasetName = projectDatasetName.datasetName projectName = projectDatasetName.projectName + _internalBtql = projectDatasetName._internalBtql additionalProperties = projectDatasetName.additionalProperties.toMutableMap() } @@ -1637,6 +1837,16 @@ private constructor( this.projectName = projectName } + fun _internalBtql(_internalBtql: _InternalBtql?) = + _internalBtql(JsonField.ofNullable(_internalBtql)) + + fun _internalBtql(_internalBtql: Optional<_InternalBtql>) = + _internalBtql(_internalBtql.getOrNull()) + + fun _internalBtql(_internalBtql: JsonField<_InternalBtql>) = apply { + this._internalBtql = _internalBtql + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1663,78 +1873,282 @@ private constructor( ProjectDatasetName( checkRequired("datasetName", datasetName), checkRequired("projectName", projectName), + _internalBtql, additionalProperties.toImmutable(), ) } + @NoAutoDetect + class _InternalBtql + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): _InternalBtql = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [_InternalBtql]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [_InternalBtql]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_internalBtql: _InternalBtql) = apply { + additionalProperties = _internalBtql.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): _InternalBtql = _InternalBtql(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is _InternalBtql && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "_InternalBtql{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectDatasetName && datasetName == other.datasetName && projectName == other.projectName && _internalBtql == other._internalBtql && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(datasetName, projectName, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(datasetName, projectName, _internalBtql, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, additionalProperties=$additionalProperties}" + "ProjectDatasetName{datasetName=$datasetName, projectName=$projectName, _internalBtql=$_internalBtql, additionalProperties=$additionalProperties}" } - } - /** The function to evaluate */ - @JsonDeserialize(using = Score.Deserializer::class) - @JsonSerialize(using = Score.Serializer::class) - class Score - private constructor( - private val functionId: FunctionId? = null, - private val projectSlug: ProjectSlug? = null, - private val globalFunction: GlobalFunction? = null, - private val promptSessionId: PromptSessionId? = null, - private val inlineCode: InlineCode? = null, - private val inlinePrompt: InlinePrompt? = null, - private val _json: JsonValue? = null, - ) { + /** Dataset rows */ + @NoAutoDetect + class DatasetRows + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - /** Function id */ - fun functionId(): Optional = Optional.ofNullable(functionId) + fun data(): List = data.getRequired("data") - /** Project name and slug */ - fun projectSlug(): Optional = Optional.ofNullable(projectSlug) + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data - /** Global function name */ - fun globalFunction(): Optional = Optional.ofNullable(globalFunction) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** Prompt session id */ - fun promptSessionId(): Optional = Optional.ofNullable(promptSessionId) + private var validated: Boolean = false - /** Inline code function */ - fun inlineCode(): Optional = Optional.ofNullable(inlineCode) + fun validate(): DatasetRows = apply { + if (validated) { + return@apply + } - /** Inline prompt definition */ - fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt) + data() + validated = true + } - fun isFunctionId(): Boolean = functionId != null + fun toBuilder() = Builder().from(this) - fun isProjectSlug(): Boolean = projectSlug != null + companion object { - fun isGlobalFunction(): Boolean = globalFunction != null + /** + * Returns a mutable builder for constructing an instance of [DatasetRows]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isPromptSessionId(): Boolean = promptSessionId != null + /** A builder for [DatasetRows]. */ + class Builder internal constructor() { - fun isInlineCode(): Boolean = inlineCode != null + private var data: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun isInlinePrompt(): Boolean = inlinePrompt != null + @JvmSynthetic + internal fun from(datasetRows: DatasetRows) = apply { + data = datasetRows.data.map { it.toMutableList() } + additionalProperties = datasetRows.additionalProperties.toMutableMap() + } - /** Function id */ - fun asFunctionId(): FunctionId = functionId.getOrThrow("functionId") + fun data(data: List) = data(JsonField.of(data)) - /** Project name and slug */ - fun asProjectSlug(): ProjectSlug = projectSlug.getOrThrow("projectSlug") + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: JsonValue) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): DatasetRows = + DatasetRows( + checkRequired("data", data).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DatasetRows && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DatasetRows{data=$data, additionalProperties=$additionalProperties}" + } + } + + /** The function to evaluate */ + @JsonDeserialize(using = Score.Deserializer::class) + @JsonSerialize(using = Score.Serializer::class) + class Score + private constructor( + private val functionId: FunctionId? = null, + private val projectSlug: ProjectSlug? = null, + private val globalFunction: GlobalFunction? = null, + private val promptSessionId: PromptSessionId? = null, + private val inlineCode: InlineCode? = null, + private val inlinePrompt: InlinePrompt? = null, + private val _json: JsonValue? = null, + ) { + + /** Function id */ + fun functionId(): Optional = Optional.ofNullable(functionId) + + /** Project name and slug */ + fun projectSlug(): Optional = Optional.ofNullable(projectSlug) + + /** Global function name */ + fun globalFunction(): Optional = Optional.ofNullable(globalFunction) + + /** Prompt session id */ + fun promptSessionId(): Optional = Optional.ofNullable(promptSessionId) + + /** Inline code function */ + fun inlineCode(): Optional = Optional.ofNullable(inlineCode) + + /** Inline prompt definition */ + fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt) + + fun isFunctionId(): Boolean = functionId != null + + fun isProjectSlug(): Boolean = projectSlug != null + + fun isGlobalFunction(): Boolean = globalFunction != null + + fun isPromptSessionId(): Boolean = promptSessionId != null + + fun isInlineCode(): Boolean = inlineCode != null + + fun isInlinePrompt(): Boolean = inlinePrompt != null + + /** Function id */ + fun asFunctionId(): FunctionId = functionId.getOrThrow("functionId") + + /** Project name and slug */ + fun asProjectSlug(): ProjectSlug = projectSlug.getOrThrow("projectSlug") /** Global function name */ fun asGlobalFunction(): GlobalFunction = globalFunction.getOrThrow("globalFunction") @@ -4895,6 +5309,687 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } + /** Options for tracing the evaluation */ + @JsonDeserialize(using = Parent.Deserializer::class) + @JsonSerialize(using = Parent.Serializer::class) + class Parent + private constructor( + private val spanParentStruct: SpanParentStruct? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + /** Span parent properties */ + fun spanParentStruct(): Optional = Optional.ofNullable(spanParentStruct) + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun string(): Optional = Optional.ofNullable(string) + + fun isSpanParentStruct(): Boolean = spanParentStruct != null + + fun isString(): Boolean = string != null + + /** Span parent properties */ + fun asSpanParentStruct(): SpanParentStruct = spanParentStruct.getOrThrow("spanParentStruct") + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + spanParentStruct != null -> visitor.visitSpanParentStruct(spanParentStruct) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): Parent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSpanParentStruct(spanParentStruct: SpanParentStruct) { + spanParentStruct.validate() + } + + override fun visitString(string: String) {} + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Parent && spanParentStruct == other.spanParentStruct && string == other.string /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(spanParentStruct, string) /* spotless:on */ + + override fun toString(): String = + when { + spanParentStruct != null -> "Parent{spanParentStruct=$spanParentStruct}" + string != null -> "Parent{string=$string}" + _json != null -> "Parent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Parent") + } + + companion object { + + /** Span parent properties */ + @JvmStatic + fun ofSpanParentStruct(spanParentStruct: SpanParentStruct) = + Parent(spanParentStruct = spanParentStruct) + + /** The parent's span identifier, created by calling `.export()` on a span */ + @JvmStatic fun ofString(string: String) = Parent(string = string) + } + + /** An interface that defines how to map each variant of [Parent] to a value of type [T]. */ + interface Visitor { + + /** Span parent properties */ + fun visitSpanParentStruct(spanParentStruct: SpanParentStruct): T + + /** The parent's span identifier, created by calling `.export()` on a span */ + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Parent] to a value of type [T]. + * + * An instance of [Parent] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws BraintrustInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Parent: $json") + } + } + + internal class Deserializer : BaseDeserializer(Parent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Parent { + val json = JsonValue.fromJsonNode(node) + + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Parent(spanParentStruct = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Parent(string = it, _json = json) + } + + return Parent(_json = json) + } + } + + internal class Serializer : BaseSerializer(Parent::class) { + + override fun serialize( + value: Parent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.spanParentStruct != null -> generator.writeObject(value.spanParentStruct) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Parent") + } + } + } + + /** Span parent properties */ + @NoAutoDetect + class SpanParentStruct + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("propagated_event") + @ExcludeMissing + private val propagatedEvent: JsonField = JsonMissing.of(), + @JsonProperty("row_ids") + @ExcludeMissing + private val rowIds: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The id of the container object you are logging to */ + fun objectId(): String = objectId.getRequired("object_id") + + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(): Optional = + Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) + + /** The id of the container object you are logging to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + /** Include these properties in every span created under this parent */ + @JsonProperty("propagated_event") + @ExcludeMissing + fun _propagatedEvent(): JsonField = propagatedEvent + + /** Identifiers for the row to to log a subspan under */ + @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField = rowIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SpanParentStruct = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + propagatedEvent().ifPresent { it.validate() } + rowIds().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SpanParentStruct]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpanParentStruct]. */ + class Builder internal constructor() { + + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var propagatedEvent: JsonField = JsonMissing.of() + private var rowIds: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanParentStruct: SpanParentStruct) = apply { + objectId = spanParentStruct.objectId + objectType = spanParentStruct.objectType + propagatedEvent = spanParentStruct.propagatedEvent + rowIds = spanParentStruct.rowIds + additionalProperties = spanParentStruct.additionalProperties.toMutableMap() + } + + /** The id of the container object you are logging to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the container object you are logging to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(propagatedEvent: PropagatedEvent?) = + propagatedEvent(JsonField.ofNullable(propagatedEvent)) + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(propagatedEvent: Optional) = + propagatedEvent(propagatedEvent.getOrNull()) + + /** Include these properties in every span created under this parent */ + fun propagatedEvent(propagatedEvent: JsonField) = apply { + this.propagatedEvent = propagatedEvent + } + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: Optional) = rowIds(rowIds.getOrNull()) + + /** Identifiers for the row to to log a subspan under */ + fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): SpanParentStruct = + SpanParentStruct( + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + propagatedEvent, + rowIds, + additionalProperties.toImmutable(), + ) + } + + 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 PROJECT_LOGS = of("project_logs") + + @JvmField val EXPERIMENT = of("experiment") + + @JvmField val PLAYGROUND_LOGS = of("playground_logs") + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + /** An enum containing [ObjectType]'s known values. */ + enum class Known { + PROJECT_LOGS, + EXPERIMENT, + PLAYGROUND_LOGS, + } + + /** + * 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 { + PROJECT_LOGS, + EXPERIMENT, + PLAYGROUND_LOGS, + /** + * 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) { + PROJECT_LOGS -> Value.PROJECT_LOGS + EXPERIMENT -> Value.EXPERIMENT + PLAYGROUND_LOGS -> Value.PLAYGROUND_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) { + PROJECT_LOGS -> Known.PROJECT_LOGS + EXPERIMENT -> Known.EXPERIMENT + PLAYGROUND_LOGS -> Known.PLAYGROUND_LOGS + 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() + } + + /** Include these properties in every span created under this parent */ + @NoAutoDetect + class PropagatedEvent + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PropagatedEvent = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PropagatedEvent]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PropagatedEvent]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(propagatedEvent: PropagatedEvent) = apply { + additionalProperties = propagatedEvent.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): PropagatedEvent = + PropagatedEvent(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PropagatedEvent && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PropagatedEvent{additionalProperties=$additionalProperties}" + } + + /** Identifiers for the row to to log a subspan under */ + @NoAutoDetect + class RowIds + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("root_span_id") + @ExcludeMissing + private val rootSpanId: JsonField = JsonMissing.of(), + @JsonProperty("span_id") + @ExcludeMissing + private val spanId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The id of the row */ + fun id(): String = id.getRequired("id") + + /** The root_span_id of the row */ + fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") + + /** The span_id of the row */ + fun spanId(): String = spanId.getRequired("span_id") + + /** The id of the row */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The root_span_id of the row */ + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId(): JsonField = rootSpanId + + /** The span_id of the row */ + @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): RowIds = apply { + if (validated) { + return@apply + } + + id() + rootSpanId() + spanId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RowIds]. + * + * The following fields are required: + * ```java + * .id() + * .rootSpanId() + * .spanId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RowIds]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var rootSpanId: JsonField? = null + private var spanId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rowIds: RowIds) = apply { + id = rowIds.id + rootSpanId = rowIds.rootSpanId + spanId = rowIds.spanId + additionalProperties = rowIds.additionalProperties.toMutableMap() + } + + /** The id of the row */ + fun id(id: String) = id(JsonField.of(id)) + + /** The id of the row */ + fun id(id: JsonField) = apply { this.id = id } + + /** The root_span_id of the row */ + fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) + + /** The root_span_id of the row */ + fun rootSpanId(rootSpanId: JsonField) = apply { + this.rootSpanId = rootSpanId + } + + /** The span_id of the row */ + fun spanId(spanId: String) = spanId(JsonField.of(spanId)) + + /** The span_id of the row */ + fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): RowIds = + RowIds( + checkRequired("id", id), + checkRequired("rootSpanId", rootSpanId), + checkRequired("spanId", spanId), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RowIds && id == other.id && rootSpanId == other.rootSpanId && spanId == other.spanId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, rootSpanId, spanId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RowIds{id=$id, rootSpanId=$rootSpanId, spanId=$spanId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SpanParentStruct && objectId == other.objectId && objectType == other.objectType && propagatedEvent == other.propagatedEvent && rowIds == other.rowIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, propagatedEvent, rowIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpanParentStruct{objectId=$objectId, objectType=$objectType, propagatedEvent=$propagatedEvent, rowIds=$rowIds, additionalProperties=$additionalProperties}" + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index e49339eb..d05a1609 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.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 @@ -48,9 +46,6 @@ private constructor( @JsonProperty("context") @ExcludeMissing private val context: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") - @ExcludeMissing - private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), @@ -65,7 +60,7 @@ private constructor( private val metrics: JsonField = JsonMissing.of(), @JsonProperty("origin") @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), @JsonProperty("scores") @ExcludeMissing @@ -121,13 +116,6 @@ private constructor( */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) - /** The error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error @@ -169,7 +157,7 @@ private constructor( fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** Indicates the event was copied from another object. */ - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** * The output of your application, including post-processing (an arbitrary, JSON serializable @@ -246,14 +234,6 @@ private constructor( */ @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun _datasetRecordId(): JsonField = datasetRecordId - /** Whether this span is a root span */ @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot @@ -274,7 +254,7 @@ private constructor( @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety @@ -322,7 +302,6 @@ private constructor( rootSpanId() spanId() context().ifPresent { it.validate() } - datasetRecordId() isRoot() metadata().ifPresent { it.validate() } metrics().ifPresent { it.validate() } @@ -366,14 +345,13 @@ private constructor( private var rootSpanId: JsonField? = null private var spanId: JsonField? = null private var context: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() private var error: JsonValue = JsonMissing.of() private var expected: JsonValue = JsonMissing.of() private var input: JsonValue = JsonMissing.of() private var isRoot: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var output: JsonValue = JsonMissing.of() private var scores: JsonField = JsonMissing.of() private var spanAttributes: JsonField = JsonMissing.of() @@ -391,7 +369,6 @@ private constructor( rootSpanId = experimentEvent.rootSpanId spanId = experimentEvent.spanId context = experimentEvent.context - datasetRecordId = experimentEvent.datasetRecordId error = experimentEvent.error expected = experimentEvent.expected input = experimentEvent.input @@ -494,28 +471,6 @@ private constructor( */ fun context(context: JsonField) = apply { this.context = context } - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: String?) = - datasetRecordId(JsonField.ofNullable(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.getOrNull()) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - /** The error that occurred, if any. */ fun error(error: JsonValue) = apply { this.error = error } @@ -598,13 +553,13 @@ private constructor( fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ - fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.getOrNull()) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = apply { this.origin = origin } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -737,7 +692,6 @@ private constructor( checkRequired("rootSpanId", rootSpanId), checkRequired("spanId", spanId), context, - datasetRecordId, error, expected, input, @@ -941,10 +895,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -956,6 +919,7 @@ private constructor( return@apply } + model() validated = true } @@ -970,13 +934,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -996,7 +971,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1004,16 +979,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } /** @@ -1356,307 +1332,6 @@ private constructor( "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } - /** Indicates the event was copied from another object. */ - @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** ID of the original event. */ - fun id(): String = id.getRequired("id") - - /** Transaction ID of the original event. */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Origin = apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Origin]. - * - * The following fields are required: - * ```java - * .id() - * ._xactId() - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Origin]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var _xactId: JsonField? = null - private var objectId: JsonField? = null - private var objectType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } - - /** ID of the original event. */ - fun id(id: String) = id(JsonField.of(id)) - - /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Origin = - Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), - ) - } - - /** Type of the object the event is originating from. */ - 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 EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val FUNCTION = of("function") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val PROJECT_LOGS = of("project_logs") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - } - - /** - * 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 { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - /** - * 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) { - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - FUNCTION -> Value.FUNCTION - PROMPT_SESSION -> Value.PROMPT_SESSION - PROJECT_LOGS -> Value.PROJECT_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) { - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - FUNCTION -> Known.FUNCTION - PROMPT_SESSION -> Known.PROMPT_SESSION - PROJECT_LOGS -> Known.PROJECT_LOGS - 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 - } - - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" - } - /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety * of signals that help you determine how accurate the outputs are compared to what you expect @@ -1750,15 +1425,15 @@ private constructor( return true } - return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExperimentEvent && id == other.id && _xactId == other._xactId && created == other.created && experimentId == other.experimentId && projectId == other.projectId && rootSpanId == other.rootSpanId && spanId == other.spanId && context == other.context && error == other.error && expected == other.expected && input == other.input && isRoot == other.isRoot && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && scores == other.scores && spanAttributes == other.spanAttributes && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, experimentId, projectId, rootSpanId, spanId, context, datasetRecordId, error, expected, input, isRoot, metadata, metrics, origin, output, scores, spanAttributes, spanParents, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _xactId, created, experimentId, projectId, rootSpanId, spanId, context, error, expected, input, isRoot, metadata, metrics, origin, output, scores, spanAttributes, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + "ExperimentEvent{id=$id, _xactId=$_xactId, created=$created, experimentId=$experimentId, projectId=$projectId, rootSpanId=$rootSpanId, spanId=$spanId, context=$context, error=$error, expected=$expected, input=$input, isRoot=$isRoot, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, scores=$scores, spanAttributes=$spanAttributes, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 2792f617..4cdd84ba 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -46,12 +46,18 @@ private constructor( /** Function id */ fun functionId(): String = functionId + /** The expected output of the function */ + fun _expected(): JsonValue = body._expected() + /** Argument to the function, which can be any JSON serializable value */ fun _input(): JsonValue = body._input() /** If the function is an LLM, additional messages to pass along to it */ fun messages(): Optional> = body.messages() + /** Any relevant metadata */ + fun metadata(): Optional = body.metadata() + /** The mode format of the returned value (defaults to 'auto') */ fun mode(): Optional = body.mode() @@ -70,6 +76,9 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun _messages(): JsonField> = body._messages() + /** Any relevant metadata */ + fun _metadata(): JsonField = body._metadata() + /** The mode format of the returned value (defaults to 'auto') */ fun _mode(): JsonField = body._mode() @@ -109,10 +118,16 @@ private constructor( class Body @JsonCreator private constructor( + @JsonProperty("expected") + @ExcludeMissing + private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), @JsonProperty("messages") @ExcludeMissing private val messages: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonProperty("mode") @ExcludeMissing private val mode: JsonField = JsonMissing.of(), @JsonProperty("parent") @ExcludeMissing @@ -127,6 +142,9 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The expected output of the function */ + @JsonProperty("expected") @ExcludeMissing fun _expected(): JsonValue = expected + /** Argument to the function, which can be any JSON serializable value */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input @@ -134,6 +152,9 @@ private constructor( fun messages(): Optional> = Optional.ofNullable(messages.getNullable("messages")) + /** Any relevant metadata */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** The mode format of the returned value (defaults to 'auto') */ fun mode(): Optional = Optional.ofNullable(mode.getNullable("mode")) @@ -154,6 +175,9 @@ private constructor( @ExcludeMissing fun _messages(): JsonField> = messages + /** Any relevant metadata */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** The mode format of the returned value (defaults to 'auto') */ @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode @@ -181,6 +205,7 @@ private constructor( } messages().ifPresent { it.forEach { it.validate() } } + metadata().ifPresent { it.validate() } mode() parent().ifPresent { it.validate() } stream() @@ -199,8 +224,10 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var expected: JsonValue = JsonMissing.of() private var input: JsonValue = JsonMissing.of() private var messages: JsonField>? = null + private var metadata: JsonField = JsonMissing.of() private var mode: JsonField = JsonMissing.of() private var parent: JsonField = JsonMissing.of() private var stream: JsonField = JsonMissing.of() @@ -209,8 +236,10 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { + expected = body.expected input = body.input messages = body.messages.map { it.toMutableList() } + metadata = body.metadata mode = body.mode parent = body.parent stream = body.stream @@ -218,6 +247,9 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** The expected output of the function */ + fun expected(expected: JsonValue) = apply { this.expected = expected } + /** Argument to the function, which can be any JSON serializable value */ fun input(input: JsonValue) = apply { this.input = input } @@ -256,6 +288,15 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(fallback: Message.Fallback) = addMessage(Message.ofFallback(fallback)) + /** Any relevant metadata */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Any relevant metadata */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** Any relevant metadata */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Mode?) = mode(JsonField.ofNullable(mode)) @@ -329,8 +370,10 @@ private constructor( fun build(): Body = Body( + expected, input, (messages ?: JsonMissing.of()).map { it.toImmutable() }, + metadata, mode, parent, stream, @@ -344,17 +387,17 @@ private constructor( return true } - return /* spotless:off */ other is Body && input == other.input && messages == other.messages && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && expected == other.expected && input == other.input && messages == other.messages && metadata == other.metadata && mode == other.mode && parent == other.parent && stream == other.stream && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(input, messages, mode, parent, stream, version, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(expected, input, messages, metadata, mode, parent, stream, version, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{input=$input, messages=$messages, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" + "Body{expected=$expected, input=$input, messages=$messages, metadata=$metadata, mode=$mode, parent=$parent, stream=$stream, version=$version, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -392,6 +435,9 @@ private constructor( /** Function id */ fun functionId(functionId: String) = apply { this.functionId = functionId } + /** The expected output of the function */ + fun expected(expected: JsonValue) = apply { body.expected(expected) } + /** Argument to the function, which can be any JSON serializable value */ fun input(input: JsonValue) = apply { body.input(input) } @@ -422,6 +468,15 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun addMessage(fallback: Message.Fallback) = apply { body.addMessage(fallback) } + /** Any relevant metadata */ + fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + + /** Any relevant metadata */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** Any relevant metadata */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Mode?) = apply { body.mode(mode) } @@ -2716,6 +2771,86 @@ private constructor( } } + /** Any relevant metadata */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + /** The mode format of the returned value (defaults to 'auto') */ class Mode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3144,6 +3279,8 @@ private constructor( @JvmField val EXPERIMENT = of("experiment") + @JvmField val PLAYGROUND_LOGS = of("playground_logs") + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) } @@ -3151,6 +3288,7 @@ private constructor( enum class Known { PROJECT_LOGS, EXPERIMENT, + PLAYGROUND_LOGS, } /** @@ -3165,6 +3303,7 @@ private constructor( enum class Value { PROJECT_LOGS, EXPERIMENT, + PLAYGROUND_LOGS, /** * An enum member indicating that [ObjectType] was instantiated with an unknown * value. @@ -3183,6 +3322,7 @@ private constructor( when (this) { PROJECT_LOGS -> Value.PROJECT_LOGS EXPERIMENT -> Value.EXPERIMENT + PLAYGROUND_LOGS -> Value.PLAYGROUND_LOGS else -> Value._UNKNOWN } @@ -3199,6 +3339,7 @@ private constructor( when (this) { PROJECT_LOGS -> Known.PROJECT_LOGS EXPERIMENT -> Known.EXPERIMENT + PLAYGROUND_LOGS -> Known.PLAYGROUND_LOGS else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 1f55b477..2030ee1a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -216,7 +216,11 @@ private constructor( this.description = description } - fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + fun functionData(functionData: FunctionData?) = + functionData(JsonField.ofNullable(functionData)) + + fun functionData(functionData: Optional) = + functionData(functionData.getOrNull()) fun functionData(functionData: JsonField) = apply { this.functionData = functionData @@ -230,9 +234,6 @@ private constructor( fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) - fun functionData(nullableVariant: FunctionData.NullableVariant) = - functionData(FunctionData.ofNullableVariant(nullableVariant)) - /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -362,7 +363,10 @@ private constructor( /** Textual description of the prompt */ fun description(description: JsonField) = apply { body.description(description) } - fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + fun functionData(functionData: FunctionData?) = apply { body.functionData(functionData) } + + fun functionData(functionData: Optional) = + functionData(functionData.getOrNull()) fun functionData(functionData: JsonField) = apply { body.functionData(functionData) @@ -374,10 +378,6 @@ private constructor( fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } - fun functionData(nullableVariant: FunctionData.NullableVariant) = apply { - body.functionData(nullableVariant) - } - /** Name of the prompt */ fun name(name: String?) = apply { body.name(name) } @@ -541,7 +541,6 @@ private constructor( private val prompt: Prompt? = null, private val code: Code? = null, private val global: Global? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -551,24 +550,18 @@ private constructor( fun global(): Optional = Optional.ofNullable(global) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isPrompt(): Boolean = prompt != null fun isCode(): Boolean = code != null fun isGlobal(): Boolean = global != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asPrompt(): Prompt = prompt.getOrThrow("prompt") fun asCode(): Code = code.getOrThrow("code") fun asGlobal(): Global = global.getOrThrow("global") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -576,7 +569,6 @@ private constructor( prompt != null -> visitor.visitPrompt(prompt) code != null -> visitor.visitCode(code) global != null -> visitor.visitGlobal(global) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -601,10 +593,6 @@ private constructor( override fun visitGlobal(global: Global) { global.validate() } - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -615,17 +603,16 @@ private constructor( return true } - return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is FunctionData && prompt == other.prompt && code == other.code && global == other.global /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(prompt, code, global) /* spotless:on */ override fun toString(): String = when { prompt != null -> "FunctionData{prompt=$prompt}" code != null -> "FunctionData{code=$code}" global != null -> "FunctionData{global=$global}" - nullableVariant != null -> "FunctionData{nullableVariant=$nullableVariant}" _json != null -> "FunctionData{_unknown=$_json}" else -> throw IllegalStateException("Invalid FunctionData") } @@ -637,10 +624,6 @@ private constructor( @JvmStatic fun ofCode(code: Code) = FunctionData(code = code) @JvmStatic fun ofGlobal(global: Global) = FunctionData(global = global) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - FunctionData(nullableVariant = nullableVariant) } /** @@ -655,8 +638,6 @@ private constructor( fun visitGlobal(global: Global): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [FunctionData] to a value of type [T]. * @@ -689,10 +670,6 @@ private constructor( ?.let { return FunctionData(global = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionData(nullableVariant = it, _json = json) - } return FunctionData(_json = json) } @@ -709,7 +686,6 @@ private constructor( value.prompt != null -> generator.writeObject(value.prompt) value.code != null -> generator.writeObject(value.code) value.global != null -> generator.writeObject(value.global) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid FunctionData") } @@ -2310,88 +2286,6 @@ private constructor( override fun toString() = "Global{name=$name, type=$type, additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index c726e52b..95ab2268 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -45,6 +45,9 @@ private constructor( @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), @JsonProperty("root_span_id") @ExcludeMissing private val rootSpanId: JsonField = JsonMissing.of(), @@ -104,6 +107,10 @@ private constructor( Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -140,10 +147,13 @@ private constructor( */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -159,9 +169,9 @@ private constructor( fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -177,9 +187,9 @@ private constructor( fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -244,6 +254,10 @@ private constructor( fun __objectDelete(): JsonField = _objectDelete /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -271,10 +285,13 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -290,9 +307,9 @@ private constructor( @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -308,9 +325,9 @@ private constructor( @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -348,6 +365,7 @@ private constructor( _parentId() created() metadata().ifPresent { it.validate() } + origin().ifPresent { it.validate() } rootSpanId() spanId() spanParents() @@ -375,6 +393,7 @@ private constructor( private var expected: JsonValue = JsonMissing.of() private var input: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() private var spanId: JsonField = JsonMissing.of() private var spanParents: JsonField>? = null @@ -392,6 +411,7 @@ private constructor( expected = insertDatasetEvent.expected input = insertDatasetEvent.input metadata = insertDatasetEvent.metadata + origin = insertDatasetEvent.origin rootSpanId = insertDatasetEvent.rootSpanId spanId = insertDatasetEvent.spanId spanParents = insertDatasetEvent.spanParents.map { it.toMutableList() } @@ -571,6 +591,10 @@ private constructor( } /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -587,6 +611,10 @@ private constructor( fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -603,6 +631,10 @@ private constructor( fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -665,10 +697,19 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Indicates the event was copied from another object. */ + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.getOrNull()) + + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -685,9 +726,9 @@ private constructor( fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -704,9 +745,9 @@ private constructor( fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -723,9 +764,9 @@ private constructor( fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -742,9 +783,9 @@ private constructor( fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -761,9 +802,9 @@ private constructor( fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -780,9 +821,9 @@ private constructor( fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -799,9 +840,9 @@ private constructor( fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -818,9 +859,9 @@ private constructor( fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -839,9 +880,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -908,6 +949,7 @@ private constructor( expected, input, metadata, + origin, rootSpanId, spanId, (spanParents ?: JsonMissing.of()).map { it.toImmutable() }, @@ -927,10 +969,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -942,6 +993,7 @@ private constructor( return@apply } + model() validated = true } @@ -956,13 +1008,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -982,7 +1045,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -990,16 +1053,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1007,15 +1071,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertDatasetEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && created == other.created && expected == other.expected && input == other.input && metadata == other.metadata && origin == other.origin && rootSpanId == other.rootSpanId && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, created, expected, input, metadata, rootSpanId, spanId, spanParents, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, created, expected, input, metadata, origin, rootSpanId, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + "InsertDatasetEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, created=$created, expected=$expected, input=$input, metadata=$metadata, origin=$origin, rootSpanId=$rootSpanId, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 3b414e84..924c9baf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -43,9 +43,6 @@ private constructor( @JsonProperty("created") @ExcludeMissing private val created: JsonField = JsonMissing.of(), - @JsonProperty("dataset_record_id") - @ExcludeMissing - private val datasetRecordId: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing private val error: JsonValue = JsonMissing.of(), @JsonProperty("expected") @ExcludeMissing private val expected: JsonValue = JsonMissing.of(), @JsonProperty("input") @ExcludeMissing private val input: JsonValue = JsonMissing.of(), @@ -55,6 +52,9 @@ private constructor( @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), @JsonProperty("root_span_id") @ExcludeMissing @@ -121,6 +121,10 @@ private constructor( Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -146,13 +150,6 @@ private constructor( /** The timestamp the experiment event was created */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(): Optional = - Optional.ofNullable(datasetRecordId.getNullable("dataset_record_id")) - /** The error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing fun _error(): JsonValue = error @@ -190,6 +187,9 @@ private constructor( */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** * The output of your application, including post-processing (an arbitrary, JSON serializable * object), that allows you to determine whether the result is correct or not. For example, in @@ -200,9 +200,9 @@ private constructor( @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -233,9 +233,9 @@ private constructor( Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -251,9 +251,9 @@ private constructor( fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -318,6 +318,10 @@ private constructor( fun __objectDelete(): JsonField = _objectDelete /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -343,14 +347,6 @@ private constructor( /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun _datasetRecordId(): JsonField = datasetRecordId - /** * A dictionary with additional data about the test example, model outputs, or just about * anything else that's relevant, that you can use to help find and analyze examples later. For @@ -367,10 +363,13 @@ private constructor( */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -402,9 +401,9 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -420,9 +419,9 @@ private constructor( @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -460,9 +459,9 @@ private constructor( _parentId() context().ifPresent { it.validate() } created() - datasetRecordId() metadata().ifPresent { it.validate() } metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } rootSpanId() scores().ifPresent { it.validate() } spanAttributes().ifPresent { it.validate() } @@ -490,12 +489,12 @@ private constructor( private var _parentId: JsonField = JsonMissing.of() private var context: JsonField = JsonMissing.of() private var created: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() private var error: JsonValue = JsonMissing.of() private var expected: JsonValue = JsonMissing.of() private var input: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var output: JsonValue = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() private var scores: JsonField = JsonMissing.of() @@ -514,12 +513,12 @@ private constructor( _parentId = insertExperimentEvent._parentId context = insertExperimentEvent.context created = insertExperimentEvent.created - datasetRecordId = insertExperimentEvent.datasetRecordId error = insertExperimentEvent.error expected = insertExperimentEvent.expected input = insertExperimentEvent.input metadata = insertExperimentEvent.metadata metrics = insertExperimentEvent.metrics + origin = insertExperimentEvent.origin output = insertExperimentEvent.output rootSpanId = insertExperimentEvent.rootSpanId scores = insertExperimentEvent.scores @@ -702,6 +701,10 @@ private constructor( } /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -718,6 +721,10 @@ private constructor( fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -734,6 +741,10 @@ private constructor( fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -779,28 +790,6 @@ private constructor( /** The timestamp the experiment event was created */ fun created(created: JsonField) = apply { this.created = created } - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: String?) = - datasetRecordId(JsonField.ofNullable(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: Optional) = - datasetRecordId(datasetRecordId.getOrNull()) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - /** The error that occurred, if any. */ fun error(error: JsonValue) = apply { this.error = error } @@ -870,6 +859,15 @@ private constructor( */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + /** Indicates the event was copied from another object. */ + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.getOrNull()) + + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } + /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object), that allows you to determine whether the result is correct or not. @@ -880,9 +878,9 @@ private constructor( fun output(output: JsonValue) = apply { this.output = output } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -899,9 +897,9 @@ private constructor( fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -918,9 +916,9 @@ private constructor( fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -983,9 +981,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1002,9 +1000,9 @@ private constructor( fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1021,9 +1019,9 @@ private constructor( fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1040,9 +1038,9 @@ private constructor( fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1059,9 +1057,9 @@ private constructor( fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1078,9 +1076,9 @@ private constructor( fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1099,9 +1097,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1166,12 +1164,12 @@ private constructor( _parentId, context, created, - datasetRecordId, error, expected, input, metadata, metrics, + origin, output, rootSpanId, scores, @@ -1370,10 +1368,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1385,6 +1392,7 @@ private constructor( return@apply } + model() validated = true } @@ -1399,13 +1407,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1425,7 +1444,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1433,16 +1452,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } /** @@ -1878,15 +1898,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && datasetRecordId == other.datasetRecordId && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertExperimentEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, datasetRecordId, error, expected, input, metadata, metrics, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, error, expected, input, metadata, metrics, origin, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, datasetRecordId=$datasetRecordId, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + "InsertExperimentEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index abf02697..977fb221 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -52,6 +52,9 @@ private constructor( @JsonProperty("metrics") @ExcludeMissing private val metrics: JsonField = JsonMissing.of(), + @JsonProperty("origin") + @ExcludeMissing + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), @JsonProperty("root_span_id") @ExcludeMissing @@ -118,6 +121,10 @@ private constructor( Optional.ofNullable(_objectDelete.getNullable("_object_delete")) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -175,6 +182,9 @@ private constructor( */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) + /** Indicates the event was copied from another object. */ + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** * The output of your application, including post-processing (an arbitrary, JSON serializable * object), that allows you to determine whether the result is correct or not. For example, in @@ -185,9 +195,9 @@ private constructor( @JsonProperty("output") @ExcludeMissing fun _output(): JsonValue = output /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -218,9 +228,9 @@ private constructor( Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -236,9 +246,9 @@ private constructor( fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -303,6 +313,10 @@ private constructor( fun __objectDelete(): JsonField = _objectDelete /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -344,10 +358,13 @@ private constructor( */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics + /** Indicates the event was copied from another object. */ + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -379,9 +396,9 @@ private constructor( fun _spanAttributes(): JsonField = spanAttributes /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -397,9 +414,9 @@ private constructor( @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to \_parent_id. - * The span_id is a unique identifier describing the row's place in the a trace, and the - * root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and + * the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -439,6 +456,7 @@ private constructor( created() metadata().ifPresent { it.validate() } metrics().ifPresent { it.validate() } + origin().ifPresent { it.validate() } rootSpanId() scores().ifPresent { it.validate() } spanAttributes().ifPresent { it.validate() } @@ -471,6 +489,7 @@ private constructor( private var input: JsonValue = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var output: JsonValue = JsonMissing.of() private var rootSpanId: JsonField = JsonMissing.of() private var scores: JsonField = JsonMissing.of() @@ -494,6 +513,7 @@ private constructor( input = insertProjectLogsEvent.input metadata = insertProjectLogsEvent.metadata metrics = insertProjectLogsEvent.metrics + origin = insertProjectLogsEvent.origin output = insertProjectLogsEvent.output rootSpanId = insertProjectLogsEvent.rootSpanId scores = insertProjectLogsEvent.scores @@ -676,6 +696,10 @@ private constructor( } /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -692,6 +716,10 @@ private constructor( fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -708,6 +736,10 @@ private constructor( fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** + * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for + * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, + * `root_span_id`, and `span_parents` explicitly instead. + * * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking * hierarchical relationships are important for tracing (see the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). @@ -819,6 +851,15 @@ private constructor( */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + /** Indicates the event was copied from another object. */ + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) + + /** Indicates the event was copied from another object. */ + fun origin(origin: Optional) = origin(origin.getOrNull()) + + /** Indicates the event was copied from another object. */ + fun origin(origin: JsonField) = apply { this.origin = origin } + /** * The output of your application, including post-processing (an arbitrary, JSON * serializable object), that allows you to determine whether the result is correct or not. @@ -829,9 +870,9 @@ private constructor( fun output(output: JsonValue) = apply { this.output = output } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -848,9 +889,9 @@ private constructor( fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -867,9 +908,9 @@ private constructor( fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -932,9 +973,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -951,9 +992,9 @@ private constructor( fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -970,9 +1011,9 @@ private constructor( fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -989,9 +1030,9 @@ private constructor( fun spanId(spanId: JsonField) = apply { this.spanId = spanId } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1008,9 +1049,9 @@ private constructor( fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1027,9 +1068,9 @@ private constructor( fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1048,9 +1089,9 @@ private constructor( } /** - * Use span_id, root_span_id, and span_parents as a more explicit alternative to - * \_parent_id. The span_id is a unique identifier describing the row's place in the a - * trace, and the root_span_id is a unique identifier for the whole trace. See the + * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now + * deprecated. The span_id is a unique identifier describing the row's place in the a trace, + * and the root_span_id is a unique identifier for the whole trace. See the * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. * * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": @@ -1120,6 +1161,7 @@ private constructor( input, metadata, metrics, + origin, output, rootSpanId, scores, @@ -1318,10 +1360,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1333,6 +1384,7 @@ private constructor( return@apply } + model() validated = true } @@ -1347,13 +1399,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1373,7 +1436,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1381,16 +1444,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } /** @@ -1826,15 +1890,15 @@ private constructor( return true } - return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InsertProjectLogsEvent && id == other.id && _isMerge == other._isMerge && _mergePaths == other._mergePaths && _objectDelete == other._objectDelete && _parentId == other._parentId && context == other.context && created == other.created && error == other.error && expected == other.expected && input == other.input && metadata == other.metadata && metrics == other.metrics && origin == other.origin && output == other.output && rootSpanId == other.rootSpanId && scores == other.scores && spanAttributes == other.spanAttributes && spanId == other.spanId && spanParents == other.spanParents && tags == other.tags && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, error, expected, input, metadata, metrics, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, _isMerge, _mergePaths, _objectDelete, _parentId, context, created, error, expected, input, metadata, metrics, origin, output, rootSpanId, scores, spanAttributes, spanId, spanParents, tags, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" + "InsertProjectLogsEvent{id=$id, _isMerge=$_isMerge, _mergePaths=$_mergePaths, _objectDelete=$_objectDelete, _parentId=$_parentId, context=$context, created=$created, error=$error, expected=$expected, input=$input, metadata=$metadata, metrics=$metrics, origin=$origin, output=$output, rootSpanId=$rootSpanId, scores=$scores, spanAttributes=$spanAttributes, spanId=$spanId, spanParents=$spanParents, tags=$tags, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt new file mode 100644 index 00000000..9ebd640e --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt @@ -0,0 +1,339 @@ +// File generated from our OpenAPI spec by Stainless. + +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 +import com.braintrustdata.api.core.JsonValue +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 +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Indicates the event was copied from another object. */ +@NoAutoDetect +class ObjectReference +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("_xact_id") + @ExcludeMissing + private val _xactId: JsonField = JsonMissing.of(), + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + private val created: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** ID of the original event. */ + fun id(): String = id.getRequired("id") + + /** Transaction ID of the original event. */ + fun _xactId(): String = _xactId.getRequired("_xact_id") + + /** ID of the object the event is originating from. */ + fun objectId(): String = objectId.getRequired("object_id") + + /** Type of the object the event is originating from. */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** Created timestamp of the original event. Used to help sort in the UI */ + fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + + /** ID of the original event. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** Transaction ID of the original event. */ + @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + + /** ID of the object the event is originating from. */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** Type of the object the event is originating from. */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + /** Created timestamp of the original event. Used to help sort in the UI */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ObjectReference = apply { + if (validated) { + return@apply + } + + id() + _xactId() + objectId() + objectType() + created() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ObjectReference]. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .objectId() + * .objectType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ObjectReference]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var _xactId: JsonField? = null + private var objectId: JsonField? = null + private var objectType: JsonField? = null + private var created: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(objectReference: ObjectReference) = apply { + id = objectReference.id + _xactId = objectReference._xactId + objectId = objectReference.objectId + objectType = objectReference.objectType + created = objectReference.created + additionalProperties = objectReference.additionalProperties.toMutableMap() + } + + /** ID of the original event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** ID of the original event. */ + fun id(id: JsonField) = apply { this.id = id } + + /** Transaction ID of the original event. */ + fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) + + /** Transaction ID of the original event. */ + fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + + /** ID of the object the event is originating from. */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** ID of the object the event is originating from. */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** Type of the object the event is originating from. */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** Type of the object the event is originating from. */ + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + /** Created timestamp of the original event. Used to help sort in the UI */ + fun created(created: String?) = created(JsonField.ofNullable(created)) + + /** Created timestamp of the original event. Used to help sort in the UI */ + fun created(created: Optional) = created(created.getOrNull()) + + /** Created timestamp of the original event. Used to help sort in the UI */ + fun created(created: JsonField) = apply { this.created = created } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): ObjectReference = + ObjectReference( + checkRequired("id", id), + checkRequired("_xactId", _xactId), + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + created, + additionalProperties.toImmutable(), + ) + } + + /** Type of the object the event is originating from. */ + 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 EXPERIMENT = of("experiment") + + @JvmField val DATASET = of("dataset") + + @JvmField val PROMPT = of("prompt") + + @JvmField val FUNCTION = of("function") + + @JvmField val PROMPT_SESSION = of("prompt_session") + + @JvmField val PROJECT_LOGS = of("project_logs") + + @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) + } + + /** An enum containing [ObjectType]'s known values. */ + enum class Known { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + } + + /** + * 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 { + EXPERIMENT, + DATASET, + PROMPT, + FUNCTION, + PROMPT_SESSION, + PROJECT_LOGS, + /** + * 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) { + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + FUNCTION -> Value.FUNCTION + PROMPT_SESSION -> Value.PROMPT_SESSION + PROJECT_LOGS -> Value.PROJECT_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) { + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + FUNCTION -> Known.FUNCTION + PROMPT_SESSION -> Known.PROMPT_SESSION + PROJECT_LOGS -> Known.PROJECT_LOGS + 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 + } + + return /* spotless:off */ other is ObjectReference && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && created == other.created && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, created, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ObjectReference{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, created=$created, additionalProperties=$additionalProperties}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 94a6ee65..760777fa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -61,7 +61,7 @@ private constructor( private val metrics: JsonField = JsonMissing.of(), @JsonProperty("origin") @ExcludeMissing - private val origin: JsonField = JsonMissing.of(), + private val origin: JsonField = JsonMissing.of(), @JsonProperty("output") @ExcludeMissing private val output: JsonValue = JsonMissing.of(), @JsonProperty("scores") @ExcludeMissing @@ -156,7 +156,7 @@ private constructor( fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) /** Indicates the event was copied from another object. */ - fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** * The output of your application, including post-processing (an arbitrary, JSON serializable @@ -254,7 +254,7 @@ private constructor( @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics /** Indicates the event was copied from another object. */ - @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety @@ -354,7 +354,7 @@ private constructor( private var isRoot: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var metrics: JsonField = JsonMissing.of() - private var origin: JsonField = JsonMissing.of() + private var origin: JsonField = JsonMissing.of() private var output: JsonValue = JsonMissing.of() private var scores: JsonField = JsonMissing.of() private var spanAttributes: JsonField = JsonMissing.of() @@ -558,13 +558,13 @@ private constructor( fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ - fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) /** Indicates the event was copied from another object. */ - fun origin(origin: Optional) = origin(origin.getOrNull()) + fun origin(origin: Optional) = origin(origin.getOrNull()) /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = apply { this.origin = origin } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -1000,10 +1000,19 @@ private constructor( class Metadata @JsonCreator private constructor( + @JsonProperty("model") + @ExcludeMissing + private val model: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() + private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The model used for this example */ + fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + + /** The model used for this example */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -1015,6 +1024,7 @@ private constructor( return@apply } + model() validated = true } @@ -1029,13 +1039,24 @@ private constructor( /** A builder for [Metadata]. */ class Builder internal constructor() { + private var model: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { + model = metadata.model additionalProperties = metadata.additionalProperties.toMutableMap() } + /** The model used for this example */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** The model used for this example */ + fun model(model: Optional) = model(model.getOrNull()) + + /** The model used for this example */ + fun model(model: JsonField) = apply { this.model = model } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1055,7 +1076,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -1063,16 +1084,17 @@ private constructor( return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && model == other.model && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(model, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = + "Metadata{model=$model, additionalProperties=$additionalProperties}" } /** @@ -1415,307 +1437,6 @@ private constructor( "Metrics{callerFilename=$callerFilename, callerFunctionname=$callerFunctionname, callerLineno=$callerLineno, completionTokens=$completionTokens, end=$end, promptTokens=$promptTokens, start=$start, tokens=$tokens, additionalProperties=$additionalProperties}" } - /** Indicates the event was copied from another object. */ - @NoAutoDetect - class Origin - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("_xact_id") - @ExcludeMissing - private val _xactId: JsonField = JsonMissing.of(), - @JsonProperty("object_id") - @ExcludeMissing - private val objectId: JsonField = JsonMissing.of(), - @JsonProperty("object_type") - @ExcludeMissing - private val objectType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** ID of the original event. */ - fun id(): String = id.getRequired("id") - - /** Transaction ID of the original event. */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** ID of the object the event is originating from. */ - fun objectId(): String = objectId.getRequired("object_id") - - /** Type of the object the event is originating from. */ - fun objectType(): ObjectType = objectType.getRequired("object_type") - - /** ID of the original event. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** Transaction ID of the original event. */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - - /** ID of the object the event is originating from. */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - - /** Type of the object the event is originating from. */ - @JsonProperty("object_type") - @ExcludeMissing - fun _objectType(): JsonField = objectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Origin = apply { - if (validated) { - return@apply - } - - id() - _xactId() - objectId() - objectType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Origin]. - * - * The following fields are required: - * ```java - * .id() - * ._xactId() - * .objectId() - * .objectType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Origin]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var _xactId: JsonField? = null - private var objectId: JsonField? = null - private var objectType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(origin: Origin) = apply { - id = origin.id - _xactId = origin._xactId - objectId = origin.objectId - objectType = origin.objectType - additionalProperties = origin.additionalProperties.toMutableMap() - } - - /** ID of the original event. */ - fun id(id: String) = id(JsonField.of(id)) - - /** ID of the original event. */ - fun id(id: JsonField) = apply { this.id = id } - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - - /** Transaction ID of the original event. */ - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** ID of the object the event is originating from. */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** ID of the object the event is originating from. */ - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** Type of the object the event is originating from. */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** Type of the object the event is originating from. */ - fun objectType(objectType: JsonField) = apply { - this.objectType = objectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Origin = - Origin( - checkRequired("id", id), - checkRequired("_xactId", _xactId), - checkRequired("objectId", objectId), - checkRequired("objectType", objectType), - additionalProperties.toImmutable(), - ) - } - - /** Type of the object the event is originating from. */ - 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 EXPERIMENT = of("experiment") - - @JvmField val DATASET = of("dataset") - - @JvmField val PROMPT = of("prompt") - - @JvmField val FUNCTION = of("function") - - @JvmField val PROMPT_SESSION = of("prompt_session") - - @JvmField val PROJECT_LOGS = of("project_logs") - - @JvmStatic fun of(value: String) = ObjectType(JsonField.of(value)) - } - - /** An enum containing [ObjectType]'s known values. */ - enum class Known { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - } - - /** - * 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 { - EXPERIMENT, - DATASET, - PROMPT, - FUNCTION, - PROMPT_SESSION, - PROJECT_LOGS, - /** - * 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) { - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - FUNCTION -> Value.FUNCTION - PROMPT_SESSION -> Value.PROMPT_SESSION - PROJECT_LOGS -> Value.PROJECT_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) { - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - FUNCTION -> Known.FUNCTION - PROMPT_SESSION -> Known.PROMPT_SESSION - PROJECT_LOGS -> Known.PROJECT_LOGS - 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 - } - - return /* spotless:off */ other is Origin && id == other.id && _xactId == other._xactId && objectId == other.objectId && objectType == other.objectType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, _xactId, objectId, objectType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Origin{id=$id, _xactId=$_xactId, objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" - } - /** * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety * of signals that help you determine how accurate the outputs are compared to what you expect 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 6144049c..fd3e6e1c 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 @@ -227,7 +227,10 @@ private constructor( fun userId(userId: JsonField) = apply { this.userId = userId } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = categories(JsonField.of(categories)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { this.categories = categories } @@ -242,10 +245,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) - fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) @@ -341,6 +340,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } @@ -352,6 +353,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -370,6 +372,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ScoreType] was instantiated with an unknown value. */ @@ -391,6 +394,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -411,6 +415,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } @@ -449,7 +454,6 @@ private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -462,16 +466,12 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null fun isMinimum(): Boolean = minimum != null - fun isNullableVariant(): Boolean = nullableVariant != null - /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") @@ -481,8 +481,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -490,7 +488,6 @@ private constructor( categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -513,10 +510,6 @@ private constructor( } override fun visitMinimum(minimum: List) {} - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -527,17 +520,16 @@ private constructor( return true } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum) /* spotless:on */ override fun toString(): String = when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } @@ -554,10 +546,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) } /** @@ -574,8 +562,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Categories] to a value of type [T]. * @@ -609,10 +595,6 @@ private constructor( tryDeserialize(node, jacksonTypeRef>())?.let { return Categories(minimum = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } return Categories(_json = json) } @@ -629,7 +611,6 @@ private constructor( value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") } @@ -718,88 +699,6 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 82cf7754..c612a666 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.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 ProjectScoreConfig private constructor( @JsonProperty("destination") @ExcludeMissing - private val destination: JsonField = JsonMissing.of(), + private val destination: JsonField = JsonMissing.of(), @JsonProperty("multi_select") @ExcludeMissing private val multiSelect: JsonField = JsonMissing.of(), @@ -35,7 +33,7 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun destination(): Optional = + fun destination(): Optional = Optional.ofNullable(destination.getNullable("destination")) fun multiSelect(): Optional = @@ -43,9 +41,7 @@ private constructor( fun online(): Optional = Optional.ofNullable(online.getNullable("online")) - @JsonProperty("destination") - @ExcludeMissing - fun _destination(): JsonField = destination + @JsonProperty("destination") @ExcludeMissing fun _destination(): JsonField = destination @JsonProperty("multi_select") @ExcludeMissing @@ -81,7 +77,7 @@ private constructor( /** A builder for [ProjectScoreConfig]. */ class Builder internal constructor() { - private var destination: JsonField = JsonMissing.of() + private var destination: JsonField = JsonMissing.of() private var multiSelect: JsonField = JsonMissing.of() private var online: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -94,13 +90,11 @@ private constructor( additionalProperties = projectScoreConfig.additionalProperties.toMutableMap() } - fun destination(destination: Destination?) = destination(JsonField.ofNullable(destination)) + fun destination(destination: String?) = destination(JsonField.ofNullable(destination)) - fun destination(destination: Optional) = destination(destination.getOrNull()) + fun destination(destination: Optional) = destination(destination.getOrNull()) - fun destination(destination: JsonField) = apply { - this.destination = destination - } + fun destination(destination: JsonField) = apply { this.destination = destination } fun multiSelect(multiSelect: Boolean?) = multiSelect(JsonField.ofNullable(multiSelect)) @@ -139,103 +133,6 @@ private constructor( ProjectScoreConfig(destination, multiSelect, online, additionalProperties.toImmutable()) } - class Destination @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 EXPECTED = of("expected") - - @JvmStatic fun of(value: String) = Destination(JsonField.of(value)) - } - - /** An enum containing [Destination]'s known values. */ - enum class Known { - EXPECTED - } - - /** - * An enum containing [Destination]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Destination] 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 { - EXPECTED, - /** - * An enum member indicating that [Destination] 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) { - EXPECTED -> Value.EXPECTED - 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) { - EXPECTED -> Known.EXPECTED - else -> throw BraintrustInvalidDataException("Unknown Destination: $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 Destination && 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/ProjectScoreCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt index 49401ff2..51091ebd 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 @@ -240,7 +240,10 @@ private constructor( fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = categories(JsonField.of(categories)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { @@ -259,10 +262,6 @@ private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) - fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) @@ -380,7 +379,10 @@ private constructor( 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) } + fun categories(categories: Categories?) = apply { body.categories(categories) } + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { body.categories(categories) } @@ -396,11 +398,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) @@ -568,6 +565,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } @@ -579,6 +578,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -597,6 +597,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ScoreType] was instantiated with an unknown value. */ @@ -618,6 +619,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -638,6 +640,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } @@ -676,7 +679,6 @@ private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -689,16 +691,12 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null fun isMinimum(): Boolean = minimum != null - fun isNullableVariant(): Boolean = nullableVariant != null - /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") @@ -708,8 +706,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -717,7 +713,6 @@ private constructor( categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -740,10 +735,6 @@ private constructor( } override fun visitMinimum(minimum: List) {} - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -754,17 +745,16 @@ private constructor( return true } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum) /* spotless:on */ override fun toString(): String = when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } @@ -781,10 +771,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) } /** @@ -801,8 +787,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Categories] to a value of type [T]. * @@ -836,10 +820,6 @@ private constructor( tryDeserialize(node, jacksonTypeRef>())?.let { return Categories(minimum = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } return Categories(_json = json) } @@ -856,7 +836,6 @@ private constructor( value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") } @@ -945,88 +924,6 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { 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 6f86bc5e..2899a11f 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 @@ -641,6 +641,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) } @@ -652,6 +654,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -671,6 +674,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ProjectScoreType] was instantiated with an * unknown value. @@ -693,6 +697,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -713,6 +718,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") } @@ -772,6 +778,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ProjectScoreType(JsonField.of(value)) } @@ -783,6 +791,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -802,6 +811,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ProjectScoreType] was instantiated with an * unknown value. @@ -824,6 +834,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -844,6 +855,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ProjectScoreType: $value") } 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 8373825d..c4ef2e87 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 @@ -241,7 +241,10 @@ private constructor( fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = categories(JsonField.of(categories)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { @@ -260,10 +263,6 @@ private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) - fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) @@ -381,7 +380,10 @@ private constructor( 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) } + fun categories(categories: Categories?) = apply { body.categories(categories) } + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { body.categories(categories) } @@ -397,11 +399,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) @@ -569,6 +566,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } @@ -580,6 +579,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -598,6 +598,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ScoreType] was instantiated with an unknown value. */ @@ -619,6 +620,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -639,6 +641,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } @@ -677,7 +680,6 @@ private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -690,16 +692,12 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null fun isMinimum(): Boolean = minimum != null - fun isNullableVariant(): Boolean = nullableVariant != null - /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") @@ -709,8 +707,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -718,7 +714,6 @@ private constructor( categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -741,10 +736,6 @@ private constructor( } override fun visitMinimum(minimum: List) {} - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -755,17 +746,16 @@ private constructor( return true } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum) /* spotless:on */ override fun toString(): String = when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } @@ -782,10 +772,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) } /** @@ -802,8 +788,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Categories] to a value of type [T]. * @@ -837,10 +821,6 @@ private constructor( tryDeserialize(node, jacksonTypeRef>())?.let { return Categories(minimum = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } return Categories(_json = json) } @@ -857,7 +837,6 @@ private constructor( value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") } @@ -946,88 +925,6 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } override fun equals(other: Any?): Boolean { 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 4784736c..6813268c 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 @@ -208,7 +208,10 @@ private constructor( } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = categories(JsonField.of(categories)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { @@ -227,10 +230,6 @@ private constructor( fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = - categories(Categories.ofNullableVariant(nullableVariant)) - fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) fun config(config: Optional) = config(config.getOrNull()) @@ -350,7 +349,10 @@ private constructor( fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { body.categories(categories) } + fun categories(categories: Categories?) = apply { body.categories(categories) } + + /** For categorical-type project scores, the list of all categories */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** For categorical-type project scores, the list of all categories */ fun categories(categories: JsonField) = apply { body.categories(categories) } @@ -366,11 +368,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } - /** For categorical-type project scores, the list of all categories */ - fun categories(nullableVariant: Categories.NullableVariant) = apply { - body.categories(nullableVariant) - } - fun config(config: ProjectScoreConfig?) = apply { body.config(config) } fun config(config: Optional) = config(config.getOrNull()) @@ -538,7 +535,6 @@ private constructor( private val categorical: List? = null, private val weighted: Weighted? = null, private val minimum: List? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -551,16 +547,12 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun minimum(): Optional> = Optional.ofNullable(minimum) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCategorical(): Boolean = categorical != null fun isWeighted(): Boolean = weighted != null fun isMinimum(): Boolean = minimum != null - fun isNullableVariant(): Boolean = nullableVariant != null - /** For categorical-type project scores, the list of all categories */ fun asCategorical(): List = categorical.getOrThrow("categorical") @@ -570,8 +562,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun asMinimum(): List = minimum.getOrThrow("minimum") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -579,7 +569,6 @@ private constructor( categorical != null -> visitor.visitCategorical(categorical) weighted != null -> visitor.visitWeighted(weighted) minimum != null -> visitor.visitMinimum(minimum) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -602,10 +591,6 @@ private constructor( } override fun visitMinimum(minimum: List) {} - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -616,17 +601,16 @@ private constructor( return true } - return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Categories && categorical == other.categorical && weighted == other.weighted && minimum == other.minimum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(categorical, weighted, minimum) /* spotless:on */ override fun toString(): String = when { categorical != null -> "Categories{categorical=$categorical}" weighted != null -> "Categories{weighted=$weighted}" minimum != null -> "Categories{minimum=$minimum}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" _json != null -> "Categories{_unknown=$_json}" else -> throw IllegalStateException("Invalid Categories") } @@ -643,10 +627,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ @JvmStatic fun ofMinimum(minimum: List) = Categories(minimum = minimum) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) } /** @@ -663,8 +643,6 @@ private constructor( /** For minimum-type project scores, the list of included scores */ fun visitMinimum(minimum: List): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Categories] to a value of type [T]. * @@ -698,10 +676,6 @@ private constructor( tryDeserialize(node, jacksonTypeRef>())?.let { return Categories(minimum = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } return Categories(_json = json) } @@ -718,7 +692,6 @@ private constructor( value.categorical != null -> generator.writeObject(value.categorical) value.weighted != null -> generator.writeObject(value.weighted) value.minimum != null -> generator.writeObject(value.minimum) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Categories") } @@ -807,88 +780,6 @@ private constructor( override fun toString() = "Weighted{additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } /** The type of the configured score */ @@ -918,6 +809,8 @@ private constructor( @JvmField val ONLINE = of("online") + @JvmField val FREE_FORM = of("free-form") + @JvmStatic fun of(value: String) = ScoreType(JsonField.of(value)) } @@ -929,6 +822,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, } /** @@ -947,6 +841,7 @@ private constructor( MINIMUM, MAXIMUM, ONLINE, + FREE_FORM, /** * An enum member indicating that [ScoreType] was instantiated with an unknown value. */ @@ -968,6 +863,7 @@ private constructor( MINIMUM -> Value.MINIMUM MAXIMUM -> Value.MAXIMUM ONLINE -> Value.ONLINE + FREE_FORM -> Value.FREE_FORM else -> Value._UNKNOWN } @@ -988,6 +884,7 @@ private constructor( MINIMUM -> Known.MINIMUM MAXIMUM -> Known.MAXIMUM ONLINE -> Known.ONLINE + FREE_FORM -> Known.FREE_FORM else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index 9c9bfe47..6a1912e4 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -2,13 +2,17 @@ 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 import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.NoAutoDetect +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 @@ -21,21 +25,45 @@ import kotlin.jvm.optionals.getOrNull class ProjectSettings @JsonCreator private constructor( + @JsonProperty("baseline_experiment_id") + @ExcludeMissing + private val baselineExperimentId: JsonField = JsonMissing.of(), @JsonProperty("comparison_key") @ExcludeMissing private val comparisonKey: JsonField = JsonMissing.of(), + @JsonProperty("spanFieldOrder") + @ExcludeMissing + private val spanFieldOrder: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The key used to join two experiments (defaults to `input`). */ + /** The id of the experiment to use as the default baseline for comparisons */ + fun baselineExperimentId(): Optional = + Optional.ofNullable(baselineExperimentId.getNullable("baseline_experiment_id")) + + /** The key used to join two experiments (defaults to `input`) */ fun comparisonKey(): Optional = Optional.ofNullable(comparisonKey.getNullable("comparison_key")) - /** The key used to join two experiments (defaults to `input`). */ + /** The order of the fields to display in the trace view */ + fun spanFieldOrder(): Optional> = + Optional.ofNullable(spanFieldOrder.getNullable("spanFieldOrder")) + + /** The id of the experiment to use as the default baseline for comparisons */ + @JsonProperty("baseline_experiment_id") + @ExcludeMissing + fun _baselineExperimentId(): JsonField = baselineExperimentId + + /** The key used to join two experiments (defaults to `input`) */ @JsonProperty("comparison_key") @ExcludeMissing fun _comparisonKey(): JsonField = comparisonKey + /** The order of the fields to display in the trace view */ + @JsonProperty("spanFieldOrder") + @ExcludeMissing + fun _spanFieldOrder(): JsonField> = spanFieldOrder + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -47,7 +75,9 @@ private constructor( return@apply } + baselineExperimentId() comparisonKey() + spanFieldOrder().ifPresent { it.forEach { it.validate() } } validated = true } @@ -62,28 +92,66 @@ private constructor( /** A builder for [ProjectSettings]. */ class Builder internal constructor() { + private var baselineExperimentId: JsonField = JsonMissing.of() private var comparisonKey: JsonField = JsonMissing.of() + private var spanFieldOrder: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(projectSettings: ProjectSettings) = apply { + baselineExperimentId = projectSettings.baselineExperimentId comparisonKey = projectSettings.comparisonKey + spanFieldOrder = projectSettings.spanFieldOrder.map { it.toMutableList() } additionalProperties = projectSettings.additionalProperties.toMutableMap() } - /** The key used to join two experiments (defaults to `input`). */ + /** The id of the experiment to use as the default baseline for comparisons */ + fun baselineExperimentId(baselineExperimentId: String?) = + baselineExperimentId(JsonField.ofNullable(baselineExperimentId)) + + /** The id of the experiment to use as the default baseline for comparisons */ + fun baselineExperimentId(baselineExperimentId: Optional) = + baselineExperimentId(baselineExperimentId.getOrNull()) + + /** The id of the experiment to use as the default baseline for comparisons */ + fun baselineExperimentId(baselineExperimentId: JsonField) = apply { + this.baselineExperimentId = baselineExperimentId + } + + /** The key used to join two experiments (defaults to `input`) */ fun comparisonKey(comparisonKey: String?) = comparisonKey(JsonField.ofNullable(comparisonKey)) - /** The key used to join two experiments (defaults to `input`). */ + /** The key used to join two experiments (defaults to `input`) */ fun comparisonKey(comparisonKey: Optional) = comparisonKey(comparisonKey.getOrNull()) - /** The key used to join two experiments (defaults to `input`). */ + /** The key used to join two experiments (defaults to `input`) */ fun comparisonKey(comparisonKey: JsonField) = apply { this.comparisonKey = comparisonKey } + /** The order of the fields to display in the trace view */ + fun spanFieldOrder(spanFieldOrder: List?) = + spanFieldOrder(JsonField.ofNullable(spanFieldOrder)) + + /** The order of the fields to display in the trace view */ + fun spanFieldOrder(spanFieldOrder: Optional>) = + spanFieldOrder(spanFieldOrder.getOrNull()) + + /** The order of the fields to display in the trace view */ + fun spanFieldOrder(spanFieldOrder: JsonField>) = apply { + this.spanFieldOrder = spanFieldOrder.map { it.toMutableList() } + } + + /** The order of the fields to display in the trace view */ + fun addSpanFieldOrder(spanFieldOrder: SpanFieldOrder) = apply { + this.spanFieldOrder = + (this.spanFieldOrder ?: JsonField.of(mutableListOf())).also { + checkKnown("spanFieldOrder", it).add(spanFieldOrder) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -104,7 +172,270 @@ private constructor( } fun build(): ProjectSettings = - ProjectSettings(comparisonKey, additionalProperties.toImmutable()) + ProjectSettings( + baselineExperimentId, + comparisonKey, + (spanFieldOrder ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class SpanFieldOrder + @JsonCreator + private constructor( + @JsonProperty("column_id") + @ExcludeMissing + private val columnId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("position") + @ExcludeMissing + private val position: JsonField = JsonMissing.of(), + @JsonProperty("layout") + @ExcludeMissing + private val layout: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun columnId(): String = columnId.getRequired("column_id") + + fun objectType(): String = objectType.getRequired("object_type") + + fun position(): String = position.getRequired("position") + + fun layout(): Optional = Optional.ofNullable(layout.getNullable("layout")) + + @JsonProperty("column_id") @ExcludeMissing fun _columnId(): JsonField = columnId + + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + @JsonProperty("layout") @ExcludeMissing fun _layout(): JsonField = layout + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SpanFieldOrder = apply { + if (validated) { + return@apply + } + + columnId() + objectType() + position() + layout() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SpanFieldOrder]. + * + * The following fields are required: + * ```java + * .columnId() + * .objectType() + * .position() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpanFieldOrder]. */ + class Builder internal constructor() { + + private var columnId: JsonField? = null + private var objectType: JsonField? = null + private var position: JsonField? = null + private var layout: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(spanFieldOrder: SpanFieldOrder) = apply { + columnId = spanFieldOrder.columnId + objectType = spanFieldOrder.objectType + position = spanFieldOrder.position + layout = spanFieldOrder.layout + additionalProperties = spanFieldOrder.additionalProperties.toMutableMap() + } + + fun columnId(columnId: String) = columnId(JsonField.of(columnId)) + + fun columnId(columnId: JsonField) = apply { this.columnId = columnId } + + fun objectType(objectType: String) = objectType(JsonField.of(objectType)) + + fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + + fun position(position: String) = position(JsonField.of(position)) + + fun position(position: JsonField) = apply { this.position = position } + + fun layout(layout: Layout?) = layout(JsonField.ofNullable(layout)) + + fun layout(layout: Optional) = layout(layout.getOrNull()) + + fun layout(layout: JsonField) = apply { this.layout = layout } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): SpanFieldOrder = + SpanFieldOrder( + checkRequired("columnId", columnId), + checkRequired("objectType", objectType), + checkRequired("position", position), + layout, + additionalProperties.toImmutable(), + ) + } + + class Layout @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 FULL = of("full") + + @JvmField val TWO_COLUMN = of("two_column") + + @JvmStatic fun of(value: String) = Layout(JsonField.of(value)) + } + + /** An enum containing [Layout]'s known values. */ + enum class Known { + FULL, + TWO_COLUMN, + } + + /** + * An enum containing [Layout]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Layout] 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 { + FULL, + TWO_COLUMN, + /** + * An enum member indicating that [Layout] 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) { + FULL -> Value.FULL + TWO_COLUMN -> Value.TWO_COLUMN + 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) { + FULL -> Known.FULL + TWO_COLUMN -> Known.TWO_COLUMN + else -> throw BraintrustInvalidDataException("Unknown Layout: $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 Layout && 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 + } + + return /* spotless:off */ other is SpanFieldOrder && columnId == other.columnId && objectType == other.objectType && position == other.position && layout == other.layout && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(columnId, objectType, position, layout, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SpanFieldOrder{columnId=$columnId, objectType=$objectType, position=$position, layout=$layout, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -112,15 +443,15 @@ private constructor( return true } - return /* spotless:off */ other is ProjectSettings && comparisonKey == other.comparisonKey && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ProjectSettings && baselineExperimentId == other.baselineExperimentId && comparisonKey == other.comparisonKey && spanFieldOrder == other.spanFieldOrder && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(comparisonKey, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(baselineExperimentId, comparisonKey, spanFieldOrder, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ProjectSettings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + "ProjectSettings{baselineExperimentId=$baselineExperimentId, comparisonKey=$comparisonKey, spanFieldOrder=$spanFieldOrder, additionalProperties=$additionalProperties}" } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index c9faaa96..cd072c2a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -142,7 +142,9 @@ private constructor( fun parser(parser: JsonField) = apply { this.parser = parser } - fun prompt(prompt: Prompt) = prompt(JsonField.of(prompt)) + fun prompt(prompt: Prompt?) = prompt(JsonField.ofNullable(prompt)) + + fun prompt(prompt: Optional) = prompt(prompt.getOrNull()) fun prompt(prompt: JsonField) = apply { this.prompt = prompt } @@ -150,9 +152,6 @@ private constructor( fun prompt(chat: Prompt.Chat) = prompt(Prompt.ofChat(chat)) - fun prompt(nullableVariant: Prompt.NullableVariant) = - prompt(Prompt.ofNullableVariant(nullableVariant)) - fun toolFunctions(toolFunctions: List?) = toolFunctions(JsonField.ofNullable(toolFunctions)) @@ -655,7 +654,6 @@ private constructor( private constructor( private val completion: Completion? = null, private val chat: Chat? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -663,27 +661,20 @@ private constructor( fun chat(): Optional = Optional.ofNullable(chat) - fun nullableVariant(): Optional = Optional.ofNullable(nullableVariant) - fun isCompletion(): Boolean = completion != null fun isChat(): Boolean = chat != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asCompletion(): Completion = completion.getOrThrow("completion") fun asChat(): Chat = chat.getOrThrow("chat") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { completion != null -> visitor.visitCompletion(completion) chat != null -> visitor.visitChat(chat) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -704,10 +695,6 @@ private constructor( override fun visitChat(chat: Chat) { chat.validate() } - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -718,16 +705,15 @@ private constructor( return true } - return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is Prompt && completion == other.completion && chat == other.chat /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(completion, chat, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(completion, chat) /* spotless:on */ override fun toString(): String = when { completion != null -> "Prompt{completion=$completion}" chat != null -> "Prompt{chat=$chat}" - nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" _json != null -> "Prompt{_unknown=$_json}" else -> throw IllegalStateException("Invalid Prompt") } @@ -737,10 +723,6 @@ private constructor( @JvmStatic fun ofCompletion(completion: Completion) = Prompt(completion = completion) @JvmStatic fun ofChat(chat: Chat) = Prompt(chat = chat) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - Prompt(nullableVariant = nullableVariant) } /** An interface that defines how to map each variant of [Prompt] to a value of type [T]. */ @@ -750,8 +732,6 @@ private constructor( fun visitChat(chat: Chat): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [Prompt] to a value of type [T]. * @@ -780,10 +760,6 @@ private constructor( ?.let { return Prompt(chat = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Prompt(nullableVariant = it, _json = json) - } return Prompt(_json = json) } @@ -799,7 +775,6 @@ private constructor( when { value.completion != null -> generator.writeObject(value.completion) value.chat != null -> generator.writeObject(value.chat) - value.nullableVariant != null -> generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Prompt") } @@ -3492,88 +3467,6 @@ private constructor( override fun toString() = "Chat{messages=$messages, type=$type, tools=$tools, additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NullableVariant]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - } } @JsonDeserialize(using = ToolFunction.Deserializer::class) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 5ac95496..86756e3f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -365,6 +365,9 @@ private constructor( @JsonProperty("function_call") @ExcludeMissing private val functionCall: JsonField = JsonMissing.of(), + @JsonProperty("max_completion_tokens") + @ExcludeMissing + private val maxCompletionTokens: JsonField = JsonMissing.of(), @JsonProperty("max_tokens") @ExcludeMissing private val maxTokens: JsonField = JsonMissing.of(), @@ -372,6 +375,9 @@ private constructor( @JsonProperty("presence_penalty") @ExcludeMissing private val presencePenalty: JsonField = JsonMissing.of(), + @JsonProperty("reasoning_effort") + @ExcludeMissing + private val reasoningEffort: JsonField = JsonMissing.of(), @JsonProperty("response_format") @ExcludeMissing private val responseFormat: JsonField = JsonMissing.of(), @@ -400,6 +406,10 @@ private constructor( fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + /** The successor to max_tokens */ + fun maxCompletionTokens(): Optional = + Optional.ofNullable(maxCompletionTokens.getNullable("max_completion_tokens")) + fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) @@ -408,6 +418,9 @@ private constructor( fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + fun reasoningEffort(): Optional = + Optional.ofNullable(reasoningEffort.getNullable("reasoning_effort")) + fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) @@ -432,6 +445,11 @@ private constructor( @ExcludeMissing fun _functionCall(): JsonField = functionCall + /** The successor to max_tokens */ + @JsonProperty("max_completion_tokens") + @ExcludeMissing + fun _maxCompletionTokens(): JsonField = maxCompletionTokens + @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens @@ -442,6 +460,10 @@ private constructor( @ExcludeMissing fun _presencePenalty(): JsonField = presencePenalty + @JsonProperty("reasoning_effort") + @ExcludeMissing + fun _reasoningEffort(): JsonField = reasoningEffort + @JsonProperty("response_format") @ExcludeMissing fun _responseFormat(): JsonField = responseFormat @@ -475,9 +497,11 @@ private constructor( frequencyPenalty() functionCall().ifPresent { it.validate() } + maxCompletionTokens() maxTokens() n() presencePenalty() + reasoningEffort() responseFormat().ifPresent { it.validate() } stop() temperature() @@ -502,9 +526,11 @@ private constructor( private var frequencyPenalty: JsonField = JsonMissing.of() private var functionCall: JsonField = JsonMissing.of() + private var maxCompletionTokens: JsonField = JsonMissing.of() private var maxTokens: JsonField = JsonMissing.of() private var n: JsonField = JsonMissing.of() private var presencePenalty: JsonField = JsonMissing.of() + private var reasoningEffort: JsonField = JsonMissing.of() private var responseFormat: JsonField = JsonMissing.of() private var stop: JsonField>? = null private var temperature: JsonField = JsonMissing.of() @@ -517,9 +543,11 @@ private constructor( internal fun from(openaiModelParams: OpenAIModelParams) = apply { frequencyPenalty = openaiModelParams.frequencyPenalty functionCall = openaiModelParams.functionCall + maxCompletionTokens = openaiModelParams.maxCompletionTokens maxTokens = openaiModelParams.maxTokens n = openaiModelParams.n presencePenalty = openaiModelParams.presencePenalty + reasoningEffort = openaiModelParams.reasoningEffort responseFormat = openaiModelParams.responseFormat stop = openaiModelParams.stop.map { it.toMutableList() } temperature = openaiModelParams.temperature @@ -549,6 +577,15 @@ private constructor( fun functionCall(function: FunctionCall.Function) = functionCall(FunctionCall.ofFunction(function)) + /** The successor to max_tokens */ + fun maxCompletionTokens(maxCompletionTokens: Double) = + maxCompletionTokens(JsonField.of(maxCompletionTokens)) + + /** The successor to max_tokens */ + fun maxCompletionTokens(maxCompletionTokens: JsonField) = apply { + this.maxCompletionTokens = maxCompletionTokens + } + fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } @@ -564,8 +601,18 @@ private constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) + fun reasoningEffort(reasoningEffort: ReasoningEffort) = + reasoningEffort(JsonField.of(reasoningEffort)) + + fun reasoningEffort(reasoningEffort: JsonField) = apply { + this.reasoningEffort = reasoningEffort + } + + fun responseFormat(responseFormat: ResponseFormat?) = + responseFormat(JsonField.ofNullable(responseFormat)) + + fun responseFormat(responseFormat: Optional) = + responseFormat(responseFormat.getOrNull()) fun responseFormat(responseFormat: JsonField) = apply { this.responseFormat = responseFormat @@ -580,9 +627,6 @@ private constructor( fun responseFormat(text: ResponseFormat.Text) = responseFormat(ResponseFormat.ofText(text)) - fun responseFormat(nullableVariant: ResponseFormat.NullableVariant) = - responseFormat(ResponseFormat.ofNullableVariant(nullableVariant)) - fun stop(stop: List) = stop(JsonField.of(stop)) fun stop(stop: JsonField>) = apply { @@ -648,9 +692,11 @@ private constructor( OpenAIModelParams( frequencyPenalty, functionCall, + maxCompletionTokens, maxTokens, n, presencePenalty, + reasoningEffort, responseFormat, (stop ?: JsonMissing.of()).map { it.toImmutable() }, temperature, @@ -1016,6 +1062,120 @@ private constructor( } } + class ReasoningEffort + @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 LOW = of("low") + + @JvmField val MEDIUM = of("medium") + + @JvmField val HIGH = of("high") + + @JvmStatic fun of(value: String) = ReasoningEffort(JsonField.of(value)) + } + + /** An enum containing [ReasoningEffort]'s known values. */ + enum class Known { + LOW, + MEDIUM, + HIGH, + } + + /** + * An enum containing [ReasoningEffort]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReasoningEffort] 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 { + LOW, + MEDIUM, + HIGH, + /** + * An enum member indicating that [ReasoningEffort] 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) { + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + HIGH -> Value.HIGH + 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) { + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + HIGH -> Known.HIGH + else -> + throw BraintrustInvalidDataException("Unknown ReasoningEffort: $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 ReasoningEffort && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + @JsonDeserialize(using = ResponseFormat.Deserializer::class) @JsonSerialize(using = ResponseFormat.Serializer::class) class ResponseFormat @@ -1023,7 +1183,6 @@ private constructor( private val jsonObject: JsonObject? = null, private val jsonSchema: JsonSchema? = null, private val text: Text? = null, - private val nullableVariant: NullableVariant? = null, private val _json: JsonValue? = null, ) { @@ -1033,26 +1192,18 @@ private constructor( fun text(): Optional = Optional.ofNullable(text) - fun nullableVariant(): Optional = - Optional.ofNullable(nullableVariant) - fun isJsonObject(): Boolean = jsonObject != null fun isJsonSchema(): Boolean = jsonSchema != null fun isText(): Boolean = text != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asJsonObject(): JsonObject = jsonObject.getOrThrow("jsonObject") fun asJsonSchema(): JsonSchema = jsonSchema.getOrThrow("jsonSchema") fun asText(): Text = text.getOrThrow("text") - fun asNullableVariant(): NullableVariant = - nullableVariant.getOrThrow("nullableVariant") - fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { @@ -1060,7 +1211,6 @@ private constructor( jsonObject != null -> visitor.visitJsonObject(jsonObject) jsonSchema != null -> visitor.visitJsonSchema(jsonSchema) text != null -> visitor.visitText(text) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) else -> visitor.unknown(_json) } } @@ -1085,10 +1235,6 @@ private constructor( override fun visitText(text: Text) { text.validate() } - - override fun visitNullableVariant(nullableVariant: NullableVariant) { - nullableVariant.validate() - } } ) validated = true @@ -1099,18 +1245,16 @@ private constructor( return true } - return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text && nullableVariant == other.nullableVariant /* spotless:on */ + return /* spotless:off */ other is ResponseFormat && jsonObject == other.jsonObject && jsonSchema == other.jsonSchema && text == other.text /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text, nullableVariant) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(jsonObject, jsonSchema, text) /* spotless:on */ override fun toString(): String = when { jsonObject != null -> "ResponseFormat{jsonObject=$jsonObject}" jsonSchema != null -> "ResponseFormat{jsonSchema=$jsonSchema}" text != null -> "ResponseFormat{text=$text}" - nullableVariant != null -> - "ResponseFormat{nullableVariant=$nullableVariant}" _json != null -> "ResponseFormat{_unknown=$_json}" else -> throw IllegalStateException("Invalid ResponseFormat") } @@ -1126,10 +1270,6 @@ private constructor( ResponseFormat(jsonSchema = jsonSchema) @JvmStatic fun ofText(text: Text) = ResponseFormat(text = text) - - @JvmStatic - fun ofNullableVariant(nullableVariant: NullableVariant) = - ResponseFormat(nullableVariant = nullableVariant) } /** @@ -1144,8 +1284,6 @@ private constructor( fun visitText(text: Text): T - fun visitNullableVariant(nullableVariant: NullableVariant): T - /** * Maps an unknown variant of [ResponseFormat] to a value of type [T]. * @@ -1179,10 +1317,6 @@ private constructor( ?.let { return ResponseFormat(text = it, _json = json) } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ResponseFormat(nullableVariant = it, _json = json) - } return ResponseFormat(_json = json) } @@ -1199,8 +1333,6 @@ private constructor( value.jsonObject != null -> generator.writeObject(value.jsonObject) value.jsonSchema != null -> generator.writeObject(value.jsonSchema) value.text != null -> generator.writeObject(value.text) - value.nullableVariant != null -> - generator.writeObject(value.nullableVariant) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ResponseFormat") } @@ -1644,6 +1776,11 @@ private constructor( fun schema(schema: JsonField) = apply { this.schema = schema } + fun schema(unionMember0: Schema.UnionMember0) = + schema(Schema.ofUnionMember0(unionMember0)) + + fun schema(string: String) = schema(Schema.ofString(string)) + fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict)) fun strict(strict: Boolean) = strict(strict as Boolean?) @@ -1684,19 +1821,38 @@ private constructor( ) } - @NoAutoDetect + @JsonDeserialize(using = Schema.Deserializer::class) + @JsonSerialize(using = Schema.Serializer::class) class Schema - @JsonCreator private constructor( - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap() + private val unionMember0: UnionMember0? = null, + private val string: String? = null, + private val _json: JsonValue? = null, ) { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun unionMember0(): Optional = + Optional.ofNullable(unionMember0) + + fun string(): Optional = Optional.ofNullable(string) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isString(): Boolean = string != null + + fun asUnionMember0(): UnionMember0 = + unionMember0.getOrThrow("unionMember0") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + } private var validated: Boolean = false @@ -1705,74 +1861,202 @@ private constructor( return@apply } + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitString(string: String) {} + } + ) validated = true } - fun toBuilder() = Builder().from(this) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Schema && unionMember0 == other.unionMember0 && string == other.string /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, string) /* spotless:on */ + + override fun toString(): String = + when { + unionMember0 != null -> "Schema{unionMember0=$unionMember0}" + string != null -> "Schema{string=$string}" + _json != null -> "Schema{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Schema") + } companion object { + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + Schema(unionMember0 = unionMember0) + + @JvmStatic fun ofString(string: String) = Schema(string = string) + } + + /** + * An interface that defines how to map each variant of [Schema] to a + * value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitString(string: String): T + /** - * Returns a mutable builder for constructing an instance of - * [Schema]. + * Maps an unknown variant of [Schema] to a value of type [T]. + * + * An instance of [Schema] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware of. + * + * @throws BraintrustInvalidDataException in the default + * implementation. */ - @JvmStatic fun builder() = Builder() + fun unknown(json: JsonValue?): T { + throw BraintrustInvalidDataException("Unknown Schema: $json") + } } - /** A builder for [Schema]. */ - class Builder internal constructor() { + internal class Deserializer : BaseDeserializer(Schema::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Schema { + val json = JsonValue.fromJsonNode(node) - private var additionalProperties: MutableMap = - mutableMapOf() + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Schema(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Schema(string = it, _json = json) + } - @JvmSynthetic - internal fun from(schema: Schema) = apply { - additionalProperties = - schema.additionalProperties.toMutableMap() + return Schema(_json = json) } + } - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + internal class Serializer : BaseSerializer(Schema::class) { + + override fun serialize( + value: Schema, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> + generator.writeObject(value.unionMember0) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Schema") + } } + } + + @NoAutoDetect + class UnionMember0 + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = + immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + validated = true } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun toBuilder() = Builder().from(this) + + companion object { - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns a mutable builder for constructing an instance of + * [UnionMember0]. + */ + @JvmStatic fun builder() = Builder() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + additionalProperties = + unionMember0.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): UnionMember0 = + UnionMember0(additionalProperties.toImmutable()) } - fun build(): Schema = Schema(additionalProperties.toImmutable()) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return /* spotless:off */ other is UnionMember0 && additionalProperties == other.additionalProperties /* spotless:on */ } - return /* spotless:off */ other is Schema && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode - override fun toString() = - "Schema{additionalProperties=$additionalProperties}" + override fun toString() = + "UnionMember0{additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { @@ -2118,95 +2402,6 @@ private constructor( override fun toString() = "Text{type=$type, additionalProperties=$additionalProperties}" } - - @NoAutoDetect - class NullableVariant - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NullableVariant = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [NullableVariant]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NullableVariant]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties = - nullableVariant.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NullableVariant = - NullableVariant(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NullableVariant && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NullableVariant{additionalProperties=$additionalProperties}" - } } @JsonDeserialize(using = ToolChoice.Deserializer::class) @@ -2807,17 +3002,17 @@ private constructor( return true } - return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is OpenAIModelParams && frequencyPenalty == other.frequencyPenalty && functionCall == other.functionCall && maxCompletionTokens == other.maxCompletionTokens && maxTokens == other.maxTokens && n == other.n && presencePenalty == other.presencePenalty && reasoningEffort == other.reasoningEffort && responseFormat == other.responseFormat && stop == other.stop && temperature == other.temperature && toolChoice == other.toolChoice && topP == other.topP && useCache == other.useCache && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(frequencyPenalty, functionCall, maxTokens, n, presencePenalty, responseFormat, stop, temperature, toolChoice, topP, useCache, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(frequencyPenalty, functionCall, maxCompletionTokens, maxTokens, n, presencePenalty, reasoningEffort, responseFormat, stop, temperature, toolChoice, topP, useCache, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" + "OpenAIModelParams{frequencyPenalty=$frequencyPenalty, functionCall=$functionCall, maxCompletionTokens=$maxCompletionTokens, maxTokens=$maxTokens, n=$n, presencePenalty=$presencePenalty, reasoningEffort=$reasoningEffort, responseFormat=$responseFormat, stop=$stop, temperature=$temperature, toolChoice=$toolChoice, topP=$topP, useCache=$useCache, additionalProperties=$additionalProperties}" } @NoAutoDetect diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 50735234..7282d348 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -37,6 +37,9 @@ private constructor( /** SpanIframe id */ fun spanIframeId(): String = spanIframeId + /** Textual description of the span iframe */ + fun description(): Optional = body.description() + /** Name of the span iframe */ fun name(): Optional = body.name() @@ -49,6 +52,9 @@ private constructor( /** URL to embed the project viewer in an iframe */ fun url(): Optional = body.url() + /** Textual description of the span iframe */ + fun _description(): JsonField = body._description() + /** Name of the span iframe */ fun _name(): JsonField = body._name() @@ -84,6 +90,9 @@ private constructor( class Body @JsonCreator private constructor( + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -95,6 +104,10 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** Textual description of the span iframe */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + /** Name of the span iframe */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @@ -108,6 +121,11 @@ private constructor( /** URL to embed the project viewer in an iframe */ fun url(): Optional = Optional.ofNullable(url.getNullable("url")) + /** Textual description of the span iframe */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + /** Name of the span iframe */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -133,6 +151,7 @@ private constructor( return@apply } + description() name() postMessage() url() @@ -150,6 +169,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var description: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var postMessage: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() @@ -157,12 +177,24 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { + description = body.description name = body.name postMessage = body.postMessage url = body.url additionalProperties = body.additionalProperties.toMutableMap() } + /** Textual description of the span iframe */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Textual description of the span iframe */ + fun description(description: Optional) = description(description.getOrNull()) + + /** Textual description of the span iframe */ + fun description(description: JsonField) = apply { + this.description = description + } + /** Name of the span iframe */ fun name(name: String?) = name(JsonField.ofNullable(name)) @@ -226,7 +258,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Body = Body(name, postMessage, url, additionalProperties.toImmutable()) + fun build(): Body = + Body(description, name, postMessage, url, additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -234,17 +267,17 @@ private constructor( return true } - return /* spotless:off */ other is Body && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && description == other.description && name == other.name && postMessage == other.postMessage && url == other.url && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, postMessage, url, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(description, name, postMessage, url, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" + "Body{description=$description, name=$name, postMessage=$postMessage, url=$url, additionalProperties=$additionalProperties}" } fun toBuilder() = Builder().from(this) @@ -282,6 +315,15 @@ private constructor( /** SpanIframe id */ fun spanIframeId(spanIframeId: String) = apply { this.spanIframeId = spanIframeId } + /** Textual description of the span iframe */ + fun description(description: String?) = apply { body.description(description) } + + /** Textual description of the span iframe */ + fun description(description: Optional) = description(description.getOrNull()) + + /** Textual description of the span iframe */ + fun description(description: JsonField) = apply { body.description(description) } + /** Name of the span iframe */ fun name(name: String?) = apply { body.name(name) } 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 a8bb266f..58a05213 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 @@ -479,19 +479,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @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 PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -499,13 +505,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -519,13 +528,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -540,13 +552,16 @@ private constructor( fun value(): Value = when (this) { PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS 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 } @@ -562,13 +577,16 @@ private constructor( fun known(): Known = when (this) { PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS 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") } 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 0597fc32..7d07ab02 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 @@ -755,19 +755,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @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 PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -775,13 +781,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -795,13 +804,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -816,13 +828,16 @@ private constructor( fun value(): Value = when (this) { PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS 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 } @@ -838,13 +853,16 @@ private constructor( fun known(): Known = when (this) { PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS 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") } 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 3dd24391..dd2f1d06 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 @@ -637,19 +637,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @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 PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -657,13 +663,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -677,13 +686,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -698,13 +710,16 @@ private constructor( fun value(): Value = when (this) { PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS 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 } @@ -720,13 +735,16 @@ private constructor( fun known(): Known = when (this) { PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS 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") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 731eab40..40ff24c4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -32,6 +32,15 @@ private constructor( @JsonProperty("columnVisibility") @ExcludeMissing private val columnVisibility: JsonField = JsonMissing.of(), + @JsonProperty("grouping") + @ExcludeMissing + private val grouping: JsonField = JsonMissing.of(), + @JsonProperty("layout") + @ExcludeMissing + private val layout: JsonField = JsonMissing.of(), + @JsonProperty("rowHeight") + @ExcludeMissing + private val rowHeight: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -44,6 +53,12 @@ private constructor( fun columnVisibility(): Optional = Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) + fun grouping(): Optional = Optional.ofNullable(grouping.getNullable("grouping")) + + fun layout(): Optional = Optional.ofNullable(layout.getNullable("layout")) + + fun rowHeight(): Optional = Optional.ofNullable(rowHeight.getNullable("rowHeight")) + @JsonProperty("columnOrder") @ExcludeMissing fun _columnOrder(): JsonField> = columnOrder @@ -56,6 +71,12 @@ private constructor( @ExcludeMissing fun _columnVisibility(): JsonField = columnVisibility + @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping + + @JsonProperty("layout") @ExcludeMissing fun _layout(): JsonField = layout + + @JsonProperty("rowHeight") @ExcludeMissing fun _rowHeight(): JsonField = rowHeight + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties @@ -70,6 +91,9 @@ private constructor( columnOrder() columnSizing().ifPresent { it.validate() } columnVisibility().ifPresent { it.validate() } + grouping() + layout() + rowHeight() validated = true } @@ -87,6 +111,9 @@ private constructor( private var columnOrder: JsonField>? = null private var columnSizing: JsonField = JsonMissing.of() private var columnVisibility: JsonField = JsonMissing.of() + private var grouping: JsonField = JsonMissing.of() + private var layout: JsonField = JsonMissing.of() + private var rowHeight: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -94,6 +121,9 @@ private constructor( columnOrder = viewOptions.columnOrder.map { it.toMutableList() } columnSizing = viewOptions.columnSizing columnVisibility = viewOptions.columnVisibility + grouping = viewOptions.grouping + layout = viewOptions.layout + rowHeight = viewOptions.rowHeight additionalProperties = viewOptions.additionalProperties.toMutableMap() } @@ -132,6 +162,24 @@ private constructor( this.columnVisibility = columnVisibility } + fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.getOrNull()) + + fun grouping(grouping: JsonField) = apply { this.grouping = grouping } + + fun layout(layout: String?) = layout(JsonField.ofNullable(layout)) + + fun layout(layout: Optional) = layout(layout.getOrNull()) + + fun layout(layout: JsonField) = apply { this.layout = layout } + + fun rowHeight(rowHeight: String?) = rowHeight(JsonField.ofNullable(rowHeight)) + + fun rowHeight(rowHeight: Optional) = rowHeight(rowHeight.getOrNull()) + + fun rowHeight(rowHeight: JsonField) = apply { this.rowHeight = rowHeight } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -156,6 +204,9 @@ private constructor( (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, columnSizing, columnVisibility, + grouping, + layout, + rowHeight, additionalProperties.toImmutable(), ) } @@ -323,15 +374,15 @@ private constructor( return true } - return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ViewOptions && columnOrder == other.columnOrder && columnSizing == other.columnSizing && columnVisibility == other.columnVisibility && grouping == other.grouping && layout == other.layout && rowHeight == other.rowHeight && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(columnOrder, columnSizing, columnVisibility, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(columnOrder, columnSizing, columnVisibility, grouping, layout, rowHeight, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, additionalProperties=$additionalProperties}" + "ViewOptions{columnOrder=$columnOrder, columnSizing=$columnSizing, columnVisibility=$columnVisibility, grouping=$grouping, layout=$layout, rowHeight=$rowHeight, additionalProperties=$additionalProperties}" } 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 d99f4f94..3c53c17e 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 @@ -759,19 +759,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @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 PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -779,13 +785,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -799,13 +808,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -820,13 +832,16 @@ private constructor( fun value(): Value = when (this) { PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS 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 } @@ -842,13 +857,16 @@ private constructor( fun known(): Known = when (this) { PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS 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") } 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 368c4698..525a0dbc 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 @@ -737,19 +737,25 @@ private constructor( @JvmField val PROJECTS = of("projects") - @JvmField val LOGS = of("logs") - @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 PLAYGROUNDS = of("playgrounds") + @JvmField val TOOLS = of("tools") - @JvmField val EXPERIMENT = of("experiment") + @JvmField val SCORERS = of("scorers") - @JvmField val DATASET = of("dataset") + @JvmField val LOGS = of("logs") @JvmStatic fun of(value: String) = ViewType(JsonField.of(value)) } @@ -757,13 +763,16 @@ private constructor( /** An enum containing [ViewType]'s known values. */ enum class Known { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, } /** @@ -777,13 +786,16 @@ private constructor( */ enum class Value { PROJECTS, - LOGS, EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, EXPERIMENT, + PLAYGROUNDS, + PLAYGROUND, + DATASETS, DATASET, + PROMPTS, + TOOLS, + SCORERS, + LOGS, /** An enum member indicating that [ViewType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -798,13 +810,16 @@ private constructor( fun value(): Value = when (this) { PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS 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 } @@ -820,13 +835,16 @@ private constructor( fun known(): Known = when (this) { PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS 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") } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 5138c220..a361b6f2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -5,8 +5,6 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.models.AclBatchUpdateParams -import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -69,28 +67,6 @@ interface AclServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. - */ - fun batchUpdate(): CompletableFuture = - batchUpdate(AclBatchUpdateParams.none()) - - /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): CompletableFuture = batchUpdate(params, RequestOptions.none()) - - /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) - /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture = findAndDelete(params, RequestOptions.none()) @@ -164,35 +140,6 @@ interface AclServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclServiceAsync.batchUpdate]. - */ - @MustBeClosed - fun batchUpdate(): CompletableFuture> = - batchUpdate(AclBatchUpdateParams.none()) - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): CompletableFuture> = - batchUpdate(params, RequestOptions.none()) - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - requestOptions: RequestOptions - ): CompletableFuture> = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) - /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as * [AclServiceAsync.findAndDelete]. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index e99ec877..00da2121 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -16,8 +16,6 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.models.AclBatchUpdateParams -import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -63,13 +61,6 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /v1/acl/batch-update - withRawResponse().batchUpdate(params, requestOptions).thenApply { it.parse() } - override fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions, @@ -204,37 +195,6 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client } } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.parseable { - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index 5d4a4de6..5e571994 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -5,8 +5,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.models.AclBatchUpdateParams -import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -58,27 +56,6 @@ interface AclService { /** @see [delete] */ fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl - /** - * Batch update acls. This operation is idempotent, so adding acls which already exist will have - * no effect, and removing acls which do not exist will have no effect. - */ - fun batchUpdate(): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none()) - - /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AclBatchUpdateResponse - - /** @see [batchUpdate] */ - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): AclBatchUpdateResponse = batchUpdate(params, RequestOptions.none()) - - /** @see [batchUpdate] */ - fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) - /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): Acl = findAndDelete(params, RequestOptions.none()) @@ -152,32 +129,6 @@ interface AclService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `post /v1/acl/batch-update`, but is otherwise the same as - * [AclService.batchUpdate]. - */ - @MustBeClosed - fun batchUpdate(): HttpResponseFor = - batchUpdate(AclBatchUpdateParams.none()) - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate( - params: AclBatchUpdateParams = AclBatchUpdateParams.none() - ): HttpResponseFor = batchUpdate(params, RequestOptions.none()) - - /** @see [batchUpdate] */ - @MustBeClosed - fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = - batchUpdate(AclBatchUpdateParams.none(), requestOptions) - /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as * [AclService.findAndDelete]. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index 39e18573..ef37bddc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -16,8 +16,6 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl -import com.braintrustdata.api.models.AclBatchUpdateParams -import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -49,13 +47,6 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).parse() - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): AclBatchUpdateResponse = - // post /v1/acl/batch-update - withRawResponse().batchUpdate(params, requestOptions).parse() - override fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions, @@ -176,34 +167,6 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio } } - private val batchUpdateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - override fun batchUpdate( - params: AclBatchUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl", "batch-update") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response.parseable { - response - .use { batchUpdateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt index 693b9866..d4b40e30 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt @@ -24,6 +24,7 @@ class AISecretTest { ) .previewSecret("preview_secret") .type("type") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() assertThat(aiSecret).isNotNull assertThat(aiSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -38,5 +39,6 @@ class AISecretTest { ) assertThat(aiSecret.previewSecret()).contains("preview_secret") assertThat(aiSecret.type()).contains("type") + assertThat(aiSecret.updatedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } } 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 deleted file mode 100644 index ce3f43d3..00000000 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt +++ /dev/null @@ -1,118 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import kotlin.test.assertNotNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class AclBatchUpdateParamsTest { - - @Test - fun create() { - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - } - - @Test - fun body() { - val params = - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - - val body = params._body() - - assertNotNull(body) - assertThat(body.addAcls()) - .contains( - listOf( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) - assertThat(body.removeAcls()) - .contains( - listOf( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = AclBatchUpdateParams.builder().build() - - val body = params._body() - - assertNotNull(body) - } -} diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt index 687f05e1..2226864c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -23,17 +23,14 @@ class DatasetEventTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(DatasetEvent.Metadata.builder().model("model").build()) .origin( - DatasetEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .addTag("string") @@ -51,18 +48,15 @@ class DatasetEventTest { assertThat(datasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(datasetEvent.isRoot()).contains(true) assertThat(datasetEvent.metadata()) - .contains( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(DatasetEvent.Metadata.builder().model("model").build()) assertThat(datasetEvent.origin()) .contains( - DatasetEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) assertThat(datasetEvent.tags().get()).containsExactly("string") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index 9f080dd0..7278beb1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -24,9 +24,14 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") @@ -53,9 +58,14 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") @@ -81,9 +91,14 @@ class DatasetInsertParamsTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index 5ac72887..869fa93c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -12,7 +12,17 @@ class EvalCreateParamsTest { @Test fun create() { EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .data( + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) .projectId("project_id") .addScore( EvalCreateParams.Score.FunctionId.builder() @@ -42,6 +52,24 @@ class EvalCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .parent( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType(EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") @@ -65,7 +93,17 @@ class EvalCreateParamsTest { fun body() { val params = EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .data( + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) .projectId("project_id") .addScore( EvalCreateParams.Score.FunctionId.builder() @@ -95,6 +133,26 @@ class EvalCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .parent( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") @@ -119,7 +177,15 @@ class EvalCreateParamsTest { assertThat(body.data()) .isEqualTo( EvalCreateParams.Data.ofDatasetId( - EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build() + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() ) ) assertThat(body.projectId()).isEqualTo("project_id") @@ -161,6 +227,29 @@ class EvalCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + assertThat(body.parent()) + .contains( + EvalCreateParams.Parent.ofSpanParentStruct( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) + ) assertThat(body.repoInfo()) .contains( RepoInfo.builder() 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 3830f18c..f10a67a4 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 @@ -27,16 +27,11 @@ class ExperimentEventTest { .callerLineno(0L) .build() ) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ExperimentEvent.Metadata.builder().model("model").build()) .metrics( ExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -50,11 +45,12 @@ class ExperimentEventTest { .build() ) .origin( - ExperimentEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) @@ -86,17 +82,12 @@ class ExperimentEventTest { .callerLineno(0L) .build() ) - assertThat(experimentEvent.datasetRecordId()).contains("dataset_record_id") assertThat(experimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) assertThat(experimentEvent._expected()).isEqualTo(JsonValue.from(mapOf())) assertThat(experimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(experimentEvent.isRoot()).contains(true) assertThat(experimentEvent.metadata()) - .contains( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(ExperimentEvent.Metadata.builder().model("model").build()) assertThat(experimentEvent.metrics()) .contains( ExperimentEvent.Metrics.builder() @@ -112,11 +103,12 @@ class ExperimentEventTest { ) assertThat(experimentEvent.origin()) .contains( - ExperimentEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) 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 9627ff9b..8326f83a 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 @@ -29,15 +29,10 @@ class ExperimentInsertParamsTest { .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertExperimentEvent.Metadata.builder().model("model").build()) .metrics( InsertExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -50,6 +45,15 @@ class ExperimentInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -88,15 +92,10 @@ class ExperimentInsertParamsTest { .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertExperimentEvent.Metadata.builder().model("model").build()) .metrics( InsertExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -109,6 +108,15 @@ class ExperimentInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -149,15 +157,10 @@ class ExperimentInsertParamsTest { .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertExperimentEvent.Metadata.builder().model("model").build()) .metrics( InsertExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -170,6 +173,15 @@ class ExperimentInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt index ad7d703b..29bcfe3b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -25,17 +25,14 @@ class FetchDatasetEventsResponseTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(DatasetEvent.Metadata.builder().model("model").build()) .origin( - DatasetEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .addTag("string") @@ -57,17 +54,14 @@ class FetchDatasetEventsResponseTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - DatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(DatasetEvent.Metadata.builder().model("model").build()) .origin( - DatasetEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DatasetEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .addTag("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 7e95ce35..d8796002 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 @@ -29,16 +29,11 @@ class FetchExperimentEventsResponseTest { .callerLineno(0L) .build() ) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ExperimentEvent.Metadata.builder().model("model").build()) .metrics( ExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -52,11 +47,12 @@ class FetchExperimentEventsResponseTest { .build() ) .origin( - ExperimentEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) @@ -95,16 +91,11 @@ class FetchExperimentEventsResponseTest { .callerLineno(0L) .build() ) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ExperimentEvent.Metadata.builder().model("model").build()) .metrics( ExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -118,11 +109,12 @@ class FetchExperimentEventsResponseTest { .build() ) .origin( - ExperimentEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ExperimentEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) 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 4c35853e..480a33d8 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 @@ -34,11 +34,7 @@ class FetchProjectLogsEventsResponseTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( ProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -52,11 +48,12 @@ class FetchProjectLogsEventsResponseTest { .build() ) .origin( - ProjectLogsEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) @@ -100,11 +97,7 @@ class FetchProjectLogsEventsResponseTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( ProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -118,11 +111,12 @@ class FetchProjectLogsEventsResponseTest { .build() ) .origin( - ProjectLogsEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) 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 f4114dc7..389d6004 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 @@ -48,9 +48,13 @@ class FunctionCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -154,9 +158,14 @@ class FunctionCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -264,9 +273,13 @@ class FunctionCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index dcfb6ecc..4a9bbd1f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -13,6 +13,7 @@ class FunctionInvokeParamsTest { fun create() { FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .addMessage( FunctionInvokeParams.Message.System.builder() @@ -21,6 +22,11 @@ class FunctionInvokeParamsTest { .name("name") .build() ) + .metadata( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -52,6 +58,7 @@ class FunctionInvokeParamsTest { val params = FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .addMessage( FunctionInvokeParams.Message.System.builder() @@ -60,6 +67,11 @@ class FunctionInvokeParamsTest { .name("name") .build() ) + .metadata( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -88,6 +100,7 @@ class FunctionInvokeParamsTest { val body = params._body() assertNotNull(body) + assertThat(body._expected()).isEqualTo(JsonValue.from(mapOf())) assertThat(body._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.messages()) .contains( @@ -101,6 +114,12 @@ class FunctionInvokeParamsTest { ) ) ) + assertThat(body.metadata()) + .contains( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(body.mode()).contains(FunctionInvokeParams.Mode.AUTO) assertThat(body.parent()) .contains( 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 56eba313..590c73e7 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 @@ -48,9 +48,13 @@ class FunctionReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -154,9 +158,14 @@ class FunctionReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -264,9 +273,13 @@ class FunctionReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject 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 b6570597..2183cad8 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 @@ -59,9 +59,14 @@ class FunctionTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -177,9 +182,13 @@ class FunctionTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index 051c89be..cd43ea77 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -33,9 +33,13 @@ class FunctionUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -124,9 +128,14 @@ class FunctionUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -216,9 +225,13 @@ class FunctionUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt index 53366aec..f81a9b5e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt @@ -21,9 +21,14 @@ class InsertDatasetEventTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") @@ -42,9 +47,15 @@ class InsertDatasetEventTest { assertThat(insertDatasetEvent._expected()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertDatasetEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertDatasetEvent.metadata()) + .contains(InsertDatasetEvent.Metadata.builder().model("model").build()) + assertThat(insertDatasetEvent.origin()) .contains( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) assertThat(insertDatasetEvent.rootSpanId()).contains("root_span_id") 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 e9425570..c067cb4b 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 @@ -26,15 +26,10 @@ class InsertExperimentEventTest { .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertExperimentEvent.Metadata.builder().model("model").build()) .metrics( InsertExperimentEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -47,6 +42,15 @@ class InsertExperimentEventTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -77,17 +81,12 @@ class InsertExperimentEventTest { ) assertThat(insertExperimentEvent.created()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEvent.datasetRecordId()).contains("dataset_record_id") assertThat(insertExperimentEvent._error()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent._expected()) .isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent.metadata()) - .contains( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(InsertExperimentEvent.Metadata.builder().model("model").build()) assertThat(insertExperimentEvent.metrics()) .contains( InsertExperimentEvent.Metrics.builder() @@ -101,6 +100,16 @@ class InsertExperimentEventTest { .tokens(0L) .build() ) + assertThat(insertExperimentEvent.origin()) + .contains( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) assertThat(insertExperimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertExperimentEvent.rootSpanId()).contains("root_span_id") assertThat(insertExperimentEvent.scores()) 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 3454b8e9..20bcc290 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 @@ -29,11 +29,7 @@ class InsertProjectLogsEventTest { .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -46,6 +42,15 @@ class InsertProjectLogsEventTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -81,11 +86,7 @@ class InsertProjectLogsEventTest { .isEqualTo(JsonValue.from(mapOf())) assertThat(insertProjectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertProjectLogsEvent.metadata()) - .contains( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(InsertProjectLogsEvent.Metadata.builder().model("model").build()) assertThat(insertProjectLogsEvent.metrics()) .contains( InsertProjectLogsEvent.Metrics.builder() @@ -99,6 +100,16 @@ class InsertProjectLogsEventTest { .tokens(0L) .build() ) + assertThat(insertProjectLogsEvent.origin()) + .contains( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) assertThat(insertProjectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) assertThat(insertProjectLogsEvent.rootSpanId()).contains("root_span_id") assertThat(insertProjectLogsEvent.scores()) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt new file mode 100644 index 00000000..d859fcd0 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ObjectReferenceTest { + + @Test + fun createObjectReference() { + val objectReference = + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + assertThat(objectReference).isNotNull + assertThat(objectReference.id()).isEqualTo("id") + assertThat(objectReference._xactId()).isEqualTo("_xact_id") + assertThat(objectReference.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(objectReference.objectType()).isEqualTo(ObjectReference.ObjectType.EXPERIMENT) + assertThat(objectReference.created()).contains("created") + } +} 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 24369344..c5bb43ae 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 @@ -32,11 +32,7 @@ class ProjectLogInsertParamsTest { .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -49,6 +45,15 @@ class ProjectLogInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -90,11 +95,7 @@ class ProjectLogInsertParamsTest { .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -107,6 +108,15 @@ class ProjectLogInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( @@ -150,11 +160,7 @@ class ProjectLogInsertParamsTest { .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(InsertProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( InsertProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -167,6 +173,15 @@ class ProjectLogInsertParamsTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( 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 d49aac8a..e81a0afb 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 @@ -32,11 +32,7 @@ class ProjectLogsEventTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .isRoot(true) - .metadata( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .metadata(ProjectLogsEvent.Metadata.builder().model("model").build()) .metrics( ProjectLogsEvent.Metrics.builder() .callerFilename(JsonValue.from(mapOf())) @@ -50,11 +46,12 @@ class ProjectLogsEventTest { .build() ) .origin( - ProjectLogsEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .output(JsonValue.from(mapOf())) @@ -92,11 +89,7 @@ class ProjectLogsEventTest { assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) assertThat(projectLogsEvent.isRoot()).contains(true) assertThat(projectLogsEvent.metadata()) - .contains( - ProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .contains(ProjectLogsEvent.Metadata.builder().model("model").build()) assertThat(projectLogsEvent.metrics()) .contains( ProjectLogsEvent.Metrics.builder() @@ -112,11 +105,12 @@ class ProjectLogsEventTest { ) assertThat(projectLogsEvent.origin()) .contains( - ProjectLogsEvent.Origin.builder() + ObjectReference.builder() .id("id") ._xactId("_xact_id") .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ProjectLogsEvent.Origin.ObjectType.EXPERIMENT) + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt index ebd3f975..762e01a3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt @@ -11,7 +11,7 @@ class ProjectScoreConfigTest { fun createProjectScoreConfig() { val projectScoreConfig = ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -28,8 +28,7 @@ class ProjectScoreConfigTest { ) .build() assertThat(projectScoreConfig).isNotNull - assertThat(projectScoreConfig.destination()) - .contains(ProjectScoreConfig.Destination.EXPECTED) + assertThat(projectScoreConfig.destination()).contains("destination") assertThat(projectScoreConfig.multiSelect()).contains(true) assertThat(projectScoreConfig.online()) .contains( 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 f2eb7ba1..ff0c8da7 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 @@ -19,7 +19,7 @@ class ProjectScoreCreateParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -52,7 +52,7 @@ class ProjectScoreCreateParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -87,7 +87,7 @@ class ProjectScoreCreateParamsTest { assertThat(body.config()) .contains( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() 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 022d016b..1049822d 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 @@ -19,7 +19,7 @@ class ProjectScoreReplaceParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -52,7 +52,7 @@ class ProjectScoreReplaceParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -87,7 +87,7 @@ class ProjectScoreReplaceParamsTest { assertThat(body.config()) .contains( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() 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 888ef861..0e2e0b4b 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 @@ -22,7 +22,7 @@ class ProjectScoreTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -58,7 +58,7 @@ class ProjectScoreTest { assertThat(projectScore.config()) .contains( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() 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 7f153a84..2407e87f 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 @@ -17,7 +17,7 @@ class ProjectScoreUpdateParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -50,7 +50,7 @@ class ProjectScoreUpdateParamsTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -84,7 +84,7 @@ class ProjectScoreUpdateParamsTest { assertThat(body.config()) .contains( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt index 0624066d..f5216655 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt @@ -9,8 +9,31 @@ class ProjectSettingsTest { @Test fun createProjectSettings() { - val projectSettings = ProjectSettings.builder().comparisonKey("comparison_key").build() + val projectSettings = + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() assertThat(projectSettings).isNotNull + assertThat(projectSettings.baselineExperimentId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(projectSettings.comparisonKey()).contains("comparison_key") + assertThat(projectSettings.spanFieldOrder().get()) + .containsExactly( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt index 390af485..0a924ec6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt @@ -17,7 +17,20 @@ class ProjectTest { .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(project).isNotNull @@ -27,7 +40,20 @@ class ProjectTest { assertThat(project.created()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(project.deletedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(project.settings()) - .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .contains( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) assertThat(project.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 63716ab9..55bd050e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -13,7 +13,20 @@ class ProjectUpdateParamsTest { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .build() } @@ -23,7 +36,20 @@ class ProjectUpdateParamsTest { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .build() val body = params._body() @@ -31,7 +57,20 @@ class ProjectUpdateParamsTest { assertNotNull(body) assertThat(body.name()).contains("name") assertThat(body.settings()) - .contains(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .contains( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 92e03d0c..80c96334 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -30,9 +30,13 @@ class PromptCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -118,9 +122,14 @@ class PromptCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -205,9 +214,13 @@ class PromptCreateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index f2acf4d6..66346100 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -22,9 +22,13 @@ class PromptDataTest { PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject .builder() @@ -92,9 +96,13 @@ class PromptDataTest { PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject .builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt index 119a47b3..beaa5bd4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -18,9 +18,11 @@ class PromptOptionsTest { .functionCall( PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort(PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject .builder() @@ -52,9 +54,11 @@ class PromptOptionsTest { .functionCall( PromptOptions.Params.OpenAIModelParams.FunctionCall.UnionMember0.AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort(PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat.JsonObject .builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 18d87eb2..b25b4263 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -30,9 +30,13 @@ class PromptReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -118,9 +122,14 @@ class PromptReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -205,9 +214,13 @@ class PromptReplaceParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index c65cd2c6..fed67a6f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -41,9 +41,14 @@ class PromptTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -136,9 +141,13 @@ class PromptTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 7dae6fe3..00490393 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -28,9 +28,13 @@ class PromptUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -115,9 +119,14 @@ class PromptUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject @@ -200,9 +209,13 @@ class PromptUpdateParamsTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams.ReasoningEffort.LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams.ResponseFormat .JsonObject diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index 57fce4c2..b6f5b3b9 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -12,6 +12,7 @@ class SpanIframeUpdateParamsTest { fun create() { SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") .name("name") .postMessage(true) .url("url") @@ -23,6 +24,7 @@ class SpanIframeUpdateParamsTest { val params = SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") .name("name") .postMessage(true) .url("url") @@ -31,6 +33,7 @@ class SpanIframeUpdateParamsTest { val body = params._body() assertNotNull(body) + assertThat(body.description()).contains("description") assertThat(body.name()).contains("name") assertThat(body.postMessage()).contains(true) assertThat(body.url()).contains("url") 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 1f09c824..3b7432e8 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 @@ -31,6 +31,9 @@ class ViewCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -71,6 +74,9 @@ class ViewCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -110,6 +116,9 @@ class ViewCreateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt index 3d6989ba..a4691564 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt @@ -23,6 +23,9 @@ class ViewOptionsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() assertThat(viewOptions).isNotNull assertThat(viewOptions.columnOrder().get()).containsExactly("string") @@ -38,5 +41,8 @@ class ViewOptionsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + assertThat(viewOptions.grouping()).contains("grouping") + assertThat(viewOptions.layout()).contains("layout") + assertThat(viewOptions.rowHeight()).contains("rowHeight") } } 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 069dcccd..81ed6e41 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 @@ -31,6 +31,9 @@ class ViewReplaceParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -71,6 +74,9 @@ class ViewReplaceParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -110,6 +116,9 @@ class ViewReplaceParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 fd19dbb6..afd86c23 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 @@ -33,6 +33,9 @@ class ViewTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -71,6 +74,9 @@ class ViewTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) assertThat(view.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 67d83174..f5072c25 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 @@ -29,6 +29,9 @@ class ViewUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -69,6 +72,9 @@ class ViewUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -107,6 +113,9 @@ class ViewUpdateParamsTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) assertThat(body.userId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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..510dfe93 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 @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync -import com.braintrustdata.api.models.AclBatchUpdateParams import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -99,51 +98,6 @@ class AclServiceAsyncTest { acl.validate() } - @Test - fun batchUpdate() { - val client = - BraintrustOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclServiceAsync = client.acls() - - val aclBatchUpdateResponseFuture = - aclServiceAsync.batchUpdate( - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) - - val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() - aclBatchUpdateResponse.validate() - } - @Test fun findAndDelete() { val client = diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt index 4e6b2e1f..a0c5552c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt @@ -16,6 +16,7 @@ import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams import com.braintrustdata.api.models.FeedbackDatasetItem import com.braintrustdata.api.models.InsertDatasetEvent +import com.braintrustdata.api.models.ObjectReference import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -237,9 +238,14 @@ class DatasetServiceAsyncTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt index 406d7f7b..a8d438bf 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt @@ -25,7 +25,17 @@ class EvalServiceAsyncTest { val summarizeExperimentResponseFuture = evalServiceAsync.create( EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .data( + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) .projectId("project_id") .addScore( EvalCreateParams.Score.FunctionId.builder() @@ -55,6 +65,26 @@ class EvalServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .parent( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") 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 e4ab67f2..ca4c7bc5 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 @@ -16,6 +16,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackExperimentItem 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 java.time.OffsetDateTime @@ -285,14 +286,11 @@ class ExperimentServiceAsyncTest { .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + InsertExperimentEvent.Metadata.builder().model("model").build() ) .metrics( InsertExperimentEvent.Metrics.builder() @@ -306,6 +304,15 @@ class ExperimentServiceAsyncTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( 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 58578b30..f1a05501 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 @@ -69,9 +69,15 @@ class FunctionServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -193,9 +199,15 @@ class FunctionServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -312,6 +324,7 @@ class FunctionServiceAsyncTest { functionServiceAsync.invoke( FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .addMessage( FunctionInvokeParams.Message.System.builder() @@ -320,6 +333,11 @@ class FunctionServiceAsyncTest { .name("name") .build() ) + .metadata( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -401,9 +419,15 @@ class FunctionServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat 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 efa55642..1aed2310 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 @@ -38,7 +38,7 @@ class ProjectScoreServiceAsyncTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -101,7 +101,7 @@ class ProjectScoreServiceAsyncTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -183,7 +183,7 @@ class ProjectScoreServiceAsyncTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt index 85f07a6a..1d4af2db 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt @@ -67,7 +67,20 @@ class ProjectServiceAsyncTest { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt index 2535012d..e44cb335 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt @@ -48,9 +48,15 @@ class PromptServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -167,9 +173,15 @@ class PromptServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -304,9 +316,15 @@ class PromptServiceAsyncTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt index 8d448a50..e10665eb 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt @@ -72,6 +72,7 @@ class SpanIframeServiceAsyncTest { spanIframeServiceAsync.update( SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") .name("name") .postMessage(true) .url("url") 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 8a7b3bfb..2a7f254c 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 @@ -51,6 +51,9 @@ class ViewServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -124,6 +127,9 @@ class ViewServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -220,6 +226,9 @@ class ViewServiceAsyncTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 fec1f6b8..566ece51 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 @@ -7,6 +7,7 @@ import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FeedbackProjectLogsItem import com.braintrustdata.api.models.InsertProjectLogsEvent +import com.braintrustdata.api.models.ObjectReference import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams @@ -139,9 +140,7 @@ class LogServiceAsyncTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + InsertProjectLogsEvent.Metadata.builder().model("model").build() ) .metrics( InsertProjectLogsEvent.Metrics.builder() @@ -155,6 +154,15 @@ class LogServiceAsyncTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( 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..ba3e2c4d 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 @@ -4,7 +4,6 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.AclBatchUpdateParams import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -95,50 +94,6 @@ class AclServiceTest { acl.validate() } - @Test - fun batchUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acls() - - val aclBatchUpdateResponse = - aclService.batchUpdate( - AclBatchUpdateParams.builder() - .addAddAcl( - AclBatchUpdateParams.AddAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .addRemoveAcl( - AclBatchUpdateParams.RemoveAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) - .restrictObjectType( - AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION - ) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .build() - ) - - aclBatchUpdateResponse.validate() - } - @Test fun findAndDelete() { val client = diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index a9bae5c4..d1b98d7b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -16,6 +16,7 @@ import com.braintrustdata.api.models.DatasetSummarizeParams import com.braintrustdata.api.models.DatasetUpdateParams import com.braintrustdata.api.models.FeedbackDatasetItem import com.braintrustdata.api.models.InsertDatasetEvent +import com.braintrustdata.api.models.ObjectReference import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -229,9 +230,14 @@ class DatasetServiceTest { .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) - .metadata( - InsertDatasetEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .metadata(InsertDatasetEvent.Metadata.builder().model("model").build()) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") .build() ) .rootSpanId("root_span_id") diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index feaa3f95..e363273c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -25,7 +25,17 @@ class EvalServiceTest { val summarizeExperimentResponse = evalService.create( EvalCreateParams.builder() - .data(EvalCreateParams.Data.DatasetId.builder().datasetId("dataset_id").build()) + .data( + EvalCreateParams.Data.DatasetId.builder() + .datasetId("dataset_id") + ._internalBtql( + EvalCreateParams.Data.DatasetId._InternalBtql + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) .projectId("project_id") .addScore( EvalCreateParams.Score.FunctionId.builder() @@ -55,6 +65,26 @@ class EvalServiceTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .parent( + EvalCreateParams.Parent.SpanParentStruct.builder() + .objectId("object_id") + .objectType( + EvalCreateParams.Parent.SpanParentStruct.ObjectType.PROJECT_LOGS + ) + .propagatedEvent( + EvalCreateParams.Parent.SpanParentStruct.PropagatedEvent.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .rowIds( + EvalCreateParams.Parent.SpanParentStruct.RowIds.builder() + .id("id") + .rootSpanId("root_span_id") + .spanId("span_id") + .build() + ) + .build() + ) .repoInfo( RepoInfo.builder() .authorEmail("author_email") 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 b4e00567..93c696d6 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 @@ -16,6 +16,7 @@ import com.braintrustdata.api.models.ExperimentSummarizeParams import com.braintrustdata.api.models.ExperimentUpdateParams import com.braintrustdata.api.models.FeedbackExperimentItem 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 java.time.OffsetDateTime @@ -277,14 +278,11 @@ class ExperimentServiceTest { .build() ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") .error(JsonValue.from(mapOf())) .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( - InsertExperimentEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + InsertExperimentEvent.Metadata.builder().model("model").build() ) .metrics( InsertExperimentEvent.Metrics.builder() @@ -298,6 +296,15 @@ class ExperimentServiceTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( 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 d5caebf7..805b0d1d 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 @@ -69,9 +69,15 @@ class FunctionServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -191,9 +197,15 @@ class FunctionServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -307,6 +319,7 @@ class FunctionServiceTest { functionService.invoke( FunctionInvokeParams.builder() .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .addMessage( FunctionInvokeParams.Message.System.builder() @@ -315,6 +328,11 @@ class FunctionServiceTest { .name("name") .build() ) + .metadata( + FunctionInvokeParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .mode(FunctionInvokeParams.Mode.AUTO) .parent( FunctionInvokeParams.Parent.SpanParentStruct.builder() @@ -395,9 +413,15 @@ class FunctionServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat 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 0f7d4d1c..96b3a100 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 @@ -38,7 +38,7 @@ class ProjectScoreServiceTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -99,7 +99,7 @@ class ProjectScoreServiceTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() @@ -178,7 +178,7 @@ class ProjectScoreServiceTest { ) .config( ProjectScoreConfig.builder() - .destination(ProjectScoreConfig.Destination.EXPECTED) + .destination("destination") .multiSelect(true) .online( OnlineScoreConfig.builder() diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 9b95d382..51fa7715 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -65,7 +65,20 @@ class ProjectServiceTest { ProjectUpdateParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .settings(ProjectSettings.builder().comparisonKey("comparison_key").build()) + .settings( + ProjectSettings.builder() + .baselineExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonKey("comparison_key") + .addSpanFieldOrder( + ProjectSettings.SpanFieldOrder.builder() + .columnId("column_id") + .objectType("object_type") + .position("position") + .layout(ProjectSettings.SpanFieldOrder.Layout.FULL) + .build() + ) + .build() + ) .build() ) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 68eff58c..4d3cd8e9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -48,9 +48,15 @@ class PromptServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -165,9 +171,15 @@ class PromptServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat @@ -299,9 +311,15 @@ class PromptServiceTest { .UnionMember0 .AUTO ) + .maxCompletionTokens(0.0) .maxTokens(0.0) .n(0.0) .presencePenalty(0.0) + .reasoningEffort( + PromptOptions.Params.OpenAIModelParams + .ReasoningEffort + .LOW + ) .responseFormat( PromptOptions.Params.OpenAIModelParams .ResponseFormat diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index 0f18d989..a7d4d465 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -70,6 +70,7 @@ class SpanIframeServiceTest { spanIframeService.update( SpanIframeUpdateParams.builder() .spanIframeId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") .name("name") .postMessage(true) .url("url") 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 888e7466..a47e80d3 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 @@ -51,6 +51,9 @@ class ViewServiceTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -122,6 +125,9 @@ class ViewServiceTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -215,6 +221,9 @@ class ViewServiceTest { .putAdditionalProperty("foo", JsonValue.from(true)) .build() ) + .grouping("grouping") + .layout("layout") + .rowHeight("rowHeight") .build() ) .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 fca0f5f6..ac3a13bc 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 @@ -7,6 +7,7 @@ import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.models.FeedbackProjectLogsItem import com.braintrustdata.api.models.InsertProjectLogsEvent +import com.braintrustdata.api.models.ObjectReference import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams @@ -136,9 +137,7 @@ class LogServiceTest { .expected(JsonValue.from(mapOf())) .input(JsonValue.from(mapOf())) .metadata( - InsertProjectLogsEvent.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + InsertProjectLogsEvent.Metadata.builder().model("model").build() ) .metrics( InsertProjectLogsEvent.Metrics.builder() @@ -152,6 +151,15 @@ class LogServiceTest { .tokens(0L) .build() ) + .origin( + ObjectReference.builder() + .id("id") + ._xactId("_xact_id") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ObjectReference.ObjectType.EXPERIMENT) + .created("created") + .build() + ) .output(JsonValue.from(mapOf())) .rootSpanId("root_span_id") .scores( From 98e4bf7ddd7fd4709b2c4bc12d6f208316f98ac0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 18:14:32 +0000 Subject: [PATCH 79/87] feat(api): manual updates (#149) --- .stats.yml | 2 +- .../api/models/AclBatchUpdateParams.kt | 2216 +++++++++++++++++ .../api/services/async/AclServiceAsync.kt | 53 + .../api/services/async/AclServiceAsyncImpl.kt | 40 + .../api/services/blocking/AclService.kt | 49 + .../api/services/blocking/AclServiceImpl.kt | 37 + .../api/models/AclBatchUpdateParamsTest.kt | 118 + .../api/services/async/AclServiceAsyncTest.kt | 46 + .../api/services/blocking/AclServiceTest.kt | 45 + 9 files changed, 2605 insertions(+), 1 deletion(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt create mode 100644 braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt diff --git a/.stats.yml b/.stats.yml index d949f1f0..aef0f80c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 109 +configured_endpoints: 110 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-f5b152de2bdc5370d7c823d3ca415e1b914897ad98b117f1f0db213f44c0798f.yml 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 new file mode 100644 index 00000000..c7232bb9 --- /dev/null +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateParams.kt @@ -0,0 +1,2216 @@ +// File generated from our OpenAPI spec by Stainless. + +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 +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Params +import com.braintrustdata.api.core.checkKnown +import com.braintrustdata.api.core.checkRequired +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 +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Batch update acls. This operation is idempotent, so adding acls which already exist will have no + * effect, and removing acls which do not exist will have no effect. + */ +class AclBatchUpdateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + fun addAcls(): Optional> = body.addAcls() + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(): Optional> = body.removeAcls() + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + fun _addAcls(): JsonField> = body._addAcls() + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + fun _removeAcls(): JsonField> = body._removeAcls() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + @NoAutoDetect + class Body + @JsonCreator + private constructor( + @JsonProperty("add_acls") + @ExcludeMissing + private val addAcls: JsonField> = JsonMissing.of(), + @JsonProperty("remove_acls") + @ExcludeMissing + private val removeAcls: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addAcls(): Optional> = Optional.ofNullable(addAcls.getNullable("add_acls")) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(): Optional> = + Optional.ofNullable(removeAcls.getNullable("remove_acls")) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + @JsonProperty("add_acls") @ExcludeMissing fun _addAcls(): JsonField> = addAcls + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + @JsonProperty("remove_acls") + @ExcludeMissing + fun _removeAcls(): JsonField> = removeAcls + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + addAcls().ifPresent { it.forEach { it.validate() } } + removeAcls().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var addAcls: JsonField>? = null + private var removeAcls: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + addAcls = body.addAcls.map { it.toMutableList() } + removeAcls = body.removeAcls.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun addAcls(addAcls: List?) = addAcls(JsonField.ofNullable(addAcls)) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun addAcls(addAcls: JsonField>) = apply { + this.addAcls = addAcls.map { it.toMutableList() } + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun addAddAcl(addAcl: AddAcl) = apply { + addAcls = + (addAcls ?: JsonField.of(mutableListOf())).also { + checkKnown("addAcls", it).add(addAcl) + } + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun removeAcls(removeAcls: List?) = + removeAcls(JsonField.ofNullable(removeAcls)) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun removeAcls(removeAcls: Optional>) = + removeAcls(removeAcls.getOrNull()) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun removeAcls(removeAcls: JsonField>) = apply { + this.removeAcls = removeAcls.map { it.toMutableList() } + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify + * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of + * a role. + */ + fun addRemoveAcl(removeAcl: RemoveAcl) = apply { + removeAcls = + (removeAcls ?: JsonField.of(mutableListOf())).also { + checkKnown("removeAcls", it).add(removeAcl) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Body = + Body( + (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, + (removeAcls ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && addAcls == other.addAcls && removeAcls == other.removeAcls && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(addAcls, removeAcls, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{addAcls=$addAcls, removeAcls=$removeAcls, additionalProperties=$additionalProperties}" + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AclBatchUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AclBatchUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AclBatchUpdateParams]. */ + @NoAutoDetect + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(aclBatchUpdateParams: AclBatchUpdateParams) = apply { + body = aclBatchUpdateParams.body.toBuilder() + additionalHeaders = aclBatchUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = aclBatchUpdateParams.additionalQueryParams.toBuilder() + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addAcls(addAcls: List?) = apply { body.addAcls(addAcls) } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addAcls(addAcls: JsonField>) = apply { body.addAcls(addAcls) } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addAddAcl(addAcl: AddAcl) = apply { body.addAddAcl(addAcl) } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(removeAcls: List?) = apply { body.removeAcls(removeAcls) } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun removeAcls(removeAcls: JsonField>) = apply { + body.removeAcls(removeAcls) + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, + * dataset, etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in + * the ACL, as part of a direct permission grant or as part of a role. + */ + fun addRemoveAcl(removeAcl: RemoveAcl) = apply { body.addRemoveAcl(removeAcl) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun build(): AclBatchUpdateParams = + AclBatchUpdateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + @NoAutoDetect + class AddAcl + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The id of the object the ACL applies to */ + fun objectId(): String = objectId.getRequired("object_id") + + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** + * 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 = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The id of the object the ACL applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission + + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + 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 + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddAcl = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AddAcl]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddAcl]. */ + class Builder internal constructor() { + + private var objectId: 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 roleId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addAcl: AddAcl) = apply { + objectId = addAcl.objectId + objectType = addAcl.objectType + groupId = addAcl.groupId + permission = addAcl.permission + restrictObjectType = addAcl.restrictObjectType + roleId = addAcl.roleId + userId = addAcl.userId + additionalProperties = addAcl.additionalProperties.toMutableMap() + } + + /** The id of the object the ACL applies to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the ACL applies to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Optional) = permission(permission.getOrNull()) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } + + /** + * 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?) = + 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) = + 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 { + this.restrictObjectType = restrictObjectType + } + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): AddAcl = + AddAcl( + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), + ) + } + + /** 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 + } + + return /* spotless:off */ other is AddAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + } + + /** + * An ACL grants a certain permission or role to a certain user or group on an object. + * + * ACLs are inherited across the object hierarchy. So for example, if a user has read + * permissions on a project, they will also have read permissions on any experiment, dataset, + * etc. created within that project. + * + * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the + * ACL, as part of a direct permission grant or as part of a role. + */ + @NoAutoDetect + class RemoveAcl + @JsonCreator + private constructor( + @JsonProperty("object_id") + @ExcludeMissing + private val objectId: JsonField = JsonMissing.of(), + @JsonProperty("object_type") + @ExcludeMissing + private val objectType: JsonField = JsonMissing.of(), + @JsonProperty("group_id") + @ExcludeMissing + private val groupId: JsonField = JsonMissing.of(), + @JsonProperty("permission") + @ExcludeMissing + private val permission: JsonField = JsonMissing.of(), + @JsonProperty("restrict_object_type") + @ExcludeMissing + private val restrictObjectType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") + @ExcludeMissing + private val roleId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + private val userId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The id of the object the ACL applies to */ + fun objectId(): String = objectId.getRequired("object_id") + + /** The object type that the ACL applies to */ + fun objectType(): ObjectType = objectType.getRequired("object_type") + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + fun permission(): Optional = + Optional.ofNullable(permission.getNullable("permission")) + + /** + * 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 = + Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) + + /** The id of the object the ACL applies to */ + @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + + /** The object type that the ACL applies to */ + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType(): JsonField = objectType + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId + + /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + @JsonProperty("permission") + @ExcludeMissing + fun _permission(): JsonField = permission + + /** + * When setting a permission directly, optionally restricts the permission grant to just the + * specified object type. Cannot be set alongside a `role_id`. + */ + @JsonProperty("restrict_object_type") + @ExcludeMissing + 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 + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): RemoveAcl = apply { + if (validated) { + return@apply + } + + objectId() + objectType() + groupId() + permission() + restrictObjectType() + roleId() + userId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RemoveAcl]. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveAcl]. */ + class Builder internal constructor() { + + private var objectId: 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 roleId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeAcl: RemoveAcl) = apply { + objectId = removeAcl.objectId + objectType = removeAcl.objectType + groupId = removeAcl.groupId + permission = removeAcl.permission + restrictObjectType = removeAcl.restrictObjectType + roleId = removeAcl.roleId + userId = removeAcl.userId + additionalProperties = removeAcl.additionalProperties.toMutableMap() + } + + /** The id of the object the ACL applies to */ + fun objectId(objectId: String) = objectId(JsonField.of(objectId)) + + /** The id of the object the ACL applies to */ + fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + + /** The object type that the ACL applies to */ + fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + + /** The object type that the ACL applies to */ + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) + + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun groupId(groupId: JsonField) = apply { this.groupId = groupId } + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: Optional) = permission(permission.getOrNull()) + + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + fun permission(permission: JsonField) = apply { + this.permission = permission + } + + /** + * 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?) = + 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) = + 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 { + this.restrictObjectType = restrictObjectType + } + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) + + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be + * provided + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): RemoveAcl = + RemoveAcl( + checkRequired("objectId", objectId), + checkRequired("objectType", objectType), + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toImmutable(), + ) + } + + /** 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 + } + + return /* spotless:off */ other is RemoveAcl && objectId == other.objectId && objectType == other.objectType && groupId == other.groupId && permission == other.permission && restrictObjectType == other.restrictObjectType && roleId == other.roleId && userId == other.userId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(objectId, objectType, groupId, permission, restrictObjectType, roleId, userId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveAcl{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AclBatchUpdateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AclBatchUpdateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index a361b6f2..a1688232 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Acl +import com.braintrustdata.api.models.AclBatchUpdateParams +import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -67,6 +69,28 @@ interface AclServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * Batch update acls. This operation is idempotent, so adding acls which already exist will have + * no effect, and removing acls which do not exist will have no effect. + */ + fun batchUpdate(): CompletableFuture = + batchUpdate(AclBatchUpdateParams.none()) + + /** @see [batchUpdate] */ + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see [batchUpdate] */ + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): CompletableFuture = batchUpdate(params, RequestOptions.none()) + + /** @see [batchUpdate] */ + fun batchUpdate(requestOptions: RequestOptions): CompletableFuture = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) + /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): CompletableFuture = findAndDelete(params, RequestOptions.none()) @@ -140,6 +164,35 @@ interface AclServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** + * Returns a raw HTTP response for `post /v1/acl/batch_update`, but is otherwise the same as + * [AclServiceAsync.batchUpdate]. + */ + @MustBeClosed + fun batchUpdate(): CompletableFuture> = + batchUpdate(AclBatchUpdateParams.none()) + + /** @see [batchUpdate] */ + @MustBeClosed + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [batchUpdate] */ + @MustBeClosed + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): CompletableFuture> = + batchUpdate(params, RequestOptions.none()) + + /** @see [batchUpdate] */ + @MustBeClosed + fun batchUpdate( + requestOptions: RequestOptions + ): CompletableFuture> = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as * [AclServiceAsync.findAndDelete]. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index 00da2121..ab68729d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -16,6 +16,8 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepareAsync import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl +import com.braintrustdata.api.models.AclBatchUpdateParams +import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -61,6 +63,13 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/acl/batch_update + withRawResponse().batchUpdate(params, requestOptions).thenApply { it.parse() } + override fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions, @@ -195,6 +204,37 @@ class AclServiceAsyncImpl internal constructor(private val clientOptions: Client } } + private val batchUpdateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch_update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { batchUpdateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index 5e571994..c94852cc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -5,6 +5,8 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpResponseFor import com.braintrustdata.api.models.Acl +import com.braintrustdata.api.models.AclBatchUpdateParams +import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -56,6 +58,27 @@ interface AclService { /** @see [delete] */ fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl + /** + * Batch update acls. This operation is idempotent, so adding acls which already exist will have + * no effect, and removing acls which do not exist will have no effect. + */ + fun batchUpdate(): AclBatchUpdateResponse = batchUpdate(AclBatchUpdateParams.none()) + + /** @see [batchUpdate] */ + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AclBatchUpdateResponse + + /** @see [batchUpdate] */ + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): AclBatchUpdateResponse = batchUpdate(params, RequestOptions.none()) + + /** @see [batchUpdate] */ + fun batchUpdate(requestOptions: RequestOptions): AclBatchUpdateResponse = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) + /** Delete a single acl */ fun findAndDelete(params: AclFindAndDeleteParams): Acl = findAndDelete(params, RequestOptions.none()) @@ -129,6 +152,32 @@ interface AclService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** + * Returns a raw HTTP response for `post /v1/acl/batch_update`, but is otherwise the same as + * [AclService.batchUpdate]. + */ + @MustBeClosed + fun batchUpdate(): HttpResponseFor = + batchUpdate(AclBatchUpdateParams.none()) + + /** @see [batchUpdate] */ + @MustBeClosed + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [batchUpdate] */ + @MustBeClosed + fun batchUpdate( + params: AclBatchUpdateParams = AclBatchUpdateParams.none() + ): HttpResponseFor = batchUpdate(params, RequestOptions.none()) + + /** @see [batchUpdate] */ + @MustBeClosed + fun batchUpdate(requestOptions: RequestOptions): HttpResponseFor = + batchUpdate(AclBatchUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete /v1/acl`, but is otherwise the same as * [AclService.findAndDelete]. diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index ef37bddc..b6a1b9e0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -16,6 +16,8 @@ import com.braintrustdata.api.core.http.parseable import com.braintrustdata.api.core.prepare import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.models.Acl +import com.braintrustdata.api.models.AclBatchUpdateParams +import com.braintrustdata.api.models.AclBatchUpdateResponse import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -47,6 +49,13 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio // delete /v1/acl/{acl_id} withRawResponse().delete(params, requestOptions).parse() + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): AclBatchUpdateResponse = + // post /v1/acl/batch_update + withRawResponse().batchUpdate(params, requestOptions).parse() + override fun findAndDelete( params: AclFindAndDeleteParams, requestOptions: RequestOptions, @@ -167,6 +176,34 @@ class AclServiceImpl internal constructor(private val clientOptions: ClientOptio } } + private val batchUpdateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun batchUpdate( + params: AclBatchUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl", "batch_update") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { batchUpdateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val findAndDeleteHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) 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 new file mode 100644 index 00000000..ce3f43d3 --- /dev/null +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.braintrustdata.api.models + +import kotlin.test.assertNotNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AclBatchUpdateParamsTest { + + @Test + fun create() { + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType(AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val body = params._body() + + assertNotNull(body) + assertThat(body.addAcls()) + .contains( + listOf( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + assertThat(body.removeAcls()) + .contains( + listOf( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = AclBatchUpdateParams.builder().build() + + val body = params._body() + + assertNotNull(body) + } +} 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 510dfe93..5df9416c 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 @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.async import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClientAsync +import com.braintrustdata.api.models.AclBatchUpdateParams import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -98,6 +99,51 @@ class AclServiceAsyncTest { acl.validate() } + @Test + fun batchUpdate() { + val client = + BraintrustOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclServiceAsync = client.acls() + + val aclBatchUpdateResponseFuture = + aclServiceAsync.batchUpdate( + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + val aclBatchUpdateResponse = aclBatchUpdateResponseFuture.get() + aclBatchUpdateResponse.validate() + } + @Test fun findAndDelete() { val client = 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 ba3e2c4d..499ca976 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 @@ -4,6 +4,7 @@ package com.braintrustdata.api.services.blocking import com.braintrustdata.api.TestServerExtension import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.models.AclBatchUpdateParams import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclFindAndDeleteParams @@ -94,6 +95,50 @@ class AclServiceTest { acl.validate() } + @Test + fun batchUpdate() { + val client = + BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acls() + + val aclBatchUpdateResponse = + aclService.batchUpdate( + AclBatchUpdateParams.builder() + .addAddAcl( + AclBatchUpdateParams.AddAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.AddAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.AddAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.AddAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .addRemoveAcl( + AclBatchUpdateParams.RemoveAcl.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclBatchUpdateParams.RemoveAcl.ObjectType.ORGANIZATION) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .permission(AclBatchUpdateParams.RemoveAcl.Permission.CREATE) + .restrictObjectType( + AclBatchUpdateParams.RemoveAcl.RestrictObjectType.ORGANIZATION + ) + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + ) + + aclBatchUpdateResponse.validate() + } + @Test fun findAndDelete() { val client = From be6e2a679a76caf1e7ef03422ef91087a2c75981 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 18:40:49 +0000 Subject: [PATCH 80/87] feat(api): manual updates (#150) --- .stats.yml | 2 +- .../api/models/PromptOptions.kt | 60 ++++++++----------- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/.stats.yml b/.stats.yml index aef0f80c..24a7d1d7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 110 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-f5b152de2bdc5370d7c823d3ca415e1b914897ad98b117f1f0db213f44c0798f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-f0d64ce0e0efde75f9c171f7f3c3d4a72f00a77abb3bc5a7d65b7be1e715689b.yml diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 86756e3f..4680666c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -1776,8 +1776,7 @@ private constructor( fun schema(schema: JsonField) = apply { this.schema = schema } - fun schema(unionMember0: Schema.UnionMember0) = - schema(Schema.ofUnionMember0(unionMember0)) + fun schema(object_: Schema.Object) = schema(Schema.ofObject(object_)) fun schema(string: String) = schema(Schema.ofString(string)) @@ -1825,22 +1824,20 @@ private constructor( @JsonSerialize(using = Schema.Serializer::class) class Schema private constructor( - private val unionMember0: UnionMember0? = null, + private val object_: Object? = null, private val string: String? = null, private val _json: JsonValue? = null, ) { - fun unionMember0(): Optional = - Optional.ofNullable(unionMember0) + fun object_(): Optional = Optional.ofNullable(object_) fun string(): Optional = Optional.ofNullable(string) - fun isUnionMember0(): Boolean = unionMember0 != null + fun isObject(): Boolean = object_ != null fun isString(): Boolean = string != null - fun asUnionMember0(): UnionMember0 = - unionMember0.getOrThrow("unionMember0") + fun asObject(): Object = object_.getOrThrow("object_") fun asString(): String = string.getOrThrow("string") @@ -1848,7 +1845,7 @@ private constructor( fun accept(visitor: Visitor): T { return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + object_ != null -> visitor.visitObject(object_) string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -1863,8 +1860,8 @@ private constructor( accept( object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() + override fun visitObject(object_: Object) { + object_.validate() } override fun visitString(string: String) {} @@ -1878,14 +1875,14 @@ private constructor( return true } - return /* spotless:off */ other is Schema && unionMember0 == other.unionMember0 && string == other.string /* spotless:on */ + return /* spotless:off */ other is Schema && object_ == other.object_ && string == other.string /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, string) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(object_, string) /* spotless:on */ override fun toString(): String = when { - unionMember0 != null -> "Schema{unionMember0=$unionMember0}" + object_ != null -> "Schema{object_=$object_}" string != null -> "Schema{string=$string}" _json != null -> "Schema{_unknown=$_json}" else -> throw IllegalStateException("Invalid Schema") @@ -1893,9 +1890,7 @@ private constructor( companion object { - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Schema(unionMember0 = unionMember0) + @JvmStatic fun ofObject(object_: Object) = Schema(object_ = object_) @JvmStatic fun ofString(string: String) = Schema(string = string) } @@ -1906,7 +1901,7 @@ private constructor( */ interface Visitor { - fun visitUnionMember0(unionMember0: UnionMember0): T + fun visitObject(object_: Object): T fun visitString(string: String): T @@ -1931,11 +1926,9 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Schema { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return Schema(unionMember0 = it, _json = json) + return Schema(object_ = it, _json = json) } tryDeserialize(node, jacksonTypeRef())?.let { return Schema(string = it, _json = json) @@ -1953,8 +1946,8 @@ private constructor( provider: SerializerProvider, ) { when { - value.unionMember0 != null -> - generator.writeObject(value.unionMember0) + value.object_ != null -> + generator.writeObject(value.object_) value.string != null -> generator.writeObject(value.string) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Schema") @@ -1963,7 +1956,7 @@ private constructor( } @NoAutoDetect - class UnionMember0 + class Object @JsonCreator private constructor( @JsonAnySetter @@ -1978,7 +1971,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnionMember0 = apply { + fun validate(): Object = apply { if (validated) { return@apply } @@ -1992,12 +1985,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [UnionMember0]. + * [Object]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnionMember0]. */ + /** A builder for [Object]. */ class Builder internal constructor() { private var additionalProperties: @@ -2005,9 +1998,9 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { + internal fun from(object_: Object) = apply { additionalProperties = - unionMember0.additionalProperties.toMutableMap() + object_.additionalProperties.toMutableMap() } fun additionalProperties( @@ -2036,8 +2029,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): UnionMember0 = - UnionMember0(additionalProperties.toImmutable()) + fun build(): Object = Object(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2045,7 +2037,7 @@ private constructor( return true } - return /* spotless:off */ other is UnionMember0 && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Object && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2055,7 +2047,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnionMember0{additionalProperties=$additionalProperties}" + "Object{additionalProperties=$additionalProperties}" } } From be0354dbb77893f24083ea294531d8f7a1e00309 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 20:53:13 +0000 Subject: [PATCH 81/87] feat(api): manual updates (#151) --- .../com/braintrustdata/api/models/Acl.kt | 489 +-------- .../api/models/AclBatchUpdateParams.kt | 986 +----------------- .../api/models/AclCreateParams.kt | 505 +-------- .../api/models/AclFindAndDeleteParams.kt | 505 +-------- .../api/models/AclListParams.kt | 168 +-- .../api/models/AclObjectType.kt | 162 +++ .../api/models/EnvVarListParams.kt | 122 +-- .../api/models/EnvVarObjectType.kt | 115 ++ .../com/braintrustdata/api/models/Function.kt | 171 +-- .../api/models/FunctionCreateParams.kt | 171 +-- .../api/models/FunctionReplaceParams.kt | 171 +-- .../braintrustdata/api/models/Permission.kt | 146 +++ .../braintrustdata/api/models/ProjectScore.kt | 148 +-- .../api/models/ProjectScoreCreateParams.kt | 156 +-- .../api/models/ProjectScoreListParams.kt | 281 +---- .../api/models/ProjectScoreReplaceParams.kt | 156 +-- .../api/models/ProjectScoreType.kt | 139 +++ .../api/models/ProjectScoreUpdateParams.kt | 160 +-- .../com/braintrustdata/api/models/Role.kt | 324 +----- .../api/models/RoleCreateParams.kt | 324 +----- .../api/models/RoleReplaceParams.kt | 324 +----- .../api/models/RoleUpdateParams.kt | 646 +----------- .../api/models/SpanAttributes.kt | 141 +-- .../com/braintrustdata/api/models/SpanType.kt | 130 +++ .../com/braintrustdata/api/models/View.kt | 171 +-- .../api/models/ViewCreateParams.kt | 177 +--- .../api/models/ViewDeleteParams.kt | 179 +--- .../api/models/ViewListParams.kt | 323 +----- .../api/models/ViewReplaceParams.kt | 177 +--- .../api/models/ViewRetrieveParams.kt | 169 +-- .../com/braintrustdata/api/models/ViewType.kt | 160 +++ .../api/models/ViewUpdateParams.kt | 177 +--- .../api/models/AclBatchUpdateParamsTest.kt | 46 +- .../api/models/AclBatchUpdateResponseTest.kt | 24 +- .../api/models/AclCreateParamsTest.kt | 23 +- .../api/models/AclFindAndDeleteParamsTest.kt | 23 +- .../api/models/AclListParamsTest.kt | 10 +- .../com/braintrustdata/api/models/AclTest.kt | 12 +- .../api/models/EnvVarListParamsTest.kt | 6 +- .../api/models/ExperimentEventTest.kt | 6 +- .../api/models/ExperimentInsertParamsTest.kt | 12 +- .../FetchExperimentEventsResponseTest.kt | 7 +- .../FetchProjectLogsEventsResponseTest.kt | 7 +- .../api/models/FunctionCreateParamsTest.kt | 6 +- .../api/models/FunctionReplaceParamsTest.kt | 6 +- .../braintrustdata/api/models/FunctionTest.kt | 4 +- .../api/models/InsertExperimentEventTest.kt | 6 +- .../api/models/InsertProjectLogsEventTest.kt | 6 +- .../api/models/ProjectLogInsertParamsTest.kt | 12 +- .../api/models/ProjectLogsEventTest.kt | 6 +- .../models/ProjectScoreCreateParamsTest.kt | 10 +- .../api/models/ProjectScoreListParamsTest.kt | 8 +- .../models/ProjectScoreReplaceParamsTest.kt | 10 +- .../api/models/ProjectScoreTest.kt | 4 +- .../models/ProjectScoreUpdateParamsTest.kt | 6 +- .../api/models/RoleCreateParamsTest.kt | 18 +- .../api/models/RoleReplaceParamsTest.kt | 18 +- .../com/braintrustdata/api/models/RoleTest.kt | 8 +- .../api/models/RoleUpdateParamsTest.kt | 36 +- .../api/models/SpanAttributesTest.kt | 5 +- .../api/models/ViewCreateParamsTest.kt | 10 +- .../api/models/ViewDeleteParamsTest.kt | 12 +- .../api/models/ViewListParamsTest.kt | 16 +- .../api/models/ViewReplaceParamsTest.kt | 10 +- .../api/models/ViewRetrieveParamsTest.kt | 12 +- .../com/braintrustdata/api/models/ViewTest.kt | 4 +- .../api/models/ViewUpdateParamsTest.kt | 12 +- .../api/services/async/AclServiceAsyncTest.kt | 32 +- .../services/async/EnvVarServiceAsyncTest.kt | 3 +- .../async/ExperimentServiceAsyncTest.kt | 6 +- .../async/FunctionServiceAsyncTest.kt | 5 +- .../async/ProjectScoreServiceAsyncTest.kt | 7 +- .../services/async/RoleServiceAsyncTest.kt | 27 +- .../services/async/ViewServiceAsyncTest.kt | 13 +- .../async/projects/LogServiceAsyncTest.kt | 6 +- .../api/services/blocking/AclServiceTest.kt | 32 +- .../services/blocking/EnvVarServiceTest.kt | 3 +- .../blocking/ExperimentServiceTest.kt | 6 +- .../services/blocking/FunctionServiceTest.kt | 5 +- .../blocking/ProjectScoreServiceTest.kt | 7 +- .../api/services/blocking/RoleServiceTest.kt | 27 +- .../api/services/blocking/ViewServiceTest.kt | 13 +- .../blocking/projects/LogServiceTest.kt | 6 +- 83 files changed, 1378 insertions(+), 7414 deletions(-) create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarObjectType.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Permission.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreType.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanType.kt create mode 100644 braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt 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 16db9180..63a1c1b0 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 @@ -2666,7 +2666,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(), @@ -2678,7 +2678,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 @@ -2692,7 +2692,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 @@ -2737,7 +2737,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() @@ -2756,10 +2756,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 } @@ -2815,165 +2815,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 bd9be34c..88dd5734 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 @@ -2666,7 +2666,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(), @@ -2678,7 +2678,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 @@ -2692,7 +2692,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 @@ -2737,7 +2737,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() @@ -2756,10 +2756,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 } @@ -2815,165 +2815,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") From 73fb462b4574596a30820dbab116ba57fab47460 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 06:32:30 +0000 Subject: [PATCH 82/87] docs: deduplicate and refine comments (#152) --- .../client/okhttp/BraintrustOkHttpClient.kt | 1 + .../okhttp/BraintrustOkHttpClientAsync.kt | 1 + .../braintrustdata/api/core/ClientOptions.kt | 1 + .../com/braintrustdata/api/core/Timeout.kt | 35 +- .../com/braintrustdata/api/models/AISecret.kt | 157 +- .../com/braintrustdata/api/models/Acl.kt | 206 +- .../api/models/AclBatchUpdateParams.kt | 467 +++-- .../api/models/AclBatchUpdateResponse.kt | 65 +- .../api/models/AclCreateParams.kt | 286 ++- .../api/models/AclFindAndDeleteParams.kt | 286 ++- .../api/models/AclListParams.kt | 39 +- .../api/models/AiSecretCreateParams.kt | 193 +- .../api/models/AiSecretFindAndDeleteParams.kt | 87 +- .../api/models/AiSecretListParams.kt | 46 +- .../api/models/AiSecretReplaceParams.kt | 193 +- .../api/models/AiSecretUpdateParams.kt | 146 +- .../com/braintrustdata/api/models/ApiKey.kt | 124 +- .../api/models/ApiKeyCreateParams.kt | 87 +- .../api/models/ApiKeyListParams.kt | 43 +- .../models/ChatCompletionContentPartImage.kt | 63 + .../models/ChatCompletionContentPartText.kt | 30 + .../models/ChatCompletionMessageToolCall.kt | 78 + .../braintrustdata/api/models/CodeBundle.kt | 246 ++- .../api/models/CreateApiKeyOutput.kt | 144 +- .../api/models/CrossObjectInsertResponse.kt | 69 +- .../braintrustdata/api/models/DataSummary.kt | 22 +- .../com/braintrustdata/api/models/Dataset.kt | 176 +- .../api/models/DatasetCreateParams.kt | 176 +- .../braintrustdata/api/models/DatasetEvent.kt | 263 ++- .../api/models/DatasetFeedbackParams.kt | 55 +- .../api/models/DatasetFetchParams.kt | 63 +- .../api/models/DatasetFetchPostParams.kt | 379 +--- .../api/models/DatasetInsertParams.kt | 55 +- .../api/models/DatasetListParams.kt | 47 +- .../api/models/DatasetSummarizeParams.kt | 8 +- .../api/models/DatasetUpdateParams.kt | 138 +- .../com/braintrustdata/api/models/EnvVar.kt | 127 +- .../api/models/EnvVarCreateParams.kt | 169 +- .../api/models/EnvVarListParams.kt | 29 +- .../api/models/EnvVarListResponse.kt | 28 +- .../api/models/EnvVarReplaceParams.kt | 169 +- .../api/models/EnvVarUpdateParams.kt | 87 +- .../api/models/EvalCreateParams.kt | 1748 ++++++++++++++--- .../braintrustdata/api/models/Experiment.kt | 301 ++- .../api/models/ExperimentCreateParams.kt | 462 +++-- .../api/models/ExperimentEvent.kt | 599 ++++-- .../api/models/ExperimentFeedbackParams.kt | 55 +- .../api/models/ExperimentFetchParams.kt | 63 +- .../api/models/ExperimentFetchPostParams.kt | 379 +--- .../api/models/ExperimentInsertParams.kt | 55 +- .../api/models/ExperimentListParams.kt | 47 +- .../api/models/ExperimentSummarizeParams.kt | 16 +- .../api/models/ExperimentUpdateParams.kt | 362 +++- .../api/models/FeedbackDatasetItem.kt | 110 +- .../api/models/FeedbackExperimentItem.kt | 129 +- .../api/models/FeedbackProjectLogsItem.kt | 129 +- .../api/models/FeedbackResponseSchema.kt | 15 + .../api/models/FetchDatasetEventsResponse.kt | 49 +- .../models/FetchExperimentEventsResponse.kt | 49 +- .../models/FetchProjectLogsEventsResponse.kt | 49 +- .../com/braintrustdata/api/models/Function.kt | 681 ++++++- .../api/models/FunctionCreateParams.kt | 776 +++++++- .../api/models/FunctionInvokeParams.kt | 828 +++++++- .../api/models/FunctionListParams.kt | 56 +- .../api/models/FunctionReplaceParams.kt | 776 +++++++- .../api/models/FunctionUpdateParams.kt | 517 ++++- .../com/braintrustdata/api/models/Group.kt | 200 +- .../api/models/GroupCreateParams.kt | 246 ++- .../api/models/GroupListParams.kt | 43 +- .../api/models/GroupReplaceParams.kt | 246 ++- .../api/models/GroupUpdateParams.kt | 337 +++- .../api/models/InsertDatasetEvent.kt | 513 ++--- .../api/models/InsertEventsResponse.kt | 20 +- .../api/models/InsertExperimentEvent.kt | 824 ++++---- .../api/models/InsertProjectLogsEvent.kt | 824 ++++---- .../api/models/MetricSummary.kt | 123 +- .../api/models/ObjectReference.kt | 103 +- .../api/models/OnlineScoreConfig.kt | 179 +- .../braintrustdata/api/models/Organization.kt | 135 +- .../api/models/OrganizationListParams.kt | 41 +- .../models/OrganizationMemberUpdateParams.kt | 439 ++++- .../api/models/OrganizationUpdateParams.kt | 191 +- .../models/PatchOrganizationMembersOutput.kt | 55 +- .../com/braintrustdata/api/models/Project.kt | 146 +- .../api/models/ProjectCreateParams.kt | 87 +- .../api/models/ProjectListParams.kt | 43 +- .../api/models/ProjectLogFeedbackParams.kt | 55 +- .../api/models/ProjectLogFetchParams.kt | 63 +- .../api/models/ProjectLogFetchPostParams.kt | 379 +--- .../api/models/ProjectLogInsertParams.kt | 55 +- .../api/models/ProjectLogsEvent.kt | 620 ++++-- .../braintrustdata/api/models/ProjectScore.kt | 211 +- .../api/models/ProjectScoreCategory.kt | 41 +- .../api/models/ProjectScoreConfig.kt | 57 + .../api/models/ProjectScoreCreateParams.kt | 263 ++- .../api/models/ProjectScoreListParams.kt | 55 +- .../api/models/ProjectScoreReplaceParams.kt | 263 ++- .../api/models/ProjectScoreUpdateParams.kt | 229 ++- .../api/models/ProjectSettings.kt | 144 +- .../braintrustdata/api/models/ProjectTag.kt | 145 +- .../api/models/ProjectTagCreateParams.kt | 175 +- .../api/models/ProjectTagListParams.kt | 47 +- .../api/models/ProjectTagReplaceParams.kt | 175 +- .../api/models/ProjectTagUpdateParams.kt | 137 +- .../api/models/ProjectUpdateParams.kt | 86 +- .../com/braintrustdata/api/models/Prompt.kt | 275 ++- .../api/models/PromptCreateParams.kt | 309 ++- .../braintrustdata/api/models/PromptData.kt | 736 +++++++ .../api/models/PromptListParams.kt | 56 +- .../api/models/PromptOptions.kt | 802 +++++++- .../api/models/PromptReplaceParams.kt | 309 ++- .../api/models/PromptUpdateParams.kt | 241 ++- .../com/braintrustdata/api/models/RepoInfo.kt | 206 +- .../com/braintrustdata/api/models/Role.kt | 257 ++- .../api/models/RoleCreateParams.kt | 290 ++- .../api/models/RoleListParams.kt | 43 +- .../api/models/RoleReplaceParams.kt | 290 ++- .../api/models/RoleUpdateParams.kt | 427 +++- .../braintrustdata/api/models/ScoreSummary.kt | 103 +- .../api/models/SpanAttributes.kt | 45 +- .../braintrustdata/api/models/SpanIFrame.kt | 198 +- .../api/models/SpanIframeCreateParams.kt | 221 ++- .../api/models/SpanIframeListParams.kt | 43 +- .../api/models/SpanIframeReplaceParams.kt | 221 ++- .../api/models/SpanIframeUpdateParams.kt | 187 +- .../api/models/SummarizeDatasetResponse.kt | 108 +- .../api/models/SummarizeExperimentResponse.kt | 156 +- .../com/braintrustdata/api/models/User.kt | 135 +- .../api/models/UserListParams.kt | 86 +- .../com/braintrustdata/api/models/View.kt | 218 +- .../api/models/ViewCreateParams.kt | 353 +++- .../com/braintrustdata/api/models/ViewData.kt | 18 + .../api/models/ViewDataSearch.kt | 89 + .../api/models/ViewDeleteParams.kt | 84 +- .../api/models/ViewListParams.kt | 43 +- .../braintrustdata/api/models/ViewOptions.kt | 107 + .../api/models/ViewReplaceParams.kt | 353 +++- .../api/models/ViewUpdateParams.kt | 311 ++- 138 files changed, 21642 insertions(+), 7008 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 94c291ac..3bcb97dc 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -146,6 +146,7 @@ class BraintrustOkHttpClient private constructor() { fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) fun fromEnv() = apply { clientOptions.fromEnv() } diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index ffc88f5c..008b59ad 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -148,6 +148,7 @@ class BraintrustOkHttpClientAsync private constructor() { fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) fun fromEnv() = apply { clientOptions.fromEnv() } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 38dc1b87..0c70ecf4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -94,6 +94,7 @@ private constructor( fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) fun headers(headers: Headers) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt index 6a0cdcc7..0ca642cc 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt @@ -90,13 +90,7 @@ private constructor( */ fun connect(connect: Duration?) = apply { this.connect = connect } - /** - * The maximum time allowed to establish a connection with a host. - * - * A value of [Duration.ZERO] means there's no timeout. - * - * Defaults to `Duration.ofMinutes(1)`. - */ + /** Alias for calling [Builder.connect] with `connect.orElse(null)`. */ fun connect(connect: Optional) = connect(connect.getOrNull()) /** @@ -108,13 +102,7 @@ private constructor( */ fun read(read: Duration?) = apply { this.read = read } - /** - * The maximum time allowed between two data packets when waiting for the server’s response. - * - * A value of [Duration.ZERO] means there's no timeout. - * - * Defaults to `request()`. - */ + /** Alias for calling [Builder.read] with `read.orElse(null)`. */ fun read(read: Optional) = read(read.getOrNull()) /** @@ -126,13 +114,7 @@ private constructor( */ fun write(write: Duration?) = apply { this.write = write } - /** - * The maximum time allowed between two data packets when sending the request to the server. - * - * A value of [Duration.ZERO] means there's no timeout. - * - * Defaults to `request()`. - */ + /** Alias for calling [Builder.write] with `write.orElse(null)`. */ fun write(write: Optional) = write(write.getOrNull()) /** @@ -147,16 +129,7 @@ private constructor( */ fun request(request: Duration?) = apply { this.request = request } - /** - * The maximum time allowed for a complete HTTP call, not including retries. - * - * This includes resolving DNS, connecting, writing the request body, server processing, as - * well as reading the response body. - * - * A value of [Duration.ZERO] means there's no timeout. - * - * Defaults to `Duration.ofMinutes(1)`. - */ + /** Alias for calling [Builder.request] with `request.orElse(null)`. */ fun request(request: Optional) = request(request.getOrNull()) fun build(): Timeout = Timeout(connect, read, write, request) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index b0cad87e..041565d0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -10,6 +10,7 @@ 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 @@ -42,50 +43,122 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the AI secret */ + /** + * Unique identifier for the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the organization */ + /** + * Unique identifier for the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun orgId(): String = orgId.getRequired("org_id") - /** Date of AI secret creation */ + /** + * Date of AI secret creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun previewSecret(): Optional = Optional.ofNullable(previewSecret.getNullable("preview_secret")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - /** Date of last AI secret update */ + /** + * Date of last AI secret update + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun updatedAt(): Optional = Optional.ofNullable(updatedAt.getNullable("updated_at")) - /** Unique identifier for the AI secret */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the organization */ + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Date of AI secret creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [previewSecret]. + * + * Unlike [previewSecret], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("preview_secret") @ExcludeMissing fun _previewSecret(): JsonField = previewSecret + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - /** Date of last AI secret update */ + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt @@ -158,59 +231,109 @@ private constructor( /** Unique identifier for the AI secret */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the AI secret */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - /** Unique identifier for the organization */ + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Date of AI secret creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of AI secret creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of AI secret creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun previewSecret(previewSecret: String?) = previewSecret(JsonField.ofNullable(previewSecret)) + /** Alias for calling [Builder.previewSecret] with `previewSecret.orElse(null)`. */ fun previewSecret(previewSecret: Optional) = previewSecret(previewSecret.getOrNull()) + /** + * Sets [Builder.previewSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.previewSecret] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun previewSecret(previewSecret: JsonField) = apply { this.previewSecret = previewSecret } fun type(type: String?) = type(JsonField.ofNullable(type)) + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } /** Date of last AI secret update */ fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) - /** Date of last AI secret update */ + /** Alias for calling [Builder.updatedAt] with `updatedAt.orElse(null)`. */ fun updatedAt(updatedAt: Optional) = updatedAt(updatedAt.getOrNull()) - /** Date of last AI secret update */ + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } fun additionalProperties(additionalProperties: Map) = apply { 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 bf184e19..09ff74d7 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 @@ -10,6 +10,7 @@ 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 @@ -64,87 +65,165 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the acl */ + /** + * Unique identifier for the acl + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** The organization the ACL's referred object belongs to */ + /** + * The organization the ACL's referred object belongs to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun _objectOrgId(): String = _objectOrgId.getRequired("_object_org_id") - /** The id of the object the ACL applies to */ + /** + * The id of the object the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") - /** Date of acl creation */ + /** + * Date of acl creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ 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 */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the acl */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The organization the ACL's referred object belongs to */ + /** + * Returns the raw JSON value of [_objectOrgId]. + * + * Unlike [_objectOrgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("_object_org_id") @ExcludeMissing fun __objectOrgId(): JsonField = _objectOrgId - /** The id of the object the ACL applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Date of acl creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Returns the raw JSON value of [groupId]. + * + * Unlike [groupId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [permission]. + * + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @@ -223,13 +302,24 @@ private constructor( /** Unique identifier for the acl */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the acl */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** The organization the ACL's referred object belongs to */ fun _objectOrgId(_objectOrgId: String) = _objectOrgId(JsonField.of(_objectOrgId)) - /** The organization the ACL's referred object belongs to */ + /** + * Sets [Builder._objectOrgId] to an arbitrary JSON value. + * + * You should usually call [Builder._objectOrgId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun _objectOrgId(_objectOrgId: JsonField) = apply { this._objectOrgId = _objectOrgId } @@ -237,13 +327,24 @@ private constructor( /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the ACL applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -251,10 +352,16 @@ private constructor( /** Date of acl creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of acl creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of acl creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** @@ -263,25 +370,30 @@ private constructor( */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.groupId] with `groupId.orElse(null)`. */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.groupId] to an arbitrary JSON value. + * + * You should usually call [Builder.groupId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** Alias for calling [Builder.permission] with `permission.orElse(null)`. */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Sets [Builder.permission] to an arbitrary JSON value. + * + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun permission(permission: JsonField) = apply { this.permission = permission } /** @@ -292,15 +404,17 @@ private constructor( 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`. + * Alias for calling [Builder.restrictObjectType] with `restrictObjectType.orElse(null)`. */ 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`. + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed [AclObjectType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType @@ -311,13 +425,14 @@ private constructor( */ fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun roleId(roleId: JsonField) = apply { this.roleId = roleId } @@ -327,15 +442,14 @@ private constructor( */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun userId(userId: JsonField) = apply { this.userId = userId } 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 c133533b..2160900e 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 @@ -14,6 +14,7 @@ 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 @@ -42,6 +43,9 @@ private constructor( * * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun addAcls(): Optional> = body.addAcls() @@ -54,30 +58,23 @@ private constructor( * * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun removeAcls(): Optional> = body.removeAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Returns the raw JSON value of [addAcls]. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * Unlike [addAcls], this method doesn't throw if the JSON field has an unexpected type. */ fun _addAcls(): JsonField> = body._addAcls() /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * Returns the raw JSON value of [removeAcls]. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * Unlike [removeAcls], this method doesn't throw if the JSON field has an unexpected type. */ fun _removeAcls(): JsonField> = body._removeAcls() @@ -116,6 +113,9 @@ private constructor( * * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun addAcls(): Optional> = Optional.ofNullable(addAcls.getNullable("add_acls")) @@ -128,31 +128,24 @@ private constructor( * * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in * the ACL, as part of a direct permission grant or as part of a role. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun removeAcls(): Optional> = Optional.ofNullable(removeAcls.getNullable("remove_acls")) /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * Returns the raw JSON value of [addAcls]. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * Unlike [addAcls], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("add_acls") @ExcludeMissing fun _addAcls(): JsonField> = addAcls /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Returns the raw JSON value of [removeAcls]. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * Unlike [removeAcls], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("remove_acls") @ExcludeMissing @@ -209,44 +202,24 @@ private constructor( */ fun addAcls(addAcls: List?) = addAcls(JsonField.ofNullable(addAcls)) - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ + /** Alias for calling [Builder.addAcls] with `addAcls.orElse(null)`. */ fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Sets [Builder.addAcls] to an arbitrary JSON value. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * You should usually call [Builder.addAcls] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun addAcls(addAcls: JsonField>) = apply { this.addAcls = addAcls.map { it.toMutableList() } } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Adds a single [AddAcl] to [addAcls]. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addAddAcl(addAcl: AddAcl) = apply { addAcls = @@ -269,45 +242,25 @@ private constructor( fun removeAcls(removeAcls: List?) = removeAcls(JsonField.ofNullable(removeAcls)) - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. - */ + /** Alias for calling [Builder.removeAcls] with `removeAcls.orElse(null)`. */ fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * Sets [Builder.removeAcls] to an arbitrary JSON value. * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * You should usually call [Builder.removeAcls] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ fun removeAcls(removeAcls: JsonField>) = apply { this.removeAcls = removeAcls.map { it.toMutableList() } } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Adds a single [RemoveAcl] to [removeAcls]. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify - * `restrict_object_type` in the ACL, as part of a direct permission grant or as part of - * a role. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addRemoveAcl(removeAcl: RemoveAcl) = apply { removeAcls = @@ -398,39 +351,22 @@ private constructor( */ fun addAcls(addAcls: List?) = apply { body.addAcls(addAcls) } - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ + /** Alias for calling [Builder.addAcls] with `addAcls.orElse(null)`. */ fun addAcls(addAcls: Optional>) = addAcls(addAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Sets [Builder.addAcls] to an arbitrary JSON value. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * You should usually call [Builder.addAcls] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun addAcls(addAcls: JsonField>) = apply { body.addAcls(addAcls) } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Adds a single [AddAcl] to [addAcls]. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addAddAcl(addAcl: AddAcl) = apply { body.addAddAcl(addAcl) } @@ -446,41 +382,24 @@ private constructor( */ fun removeAcls(removeAcls: List?) = apply { body.removeAcls(removeAcls) } - /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. - */ + /** Alias for calling [Builder.removeAcls] with `removeAcls.orElse(null)`. */ fun removeAcls(removeAcls: Optional>) = removeAcls(removeAcls.getOrNull()) /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * Sets [Builder.removeAcls] to an arbitrary JSON value. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * You should usually call [Builder.removeAcls] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun removeAcls(removeAcls: JsonField>) = apply { body.removeAcls(removeAcls) } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Adds a single [RemoveAcl] to [removeAcls]. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addRemoveAcl(removeAcl: RemoveAcl) = apply { body.addRemoveAcl(removeAcl) } @@ -648,75 +567,120 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the object the ACL applies to */ + /** + * The id of the object the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** The id of the object the ACL applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Returns the raw JSON value of [groupId]. + * + * Unlike [groupId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [permission]. + * + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @@ -784,13 +748,25 @@ private constructor( /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the ACL applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -801,15 +777,15 @@ private constructor( */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.groupId] with `groupId.orElse(null)`. */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.groupId] to an arbitrary JSON value. + * + * You should usually call [Builder.groupId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun groupId(groupId: JsonField) = apply { this.groupId = groupId } @@ -818,13 +794,15 @@ private constructor( */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ + /** Alias for calling [Builder.permission] with `permission.orElse(null)`. */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Sets [Builder.permission] to an arbitrary JSON value. + * + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -838,15 +816,18 @@ private constructor( 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`. + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. */ 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`. + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType @@ -858,15 +839,15 @@ private constructor( */ fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun roleId(roleId: JsonField) = apply { this.roleId = roleId } @@ -876,15 +857,15 @@ private constructor( */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun userId(userId: JsonField) = apply { this.userId = userId } @@ -977,75 +958,120 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the object the ACL applies to */ + /** + * The id of the object the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** The id of the object the ACL applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Returns the raw JSON value of [groupId]. + * + * Unlike [groupId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [permission]. + * + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @@ -1113,13 +1139,25 @@ private constructor( /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the ACL applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -1130,15 +1168,15 @@ private constructor( */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.groupId] with `groupId.orElse(null)`. */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.groupId] to an arbitrary JSON value. + * + * You should usually call [Builder.groupId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun groupId(groupId: JsonField) = apply { this.groupId = groupId } @@ -1147,13 +1185,15 @@ private constructor( */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ + /** Alias for calling [Builder.permission] with `permission.orElse(null)`. */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Sets [Builder.permission] to an arbitrary JSON value. + * + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -1167,15 +1207,18 @@ private constructor( 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`. + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. */ 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`. + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType @@ -1187,15 +1230,15 @@ private constructor( */ fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun roleId(roleId: JsonField) = apply { this.roleId = roleId } @@ -1205,15 +1248,15 @@ private constructor( */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun userId(userId: JsonField) = apply { this.userId = userId } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index eec25147..bb393790 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -11,6 +11,7 @@ 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 @@ -39,6 +40,9 @@ private constructor( * * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun addedAcls(): List = addedAcls.getRequired("added_acls") @@ -51,30 +55,23 @@ private constructor( * * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the * ACL, as part of a direct permission grant or as part of a role. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun removedAcls(): List = removedAcls.getRequired("removed_acls") /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Returns the raw JSON value of [addedAcls]. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * Unlike [addedAcls], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("added_acls") @ExcludeMissing fun _addedAcls(): JsonField> = addedAcls /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, dataset, - * etc. created within that project. + * Returns the raw JSON value of [removedAcls]. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. + * Unlike [removedAcls], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("removed_acls") @ExcludeMissing @@ -139,28 +136,20 @@ private constructor( fun addedAcls(addedAcls: List) = addedAcls(JsonField.of(addedAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Sets [Builder.addedAcls] to an arbitrary JSON value. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * You should usually call [Builder.addedAcls] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun addedAcls(addedAcls: JsonField>) = apply { this.addedAcls = addedAcls.map { it.toMutableList() } } /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * Adds a single [Acl] to [addedAcls]. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addAddedAcl(addedAcl: Acl) = apply { addedAcls = @@ -182,28 +171,20 @@ private constructor( fun removedAcls(removedAcls: List) = removedAcls(JsonField.of(removedAcls)) /** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. + * Sets [Builder.removedAcls] to an arbitrary JSON value. * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * You should usually call [Builder.removedAcls] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun removedAcls(removedAcls: JsonField>) = apply { this.removedAcls = removedAcls.map { it.toMutableList() } } /** - * An ACL grants a certain permission or role to a certain user or group on an object. + * Adds a single [Acl] to [removedAcls]. * - * ACLs are inherited across the object hierarchy. So for example, if a user has read - * permissions on a project, they will also have read permissions on any experiment, - * dataset, etc. created within that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in - * the ACL, as part of a direct permission grant or as part of a role. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addRemovedAcl(removedAcl: Acl) = apply { removedAcls = 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 c6266e37..387d9a11 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 @@ -13,6 +13,7 @@ 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 @@ -32,59 +33,110 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** The id of the object the ACL applies to */ + /** + * The id of the object the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = body.objectId() - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = body.objectType() /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun groupId(): Optional = body.groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun permission(): Optional = body.permission() /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun restrictObjectType(): Optional = body.restrictObjectType() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun roleId(): Optional = body.roleId() /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun userId(): Optional = body.userId() - /** The id of the object the ACL applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectId(): JsonField = body._objectId() - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectType(): JsonField = body._objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Returns the raw JSON value of [groupId]. + * + * Unlike [groupId], this method doesn't throw if the JSON field has an unexpected type. */ fun _groupId(): JsonField = body._groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [permission]. + * + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. + */ fun _permission(): JsonField = body._permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an unexpected + * type. */ fun _restrictObjectType(): JsonField = body._restrictObjectType() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _roleId(): JsonField = body._roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. */ fun _userId(): JsonField = body._userId() @@ -139,75 +191,120 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the object the ACL applies to */ + /** + * The id of the object the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** The id of the object the ACL applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Returns the raw JSON value of [groupId]. + * + * Unlike [groupId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [permission]. + * + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @@ -275,13 +372,25 @@ private constructor( /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the ACL applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -292,15 +401,15 @@ private constructor( */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.groupId] with `groupId.orElse(null)`. */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.groupId] to an arbitrary JSON value. + * + * You should usually call [Builder.groupId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun groupId(groupId: JsonField) = apply { this.groupId = groupId } @@ -309,13 +418,15 @@ private constructor( */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ + /** Alias for calling [Builder.permission] with `permission.orElse(null)`. */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Sets [Builder.permission] to an arbitrary JSON value. + * + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -329,15 +440,18 @@ private constructor( 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`. + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. */ 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`. + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType @@ -349,15 +463,15 @@ private constructor( */ fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun roleId(roleId: JsonField) = apply { this.roleId = roleId } @@ -367,15 +481,15 @@ private constructor( */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun userId(userId: JsonField) = apply { this.userId = userId } @@ -463,13 +577,24 @@ private constructor( /** The id of the object the ACL applies to */ fun objectId(objectId: String) = apply { body.objectId(objectId) } - /** The id of the object the ACL applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** @@ -478,25 +603,30 @@ private constructor( */ fun groupId(groupId: String?) = apply { body.groupId(groupId) } - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.groupId] with `groupId.orElse(null)`. */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.groupId] to an arbitrary JSON value. + * + * You should usually call [Builder.groupId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission?) = apply { body.permission(permission) } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** Alias for calling [Builder.permission] with `permission.orElse(null)`. */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Sets [Builder.permission] to an arbitrary JSON value. + * + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun permission(permission: JsonField) = apply { body.permission(permission) } /** @@ -508,15 +638,17 @@ 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`. + * Alias for calling [Builder.restrictObjectType] with `restrictObjectType.orElse(null)`. */ 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`. + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed [AclObjectType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ fun restrictObjectType(restrictObjectType: JsonField) = apply { body.restrictObjectType(restrictObjectType) @@ -527,13 +659,14 @@ private constructor( */ fun roleId(roleId: String?) = apply { body.roleId(roleId) } - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } @@ -543,15 +676,14 @@ private constructor( */ fun userId(userId: String?) = apply { body.userId(userId) } - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun userId(userId: JsonField) = apply { body.userId(userId) } 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 237fc6b6..968fe6ce 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 @@ -13,6 +13,7 @@ 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 @@ -29,59 +30,110 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** The id of the object the ACL applies to */ + /** + * The id of the object the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = body.objectId() - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = body.objectType() /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun groupId(): Optional = body.groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun permission(): Optional = body.permission() /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun restrictObjectType(): Optional = body.restrictObjectType() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun roleId(): Optional = body.roleId() /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun userId(): Optional = body.userId() - /** The id of the object the ACL applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectId(): JsonField = body._objectId() - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectType(): JsonField = body._objectType() /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Returns the raw JSON value of [groupId]. + * + * Unlike [groupId], this method doesn't throw if the JSON field has an unexpected type. */ fun _groupId(): JsonField = body._groupId() - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [permission]. + * + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. + */ fun _permission(): JsonField = body._permission() /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an unexpected + * type. */ fun _restrictObjectType(): JsonField = body._restrictObjectType() - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _roleId(): JsonField = body._roleId() /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. */ fun _userId(): JsonField = body._userId() @@ -136,75 +188,120 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the object the ACL applies to */ + /** + * The id of the object the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun permission(): Optional = Optional.ofNullable(permission.getNullable("permission")) /** * When setting a permission directly, optionally restricts the permission grant to just the * specified object type. Cannot be set alongside a `role_id`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun roleId(): Optional = Optional.ofNullable(roleId.getNullable("role_id")) /** * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be * provided + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** The id of the object the ACL applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Returns the raw JSON value of [groupId]. + * + * Unlike [groupId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Returns the raw JSON value of [permission]. + * + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @@ -272,13 +369,25 @@ private constructor( /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the ACL applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -289,15 +398,15 @@ private constructor( */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.groupId] with `groupId.orElse(null)`. */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.groupId] to an arbitrary JSON value. + * + * You should usually call [Builder.groupId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun groupId(groupId: JsonField) = apply { this.groupId = groupId } @@ -306,13 +415,15 @@ private constructor( */ fun permission(permission: Permission?) = permission(JsonField.ofNullable(permission)) - /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ + /** Alias for calling [Builder.permission] with `permission.orElse(null)`. */ fun permission(permission: Optional) = permission(permission.getOrNull()) /** - * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Sets [Builder.permission] to an arbitrary JSON value. + * + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -326,15 +437,18 @@ private constructor( 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`. + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. */ 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`. + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType @@ -346,15 +460,15 @@ private constructor( */ fun roleId(roleId: String?) = roleId(JsonField.ofNullable(roleId)) - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided - */ + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be - * provided + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun roleId(roleId: JsonField) = apply { this.roleId = roleId } @@ -364,15 +478,15 @@ private constructor( */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun userId(userId: JsonField) = apply { this.userId = userId } @@ -460,13 +574,24 @@ private constructor( /** The id of the object the ACL applies to */ fun objectId(objectId: String) = apply { body.objectId(objectId) } - /** The id of the object the ACL applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** @@ -475,25 +600,30 @@ private constructor( */ fun groupId(groupId: String?) = apply { body.groupId(groupId) } - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.groupId] with `groupId.orElse(null)`. */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.groupId] to an arbitrary JSON value. + * + * You should usually call [Builder.groupId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun groupId(groupId: JsonField) = apply { body.groupId(groupId) } /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ fun permission(permission: Permission?) = apply { body.permission(permission) } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** Alias for calling [Builder.permission] with `permission.orElse(null)`. */ fun permission(permission: Optional) = permission(permission.getOrNull()) - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Sets [Builder.permission] to an arbitrary JSON value. + * + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun permission(permission: JsonField) = apply { body.permission(permission) } /** @@ -505,15 +635,17 @@ 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`. + * Alias for calling [Builder.restrictObjectType] with `restrictObjectType.orElse(null)`. */ 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`. + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed [AclObjectType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ fun restrictObjectType(restrictObjectType: JsonField) = apply { body.restrictObjectType(restrictObjectType) @@ -524,13 +656,14 @@ private constructor( */ fun roleId(roleId: String?) = apply { body.roleId(roleId) } - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ + /** Alias for calling [Builder.roleId] with `roleId.orElse(null)`. */ fun roleId(roleId: Optional) = roleId(roleId.getOrNull()) /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun roleId(roleId: JsonField) = apply { body.roleId(roleId) } @@ -540,15 +673,14 @@ private constructor( */ fun userId(userId: String?) = apply { body.userId(userId) } - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun userId(userId: JsonField) = apply { body.userId(userId) } 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 6f389829..c61cbd7d 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 @@ -146,13 +146,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -161,31 +155,26 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** @@ -197,13 +186,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 4de28c65..9092df23 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,44 +33,78 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = body.metadata() /** * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * AI Secret belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not * replaced with null. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun secret(): Optional = body.secret() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun type(): Optional = body.type() - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ fun _metadata(): JsonField = body._metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Returns the raw JSON value of [secret]. + * + * Unlike [secret], this method doesn't throw if the JSON field has an unexpected type. */ fun _secret(): JsonField = body._secret() + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ fun _type(): JsonField = body._type() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -107,44 +142,78 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, * not replaced with null. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Returns the raw JSON value of [secret]. + * + * Unlike [secret], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -204,13 +273,27 @@ private constructor( /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** @@ -220,17 +303,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -240,22 +321,30 @@ private constructor( */ fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) - /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. - */ + /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Sets [Builder.secret] to an arbitrary JSON value. + * + * You should usually call [Builder.secret] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun secret(secret: JsonField) = apply { this.secret = secret } fun type(type: String?) = type(JsonField.ofNullable(type)) + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -339,13 +428,26 @@ private constructor( /** Name of the AI secret */ fun name(name: String) = apply { body.name(name) } - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** @@ -355,17 +457,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } @@ -375,22 +474,28 @@ private constructor( */ fun secret(secret: String?) = apply { body.secret(secret) } - /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. - */ + /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Sets [Builder.secret] to an arbitrary JSON value. + * + * You should usually call [Builder.secret] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun secret(secret: JsonField) = apply { body.secret(secret) } fun type(type: String?) = apply { body.type(type) } + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { body.type(type) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 09e2cfab..4dfef4d2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -13,6 +13,7 @@ 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 @@ -29,23 +30,35 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() /** * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * AI Secret belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() @@ -75,23 +88,35 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @@ -143,7 +168,13 @@ private constructor( /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** @@ -153,17 +184,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -241,7 +270,12 @@ private constructor( /** Name of the AI secret */ fun name(name: String) = apply { body.name(name) } - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** @@ -251,17 +285,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index d41f9f78..da87f527 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -133,16 +133,19 @@ private constructor( /** Name of the ai_secret to search for */ fun aiSecretName(aiSecretName: String?) = apply { this.aiSecretName = aiSecretName } - /** Name of the ai_secret to search for */ + /** Alias for calling [Builder.aiSecretName] with `aiSecretName.orElse(null)`. */ fun aiSecretName(aiSecretName: Optional) = aiSecretName(aiSecretName.getOrNull()) fun aiSecretType(aiSecretType: AiSecretType?) = apply { this.aiSecretType = aiSecretType } + /** Alias for calling [Builder.aiSecretType] with `aiSecretType.orElse(null)`. */ fun aiSecretType(aiSecretType: Optional) = aiSecretType(aiSecretType.getOrNull()) + /** Alias for calling [aiSecretType] with `AiSecretType.ofString(string)`. */ fun aiSecretType(string: String) = aiSecretType(AiSecretType.ofString(string)) + /** Alias for calling [aiSecretType] with `AiSecretType.ofStrings(strings)`. */ fun aiSecretTypeOfStrings(strings: List) = aiSecretType(AiSecretType.ofStrings(strings)) @@ -155,13 +158,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -170,37 +167,32 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** @@ -212,13 +204,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 30fafd07..875a99c6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,44 +33,78 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = body.metadata() /** * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * AI Secret belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not * replaced with null. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun secret(): Optional = body.secret() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun type(): Optional = body.type() - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ fun _metadata(): JsonField = body._metadata() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * AI Secret belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, not - * replaced with null. + * Returns the raw JSON value of [secret]. + * + * Unlike [secret], this method doesn't throw if the JSON field has an unexpected type. */ fun _secret(): JsonField = body._secret() + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ fun _type(): JsonField = body._type() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -107,44 +142,78 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the AI Secret belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) /** * Secret value. If omitted in a PUT request, the existing secret value will be left intact, * not replaced with null. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Returns the raw JSON value of [secret]. + * + * Unlike [secret], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -204,13 +273,27 @@ private constructor( /** Name of the AI secret */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** @@ -220,17 +303,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -240,22 +321,30 @@ private constructor( */ fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) - /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. - */ + /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left - * intact, not replaced with null. + * Sets [Builder.secret] to an arbitrary JSON value. + * + * You should usually call [Builder.secret] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun secret(secret: JsonField) = apply { this.secret = secret } fun type(type: String?) = type(JsonField.ofNullable(type)) + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -339,13 +428,26 @@ private constructor( /** Name of the AI secret */ fun name(name: String) = apply { body.name(name) } - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** @@ -355,17 +457,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the AI Secret belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } @@ -375,22 +474,28 @@ private constructor( */ fun secret(secret: String?) = apply { body.secret(secret) } - /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. - */ + /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */ fun secret(secret: Optional) = secret(secret.getOrNull()) /** - * Secret value. If omitted in a PUT request, the existing secret value will be left intact, - * not replaced with null. + * Sets [Builder.secret] to an arbitrary JSON value. + * + * You should usually call [Builder.secret] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun secret(secret: JsonField) = apply { body.secret(secret) } fun type(type: String?) = apply { body.type(type) } + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { body.type(type) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index a1146def..42e63b47 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -13,6 +13,7 @@ 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,22 +38,58 @@ private constructor( /** AiSecret id */ fun aiSecretId(): String = aiSecretId + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = body.metadata() - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun secret(): Optional = body.secret() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun type(): Optional = body.type() + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ fun _metadata(): JsonField = body._metadata() - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() + /** + * Returns the raw JSON value of [secret]. + * + * Unlike [secret], this method doesn't throw if the JSON field has an unexpected type. + */ fun _secret(): JsonField = body._secret() + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ fun _type(): JsonField = body._type() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -94,22 +131,58 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Name of the AI secret */ + /** + * Name of the AI secret + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun secret(): Optional = Optional.ofNullable(secret.getNullable("secret")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Name of the AI secret */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [secret]. + * + * Unlike [secret], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -158,29 +231,59 @@ private constructor( fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the AI secret */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the AI secret */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } fun secret(secret: String?) = secret(JsonField.ofNullable(secret)) + /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */ fun secret(secret: Optional) = secret(secret.getOrNull()) + /** + * Sets [Builder.secret] to an arbitrary JSON value. + * + * You should usually call [Builder.secret] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun secret(secret: JsonField) = apply { this.secret = secret } fun type(type: String?) = type(JsonField.ofNullable(type)) + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -261,29 +364,56 @@ private constructor( fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the AI secret */ fun name(name: String?) = apply { body.name(name) } - /** Name of the AI secret */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the AI secret */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } fun secret(secret: String?) = apply { body.secret(secret) } + /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */ fun secret(secret: Optional) = secret(secret.getOrNull()) + /** + * Sets [Builder.secret] to an arbitrary JSON value. + * + * You should usually call [Builder.secret] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun secret(secret: JsonField) = apply { body.secret(secret) } fun type(type: String?) = apply { body.type(type) } + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { body.type(type) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 0b88b229..0a18e742 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -10,6 +10,7 @@ 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 @@ -38,40 +39,94 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the api key */ + /** + * Unique identifier for the api key + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the api key */ + /** + * Name of the api key + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun previewName(): String = previewName.getRequired("preview_name") - /** Date of api key creation */ + /** + * Date of api key creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Unique identifier for the organization */ + /** + * Unique identifier for the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) - /** Unique identifier for the user */ + /** + * Unique identifier for the user + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the api key */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the api key */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [previewName]. + * + * Unlike [previewName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("preview_name") @ExcludeMissing fun _previewName(): JsonField = previewName - /** Date of api key creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Unique identifier for the organization */ + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Unique identifier for the user */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @@ -136,44 +191,77 @@ private constructor( /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the api key */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the api key */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) + /** + * Sets [Builder.previewName] to an arbitrary JSON value. + * + * You should usually call [Builder.previewName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun previewName(previewName: JsonField) = apply { this.previewName = previewName } /** Date of api key creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of api key creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of api key creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the organization */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) - /** Unique identifier for the organization */ + /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) - /** Unique identifier for the organization */ + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the user */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Unique identifier for the user */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Unique identifier for the user */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index a66bf130..2b0fe95a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,23 +33,35 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the api key. Does not have to be unique */ + /** + * Name of the api key. Does not have to be unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() /** * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * API key belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() - /** Name of the api key. Does not have to be unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * API key belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() @@ -78,23 +91,35 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the api key. Does not have to be unique */ + /** + * Name of the api key. Does not have to be unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the API key belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) - /** Name of the api key. Does not have to be unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @@ -146,7 +171,13 @@ private constructor( /** Name of the api key. Does not have to be unique */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the api key. Does not have to be unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** @@ -156,17 +187,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -244,7 +273,12 @@ private constructor( /** Name of the api key. Does not have to be unique */ fun name(name: String) = apply { body.name(name) } - /** Name of the api key. Does not have to be unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** @@ -254,17 +288,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 124f92d2..46f9e571 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -127,7 +127,7 @@ private constructor( /** Name of the api_key to search for */ fun apiKeyName(apiKeyName: String?) = apply { this.apiKeyName = apiKeyName } - /** Name of the api_key to search for */ + /** Alias for calling [Builder.apiKeyName] with `apiKeyName.orElse(null)`. */ fun apiKeyName(apiKeyName: Optional) = apiKeyName(apiKeyName.getOrNull()) /** @@ -139,13 +139,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -154,37 +148,32 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** @@ -196,13 +185,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index fcb0d184..0a47e4ef 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -30,12 +30,30 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun imageUrl(): ImageUrl = imageUrl.getRequired("image_url") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [imageUrl]. + * + * Unlike [imageUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("image_url") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -88,10 +106,23 @@ private constructor( fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) + /** + * Sets [Builder.imageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.imageUrl] with a well-typed [ImageUrl] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -133,12 +164,30 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun url(): String = url.getRequired("url") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun detail(): Optional = Optional.ofNullable(detail.getNullable("detail")) + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + /** + * Returns the raw JSON value of [detail]. + * + * Unlike [detail], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("detail") @ExcludeMissing fun _detail(): JsonField = detail @JsonAnyGetter @@ -188,10 +237,24 @@ private constructor( fun url(url: String) = url(JsonField.of(url)) + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun url(url: JsonField) = apply { this.url = url } fun detail(detail: Detail) = detail(JsonField.of(detail)) + /** + * Sets [Builder.detail] to an arbitrary JSON value. + * + * You should usually call [Builder.detail] with a well-typed [Detail] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun detail(detail: JsonField) = apply { this.detail = detail } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index c4b1ce91..6d1a633b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -28,12 +28,30 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun text(): Optional = Optional.ofNullable(text.getNullable("text")) + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text @JsonAnyGetter @@ -84,10 +102,22 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun text(text: String) = text(JsonField.of(text)) + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun text(text: JsonField) = apply { this.text = text } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 3ae3ad83..2add01f0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -30,16 +30,43 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun function(): Function = function.getRequired("function") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [function]. + * + * Unlike [function], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("function") @ExcludeMissing fun _function(): JsonField = function + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -95,14 +122,33 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } fun function(function: Function) = function(JsonField.of(function)) + /** + * Sets [Builder.function] to an arbitrary JSON value. + * + * You should usually call [Builder.function] with a well-typed [Function] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun function(function: JsonField) = apply { this.function = function } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -147,12 +193,30 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun arguments(): String = arguments.getRequired("arguments") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * Returns the raw JSON value of [arguments]. + * + * Unlike [arguments], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonField = arguments + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -203,10 +267,24 @@ private constructor( fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + /** + * Sets [Builder.arguments] to an arbitrary JSON value. + * + * You should usually call [Builder.arguments] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun arguments(arguments: JsonField) = apply { this.arguments = arguments } fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index e5712817..f113a8c9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -49,24 +49,60 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun bundleId(): String = bundleId.getRequired("bundle_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun location(): Location = location.getRequired("location") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") - /** A preview of the code */ + /** + * A preview of the code + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + /** + * Returns the raw JSON value of [bundleId]. + * + * Unlike [bundleId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - /** A preview of the code */ + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview @JsonAnyGetter @@ -124,19 +160,41 @@ private constructor( fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + /** + * Sets [Builder.bundleId] to an arbitrary JSON value. + * + * You should usually call [Builder.bundleId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } fun location(location: Location) = location(JsonField.of(location)) + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed [Location] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun location(location: JsonField) = apply { this.location = location } + /** Alias for calling [location] with `Location.ofExperiment(experiment)`. */ fun location(experiment: Location.Experiment) = location(Location.ofExperiment(experiment)) + /** Alias for calling [location] with `Location.ofFunction(function)`. */ fun location(function: Location.Function) = location(Location.ofFunction(function)) fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed [RuntimeContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } @@ -144,10 +202,15 @@ private constructor( /** A preview of the code */ fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) - /** A preview of the code */ + /** Alias for calling [Builder.preview] with `preview.orElse(null)`. */ fun preview(preview: Optional) = preview(preview.getOrNull()) - /** A preview of the code */ + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun preview(preview: JsonField) = apply { this.preview = preview } fun additionalProperties(additionalProperties: Map) = apply { @@ -331,18 +394,50 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun evalName(): String = evalName.getRequired("eval_name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun position(): Position = position.getRequired("position") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [evalName]. + * + * Unlike [evalName], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("eval_name") @ExcludeMissing fun _evalName(): JsonField = evalName + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -397,18 +492,41 @@ private constructor( fun evalName(evalName: String) = evalName(JsonField.of(evalName)) + /** + * Sets [Builder.evalName] to an arbitrary JSON value. + * + * You should usually call [Builder.evalName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun evalName(evalName: JsonField) = apply { this.evalName = evalName } fun position(position: Position) = position(JsonField.of(position)) + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Position] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun position(position: JsonField) = apply { this.position = position } + /** Alias for calling [position] with `Position.ofType(type)`. */ fun position(type: Position.Type) = position(Position.ofType(type)) + /** Alias for calling [position] with `Position.ofScorer(scorer)`. */ fun position(scorer: Position.Scorer) = position(Position.ofScorer(scorer)) fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -589,8 +707,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): InnerType = type.getRequired("type") + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -638,6 +767,13 @@ private constructor( fun type(type: InnerType) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [InnerType] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -803,12 +939,34 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun index(): Long = index.getRequired("index") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -860,10 +1018,24 @@ private constructor( fun index(index: Long) = index(JsonField.of(index)) + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun index(index: JsonField) = apply { this.index = index } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1145,12 +1317,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun index(): Long = index.getRequired("index") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [index]. + * + * Unlike [index], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1201,10 +1393,24 @@ private constructor( fun index(index: Long) = index(JsonField.of(index)) + /** + * Sets [Builder.index] to an arbitrary JSON value. + * + * You should usually call [Builder.index] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun index(index: JsonField) = apply { this.index = index } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1367,12 +1573,30 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun runtime(): Runtime = runtime.getRequired("runtime") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun version(): String = version.getRequired("version") + /** + * Returns the raw JSON value of [runtime]. + * + * Unlike [runtime], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -1423,10 +1647,24 @@ private constructor( fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + /** + * Sets [Builder.runtime] to an arbitrary JSON value. + * + * You should usually call [Builder.runtime] with a well-typed [Runtime] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index ba204bc6..b3162489 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -10,6 +10,7 @@ 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 @@ -39,46 +40,109 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the api key */ + /** + * Unique identifier for the api key + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** The raw API key. It will only be exposed this one time */ + /** + * The raw API key. It will only be exposed this one time + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun key(): String = key.getRequired("key") - /** Name of the api key */ + /** + * Name of the api key + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun previewName(): String = previewName.getRequired("preview_name") - /** Date of api key creation */ + /** + * Date of api key creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Unique identifier for the organization */ + /** + * Unique identifier for the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) - /** Unique identifier for the user */ + /** + * Unique identifier for the user + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the api key */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The raw API key. It will only be exposed this one time */ + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - /** Name of the api key */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [previewName]. + * + * Unlike [previewName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("preview_name") @ExcludeMissing fun _previewName(): JsonField = previewName - /** Date of api key creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Unique identifier for the organization */ + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Unique identifier for the user */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @@ -147,50 +211,88 @@ private constructor( /** Unique identifier for the api key */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the api key */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** The raw API key. It will only be exposed this one time */ fun key(key: String) = key(JsonField.of(key)) - /** The raw API key. It will only be exposed this one time */ + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun key(key: JsonField) = apply { this.key = key } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the api key */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) + /** + * Sets [Builder.previewName] to an arbitrary JSON value. + * + * You should usually call [Builder.previewName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun previewName(previewName: JsonField) = apply { this.previewName = previewName } /** Date of api key creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of api key creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of api key creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the organization */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) - /** Unique identifier for the organization */ + /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) - /** Unique identifier for the organization */ + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the user */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Unique identifier for the user */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Unique identifier for the user */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index b6a00359..b041b845 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -9,6 +9,7 @@ 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 @@ -33,26 +34,53 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A mapping from dataset id to row ids for inserted `events` */ + /** + * A mapping from dataset id to row ids for inserted `events` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun dataset(): Optional = Optional.ofNullable(dataset.getNullable("dataset")) - /** A mapping from experiment id to row ids for inserted `events` */ + /** + * A mapping from experiment id to row ids for inserted `events` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun experiment(): Optional = Optional.ofNullable(experiment.getNullable("experiment")) - /** A mapping from project id to row ids for inserted `events` */ + /** + * A mapping from project id to row ids for inserted `events` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun projectLogs(): Optional = Optional.ofNullable(projectLogs.getNullable("project_logs")) - /** A mapping from dataset id to row ids for inserted `events` */ + /** + * Returns the raw JSON value of [dataset]. + * + * Unlike [dataset], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("dataset") @ExcludeMissing fun _dataset(): JsonField = dataset - /** A mapping from experiment id to row ids for inserted `events` */ + /** + * Returns the raw JSON value of [experiment]. + * + * Unlike [experiment], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("experiment") @ExcludeMissing fun _experiment(): JsonField = experiment - /** A mapping from project id to row ids for inserted `events` */ + /** + * Returns the raw JSON value of [projectLogs]. + * + * Unlike [projectLogs], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_logs") @ExcludeMissing fun _projectLogs(): JsonField = projectLogs @@ -103,28 +131,45 @@ private constructor( /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(dataset: Dataset?) = dataset(JsonField.ofNullable(dataset)) - /** A mapping from dataset id to row ids for inserted `events` */ + /** Alias for calling [Builder.dataset] with `dataset.orElse(null)`. */ fun dataset(dataset: Optional) = dataset(dataset.getOrNull()) - /** A mapping from dataset id to row ids for inserted `events` */ + /** + * Sets [Builder.dataset] to an arbitrary JSON value. + * + * You should usually call [Builder.dataset] with a well-typed [Dataset] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun dataset(dataset: JsonField) = apply { this.dataset = dataset } /** A mapping from experiment id to row ids for inserted `events` */ fun experiment(experiment: Experiment?) = experiment(JsonField.ofNullable(experiment)) - /** A mapping from experiment id to row ids for inserted `events` */ + /** Alias for calling [Builder.experiment] with `experiment.orElse(null)`. */ fun experiment(experiment: Optional) = experiment(experiment.getOrNull()) - /** A mapping from experiment id to row ids for inserted `events` */ + /** + * Sets [Builder.experiment] to an arbitrary JSON value. + * + * You should usually call [Builder.experiment] with a well-typed [Experiment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun experiment(experiment: JsonField) = apply { this.experiment = experiment } /** A mapping from project id to row ids for inserted `events` */ fun projectLogs(projectLogs: ProjectLogs?) = projectLogs(JsonField.ofNullable(projectLogs)) - /** A mapping from project id to row ids for inserted `events` */ + /** Alias for calling [Builder.projectLogs] with `projectLogs.orElse(null)`. */ fun projectLogs(projectLogs: Optional) = projectLogs(projectLogs.getOrNull()) - /** A mapping from project id to row ids for inserted `events` */ + /** + * Sets [Builder.projectLogs] to an arbitrary JSON value. + * + * You should usually call [Builder.projectLogs] with a well-typed [ProjectLogs] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectLogs(projectLogs: JsonField) = apply { this.projectLogs = projectLogs } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index 25297bb3..2b0bb6d7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -10,6 +10,7 @@ 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 @@ -27,10 +28,19 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Total number of records in the dataset */ + /** + * Total number of records in the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun totalRecords(): Long = totalRecords.getRequired("total_records") - /** Total number of records in the dataset */ + /** + * Returns the raw JSON value of [totalRecords]. + * + * Unlike [totalRecords], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("total_records") @ExcludeMissing fun _totalRecords(): JsonField = totalRecords @@ -80,7 +90,13 @@ private constructor( /** Total number of records in the dataset */ fun totalRecords(totalRecords: Long) = totalRecords(JsonField.of(totalRecords)) - /** Total number of records in the dataset */ + /** + * Sets [Builder.totalRecords] to an arbitrary JSON value. + * + * You should usually call [Builder.totalRecords] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun totalRecords(totalRecords: JsonField) = apply { this.totalRecords = totalRecords } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index 6a1818a9..f1d396e8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -10,6 +10,7 @@ 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 @@ -46,56 +47,128 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the dataset */ + /** + * Unique identifier for the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Name of the dataset. Within a project, dataset names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the dataset belongs under */ + /** + * Unique identifier for the project that the dataset belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Date of dataset creation */ + /** + * Date of dataset creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Date of dataset deletion, or null if the dataset is still active */ + /** + * Date of dataset deletion, or null if the dataset is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Textual description of the dataset */ + /** + * Textual description of the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** User-controlled metadata about the dataset */ + /** + * User-controlled metadata about the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Identifies the user who created the dataset */ + /** + * Identifies the user who created the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the dataset */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the dataset belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Date of dataset creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Date of dataset deletion, or null if the dataset is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - /** Textual description of the dataset */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** User-controlled metadata about the dataset */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Identifies the user who created the dataset */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @@ -166,64 +239,109 @@ private constructor( /** Unique identifier for the dataset */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the dataset */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the dataset belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Date of dataset creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of dataset creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of dataset creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Date of dataset deletion, or null if the dataset is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of dataset deletion, or null if the dataset is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of dataset deletion, or null if the dataset is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the dataset */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the dataset */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** User-controlled metadata about the dataset */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the dataset */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Identifies the user who created the dataset */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the dataset */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the dataset */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index be5669c3..50a2261f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,28 +33,64 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Name of the dataset. Within a project, dataset names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the dataset belongs under */ + /** + * Unique identifier for the project that the dataset belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** Textual description of the dataset */ + /** + * Textual description of the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** User-controlled metadata about the dataset */ + /** + * User-controlled metadata about the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = body.metadata() - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the dataset belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** Textual description of the dataset */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** User-controlled metadata about the dataset */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ fun _metadata(): JsonField = body._metadata() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -88,31 +125,67 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Name of the dataset. Within a project, dataset names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the dataset belongs under */ + /** + * Unique identifier for the project that the dataset belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Textual description of the dataset */ + /** + * Textual description of the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** User-controlled metadata about the dataset */ + /** + * User-controlled metadata about the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the dataset belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Textual description of the dataset */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** User-controlled metadata about the dataset */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @@ -170,22 +243,40 @@ private constructor( /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the dataset belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the dataset */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the dataset */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -193,10 +284,16 @@ private constructor( /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** User-controlled metadata about the dataset */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the dataset */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun additionalProperties(additionalProperties: Map) = apply { @@ -280,31 +377,54 @@ private constructor( /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = apply { body.name(name) } - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the dataset belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Textual description of the dataset */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the dataset */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the dataset */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - /** User-controlled metadata about the dataset */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the dataset */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index b60821c8..116cce7b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -11,6 +11,7 @@ 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 @@ -63,6 +64,9 @@ private constructor( /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate * one for you + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") @@ -70,25 +74,51 @@ private constructor( * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the dataset (see the `version` parameter) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** The timestamp the dataset event was created */ + /** + * The timestamp the dataset event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun created(): OffsetDateTime = created.getRequired("created") - /** Unique identifier for the dataset */ + /** + * Unique identifier for the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun datasetId(): String = datasetId.getRequired("dataset_id") - /** Unique identifier for the project that the dataset belongs under */ + /** + * Unique identifier for the project that the dataset belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** A unique identifier for the trace this dataset event belongs to */ + /** + * A unique identifier for the trace this dataset event belongs to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** * A unique identifier used to link different dataset events together as part of a full trace. * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on * tracing + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun spanId(): String = spanId.getRequired("span_id") @@ -101,7 +131,12 @@ private constructor( /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input - /** Whether this span is a root span */ + /** + * Whether this span is a root span + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** @@ -110,63 +145,103 @@ private constructor( * example, you could log the `prompt`, example's `id`, or anything else that would be useful to * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Indicates the event was copied from another object. */ + /** + * Indicates the event was copied from another object. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the dataset (see the `version` parameter) + * Returns the raw JSON value of [_xactId]. + * + * Unlike [_xactId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - /** The timestamp the dataset event was created */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Unique identifier for the dataset */ + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId - /** Unique identifier for the project that the dataset belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** A unique identifier for the trace this dataset event belongs to */ + /** + * Returns the raw JSON value of [rootSpanId]. + * + * Unlike [rootSpanId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing + * Returns the raw JSON value of [spanId]. + * + * Unlike [spanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId - /** Whether this span is a root span */ + /** + * Returns the raw JSON value of [isRoot]. + * + * Unlike [isRoot], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Indicates the event was copied from another object. */ + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -258,8 +333,10 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } @@ -271,34 +348,59 @@ private constructor( fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the dataset (see the `version` parameter) + * Sets [Builder._xactId] to an arbitrary JSON value. + * + * You should usually call [Builder._xactId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) - /** The timestamp the dataset event was created */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the dataset */ fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - /** Unique identifier for the dataset */ + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the dataset belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A unique identifier for the trace this dataset event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** A unique identifier for the trace this dataset event belongs to */ + /** + * Sets [Builder.rootSpanId] to an arbitrary JSON value. + * + * You should usually call [Builder.rootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** @@ -309,9 +411,10 @@ private constructor( fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * Sets [Builder.spanId] to an arbitrary JSON value. + * + * You should usually call [Builder.spanId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun spanId(spanId: JsonField) = apply { this.spanId = spanId } @@ -329,13 +432,22 @@ private constructor( /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) - /** Whether this span is a root span */ + /** + * Alias for [Builder.isRoot]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) - /** Whether this span is a root span */ + /** Alias for calling [Builder.isRoot] with `isRoot.orElse(null)`. */ fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) - /** Whether this span is a root span */ + /** + * Sets [Builder.isRoot] to an arbitrary JSON value. + * + * You should usually call [Builder.isRoot] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } /** @@ -347,45 +459,55 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Indicates the event was copied from another object. */ fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) - /** Indicates the event was copied from another object. */ + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) - /** Indicates the event was copied from another object. */ + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [ObjectReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } @@ -446,10 +568,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The model used for this example */ + /** + * The model used for this example + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - /** The model used for this example */ + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model @JsonAnyGetter @@ -490,10 +621,16 @@ private constructor( /** The model used for this example */ fun model(model: String?) = model(JsonField.ofNullable(model)) - /** The model used for this example */ + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ fun model(model: Optional) = model(model.getOrNull()) - /** The model used for this example */ + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun model(model: JsonField) = apply { this.model = model } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index 1b7d0197..efa54e3d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -14,6 +14,7 @@ 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 @@ -32,10 +33,19 @@ private constructor( /** Dataset id */ fun datasetId(): String = datasetId - /** A list of dataset feedback items */ + /** + * A list of dataset feedback items + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun feedback(): List = body.feedback() - /** A list of dataset feedback items */ + /** + * Returns the raw JSON value of [feedback]. + * + * Unlike [feedback], this method doesn't throw if the JSON field has an unexpected type. + */ fun _feedback(): JsonField> = body._feedback() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -68,10 +78,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of dataset feedback items */ + /** + * A list of dataset feedback items + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun feedback(): List = feedback.getRequired("feedback") - /** A list of dataset feedback items */ + /** + * Returns the raw JSON value of [feedback]. + * + * Unlike [feedback], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("feedback") @ExcludeMissing fun _feedback(): JsonField> = feedback @@ -121,12 +140,22 @@ private constructor( /** A list of dataset feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) - /** A list of dataset feedback items */ + /** + * Sets [Builder.feedback] to an arbitrary JSON value. + * + * You should usually call [Builder.feedback] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun feedback(feedback: JsonField>) = apply { this.feedback = feedback.map { it.toMutableList() } } - /** A list of dataset feedback items */ + /** + * Adds a single [FeedbackDatasetItem] to [Builder.feedback]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addFeedback(feedback: FeedbackDatasetItem) = apply { this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { @@ -217,12 +246,22 @@ private constructor( /** A list of dataset feedback items */ fun feedback(feedback: List) = apply { body.feedback(feedback) } - /** A list of dataset feedback items */ + /** + * Sets [Builder.feedback] to an arbitrary JSON value. + * + * You should usually call [Builder.feedback] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun feedback(feedback: JsonField>) = apply { body.feedback(feedback) } - /** A list of dataset feedback items */ + /** + * Adds a single [FeedbackDatasetItem] to [Builder.feedback]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addFeedback(feedback: FeedbackDatasetItem) = apply { body.addFeedback(feedback) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index e045595c..36fa92fa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -164,37 +164,13 @@ private constructor( fun limit(limit: Long?) = apply { this.limit = limit } /** - * limit the number of traces fetched + * Alias for [Builder.limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** @@ -211,18 +187,7 @@ private constructor( */ fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) @@ -240,18 +205,7 @@ private constructor( */ fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** @@ -262,12 +216,7 @@ private constructor( */ fun version(version: String?) = apply { this.version = version } - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 02ffad07..dda145f4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -13,6 +13,7 @@ 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 @@ -42,6 +43,9 @@ private constructor( * earliest. * * The string can be obtained directly from the `cursor` property of the previous fetch query + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun cursor(): Optional = body.cursor() @@ -58,6 +62,9 @@ private constructor( * * The `limit` parameter controls the number of full traces to return. So you may end up with * more individual rows than the specified limit if you are fetching events containing traces. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun limit(): Optional = body.limit() @@ -72,6 +79,9 @@ private constructor( * for the next page can be found as the row with the minimum (earliest) value of the tuple * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating * fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun maxRootSpanId(): Optional = body.maxRootSpanId() @@ -86,6 +96,9 @@ private constructor( * for the next page can be found as the row with the minimum (earliest) value of the tuple * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating * fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun maxXactId(): Optional = body.maxXactId() @@ -94,66 +107,44 @@ private constructor( * * The version id is essentially a filter on the latest event transaction id. You can use the * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * Returns the raw JSON value of [cursor]. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ fun _cursor(): JsonField = body._cursor() /** - * limit the number of traces fetched + * Returns the raw JSON value of [limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * Returns the raw JSON value of [maxRootSpanId]. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Unlike [maxRootSpanId], this method doesn't throw if the JSON field has an unexpected type. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * Returns the raw JSON value of [maxXactId]. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Unlike [maxXactId], this method doesn't throw if the JSON field has an unexpected type. */ fun _maxXactId(): JsonField = body._maxXactId() /** - * Retrieve a snapshot of events from a past time + * Returns the raw JSON value of [version]. * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. */ fun _version(): JsonField = body._version() @@ -205,6 +196,9 @@ private constructor( * * The string can be obtained directly from the `cursor` property of the previous fetch * query + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) @@ -222,6 +216,9 @@ private constructor( * The `limit` parameter controls the number of full traces to return. So you may end up * with more individual rows than the specified limit if you are fetching events containing * traces. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) @@ -236,6 +233,9 @@ private constructor( * cursor for the next page can be found as the row with the minimum (earliest) value of the * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) @@ -251,6 +251,9 @@ private constructor( * cursor for the next page can be found as the row with the minimum (earliest) value of the * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) @@ -260,70 +263,47 @@ private constructor( * * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Returns the raw JSON value of [cursor]. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Returns the raw JSON value of [limit]. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Returns the raw JSON value of [maxRootSpanId]. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Unlike [maxRootSpanId], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Returns the raw JSON value of [maxXactId]. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Unlike [maxXactId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId /** - * Retrieve a snapshot of events from a past time + * Returns the raw JSON value of [version]. * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @@ -383,21 +363,15 @@ private constructor( */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Sets [Builder.cursor] to an arbitrary JSON value. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * You should usually call [Builder.cursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun cursor(cursor: JsonField) = apply { this.cursor = cursor } @@ -419,53 +393,21 @@ private constructor( fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Alias for [Builder.limit]. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * limit the number of traces fetched + * Sets [Builder.limit] to an arbitrary JSON value. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun limit(limit: JsonField) = apply { this.limit = limit } @@ -484,32 +426,16 @@ private constructor( fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * Sets [Builder.maxRootSpanId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * You should usually call [Builder.maxRootSpanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun maxRootSpanId(maxRootSpanId: JsonField) = apply { this.maxRootSpanId = maxRootSpanId @@ -529,31 +455,15 @@ private constructor( */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Sets [Builder.maxXactId] to an arbitrary JSON value. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * You should usually call [Builder.maxXactId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } @@ -566,21 +476,15 @@ private constructor( */ fun version(version: String?) = version(JsonField.ofNullable(version)) - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) /** - * Retrieve a snapshot of events from a past time + * Sets [Builder.version] to an arbitrary JSON value. * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun version(version: JsonField) = apply { this.version = version } @@ -676,21 +580,14 @@ private constructor( */ fun cursor(cursor: String?) = apply { body.cursor(cursor) } - /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Sets [Builder.cursor] to an arbitrary JSON value. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } @@ -712,53 +609,20 @@ private constructor( fun limit(limit: Long?) = apply { body.limit(limit) } /** - * limit the number of traces fetched + * Alias for [Builder.limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * limit the number of traces fetched + * Sets [Builder.limit] to an arbitrary JSON value. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun limit(limit: JsonField) = apply { body.limit(limit) } @@ -776,32 +640,16 @@ private constructor( */ fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * Sets [Builder.maxRootSpanId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * You should usually call [Builder.maxRootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun maxRootSpanId(maxRootSpanId: JsonField) = apply { body.maxRootSpanId(maxRootSpanId) @@ -821,31 +669,15 @@ private constructor( */ fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * Sets [Builder.maxXactId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * You should usually call [Builder.maxXactId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } @@ -857,19 +689,14 @@ private constructor( */ fun version(version: String?) = apply { body.version(version) } - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) /** - * Retrieve a snapshot of events from a past time + * Sets [Builder.version] to an arbitrary JSON value. * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun version(version: JsonField) = apply { body.version(version) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 043cce99..55c6c8ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -14,6 +14,7 @@ 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 @@ -32,10 +33,19 @@ private constructor( /** Dataset id */ fun datasetId(): String = datasetId - /** A list of dataset events to insert */ + /** + * A list of dataset events to insert + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = body.events() - /** A list of dataset events to insert */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ fun _events(): JsonField> = body._events() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -68,10 +78,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of dataset events to insert */ + /** + * A list of dataset events to insert + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = events.getRequired("events") - /** A list of dataset events to insert */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events @@ -121,12 +140,22 @@ private constructor( /** A list of dataset events to insert */ fun events(events: List) = events(JsonField.of(events)) - /** A list of dataset events to insert */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } - /** A list of dataset events to insert */ + /** + * Adds a single [InsertDatasetEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: InsertDatasetEvent) = apply { events = (events ?: JsonField.of(mutableListOf())).also { @@ -216,10 +245,20 @@ private constructor( /** A list of dataset events to insert */ fun events(events: List) = apply { body.events(events) } - /** A list of dataset events to insert */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun events(events: JsonField>) = apply { body.events(events) } - /** A list of dataset events to insert */ + /** + * Adds a single [InsertDatasetEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: InsertDatasetEvent) = apply { body.addEvent(event) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index 5ae454e3..b7818b13 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -141,7 +141,7 @@ private constructor( /** Name of the dataset to search for */ fun datasetName(datasetName: String?) = apply { this.datasetName = datasetName } - /** Name of the dataset to search for */ + /** Alias for calling [Builder.datasetName] with `datasetName.orElse(null)`. */ fun datasetName(datasetName: Optional) = datasetName(datasetName.getOrNull()) /** @@ -153,13 +153,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -168,49 +162,44 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } - /** Project id */ + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } - /** Name of the project to search for */ + /** Alias for calling [Builder.projectName] with `projectName.orElse(null)`. */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** @@ -222,13 +211,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index bea55242..8a27ca2d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -87,13 +87,13 @@ private constructor( fun summarizeData(summarizeData: Boolean?) = apply { this.summarizeData = summarizeData } /** - * Whether to summarize the data. If false (or omitted), only the metadata will be returned. + * Alias for [Builder.summarizeData]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun summarizeData(summarizeData: Boolean) = summarizeData(summarizeData as Boolean?) - /** - * Whether to summarize the data. If false (or omitted), only the metadata will be returned. - */ + /** Alias for calling [Builder.summarizeData] with `summarizeData.orElse(null)`. */ fun summarizeData(summarizeData: Optional) = summarizeData(summarizeData.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index a125d34b..eb2b4cf2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -13,6 +13,7 @@ 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,22 +38,49 @@ private constructor( /** Dataset id */ fun datasetId(): String = datasetId - /** Textual description of the dataset */ + /** + * Textual description of the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** User-controlled metadata about the dataset */ + /** + * User-controlled metadata about the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = body.metadata() - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Name of the dataset. Within a project, dataset names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() - /** Textual description of the dataset */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** User-controlled metadata about the dataset */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ fun _metadata(): JsonField = body._metadata() - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -91,25 +119,52 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Textual description of the dataset */ + /** + * Textual description of the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** User-controlled metadata about the dataset */ + /** + * User-controlled metadata about the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Name of the dataset. Within a project, dataset names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** Textual description of the dataset */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** User-controlled metadata about the dataset */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -156,10 +211,16 @@ private constructor( /** Textual description of the dataset */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the dataset */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the dataset */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -167,19 +228,31 @@ private constructor( /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** User-controlled metadata about the dataset */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the dataset */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the dataset. Within a project, dataset names are unique */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -261,28 +334,45 @@ private constructor( /** Textual description of the dataset */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the dataset */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the dataset */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - /** User-controlled metadata about the dataset */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the dataset */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String?) = apply { body.name(name) } - /** Name of the dataset. Within a project, dataset names are unique */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the dataset. Within a project, dataset names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 10a99c22..668c0861 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -42,42 +42,96 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the environment variable */ + /** + * Unique identifier for the environment variable + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** The name of the environment variable */ + /** + * The name of the environment variable + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** The id of the object the environment variable is scoped for */ + /** + * The id of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The type of the object the environment variable is scoped for */ + /** + * The type of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): ObjectType = objectType.getRequired("object_type") - /** Date of environment variable creation */ + /** + * Date of environment variable creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Date the environment variable was last used */ + /** + * Date the environment variable was last used + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun used(): Optional = Optional.ofNullable(used.getNullable("used")) - /** Unique identifier for the environment variable */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The name of the environment variable */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The id of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The type of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Date of environment variable creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Date the environment variable was last used */ + /** + * Returns the raw JSON value of [used]. + * + * Unlike [used], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("used") @ExcludeMissing fun _used(): JsonField = used @JsonAnyGetter @@ -143,43 +197,76 @@ private constructor( /** Unique identifier for the environment variable */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the environment variable */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) - /** The name of the environment variable */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - /** The type of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [ObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } /** Date of environment variable creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of environment variable creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of environment variable creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Date the environment variable was last used */ fun used(used: OffsetDateTime?) = used(JsonField.ofNullable(used)) - /** Date the environment variable was last used */ + /** Alias for calling [Builder.used] with `used.orElse(null)`. */ fun used(used: Optional) = used(used.getOrNull()) - /** Date the environment variable was last used */ + /** + * Sets [Builder.used] to an arbitrary JSON value. + * + * You should usually call [Builder.used] with a well-typed [OffsetDateTime] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun used(used: JsonField) = apply { this.used = used } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index b088aebe..201e9993 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -34,28 +34,64 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** The name of the environment variable */ + /** + * The name of the environment variable + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** The id of the object the environment variable is scoped for */ + /** + * The id of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = body.objectId() - /** The type of the object the environment variable is scoped for */ + /** + * The type of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): ObjectType = body.objectType() - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * The value of the environment variable. Will be encrypted at rest. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun value(): Optional = body.value() - /** The name of the environment variable */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** The id of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectId(): JsonField = body._objectId() - /** The type of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectType(): JsonField = body._objectType() - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ fun _value(): JsonField = body._value() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -90,30 +126,66 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The name of the environment variable */ + /** + * The name of the environment variable + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** The id of the object the environment variable is scoped for */ + /** + * The id of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The type of the object the environment variable is scoped for */ + /** + * The type of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): ObjectType = objectType.getRequired("object_type") - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * The value of the environment variable. Will be encrypted at rest. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - /** The name of the environment variable */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The id of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The type of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @@ -172,19 +244,37 @@ private constructor( /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) - /** The name of the environment variable */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - /** The type of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [ObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -192,10 +282,16 @@ private constructor( /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) - /** The value of the environment variable. Will be encrypted at rest. */ + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ fun value(value: Optional) = value(value.getOrNull()) - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { @@ -280,28 +376,49 @@ private constructor( /** The name of the environment variable */ fun name(name: String) = apply { body.name(name) } - /** The name of the environment variable */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = apply { body.objectId(objectId) } - /** The id of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } - /** The type of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [ObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = apply { body.value(value) } - /** The value of the environment variable. Will be encrypted at rest. */ + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ fun value(value: Optional) = value(value.getOrNull()) - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun value(value: JsonField) = apply { body.value(value) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { 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 86d2b48e..1afc6fa8 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 @@ -108,7 +108,7 @@ private constructor( /** Name of the env_var to search for */ fun envVarName(envVarName: String?) = apply { this.envVarName = envVarName } - /** Name of the env_var to search for */ + /** Alias for calling [Builder.envVarName] with `envVarName.orElse(null)`. */ fun envVarName(envVarName: Optional) = envVarName(envVarName.getOrNull()) /** @@ -117,43 +117,38 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String?) = apply { this.objectId = objectId } - /** The id of the object the environment variable is scoped for */ + /** Alias for calling [Builder.objectId] with `objectId.orElse(null)`. */ fun objectId(objectId: Optional) = objectId(objectId.getOrNull()) /** The type of the object the environment variable is scoped for */ fun objectType(objectType: EnvVarObjectType?) = apply { this.objectType = objectType } - /** The type of the object the environment variable is scoped for */ + /** Alias for calling [Builder.objectType] with `objectType.orElse(null)`. */ fun objectType(objectType: Optional) = objectType(objectType.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 014c0040..52b019c9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -11,6 +11,7 @@ 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 @@ -27,10 +28,19 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of env_var objects */ + /** + * A list of env_var objects + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objects(): List = objects.getRequired("objects") - /** A list of env_var objects */ + /** + * Returns the raw JSON value of [objects]. + * + * Unlike [objects], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("objects") @ExcludeMissing fun _objects(): JsonField> = objects @JsonAnyGetter @@ -78,12 +88,22 @@ private constructor( /** A list of env_var objects */ fun objects(objects: List) = objects(JsonField.of(objects)) - /** A list of env_var objects */ + /** + * Sets [Builder.objects] to an arbitrary JSON value. + * + * You should usually call [Builder.objects] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun objects(objects: JsonField>) = apply { this.objects = objects.map { it.toMutableList() } } - /** A list of env_var objects */ + /** + * Adds a single [EnvVar] to [objects]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addObject(object_: EnvVar) = apply { objects = (objects ?: JsonField.of(mutableListOf())).also { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index da9d9b85..20e9ac8c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -34,28 +34,64 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** The name of the environment variable */ + /** + * The name of the environment variable + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** The id of the object the environment variable is scoped for */ + /** + * The id of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = body.objectId() - /** The type of the object the environment variable is scoped for */ + /** + * The type of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): ObjectType = body.objectType() - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * The value of the environment variable. Will be encrypted at rest. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun value(): Optional = body.value() - /** The name of the environment variable */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** The id of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectId(): JsonField = body._objectId() - /** The type of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectType(): JsonField = body._objectType() - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ fun _value(): JsonField = body._value() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -90,30 +126,66 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The name of the environment variable */ + /** + * The name of the environment variable + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** The id of the object the environment variable is scoped for */ + /** + * The id of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The type of the object the environment variable is scoped for */ + /** + * The type of the object the environment variable is scoped for + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): ObjectType = objectType.getRequired("object_type") - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * The value of the environment variable. Will be encrypted at rest. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - /** The name of the environment variable */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The id of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The type of the object the environment variable is scoped for */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @@ -172,19 +244,37 @@ private constructor( /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) - /** The name of the environment variable */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - /** The type of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [ObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -192,10 +282,16 @@ private constructor( /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) - /** The value of the environment variable. Will be encrypted at rest. */ + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ fun value(value: Optional) = value(value.getOrNull()) - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { @@ -280,28 +376,49 @@ private constructor( /** The name of the environment variable */ fun name(name: String) = apply { body.name(name) } - /** The name of the environment variable */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the environment variable is scoped for */ fun objectId(objectId: String) = apply { body.objectId(objectId) } - /** The id of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The type of the object the environment variable is scoped for */ fun objectType(objectType: ObjectType) = apply { body.objectType(objectType) } - /** The type of the object the environment variable is scoped for */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [ObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = apply { body.value(value) } - /** The value of the environment variable. Will be encrypted at rest. */ + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ fun value(value: Optional) = value(value.getOrNull()) - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun value(value: JsonField) = apply { body.value(value) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index 11d4bded..e5e94255 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -13,6 +13,7 @@ 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,16 +38,34 @@ private constructor( /** EnvVar id */ fun envVarId(): String = envVarId - /** The name of the environment variable */ + /** + * The name of the environment variable + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * The value of the environment variable. Will be encrypted at rest. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun value(): Optional = body.value() - /** The name of the environment variable */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ fun _value(): JsonField = body._value() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -82,16 +101,34 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The name of the environment variable */ + /** + * The name of the environment variable + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * The value of the environment variable. Will be encrypted at rest. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - /** The name of the environment variable */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @@ -142,16 +179,28 @@ private constructor( /** The name of the environment variable */ fun name(name: String) = name(JsonField.of(name)) - /** The name of the environment variable */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = value(JsonField.ofNullable(value)) - /** The value of the environment variable. Will be encrypted at rest. */ + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ fun value(value: Optional) = value(value.getOrNull()) - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { @@ -234,16 +283,26 @@ private constructor( /** The name of the environment variable */ fun name(name: String) = apply { body.name(name) } - /** The name of the environment variable */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** The value of the environment variable. Will be encrypted at rest. */ fun value(value: String?) = apply { body.value(value) } - /** The value of the environment variable. Will be encrypted at rest. */ + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ fun value(value: Optional) = value(value.getOrNull()) - /** The value of the environment variable. Will be encrypted at rest. */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun value(value: JsonField) = apply { body.value(value) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index 13823ba0..abc2abdf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -48,73 +48,132 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** The dataset to use */ + /** + * The dataset to use + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun data(): Data = body.data() - /** Unique identifier for the project to run the eval in */ + /** + * Unique identifier for the project to run the eval in + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** The functions to score the eval on */ + /** + * The functions to score the eval on + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun scores(): List = body.scores() - /** The function to evaluate */ + /** + * The function to evaluate + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun task(): Task = body.task() /** * An optional experiment id to use as a base. If specified, the new experiment will be * summarized and compared to this experiment. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun baseExperimentId(): Optional = body.baseExperimentId() /** * An optional experiment name to use as a base. If specified, the new experiment will be * summarized and compared to this experiment. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun baseExperimentName(): Optional = body.baseExperimentName() /** * An optional name for the experiment created by this eval. If it conflicts with an existing * experiment, it will be suffixed with a unique identifier. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun experimentName(): Optional = body.experimentName() /** * Optional settings for collecting git metadata. By default, will collect all git metadata * fields allowed in org-level settings. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun gitMetadataSettings(): Optional = body.gitMetadataSettings() - /** Whether the experiment should be public. Defaults to false. */ + /** + * Whether the experiment should be public. Defaults to false. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun isPublic(): Optional = body.isPublic() /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in * which case there is no max concurrency. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun maxConcurrency(): Optional = body.maxConcurrency() /** * Optional experiment-level metadata to store about the evaluation. You can later use this to * slice & dice across experiments. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = body.metadata() - /** Options for tracing the evaluation */ + /** + * Options for tracing the evaluation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun parent(): Optional = body.parent() - /** Metadata about the state of the repo when the experiment was created */ + /** + * Metadata about the state of the repo when the experiment was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun repoInfo(): Optional = body.repoInfo() /** * Whether to stream the results of the eval. If true, the request will return two events: one * to indicate the experiment has started, and another upon completion. If false, the request * will return the evaluation's summary upon completion. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun stream(): Optional = body.stream() /** * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which * case there is no timeout. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun timeout(): Optional = body.timeout() @@ -122,83 +181,124 @@ private constructor( * The number of times to run the evaluator per input. This is useful for evaluating * applications that have non-deterministic behavior and gives you both a stronger aggregate * measure and a sense of the variance in the results. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun trialCount(): Optional = body.trialCount() - /** The dataset to use */ + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ fun _data(): JsonField = body._data() - /** Unique identifier for the project to run the eval in */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** The functions to score the eval on */ + /** + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. + */ fun _scores(): JsonField> = body._scores() - /** The function to evaluate */ + /** + * Returns the raw JSON value of [task]. + * + * Unlike [task], this method doesn't throw if the JSON field has an unexpected type. + */ fun _task(): JsonField = body._task() /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Returns the raw JSON value of [baseExperimentId]. + * + * Unlike [baseExperimentId], this method doesn't throw if the JSON field has an unexpected + * type. */ fun _baseExperimentId(): JsonField = body._baseExperimentId() /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Returns the raw JSON value of [baseExperimentName]. + * + * Unlike [baseExperimentName], this method doesn't throw if the JSON field has an unexpected + * type. */ fun _baseExperimentName(): JsonField = body._baseExperimentName() /** - * An optional name for the experiment created by this eval. If it conflicts with an existing - * experiment, it will be suffixed with a unique identifier. + * Returns the raw JSON value of [experimentName]. + * + * Unlike [experimentName], this method doesn't throw if the JSON field has an unexpected type. */ fun _experimentName(): JsonField = body._experimentName() /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Returns the raw JSON value of [gitMetadataSettings]. + * + * Unlike [gitMetadataSettings], this method doesn't throw if the JSON field has an unexpected + * type. */ fun _gitMetadataSettings(): JsonField = body._gitMetadataSettings() - /** Whether the experiment should be public. Defaults to false. */ + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ fun _isPublic(): JsonField = body._isPublic() /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, in - * which case there is no max concurrency. + * Returns the raw JSON value of [maxConcurrency]. + * + * Unlike [maxConcurrency], this method doesn't throw if the JSON field has an unexpected type. */ fun _maxConcurrency(): JsonField = body._maxConcurrency() /** - * Optional experiment-level metadata to store about the evaluation. You can later use this to - * slice & dice across experiments. + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ fun _metadata(): JsonField = body._metadata() - /** Options for tracing the evaluation */ + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ fun _parent(): JsonField = body._parent() - /** Metadata about the state of the repo when the experiment was created */ + /** + * Returns the raw JSON value of [repoInfo]. + * + * Unlike [repoInfo], this method doesn't throw if the JSON field has an unexpected type. + */ fun _repoInfo(): JsonField = body._repoInfo() /** - * Whether to stream the results of the eval. If true, the request will return two events: one - * to indicate the experiment has started, and another upon completion. If false, the request - * will return the evaluation's summary upon completion. + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. */ fun _stream(): JsonField = body._stream() /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which - * case there is no timeout. + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. */ fun _timeout(): JsonField = body._timeout() /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * Returns the raw JSON value of [trialCount]. + * + * Unlike [trialCount], this method doesn't throw if the JSON field has an unexpected type. */ fun _trialCount(): JsonField = body._trialCount() @@ -266,21 +366,44 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The dataset to use */ + /** + * The dataset to use + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun data(): Data = data.getRequired("data") - /** Unique identifier for the project to run the eval in */ + /** + * Unique identifier for the project to run the eval in + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** The functions to score the eval on */ + /** + * The functions to score the eval on + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun scores(): List = scores.getRequired("scores") - /** The function to evaluate */ + /** + * The function to evaluate + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun task(): Task = task.getRequired("task") /** * An optional experiment id to use as a base. If specified, the new experiment will be * summarized and compared to this experiment. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun baseExperimentId(): Optional = Optional.ofNullable(baseExperimentId.getNullable("base_experiment_id")) @@ -288,6 +411,9 @@ private constructor( /** * An optional experiment name to use as a base. If specified, the new experiment will be * summarized and compared to this experiment. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun baseExperimentName(): Optional = Optional.ofNullable(baseExperimentName.getNullable("base_experiment_name")) @@ -295,6 +421,9 @@ private constructor( /** * An optional name for the experiment created by this eval. If it conflicts with an * existing experiment, it will be suffixed with a unique identifier. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun experimentName(): Optional = Optional.ofNullable(experimentName.getNullable("experiment_name")) @@ -302,16 +431,27 @@ private constructor( /** * Optional settings for collecting git metadata. By default, will collect all git metadata * fields allowed in org-level settings. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun gitMetadataSettings(): Optional = Optional.ofNullable(gitMetadataSettings.getNullable("git_metadata_settings")) - /** Whether the experiment should be public. Defaults to false. */ + /** + * Whether the experiment should be public. Defaults to false. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun isPublic(): Optional = Optional.ofNullable(isPublic.getNullable("is_public")) /** * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, * in which case there is no max concurrency. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun maxConcurrency(): Optional = Optional.ofNullable(maxConcurrency.getNullable("max_concurrency")) @@ -319,25 +459,44 @@ private constructor( /** * Optional experiment-level metadata to store about the evaluation. You can later use this * to slice & dice across experiments. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Options for tracing the evaluation */ + /** + * Options for tracing the evaluation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Metadata about the state of the repo when the experiment was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) /** * Whether to stream the results of the eval. If true, the request will return two events: * one to indicate the experiment has started, and another upon completion. If false, the * request will return the evaluation's summary upon completion. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) /** * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in * which case there is no timeout. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun timeout(): Optional = Optional.ofNullable(timeout.getNullable("timeout")) @@ -345,94 +504,137 @@ private constructor( * The number of times to run the evaluator per input. This is useful for evaluating * applications that have non-deterministic behavior and gives you both a stronger aggregate * measure and a sense of the variance in the results. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun trialCount(): Optional = Optional.ofNullable(trialCount.getNullable("trial_count")) - /** The dataset to use */ + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - /** Unique identifier for the project to run the eval in */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** The functions to score the eval on */ + /** + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField> = scores - /** The function to evaluate */ + /** + * Returns the raw JSON value of [task]. + * + * Unlike [task], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("task") @ExcludeMissing fun _task(): JsonField = task /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Returns the raw JSON value of [baseExperimentId]. + * + * Unlike [baseExperimentId], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("base_experiment_id") @ExcludeMissing fun _baseExperimentId(): JsonField = baseExperimentId /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Returns the raw JSON value of [baseExperimentName]. + * + * Unlike [baseExperimentName], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("base_experiment_name") @ExcludeMissing fun _baseExperimentName(): JsonField = baseExperimentName /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * Returns the raw JSON value of [experimentName]. + * + * Unlike [experimentName], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName(): JsonField = experimentName /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Returns the raw JSON value of [gitMetadataSettings]. + * + * Unlike [gitMetadataSettings], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("git_metadata_settings") @ExcludeMissing fun _gitMetadataSettings(): JsonField = gitMetadataSettings - /** Whether the experiment should be public. Defaults to false. */ + /** + * Returns the raw JSON value of [isPublic]. + * + * Unlike [isPublic], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("is_public") @ExcludeMissing fun _isPublic(): JsonField = isPublic /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * Returns the raw JSON value of [maxConcurrency]. + * + * Unlike [maxConcurrency], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("max_concurrency") @ExcludeMissing fun _maxConcurrency(): JsonField = maxConcurrency /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Options for tracing the evaluation */ + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - /** Metadata about the state of the repo when the experiment was created */ + /** + * Returns the raw JSON value of [repoInfo]. + * + * Unlike [repoInfo], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * Returns the raw JSON value of [trialCount]. + * + * Unlike [trialCount], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("trial_count") @ExcludeMissing @@ -531,34 +733,56 @@ private constructor( /** The dataset to use */ fun data(data: Data) = data(JsonField.of(data)) - /** The dataset to use */ + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun data(data: JsonField) = apply { this.data = data } - /** Dataset id */ + /** Alias for calling [data] with `Data.ofDatasetId(datasetId)`. */ fun data(datasetId: Data.DatasetId) = data(Data.ofDatasetId(datasetId)) - /** Project and dataset name */ + /** Alias for calling [data] with `Data.ofProjectDatasetName(projectDatasetName)`. */ fun data(projectDatasetName: Data.ProjectDatasetName) = data(Data.ofProjectDatasetName(projectDatasetName)) - /** Dataset rows */ + /** Alias for calling [data] with `Data.ofDatasetRows(datasetRows)`. */ fun data(datasetRows: Data.DatasetRows) = data(Data.ofDatasetRows(datasetRows)) /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project to run the eval in */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The functions to score the eval on */ fun scores(scores: List) = scores(JsonField.of(scores)) - /** The functions to score the eval on */ + /** + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun scores(scores: JsonField>) = apply { this.scores = scores.map { it.toMutableList() } } - /** The functions to score the eval on */ + /** + * Adds a single [Score] to [scores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addScore(score: Score) = apply { scores = (scores ?: JsonField.of(mutableListOf())).also { @@ -566,52 +790,58 @@ private constructor( } } - /** Function id */ + /** Alias for calling [addScore] with `Score.ofFunctionId(functionId)`. */ fun addScore(functionId: Score.FunctionId) = addScore(Score.ofFunctionId(functionId)) - /** Project name and slug */ + /** Alias for calling [addScore] with `Score.ofProjectSlug(projectSlug)`. */ fun addScore(projectSlug: Score.ProjectSlug) = addScore(Score.ofProjectSlug(projectSlug)) - /** Global function name */ + /** Alias for calling [addScore] with `Score.ofGlobalFunction(globalFunction)`. */ fun addScore(globalFunction: Score.GlobalFunction) = addScore(Score.ofGlobalFunction(globalFunction)) - /** Prompt session id */ + /** Alias for calling [addScore] with `Score.ofPromptSessionId(promptSessionId)`. */ fun addScore(promptSessionId: Score.PromptSessionId) = addScore(Score.ofPromptSessionId(promptSessionId)) - /** Inline code function */ + /** Alias for calling [addScore] with `Score.ofInlineCode(inlineCode)`. */ fun addScore(inlineCode: Score.InlineCode) = addScore(Score.ofInlineCode(inlineCode)) - /** Inline prompt definition */ + /** Alias for calling [addScore] with `Score.ofInlinePrompt(inlinePrompt)`. */ fun addScore(inlinePrompt: Score.InlinePrompt) = addScore(Score.ofInlinePrompt(inlinePrompt)) /** The function to evaluate */ fun task(task: Task) = task(JsonField.of(task)) - /** The function to evaluate */ + /** + * Sets [Builder.task] to an arbitrary JSON value. + * + * You should usually call [Builder.task] with a well-typed [Task] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun task(task: JsonField) = apply { this.task = task } - /** Function id */ + /** Alias for calling [task] with `Task.ofFunctionId(functionId)`. */ fun task(functionId: Task.FunctionId) = task(Task.ofFunctionId(functionId)) - /** Project name and slug */ + /** Alias for calling [task] with `Task.ofProjectSlug(projectSlug)`. */ fun task(projectSlug: Task.ProjectSlug) = task(Task.ofProjectSlug(projectSlug)) - /** Global function name */ + /** Alias for calling [task] with `Task.ofGlobalFunction(globalFunction)`. */ fun task(globalFunction: Task.GlobalFunction) = task(Task.ofGlobalFunction(globalFunction)) - /** Prompt session id */ + /** Alias for calling [task] with `Task.ofPromptSessionId(promptSessionId)`. */ fun task(promptSessionId: Task.PromptSessionId) = task(Task.ofPromptSessionId(promptSessionId)) - /** Inline code function */ + /** Alias for calling [task] with `Task.ofInlineCode(inlineCode)`. */ fun task(inlineCode: Task.InlineCode) = task(Task.ofInlineCode(inlineCode)) - /** Inline prompt definition */ + /** Alias for calling [task] with `Task.ofInlinePrompt(inlinePrompt)`. */ fun task(inlinePrompt: Task.InlinePrompt) = task(Task.ofInlinePrompt(inlinePrompt)) /** @@ -622,15 +852,17 @@ private constructor( baseExperimentId(JsonField.ofNullable(baseExperimentId)) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Alias for calling [Builder.baseExperimentId] with `baseExperimentId.orElse(null)`. */ fun baseExperimentId(baseExperimentId: Optional) = baseExperimentId(baseExperimentId.getOrNull()) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Sets [Builder.baseExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExperimentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun baseExperimentId(baseExperimentId: JsonField) = apply { this.baseExperimentId = baseExperimentId @@ -644,15 +876,18 @@ private constructor( baseExperimentName(JsonField.ofNullable(baseExperimentName)) /** - * An optional experiment name to use as a base. If specified, the new experiment will - * be summarized and compared to this experiment. + * Alias for calling [Builder.baseExperimentName] with + * `baseExperimentName.orElse(null)`. */ fun baseExperimentName(baseExperimentName: Optional) = baseExperimentName(baseExperimentName.getOrNull()) /** - * An optional experiment name to use as a base. If specified, the new experiment will - * be summarized and compared to this experiment. + * Sets [Builder.baseExperimentName] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExperimentName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun baseExperimentName(baseExperimentName: JsonField) = apply { this.baseExperimentName = baseExperimentName @@ -666,8 +901,11 @@ private constructor( experimentName(JsonField.of(experimentName)) /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * Sets [Builder.experimentName] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun experimentName(experimentName: JsonField) = apply { this.experimentName = experimentName @@ -681,15 +919,18 @@ private constructor( gitMetadataSettings(JsonField.ofNullable(gitMetadataSettings)) /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Alias for calling [Builder.gitMetadataSettings] with + * `gitMetadataSettings.orElse(null)`. */ fun gitMetadataSettings(gitMetadataSettings: Optional) = gitMetadataSettings(gitMetadataSettings.getOrNull()) /** - * Optional settings for collecting git metadata. By default, will collect all git - * metadata fields allowed in org-level settings. + * Sets [Builder.gitMetadataSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.gitMetadataSettings] with a well-typed + * [GitMetadataSettings] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { this.gitMetadataSettings = gitMetadataSettings @@ -698,13 +939,23 @@ private constructor( /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: Boolean?) = isPublic(JsonField.ofNullable(isPublic)) - /** Whether the experiment should be public. Defaults to false. */ + /** + * Alias for [Builder.isPublic]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) - /** Whether the experiment should be public. Defaults to false. */ + /** Alias for calling [Builder.isPublic] with `isPublic.orElse(null)`. */ fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) - /** Whether the experiment should be public. Defaults to false. */ + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun isPublic(isPublic: JsonField) = apply { this.isPublic = isPublic } /** @@ -715,21 +966,22 @@ private constructor( maxConcurrency(JsonField.ofNullable(maxConcurrency)) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * Alias for [Builder.maxConcurrency]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun maxConcurrency(maxConcurrency: Double) = maxConcurrency(maxConcurrency as Double?) - /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. - */ + /** Alias for calling [Builder.maxConcurrency] with `maxConcurrency.orElse(null)`. */ fun maxConcurrency(maxConcurrency: Optional) = maxConcurrency(maxConcurrency.getOrNull()) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to - * undefined, in which case there is no max concurrency. + * Sets [Builder.maxConcurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.maxConcurrency] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun maxConcurrency(maxConcurrency: JsonField) = apply { this.maxConcurrency = maxConcurrency @@ -742,31 +994,46 @@ private constructor( fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * Optional experiment-level metadata to store about the evaluation. You can later use - * this to slice & dice across experiments. + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Options for tracing the evaluation */ fun parent(parent: Parent) = parent(JsonField.of(parent)) - /** Options for tracing the evaluation */ + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [Parent] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun parent(parent: JsonField) = apply { this.parent = parent } - /** Span parent properties */ + /** Alias for calling [parent] with `Parent.ofSpanParentStruct(spanParentStruct)`. */ fun parent(spanParentStruct: Parent.SpanParentStruct) = parent(Parent.ofSpanParentStruct(spanParentStruct)) - /** The parent's span identifier, created by calling `.export()` on a span */ + /** Alias for calling [parent] with `Parent.ofString(string)`. */ fun parent(string: String) = parent(Parent.ofString(string)) /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) - /** Metadata about the state of the repo when the experiment was created */ + /** Alias for calling [Builder.repoInfo] with `repoInfo.orElse(null)`. */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Sets [Builder.repoInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.repoInfo] with a well-typed [RepoInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } /** @@ -777,9 +1044,11 @@ private constructor( fun stream(stream: Boolean) = stream(JsonField.of(stream)) /** - * Whether to stream the results of the eval. If true, the request will return two - * events: one to indicate the experiment has started, and another upon completion. If - * false, the request will return the evaluation's summary upon completion. + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun stream(stream: JsonField) = apply { this.stream = stream } @@ -790,20 +1059,21 @@ private constructor( fun timeout(timeout: Double?) = timeout(JsonField.ofNullable(timeout)) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * Alias for [Builder.timeout]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun timeout(timeout: Double) = timeout(timeout as Double?) - /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. - */ + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, - * in which case there is no timeout. + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun timeout(timeout: JsonField) = apply { this.timeout = timeout } @@ -815,23 +1085,21 @@ private constructor( fun trialCount(trialCount: Double?) = trialCount(JsonField.ofNullable(trialCount)) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * Alias for [Builder.trialCount]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) - /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. - */ + /** Alias for calling [Builder.trialCount] with `trialCount.orElse(null)`. */ fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger - * aggregate measure and a sense of the variance in the results. + * Sets [Builder.trialCount] to an arbitrary JSON value. + * + * You should usually call [Builder.trialCount] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun trialCount(trialCount: JsonField) = apply { this.trialCount = trialCount } @@ -930,77 +1198,103 @@ private constructor( /** The dataset to use */ fun data(data: Data) = apply { body.data(data) } - /** The dataset to use */ + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun data(data: JsonField) = apply { body.data(data) } - /** Dataset id */ + /** Alias for calling [data] with `Data.ofDatasetId(datasetId)`. */ fun data(datasetId: Data.DatasetId) = apply { body.data(datasetId) } - /** Project and dataset name */ + /** Alias for calling [data] with `Data.ofProjectDatasetName(projectDatasetName)`. */ fun data(projectDatasetName: Data.ProjectDatasetName) = apply { body.data(projectDatasetName) } - /** Dataset rows */ + /** Alias for calling [data] with `Data.ofDatasetRows(datasetRows)`. */ fun data(datasetRows: Data.DatasetRows) = apply { body.data(datasetRows) } /** Unique identifier for the project to run the eval in */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project to run the eval in */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The functions to score the eval on */ fun scores(scores: List) = apply { body.scores(scores) } - /** The functions to score the eval on */ + /** + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun scores(scores: JsonField>) = apply { body.scores(scores) } - /** The functions to score the eval on */ + /** + * Adds a single [Score] to [scores]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addScore(score: Score) = apply { body.addScore(score) } - /** Function id */ + /** Alias for calling [addScore] with `Score.ofFunctionId(functionId)`. */ fun addScore(functionId: Score.FunctionId) = apply { body.addScore(functionId) } - /** Project name and slug */ + /** Alias for calling [addScore] with `Score.ofProjectSlug(projectSlug)`. */ fun addScore(projectSlug: Score.ProjectSlug) = apply { body.addScore(projectSlug) } - /** Global function name */ + /** Alias for calling [addScore] with `Score.ofGlobalFunction(globalFunction)`. */ fun addScore(globalFunction: Score.GlobalFunction) = apply { body.addScore(globalFunction) } - /** Prompt session id */ + /** Alias for calling [addScore] with `Score.ofPromptSessionId(promptSessionId)`. */ fun addScore(promptSessionId: Score.PromptSessionId) = apply { body.addScore(promptSessionId) } - /** Inline code function */ + /** Alias for calling [addScore] with `Score.ofInlineCode(inlineCode)`. */ fun addScore(inlineCode: Score.InlineCode) = apply { body.addScore(inlineCode) } - /** Inline prompt definition */ + /** Alias for calling [addScore] with `Score.ofInlinePrompt(inlinePrompt)`. */ fun addScore(inlinePrompt: Score.InlinePrompt) = apply { body.addScore(inlinePrompt) } /** The function to evaluate */ fun task(task: Task) = apply { body.task(task) } - /** The function to evaluate */ + /** + * Sets [Builder.task] to an arbitrary JSON value. + * + * You should usually call [Builder.task] with a well-typed [Task] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun task(task: JsonField) = apply { body.task(task) } - /** Function id */ + /** Alias for calling [task] with `Task.ofFunctionId(functionId)`. */ fun task(functionId: Task.FunctionId) = apply { body.task(functionId) } - /** Project name and slug */ + /** Alias for calling [task] with `Task.ofProjectSlug(projectSlug)`. */ fun task(projectSlug: Task.ProjectSlug) = apply { body.task(projectSlug) } - /** Global function name */ + /** Alias for calling [task] with `Task.ofGlobalFunction(globalFunction)`. */ fun task(globalFunction: Task.GlobalFunction) = apply { body.task(globalFunction) } - /** Prompt session id */ + /** Alias for calling [task] with `Task.ofPromptSessionId(promptSessionId)`. */ fun task(promptSessionId: Task.PromptSessionId) = apply { body.task(promptSessionId) } - /** Inline code function */ + /** Alias for calling [task] with `Task.ofInlineCode(inlineCode)`. */ fun task(inlineCode: Task.InlineCode) = apply { body.task(inlineCode) } - /** Inline prompt definition */ + /** Alias for calling [task] with `Task.ofInlinePrompt(inlinePrompt)`. */ fun task(inlinePrompt: Task.InlinePrompt) = apply { body.task(inlinePrompt) } /** @@ -1011,16 +1305,16 @@ private constructor( body.baseExperimentId(baseExperimentId) } - /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. - */ + /** Alias for calling [Builder.baseExperimentId] with `baseExperimentId.orElse(null)`. */ fun baseExperimentId(baseExperimentId: Optional) = baseExperimentId(baseExperimentId.getOrNull()) /** - * An optional experiment id to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Sets [Builder.baseExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExperimentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun baseExperimentId(baseExperimentId: JsonField) = apply { body.baseExperimentId(baseExperimentId) @@ -1035,15 +1329,17 @@ private constructor( } /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Alias for calling [Builder.baseExperimentName] with `baseExperimentName.orElse(null)`. */ fun baseExperimentName(baseExperimentName: Optional) = baseExperimentName(baseExperimentName.getOrNull()) /** - * An optional experiment name to use as a base. If specified, the new experiment will be - * summarized and compared to this experiment. + * Sets [Builder.baseExperimentName] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExperimentName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun baseExperimentName(baseExperimentName: JsonField) = apply { body.baseExperimentName(baseExperimentName) @@ -1056,8 +1352,11 @@ private constructor( fun experimentName(experimentName: String) = apply { body.experimentName(experimentName) } /** - * An optional name for the experiment created by this eval. If it conflicts with an - * existing experiment, it will be suffixed with a unique identifier. + * Sets [Builder.experimentName] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun experimentName(experimentName: JsonField) = apply { body.experimentName(experimentName) @@ -1072,15 +1371,17 @@ private constructor( } /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Alias for calling [Builder.gitMetadataSettings] with `gitMetadataSettings.orElse(null)`. */ fun gitMetadataSettings(gitMetadataSettings: Optional) = gitMetadataSettings(gitMetadataSettings.getOrNull()) /** - * Optional settings for collecting git metadata. By default, will collect all git metadata - * fields allowed in org-level settings. + * Sets [Builder.gitMetadataSettings] to an arbitrary JSON value. + * + * You should usually call [Builder.gitMetadataSettings] with a well-typed + * [GitMetadataSettings] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ fun gitMetadataSettings(gitMetadataSettings: JsonField) = apply { body.gitMetadataSettings(gitMetadataSettings) @@ -1089,13 +1390,23 @@ private constructor( /** Whether the experiment should be public. Defaults to false. */ fun isPublic(isPublic: Boolean?) = apply { body.isPublic(isPublic) } - /** Whether the experiment should be public. Defaults to false. */ + /** + * Alias for [Builder.isPublic]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun isPublic(isPublic: Boolean) = isPublic(isPublic as Boolean?) - /** Whether the experiment should be public. Defaults to false. */ + /** Alias for calling [Builder.isPublic] with `isPublic.orElse(null)`. */ fun isPublic(isPublic: Optional) = isPublic(isPublic.getOrNull()) - /** Whether the experiment should be public. Defaults to false. */ + /** + * Sets [Builder.isPublic] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublic] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun isPublic(isPublic: JsonField) = apply { body.isPublic(isPublic) } /** @@ -1105,21 +1416,22 @@ private constructor( fun maxConcurrency(maxConcurrency: Double?) = apply { body.maxConcurrency(maxConcurrency) } /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * Alias for [Builder.maxConcurrency]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun maxConcurrency(maxConcurrency: Double) = maxConcurrency(maxConcurrency as Double?) - /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. - */ + /** Alias for calling [Builder.maxConcurrency] with `maxConcurrency.orElse(null)`. */ fun maxConcurrency(maxConcurrency: Optional) = maxConcurrency(maxConcurrency.getOrNull()) /** - * The maximum number of tasks/scorers that will be run concurrently. Defaults to undefined, - * in which case there is no max concurrency. + * Sets [Builder.maxConcurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.maxConcurrency] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun maxConcurrency(maxConcurrency: JsonField) = apply { body.maxConcurrency(maxConcurrency) @@ -1132,32 +1444,46 @@ private constructor( fun metadata(metadata: Metadata) = apply { body.metadata(metadata) } /** - * Optional experiment-level metadata to store about the evaluation. You can later use this - * to slice & dice across experiments. + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Options for tracing the evaluation */ fun parent(parent: Parent) = apply { body.parent(parent) } - /** Options for tracing the evaluation */ + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [Parent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun parent(parent: JsonField) = apply { body.parent(parent) } - /** Span parent properties */ + /** Alias for calling [parent] with `Parent.ofSpanParentStruct(spanParentStruct)`. */ fun parent(spanParentStruct: Parent.SpanParentStruct) = apply { body.parent(spanParentStruct) } - /** The parent's span identifier, created by calling `.export()` on a span */ + /** Alias for calling [parent] with `Parent.ofString(string)`. */ fun parent(string: String) = apply { body.parent(string) } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } - /** Metadata about the state of the repo when the experiment was created */ + /** Alias for calling [Builder.repoInfo] with `repoInfo.orElse(null)`. */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Sets [Builder.repoInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.repoInfo] with a well-typed [RepoInfo] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } /** @@ -1168,9 +1494,10 @@ private constructor( fun stream(stream: Boolean) = apply { body.stream(stream) } /** - * Whether to stream the results of the eval. If true, the request will return two events: - * one to indicate the experiment has started, and another upon completion. If false, the - * request will return the evaluation's summary upon completion. + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun stream(stream: JsonField) = apply { body.stream(stream) } @@ -1181,20 +1508,20 @@ private constructor( fun timeout(timeout: Double?) = apply { body.timeout(timeout) } /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * Alias for [Builder.timeout]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun timeout(timeout: Double) = timeout(timeout as Double?) - /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. - */ + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) /** - * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in - * which case there is no timeout. + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun timeout(timeout: JsonField) = apply { body.timeout(timeout) } @@ -1206,23 +1533,21 @@ private constructor( fun trialCount(trialCount: Double?) = apply { body.trialCount(trialCount) } /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * Alias for [Builder.trialCount]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun trialCount(trialCount: Double) = trialCount(trialCount as Double?) - /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. - */ + /** Alias for calling [Builder.trialCount] with `trialCount.orElse(null)`. */ fun trialCount(trialCount: Optional) = trialCount(trialCount.getOrNull()) /** - * The number of times to run the evaluator per input. This is useful for evaluating - * applications that have non-deterministic behavior and gives you both a stronger aggregate - * measure and a sense of the variance in the results. + * Sets [Builder.trialCount] to an arbitrary JSON value. + * + * You should usually call [Builder.trialCount] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun trialCount(trialCount: JsonField) = apply { body.trialCount(trialCount) } @@ -1534,15 +1859,36 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun datasetId(): String = datasetId.getRequired("dataset_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun _internalBtql(): Optional<_InternalBtql> = Optional.ofNullable(_internalBtql.getNullable("_internal_btql")) + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId + /** + * Returns the raw JSON value of [_internalBtql]. + * + * Unlike [_internalBtql], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("_internal_btql") @ExcludeMissing fun __internalBtql(): JsonField<_InternalBtql> = _internalBtql @@ -1594,14 +1940,29 @@ private constructor( fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) + /** + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } fun _internalBtql(_internalBtql: _InternalBtql?) = _internalBtql(JsonField.ofNullable(_internalBtql)) + /** Alias for calling [Builder._internalBtql] with `_internalBtql.orElse(null)`. */ fun _internalBtql(_internalBtql: Optional<_InternalBtql>) = _internalBtql(_internalBtql.getOrNull()) + /** + * Sets [Builder._internalBtql] to an arbitrary JSON value. + * + * You should usually call [Builder._internalBtql] with a well-typed [_InternalBtql] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun _internalBtql(_internalBtql: JsonField<_InternalBtql>) = apply { this._internalBtql = _internalBtql } @@ -1757,21 +2118,53 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun datasetName(): String = datasetName.getRequired("dataset_name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun projectName(): String = projectName.getRequired("project_name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun _internalBtql(): Optional<_InternalBtql> = Optional.ofNullable(_internalBtql.getNullable("_internal_btql")) + /** + * Returns the raw JSON value of [datasetName]. + * + * Unlike [datasetName], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName(): JsonField = datasetName + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("project_name") @ExcludeMissing fun _projectName(): JsonField = projectName + /** + * Returns the raw JSON value of [_internalBtql]. + * + * Unlike [_internalBtql], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("_internal_btql") @ExcludeMissing fun __internalBtql(): JsonField<_InternalBtql> = _internalBtql @@ -1827,12 +2220,26 @@ private constructor( fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) + /** + * Sets [Builder.datasetName] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } fun projectName(projectName: String) = projectName(JsonField.of(projectName)) + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun projectName(projectName: JsonField) = apply { this.projectName = projectName } @@ -1840,9 +2247,17 @@ private constructor( fun _internalBtql(_internalBtql: _InternalBtql?) = _internalBtql(JsonField.ofNullable(_internalBtql)) + /** Alias for calling [Builder._internalBtql] with `_internalBtql.orElse(null)`. */ fun _internalBtql(_internalBtql: Optional<_InternalBtql>) = _internalBtql(_internalBtql.getOrNull()) + /** + * Sets [Builder._internalBtql] to an arbitrary JSON value. + * + * You should usually call [Builder._internalBtql] with a well-typed [_InternalBtql] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun _internalBtql(_internalBtql: JsonField<_InternalBtql>) = apply { this._internalBtql = _internalBtql } @@ -1993,8 +2408,18 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun data(): List = data.getRequired("data") + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @@ -2041,10 +2466,22 @@ private constructor( fun data(data: List) = data(JsonField.of(data)) + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } + /** + * Adds a single [JsonValue] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addData(data: JsonValue) = apply { this.data = (this.data ?: JsonField.of(mutableListOf())).also { @@ -2367,18 +2804,38 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The ID of the function */ + /** + * The ID of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun functionId(): String = functionId.getRequired("function_id") - /** The version of the function */ + /** + * The version of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** The ID of the function */ + /** + * Returns the raw JSON value of [functionId]. + * + * Unlike [functionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_id") @ExcludeMissing fun _functionId(): JsonField = functionId - /** The version of the function */ + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -2429,7 +2886,13 @@ private constructor( /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) - /** The ID of the function */ + /** + * Sets [Builder.functionId] to an arbitrary JSON value. + * + * You should usually call [Builder.functionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun functionId(functionId: JsonField) = apply { this.functionId = functionId } @@ -2437,7 +2900,13 @@ private constructor( /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) - /** The version of the function */ + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -2506,24 +2975,54 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The name of the project containing the function */ + /** + * The name of the project containing the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun projectName(): String = projectName.getRequired("project_name") - /** The slug of the function */ + /** + * The slug of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun slug(): String = slug.getRequired("slug") - /** The version of the function */ + /** + * The version of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** The name of the project containing the function */ + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("project_name") @ExcludeMissing fun _projectName(): JsonField = projectName - /** The slug of the function */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** The version of the function */ + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -2578,7 +3077,13 @@ private constructor( /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - /** The name of the project containing the function */ + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun projectName(projectName: JsonField) = apply { this.projectName = projectName } @@ -2586,13 +3091,25 @@ private constructor( /** The slug of the function */ fun slug(slug: String) = slug(JsonField.of(slug)) - /** The slug of the function */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) - /** The version of the function */ + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -2659,12 +3176,18 @@ private constructor( /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ fun globalFunction(): String = globalFunction.getRequired("global_function") /** - * The name of the global function. Currently, the global namespace includes the - * functions in autoevals + * Returns the raw JSON value of [globalFunction]. + * + * Unlike [globalFunction], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("global_function") @ExcludeMissing @@ -2720,8 +3243,11 @@ private constructor( globalFunction(JsonField.of(globalFunction)) /** - * The name of the global function. Currently, the global namespace includes the - * functions in autoevals + * Sets [Builder.globalFunction] to an arbitrary JSON value. + * + * You should usually call [Builder.globalFunction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ fun globalFunction(globalFunction: JsonField) = apply { this.globalFunction = globalFunction @@ -2792,27 +3318,58 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The ID of the function in the prompt session */ + /** + * The ID of the function in the prompt session + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") - /** The ID of the prompt session */ + /** + * The ID of the prompt session + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") - /** The version of the function */ + /** + * The version of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** The ID of the function in the prompt session */ + /** + * Returns the raw JSON value of [promptSessionFunctionId]. + * + * Unlike [promptSessionFunctionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("prompt_session_function_id") @ExcludeMissing fun _promptSessionFunctionId(): JsonField = promptSessionFunctionId - /** The ID of the prompt session */ + /** + * Returns the raw JSON value of [promptSessionId]. + * + * Unlike [promptSessionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("prompt_session_id") @ExcludeMissing fun _promptSessionId(): JsonField = promptSessionId - /** The version of the function */ + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -2868,7 +3425,13 @@ private constructor( fun promptSessionFunctionId(promptSessionFunctionId: String) = promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) - /** The ID of the function in the prompt session */ + /** + * Sets [Builder.promptSessionFunctionId] to an arbitrary JSON value. + * + * You should usually call [Builder.promptSessionFunctionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { this.promptSessionFunctionId = promptSessionFunctionId } @@ -2877,7 +3440,13 @@ private constructor( fun promptSessionId(promptSessionId: String) = promptSessionId(JsonField.of(promptSessionId)) - /** The ID of the prompt session */ + /** + * Sets [Builder.promptSessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.promptSessionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun promptSessionId(promptSessionId: JsonField) = apply { this.promptSessionId = promptSessionId } @@ -2885,7 +3454,13 @@ private constructor( /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) - /** The version of the function */ + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -2955,22 +3530,52 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The inline code to execute */ + /** + * The inline code to execute + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun code(): String = code.getRequired("code") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun inlineContext(): InlineContext = inlineContext.getRequired("inline_context") - /** The name of the inline code function */ + /** + * The name of the inline code function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** The inline code to execute */ + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + /** + * Returns the raw JSON value of [inlineContext]. + * + * Unlike [inlineContext], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext(): JsonField = inlineContext - /** The name of the inline code function */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -3025,12 +3630,25 @@ private constructor( /** The inline code to execute */ fun code(code: String) = code(JsonField.of(code)) - /** The inline code to execute */ + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun code(code: JsonField) = apply { this.code = code } fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) + /** + * Sets [Builder.inlineContext] to an arbitrary JSON value. + * + * You should usually call [Builder.inlineContext] with a well-typed [InlineContext] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun inlineContext(inlineContext: JsonField) = apply { this.inlineContext = inlineContext } @@ -3038,10 +3656,16 @@ private constructor( /** The name of the inline code function */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** The name of the inline code function */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** The name of the inline code function */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -3089,14 +3713,36 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun runtime(): Runtime = runtime.getRequired("runtime") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun version(): String = version.getRequired("version") + /** + * Returns the raw JSON value of [runtime]. + * + * Unlike [runtime], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -3147,10 +3793,24 @@ private constructor( fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + /** + * Sets [Builder.runtime] to an arbitrary JSON value. + * + * You should usually call [Builder.runtime] with a well-typed [Runtime] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -3340,19 +4000,38 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) - /** The name of the inline prompt */ + /** + * The name of the inline prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [inlinePrompt]. + * + * Unlike [inlinePrompt], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("inline_prompt") @ExcludeMissing fun _inlinePrompt(): JsonField = inlinePrompt - /** The name of the inline prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -3404,11 +4083,17 @@ private constructor( fun inlinePrompt(inlinePrompt: PromptData?) = inlinePrompt(JsonField.ofNullable(inlinePrompt)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.inlinePrompt] with `inlinePrompt.orElse(null)`. */ fun inlinePrompt(inlinePrompt: Optional) = inlinePrompt(inlinePrompt.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.inlinePrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.inlinePrompt] with a well-typed [PromptData] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun inlinePrompt(inlinePrompt: JsonField) = apply { this.inlinePrompt = inlinePrompt } @@ -3416,10 +4101,16 @@ private constructor( /** The name of the inline prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** The name of the inline prompt */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** The name of the inline prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -3736,18 +4427,38 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The ID of the function */ + /** + * The ID of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun functionId(): String = functionId.getRequired("function_id") - /** The version of the function */ + /** + * The version of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** The ID of the function */ + /** + * Returns the raw JSON value of [functionId]. + * + * Unlike [functionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_id") @ExcludeMissing fun _functionId(): JsonField = functionId - /** The version of the function */ + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -3798,7 +4509,13 @@ private constructor( /** The ID of the function */ fun functionId(functionId: String) = functionId(JsonField.of(functionId)) - /** The ID of the function */ + /** + * Sets [Builder.functionId] to an arbitrary JSON value. + * + * You should usually call [Builder.functionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun functionId(functionId: JsonField) = apply { this.functionId = functionId } @@ -3806,7 +4523,13 @@ private constructor( /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) - /** The version of the function */ + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -3875,24 +4598,54 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The name of the project containing the function */ + /** + * The name of the project containing the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun projectName(): String = projectName.getRequired("project_name") - /** The slug of the function */ + /** + * The slug of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun slug(): String = slug.getRequired("slug") - /** The version of the function */ + /** + * The version of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** The name of the project containing the function */ + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("project_name") @ExcludeMissing fun _projectName(): JsonField = projectName - /** The slug of the function */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** The version of the function */ + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -3947,7 +4700,13 @@ private constructor( /** The name of the project containing the function */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - /** The name of the project containing the function */ + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun projectName(projectName: JsonField) = apply { this.projectName = projectName } @@ -3955,13 +4714,25 @@ private constructor( /** The slug of the function */ fun slug(slug: String) = slug(JsonField.of(slug)) - /** The slug of the function */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) - /** The version of the function */ + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -4028,12 +4799,18 @@ private constructor( /** * The name of the global function. Currently, the global namespace includes the * functions in autoevals + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ fun globalFunction(): String = globalFunction.getRequired("global_function") /** - * The name of the global function. Currently, the global namespace includes the - * functions in autoevals + * Returns the raw JSON value of [globalFunction]. + * + * Unlike [globalFunction], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("global_function") @ExcludeMissing @@ -4089,8 +4866,11 @@ private constructor( globalFunction(JsonField.of(globalFunction)) /** - * The name of the global function. Currently, the global namespace includes the - * functions in autoevals + * Sets [Builder.globalFunction] to an arbitrary JSON value. + * + * You should usually call [Builder.globalFunction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ fun globalFunction(globalFunction: JsonField) = apply { this.globalFunction = globalFunction @@ -4161,27 +4941,58 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The ID of the function in the prompt session */ + /** + * The ID of the function in the prompt session + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun promptSessionFunctionId(): String = promptSessionFunctionId.getRequired("prompt_session_function_id") - /** The ID of the prompt session */ + /** + * The ID of the prompt session + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun promptSessionId(): String = promptSessionId.getRequired("prompt_session_id") - /** The version of the function */ + /** + * The version of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** The ID of the function in the prompt session */ + /** + * Returns the raw JSON value of [promptSessionFunctionId]. + * + * Unlike [promptSessionFunctionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("prompt_session_function_id") @ExcludeMissing fun _promptSessionFunctionId(): JsonField = promptSessionFunctionId - /** The ID of the prompt session */ + /** + * Returns the raw JSON value of [promptSessionId]. + * + * Unlike [promptSessionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("prompt_session_id") @ExcludeMissing fun _promptSessionId(): JsonField = promptSessionId - /** The version of the function */ + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -4237,7 +5048,13 @@ private constructor( fun promptSessionFunctionId(promptSessionFunctionId: String) = promptSessionFunctionId(JsonField.of(promptSessionFunctionId)) - /** The ID of the function in the prompt session */ + /** + * Sets [Builder.promptSessionFunctionId] to an arbitrary JSON value. + * + * You should usually call [Builder.promptSessionFunctionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun promptSessionFunctionId(promptSessionFunctionId: JsonField) = apply { this.promptSessionFunctionId = promptSessionFunctionId } @@ -4246,7 +5063,13 @@ private constructor( fun promptSessionId(promptSessionId: String) = promptSessionId(JsonField.of(promptSessionId)) - /** The ID of the prompt session */ + /** + * Sets [Builder.promptSessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.promptSessionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun promptSessionId(promptSessionId: JsonField) = apply { this.promptSessionId = promptSessionId } @@ -4254,7 +5077,13 @@ private constructor( /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) - /** The version of the function */ + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -4324,22 +5153,52 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The inline code to execute */ + /** + * The inline code to execute + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun code(): String = code.getRequired("code") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun inlineContext(): InlineContext = inlineContext.getRequired("inline_context") - /** The name of the inline code function */ + /** + * The name of the inline code function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** The inline code to execute */ + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + /** + * Returns the raw JSON value of [inlineContext]. + * + * Unlike [inlineContext], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("inline_context") @ExcludeMissing fun _inlineContext(): JsonField = inlineContext - /** The name of the inline code function */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -4394,12 +5253,25 @@ private constructor( /** The inline code to execute */ fun code(code: String) = code(JsonField.of(code)) - /** The inline code to execute */ + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun code(code: JsonField) = apply { this.code = code } fun inlineContext(inlineContext: InlineContext) = inlineContext(JsonField.of(inlineContext)) + /** + * Sets [Builder.inlineContext] to an arbitrary JSON value. + * + * You should usually call [Builder.inlineContext] with a well-typed [InlineContext] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun inlineContext(inlineContext: JsonField) = apply { this.inlineContext = inlineContext } @@ -4407,10 +5279,16 @@ private constructor( /** The name of the inline code function */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** The name of the inline code function */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** The name of the inline code function */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -4458,14 +5336,36 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun runtime(): Runtime = runtime.getRequired("runtime") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun version(): String = version.getRequired("version") + /** + * Returns the raw JSON value of [runtime]. + * + * Unlike [runtime], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -4516,10 +5416,24 @@ private constructor( fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + /** + * Sets [Builder.runtime] to an arbitrary JSON value. + * + * You should usually call [Builder.runtime] with a well-typed [Runtime] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -4709,19 +5623,38 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun inlinePrompt(): Optional = Optional.ofNullable(inlinePrompt.getNullable("inline_prompt")) - /** The name of the inline prompt */ + /** + * The name of the inline prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [inlinePrompt]. + * + * Unlike [inlinePrompt], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("inline_prompt") @ExcludeMissing fun _inlinePrompt(): JsonField = inlinePrompt - /** The name of the inline prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -4773,11 +5706,17 @@ private constructor( fun inlinePrompt(inlinePrompt: PromptData?) = inlinePrompt(JsonField.ofNullable(inlinePrompt)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.inlinePrompt] with `inlinePrompt.orElse(null)`. */ fun inlinePrompt(inlinePrompt: Optional) = inlinePrompt(inlinePrompt.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.inlinePrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.inlinePrompt] with a well-typed [PromptData] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun inlinePrompt(inlinePrompt: JsonField) = apply { this.inlinePrompt = inlinePrompt } @@ -4785,10 +5724,16 @@ private constructor( /** The name of the inline prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** The name of the inline prompt */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** The name of the inline prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -4858,12 +5803,30 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun collect(): Collect = collect.getRequired("collect") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun fields(): Optional> = Optional.ofNullable(fields.getNullable("fields")) + /** + * Returns the raw JSON value of [collect]. + * + * Unlike [collect], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("collect") @ExcludeMissing fun _collect(): JsonField = collect + /** + * Returns the raw JSON value of [fields]. + * + * Unlike [fields], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("fields") @ExcludeMissing fun _fields(): JsonField> = fields @JsonAnyGetter @@ -4913,14 +5876,33 @@ private constructor( fun collect(collect: Collect) = collect(JsonField.of(collect)) + /** + * Sets [Builder.collect] to an arbitrary JSON value. + * + * You should usually call [Builder.collect] with a well-typed [Collect] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun collect(collect: JsonField) = apply { this.collect = collect } fun fields(fields: List) = fields(JsonField.of(fields)) + /** + * Sets [Builder.fields] to an arbitrary JSON value. + * + * You should usually call [Builder.fields] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun fields(fields: JsonField>) = apply { this.fields = fields.map { it.toMutableList() } } + /** + * Adds a single [Field] to [fields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addField(field: Field) = apply { fields = (fields ?: JsonField.of(mutableListOf())).also { @@ -5471,31 +6453,72 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the container object you are logging to */ + /** + * The id of the container object you are logging to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun objectId(): String = objectId.getRequired("object_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun objectType(): ObjectType = objectType.getRequired("object_type") - /** Include these properties in every span created under this parent */ + /** + * Include these properties in every span created under this parent + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun propagatedEvent(): Optional = Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) - /** Identifiers for the row to to log a subspan under */ + /** + * Identifiers for the row to to log a subspan under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) - /** The id of the container object you are logging to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Include these properties in every span created under this parent */ + /** + * Returns the raw JSON value of [propagatedEvent]. + * + * Unlike [propagatedEvent], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("propagated_event") @ExcludeMissing fun _propagatedEvent(): JsonField = propagatedEvent - /** Identifiers for the row to to log a subspan under */ + /** + * Returns the raw JSON value of [rowIds]. + * + * Unlike [rowIds], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField = rowIds @JsonAnyGetter @@ -5553,11 +6576,24 @@ private constructor( /** The id of the container object you are logging to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the container object you are logging to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [ObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -5566,11 +6602,19 @@ private constructor( fun propagatedEvent(propagatedEvent: PropagatedEvent?) = propagatedEvent(JsonField.ofNullable(propagatedEvent)) - /** Include these properties in every span created under this parent */ + /** + * Alias for calling [Builder.propagatedEvent] with `propagatedEvent.orElse(null)`. + */ fun propagatedEvent(propagatedEvent: Optional) = propagatedEvent(propagatedEvent.getOrNull()) - /** Include these properties in every span created under this parent */ + /** + * Sets [Builder.propagatedEvent] to an arbitrary JSON value. + * + * You should usually call [Builder.propagatedEvent] with a well-typed + * [PropagatedEvent] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ fun propagatedEvent(propagatedEvent: JsonField) = apply { this.propagatedEvent = propagatedEvent } @@ -5578,10 +6622,16 @@ private constructor( /** Identifiers for the row to to log a subspan under */ fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) - /** Identifiers for the row to to log a subspan under */ + /** Alias for calling [Builder.rowIds] with `rowIds.orElse(null)`. */ fun rowIds(rowIds: Optional) = rowIds(rowIds.getOrNull()) - /** Identifiers for the row to to log a subspan under */ + /** + * Sets [Builder.rowIds] to an arbitrary JSON value. + * + * You should usually call [Builder.rowIds] with a well-typed [RowIds] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } fun additionalProperties(additionalProperties: Map) = apply { @@ -5832,24 +6882,56 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the row */ + /** + * The id of the row + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun id(): String = id.getRequired("id") - /** The root_span_id of the row */ + /** + * The root_span_id of the row + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - /** The span_id of the row */ + /** + * The span_id of the row + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun spanId(): String = spanId.getRequired("span_id") - /** The id of the row */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The root_span_id of the row */ + /** + * Returns the raw JSON value of [rootSpanId]. + * + * Unlike [rootSpanId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId - /** The span_id of the row */ + /** + * Returns the raw JSON value of [spanId]. + * + * Unlike [spanId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId @JsonAnyGetter @@ -5905,13 +6987,25 @@ private constructor( /** The id of the row */ fun id(id: String) = id(JsonField.of(id)) - /** The id of the row */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** The root_span_id of the row */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** The root_span_id of the row */ + /** + * Sets [Builder.rootSpanId] to an arbitrary JSON value. + * + * You should usually call [Builder.rootSpanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } @@ -5919,7 +7013,13 @@ private constructor( /** The span_id of the row */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) - /** The span_id of the row */ + /** + * Sets [Builder.spanId] to an arbitrary JSON value. + * + * You should usually call [Builder.spanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun spanId(spanId: JsonField) = apply { this.spanId = spanId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 15cc8fb6..6aac3eb1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -10,6 +10,7 @@ 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 @@ -64,107 +65,223 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the experiment */ + /** + * Unique identifier for the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Name of the experiment. Within a project, experiment names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the experiment belongs under */ + /** + * Unique identifier for the project that the experiment belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") /** * Whether or not the experiment is public. Public experiments can be viewed by anybody inside * or outside the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun public_(): Boolean = public_.getRequired("public") - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Id of default base experiment to compare against when viewing this experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) - /** Commit, taken directly from `repo_info.commit` */ + /** + * Commit, taken directly from `repo_info.commit` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) - /** Date of experiment creation */ + /** + * Date of experiment creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) - /** Date of experiment deletion, or null if the experiment is still active */ + /** + * Date of experiment deletion, or null if the experiment is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Textual description of the experiment */ + /** + * Textual description of the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** User-controlled metadata about the experiment */ + /** + * User-controlled metadata about the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Metadata about the state of the repo when the experiment was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) - /** Identifies the user who created the experiment */ + /** + * Identifies the user who created the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the experiment */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the experiment belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Returns the raw JSON value of [public_]. + * + * Unlike [public_], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Returns the raw JSON value of [baseExpId]. + * + * Unlike [baseExpId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId - /** Commit, taken directly from `repo_info.commit` */ + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit - /** Date of experiment creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Returns the raw JSON value of [datasetVersion]. + * + * Unlike [datasetVersion], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion(): JsonField = datasetVersion - /** Date of experiment deletion, or null if the experiment is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - /** Textual description of the experiment */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** User-controlled metadata about the experiment */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Metadata about the state of the repo when the experiment was created */ + /** + * Returns the raw JSON value of [repoInfo]. + * + * Unlike [repoInfo], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo - /** Identifies the user who created the experiment */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @@ -254,19 +371,35 @@ private constructor( /** Unique identifier for the experiment */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the experiment */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the experiment belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** @@ -276,36 +409,55 @@ private constructor( fun public_(public_: Boolean) = public_(JsonField.of(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Sets [Builder.public_] to an arbitrary JSON value. + * + * You should usually call [Builder.public_] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun public_(public_: JsonField) = apply { this.public_ = public_ } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) - /** Id of default base experiment to compare against when viewing this experiment */ + /** Alias for calling [Builder.baseExpId] with `baseExpId.orElse(null)`. */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Sets [Builder.baseExpId] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExpId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } /** Commit, taken directly from `repo_info.commit` */ fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) - /** Commit, taken directly from `repo_info.commit` */ + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ fun commit(commit: Optional) = commit(commit.getOrNull()) - /** Commit, taken directly from `repo_info.commit` */ + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun commit(commit: JsonField) = apply { this.commit = commit } /** Date of experiment creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of experiment creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of experiment creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** @@ -313,13 +465,15 @@ private constructor( */ fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } @@ -330,16 +484,16 @@ private constructor( fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Sets [Builder.datasetVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun datasetVersion(datasetVersion: JsonField) = apply { this.datasetVersion = datasetVersion @@ -348,46 +502,75 @@ private constructor( /** Date of experiment deletion, or null if the experiment is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of experiment deletion, or null if the experiment is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of experiment deletion, or null if the experiment is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the experiment */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the experiment */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** User-controlled metadata about the experiment */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the experiment */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) - /** Metadata about the state of the repo when the experiment was created */ + /** Alias for calling [Builder.repoInfo] with `repoInfo.orElse(null)`. */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Sets [Builder.repoInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.repoInfo] with a well-typed [RepoInfo] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } /** Identifies the user who created the experiment */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the experiment */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the experiment */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index ae017556..b3c21a00 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,84 +33,158 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Unique identifier for the project that the experiment belongs under */ + /** + * Unique identifier for the project that the experiment belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Id of default base experiment to compare against when viewing this experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun baseExpId(): Optional = body.baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun datasetId(): Optional = body.datasetId() /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun datasetVersion(): Optional = body.datasetVersion() - /** Textual description of the experiment */ + /** + * Textual description of the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() /** * Normally, creating an experiment with the same name as an existing experiment will return the * existing one un-modified. But if `ensure_new` is true, registration will generate a new * experiment with a unique name in case of a conflict. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun ensureNew(): Optional = body.ensureNew() - /** User-controlled metadata about the experiment */ + /** + * User-controlled metadata about the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = body.metadata() - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Name of the experiment. Within a project, experiment names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() /** * Whether or not the experiment is public. Public experiments can be viewed by anybody inside * or outside the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun public_(): Optional = body.public_() - /** Metadata about the state of the repo when the experiment was created */ + /** + * Metadata about the state of the repo when the experiment was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun repoInfo(): Optional = body.repoInfo() - /** Unique identifier for the project that the experiment belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Returns the raw JSON value of [baseExpId]. + * + * Unlike [baseExpId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _baseExpId(): JsonField = body._baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _datasetId(): JsonField = body._datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Returns the raw JSON value of [datasetVersion]. + * + * Unlike [datasetVersion], this method doesn't throw if the JSON field has an unexpected type. */ fun _datasetVersion(): JsonField = body._datasetVersion() - /** Textual description of the experiment */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() /** - * Normally, creating an experiment with the same name as an existing experiment will return the - * existing one un-modified. But if `ensure_new` is true, registration will generate a new - * experiment with a unique name in case of a conflict. + * Returns the raw JSON value of [ensureNew]. + * + * Unlike [ensureNew], this method doesn't throw if the JSON field has an unexpected type. */ fun _ensureNew(): JsonField = body._ensureNew() - /** User-controlled metadata about the experiment */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ fun _metadata(): JsonField = body._metadata() - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Returns the raw JSON value of [public_]. + * + * Unlike [public_], this method doesn't throw if the JSON field has an unexpected type. */ fun _public_(): JsonField = body._public_() - /** Metadata about the state of the repo when the experiment was created */ + /** + * Returns the raw JSON value of [repoInfo]. + * + * Unlike [repoInfo], this method doesn't throw if the JSON field has an unexpected type. + */ fun _repoInfo(): JsonField = body._repoInfo() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -162,26 +237,47 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the project that the experiment belongs under */ + /** + * Unique identifier for the project that the experiment belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Id of default base experiment to compare against when viewing this experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) - /** Textual description of the experiment */ + /** + * Textual description of the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -189,69 +285,119 @@ private constructor( * Normally, creating an experiment with the same name as an existing experiment will return * the existing one un-modified. But if `ensure_new` is true, registration will generate a * new experiment with a unique name in case of a conflict. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun ensureNew(): Optional = Optional.ofNullable(ensureNew.getNullable("ensure_new")) - /** User-controlled metadata about the experiment */ + /** + * User-controlled metadata about the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Name of the experiment. Within a project, experiment names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Metadata about the state of the repo when the experiment was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) - /** Unique identifier for the project that the experiment belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Returns the raw JSON value of [baseExpId]. + * + * Unlike [baseExpId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Returns the raw JSON value of [datasetVersion]. + * + * Unlike [datasetVersion], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion(): JsonField = datasetVersion - /** Textual description of the experiment */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Returns the raw JSON value of [ensureNew]. + * + * Unlike [ensureNew], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("ensure_new") @ExcludeMissing fun _ensureNew(): JsonField = ensureNew - /** User-controlled metadata about the experiment */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Returns the raw JSON value of [public_]. + * + * Unlike [public_], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ - /** Metadata about the state of the repo when the experiment was created */ + /** + * Returns the raw JSON value of [repoInfo]. + * + * Unlike [repoInfo], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @@ -326,16 +472,28 @@ private constructor( /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the experiment belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) - /** Id of default base experiment to compare against when viewing this experiment */ + /** Alias for calling [Builder.baseExpId] with `baseExpId.orElse(null)`. */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Sets [Builder.baseExpId] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExpId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } /** @@ -344,15 +502,15 @@ private constructor( */ fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } @@ -363,16 +521,16 @@ private constructor( fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) - /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. - */ + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Sets [Builder.datasetVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun datasetVersion(datasetVersion: JsonField) = apply { this.datasetVersion = datasetVersion @@ -381,10 +539,16 @@ private constructor( /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the experiment */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the experiment */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -397,42 +561,52 @@ private constructor( fun ensureNew(ensureNew: Boolean?) = ensureNew(JsonField.ofNullable(ensureNew)) /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Alias for [Builder.ensureNew]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) - /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. - */ + /** Alias for calling [Builder.ensureNew] with `ensureNew.orElse(null)`. */ fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** - * Normally, creating an experiment with the same name as an existing experiment will - * return the existing one un-modified. But if `ensure_new` is true, registration will - * generate a new experiment with a unique name in case of a conflict. + * Sets [Builder.ensureNew] to an arbitrary JSON value. + * + * You should usually call [Builder.ensureNew] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun ensureNew(ensureNew: JsonField) = apply { this.ensureNew = ensureNew } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** User-controlled metadata about the experiment */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the experiment */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the experiment. Within a project, experiment names are unique */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** @@ -442,30 +616,37 @@ private constructor( fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Alias for [Builder.public_]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun public_(public_: Boolean) = public_(public_ as Boolean?) - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ + /** Alias for calling [Builder.public_] with `public_.orElse(null)`. */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Sets [Builder.public_] to an arbitrary JSON value. + * + * You should usually call [Builder.public_] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun public_(public_: JsonField) = apply { this.public_ = public_ } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) - /** Metadata about the state of the repo when the experiment was created */ + /** Alias for calling [Builder.repoInfo] with `repoInfo.orElse(null)`. */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Sets [Builder.repoInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.repoInfo] with a well-typed [RepoInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } fun additionalProperties(additionalProperties: Map) = apply { @@ -554,16 +735,28 @@ private constructor( /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the experiment belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } - /** Id of default base experiment to compare against when viewing this experiment */ + /** Alias for calling [Builder.baseExpId] with `baseExpId.orElse(null)`. */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Sets [Builder.baseExpId] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExpId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } /** @@ -571,13 +764,15 @@ private constructor( */ fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } @@ -587,16 +782,16 @@ private constructor( */ fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Sets [Builder.datasetVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun datasetVersion(datasetVersion: JsonField) = apply { body.datasetVersion(datasetVersion) @@ -605,10 +800,16 @@ private constructor( /** Textual description of the experiment */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the experiment */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the experiment */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** @@ -619,42 +820,51 @@ private constructor( fun ensureNew(ensureNew: Boolean?) = apply { body.ensureNew(ensureNew) } /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Alias for [Builder.ensureNew]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun ensureNew(ensureNew: Boolean) = ensureNew(ensureNew as Boolean?) - /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. - */ + /** Alias for calling [Builder.ensureNew] with `ensureNew.orElse(null)`. */ fun ensureNew(ensureNew: Optional) = ensureNew(ensureNew.getOrNull()) /** - * Normally, creating an experiment with the same name as an existing experiment will return - * the existing one un-modified. But if `ensure_new` is true, registration will generate a - * new experiment with a unique name in case of a conflict. + * Sets [Builder.ensureNew] to an arbitrary JSON value. + * + * You should usually call [Builder.ensureNew] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun ensureNew(ensureNew: JsonField) = apply { body.ensureNew(ensureNew) } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - /** User-controlled metadata about the experiment */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the experiment */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = apply { body.name(name) } - /** Name of the experiment. Within a project, experiment names are unique */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** @@ -664,30 +874,36 @@ private constructor( fun public_(public_: Boolean?) = apply { body.public_(public_) } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Alias for [Builder.public_]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun public_(public_: Boolean) = public_(public_ as Boolean?) - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ + /** Alias for calling [Builder.public_] with `public_.orElse(null)`. */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Sets [Builder.public_] to an arbitrary JSON value. + * + * You should usually call [Builder.public_] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun public_(public_: JsonField) = apply { body.public_(public_) } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } - /** Metadata about the state of the repo when the experiment was created */ + /** Alias for calling [Builder.repoInfo] with `repoInfo.orElse(null)`. */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Sets [Builder.repoInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.repoInfo] with a well-typed [RepoInfo] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index d05a1609..009aab07 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -11,6 +11,7 @@ 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 @@ -80,6 +81,9 @@ private constructor( /** * A unique identifier for the experiment event. If you don't provide one, BrainTrust will * generate one for you + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") @@ -87,25 +91,51 @@ private constructor( * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the experiment (see the `version` parameter) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** The timestamp the experiment event was created */ + /** + * The timestamp the experiment event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun created(): OffsetDateTime = created.getRequired("created") - /** Unique identifier for the experiment */ + /** + * Unique identifier for the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun experimentId(): String = experimentId.getRequired("experiment_id") - /** Unique identifier for the project that the experiment belongs under */ + /** + * Unique identifier for the project that the experiment belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** A unique identifier for the trace this experiment event belongs to */ + /** + * A unique identifier for the trace this experiment event belongs to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** * A unique identifier used to link different experiment events together as part of a full * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full * details on tracing + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun spanId(): String = spanId.getRequired("span_id") @@ -113,6 +143,9 @@ private constructor( * Context is additional information about the code that produced the experiment event. It is * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the * location in code which produced the experiment event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) @@ -137,7 +170,12 @@ private constructor( */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input - /** Whether this span is a root span */ + /** + * Whether this span is a root span + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** @@ -146,6 +184,9 @@ private constructor( * example, you could log the `prompt`, example's `id`, or anything else that would be useful to * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -153,10 +194,18 @@ private constructor( * Metrics are numerical measurements tracking the execution of the code that produced the * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - /** Indicates the event was copied from another object. */ + /** + * Indicates the event was copied from another object. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** @@ -176,111 +225,155 @@ private constructor( * generated and grouth truth summary. The word similarity score could help you determine * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Human-identifying attributes of the span, such as name, type, etc. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** * An array of the parent `span_ids` of this experiment event. This should be empty for the root * span of a trace, and should most often contain just one parent element for subspans + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the experiment (see the `version` parameter) + * Returns the raw JSON value of [_xactId]. + * + * Unlike [_xactId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - /** The timestamp the experiment event was created */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Unique identifier for the experiment */ + /** + * Returns the raw JSON value of [experimentId]. + * + * Unlike [experimentId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("experiment_id") @ExcludeMissing fun _experimentId(): JsonField = experimentId - /** Unique identifier for the project that the experiment belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** A unique identifier for the trace this experiment event belongs to */ + /** + * Returns the raw JSON value of [rootSpanId]. + * + * Unlike [rootSpanId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * Returns the raw JSON value of [spanId]. + * + * Unlike [spanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - /** Whether this span is a root span */ + /** + * Returns the raw JSON value of [isRoot]. + * + * Unlike [isRoot], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Returns the raw JSON value of [metrics]. + * + * Unlike [metrics], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics - /** Indicates the event was copied from another object. */ + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Returns the raw JSON value of [spanAttributes]. + * + * Unlike [spanAttributes], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes(): JsonField = spanAttributes /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the root - * span of a trace, and should most often contain just one parent element for subspans + * Returns the raw JSON value of [spanParents]. + * + * Unlike [spanParents], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -391,8 +484,10 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } @@ -404,22 +499,35 @@ private constructor( fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) + * Sets [Builder._xactId] to an arbitrary JSON value. + * + * You should usually call [Builder._xactId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) - /** The timestamp the experiment event was created */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Unique identifier for the experiment */ fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) - /** Unique identifier for the experiment */ + /** + * Sets [Builder.experimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun experimentId(experimentId: JsonField) = apply { this.experimentId = experimentId } @@ -427,13 +535,25 @@ private constructor( /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the experiment belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A unique identifier for the trace this experiment event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** A unique identifier for the trace this experiment event belongs to */ + /** + * Sets [Builder.rootSpanId] to an arbitrary JSON value. + * + * You should usually call [Builder.rootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** @@ -444,9 +564,10 @@ private constructor( fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different experiment events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * Sets [Builder.spanId] to an arbitrary JSON value. + * + * You should usually call [Builder.spanId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun spanId(spanId: JsonField) = apply { this.spanId = spanId } @@ -457,17 +578,14 @@ private constructor( */ fun context(context: Context?) = context(JsonField.ofNullable(context)) - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [Context] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun context(context: JsonField) = apply { this.context = context } @@ -495,13 +613,22 @@ private constructor( /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) - /** Whether this span is a root span */ + /** + * Alias for [Builder.isRoot]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) - /** Whether this span is a root span */ + /** Alias for calling [Builder.isRoot] with `isRoot.orElse(null)`. */ fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) - /** Whether this span is a root span */ + /** + * Sets [Builder.isRoot] to an arbitrary JSON value. + * + * You should usually call [Builder.isRoot] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } /** @@ -513,21 +640,15 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -538,27 +659,30 @@ private constructor( */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ + /** Alias for calling [Builder.metrics] with `metrics.orElse(null)`. */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Sets [Builder.metrics] to an arbitrary JSON value. + * + * You should usually call [Builder.metrics] with a well-typed [Metrics] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) - /** Indicates the event was copied from another object. */ + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) - /** Indicates the event was copied from another object. */ + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [ObjectReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } /** @@ -581,25 +705,14 @@ private constructor( */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments - */ + /** Alias for calling [Builder.scores] with `scores.orElse(null)`. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed [Scores] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun scores(scores: JsonField) = apply { this.scores = scores } @@ -607,11 +720,17 @@ private constructor( fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** Alias for calling [Builder.spanAttributes] with `spanAttributes.orElse(null)`. */ fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Sets [Builder.spanAttributes] to an arbitrary JSON value. + * + * You should usually call [Builder.spanAttributes] with a well-typed [SpanAttributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun spanAttributes(spanAttributes: JsonField) = apply { this.spanAttributes = spanAttributes } @@ -622,23 +741,24 @@ private constructor( */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) - /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans - */ + /** Alias for calling [Builder.spanParents] with `spanParents.orElse(null)`. */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * Sets [Builder.spanParents] to an arbitrary JSON value. + * + * You should usually call [Builder.spanParents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun spanParents(spanParents: JsonField>) = apply { this.spanParents = spanParents.map { it.toMutableList() } } /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * Adds a single [String] to [spanParents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addSpanParent(spanParent: String) = apply { spanParents = @@ -650,15 +770,25 @@ private constructor( /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } @@ -730,29 +860,59 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the file in code where the experiment event was created */ + /** + * Name of the file in code where the experiment event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) - /** The function in code which created the experiment event */ + /** + * The function in code which created the experiment event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - /** Line of code where the experiment event was created */ + /** + * Line of code where the experiment event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - /** Name of the file in code where the experiment event was created */ + /** + * Returns the raw JSON value of [callerFilename]. + * + * Unlike [callerFilename], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename(): JsonField = callerFilename - /** The function in code which created the experiment event */ + /** + * Returns the raw JSON value of [callerFunctionname]. + * + * Unlike [callerFunctionname], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("caller_functionname") @ExcludeMissing fun _callerFunctionname(): JsonField = callerFunctionname - /** Line of code where the experiment event was created */ + /** + * Returns the raw JSON value of [callerLineno]. + * + * Unlike [callerLineno], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonField = callerLineno @@ -802,11 +962,17 @@ private constructor( fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) - /** Name of the file in code where the experiment event was created */ + /** Alias for calling [Builder.callerFilename] with `callerFilename.orElse(null)`. */ fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) - /** Name of the file in code where the experiment event was created */ + /** + * Sets [Builder.callerFilename] to an arbitrary JSON value. + * + * You should usually call [Builder.callerFilename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerFilename(callerFilename: JsonField) = apply { this.callerFilename = callerFilename } @@ -815,11 +981,20 @@ private constructor( fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) - /** The function in code which created the experiment event */ + /** + * Alias for calling [Builder.callerFunctionname] with + * `callerFunctionname.orElse(null)`. + */ fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) - /** The function in code which created the experiment event */ + /** + * Sets [Builder.callerFunctionname] to an arbitrary JSON value. + * + * You should usually call [Builder.callerFunctionname] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerFunctionname(callerFunctionname: JsonField) = apply { this.callerFunctionname = callerFunctionname } @@ -827,13 +1002,23 @@ private constructor( /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) - /** Line of code where the experiment event was created */ + /** + * Alias for [Builder.callerLineno]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) - /** Line of code where the experiment event was created */ + /** Alias for calling [Builder.callerLineno] with `callerLineno.orElse(null)`. */ fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) - /** Line of code where the experiment event was created */ + /** + * Sets [Builder.callerLineno] to an arbitrary JSON value. + * + * You should usually call [Builder.callerLineno] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerLineno(callerLineno: JsonField) = apply { this.callerLineno = callerLineno } @@ -902,10 +1087,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The model used for this example */ + /** + * The model used for this example + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - /** The model used for this example */ + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model @JsonAnyGetter @@ -946,10 +1140,16 @@ private constructor( /** The model used for this example */ fun model(model: String?) = model(JsonField.ofNullable(model)) - /** The model used for this example */ + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ fun model(model: Optional) = model(model.getOrNull()) - /** The model used for this example */ + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun model(model: JsonField) = apply { this.model = model } fun additionalProperties(additionalProperties: Map) = apply { @@ -1043,6 +1243,9 @@ private constructor( /** * The number of tokens in the completion generated by the model (only set if this is an LLM * span) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) @@ -1050,12 +1253,18 @@ private constructor( /** * A unix timestamp recording when the section of code which produced the experiment event * finished + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) @@ -1063,41 +1272,59 @@ private constructor( /** * A unix timestamp recording when the section of code which produced the experiment event * started + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - /** The total number of tokens in the input and output of the experiment event. */ + /** + * The total number of tokens in the input and output of the experiment event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * Returns the raw JSON value of [end]. + * + * Unlike [end], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * Returns the raw JSON value of [start]. + * + * Unlike [start], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start - /** The total number of tokens in the input and output of the experiment event. */ + /** + * Returns the raw JSON value of [tokens]. + * + * Unlike [tokens], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @@ -1174,22 +1401,25 @@ private constructor( completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. */ fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun completionTokens(completionTokens: JsonField) = apply { this.completionTokens = completionTokens @@ -1202,20 +1432,21 @@ private constructor( fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * Alias for [Builder.end]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun end(end: Double) = end(end as Double?) - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ + /** Alias for calling [Builder.end] with `end.orElse(null)`. */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * Sets [Builder.end] to an arbitrary JSON value. + * + * You should usually call [Builder.end] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun end(end: JsonField) = apply { this.end = end } @@ -1226,20 +1457,21 @@ private constructor( fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens @@ -1252,33 +1484,44 @@ private constructor( fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * Alias for [Builder.start]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun start(start: Double) = start(start as Double?) - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ + /** Alias for calling [Builder.start] with `start.orElse(null)`. */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * Sets [Builder.start] to an arbitrary JSON value. + * + * You should usually call [Builder.start] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) - /** The total number of tokens in the input and output of the experiment event. */ + /** + * Alias for [Builder.tokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun tokens(tokens: Long) = tokens(tokens as Long?) - /** The total number of tokens in the input and output of the experiment event. */ + /** Alias for calling [Builder.tokens] with `tokens.orElse(null)`. */ fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) - /** The total number of tokens in the input and output of the experiment event. */ + /** + * Sets [Builder.tokens] to an arbitrary JSON value. + * + * You should usually call [Builder.tokens] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index b4b3324a..1d338421 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -14,6 +14,7 @@ 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 @@ -32,10 +33,19 @@ private constructor( /** Experiment id */ fun experimentId(): String = experimentId - /** A list of experiment feedback items */ + /** + * A list of experiment feedback items + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun feedback(): List = body.feedback() - /** A list of experiment feedback items */ + /** + * Returns the raw JSON value of [feedback]. + * + * Unlike [feedback], this method doesn't throw if the JSON field has an unexpected type. + */ fun _feedback(): JsonField> = body._feedback() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -68,10 +78,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of experiment feedback items */ + /** + * A list of experiment feedback items + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun feedback(): List = feedback.getRequired("feedback") - /** A list of experiment feedback items */ + /** + * Returns the raw JSON value of [feedback]. + * + * Unlike [feedback], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("feedback") @ExcludeMissing fun _feedback(): JsonField> = feedback @@ -121,12 +140,22 @@ private constructor( /** A list of experiment feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) - /** A list of experiment feedback items */ + /** + * Sets [Builder.feedback] to an arbitrary JSON value. + * + * You should usually call [Builder.feedback] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ fun feedback(feedback: JsonField>) = apply { this.feedback = feedback.map { it.toMutableList() } } - /** A list of experiment feedback items */ + /** + * Adds a single [FeedbackExperimentItem] to [Builder.feedback]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addFeedback(feedback: FeedbackExperimentItem) = apply { this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { @@ -217,12 +246,22 @@ private constructor( /** A list of experiment feedback items */ fun feedback(feedback: List) = apply { body.feedback(feedback) } - /** A list of experiment feedback items */ + /** + * Sets [Builder.feedback] to an arbitrary JSON value. + * + * You should usually call [Builder.feedback] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun feedback(feedback: JsonField>) = apply { body.feedback(feedback) } - /** A list of experiment feedback items */ + /** + * Adds a single [FeedbackExperimentItem] to [Builder.feedback]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addFeedback(feedback: FeedbackExperimentItem) = apply { body.addFeedback(feedback) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 53ca3670..0edbea15 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -164,37 +164,13 @@ private constructor( fun limit(limit: Long?) = apply { this.limit = limit } /** - * limit the number of traces fetched + * Alias for [Builder.limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** @@ -211,18 +187,7 @@ private constructor( */ fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) @@ -240,18 +205,7 @@ private constructor( */ fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** @@ -262,12 +216,7 @@ private constructor( */ fun version(version: String?) = apply { this.version = version } - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index b6cde61b..42a6bf11 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -13,6 +13,7 @@ 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 @@ -42,6 +43,9 @@ private constructor( * earliest. * * The string can be obtained directly from the `cursor` property of the previous fetch query + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun cursor(): Optional = body.cursor() @@ -58,6 +62,9 @@ private constructor( * * The `limit` parameter controls the number of full traces to return. So you may end up with * more individual rows than the specified limit if you are fetching events containing traces. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun limit(): Optional = body.limit() @@ -72,6 +79,9 @@ private constructor( * for the next page can be found as the row with the minimum (earliest) value of the tuple * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating * fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun maxRootSpanId(): Optional = body.maxRootSpanId() @@ -86,6 +96,9 @@ private constructor( * for the next page can be found as the row with the minimum (earliest) value of the tuple * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating * fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun maxXactId(): Optional = body.maxXactId() @@ -94,66 +107,44 @@ private constructor( * * The version id is essentially a filter on the latest event transaction id. You can use the * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * Returns the raw JSON value of [cursor]. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ fun _cursor(): JsonField = body._cursor() /** - * limit the number of traces fetched + * Returns the raw JSON value of [limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * Returns the raw JSON value of [maxRootSpanId]. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Unlike [maxRootSpanId], this method doesn't throw if the JSON field has an unexpected type. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * Returns the raw JSON value of [maxXactId]. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Unlike [maxXactId], this method doesn't throw if the JSON field has an unexpected type. */ fun _maxXactId(): JsonField = body._maxXactId() /** - * Retrieve a snapshot of events from a past time + * Returns the raw JSON value of [version]. * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. */ fun _version(): JsonField = body._version() @@ -205,6 +196,9 @@ private constructor( * * The string can be obtained directly from the `cursor` property of the previous fetch * query + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) @@ -222,6 +216,9 @@ private constructor( * The `limit` parameter controls the number of full traces to return. So you may end up * with more individual rows than the specified limit if you are fetching events containing * traces. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) @@ -236,6 +233,9 @@ private constructor( * cursor for the next page can be found as the row with the minimum (earliest) value of the * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) @@ -251,6 +251,9 @@ private constructor( * cursor for the next page can be found as the row with the minimum (earliest) value of the * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) @@ -260,70 +263,47 @@ private constructor( * * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Returns the raw JSON value of [cursor]. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Returns the raw JSON value of [limit]. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Returns the raw JSON value of [maxRootSpanId]. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Unlike [maxRootSpanId], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Returns the raw JSON value of [maxXactId]. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Unlike [maxXactId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId /** - * Retrieve a snapshot of events from a past time + * Returns the raw JSON value of [version]. * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @@ -383,21 +363,15 @@ private constructor( */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Sets [Builder.cursor] to an arbitrary JSON value. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * You should usually call [Builder.cursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun cursor(cursor: JsonField) = apply { this.cursor = cursor } @@ -419,53 +393,21 @@ private constructor( fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Alias for [Builder.limit]. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * limit the number of traces fetched + * Sets [Builder.limit] to an arbitrary JSON value. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun limit(limit: JsonField) = apply { this.limit = limit } @@ -484,32 +426,16 @@ private constructor( fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * Sets [Builder.maxRootSpanId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * You should usually call [Builder.maxRootSpanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun maxRootSpanId(maxRootSpanId: JsonField) = apply { this.maxRootSpanId = maxRootSpanId @@ -529,31 +455,15 @@ private constructor( */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Sets [Builder.maxXactId] to an arbitrary JSON value. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * You should usually call [Builder.maxXactId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } @@ -566,21 +476,15 @@ private constructor( */ fun version(version: String?) = version(JsonField.ofNullable(version)) - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) /** - * Retrieve a snapshot of events from a past time + * Sets [Builder.version] to an arbitrary JSON value. * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun version(version: JsonField) = apply { this.version = version } @@ -676,21 +580,14 @@ private constructor( */ fun cursor(cursor: String?) = apply { body.cursor(cursor) } - /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Sets [Builder.cursor] to an arbitrary JSON value. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } @@ -712,53 +609,20 @@ private constructor( fun limit(limit: Long?) = apply { body.limit(limit) } /** - * limit the number of traces fetched + * Alias for [Builder.limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * limit the number of traces fetched + * Sets [Builder.limit] to an arbitrary JSON value. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun limit(limit: JsonField) = apply { body.limit(limit) } @@ -776,32 +640,16 @@ private constructor( */ fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * Sets [Builder.maxRootSpanId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * You should usually call [Builder.maxRootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun maxRootSpanId(maxRootSpanId: JsonField) = apply { body.maxRootSpanId(maxRootSpanId) @@ -821,31 +669,15 @@ private constructor( */ fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * Sets [Builder.maxXactId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * You should usually call [Builder.maxXactId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } @@ -857,19 +689,14 @@ private constructor( */ fun version(version: String?) = apply { body.version(version) } - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) /** - * Retrieve a snapshot of events from a past time + * Sets [Builder.version] to an arbitrary JSON value. * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun version(version: JsonField) = apply { body.version(version) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index e04423cf..52aad5c8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -14,6 +14,7 @@ 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 @@ -32,10 +33,19 @@ private constructor( /** Experiment id */ fun experimentId(): String = experimentId - /** A list of experiment events to insert */ + /** + * A list of experiment events to insert + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = body.events() - /** A list of experiment events to insert */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ fun _events(): JsonField> = body._events() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -68,10 +78,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of experiment events to insert */ + /** + * A list of experiment events to insert + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = events.getRequired("events") - /** A list of experiment events to insert */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events @@ -121,12 +140,22 @@ private constructor( /** A list of experiment events to insert */ fun events(events: List) = events(JsonField.of(events)) - /** A list of experiment events to insert */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } - /** A list of experiment events to insert */ + /** + * Adds a single [InsertExperimentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: InsertExperimentEvent) = apply { events = (events ?: JsonField.of(mutableListOf())).also { @@ -216,10 +245,20 @@ private constructor( /** A list of experiment events to insert */ fun events(events: List) = apply { body.events(events) } - /** A list of experiment events to insert */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun events(events: JsonField>) = apply { body.events(events) } - /** A list of experiment events to insert */ + /** + * Adds a single [InsertExperimentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: InsertExperimentEvent) = apply { body.addEvent(event) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 2b4b05c0..71db2f5c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -147,19 +147,13 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the experiment to search for */ fun experimentName(experimentName: String?) = apply { this.experimentName = experimentName } - /** Name of the experiment to search for */ + /** Alias for calling [Builder.experimentName] with `experimentName.orElse(null)`. */ fun experimentName(experimentName: Optional) = experimentName(experimentName.getOrNull()) @@ -169,49 +163,44 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } - /** Project id */ + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } - /** Name of the project to search for */ + /** Alias for calling [Builder.projectName] with `projectName.orElse(null)`. */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** @@ -223,13 +212,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index c988c73a..d6df3b64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -108,10 +108,8 @@ private constructor( } /** - * The experiment to compare against, if summarizing scores and metrics. If omitted, will - * fall back to the `base_exp_id` stored in the experiment metadata, and then to the most - * recent experiment run in the same project. Must pass `summarize_scores=true` for this id - * to be used + * Alias for calling [Builder.comparisonExperimentId] with + * `comparisonExperimentId.orElse(null)`. */ fun comparisonExperimentId(comparisonExperimentId: Optional) = comparisonExperimentId(comparisonExperimentId.getOrNull()) @@ -125,15 +123,13 @@ private constructor( } /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata - * will be returned. + * Alias for [Builder.summarizeScores]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun summarizeScores(summarizeScores: Boolean) = summarizeScores(summarizeScores as Boolean?) - /** - * Whether to summarize the scores and metrics. If false (or omitted), only the metadata - * will be returned. - */ + /** Alias for calling [Builder.summarizeScores] with `summarizeScores.orElse(null)`. */ fun summarizeScores(summarizeScores: Optional) = summarizeScores(summarizeScores.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 1f99550c..2b2b32af 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -13,6 +13,7 @@ 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,64 +38,126 @@ private constructor( /** Experiment id */ fun experimentId(): String = experimentId - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Id of default base experiment to compare against when viewing this experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun baseExpId(): Optional = body.baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun datasetId(): Optional = body.datasetId() /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun datasetVersion(): Optional = body.datasetVersion() - /** Textual description of the experiment */ + /** + * Textual description of the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** User-controlled metadata about the experiment */ + /** + * User-controlled metadata about the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = body.metadata() - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Name of the experiment. Within a project, experiment names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() /** * Whether or not the experiment is public. Public experiments can be viewed by anybody inside * or outside the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun public_(): Optional = body.public_() - /** Metadata about the state of the repo when the experiment was created */ + /** + * Metadata about the state of the repo when the experiment was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun repoInfo(): Optional = body.repoInfo() - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Returns the raw JSON value of [baseExpId]. + * + * Unlike [baseExpId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _baseExpId(): JsonField = body._baseExpId() - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ + /** + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _datasetId(): JsonField = body._datasetId() /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Returns the raw JSON value of [datasetVersion]. + * + * Unlike [datasetVersion], this method doesn't throw if the JSON field has an unexpected type. */ fun _datasetVersion(): JsonField = body._datasetVersion() - /** Textual description of the experiment */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** User-controlled metadata about the experiment */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ fun _metadata(): JsonField = body._metadata() - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization + * Returns the raw JSON value of [public_]. + * + * Unlike [public_], this method doesn't throw if the JSON field has an unexpected type. */ fun _public_(): JsonField = body._public_() - /** Metadata about the state of the repo when the experiment was created */ + /** + * Returns the raw JSON value of [repoInfo]. + * + * Unlike [repoInfo], this method doesn't throw if the JSON field has an unexpected type. + */ fun _repoInfo(): JsonField = body._repoInfo() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -148,75 +211,134 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Id of default base experiment to compare against when viewing this experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun baseExpId(): Optional = Optional.ofNullable(baseExpId.getNullable("base_exp_id")) /** * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun datasetId(): Optional = Optional.ofNullable(datasetId.getNullable("dataset_id")) /** * Version number of the linked dataset the experiment was run against. This can be used to * reproduce the experiment after the dataset has been modified. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun datasetVersion(): Optional = Optional.ofNullable(datasetVersion.getNullable("dataset_version")) - /** Textual description of the experiment */ + /** + * Textual description of the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** User-controlled metadata about the experiment */ + /** + * User-controlled metadata about the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Name of the experiment. Within a project, experiment names are unique + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** * Whether or not the experiment is public. Public experiments can be viewed by anybody * inside or outside the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun public_(): Optional = Optional.ofNullable(public_.getNullable("public")) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Metadata about the state of the repo when the experiment was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun repoInfo(): Optional = Optional.ofNullable(repoInfo.getNullable("repo_info")) - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Returns the raw JSON value of [baseExpId]. + * + * Unlike [baseExpId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId(): JsonField = baseExpId /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Returns the raw JSON value of [datasetId]. + * + * Unlike [datasetId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId(): JsonField = datasetId /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Returns the raw JSON value of [datasetVersion]. + * + * Unlike [datasetVersion], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion(): JsonField = datasetVersion - /** Textual description of the experiment */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** User-controlled metadata about the experiment */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Returns the raw JSON value of [public_]. + * + * Unlike [public_], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("public") @ExcludeMissing fun _public_(): JsonField = public_ - /** Metadata about the state of the repo when the experiment was created */ + /** + * Returns the raw JSON value of [repoInfo]. + * + * Unlike [repoInfo], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo(): JsonField = repoInfo @JsonAnyGetter @@ -278,10 +400,16 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = baseExpId(JsonField.ofNullable(baseExpId)) - /** Id of default base experiment to compare against when viewing this experiment */ + /** Alias for calling [Builder.baseExpId] with `baseExpId.orElse(null)`. */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Sets [Builder.baseExpId] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExpId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } /** @@ -290,15 +418,15 @@ private constructor( */ fun datasetId(datasetId: String?) = datasetId(JsonField.ofNullable(datasetId)) - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset - */ + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a - * dataset + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } @@ -309,16 +437,16 @@ private constructor( fun datasetVersion(datasetVersion: String?) = datasetVersion(JsonField.ofNullable(datasetVersion)) - /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. - */ + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used - * to reproduce the experiment after the dataset has been modified. + * Sets [Builder.datasetVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun datasetVersion(datasetVersion: JsonField) = apply { this.datasetVersion = datasetVersion @@ -327,10 +455,16 @@ private constructor( /** Textual description of the experiment */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the experiment */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the experiment */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -338,19 +472,31 @@ private constructor( /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** User-controlled metadata about the experiment */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the experiment */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the experiment. Within a project, experiment names are unique */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** @@ -360,30 +506,37 @@ private constructor( fun public_(public_: Boolean?) = public_(JsonField.ofNullable(public_)) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Alias for [Builder.public_]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun public_(public_: Boolean) = public_(public_ as Boolean?) - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ + /** Alias for calling [Builder.public_] with `public_.orElse(null)`. */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Sets [Builder.public_] to an arbitrary JSON value. + * + * You should usually call [Builder.public_] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun public_(public_: JsonField) = apply { this.public_ = public_ } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = repoInfo(JsonField.ofNullable(repoInfo)) - /** Metadata about the state of the repo when the experiment was created */ + /** Alias for calling [Builder.repoInfo] with `repoInfo.orElse(null)`. */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Sets [Builder.repoInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.repoInfo] with a well-typed [RepoInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } fun additionalProperties(additionalProperties: Map) = apply { @@ -475,10 +628,16 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String?) = apply { body.baseExpId(baseExpId) } - /** Id of default base experiment to compare against when viewing this experiment */ + /** Alias for calling [Builder.baseExpId] with `baseExpId.orElse(null)`. */ fun baseExpId(baseExpId: Optional) = baseExpId(baseExpId.getOrNull()) - /** Id of default base experiment to compare against when viewing this experiment */ + /** + * Sets [Builder.baseExpId] to an arbitrary JSON value. + * + * You should usually call [Builder.baseExpId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun baseExpId(baseExpId: JsonField) = apply { body.baseExpId(baseExpId) } /** @@ -486,13 +645,15 @@ private constructor( */ fun datasetId(datasetId: String?) = apply { body.datasetId(datasetId) } - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ + /** Alias for calling [Builder.datasetId] with `datasetId.orElse(null)`. */ fun datasetId(datasetId: Optional) = datasetId(datasetId.getOrNull()) /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + * Sets [Builder.datasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun datasetId(datasetId: JsonField) = apply { body.datasetId(datasetId) } @@ -502,16 +663,16 @@ private constructor( */ fun datasetVersion(datasetVersion: String?) = apply { body.datasetVersion(datasetVersion) } - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ + /** Alias for calling [Builder.datasetVersion] with `datasetVersion.orElse(null)`. */ fun datasetVersion(datasetVersion: Optional) = datasetVersion(datasetVersion.getOrNull()) /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. + * Sets [Builder.datasetVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun datasetVersion(datasetVersion: JsonField) = apply { body.datasetVersion(datasetVersion) @@ -520,28 +681,45 @@ private constructor( /** Textual description of the experiment */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the experiment */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the experiment */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - /** User-controlled metadata about the experiment */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the experiment */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String?) = apply { body.name(name) } - /** Name of the experiment. Within a project, experiment names are unique */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the experiment. Within a project, experiment names are unique */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** @@ -551,30 +729,36 @@ private constructor( fun public_(public_: Boolean?) = apply { body.public_(public_) } /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Alias for [Builder.public_]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun public_(public_: Boolean) = public_(public_ as Boolean?) - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ + /** Alias for calling [Builder.public_] with `public_.orElse(null)`. */ fun public_(public_: Optional) = public_(public_.getOrNull()) /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization + * Sets [Builder.public_] to an arbitrary JSON value. + * + * You should usually call [Builder.public_] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun public_(public_: JsonField) = apply { body.public_(public_) } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo?) = apply { body.repoInfo(repoInfo) } - /** Metadata about the state of the repo when the experiment was created */ + /** Alias for calling [Builder.repoInfo] with `repoInfo.orElse(null)`. */ fun repoInfo(repoInfo: Optional) = repoInfo(repoInfo.getOrNull()) - /** Metadata about the state of the repo when the experiment was created */ + /** + * Sets [Builder.repoInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.repoInfo] with a well-typed [RepoInfo] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun repoInfo(repoInfo: JsonField) = apply { body.repoInfo(repoInfo) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 887cdc58..95b2eb66 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -44,45 +44,79 @@ private constructor( /** * The id of the dataset event to log feedback for. This is the row `id` returned by `POST * /v1/dataset/{dataset_id}/insert` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") - /** An optional comment string to log about the dataset event */ + /** + * An optional comment string to log about the dataset event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * The source of the feedback. Must be one of "external" (default), "app", or "api" + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** An optional comment string to log about the dataset event */ + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -146,18 +180,25 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } /** An optional comment string to log about the dataset event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) - /** An optional comment string to log about the dataset event */ + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ fun comment(comment: Optional) = comment(comment.getOrNull()) - /** An optional comment string to log about the dataset event */ + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun comment(comment: JsonField) = apply { this.comment = comment } /** @@ -167,41 +208,54 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ fun source(source: Optional) = source(source.getOrNull()) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index a30bbcd2..f0c2949a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -48,10 +48,18 @@ private constructor( /** * The id of the experiment event to log feedback for. This is the row `id` returned by `POST * /v1/experiment/{experiment_id}/insert` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") - /** An optional comment string to log about the experiment event */ + /** + * An optional comment string to log about the experiment event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** @@ -64,47 +72,77 @@ private constructor( * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the * existing scores for the experiment event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * The source of the feedback. Must be one of "external" (default), "app", or "api" + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the experiment event to log feedback for. This is the row `id` returned by `POST - * /v1/experiment/{experiment_id}/insert` + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** An optional comment string to log about the experiment event */ + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -173,18 +211,25 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** - * The id of the experiment event to log feedback for. This is the row `id` returned by - * `POST /v1/experiment/{experiment_id}/insert` + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } /** An optional comment string to log about the experiment event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) - /** An optional comment string to log about the experiment event */ + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ fun comment(comment: Optional) = comment(comment.getOrNull()) - /** An optional comment string to log about the experiment event */ + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun comment(comment: JsonField) = apply { this.comment = comment } /** @@ -200,17 +245,15 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -220,39 +263,53 @@ private constructor( */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event - */ + /** Alias for calling [Builder.scores] with `scores.orElse(null)`. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed [Scores] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun scores(scores: JsonField) = apply { this.scores = scores } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ fun source(source: Optional) = source(source.getOrNull()) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 14572b2f..5bc5746b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -48,10 +48,18 @@ private constructor( /** * The id of the project logs event to log feedback for. This is the row `id` returned by `POST * /v1/project_logs/{project_id}/insert` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") - /** An optional comment string to log about the project logs event */ + /** + * An optional comment string to log about the project logs event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun comment(): Optional = Optional.ofNullable(comment.getNullable("comment")) /** @@ -64,47 +72,77 @@ private constructor( * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main * event itself, but rather the audit log attached to the event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the * existing scores for the project logs event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * The source of the feedback. Must be one of "external" (default), "app", or "api" + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * The id of the project logs event to log feedback for. This is the row `id` returned by `POST - * /v1/project_logs/{project_id}/insert` + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** An optional comment string to log about the project logs event */ + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can log it - * here and access it in the Braintrust UI. Note, this metadata does not correspond to the main - * event itself, but rather the audit log attached to the event. + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -173,18 +211,25 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** - * The id of the project logs event to log feedback for. This is the row `id` returned by - * `POST /v1/project_logs/{project_id}/insert` + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } /** An optional comment string to log about the project logs event */ fun comment(comment: String?) = comment(JsonField.ofNullable(comment)) - /** An optional comment string to log about the project logs event */ + /** Alias for calling [Builder.comment] with `comment.orElse(null)`. */ fun comment(comment: Optional) = comment(comment.getOrNull()) - /** An optional comment string to log about the project logs event */ + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun comment(comment: JsonField) = apply { this.comment = comment } /** @@ -200,17 +245,15 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. Note, this metadata does not correspond - * to the main event itself, but rather the audit log attached to the event. + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -220,39 +263,53 @@ private constructor( */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) - /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event - */ + /** Alias for calling [Builder.scores] with `scores.orElse(null)`. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed [Scores] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun scores(scores: JsonField) = apply { this.scores = scores } /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ fun source(source: Source?) = source(JsonField.ofNullable(source)) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ fun source(source: Optional) = source(source.getOrNull()) - /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun source(source: JsonField) = apply { this.source = source } /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index d4e37e96..c87c941a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -28,8 +28,17 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun status(): Status = status.getRequired("status") + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @@ -76,6 +85,12 @@ private constructor( fun status(status: Status) = status(JsonField.of(status)) + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun status(status: JsonField) = apply { this.status = status } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 93503c6a..4d0220c2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -11,6 +11,7 @@ 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 @@ -32,7 +33,12 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of fetched events */ + /** + * A list of fetched events + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = events.getRequired("events") /** @@ -40,17 +46,23 @@ private constructor( * * Pass this string directly as the `cursor` param to your next fetch request to get the next * page of results. Not provided if the returned result set is empty. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) - /** A list of fetched events */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** - * Pagination cursor + * Returns the raw JSON value of [cursor]. * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @@ -102,12 +114,22 @@ private constructor( /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) - /** A list of fetched events */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } - /** A list of fetched events */ + /** + * Adds a single [DatasetEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: DatasetEvent) = apply { events = (events ?: JsonField.of(mutableListOf())).also { @@ -123,19 +145,14 @@ private constructor( */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * Pagination cursor + * Sets [Builder.cursor] to an arbitrary JSON value. * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun cursor(cursor: JsonField) = apply { this.cursor = cursor } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 23656816..6bbddad4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -11,6 +11,7 @@ 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 @@ -32,7 +33,12 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of fetched events */ + /** + * A list of fetched events + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = events.getRequired("events") /** @@ -40,17 +46,23 @@ private constructor( * * Pass this string directly as the `cursor` param to your next fetch request to get the next * page of results. Not provided if the returned result set is empty. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) - /** A list of fetched events */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** - * Pagination cursor + * Returns the raw JSON value of [cursor]. * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @@ -103,12 +115,22 @@ private constructor( /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) - /** A list of fetched events */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } - /** A list of fetched events */ + /** + * Adds a single [ExperimentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: ExperimentEvent) = apply { events = (events ?: JsonField.of(mutableListOf())).also { @@ -124,19 +146,14 @@ private constructor( */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * Pagination cursor + * Sets [Builder.cursor] to an arbitrary JSON value. * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun cursor(cursor: JsonField) = apply { this.cursor = cursor } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index 1fd8d53c..ac15fc3d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -11,6 +11,7 @@ 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 @@ -32,7 +33,12 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of fetched events */ + /** + * A list of fetched events + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = events.getRequired("events") /** @@ -40,19 +46,25 @@ private constructor( * * Pass this string directly as the `cursor` param to your next fetch request to get the next * page of results. Not provided if the returned result set is empty. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) - /** A list of fetched events */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** - * Pagination cursor + * Returns the raw JSON value of [cursor]. * - * Pass this string directly as the `cursor` param to your next fetch request to get the next - * page of results. Not provided if the returned result set is empty. + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor @@ -106,12 +118,22 @@ private constructor( /** A list of fetched events */ fun events(events: List) = events(JsonField.of(events)) - /** A list of fetched events */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } - /** A list of fetched events */ + /** + * Adds a single [ProjectLogsEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: ProjectLogsEvent) = apply { events = (events ?: JsonField.of(mutableListOf())).also { @@ -127,19 +149,14 @@ private constructor( */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * Pagination cursor + * Sets [Builder.cursor] to an arbitrary JSON value. * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun cursor(cursor: JsonField) = apply { this.cursor = cursor } 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 e4656f96..64717439 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 @@ -77,114 +77,252 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") /** * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the prompt (see the `version` parameter) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun _xactId(): String = _xactId.getRequired("_xact_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun functionData(): FunctionData = functionData.getRequired("function_data") - /** A literal 'p' which identifies the object as a project prompt */ + /** + * A literal 'p' which identifies the object as a project prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun logId(): LogId = logId.getRequired("log_id") - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the organization */ + /** + * Unique identifier for the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun orgId(): String = orgId.getRequired("org_id") - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = slug.getRequired("slug") - /** Date of prompt creation */ + /** + * Date of prompt creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** JSON schema for the function's parameters and return type */ + /** + * JSON schema for the function's parameters and return type + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) - /** User-controlled metadata about the prompt */ + /** + * User-controlled metadata about the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * Returns the raw JSON value of [_xactId]. + * + * Unlike [_xactId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId + /** + * Returns the raw JSON value of [functionData]. + * + * Unlike [functionData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("function_data") @ExcludeMissing fun _functionData(): JsonField = functionData - /** A literal 'p' which identifies the object as a project prompt */ + /** + * Returns the raw JSON value of [logId]. + * + * Unlike [logId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the organization */ + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** Date of prompt creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** JSON schema for the function's parameters and return type */ + /** + * Returns the raw JSON value of [functionSchema]. + * + * Unlike [functionSchema], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("function_schema") @ExcludeMissing fun _functionSchema(): JsonField = functionSchema + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType - /** User-controlled metadata about the prompt */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_data") @ExcludeMissing fun _promptData(): JsonField = promptData - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -284,7 +422,12 @@ private constructor( /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** @@ -295,81 +438,136 @@ private constructor( fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * Sets [Builder._xactId] to an arbitrary JSON value. + * + * You should usually call [Builder._xactId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + /** + * Sets [Builder.functionData] to an arbitrary JSON value. + * + * You should usually call [Builder.functionData] with a well-typed [FunctionData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionData(functionData: JsonField) = apply { this.functionData = functionData } + /** Alias for calling [functionData] with `FunctionData.ofPrompt(prompt)`. */ fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) + /** Alias for calling [functionData] with `FunctionData.ofCode(code)`. */ fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) + /** Alias for calling [functionData] with `FunctionData.ofGlobal(global)`. */ fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) - /** A literal 'p' which identifies the object as a project prompt */ + /** + * Sets [Builder.logId] to an arbitrary JSON value. + * + * You should usually call [Builder.logId] with a well-typed [LogId] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun logId(logId: JsonField) = apply { this.logId = logId } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - /** Unique identifier for the organization */ + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** Date of prompt creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of prompt creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of prompt creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } /** JSON schema for the function's parameters and return type */ fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) - /** JSON schema for the function's parameters and return type */ + /** Alias for calling [Builder.functionSchema] with `functionSchema.orElse(null)`. */ fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) - /** JSON schema for the function's parameters and return type */ + /** + * Sets [Builder.functionSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.functionSchema] with a well-typed [FunctionSchema] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionSchema(functionSchema: JsonField) = apply { this.functionSchema = functionSchema } @@ -377,9 +575,17 @@ private constructor( fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { this.functionType = functionType } @@ -387,39 +593,68 @@ private constructor( /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** User-controlled metadata about the prompt */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the prompt */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [Origin] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } @@ -634,8 +869,18 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -682,6 +927,13 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -839,12 +1091,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun data(): Data = data.getRequired("data") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -895,14 +1167,30 @@ private constructor( fun data(data: Data) = data(JsonField.of(data)) + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun data(data: JsonField) = apply { this.data = data } + /** Alias for calling [data] with `Data.ofBundle(bundle)`. */ fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) + /** Alias for calling [data] with `Data.ofInline(inline)`. */ fun data(inline: Data.Inline) = data(Data.ofInline(inline)) fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1095,36 +1383,90 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun bundleId(): String = bundleId.getRequired("bundle_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun location(): CodeBundle.Location = location.getRequired("location") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") - /** A preview of the code */ + /** + * A preview of the code + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [bundleId]. + * + * Unlike [bundleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - /** A preview of the code */ + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1195,6 +1537,13 @@ private constructor( fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + /** + * Sets [Builder.bundleId] to an arbitrary JSON value. + * + * You should usually call [Builder.bundleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } @@ -1202,19 +1551,41 @@ private constructor( fun location(location: CodeBundle.Location) = location(JsonField.of(location)) + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed + * [CodeBundle.Location] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ fun location(location: JsonField) = apply { this.location = location } + /** + * Alias for calling [location] with + * `CodeBundle.Location.ofExperiment(experiment)`. + */ fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) + /** + * Alias for calling [location] with + * `CodeBundle.Location.ofFunction(function)`. + */ fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed + * [CodeBundle.RuntimeContext] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext @@ -1223,14 +1594,27 @@ private constructor( /** A preview of the code */ fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) - /** A preview of the code */ + /** Alias for calling [Builder.preview] with `preview.orElse(null)`. */ fun preview(preview: Optional) = preview(preview.getOrNull()) - /** A preview of the code */ + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1402,19 +1786,52 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun code(): String = code.getRequired("code") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1470,17 +1887,38 @@ private constructor( fun code(code: String) = code(JsonField.of(code)) + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun code(code: JsonField) = apply { this.code = code } fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed + * [RuntimeContext] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1529,14 +1967,36 @@ private constructor( immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun runtime(): Runtime = runtime.getRequired("runtime") + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun version(): String = version.getRequired("version") + /** + * Returns the raw JSON value of [runtime]. + * + * Unlike [runtime], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @@ -1592,12 +2052,26 @@ private constructor( fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + /** + * Sets [Builder.runtime] to an arbitrary JSON value. + * + * You should usually call [Builder.runtime] with a well-typed [Runtime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } @@ -2011,12 +2485,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -2067,10 +2561,24 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -2624,29 +3132,51 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Id of the object the function is originating from */ + /** + * Id of the object the function is originating from + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * The function exists for internal purposes and should not be displayed in the list of * functions. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) - /** Id of the object the function is originating from */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Returns the raw JSON value of [internal_]. + * + * Unlike [internal_], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @@ -2702,13 +3232,25 @@ private constructor( /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** Id of the object the function is originating from */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -2720,20 +3262,21 @@ private constructor( fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Alias for [Builder.internal_]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) - /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. - */ + /** Alias for calling [Builder.internal_] with `internal_.orElse(null)`. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Sets [Builder.internal_] to an arbitrary JSON value. + * + * You should usually call [Builder.internal_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } 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 63a1c1b0..9e9a4bdf 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 @@ -46,58 +46,148 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun functionData(): FunctionData = body.functionData() - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = body.slug() - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** JSON schema for the function's parameters and return type */ + /** + * JSON schema for the function's parameters and return type + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionSchema(): Optional = body.functionSchema() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionType(): Optional = body.functionType() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = body.origin() - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun promptData(): Optional = body.promptData() - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = body.tags() + /** + * Returns the raw JSON value of [functionData]. + * + * Unlike [functionData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionData(): JsonField = body._functionData() - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ fun _slug(): JsonField = body._slug() - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** JSON schema for the function's parameters and return type */ + /** + * Returns the raw JSON value of [functionSchema]. + * + * Unlike [functionSchema], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionSchema(): JsonField = body._functionSchema() + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionType(): JsonField = body._functionType() + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ fun _origin(): JsonField = body._origin() - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _promptData(): JsonField = body._promptData() - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ fun _tags(): JsonField> = body._tags() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -150,72 +240,165 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun functionData(): FunctionData = functionData.getRequired("function_data") - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = slug.getRequired("slug") - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** JSON schema for the function's parameters and return type */ + /** + * JSON schema for the function's parameters and return type + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** + * Returns the raw JSON value of [functionData]. + * + * Unlike [functionData], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_data") @ExcludeMissing fun _functionData(): JsonField = functionData - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** JSON schema for the function's parameters and return type */ + /** + * Returns the raw JSON value of [functionSchema]. + * + * Unlike [functionSchema], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_schema") @ExcludeMissing fun _functionSchema(): JsonField = functionSchema + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_data") @ExcludeMissing fun _promptData(): JsonField = promptData - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -292,43 +475,77 @@ private constructor( fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + /** + * Sets [Builder.functionData] to an arbitrary JSON value. + * + * You should usually call [Builder.functionData] with a well-typed [FunctionData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionData(functionData: JsonField) = apply { this.functionData = functionData } + /** Alias for calling [functionData] with `FunctionData.ofPrompt(prompt)`. */ fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) + /** Alias for calling [functionData] with `FunctionData.ofCode(code)`. */ fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) + /** Alias for calling [functionData] with `FunctionData.ofGlobal(global)`. */ fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -337,11 +554,17 @@ private constructor( fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) - /** JSON schema for the function's parameters and return type */ + /** Alias for calling [Builder.functionSchema] with `functionSchema.orElse(null)`. */ fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) - /** JSON schema for the function's parameters and return type */ + /** + * Sets [Builder.functionSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.functionSchema] with a well-typed [FunctionSchema] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun functionSchema(functionSchema: JsonField) = apply { this.functionSchema = functionSchema } @@ -349,26 +572,48 @@ private constructor( fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { this.functionType = functionType } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [Origin] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } @@ -376,15 +621,25 @@ private constructor( /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } @@ -478,41 +733,73 @@ private constructor( fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + /** + * Sets [Builder.functionData] to an arbitrary JSON value. + * + * You should usually call [Builder.functionData] with a well-typed [FunctionData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionData(functionData: JsonField) = apply { body.functionData(functionData) } + /** Alias for calling [functionData] with `FunctionData.ofPrompt(prompt)`. */ fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + /** Alias for calling [functionData] with `FunctionData.ofCode(code)`. */ fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + /** Alias for calling [functionData] with `FunctionData.ofGlobal(global)`. */ fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } /** Name of the prompt */ fun name(name: String) = apply { body.name(name) } - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Unique identifier for the prompt */ fun slug(slug: String) = apply { body.slug(slug) } - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun slug(slug: JsonField) = apply { body.slug(slug) } /** Textual description of the prompt */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** JSON schema for the function's parameters and return type */ @@ -520,49 +807,86 @@ private constructor( body.functionSchema(functionSchema) } - /** JSON schema for the function's parameters and return type */ + /** Alias for calling [Builder.functionSchema] with `functionSchema.orElse(null)`. */ fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) - /** JSON schema for the function's parameters and return type */ + /** + * Sets [Builder.functionSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.functionSchema] with a well-typed [FunctionSchema] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionSchema(functionSchema: JsonField) = apply { body.functionSchema(functionSchema) } fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { body.functionType(functionType) } fun origin(origin: Origin?) = apply { body.origin(origin) } + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [Origin] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun origin(origin: JsonField) = apply { body.origin(origin) } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ fun tags(tags: List?) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { body.addTag(tag) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { @@ -859,8 +1183,18 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -907,6 +1241,13 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1064,12 +1405,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun data(): Data = data.getRequired("data") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1120,14 +1481,30 @@ private constructor( fun data(data: Data) = data(JsonField.of(data)) + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun data(data: JsonField) = apply { this.data = data } + /** Alias for calling [data] with `Data.ofBundle(bundle)`. */ fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) + /** Alias for calling [data] with `Data.ofInline(inline)`. */ fun data(inline: Data.Inline) = data(Data.ofInline(inline)) fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1320,36 +1697,90 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun bundleId(): String = bundleId.getRequired("bundle_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun location(): CodeBundle.Location = location.getRequired("location") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") - /** A preview of the code */ + /** + * A preview of the code + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [bundleId]. + * + * Unlike [bundleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - /** A preview of the code */ + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1420,6 +1851,13 @@ private constructor( fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + /** + * Sets [Builder.bundleId] to an arbitrary JSON value. + * + * You should usually call [Builder.bundleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } @@ -1427,19 +1865,41 @@ private constructor( fun location(location: CodeBundle.Location) = location(JsonField.of(location)) + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed + * [CodeBundle.Location] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ fun location(location: JsonField) = apply { this.location = location } + /** + * Alias for calling [location] with + * `CodeBundle.Location.ofExperiment(experiment)`. + */ fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) + /** + * Alias for calling [location] with + * `CodeBundle.Location.ofFunction(function)`. + */ fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed + * [CodeBundle.RuntimeContext] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext @@ -1448,14 +1908,27 @@ private constructor( /** A preview of the code */ fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) - /** A preview of the code */ + /** Alias for calling [Builder.preview] with `preview.orElse(null)`. */ fun preview(preview: Optional) = preview(preview.getOrNull()) - /** A preview of the code */ + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1627,19 +2100,52 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun code(): String = code.getRequired("code") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1695,17 +2201,38 @@ private constructor( fun code(code: String) = code(JsonField.of(code)) + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun code(code: JsonField) = apply { this.code = code } fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed + * [RuntimeContext] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1754,14 +2281,36 @@ private constructor( immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun runtime(): Runtime = runtime.getRequired("runtime") + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun version(): String = version.getRequired("version") + /** + * Returns the raw JSON value of [runtime]. + * + * Unlike [runtime], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @@ -1817,12 +2366,26 @@ private constructor( fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + /** + * Sets [Builder.runtime] to an arbitrary JSON value. + * + * You should usually call [Builder.runtime] with a well-typed [Runtime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } @@ -2236,12 +2799,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -2292,10 +2875,24 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -2674,29 +3271,51 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Id of the object the function is originating from */ + /** + * Id of the object the function is originating from + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * The function exists for internal purposes and should not be displayed in the list of * functions. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) - /** Id of the object the function is originating from */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Returns the raw JSON value of [internal_]. + * + * Unlike [internal_], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @@ -2752,13 +3371,25 @@ private constructor( /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** Id of the object the function is originating from */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -2770,20 +3401,21 @@ private constructor( fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Alias for [Builder.internal_]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) - /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. - */ + /** Alias for calling [Builder.internal_] with `internal_.orElse(null)`. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Sets [Builder.internal_] to an arbitrary JSON value. + * + * You should usually call [Builder.internal_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index 4cdd84ba..b9d63939 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -52,46 +52,95 @@ private constructor( /** Argument to the function, which can be any JSON serializable value */ fun _input(): JsonValue = body._input() - /** If the function is an LLM, additional messages to pass along to it */ + /** + * If the function is an LLM, additional messages to pass along to it + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun messages(): Optional> = body.messages() - /** Any relevant metadata */ + /** + * Any relevant metadata + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = body.metadata() - /** The mode format of the returned value (defaults to 'auto') */ + /** + * The mode format of the returned value (defaults to 'auto') + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun mode(): Optional = body.mode() - /** Options for tracing the function call */ + /** + * Options for tracing the function call + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun parent(): Optional = body.parent() /** * Whether to stream the response. If true, results will be returned in the Braintrust SSE * format. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun stream(): Optional = body.stream() - /** The version of the function */ + /** + * The version of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun version(): Optional = body.version() - /** If the function is an LLM, additional messages to pass along to it */ + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ fun _messages(): JsonField> = body._messages() - /** Any relevant metadata */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ fun _metadata(): JsonField = body._metadata() - /** The mode format of the returned value (defaults to 'auto') */ + /** + * Returns the raw JSON value of [mode]. + * + * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. + */ fun _mode(): JsonField = body._mode() - /** Options for tracing the function call */ + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ fun _parent(): JsonField = body._parent() /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. */ fun _stream(): JsonField = body._stream() - /** The version of the function */ + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ fun _version(): JsonField = body._version() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -148,49 +197,98 @@ private constructor( /** Argument to the function, which can be any JSON serializable value */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input - /** If the function is an LLM, additional messages to pass along to it */ + /** + * If the function is an LLM, additional messages to pass along to it + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun messages(): Optional> = Optional.ofNullable(messages.getNullable("messages")) - /** Any relevant metadata */ + /** + * Any relevant metadata + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** The mode format of the returned value (defaults to 'auto') */ + /** + * The mode format of the returned value (defaults to 'auto') + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun mode(): Optional = Optional.ofNullable(mode.getNullable("mode")) - /** Options for tracing the function call */ + /** + * Options for tracing the function call + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) /** * Whether to stream the response. If true, results will be returned in the Braintrust SSE * format. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun stream(): Optional = Optional.ofNullable(stream.getNullable("stream")) - /** The version of the function */ + /** + * The version of the function + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) - /** If the function is an LLM, additional messages to pass along to it */ + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("messages") @ExcludeMissing fun _messages(): JsonField> = messages - /** Any relevant metadata */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** The mode format of the returned value (defaults to 'auto') */ + /** + * Returns the raw JSON value of [mode]. + * + * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode - /** Options for tracing the function call */ + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Returns the raw JSON value of [stream]. + * + * Unlike [stream], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("stream") @ExcludeMissing fun _stream(): JsonField = stream - /** The version of the function */ + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @@ -256,12 +354,22 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun messages(messages: List) = messages(JsonField.of(messages)) - /** If the function is an LLM, additional messages to pass along to it */ + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun messages(messages: JsonField>) = apply { this.messages = messages.map { it.toMutableList() } } - /** If the function is an LLM, additional messages to pass along to it */ + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMessage(message: Message) = apply { messages = (messages ?: JsonField.of(mutableListOf())).also { @@ -269,54 +377,72 @@ private constructor( } } - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofSystem(system)`. */ fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofUser(user)`. */ fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofAssistant(assistant)`. */ fun addMessage(assistant: Message.Assistant) = addMessage(Message.ofAssistant(assistant)) - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofTool(tool)`. */ fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofFunction(function)`. */ fun addMessage(function: Message.Function) = addMessage(Message.ofFunction(function)) - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofFallback(fallback)`. */ fun addMessage(fallback: Message.Fallback) = addMessage(Message.ofFallback(fallback)) /** Any relevant metadata */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** Any relevant metadata */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** Any relevant metadata */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Mode?) = mode(JsonField.ofNullable(mode)) - /** The mode format of the returned value (defaults to 'auto') */ + /** Alias for calling [Builder.mode] with `mode.orElse(null)`. */ fun mode(mode: Optional) = mode(mode.getOrNull()) - /** The mode format of the returned value (defaults to 'auto') */ + /** + * Sets [Builder.mode] to an arbitrary JSON value. + * + * You should usually call [Builder.mode] with a well-typed [Mode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun mode(mode: JsonField) = apply { this.mode = mode } /** Options for tracing the function call */ fun parent(parent: Parent) = parent(JsonField.of(parent)) - /** Options for tracing the function call */ + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [Parent] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun parent(parent: JsonField) = apply { this.parent = parent } - /** Span parent properties */ + /** Alias for calling [parent] with `Parent.ofSpanParentStruct(spanParentStruct)`. */ fun parent(spanParentStruct: Parent.SpanParentStruct) = parent(Parent.ofSpanParentStruct(spanParentStruct)) - /** The parent's span identifier, created by calling `.export()` on a span */ + /** Alias for calling [parent] with `Parent.ofString(string)`. */ fun parent(string: String) = parent(Parent.ofString(string)) /** @@ -326,27 +452,34 @@ private constructor( fun stream(stream: Boolean?) = stream(JsonField.ofNullable(stream)) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Alias for [Builder.stream]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun stream(stream: Boolean) = stream(stream as Boolean?) - /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. - */ + /** Alias for calling [Builder.stream] with `stream.orElse(null)`. */ fun stream(stream: Optional) = stream(stream.getOrNull()) /** - * Whether to stream the response. If true, results will be returned in the Braintrust - * SSE format. + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun stream(stream: JsonField) = apply { this.stream = stream } /** The version of the function */ fun version(version: String) = version(JsonField.of(version)) - /** The version of the function */ + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun version(version: JsonField) = apply { this.version = version } fun additionalProperties(additionalProperties: Map) = apply { @@ -444,60 +577,86 @@ private constructor( /** If the function is an LLM, additional messages to pass along to it */ fun messages(messages: List) = apply { body.messages(messages) } - /** If the function is an LLM, additional messages to pass along to it */ + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun messages(messages: JsonField>) = apply { body.messages(messages) } - /** If the function is an LLM, additional messages to pass along to it */ + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMessage(message: Message) = apply { body.addMessage(message) } - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofSystem(system)`. */ fun addMessage(system: Message.System) = apply { body.addMessage(system) } - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofUser(user)`. */ fun addMessage(user: Message.User) = apply { body.addMessage(user) } - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofAssistant(assistant)`. */ fun addMessage(assistant: Message.Assistant) = apply { body.addMessage(assistant) } - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofTool(tool)`. */ fun addMessage(tool: Message.Tool) = apply { body.addMessage(tool) } - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofFunction(function)`. */ fun addMessage(function: Message.Function) = apply { body.addMessage(function) } - /** If the function is an LLM, additional messages to pass along to it */ + /** Alias for calling [addMessage] with `Message.ofFallback(fallback)`. */ fun addMessage(fallback: Message.Fallback) = apply { body.addMessage(fallback) } /** Any relevant metadata */ fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - /** Any relevant metadata */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** Any relevant metadata */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** The mode format of the returned value (defaults to 'auto') */ fun mode(mode: Mode?) = apply { body.mode(mode) } - /** The mode format of the returned value (defaults to 'auto') */ + /** Alias for calling [Builder.mode] with `mode.orElse(null)`. */ fun mode(mode: Optional) = mode(mode.getOrNull()) - /** The mode format of the returned value (defaults to 'auto') */ + /** + * Sets [Builder.mode] to an arbitrary JSON value. + * + * You should usually call [Builder.mode] with a well-typed [Mode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun mode(mode: JsonField) = apply { body.mode(mode) } /** Options for tracing the function call */ fun parent(parent: Parent) = apply { body.parent(parent) } - /** Options for tracing the function call */ + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [Parent] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun parent(parent: JsonField) = apply { body.parent(parent) } - /** Span parent properties */ + /** Alias for calling [parent] with `Parent.ofSpanParentStruct(spanParentStruct)`. */ fun parent(spanParentStruct: Parent.SpanParentStruct) = apply { body.parent(spanParentStruct) } - /** The parent's span identifier, created by calling `.export()` on a span */ + /** Alias for calling [parent] with `Parent.ofString(string)`. */ fun parent(string: String) = apply { body.parent(string) } /** @@ -507,27 +666,32 @@ private constructor( fun stream(stream: Boolean?) = apply { body.stream(stream) } /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Alias for [Builder.stream]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun stream(stream: Boolean) = stream(stream as Boolean?) - /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. - */ + /** Alias for calling [Builder.stream] with `stream.orElse(null)`. */ fun stream(stream: Optional) = stream(stream.getOrNull()) /** - * Whether to stream the response. If true, results will be returned in the Braintrust SSE - * format. + * Sets [Builder.stream] to an arbitrary JSON value. + * + * You should usually call [Builder.stream] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun stream(stream: JsonField) = apply { body.stream(stream) } /** The version of the function */ fun version(version: String) = apply { body.version(version) } - /** The version of the function */ + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun version(version: JsonField) = apply { body.version(version) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { @@ -896,16 +1060,44 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -958,14 +1150,35 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -1131,16 +1344,44 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -1193,19 +1434,42 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: Content) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } + /** Alias for calling [content] with `Content.ofText(text)`. */ fun content(text: String) = content(Content.ofText(text)) + /** Alias for calling [content] with `Content.ofArray(array)`. */ fun contentOfArray(array: List) = content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -1673,28 +1937,76 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_call") @ExcludeMissing fun _functionCall(): JsonField = functionCall + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [toolCalls]. + * + * Unlike [toolCalls], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls(): JsonField> = toolCalls @@ -1755,40 +2067,84 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String?) = content(JsonField.ofNullable(content)) + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ fun content(content: Optional) = content(content.getOrNull()) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun functionCall(functionCall: FunctionCall?) = functionCall(JsonField.ofNullable(functionCall)) + /** Alias for calling [Builder.functionCall] with `functionCall.orElse(null)`. */ fun functionCall(functionCall: Optional) = functionCall(functionCall.getOrNull()) + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun functionCall(functionCall: JsonField) = apply { this.functionCall = functionCall } fun name(name: String?) = name(JsonField.ofNullable(name)) + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun toolCalls(toolCalls: List?) = toolCalls(JsonField.ofNullable(toolCalls)) + /** Alias for calling [Builder.toolCalls] with `toolCalls.orElse(null)`. */ fun toolCalls(toolCalls: Optional>) = toolCalls(toolCalls.getOrNull()) + /** + * Sets [Builder.toolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCalls] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ fun toolCalls(toolCalls: JsonField>) = apply { this.toolCalls = toolCalls.map { it.toMutableList() } } + /** + * Adds a single [ChatCompletionMessageToolCall] to [toolCalls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { toolCalls = (toolCalls ?: JsonField.of(mutableListOf())).also { @@ -1940,14 +2296,36 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun arguments(): String = arguments.getRequired("arguments") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * Returns the raw JSON value of [arguments]. + * + * Unlike [arguments], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonField = arguments + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -1998,12 +2376,26 @@ private constructor( fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + /** + * Sets [Builder.arguments] to an arbitrary JSON value. + * + * You should usually call [Builder.arguments] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun arguments(arguments: JsonField) = apply { this.arguments = arguments } fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -2089,17 +2481,46 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [toolCallId]. + * + * Unlike [toolCallId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId(): JsonField = toolCallId @@ -2154,14 +2575,35 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + /** + * Sets [Builder.toolCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun toolCallId(toolCallId: JsonField) = apply { this.toolCallId = toolCallId } @@ -2329,16 +2771,45 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @JsonAnyGetter @@ -2392,14 +2863,35 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { @@ -2562,12 +3054,31 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @JsonAnyGetter @@ -2617,12 +3128,27 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String?) = content(JsonField.ofNullable(content)) + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ fun content(content: Optional) = content(content.getOrNull()) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = apply { @@ -3114,31 +3640,72 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the container object you are logging to */ + /** + * The id of the container object you are logging to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun objectId(): String = objectId.getRequired("object_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun objectType(): ObjectType = objectType.getRequired("object_type") - /** Include these properties in every span created under this parent */ + /** + * Include these properties in every span created under this parent + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun propagatedEvent(): Optional = Optional.ofNullable(propagatedEvent.getNullable("propagated_event")) - /** Identifiers for the row to to log a subspan under */ + /** + * Identifiers for the row to to log a subspan under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun rowIds(): Optional = Optional.ofNullable(rowIds.getNullable("row_ids")) - /** The id of the container object you are logging to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Include these properties in every span created under this parent */ + /** + * Returns the raw JSON value of [propagatedEvent]. + * + * Unlike [propagatedEvent], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("propagated_event") @ExcludeMissing fun _propagatedEvent(): JsonField = propagatedEvent - /** Identifiers for the row to to log a subspan under */ + /** + * Returns the raw JSON value of [rowIds]. + * + * Unlike [rowIds], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField = rowIds @JsonAnyGetter @@ -3196,11 +3763,24 @@ private constructor( /** The id of the container object you are logging to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the container object you are logging to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [ObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -3209,11 +3789,19 @@ private constructor( fun propagatedEvent(propagatedEvent: PropagatedEvent?) = propagatedEvent(JsonField.ofNullable(propagatedEvent)) - /** Include these properties in every span created under this parent */ + /** + * Alias for calling [Builder.propagatedEvent] with `propagatedEvent.orElse(null)`. + */ fun propagatedEvent(propagatedEvent: Optional) = propagatedEvent(propagatedEvent.getOrNull()) - /** Include these properties in every span created under this parent */ + /** + * Sets [Builder.propagatedEvent] to an arbitrary JSON value. + * + * You should usually call [Builder.propagatedEvent] with a well-typed + * [PropagatedEvent] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ fun propagatedEvent(propagatedEvent: JsonField) = apply { this.propagatedEvent = propagatedEvent } @@ -3221,10 +3809,16 @@ private constructor( /** Identifiers for the row to to log a subspan under */ fun rowIds(rowIds: RowIds?) = rowIds(JsonField.ofNullable(rowIds)) - /** Identifiers for the row to to log a subspan under */ + /** Alias for calling [Builder.rowIds] with `rowIds.orElse(null)`. */ fun rowIds(rowIds: Optional) = rowIds(rowIds.getOrNull()) - /** Identifiers for the row to to log a subspan under */ + /** + * Sets [Builder.rowIds] to an arbitrary JSON value. + * + * You should usually call [Builder.rowIds] with a well-typed [RowIds] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun rowIds(rowIds: JsonField) = apply { this.rowIds = rowIds } fun additionalProperties(additionalProperties: Map) = apply { @@ -3475,24 +4069,56 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the row */ + /** + * The id of the row + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun id(): String = id.getRequired("id") - /** The root_span_id of the row */ + /** + * The root_span_id of the row + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - /** The span_id of the row */ + /** + * The span_id of the row + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ fun spanId(): String = spanId.getRequired("span_id") - /** The id of the row */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The root_span_id of the row */ + /** + * Returns the raw JSON value of [rootSpanId]. + * + * Unlike [rootSpanId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId - /** The span_id of the row */ + /** + * Returns the raw JSON value of [spanId]. + * + * Unlike [spanId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId @JsonAnyGetter @@ -3548,13 +4174,25 @@ private constructor( /** The id of the row */ fun id(id: String) = id(JsonField.of(id)) - /** The id of the row */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** The root_span_id of the row */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** The root_span_id of the row */ + /** + * Sets [Builder.rootSpanId] to an arbitrary JSON value. + * + * You should usually call [Builder.rootSpanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } @@ -3562,7 +4200,13 @@ private constructor( /** The span_id of the row */ fun spanId(spanId: String) = spanId(JsonField.of(spanId)) - /** The span_id of the row */ + /** + * Sets [Builder.spanId] to an arbitrary JSON value. + * + * You should usually call [Builder.spanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun spanId(spanId: JsonField) = apply { this.spanId = spanId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index aaf2b9ca..454c33dd 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -166,19 +166,13 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the function to search for */ fun functionName(functionName: String?) = apply { this.functionName = functionName } - /** Name of the function to search for */ + /** Alias for calling [Builder.functionName] with `functionName.orElse(null)`. */ fun functionName(functionName: Optional) = functionName(functionName.getOrNull()) /** @@ -187,55 +181,50 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } - /** Project id */ + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } - /** Name of the project to search for */ + /** Alias for calling [Builder.projectName] with `projectName.orElse(null)`. */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Retrieve prompt with a specific slug */ fun slug(slug: String?) = apply { this.slug = slug } - /** Retrieve prompt with a specific slug */ + /** Alias for calling [Builder.slug] with `slug.orElse(null)`. */ fun slug(slug: Optional) = slug(slug.getOrNull()) /** @@ -247,13 +236,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) @@ -265,12 +248,7 @@ private constructor( */ fun version(version: String?) = apply { this.version = version } - /** - * Retrieve prompt at a specific version. - * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { 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 88dd5734..0903fccd 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 @@ -46,58 +46,148 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun functionData(): FunctionData = body.functionData() - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = body.slug() - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** JSON schema for the function's parameters and return type */ + /** + * JSON schema for the function's parameters and return type + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionSchema(): Optional = body.functionSchema() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionType(): Optional = body.functionType() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = body.origin() - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun promptData(): Optional = body.promptData() - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = body.tags() + /** + * Returns the raw JSON value of [functionData]. + * + * Unlike [functionData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionData(): JsonField = body._functionData() - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ fun _slug(): JsonField = body._slug() - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** JSON schema for the function's parameters and return type */ + /** + * Returns the raw JSON value of [functionSchema]. + * + * Unlike [functionSchema], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionSchema(): JsonField = body._functionSchema() + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionType(): JsonField = body._functionType() + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ fun _origin(): JsonField = body._origin() - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _promptData(): JsonField = body._promptData() - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ fun _tags(): JsonField> = body._tags() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -150,72 +240,165 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun functionData(): FunctionData = functionData.getRequired("function_data") - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = slug.getRequired("slug") - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** JSON schema for the function's parameters and return type */ + /** + * JSON schema for the function's parameters and return type + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun functionSchema(): Optional = Optional.ofNullable(functionSchema.getNullable("function_schema")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) + /** + * Returns the raw JSON value of [functionData]. + * + * Unlike [functionData], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_data") @ExcludeMissing fun _functionData(): JsonField = functionData - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** JSON schema for the function's parameters and return type */ + /** + * Returns the raw JSON value of [functionSchema]. + * + * Unlike [functionSchema], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_schema") @ExcludeMissing fun _functionSchema(): JsonField = functionSchema + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_data") @ExcludeMissing fun _promptData(): JsonField = promptData - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -292,43 +475,77 @@ private constructor( fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) + /** + * Sets [Builder.functionData] to an arbitrary JSON value. + * + * You should usually call [Builder.functionData] with a well-typed [FunctionData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionData(functionData: JsonField) = apply { this.functionData = functionData } + /** Alias for calling [functionData] with `FunctionData.ofPrompt(prompt)`. */ fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) + /** Alias for calling [functionData] with `FunctionData.ofCode(code)`. */ fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) + /** Alias for calling [functionData] with `FunctionData.ofGlobal(global)`. */ fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -337,11 +554,17 @@ private constructor( fun functionSchema(functionSchema: FunctionSchema?) = functionSchema(JsonField.ofNullable(functionSchema)) - /** JSON schema for the function's parameters and return type */ + /** Alias for calling [Builder.functionSchema] with `functionSchema.orElse(null)`. */ fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) - /** JSON schema for the function's parameters and return type */ + /** + * Sets [Builder.functionSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.functionSchema] with a well-typed [FunctionSchema] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun functionSchema(functionSchema: JsonField) = apply { this.functionSchema = functionSchema } @@ -349,26 +572,48 @@ private constructor( fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { this.functionType = functionType } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [Origin] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } @@ -376,15 +621,25 @@ private constructor( /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } @@ -478,41 +733,73 @@ private constructor( fun functionData(functionData: FunctionData) = apply { body.functionData(functionData) } + /** + * Sets [Builder.functionData] to an arbitrary JSON value. + * + * You should usually call [Builder.functionData] with a well-typed [FunctionData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionData(functionData: JsonField) = apply { body.functionData(functionData) } + /** Alias for calling [functionData] with `FunctionData.ofPrompt(prompt)`. */ fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + /** Alias for calling [functionData] with `FunctionData.ofCode(code)`. */ fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + /** Alias for calling [functionData] with `FunctionData.ofGlobal(global)`. */ fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } /** Name of the prompt */ fun name(name: String) = apply { body.name(name) } - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Unique identifier for the prompt */ fun slug(slug: String) = apply { body.slug(slug) } - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun slug(slug: JsonField) = apply { body.slug(slug) } /** Textual description of the prompt */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** JSON schema for the function's parameters and return type */ @@ -520,49 +807,86 @@ private constructor( body.functionSchema(functionSchema) } - /** JSON schema for the function's parameters and return type */ + /** Alias for calling [Builder.functionSchema] with `functionSchema.orElse(null)`. */ fun functionSchema(functionSchema: Optional) = functionSchema(functionSchema.getOrNull()) - /** JSON schema for the function's parameters and return type */ + /** + * Sets [Builder.functionSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.functionSchema] with a well-typed [FunctionSchema] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionSchema(functionSchema: JsonField) = apply { body.functionSchema(functionSchema) } fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { body.functionType(functionType) } fun origin(origin: Origin?) = apply { body.origin(origin) } + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [Origin] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun origin(origin: JsonField) = apply { body.origin(origin) } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ fun tags(tags: List?) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { body.addTag(tag) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { @@ -859,8 +1183,18 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -907,6 +1241,13 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1064,12 +1405,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun data(): Data = data.getRequired("data") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1120,14 +1481,30 @@ private constructor( fun data(data: Data) = data(JsonField.of(data)) + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun data(data: JsonField) = apply { this.data = data } + /** Alias for calling [data] with `Data.ofBundle(bundle)`. */ fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) + /** Alias for calling [data] with `Data.ofInline(inline)`. */ fun data(inline: Data.Inline) = data(Data.ofInline(inline)) fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1320,36 +1697,90 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun bundleId(): String = bundleId.getRequired("bundle_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun location(): CodeBundle.Location = location.getRequired("location") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") - /** A preview of the code */ + /** + * A preview of the code + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [bundleId]. + * + * Unlike [bundleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - /** A preview of the code */ + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1420,6 +1851,13 @@ private constructor( fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + /** + * Sets [Builder.bundleId] to an arbitrary JSON value. + * + * You should usually call [Builder.bundleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } @@ -1427,19 +1865,41 @@ private constructor( fun location(location: CodeBundle.Location) = location(JsonField.of(location)) + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed + * [CodeBundle.Location] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ fun location(location: JsonField) = apply { this.location = location } + /** + * Alias for calling [location] with + * `CodeBundle.Location.ofExperiment(experiment)`. + */ fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) + /** + * Alias for calling [location] with + * `CodeBundle.Location.ofFunction(function)`. + */ fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed + * [CodeBundle.RuntimeContext] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext @@ -1448,14 +1908,27 @@ private constructor( /** A preview of the code */ fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) - /** A preview of the code */ + /** Alias for calling [Builder.preview] with `preview.orElse(null)`. */ fun preview(preview: Optional) = preview(preview.getOrNull()) - /** A preview of the code */ + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1627,19 +2100,52 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun code(): String = code.getRequired("code") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1695,17 +2201,38 @@ private constructor( fun code(code: String) = code(JsonField.of(code)) + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun code(code: JsonField) = apply { this.code = code } fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed + * [RuntimeContext] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1754,14 +2281,36 @@ private constructor( immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun runtime(): Runtime = runtime.getRequired("runtime") + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun version(): String = version.getRequired("version") + /** + * Returns the raw JSON value of [runtime]. + * + * Unlike [runtime], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @@ -1817,12 +2366,26 @@ private constructor( fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + /** + * Sets [Builder.runtime] to an arbitrary JSON value. + * + * You should usually call [Builder.runtime] with a well-typed [Runtime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } @@ -2236,12 +2799,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -2292,10 +2875,24 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -2674,29 +3271,51 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Id of the object the function is originating from */ + /** + * Id of the object the function is originating from + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") /** * The function exists for internal purposes and should not be displayed in the list of * functions. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun internal_(): Optional = Optional.ofNullable(internal_.getNullable("internal")) - /** Id of the object the function is originating from */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Returns the raw JSON value of [internal_]. + * + * Unlike [internal_], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("internal") @ExcludeMissing fun _internal_(): JsonField = internal_ @@ -2752,13 +3371,25 @@ private constructor( /** Id of the object the function is originating from */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** Id of the object the function is originating from */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -2770,20 +3401,21 @@ private constructor( fun internal_(internal_: Boolean?) = internal_(JsonField.ofNullable(internal_)) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Alias for [Builder.internal_]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun internal_(internal_: Boolean) = internal_(internal_ as Boolean?) - /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. - */ + /** Alias for calling [Builder.internal_] with `internal_.orElse(null)`. */ fun internal_(internal_: Optional) = internal_(internal_.getOrNull()) /** - * The function exists for internal purposes and should not be displayed in the list of - * functions. + * Sets [Builder.internal_] to an arbitrary JSON value. + * + * You should usually call [Builder.internal_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 2030ee1a..11a615a1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -51,32 +51,77 @@ private constructor( /** Function id */ fun functionId(): String = functionId - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionData(): Optional = body.functionData() - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun promptData(): Optional = body.promptData() - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = body.tags() - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() + /** + * Returns the raw JSON value of [functionData]. + * + * Unlike [functionData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionData(): JsonField = body._functionData() - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _promptData(): JsonField = body._promptData() - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ fun _tags(): JsonField> = body._tags() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -121,41 +166,87 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun functionData(): Optional = Optional.ofNullable(functionData.getNullable("function_data")) - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [functionData]. + * + * Unlike [functionData], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_data") @ExcludeMissing fun _functionData(): JsonField = functionData - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_data") @ExcludeMissing fun _promptData(): JsonField = promptData - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -208,10 +299,16 @@ private constructor( /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -219,37 +316,60 @@ private constructor( fun functionData(functionData: FunctionData?) = functionData(JsonField.ofNullable(functionData)) + /** Alias for calling [Builder.functionData] with `functionData.orElse(null)`. */ fun functionData(functionData: Optional) = functionData(functionData.getOrNull()) + /** + * Sets [Builder.functionData] to an arbitrary JSON value. + * + * You should usually call [Builder.functionData] with a well-typed [FunctionData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionData(functionData: JsonField) = apply { this.functionData = functionData } + /** Alias for calling [functionData] with `FunctionData.ofPrompt(prompt)`. */ fun functionData(prompt: FunctionData.Prompt) = functionData(FunctionData.ofPrompt(prompt)) + /** Alias for calling [functionData] with `FunctionData.ofCode(code)`. */ fun functionData(code: FunctionData.Code) = functionData(FunctionData.ofCode(code)) + /** Alias for calling [functionData] with `FunctionData.ofGlobal(global)`. */ fun functionData(global: FunctionData.Global) = functionData(FunctionData.ofGlobal(global)) /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the prompt */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } @@ -257,15 +377,25 @@ private constructor( /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } @@ -357,55 +487,93 @@ private constructor( /** Textual description of the prompt */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } fun functionData(functionData: FunctionData?) = apply { body.functionData(functionData) } + /** Alias for calling [Builder.functionData] with `functionData.orElse(null)`. */ fun functionData(functionData: Optional) = functionData(functionData.getOrNull()) + /** + * Sets [Builder.functionData] to an arbitrary JSON value. + * + * You should usually call [Builder.functionData] with a well-typed [FunctionData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionData(functionData: JsonField) = apply { body.functionData(functionData) } + /** Alias for calling [functionData] with `FunctionData.ofPrompt(prompt)`. */ fun functionData(prompt: FunctionData.Prompt) = apply { body.functionData(prompt) } + /** Alias for calling [functionData] with `FunctionData.ofCode(code)`. */ fun functionData(code: FunctionData.Code) = apply { body.functionData(code) } + /** Alias for calling [functionData] with `FunctionData.ofGlobal(global)`. */ fun functionData(global: FunctionData.Global) = apply { body.functionData(global) } /** Name of the prompt */ fun name(name: String?) = apply { body.name(name) } - /** Name of the prompt */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ fun tags(tags: List?) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { body.addTag(tag) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { @@ -703,8 +871,18 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -751,6 +929,13 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -908,12 +1093,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun data(): Data = data.getRequired("data") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -964,14 +1169,30 @@ private constructor( fun data(data: Data) = data(JsonField.of(data)) + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun data(data: JsonField) = apply { this.data = data } + /** Alias for calling [data] with `Data.ofBundle(bundle)`. */ fun data(bundle: Data.Bundle) = data(Data.ofBundle(bundle)) + /** Alias for calling [data] with `Data.ofInline(inline)`. */ fun data(inline: Data.Inline) = data(Data.ofInline(inline)) fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1164,36 +1385,90 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun bundleId(): String = bundleId.getRequired("bundle_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun location(): CodeBundle.Location = location.getRequired("location") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun runtimeContext(): CodeBundle.RuntimeContext = runtimeContext.getRequired("runtime_context") - /** A preview of the code */ + /** + * A preview of the code + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun preview(): Optional = Optional.ofNullable(preview.getNullable("preview")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [bundleId]. + * + * Unlike [bundleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId(): JsonField = bundleId + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext - /** A preview of the code */ + /** + * Returns the raw JSON value of [preview]. + * + * Unlike [preview], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("preview") @ExcludeMissing fun _preview(): JsonField = preview + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1264,6 +1539,13 @@ private constructor( fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) + /** + * Sets [Builder.bundleId] to an arbitrary JSON value. + * + * You should usually call [Builder.bundleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } @@ -1271,19 +1553,41 @@ private constructor( fun location(location: CodeBundle.Location) = location(JsonField.of(location)) + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed + * [CodeBundle.Location] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ fun location(location: JsonField) = apply { this.location = location } + /** + * Alias for calling [location] with + * `CodeBundle.Location.ofExperiment(experiment)`. + */ fun location(experiment: CodeBundle.Location.Experiment) = location(CodeBundle.Location.ofExperiment(experiment)) + /** + * Alias for calling [location] with + * `CodeBundle.Location.ofFunction(function)`. + */ fun location(function: CodeBundle.Location.Function) = location(CodeBundle.Location.ofFunction(function)) fun runtimeContext(runtimeContext: CodeBundle.RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed + * [CodeBundle.RuntimeContext] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext @@ -1292,14 +1596,27 @@ private constructor( /** A preview of the code */ fun preview(preview: String?) = preview(JsonField.ofNullable(preview)) - /** A preview of the code */ + /** Alias for calling [Builder.preview] with `preview.orElse(null)`. */ fun preview(preview: Optional) = preview(preview.getOrNull()) - /** A preview of the code */ + /** + * Sets [Builder.preview] to an arbitrary JSON value. + * + * You should usually call [Builder.preview] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun preview(preview: JsonField) = apply { this.preview = preview } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1471,19 +1788,52 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun code(): String = code.getRequired("code") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + /** + * Returns the raw JSON value of [runtimeContext]. + * + * Unlike [runtimeContext], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext(): JsonField = runtimeContext + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1539,17 +1889,38 @@ private constructor( fun code(code: String) = code(JsonField.of(code)) + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun code(code: JsonField) = apply { this.code = code } fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) + /** + * Sets [Builder.runtimeContext] to an arbitrary JSON value. + * + * You should usually call [Builder.runtimeContext] with a well-typed + * [RuntimeContext] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun runtimeContext(runtimeContext: JsonField) = apply { this.runtimeContext = runtimeContext } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1598,14 +1969,36 @@ private constructor( immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun runtime(): Runtime = runtime.getRequired("runtime") + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun version(): String = version.getRequired("version") + /** + * Returns the raw JSON value of [runtime]. + * + * Unlike [runtime], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("runtime") @ExcludeMissing fun _runtime(): JsonField = runtime + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @@ -1661,12 +2054,26 @@ private constructor( fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) + /** + * Sets [Builder.runtime] to an arbitrary JSON value. + * + * You should usually call [Builder.runtime] with a well-typed [Runtime] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun runtime(runtime: JsonField) = apply { this.runtime = runtime } fun version(version: String) = version(JsonField.of(version)) + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun version(version: JsonField) = apply { this.version = version } @@ -2080,12 +2487,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -2136,10 +2563,24 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 2dc72265..02e1c660 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -11,6 +11,7 @@ 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 @@ -53,27 +54,55 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the group */ + /** + * Unique identifier for the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the group */ + /** + * Name of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") /** * Unique id for the organization that the group belongs under * * It is forbidden to change the org after creating a group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun orgId(): String = orgId.getRequired("org_id") - /** Date of group creation */ + /** + * Date of group creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Date of group deletion, or null if the group is still active */ + /** + * Date of group deletion, or null if the group is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Textual description of the group */ + /** + * Textual description of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -82,57 +111,97 @@ private constructor( * * An inheriting group has all the users contained in its member groups, as well as all of their * inherited users + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) - /** Ids of users which belong to this group */ + /** + * Ids of users which belong to this group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) - /** Identifies the user who created the group */ + /** + * Identifies the user who created the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the group */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the group */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Unique id for the organization that the group belongs under + * Returns the raw JSON value of [orgId]. * - * It is forbidden to change the org after creating a group + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Date of group creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Date of group deletion, or null if the group is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - /** Textual description of the group */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** - * Ids of the groups this group inherits from + * Returns the raw JSON value of [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * Unlike [memberGroups], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("member_groups") @ExcludeMissing fun _memberGroups(): JsonField> = memberGroups - /** Ids of users which belong to this group */ + /** + * Returns the raw JSON value of [memberUsers]. + * + * Unlike [memberUsers], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("member_users") @ExcludeMissing fun _memberUsers(): JsonField> = memberUsers - /** Identifies the user who created the group */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @@ -206,13 +275,23 @@ private constructor( /** Unique identifier for the group */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the group */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the group */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** @@ -223,37 +302,56 @@ private constructor( fun orgId(orgId: String) = orgId(JsonField.of(orgId)) /** - * Unique id for the organization that the group belongs under + * Sets [Builder.orgId] to an arbitrary JSON value. * - * It is forbidden to change the org after creating a group + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Date of group creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of group creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of group creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Date of group deletion, or null if the group is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of group deletion, or null if the group is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of group deletion, or null if the group is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the group */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the group */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } /** @@ -265,30 +363,25 @@ private constructor( fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) - /** - * Ids of the groups this group inherits from - * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users - */ + /** Alias for calling [Builder.memberGroups] with `memberGroups.orElse(null)`. */ fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** - * Ids of the groups this group inherits from + * Sets [Builder.memberGroups] to an arbitrary JSON value. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * You should usually call [Builder.memberGroups] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberGroups(memberGroups: JsonField>) = apply { this.memberGroups = memberGroups.map { it.toMutableList() } } /** - * Ids of the groups this group inherits from + * Adds a single [String] to [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberGroup(memberGroup: String) = apply { memberGroups = @@ -300,15 +393,25 @@ private constructor( /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) - /** Ids of users which belong to this group */ + /** Alias for calling [Builder.memberUsers] with `memberUsers.orElse(null)`. */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) - /** Ids of users which belong to this group */ + /** + * Sets [Builder.memberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.memberUsers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun memberUsers(memberUsers: JsonField>) = apply { this.memberUsers = memberUsers.map { it.toMutableList() } } - /** Ids of users which belong to this group */ + /** + * Adds a single [String] to [memberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberUser(memberUser: String) = apply { memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { @@ -319,10 +422,15 @@ private constructor( /** Identifies the user who created the group */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the group */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the group */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 492a36c7..3494b349 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -14,6 +14,7 @@ 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 @@ -33,10 +34,20 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the group */ + /** + * Name of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Textual description of the group */ + /** + * Textual description of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() /** @@ -44,40 +55,62 @@ private constructor( * * An inheriting group has all the users contained in its member groups, as well as all of their * inherited users + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun memberGroups(): Optional> = body.memberGroups() - /** Ids of users which belong to this group */ + /** + * Ids of users which belong to this group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun memberUsers(): Optional> = body.memberUsers() /** * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * group belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() - /** Name of the group */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Textual description of the group */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() /** - * Ids of the groups this group inherits from + * Returns the raw JSON value of [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * Unlike [memberGroups], this method doesn't throw if the JSON field has an unexpected type. */ fun _memberGroups(): JsonField> = body._memberGroups() - /** Ids of users which belong to this group */ + /** + * Returns the raw JSON value of [memberUsers]. + * + * Unlike [memberUsers], this method doesn't throw if the JSON field has an unexpected type. + */ fun _memberUsers(): JsonField> = body._memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() @@ -116,10 +149,20 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the group */ + /** + * Name of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Textual description of the group */ + /** + * Textual description of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -128,11 +171,19 @@ private constructor( * * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) - /** Ids of users which belong to this group */ + /** + * Ids of users which belong to this group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) @@ -140,36 +191,51 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) - /** Name of the group */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Textual description of the group */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** - * Ids of the groups this group inherits from + * Returns the raw JSON value of [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * Unlike [memberGroups], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("member_groups") @ExcludeMissing fun _memberGroups(): JsonField> = memberGroups - /** Ids of users which belong to this group */ + /** + * Returns the raw JSON value of [memberUsers]. + * + * Unlike [memberUsers], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("member_users") @ExcludeMissing fun _memberUsers(): JsonField> = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @@ -230,16 +296,28 @@ private constructor( /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the group */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the group */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the group */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -253,30 +331,25 @@ private constructor( fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) - /** - * Ids of the groups this group inherits from - * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users - */ + /** Alias for calling [Builder.memberGroups] with `memberGroups.orElse(null)`. */ fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** - * Ids of the groups this group inherits from + * Sets [Builder.memberGroups] to an arbitrary JSON value. * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * You should usually call [Builder.memberGroups] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberGroups(memberGroups: JsonField>) = apply { this.memberGroups = memberGroups.map { it.toMutableList() } } /** - * Ids of the groups this group inherits from + * Adds a single [String] to [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberGroup(memberGroup: String) = apply { memberGroups = @@ -289,16 +362,26 @@ private constructor( fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) - /** Ids of users which belong to this group */ + /** Alias for calling [Builder.memberUsers] with `memberUsers.orElse(null)`. */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) - /** Ids of users which belong to this group */ + /** + * Sets [Builder.memberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.memberUsers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun memberUsers(memberUsers: JsonField>) = apply { this.memberUsers = memberUsers.map { it.toMutableList() } } - /** Ids of users which belong to this group */ + /** + * Adds a single [String] to [memberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberUser(memberUser: String) = apply { memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { @@ -313,17 +396,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -408,25 +489,28 @@ private constructor( /** Name of the group */ fun name(name: String) = apply { body.name(name) } - /** Name of the group */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the group */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the group */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the group */ - fun description(description: JsonField) = apply { body.description(description) } - /** - * Ids of the groups this group inherits from + * Sets [Builder.description] to an arbitrary JSON value. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + fun description(description: JsonField) = apply { body.description(description) } /** * Ids of the groups this group inherits from @@ -434,39 +518,52 @@ private constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ + fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + + /** Alias for calling [Builder.memberGroups] with `memberGroups.orElse(null)`. */ fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** - * Ids of the groups this group inherits from + * Sets [Builder.memberGroups] to an arbitrary JSON value. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * You should usually call [Builder.memberGroups] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberGroups(memberGroups: JsonField>) = apply { body.memberGroups(memberGroups) } /** - * Ids of the groups this group inherits from + * Adds a single [String] to [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } - /** Ids of users which belong to this group */ + /** Alias for calling [Builder.memberUsers] with `memberUsers.orElse(null)`. */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) - /** Ids of users which belong to this group */ + /** + * Sets [Builder.memberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.memberUsers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun memberUsers(memberUsers: JsonField>) = apply { body.memberUsers(memberUsers) } - /** Ids of users which belong to this group */ + /** + * Adds a single [String] to [memberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } /** @@ -476,17 +573,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index d63abcd7..810d7b33 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -133,19 +133,13 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** Name of the group to search for */ fun groupName(groupName: String?) = apply { this.groupName = groupName } - /** Name of the group to search for */ + /** Alias for calling [Builder.groupName] with `groupName.orElse(null)`. */ fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) /** @@ -154,37 +148,32 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** @@ -196,13 +185,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index add7d123..9a52d7dc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -14,6 +14,7 @@ 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 @@ -33,10 +34,20 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the group */ + /** + * Name of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Textual description of the group */ + /** + * Textual description of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() /** @@ -44,40 +55,62 @@ private constructor( * * An inheriting group has all the users contained in its member groups, as well as all of their * inherited users + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun memberGroups(): Optional> = body.memberGroups() - /** Ids of users which belong to this group */ + /** + * Ids of users which belong to this group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun memberUsers(): Optional> = body.memberUsers() /** * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * group belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() - /** Name of the group */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Textual description of the group */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() /** - * Ids of the groups this group inherits from + * Returns the raw JSON value of [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users + * Unlike [memberGroups], this method doesn't throw if the JSON field has an unexpected type. */ fun _memberGroups(): JsonField> = body._memberGroups() - /** Ids of users which belong to this group */ + /** + * Returns the raw JSON value of [memberUsers]. + * + * Unlike [memberUsers], this method doesn't throw if the JSON field has an unexpected type. + */ fun _memberUsers(): JsonField> = body._memberUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * group belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() @@ -116,10 +149,20 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the group */ + /** + * Name of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Textual description of the group */ + /** + * Textual description of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -128,11 +171,19 @@ private constructor( * * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun memberGroups(): Optional> = Optional.ofNullable(memberGroups.getNullable("member_groups")) - /** Ids of users which belong to this group */ + /** + * Ids of users which belong to this group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun memberUsers(): Optional> = Optional.ofNullable(memberUsers.getNullable("member_users")) @@ -140,36 +191,51 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the group belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) - /** Name of the group */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Textual description of the group */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** - * Ids of the groups this group inherits from + * Returns the raw JSON value of [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * Unlike [memberGroups], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("member_groups") @ExcludeMissing fun _memberGroups(): JsonField> = memberGroups - /** Ids of users which belong to this group */ + /** + * Returns the raw JSON value of [memberUsers]. + * + * Unlike [memberUsers], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("member_users") @ExcludeMissing fun _memberUsers(): JsonField> = memberUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @@ -230,16 +296,28 @@ private constructor( /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the group */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the group */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the group */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -253,30 +331,25 @@ private constructor( fun memberGroups(memberGroups: List?) = memberGroups(JsonField.ofNullable(memberGroups)) - /** - * Ids of the groups this group inherits from - * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users - */ + /** Alias for calling [Builder.memberGroups] with `memberGroups.orElse(null)`. */ fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** - * Ids of the groups this group inherits from + * Sets [Builder.memberGroups] to an arbitrary JSON value. * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * You should usually call [Builder.memberGroups] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberGroups(memberGroups: JsonField>) = apply { this.memberGroups = memberGroups.map { it.toMutableList() } } /** - * Ids of the groups this group inherits from + * Adds a single [String] to [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all - * of their inherited users + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberGroup(memberGroup: String) = apply { memberGroups = @@ -289,16 +362,26 @@ private constructor( fun memberUsers(memberUsers: List?) = memberUsers(JsonField.ofNullable(memberUsers)) - /** Ids of users which belong to this group */ + /** Alias for calling [Builder.memberUsers] with `memberUsers.orElse(null)`. */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) - /** Ids of users which belong to this group */ + /** + * Sets [Builder.memberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.memberUsers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun memberUsers(memberUsers: JsonField>) = apply { this.memberUsers = memberUsers.map { it.toMutableList() } } - /** Ids of users which belong to this group */ + /** + * Adds a single [String] to [memberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberUser(memberUser: String) = apply { memberUsers = (memberUsers ?: JsonField.of(mutableListOf())).also { @@ -313,17 +396,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -408,25 +489,28 @@ private constructor( /** Name of the group */ fun name(name: String) = apply { body.name(name) } - /** Name of the group */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the group */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the group */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the group */ - fun description(description: JsonField) = apply { body.description(description) } - /** - * Ids of the groups this group inherits from + * Sets [Builder.description] to an arbitrary JSON value. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + fun description(description: JsonField) = apply { body.description(description) } /** * Ids of the groups this group inherits from @@ -434,39 +518,52 @@ private constructor( * An inheriting group has all the users contained in its member groups, as well as all of * their inherited users */ + fun memberGroups(memberGroups: List?) = apply { body.memberGroups(memberGroups) } + + /** Alias for calling [Builder.memberGroups] with `memberGroups.orElse(null)`. */ fun memberGroups(memberGroups: Optional>) = memberGroups(memberGroups.getOrNull()) /** - * Ids of the groups this group inherits from + * Sets [Builder.memberGroups] to an arbitrary JSON value. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * You should usually call [Builder.memberGroups] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberGroups(memberGroups: JsonField>) = apply { body.memberGroups(memberGroups) } /** - * Ids of the groups this group inherits from + * Adds a single [String] to [memberGroups]. * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberGroup(memberGroup: String) = apply { body.addMemberGroup(memberGroup) } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List?) = apply { body.memberUsers(memberUsers) } - /** Ids of users which belong to this group */ + /** Alias for calling [Builder.memberUsers] with `memberUsers.orElse(null)`. */ fun memberUsers(memberUsers: Optional>) = memberUsers(memberUsers.getOrNull()) - /** Ids of users which belong to this group */ + /** + * Sets [Builder.memberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.memberUsers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun memberUsers(memberUsers: JsonField>) = apply { body.memberUsers(memberUsers) } - /** Ids of users which belong to this group */ + /** + * Adds a single [String] to [memberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberUser(memberUser: String) = apply { body.addMemberUser(memberUser) } /** @@ -476,17 +573,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the group belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 5945b26a..55465b89 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -14,6 +14,7 @@ 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,40 +39,96 @@ private constructor( /** Group id */ fun groupId(): String = groupId - /** A list of group IDs to add to the group's inheriting-from set */ + /** + * A list of group IDs to add to the group's inheriting-from set + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun addMemberGroups(): Optional> = body.addMemberGroups() - /** A list of user IDs to add to the group */ + /** + * A list of user IDs to add to the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun addMemberUsers(): Optional> = body.addMemberUsers() - /** Textual description of the group */ + /** + * Textual description of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the group */ + /** + * Name of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * A list of group IDs to remove from the group's inheriting-from set + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun removeMemberGroups(): Optional> = body.removeMemberGroups() - /** A list of user IDs to remove from the group */ + /** + * A list of user IDs to remove from the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun removeMemberUsers(): Optional> = body.removeMemberUsers() - /** A list of group IDs to add to the group's inheriting-from set */ + /** + * Returns the raw JSON value of [addMemberGroups]. + * + * Unlike [addMemberGroups], this method doesn't throw if the JSON field has an unexpected type. + */ fun _addMemberGroups(): JsonField> = body._addMemberGroups() - /** A list of user IDs to add to the group */ + /** + * Returns the raw JSON value of [addMemberUsers]. + * + * Unlike [addMemberUsers], this method doesn't throw if the JSON field has an unexpected type. + */ fun _addMemberUsers(): JsonField> = body._addMemberUsers() - /** Textual description of the group */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** Name of the group */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * Returns the raw JSON value of [removeMemberGroups]. + * + * Unlike [removeMemberGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ fun _removeMemberGroups(): JsonField> = body._removeMemberGroups() - /** A list of user IDs to remove from the group */ + /** + * Returns the raw JSON value of [removeMemberUsers]. + * + * Unlike [removeMemberUsers], this method doesn't throw if the JSON field has an unexpected + * type. + */ fun _removeMemberUsers(): JsonField> = body._removeMemberUsers() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -119,53 +176,111 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of group IDs to add to the group's inheriting-from set */ + /** + * A list of group IDs to add to the group's inheriting-from set + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun addMemberGroups(): Optional> = Optional.ofNullable(addMemberGroups.getNullable("add_member_groups")) - /** A list of user IDs to add to the group */ + /** + * A list of user IDs to add to the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun addMemberUsers(): Optional> = Optional.ofNullable(addMemberUsers.getNullable("add_member_users")) - /** Textual description of the group */ + /** + * Textual description of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the group */ + /** + * Name of the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * A list of group IDs to remove from the group's inheriting-from set + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun removeMemberGroups(): Optional> = Optional.ofNullable(removeMemberGroups.getNullable("remove_member_groups")) - /** A list of user IDs to remove from the group */ + /** + * A list of user IDs to remove from the group + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun removeMemberUsers(): Optional> = Optional.ofNullable(removeMemberUsers.getNullable("remove_member_users")) - /** A list of group IDs to add to the group's inheriting-from set */ + /** + * Returns the raw JSON value of [addMemberGroups]. + * + * Unlike [addMemberGroups], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("add_member_groups") @ExcludeMissing fun _addMemberGroups(): JsonField> = addMemberGroups - /** A list of user IDs to add to the group */ + /** + * Returns the raw JSON value of [addMemberUsers]. + * + * Unlike [addMemberUsers], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("add_member_users") @ExcludeMissing fun _addMemberUsers(): JsonField> = addMemberUsers - /** Textual description of the group */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** Name of the group */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * Returns the raw JSON value of [removeMemberGroups]. + * + * Unlike [removeMemberGroups], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("remove_member_groups") @ExcludeMissing fun _removeMemberGroups(): JsonField> = removeMemberGroups - /** A list of user IDs to remove from the group */ + /** + * Returns the raw JSON value of [removeMemberUsers]. + * + * Unlike [removeMemberUsers], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("remove_member_users") @ExcludeMissing fun _removeMemberUsers(): JsonField> = removeMemberUsers @@ -224,16 +339,26 @@ private constructor( fun addMemberGroups(addMemberGroups: List?) = addMemberGroups(JsonField.ofNullable(addMemberGroups)) - /** A list of group IDs to add to the group's inheriting-from set */ + /** Alias for calling [Builder.addMemberGroups] with `addMemberGroups.orElse(null)`. */ fun addMemberGroups(addMemberGroups: Optional>) = addMemberGroups(addMemberGroups.getOrNull()) - /** A list of group IDs to add to the group's inheriting-from set */ + /** + * Sets [Builder.addMemberGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.addMemberGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun addMemberGroups(addMemberGroups: JsonField>) = apply { this.addMemberGroups = addMemberGroups.map { it.toMutableList() } } - /** A list of group IDs to add to the group's inheriting-from set */ + /** + * Adds a single [String] to [addMemberGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAddMemberGroup(addMemberGroup: String) = apply { addMemberGroups = (addMemberGroups ?: JsonField.of(mutableListOf())).also { @@ -245,16 +370,26 @@ private constructor( fun addMemberUsers(addMemberUsers: List?) = addMemberUsers(JsonField.ofNullable(addMemberUsers)) - /** A list of user IDs to add to the group */ + /** Alias for calling [Builder.addMemberUsers] with `addMemberUsers.orElse(null)`. */ fun addMemberUsers(addMemberUsers: Optional>) = addMemberUsers(addMemberUsers.getOrNull()) - /** A list of user IDs to add to the group */ + /** + * Sets [Builder.addMemberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.addMemberUsers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun addMemberUsers(addMemberUsers: JsonField>) = apply { this.addMemberUsers = addMemberUsers.map { it.toMutableList() } } - /** A list of user IDs to add to the group */ + /** + * Adds a single [String] to [addMemberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAddMemberUser(addMemberUser: String) = apply { addMemberUsers = (addMemberUsers ?: JsonField.of(mutableListOf())).also { @@ -265,10 +400,16 @@ private constructor( /** Textual description of the group */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the group */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the group */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -276,26 +417,45 @@ private constructor( /** Name of the group */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the group */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the group */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** A list of group IDs to remove from the group's inheriting-from set */ fun removeMemberGroups(removeMemberGroups: List?) = removeMemberGroups(JsonField.ofNullable(removeMemberGroups)) - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * Alias for calling [Builder.removeMemberGroups] with + * `removeMemberGroups.orElse(null)`. + */ fun removeMemberGroups(removeMemberGroups: Optional>) = removeMemberGroups(removeMemberGroups.getOrNull()) - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * Sets [Builder.removeMemberGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.removeMemberGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { this.removeMemberGroups = removeMemberGroups.map { it.toMutableList() } } - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * Adds a single [String] to [removeMemberGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRemoveMemberGroup(removeMemberGroup: String) = apply { removeMemberGroups = (removeMemberGroups ?: JsonField.of(mutableListOf())).also { @@ -307,16 +467,28 @@ private constructor( fun removeMemberUsers(removeMemberUsers: List?) = removeMemberUsers(JsonField.ofNullable(removeMemberUsers)) - /** A list of user IDs to remove from the group */ + /** + * Alias for calling [Builder.removeMemberUsers] with `removeMemberUsers.orElse(null)`. + */ fun removeMemberUsers(removeMemberUsers: Optional>) = removeMemberUsers(removeMemberUsers.getOrNull()) - /** A list of user IDs to remove from the group */ + /** + * Sets [Builder.removeMemberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.removeMemberUsers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { this.removeMemberUsers = removeMemberUsers.map { it.toMutableList() } } - /** A list of user IDs to remove from the group */ + /** + * Adds a single [String] to [removeMemberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRemoveMemberUser(removeMemberUser: String) = apply { removeMemberUsers = (removeMemberUsers ?: JsonField.of(mutableListOf())).also { @@ -413,16 +585,26 @@ private constructor( body.addMemberGroups(addMemberGroups) } - /** A list of group IDs to add to the group's inheriting-from set */ + /** Alias for calling [Builder.addMemberGroups] with `addMemberGroups.orElse(null)`. */ fun addMemberGroups(addMemberGroups: Optional>) = addMemberGroups(addMemberGroups.getOrNull()) - /** A list of group IDs to add to the group's inheriting-from set */ + /** + * Sets [Builder.addMemberGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.addMemberGroups] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun addMemberGroups(addMemberGroups: JsonField>) = apply { body.addMemberGroups(addMemberGroups) } - /** A list of group IDs to add to the group's inheriting-from set */ + /** + * Adds a single [String] to [addMemberGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAddMemberGroup(addMemberGroup: String) = apply { body.addAddMemberGroup(addMemberGroup) } @@ -432,34 +614,55 @@ private constructor( body.addMemberUsers(addMemberUsers) } - /** A list of user IDs to add to the group */ + /** Alias for calling [Builder.addMemberUsers] with `addMemberUsers.orElse(null)`. */ fun addMemberUsers(addMemberUsers: Optional>) = addMemberUsers(addMemberUsers.getOrNull()) - /** A list of user IDs to add to the group */ + /** + * Sets [Builder.addMemberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.addMemberUsers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun addMemberUsers(addMemberUsers: JsonField>) = apply { body.addMemberUsers(addMemberUsers) } - /** A list of user IDs to add to the group */ + /** + * Adds a single [String] to [addMemberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAddMemberUser(addMemberUser: String) = apply { body.addAddMemberUser(addMemberUser) } /** Textual description of the group */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the group */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the group */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** Name of the group */ fun name(name: String?) = apply { body.name(name) } - /** Name of the group */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the group */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** A list of group IDs to remove from the group's inheriting-from set */ @@ -467,16 +670,28 @@ private constructor( body.removeMemberGroups(removeMemberGroups) } - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * Alias for calling [Builder.removeMemberGroups] with `removeMemberGroups.orElse(null)`. + */ fun removeMemberGroups(removeMemberGroups: Optional>) = removeMemberGroups(removeMemberGroups.getOrNull()) - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * Sets [Builder.removeMemberGroups] to an arbitrary JSON value. + * + * You should usually call [Builder.removeMemberGroups] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { body.removeMemberGroups(removeMemberGroups) } - /** A list of group IDs to remove from the group's inheriting-from set */ + /** + * Adds a single [String] to [removeMemberGroups]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRemoveMemberGroup(removeMemberGroup: String) = apply { body.addRemoveMemberGroup(removeMemberGroup) } @@ -486,16 +701,26 @@ private constructor( body.removeMemberUsers(removeMemberUsers) } - /** A list of user IDs to remove from the group */ + /** Alias for calling [Builder.removeMemberUsers] with `removeMemberUsers.orElse(null)`. */ fun removeMemberUsers(removeMemberUsers: Optional>) = removeMemberUsers(removeMemberUsers.getOrNull()) - /** A list of user IDs to remove from the group */ + /** + * Sets [Builder.removeMemberUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.removeMemberUsers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { body.removeMemberUsers(removeMemberUsers) } - /** A list of user IDs to remove from the group */ + /** + * Adds a single [String] to [removeMemberUsers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRemoveMemberUser(removeMemberUser: String) = apply { body.addRemoveMemberUser(removeMemberUser) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index 95ab2268..a85c0c55 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.checkKnown 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 @@ -66,6 +67,9 @@ private constructor( /** * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate * one for you + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) @@ -80,6 +84,9 @@ private constructor( * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) @@ -95,6 +102,9 @@ private constructor( * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and * `input.c`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) @@ -102,6 +112,9 @@ private constructor( /** * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up * in subsequent fetches for this dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) @@ -123,10 +136,18 @@ private constructor( * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) - /** The timestamp the dataset event was created */ + /** + * The timestamp the dataset event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** @@ -144,10 +165,18 @@ private constructor( * example, you could log the `prompt`, example's `id`, or anything else that would be useful to * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** Indicates the event was copied from another object. */ + /** + * Indicates the event was copied from another object. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** @@ -165,6 +194,9 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) @@ -183,6 +215,9 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) @@ -201,150 +236,109 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * Returns the raw JSON value of [_isMerge]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * Unlike [_isMerge], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * Returns the raw JSON value of [_mergePaths]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * Unlike [_mergePaths], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Returns the raw JSON value of [_objectDelete]. + * + * Unlike [_objectDelete], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. + * Returns the raw JSON value of [_parentId]. * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [_parentId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId - /** The timestamp the dataset event was created */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** Indicates the event was copied from another object. */ + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * Returns the raw JSON value of [rootSpanId]. * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [rootSpanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * Returns the raw JSON value of [spanId]. * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [spanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. + * Returns the raw JSON value of [spanParents]. * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [spanParents], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -425,15 +419,14 @@ private constructor( */ fun id(id: String?) = id(JsonField.ofNullable(id)) - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } @@ -452,44 +445,21 @@ private constructor( fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * Alias for [Builder._isMerge]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * This unboxed primitive overload exists for backwards compatibility. */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ + /** Alias for calling [Builder._isMerge] with `_isMerge.orElse(null)`. */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * Sets [Builder._isMerge] to an arbitrary JSON value. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * You should usually call [Builder._isMerge] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } @@ -509,51 +479,25 @@ private constructor( fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) - /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ + /** Alias for calling [Builder._mergePaths] with `_mergePaths.orElse(null)`. */ fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * Sets [Builder._mergePaths] to an arbitrary JSON value. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * You should usually call [Builder._mergePaths] with a well-typed `List>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ fun _mergePaths(_mergePaths: JsonField>>) = apply { this._mergePaths = _mergePaths.map { it.toMutableList() } } /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * Adds a single [List] to [_mergePaths]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMergePath(mergePath: List) = apply { _mergePaths = @@ -570,21 +514,22 @@ private constructor( _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Alias for [Builder._objectDelete]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) - /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset - */ + /** Alias for calling [Builder._objectDelete] with `_objectDelete.orElse(null)`. */ fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Sets [Builder._objectDelete] to an arbitrary JSON value. + * + * You should usually call [Builder._objectDelete] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun _objectDelete(_objectDelete: JsonField) = apply { this._objectDelete = _objectDelete @@ -610,53 +555,31 @@ private constructor( */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) - /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. - * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder._parentId] with `_parentId.orElse(null)`. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. - * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Sets [Builder._parentId] to an arbitrary JSON value. * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder._parentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** The timestamp the dataset event was created */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** The timestamp the dataset event was created */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** @@ -679,51 +602,32 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** Indicates the event was copied from another object. */ fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) - /** Indicates the event was copied from another object. */ + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) - /** Indicates the event was copied from another object. */ - fun origin(origin: JsonField) = apply { this.origin = origin } - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Sets [Builder.origin] to an arbitrary JSON value. * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.origin] with a well-typed [ObjectReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) + fun origin(origin: JsonField) = apply { this.origin = origin } /** * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now @@ -742,24 +646,17 @@ private constructor( * * If the row is being merged into an existing row, this field will be ignored. */ + fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) + + /** Alias for calling [Builder.rootSpanId] with `rootSpanId.orElse(null)`. */ fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Sets [Builder.rootSpanId] to an arbitrary JSON value. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.rootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } @@ -782,41 +679,14 @@ private constructor( */ fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder.spanId] with `spanId.orElse(null)`. */ fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Sets [Builder.spanId] to an arbitrary JSON value. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.spanId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun spanId(spanId: JsonField) = apply { this.spanId = spanId } @@ -839,62 +709,24 @@ private constructor( */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder.spanParents] with `spanParents.orElse(null)`. */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Sets [Builder.spanParents] to an arbitrary JSON value. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.spanParents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun spanParents(spanParents: JsonField>) = apply { this.spanParents = spanParents.map { it.toMutableList() } } /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Adds a single [String] to [spanParents]. * - * If the row is being merged into an existing row, this field will be ignored. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addSpanParent(spanParent: String) = apply { spanParents = @@ -906,15 +738,25 @@ private constructor( /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } @@ -976,10 +818,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The model used for this example */ + /** + * The model used for this example + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - /** The model used for this example */ + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model @JsonAnyGetter @@ -1020,10 +871,16 @@ private constructor( /** The model used for this example */ fun model(model: String?) = model(JsonField.ofNullable(model)) - /** The model used for this example */ + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ fun model(model: Optional) = model(model.getOrNull()) - /** The model used for this example */ + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun model(model: JsonField) = apply { this.model = model } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 099bcb9a..a2436a67 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -11,6 +11,7 @@ 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 @@ -29,11 +30,16 @@ private constructor( /** * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun rowIds(): List = rowIds.getRequired("row_ids") /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + * Returns the raw JSON value of [rowIds]. + * + * Unlike [rowIds], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("row_ids") @ExcludeMissing fun _rowIds(): JsonField> = rowIds @@ -86,16 +92,20 @@ private constructor( fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input + * Sets [Builder.rowIds] to an arbitrary JSON value. + * + * You should usually call [Builder.rowIds] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds.map { it.toMutableList() } } /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input + * Adds a single [String] to [rowIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addRowId(rowId: String) = apply { rowIds = diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 924c9baf..13aa14a8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.checkKnown 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 @@ -80,6 +81,9 @@ private constructor( /** * A unique identifier for the experiment event. If you don't provide one, BrainTrust will * generate one for you + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) @@ -94,6 +98,9 @@ private constructor( * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) @@ -109,6 +116,9 @@ private constructor( * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and * `input.c`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) @@ -116,6 +126,9 @@ private constructor( /** * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show * up in subsequent fetches for this experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) @@ -137,6 +150,9 @@ private constructor( * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) @@ -144,10 +160,18 @@ private constructor( * Context is additional information about the code that produced the experiment event. It is * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the * location in code which produced the experiment event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - /** The timestamp the experiment event was created */ + /** + * The timestamp the experiment event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** The error that occurred, if any. */ @@ -177,6 +201,9 @@ private constructor( * example, you could log the `prompt`, example's `id`, or anything else that would be useful to * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -184,10 +211,18 @@ private constructor( * Metrics are numerical measurements tracking the execution of the code that produced the * experiment event. Use "start" and "end" to track the time span over which the experiment * event was produced + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - /** Indicates the event was copied from another object. */ + /** + * Indicates the event was copied from another object. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** @@ -214,6 +249,9 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) @@ -225,10 +263,18 @@ private constructor( * generated and grouth truth summary. The word similarity score could help you determine * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Human-identifying attributes of the span, such as name, type, etc. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) @@ -247,6 +293,9 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) @@ -265,180 +314,139 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * Returns the raw JSON value of [_isMerge]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * Unlike [_isMerge], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * Returns the raw JSON value of [_mergePaths]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * Unlike [_mergePaths], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Returns the raw JSON value of [_objectDelete]. + * + * Unlike [_objectDelete], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. + * Returns the raw JSON value of [_parentId]. * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [_parentId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - /** The timestamp the experiment event was created */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Returns the raw JSON value of [metrics]. + * + * Unlike [metrics], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics - /** Indicates the event was copied from another object. */ + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Returns the raw JSON value of [rootSpanId]. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [rootSpanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare experiments + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Returns the raw JSON value of [spanAttributes]. + * + * Unlike [spanAttributes], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes(): JsonField = spanAttributes /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Returns the raw JSON value of [spanId]. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [spanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Returns the raw JSON value of [spanParents]. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [spanParents], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -535,15 +543,14 @@ private constructor( */ fun id(id: String?) = id(JsonField.ofNullable(id)) - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } @@ -562,44 +569,21 @@ private constructor( fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * Alias for [Builder._isMerge]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * This unboxed primitive overload exists for backwards compatibility. */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ + /** Alias for calling [Builder._isMerge] with `_isMerge.orElse(null)`. */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * Sets [Builder._isMerge] to an arbitrary JSON value. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * You should usually call [Builder._isMerge] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } @@ -619,51 +603,25 @@ private constructor( fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) - /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ + /** Alias for calling [Builder._mergePaths] with `_mergePaths.orElse(null)`. */ fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * Sets [Builder._mergePaths] to an arbitrary JSON value. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * You should usually call [Builder._mergePaths] with a well-typed `List>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ fun _mergePaths(_mergePaths: JsonField>>) = apply { this._mergePaths = _mergePaths.map { it.toMutableList() } } /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * Adds a single [List] to [_mergePaths]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMergePath(mergePath: List) = apply { _mergePaths = @@ -680,21 +638,22 @@ private constructor( _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Alias for [Builder._objectDelete]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) - /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment - */ + /** Alias for calling [Builder._objectDelete] with `_objectDelete.orElse(null)`. */ fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Sets [Builder._objectDelete] to an arbitrary JSON value. + * + * You should usually call [Builder._objectDelete] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun _objectDelete(_objectDelete: JsonField) = apply { this._objectDelete = _objectDelete @@ -720,43 +679,15 @@ private constructor( */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) - /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. - * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder._parentId] with `_parentId.orElse(null)`. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. - * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Sets [Builder._parentId] to an arbitrary JSON value. * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder._parentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } @@ -767,27 +698,30 @@ private constructor( */ fun context(context: Context?) = context(JsonField.ofNullable(context)) - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [Context] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun context(context: JsonField) = apply { this.context = context } /** The timestamp the experiment event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** The timestamp the experiment event was created */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** The timestamp the experiment event was created */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** The error that occurred, if any. */ @@ -820,21 +754,15 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -845,27 +773,30 @@ private constructor( */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ + /** Alias for calling [Builder.metrics] with `metrics.orElse(null)`. */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Sets [Builder.metrics] to an arbitrary JSON value. + * + * You should usually call [Builder.metrics] with a well-typed [Metrics] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) - /** Indicates the event was copied from another object. */ + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) - /** Indicates the event was copied from another object. */ + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [ObjectReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } /** @@ -896,41 +827,15 @@ private constructor( */ fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder.rootSpanId] with `rootSpanId.orElse(null)`. */ fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Sets [Builder.rootSpanId] to an arbitrary JSON value. * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.rootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } @@ -945,25 +850,14 @@ private constructor( */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments - */ + /** Alias for calling [Builder.scores] with `scores.orElse(null)`. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed [Scores] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun scores(scores: JsonField) = apply { this.scores = scores } @@ -971,11 +865,17 @@ private constructor( fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** Alias for calling [Builder.spanAttributes] with `spanAttributes.orElse(null)`. */ fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Sets [Builder.spanAttributes] to an arbitrary JSON value. + * + * You should usually call [Builder.spanAttributes] with a well-typed [SpanAttributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun spanAttributes(spanAttributes: JsonField) = apply { this.spanAttributes = spanAttributes } @@ -999,41 +899,14 @@ private constructor( */ fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder.spanId] with `spanId.orElse(null)`. */ fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Sets [Builder.spanId] to an arbitrary JSON value. * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.spanId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun spanId(spanId: JsonField) = apply { this.spanId = spanId } @@ -1056,62 +929,24 @@ private constructor( */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder.spanParents] with `spanParents.orElse(null)`. */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Sets [Builder.spanParents] to an arbitrary JSON value. * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.spanParents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun spanParents(spanParents: JsonField>) = apply { this.spanParents = spanParents.map { it.toMutableList() } } /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Adds a single [String] to [spanParents]. * - * If the row is being merged into an existing row, this field will be ignored. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addSpanParent(spanParent: String) = apply { spanParents = @@ -1123,15 +958,25 @@ private constructor( /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } @@ -1203,29 +1048,59 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the file in code where the experiment event was created */ + /** + * Name of the file in code where the experiment event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) - /** The function in code which created the experiment event */ + /** + * The function in code which created the experiment event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - /** Line of code where the experiment event was created */ + /** + * Line of code where the experiment event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - /** Name of the file in code where the experiment event was created */ + /** + * Returns the raw JSON value of [callerFilename]. + * + * Unlike [callerFilename], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename(): JsonField = callerFilename - /** The function in code which created the experiment event */ + /** + * Returns the raw JSON value of [callerFunctionname]. + * + * Unlike [callerFunctionname], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("caller_functionname") @ExcludeMissing fun _callerFunctionname(): JsonField = callerFunctionname - /** Line of code where the experiment event was created */ + /** + * Returns the raw JSON value of [callerLineno]. + * + * Unlike [callerLineno], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonField = callerLineno @@ -1275,11 +1150,17 @@ private constructor( fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) - /** Name of the file in code where the experiment event was created */ + /** Alias for calling [Builder.callerFilename] with `callerFilename.orElse(null)`. */ fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) - /** Name of the file in code where the experiment event was created */ + /** + * Sets [Builder.callerFilename] to an arbitrary JSON value. + * + * You should usually call [Builder.callerFilename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerFilename(callerFilename: JsonField) = apply { this.callerFilename = callerFilename } @@ -1288,11 +1169,20 @@ private constructor( fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) - /** The function in code which created the experiment event */ + /** + * Alias for calling [Builder.callerFunctionname] with + * `callerFunctionname.orElse(null)`. + */ fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) - /** The function in code which created the experiment event */ + /** + * Sets [Builder.callerFunctionname] to an arbitrary JSON value. + * + * You should usually call [Builder.callerFunctionname] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerFunctionname(callerFunctionname: JsonField) = apply { this.callerFunctionname = callerFunctionname } @@ -1300,13 +1190,23 @@ private constructor( /** Line of code where the experiment event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) - /** Line of code where the experiment event was created */ + /** + * Alias for [Builder.callerLineno]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) - /** Line of code where the experiment event was created */ + /** Alias for calling [Builder.callerLineno] with `callerLineno.orElse(null)`. */ fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) - /** Line of code where the experiment event was created */ + /** + * Sets [Builder.callerLineno] to an arbitrary JSON value. + * + * You should usually call [Builder.callerLineno] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerLineno(callerLineno: JsonField) = apply { this.callerLineno = callerLineno } @@ -1375,10 +1275,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The model used for this example */ + /** + * The model used for this example + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - /** The model used for this example */ + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model @JsonAnyGetter @@ -1419,10 +1328,16 @@ private constructor( /** The model used for this example */ fun model(model: String?) = model(JsonField.ofNullable(model)) - /** The model used for this example */ + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ fun model(model: Optional) = model(model.getOrNull()) - /** The model used for this example */ + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun model(model: JsonField) = apply { this.model = model } fun additionalProperties(additionalProperties: Map) = apply { @@ -1516,6 +1431,9 @@ private constructor( /** * The number of tokens in the completion generated by the model (only set if this is an LLM * span) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) @@ -1523,12 +1441,18 @@ private constructor( /** * A unix timestamp recording when the section of code which produced the experiment event * finished + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** * The number of tokens in the prompt used to generate the experiment event (only set if * this is an LLM span) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) @@ -1536,41 +1460,59 @@ private constructor( /** * A unix timestamp recording when the section of code which produced the experiment event * started + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - /** The total number of tokens in the input and output of the experiment event. */ + /** + * The total number of tokens in the input and output of the experiment event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * finished + * Returns the raw JSON value of [end]. + * + * Unlike [end], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the experiment event - * started + * Returns the raw JSON value of [start]. + * + * Unlike [start], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start - /** The total number of tokens in the input and output of the experiment event. */ + /** + * Returns the raw JSON value of [tokens]. + * + * Unlike [tokens], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @@ -1647,22 +1589,25 @@ private constructor( completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. */ fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun completionTokens(completionTokens: JsonField) = apply { this.completionTokens = completionTokens @@ -1675,20 +1620,21 @@ private constructor( fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * Alias for [Builder.end]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun end(end: Double) = end(end as Double?) - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ + /** Alias for calling [Builder.end] with `end.orElse(null)`. */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished + * Sets [Builder.end] to an arbitrary JSON value. + * + * You should usually call [Builder.end] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun end(end: JsonField) = apply { this.end = end } @@ -1699,20 +1645,21 @@ private constructor( fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens @@ -1725,33 +1672,44 @@ private constructor( fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * Alias for [Builder.start]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun start(start: Double) = start(start as Double?) - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ + /** Alias for calling [Builder.start] with `start.orElse(null)`. */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the experiment - * event started + * Sets [Builder.start] to an arbitrary JSON value. + * + * You should usually call [Builder.start] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the experiment event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) - /** The total number of tokens in the input and output of the experiment event. */ + /** + * Alias for [Builder.tokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun tokens(tokens: Long) = tokens(tokens as Long?) - /** The total number of tokens in the input and output of the experiment event. */ + /** Alias for calling [Builder.tokens] with `tokens.orElse(null)`. */ fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) - /** The total number of tokens in the input and output of the experiment event. */ + /** + * Sets [Builder.tokens] to an arbitrary JSON value. + * + * You should usually call [Builder.tokens] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index 977fb221..cd8dd98c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.checkKnown 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 @@ -80,6 +81,9 @@ private constructor( /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun id(): Optional = Optional.ofNullable(id.getNullable("id")) @@ -94,6 +98,9 @@ private constructor( * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _isMerge(): Optional = Optional.ofNullable(_isMerge.getNullable("_is_merge")) @@ -109,6 +116,9 @@ private constructor( * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and * `input.c`. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _mergePaths(): Optional>> = Optional.ofNullable(_mergePaths.getNullable("_merge_paths")) @@ -116,6 +126,9 @@ private constructor( /** * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not * show up in subsequent fetches for this project logs + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _objectDelete(): Optional = Optional.ofNullable(_objectDelete.getNullable("_object_delete")) @@ -137,6 +150,9 @@ private constructor( * case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun _parentId(): Optional = Optional.ofNullable(_parentId.getNullable("_parent_id")) @@ -144,10 +160,18 @@ private constructor( * Context is additional information about the code that produced the project logs event. It is * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the * location in code which produced the project logs event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) - /** The timestamp the project logs event was created */ + /** + * The timestamp the project logs event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** The error that occurred, if any. */ @@ -172,6 +196,9 @@ private constructor( * example, you could log the `prompt`, example's `id`, or anything else that would be useful to * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -179,10 +206,18 @@ private constructor( * Metrics are numerical measurements tracking the execution of the code that produced the * project logs event. Use "start" and "end" to track the time span over which the project logs * event was produced + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - /** Indicates the event was copied from another object. */ + /** + * Indicates the event was copied from another object. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** @@ -209,6 +244,9 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun rootSpanId(): Optional = Optional.ofNullable(rootSpanId.getNullable("root_span_id")) @@ -220,10 +258,18 @@ private constructor( * generated and grouth truth summary. The word similarity score could help you determine * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Human-identifying attributes of the span, such as name, type, etc. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) @@ -242,6 +288,9 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun spanId(): Optional = Optional.ofNullable(spanId.getNullable("span_id")) @@ -260,180 +309,139 @@ private constructor( * this case, the `"llm_call"` row) by clicking on the "abc" row. * * If the row is being merged into an existing row, this field will be ignored. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row, if one is - * found. If no existing row is found, the new row is inserted as is. + * Returns the raw JSON value of [_isMerge]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * Unlike [_isMerge], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge(): JsonField = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge, when `_is_merge=true`. - * `_merge_paths` is a list of paths, where each path is a list of field names. The deep merge - * will not descend below any of the specified merge paths. + * Returns the raw JSON value of [_mergePaths]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * Unlike [_mergePaths], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths(): JsonField>> = _mergePaths /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * Returns the raw JSON value of [_objectDelete]. + * + * Unlike [_objectDelete], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete(): JsonField = _objectDelete /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. + * Returns the raw JSON value of [_parentId]. * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [_parentId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_parent_id") @ExcludeMissing fun __parentId(): JsonField = _parentId /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - /** The timestamp the project logs event was created */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Returns the raw JSON value of [metrics]. + * + * Unlike [metrics], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics - /** Indicates the event was copied from another object. */ + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Returns the raw JSON value of [rootSpanId]. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [rootSpanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Returns the raw JSON value of [spanAttributes]. + * + * Unlike [spanAttributes], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes(): JsonField = spanAttributes /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Returns the raw JSON value of [spanId]. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [spanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, and - * the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. + * Returns the raw JSON value of [spanParents]. * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": - * 0.33}}`. We can create a sub-span of the parent row by logging `{"id": "llm_call", "span_id": - * "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root - * span row `"abc"` will show up in the summary view. You can view the full trace hierarchy (in - * this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * Unlike [spanParents], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -530,15 +538,14 @@ private constructor( */ fun id(id: String?) = id(JsonField.ofNullable(id)) - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } @@ -557,44 +564,21 @@ private constructor( fun _isMerge(_isMerge: Boolean?) = _isMerge(JsonField.ofNullable(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * Alias for [Builder._isMerge]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * This unboxed primitive overload exists for backwards compatibility. */ fun _isMerge(_isMerge: Boolean) = _isMerge(_isMerge as Boolean?) - /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` - */ + /** Alias for calling [Builder._isMerge] with `_isMerge.orElse(null)`. */ fun _isMerge(_isMerge: Optional) = _isMerge(_isMerge.getOrNull()) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row, if one is found. If no existing row is found, the new row is inserted as is. + * Sets [Builder._isMerge] to an arbitrary JSON value. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be - * `{"id": "foo", "input": {"b": 11, "c": 20}}` + * You should usually call [Builder._isMerge] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } @@ -614,51 +598,25 @@ private constructor( fun _mergePaths(_mergePaths: List>?) = _mergePaths(JsonField.ofNullable(_mergePaths)) - /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. - * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. - */ + /** Alias for calling [Builder._mergePaths] with `_mergePaths.orElse(null)`. */ fun _mergePaths(_mergePaths: Optional>>) = _mergePaths(_mergePaths.getOrNull()) /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * Sets [Builder._mergePaths] to an arbitrary JSON value. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * You should usually call [Builder._mergePaths] with a well-typed `List>` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ fun _mergePaths(_mergePaths: JsonField>>) = apply { this._mergePaths = _mergePaths.map { it.toMutableList() } } /** - * The `_merge_paths` field allows controlling the depth of the merge, when - * `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of field - * names. The deep merge will not descend below any of the specified merge paths. + * Adds a single [List] to [_mergePaths]. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMergePath(mergePath: List) = apply { _mergePaths = @@ -675,21 +633,22 @@ private constructor( _objectDelete(JsonField.ofNullable(_objectDelete)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Alias for [Builder._objectDelete]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(_objectDelete as Boolean?) - /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs - */ + /** Alias for calling [Builder._objectDelete] with `_objectDelete.orElse(null)`. */ fun _objectDelete(_objectDelete: Optional) = _objectDelete(_objectDelete.getOrNull()) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Sets [Builder._objectDelete] to an arbitrary JSON value. + * + * You should usually call [Builder._objectDelete] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun _objectDelete(_objectDelete: JsonField) = apply { this._objectDelete = _objectDelete @@ -715,43 +674,15 @@ private constructor( */ fun _parentId(_parentId: String?) = _parentId(JsonField.ofNullable(_parentId)) - /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. - * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). - * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder._parentId] with `_parentId.orElse(null)`. */ fun _parentId(_parentId: Optional) = _parentId(_parentId.getOrNull()) /** - * DEPRECATED: The `_parent_id` field is deprecated and should not be used. Support for - * `_parent_id` will be dropped in a future version of Braintrust. Log `span_id`, - * `root_span_id`, and `span_parents` explicitly instead. - * - * Use the `_parent_id` field to create this row as a subspan of an existing row. Tracking - * hierarchical relationships are important for tracing (see the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Sets [Builder._parentId] to an arbitrary JSON value. * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder._parentId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } @@ -762,27 +693,30 @@ private constructor( */ fun context(context: Context?) = context(JsonField.ofNullable(context)) - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [Context] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun context(context: JsonField) = apply { this.context = context } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** The timestamp the project logs event was created */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** The timestamp the project logs event was created */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** The error that occurred, if any. */ @@ -812,21 +746,15 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -837,27 +765,30 @@ private constructor( */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ + /** Alias for calling [Builder.metrics] with `metrics.orElse(null)`. */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Sets [Builder.metrics] to an arbitrary JSON value. + * + * You should usually call [Builder.metrics] with a well-typed [Metrics] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) - /** Indicates the event was copied from another object. */ + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) - /** Indicates the event was copied from another object. */ + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [ObjectReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } /** @@ -888,41 +819,15 @@ private constructor( */ fun rootSpanId(rootSpanId: String?) = rootSpanId(JsonField.ofNullable(rootSpanId)) - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder.rootSpanId] with `rootSpanId.orElse(null)`. */ fun rootSpanId(rootSpanId: Optional) = rootSpanId(rootSpanId.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Sets [Builder.rootSpanId] to an arbitrary JSON value. * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.rootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } @@ -937,25 +842,14 @@ private constructor( */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. - */ + /** Alias for calling [Builder.scores] with `scores.orElse(null)`. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed [Scores] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun scores(scores: JsonField) = apply { this.scores = scores } @@ -963,11 +857,17 @@ private constructor( fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** Alias for calling [Builder.spanAttributes] with `spanAttributes.orElse(null)`. */ fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Sets [Builder.spanAttributes] to an arbitrary JSON value. + * + * You should usually call [Builder.spanAttributes] with a well-typed [SpanAttributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun spanAttributes(spanAttributes: JsonField) = apply { this.spanAttributes = spanAttributes } @@ -991,41 +891,14 @@ private constructor( */ fun spanId(spanId: String?) = spanId(JsonField.ofNullable(spanId)) - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder.spanId] with `spanId.orElse(null)`. */ fun spanId(spanId: Optional) = spanId(spanId.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Sets [Builder.spanId] to an arbitrary JSON value. * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.spanId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun spanId(spanId: JsonField) = apply { this.spanId = spanId } @@ -1048,62 +921,24 @@ private constructor( */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) - /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. - * - * If the row is being merged into an existing row, this field will be ignored. - */ + /** Alias for calling [Builder.spanParents] with `spanParents.orElse(null)`. */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Sets [Builder.spanParents] to an arbitrary JSON value. * - * If the row is being merged into an existing row, this field will be ignored. + * You should usually call [Builder.spanParents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun spanParents(spanParents: JsonField>) = apply { this.spanParents = spanParents.map { it.toMutableList() } } /** - * Use `span_id`, `root_span_id`, and `span_parents` instead of `_parent_id`, which is now - * deprecated. The span_id is a unique identifier describing the row's place in the a trace, - * and the root_span_id is a unique identifier for the whole trace. See the - * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details. - * - * For example, say we have logged a row `{"id": "abc", "span_id": "span0", "root_span_id": - * "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": - * {"correctness": 0.33}}`. We can create a sub-span of the parent row by logging `{"id": - * "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], - * "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": - * 1}}`. In the webapp, only the root span row `"abc"` will show up in the summary view. You - * can view the full trace hierarchy (in this case, the `"llm_call"` row) by clicking on the - * "abc" row. + * Adds a single [String] to [spanParents]. * - * If the row is being merged into an existing row, this field will be ignored. + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addSpanParent(spanParent: String) = apply { spanParents = @@ -1115,15 +950,25 @@ private constructor( /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } @@ -1195,29 +1040,59 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the file in code where the project logs event was created */ + /** + * Name of the file in code where the project logs event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) - /** The function in code which created the project logs event */ + /** + * The function in code which created the project logs event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - /** Line of code where the project logs event was created */ + /** + * Line of code where the project logs event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - /** Name of the file in code where the project logs event was created */ + /** + * Returns the raw JSON value of [callerFilename]. + * + * Unlike [callerFilename], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename(): JsonField = callerFilename - /** The function in code which created the project logs event */ + /** + * Returns the raw JSON value of [callerFunctionname]. + * + * Unlike [callerFunctionname], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("caller_functionname") @ExcludeMissing fun _callerFunctionname(): JsonField = callerFunctionname - /** Line of code where the project logs event was created */ + /** + * Returns the raw JSON value of [callerLineno]. + * + * Unlike [callerLineno], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonField = callerLineno @@ -1267,11 +1142,17 @@ private constructor( fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) - /** Name of the file in code where the project logs event was created */ + /** Alias for calling [Builder.callerFilename] with `callerFilename.orElse(null)`. */ fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) - /** Name of the file in code where the project logs event was created */ + /** + * Sets [Builder.callerFilename] to an arbitrary JSON value. + * + * You should usually call [Builder.callerFilename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerFilename(callerFilename: JsonField) = apply { this.callerFilename = callerFilename } @@ -1280,11 +1161,20 @@ private constructor( fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) - /** The function in code which created the project logs event */ + /** + * Alias for calling [Builder.callerFunctionname] with + * `callerFunctionname.orElse(null)`. + */ fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) - /** The function in code which created the project logs event */ + /** + * Sets [Builder.callerFunctionname] to an arbitrary JSON value. + * + * You should usually call [Builder.callerFunctionname] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerFunctionname(callerFunctionname: JsonField) = apply { this.callerFunctionname = callerFunctionname } @@ -1292,13 +1182,23 @@ private constructor( /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) - /** Line of code where the project logs event was created */ + /** + * Alias for [Builder.callerLineno]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) - /** Line of code where the project logs event was created */ + /** Alias for calling [Builder.callerLineno] with `callerLineno.orElse(null)`. */ fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) - /** Line of code where the project logs event was created */ + /** + * Sets [Builder.callerLineno] to an arbitrary JSON value. + * + * You should usually call [Builder.callerLineno] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerLineno(callerLineno: JsonField) = apply { this.callerLineno = callerLineno } @@ -1367,10 +1267,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The model used for this example */ + /** + * The model used for this example + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - /** The model used for this example */ + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model @JsonAnyGetter @@ -1411,10 +1320,16 @@ private constructor( /** The model used for this example */ fun model(model: String?) = model(JsonField.ofNullable(model)) - /** The model used for this example */ + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ fun model(model: Optional) = model(model.getOrNull()) - /** The model used for this example */ + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun model(model: JsonField) = apply { this.model = model } fun additionalProperties(additionalProperties: Map) = apply { @@ -1508,6 +1423,9 @@ private constructor( /** * The number of tokens in the completion generated by the model (only set if this is an LLM * span) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) @@ -1515,12 +1433,18 @@ private constructor( /** * A unix timestamp recording when the section of code which produced the project logs event * finished + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** * The number of tokens in the prompt used to generate the project logs event (only set if * this is an LLM span) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) @@ -1528,41 +1452,59 @@ private constructor( /** * A unix timestamp recording when the section of code which produced the project logs event * started + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - /** The total number of tokens in the input and output of the project logs event. */ + /** + * The total number of tokens in the input and output of the project logs event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * Returns the raw JSON value of [end]. + * + * Unlike [end], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * Returns the raw JSON value of [start]. + * + * Unlike [start], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start - /** The total number of tokens in the input and output of the project logs event. */ + /** + * Returns the raw JSON value of [tokens]. + * + * Unlike [tokens], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @@ -1639,22 +1581,25 @@ private constructor( completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. */ fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun completionTokens(completionTokens: JsonField) = apply { this.completionTokens = completionTokens @@ -1667,20 +1612,21 @@ private constructor( fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * Alias for [Builder.end]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun end(end: Double) = end(end as Double?) - /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished - */ + /** Alias for calling [Builder.end] with `end.orElse(null)`. */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * Sets [Builder.end] to an arbitrary JSON value. + * + * You should usually call [Builder.end] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun end(end: JsonField) = apply { this.end = end } @@ -1691,20 +1637,21 @@ private constructor( fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) - /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) - */ + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens @@ -1717,33 +1664,44 @@ private constructor( fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * Alias for [Builder.start]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun start(start: Double) = start(start as Double?) - /** - * A unix timestamp recording when the section of code which produced the project logs - * event started - */ + /** Alias for calling [Builder.start] with `start.orElse(null)`. */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * Sets [Builder.start] to an arbitrary JSON value. + * + * You should usually call [Builder.start] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) - /** The total number of tokens in the input and output of the project logs event. */ + /** + * Alias for [Builder.tokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun tokens(tokens: Long) = tokens(tokens as Long?) - /** The total number of tokens in the input and output of the project logs event. */ + /** Alias for calling [Builder.tokens] with `tokens.orElse(null)`. */ fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) - /** The total number of tokens in the input and output of the project logs event. */ + /** + * Sets [Builder.tokens] to an arbitrary JSON value. + * + * You should usually call [Builder.tokens] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index a7fa4c4d..f9183713 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -10,6 +10,7 @@ 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 @@ -37,42 +38,96 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Number of improvements in the metric */ + /** + * Number of improvements in the metric + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun improvements(): Long = improvements.getRequired("improvements") - /** Average metric across all examples */ + /** + * Average metric across all examples + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun metric(): Double = metric.getRequired("metric") - /** Name of the metric */ + /** + * Name of the metric + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Number of regressions in the metric */ + /** + * Number of regressions in the metric + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun regressions(): Long = regressions.getRequired("regressions") - /** Unit label for the metric */ + /** + * Unit label for the metric + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun unit(): String = unit.getRequired("unit") - /** Difference in metric between the current and comparison experiment */ + /** + * Difference in metric between the current and comparison experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun diff(): Optional = Optional.ofNullable(diff.getNullable("diff")) - /** Number of improvements in the metric */ + /** + * Returns the raw JSON value of [improvements]. + * + * Unlike [improvements], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("improvements") @ExcludeMissing fun _improvements(): JsonField = improvements - /** Average metric across all examples */ + /** + * Returns the raw JSON value of [metric]. + * + * Unlike [metric], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric - /** Name of the metric */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Number of regressions in the metric */ + /** + * Returns the raw JSON value of [regressions]. + * + * Unlike [regressions], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions - /** Unit label for the metric */ + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit - /** Difference in metric between the current and comparison experiment */ + /** + * Returns the raw JSON value of [diff]. + * + * Unlike [diff], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff @JsonAnyGetter @@ -139,37 +194,69 @@ private constructor( /** Number of improvements in the metric */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) - /** Number of improvements in the metric */ + /** + * Sets [Builder.improvements] to an arbitrary JSON value. + * + * You should usually call [Builder.improvements] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun improvements(improvements: JsonField) = apply { this.improvements = improvements } /** Average metric across all examples */ fun metric(metric: Double) = metric(JsonField.of(metric)) - /** Average metric across all examples */ + /** + * Sets [Builder.metric] to an arbitrary JSON value. + * + * You should usually call [Builder.metric] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun metric(metric: JsonField) = apply { this.metric = metric } /** Name of the metric */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the metric */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Number of regressions in the metric */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) - /** Number of regressions in the metric */ + /** + * Sets [Builder.regressions] to an arbitrary JSON value. + * + * You should usually call [Builder.regressions] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun regressions(regressions: JsonField) = apply { this.regressions = regressions } /** Unit label for the metric */ fun unit(unit: String) = unit(JsonField.of(unit)) - /** Unit label for the metric */ + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun unit(unit: JsonField) = apply { this.unit = unit } /** Difference in metric between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) - /** Difference in metric between the current and comparison experiment */ + /** + * Sets [Builder.diff] to an arbitrary JSON value. + * + * You should usually call [Builder.diff] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun diff(diff: JsonField) = apply { this.diff = diff } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt index 9ebd640e..20aaf4ed 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt @@ -41,36 +41,81 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** ID of the original event. */ + /** + * ID of the original event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Transaction ID of the original event. */ + /** + * Transaction ID of the original event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** ID of the object the event is originating from. */ + /** + * ID of the object the event is originating from. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** Type of the object the event is originating from. */ + /** + * Type of the object the event is originating from. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): ObjectType = objectType.getRequired("object_type") - /** Created timestamp of the original event. Used to help sort in the UI */ + /** + * Created timestamp of the original event. Used to help sort in the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** ID of the original event. */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Transaction ID of the original event. */ + /** + * Returns the raw JSON value of [_xactId]. + * + * Unlike [_xactId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - /** ID of the object the event is originating from. */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** Type of the object the event is originating from. */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Created timestamp of the original event. Used to help sort in the UI */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created @JsonAnyGetter @@ -133,34 +178,60 @@ private constructor( /** ID of the original event. */ fun id(id: String) = id(JsonField.of(id)) - /** ID of the original event. */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Transaction ID of the original event. */ fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) - /** Transaction ID of the original event. */ + /** + * Sets [Builder._xactId] to an arbitrary JSON value. + * + * You should usually call [Builder._xactId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** ID of the object the event is originating from. */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** ID of the object the event is originating from. */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** Type of the object the event is originating from. */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - /** Type of the object the event is originating from. */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [ObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } /** Created timestamp of the original event. Used to help sort in the UI */ fun created(created: String?) = created(JsonField.ofNullable(created)) - /** Created timestamp of the original event. Used to help sort in the UI */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Created timestamp of the original event. Used to help sort in the UI */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun created(created: JsonField) = apply { this.created = created } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 6eb781e8..41ee565c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -50,34 +50,71 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The sampling rate for online scoring */ + /** + * The sampling rate for online scoring + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun samplingRate(): Double = samplingRate.getRequired("sampling_rate") - /** The list of scorers to use for online scoring */ + /** + * The list of scorers to use for online scoring + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun scorers(): List = scorers.getRequired("scorers") - /** Whether to trigger online scoring on the root span of each trace */ + /** + * Whether to trigger online scoring on the root span of each trace + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun applyToRootSpan(): Optional = Optional.ofNullable(applyToRootSpan.getNullable("apply_to_root_span")) - /** Trigger online scoring on any spans with a name in this list */ + /** + * Trigger online scoring on any spans with a name in this list + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun applyToSpanNames(): Optional> = Optional.ofNullable(applyToSpanNames.getNullable("apply_to_span_names")) - /** The sampling rate for online scoring */ + /** + * Returns the raw JSON value of [samplingRate]. + * + * Unlike [samplingRate], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("sampling_rate") @ExcludeMissing fun _samplingRate(): JsonField = samplingRate - /** The list of scorers to use for online scoring */ + /** + * Returns the raw JSON value of [scorers]. + * + * Unlike [scorers], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("scorers") @ExcludeMissing fun _scorers(): JsonField> = scorers - /** Whether to trigger online scoring on the root span of each trace */ + /** + * Returns the raw JSON value of [applyToRootSpan]. + * + * Unlike [applyToRootSpan], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("apply_to_root_span") @ExcludeMissing fun _applyToRootSpan(): JsonField = applyToRootSpan - /** Trigger online scoring on any spans with a name in this list */ + /** + * Returns the raw JSON value of [applyToSpanNames]. + * + * Unlike [applyToSpanNames], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("apply_to_span_names") @ExcludeMissing fun _applyToSpanNames(): JsonField> = applyToSpanNames @@ -137,7 +174,13 @@ private constructor( /** The sampling rate for online scoring */ fun samplingRate(samplingRate: Double) = samplingRate(JsonField.of(samplingRate)) - /** The sampling rate for online scoring */ + /** + * Sets [Builder.samplingRate] to an arbitrary JSON value. + * + * You should usually call [Builder.samplingRate] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun samplingRate(samplingRate: JsonField) = apply { this.samplingRate = samplingRate } @@ -145,12 +188,22 @@ private constructor( /** The list of scorers to use for online scoring */ fun scorers(scorers: List) = scorers(JsonField.of(scorers)) - /** The list of scorers to use for online scoring */ + /** + * Sets [Builder.scorers] to an arbitrary JSON value. + * + * You should usually call [Builder.scorers] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun scorers(scorers: JsonField>) = apply { this.scorers = scorers.map { it.toMutableList() } } - /** The list of scorers to use for online scoring */ + /** + * Adds a single [Scorer] to [scorers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addScorer(scorer: Scorer) = apply { scorers = (scorers ?: JsonField.of(mutableListOf())).also { @@ -158,24 +211,34 @@ private constructor( } } - /** The list of scorers to use for online scoring */ + /** Alias for calling [addScorer] with `Scorer.ofFunction(function)`. */ fun addScorer(function: Scorer.Function) = addScorer(Scorer.ofFunction(function)) - /** The list of scorers to use for online scoring */ + /** Alias for calling [addScorer] with `Scorer.ofGlobal(global)`. */ fun addScorer(global: Scorer.Global) = addScorer(Scorer.ofGlobal(global)) /** Whether to trigger online scoring on the root span of each trace */ fun applyToRootSpan(applyToRootSpan: Boolean?) = applyToRootSpan(JsonField.ofNullable(applyToRootSpan)) - /** Whether to trigger online scoring on the root span of each trace */ + /** + * Alias for [Builder.applyToRootSpan]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun applyToRootSpan(applyToRootSpan: Boolean) = applyToRootSpan(applyToRootSpan as Boolean?) - /** Whether to trigger online scoring on the root span of each trace */ + /** Alias for calling [Builder.applyToRootSpan] with `applyToRootSpan.orElse(null)`. */ fun applyToRootSpan(applyToRootSpan: Optional) = applyToRootSpan(applyToRootSpan.getOrNull()) - /** Whether to trigger online scoring on the root span of each trace */ + /** + * Sets [Builder.applyToRootSpan] to an arbitrary JSON value. + * + * You should usually call [Builder.applyToRootSpan] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun applyToRootSpan(applyToRootSpan: JsonField) = apply { this.applyToRootSpan = applyToRootSpan } @@ -184,16 +247,26 @@ private constructor( fun applyToSpanNames(applyToSpanNames: List?) = applyToSpanNames(JsonField.ofNullable(applyToSpanNames)) - /** Trigger online scoring on any spans with a name in this list */ + /** Alias for calling [Builder.applyToSpanNames] with `applyToSpanNames.orElse(null)`. */ fun applyToSpanNames(applyToSpanNames: Optional>) = applyToSpanNames(applyToSpanNames.getOrNull()) - /** Trigger online scoring on any spans with a name in this list */ + /** + * Sets [Builder.applyToSpanNames] to an arbitrary JSON value. + * + * You should usually call [Builder.applyToSpanNames] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun applyToSpanNames(applyToSpanNames: JsonField>) = apply { this.applyToSpanNames = applyToSpanNames.map { it.toMutableList() } } - /** Trigger online scoring on any spans with a name in this list */ + /** + * Adds a single [String] to [applyToSpanNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addApplyToSpanName(applyToSpanName: String) = apply { applyToSpanNames = (applyToSpanNames ?: JsonField.of(mutableListOf())).also { @@ -377,12 +450,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun id(): String = id.getRequired("id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -433,10 +526,24 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun id(id: JsonField) = apply { this.id = id } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -598,12 +705,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -654,10 +781,24 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 584931b5..fc1fc26e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -10,6 +10,7 @@ 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 @@ -43,42 +44,105 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the organization */ + /** + * Unique identifier for the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the organization */ + /** + * Name of the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) - /** Date of organization creation */ + /** + * Date of organization creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) - /** Unique identifier for the organization */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the organization */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [apiUrl]. + * + * Unlike [apiUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl - /** Date of organization creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + /** + * Returns the raw JSON value of [isUniversalApi]. + * + * Unlike [isUniversalApi], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi(): JsonField = isUniversalApi + /** + * Returns the raw JSON value of [proxyUrl]. + * + * Unlike [proxyUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl + /** + * Returns the raw JSON value of [realtimeUrl]. + * + * Unlike [realtimeUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("realtime_url") @ExcludeMissing fun _realtimeUrl(): JsonField = realtimeUrl @@ -147,52 +211,103 @@ private constructor( /** Unique identifier for the organization */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the organization */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the organization */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the organization */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) + /** Alias for calling [Builder.apiUrl] with `apiUrl.orElse(null)`. */ fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) + /** + * Sets [Builder.apiUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.apiUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } /** Date of organization creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of organization creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of organization creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } fun isUniversalApi(isUniversalApi: Boolean?) = isUniversalApi(JsonField.ofNullable(isUniversalApi)) + /** + * Alias for [Builder.isUniversalApi]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) + /** Alias for calling [Builder.isUniversalApi] with `isUniversalApi.orElse(null)`. */ fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) + /** + * Sets [Builder.isUniversalApi] to an arbitrary JSON value. + * + * You should usually call [Builder.isUniversalApi] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun isUniversalApi(isUniversalApi: JsonField) = apply { this.isUniversalApi = isUniversalApi } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) + /** Alias for calling [Builder.proxyUrl] with `proxyUrl.orElse(null)`. */ fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) + /** + * Sets [Builder.proxyUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.proxyUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) + /** Alias for calling [Builder.realtimeUrl] with `realtimeUrl.orElse(null)`. */ fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) + /** + * Sets [Builder.realtimeUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.realtimeUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index d01ebbf0..fae0f2e8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -126,13 +126,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -141,37 +135,32 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** @@ -183,13 +172,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index f75b1abe..350ff674 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -13,6 +13,7 @@ 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 @@ -29,13 +30,21 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Users to invite to the organization */ + /** + * Users to invite to the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun inviteUsers(): Optional = body.inviteUsers() /** * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, or in case you want to explicitly assert the * organization you are modifying, you may specify the id of the organization. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgId(): Optional = body.orgId() @@ -43,30 +52,46 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, or in case you want to explicitly assert the * organization you are modifying, you may specify the name of the organization. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() - /** Users to remove from the organization */ + /** + * Users to remove from the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun removeUsers(): Optional = body.removeUsers() - /** Users to invite to the organization */ + /** + * Returns the raw JSON value of [inviteUsers]. + * + * Unlike [inviteUsers], this method doesn't throw if the JSON field has an unexpected type. + */ fun _inviteUsers(): JsonField = body._inviteUsers() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the id of the organization. + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgId(): JsonField = body._orgId() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, or in case you want to explicitly assert the - * organization you are modifying, you may specify the name of the organization. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() - /** Users to remove from the organization */ + /** + * Returns the raw JSON value of [removeUsers]. + * + * Unlike [removeUsers], this method doesn't throw if the JSON field has an unexpected type. + */ fun _removeUsers(): JsonField = body._removeUsers() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -101,7 +126,12 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Users to invite to the organization */ + /** + * Users to invite to the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun inviteUsers(): Optional = Optional.ofNullable(inviteUsers.getNullable("invite_users")) @@ -109,6 +139,9 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, or in case you want to explicitly assert * the organization you are modifying, you may specify the id of the organization. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) @@ -116,33 +149,49 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, or in case you want to explicitly assert * the organization you are modifying, you may specify the name of the organization. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) - /** Users to remove from the organization */ + /** + * Users to remove from the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun removeUsers(): Optional = Optional.ofNullable(removeUsers.getNullable("remove_users")) - /** Users to invite to the organization */ + /** + * Returns the raw JSON value of [inviteUsers]. + * + * Unlike [inviteUsers], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("invite_users") @ExcludeMissing fun _inviteUsers(): JsonField = inviteUsers /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName - /** Users to remove from the organization */ + /** + * Returns the raw JSON value of [removeUsers]. + * + * Unlike [removeUsers], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("remove_users") @ExcludeMissing fun _removeUsers(): JsonField = removeUsers @@ -195,11 +244,17 @@ private constructor( fun inviteUsers(inviteUsers: InviteUsers?) = inviteUsers(JsonField.ofNullable(inviteUsers)) - /** Users to invite to the organization */ + /** Alias for calling [Builder.inviteUsers] with `inviteUsers.orElse(null)`. */ fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) - /** Users to invite to the organization */ + /** + * Sets [Builder.inviteUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteUsers] with a well-typed [InviteUsers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun inviteUsers(inviteUsers: JsonField) = apply { this.inviteUsers = inviteUsers } @@ -212,19 +267,15 @@ private constructor( */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the id of the - * organization. - */ + /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the id of the - * organization. + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } @@ -236,19 +287,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the name of the - * organization. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly - * assert the organization you are modifying, you may specify the name of the - * organization. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -256,11 +303,17 @@ private constructor( fun removeUsers(removeUsers: RemoveUsers?) = removeUsers(JsonField.ofNullable(removeUsers)) - /** Users to remove from the organization */ + /** Alias for calling [Builder.removeUsers] with `removeUsers.orElse(null)`. */ fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) - /** Users to remove from the organization */ + /** + * Sets [Builder.removeUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.removeUsers] with a well-typed [RemoveUsers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun removeUsers(removeUsers: JsonField) = apply { this.removeUsers = removeUsers } @@ -337,10 +390,16 @@ private constructor( /** Users to invite to the organization */ fun inviteUsers(inviteUsers: InviteUsers?) = apply { body.inviteUsers(inviteUsers) } - /** Users to invite to the organization */ + /** Alias for calling [Builder.inviteUsers] with `inviteUsers.orElse(null)`. */ fun inviteUsers(inviteUsers: Optional) = inviteUsers(inviteUsers.getOrNull()) - /** Users to invite to the organization */ + /** + * Sets [Builder.inviteUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteUsers] with a well-typed [InviteUsers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun inviteUsers(inviteUsers: JsonField) = apply { body.inviteUsers(inviteUsers) } @@ -352,17 +411,14 @@ private constructor( */ fun orgId(orgId: String?) = apply { body.orgId(orgId) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. - */ + /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the id of the organization. + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgId(orgId: JsonField) = apply { body.orgId(orgId) } @@ -373,27 +429,30 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, or in case you want to explicitly assert - * the organization you are modifying, you may specify the name of the organization. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } /** Users to remove from the organization */ fun removeUsers(removeUsers: RemoveUsers?) = apply { body.removeUsers(removeUsers) } - /** Users to remove from the organization */ + /** Alias for calling [Builder.removeUsers] with `removeUsers.orElse(null)`. */ fun removeUsers(removeUsers: Optional) = removeUsers(removeUsers.getOrNull()) - /** Users to remove from the organization */ + /** + * Sets [Builder.removeUsers] to an arbitrary JSON value. + * + * You should usually call [Builder.removeUsers] with a well-typed [RemoveUsers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun removeUsers(removeUsers: JsonField) = apply { body.removeUsers(removeUsers) } @@ -553,53 +612,117 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Emails of users to invite */ + /** + * Emails of users to invite + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun emails(): Optional> = Optional.ofNullable(emails.getNullable("emails")) - /** Singular form of group_ids */ + /** + * Singular form of group_ids + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun groupId(): Optional = Optional.ofNullable(groupId.getNullable("group_id")) - /** Optional list of group ids to add newly-invited users to. */ + /** + * Optional list of group ids to add newly-invited users to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun groupIds(): Optional> = Optional.ofNullable(groupIds.getNullable("group_ids")) - /** Singular form of group_names */ + /** + * Singular form of group_names + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun groupName(): Optional = Optional.ofNullable(groupName.getNullable("group_name")) - /** Optional list of group names to add newly-invited users to. */ + /** + * Optional list of group names to add newly-invited users to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun groupNames(): Optional> = Optional.ofNullable(groupNames.getNullable("group_names")) - /** Ids of existing users to invite */ + /** + * Ids of existing users to invite + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) - /** If true, send invite emails to the users who wore actually added */ + /** + * If true, send invite emails to the users who wore actually added + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun sendInviteEmails(): Optional = Optional.ofNullable(sendInviteEmails.getNullable("send_invite_emails")) - /** Emails of users to invite */ + /** + * Returns the raw JSON value of [emails]. + * + * Unlike [emails], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails - /** Singular form of group_ids */ + /** + * Returns the raw JSON value of [groupId]. + * + * Unlike [groupId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("group_id") @ExcludeMissing fun _groupId(): JsonField = groupId - /** Optional list of group ids to add newly-invited users to. */ + /** + * Returns the raw JSON value of [groupIds]. + * + * Unlike [groupIds], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("group_ids") @ExcludeMissing fun _groupIds(): JsonField> = groupIds - /** Singular form of group_names */ + /** + * Returns the raw JSON value of [groupName]. + * + * Unlike [groupName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("group_name") @ExcludeMissing fun _groupName(): JsonField = groupName - /** Optional list of group names to add newly-invited users to. */ + /** + * Returns the raw JSON value of [groupNames]. + * + * Unlike [groupNames], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("group_names") @ExcludeMissing fun _groupNames(): JsonField> = groupNames - /** Ids of existing users to invite */ + /** + * Returns the raw JSON value of [ids]. + * + * Unlike [ids], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids - /** If true, send invite emails to the users who wore actually added */ + /** + * Returns the raw JSON value of [sendInviteEmails]. + * + * Unlike [sendInviteEmails], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("send_invite_emails") @ExcludeMissing fun _sendInviteEmails(): JsonField = sendInviteEmails @@ -660,15 +783,25 @@ private constructor( /** Emails of users to invite */ fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) - /** Emails of users to invite */ + /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ fun emails(emails: Optional>) = emails(emails.getOrNull()) - /** Emails of users to invite */ + /** + * Sets [Builder.emails] to an arbitrary JSON value. + * + * You should usually call [Builder.emails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun emails(emails: JsonField>) = apply { this.emails = emails.map { it.toMutableList() } } - /** Emails of users to invite */ + /** + * Adds a single [String] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEmail(email: String) = apply { emails = (emails ?: JsonField.of(mutableListOf())).also { @@ -679,24 +812,40 @@ private constructor( /** Singular form of group_ids */ fun groupId(groupId: String?) = groupId(JsonField.ofNullable(groupId)) - /** Singular form of group_ids */ + /** Alias for calling [Builder.groupId] with `groupId.orElse(null)`. */ fun groupId(groupId: Optional) = groupId(groupId.getOrNull()) - /** Singular form of group_ids */ + /** + * Sets [Builder.groupId] to an arbitrary JSON value. + * + * You should usually call [Builder.groupId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun groupId(groupId: JsonField) = apply { this.groupId = groupId } /** Optional list of group ids to add newly-invited users to. */ fun groupIds(groupIds: List?) = groupIds(JsonField.ofNullable(groupIds)) - /** Optional list of group ids to add newly-invited users to. */ + /** Alias for calling [Builder.groupIds] with `groupIds.orElse(null)`. */ fun groupIds(groupIds: Optional>) = groupIds(groupIds.getOrNull()) - /** Optional list of group ids to add newly-invited users to. */ + /** + * Sets [Builder.groupIds] to an arbitrary JSON value. + * + * You should usually call [Builder.groupIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun groupIds(groupIds: JsonField>) = apply { this.groupIds = groupIds.map { it.toMutableList() } } - /** Optional list of group ids to add newly-invited users to. */ + /** + * Adds a single [String] to [groupIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addGroupId(groupId: String) = apply { groupIds = (groupIds ?: JsonField.of(mutableListOf())).also { @@ -707,24 +856,40 @@ private constructor( /** Singular form of group_names */ fun groupName(groupName: String?) = groupName(JsonField.ofNullable(groupName)) - /** Singular form of group_names */ + /** Alias for calling [Builder.groupName] with `groupName.orElse(null)`. */ fun groupName(groupName: Optional) = groupName(groupName.getOrNull()) - /** Singular form of group_names */ + /** + * Sets [Builder.groupName] to an arbitrary JSON value. + * + * You should usually call [Builder.groupName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun groupName(groupName: JsonField) = apply { this.groupName = groupName } /** Optional list of group names to add newly-invited users to. */ fun groupNames(groupNames: List?) = groupNames(JsonField.ofNullable(groupNames)) - /** Optional list of group names to add newly-invited users to. */ + /** Alias for calling [Builder.groupNames] with `groupNames.orElse(null)`. */ fun groupNames(groupNames: Optional>) = groupNames(groupNames.getOrNull()) - /** Optional list of group names to add newly-invited users to. */ + /** + * Sets [Builder.groupNames] to an arbitrary JSON value. + * + * You should usually call [Builder.groupNames] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun groupNames(groupNames: JsonField>) = apply { this.groupNames = groupNames.map { it.toMutableList() } } - /** Optional list of group names to add newly-invited users to. */ + /** + * Adds a single [String] to [groupNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addGroupName(groupName: String) = apply { groupNames = (groupNames ?: JsonField.of(mutableListOf())).also { @@ -735,15 +900,25 @@ private constructor( /** Ids of existing users to invite */ fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) - /** Ids of existing users to invite */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional>) = ids(ids.getOrNull()) - /** Ids of existing users to invite */ + /** + * Sets [Builder.ids] to an arbitrary JSON value. + * + * You should usually call [Builder.ids] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun ids(ids: JsonField>) = apply { this.ids = ids.map { it.toMutableList() } } - /** Ids of existing users to invite */ + /** + * Adds a single [String] to [ids]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addId(id: String) = apply { ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } } @@ -752,15 +927,27 @@ private constructor( fun sendInviteEmails(sendInviteEmails: Boolean?) = sendInviteEmails(JsonField.ofNullable(sendInviteEmails)) - /** If true, send invite emails to the users who wore actually added */ + /** + * Alias for [Builder.sendInviteEmails]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun sendInviteEmails(sendInviteEmails: Boolean) = sendInviteEmails(sendInviteEmails as Boolean?) - /** If true, send invite emails to the users who wore actually added */ + /** + * Alias for calling [Builder.sendInviteEmails] with `sendInviteEmails.orElse(null)`. + */ fun sendInviteEmails(sendInviteEmails: Optional) = sendInviteEmails(sendInviteEmails.getOrNull()) - /** If true, send invite emails to the users who wore actually added */ + /** + * Sets [Builder.sendInviteEmails] to an arbitrary JSON value. + * + * You should usually call [Builder.sendInviteEmails] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun sendInviteEmails(sendInviteEmails: JsonField) = apply { this.sendInviteEmails = sendInviteEmails } @@ -830,16 +1017,34 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Emails of users to remove */ + /** + * Emails of users to remove + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun emails(): Optional> = Optional.ofNullable(emails.getNullable("emails")) - /** Ids of users to remove */ + /** + * Ids of users to remove + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun ids(): Optional> = Optional.ofNullable(ids.getNullable("ids")) - /** Emails of users to remove */ + /** + * Returns the raw JSON value of [emails]. + * + * Unlike [emails], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails - /** Ids of users to remove */ + /** + * Returns the raw JSON value of [ids]. + * + * Unlike [ids], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("ids") @ExcludeMissing fun _ids(): JsonField> = ids @JsonAnyGetter @@ -883,15 +1088,25 @@ private constructor( /** Emails of users to remove */ fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) - /** Emails of users to remove */ + /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ fun emails(emails: Optional>) = emails(emails.getOrNull()) - /** Emails of users to remove */ + /** + * Sets [Builder.emails] to an arbitrary JSON value. + * + * You should usually call [Builder.emails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun emails(emails: JsonField>) = apply { this.emails = emails.map { it.toMutableList() } } - /** Emails of users to remove */ + /** + * Adds a single [String] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEmail(email: String) = apply { emails = (emails ?: JsonField.of(mutableListOf())).also { @@ -902,15 +1117,25 @@ private constructor( /** Ids of users to remove */ fun ids(ids: List?) = ids(JsonField.ofNullable(ids)) - /** Ids of users to remove */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional>) = ids(ids.getOrNull()) - /** Ids of users to remove */ + /** + * Sets [Builder.ids] to an arbitrary JSON value. + * + * You should usually call [Builder.ids] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun ids(ids: JsonField>) = apply { this.ids = ids.map { it.toMutableList() } } - /** Ids of users to remove */ + /** + * Adds a single [String] to [ids]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addId(id: String) = apply { ids = (ids ?: JsonField.of(mutableListOf())).also { checkKnown("ids", it).add(id) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 83efeac1..21c12848 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -13,6 +13,7 @@ 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,26 +38,71 @@ private constructor( /** Organization id */ fun organizationId(): String = organizationId + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun apiUrl(): Optional = body.apiUrl() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun isUniversalApi(): Optional = body.isUniversalApi() - /** Name of the organization */ + /** + * Name of the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun proxyUrl(): Optional = body.proxyUrl() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun realtimeUrl(): Optional = body.realtimeUrl() + /** + * Returns the raw JSON value of [apiUrl]. + * + * Unlike [apiUrl], this method doesn't throw if the JSON field has an unexpected type. + */ fun _apiUrl(): JsonField = body._apiUrl() + /** + * Returns the raw JSON value of [isUniversalApi]. + * + * Unlike [isUniversalApi], this method doesn't throw if the JSON field has an unexpected type. + */ fun _isUniversalApi(): JsonField = body._isUniversalApi() - /** Name of the organization */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() + /** + * Returns the raw JSON value of [proxyUrl]. + * + * Unlike [proxyUrl], this method doesn't throw if the JSON field has an unexpected type. + */ fun _proxyUrl(): JsonField = body._proxyUrl() + /** + * Returns the raw JSON value of [realtimeUrl]. + * + * Unlike [realtimeUrl], this method doesn't throw if the JSON field has an unexpected type. + */ fun _realtimeUrl(): JsonField = body._realtimeUrl() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -101,30 +147,76 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun apiUrl(): Optional = Optional.ofNullable(apiUrl.getNullable("api_url")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun isUniversalApi(): Optional = Optional.ofNullable(isUniversalApi.getNullable("is_universal_api")) - /** Name of the organization */ + /** + * Name of the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun proxyUrl(): Optional = Optional.ofNullable(proxyUrl.getNullable("proxy_url")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun realtimeUrl(): Optional = Optional.ofNullable(realtimeUrl.getNullable("realtime_url")) + /** + * Returns the raw JSON value of [apiUrl]. + * + * Unlike [apiUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("api_url") @ExcludeMissing fun _apiUrl(): JsonField = apiUrl + /** + * Returns the raw JSON value of [isUniversalApi]. + * + * Unlike [isUniversalApi], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi(): JsonField = isUniversalApi - /** Name of the organization */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [proxyUrl]. + * + * Unlike [proxyUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl(): JsonField = proxyUrl + /** + * Returns the raw JSON value of [realtimeUrl]. + * + * Unlike [realtimeUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("realtime_url") @ExcludeMissing fun _realtimeUrl(): JsonField = realtimeUrl @@ -178,18 +270,39 @@ private constructor( fun apiUrl(apiUrl: String?) = apiUrl(JsonField.ofNullable(apiUrl)) + /** Alias for calling [Builder.apiUrl] with `apiUrl.orElse(null)`. */ fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) + /** + * Sets [Builder.apiUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.apiUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } fun isUniversalApi(isUniversalApi: Boolean?) = isUniversalApi(JsonField.ofNullable(isUniversalApi)) + /** + * Alias for [Builder.isUniversalApi]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) + /** Alias for calling [Builder.isUniversalApi] with `isUniversalApi.orElse(null)`. */ fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) + /** + * Sets [Builder.isUniversalApi] to an arbitrary JSON value. + * + * You should usually call [Builder.isUniversalApi] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun isUniversalApi(isUniversalApi: JsonField) = apply { this.isUniversalApi = isUniversalApi } @@ -197,22 +310,44 @@ private constructor( /** Name of the organization */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the organization */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the organization */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } fun proxyUrl(proxyUrl: String?) = proxyUrl(JsonField.ofNullable(proxyUrl)) + /** Alias for calling [Builder.proxyUrl] with `proxyUrl.orElse(null)`. */ fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) + /** + * Sets [Builder.proxyUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.proxyUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } fun realtimeUrl(realtimeUrl: String?) = realtimeUrl(JsonField.ofNullable(realtimeUrl)) + /** Alias for calling [Builder.realtimeUrl] with `realtimeUrl.orElse(null)`. */ fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) + /** + * Sets [Builder.realtimeUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.realtimeUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } @@ -302,17 +437,37 @@ private constructor( fun apiUrl(apiUrl: String?) = apply { body.apiUrl(apiUrl) } + /** Alias for calling [Builder.apiUrl] with `apiUrl.orElse(null)`. */ fun apiUrl(apiUrl: Optional) = apiUrl(apiUrl.getOrNull()) + /** + * Sets [Builder.apiUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.apiUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun apiUrl(apiUrl: JsonField) = apply { body.apiUrl(apiUrl) } fun isUniversalApi(isUniversalApi: Boolean?) = apply { body.isUniversalApi(isUniversalApi) } + /** + * Alias for [Builder.isUniversalApi]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(isUniversalApi as Boolean?) + /** Alias for calling [Builder.isUniversalApi] with `isUniversalApi.orElse(null)`. */ fun isUniversalApi(isUniversalApi: Optional) = isUniversalApi(isUniversalApi.getOrNull()) + /** + * Sets [Builder.isUniversalApi] to an arbitrary JSON value. + * + * You should usually call [Builder.isUniversalApi] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun isUniversalApi(isUniversalApi: JsonField) = apply { body.isUniversalApi(isUniversalApi) } @@ -320,22 +475,42 @@ private constructor( /** Name of the organization */ fun name(name: String?) = apply { body.name(name) } - /** Name of the organization */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the organization */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } fun proxyUrl(proxyUrl: String?) = apply { body.proxyUrl(proxyUrl) } + /** Alias for calling [Builder.proxyUrl] with `proxyUrl.orElse(null)`. */ fun proxyUrl(proxyUrl: Optional) = proxyUrl(proxyUrl.getOrNull()) + /** + * Sets [Builder.proxyUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.proxyUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun proxyUrl(proxyUrl: JsonField) = apply { body.proxyUrl(proxyUrl) } fun realtimeUrl(realtimeUrl: String?) = apply { body.realtimeUrl(realtimeUrl) } + /** Alias for calling [Builder.realtimeUrl] with `realtimeUrl.orElse(null)`. */ fun realtimeUrl(realtimeUrl: Optional) = realtimeUrl(realtimeUrl.getOrNull()) + /** + * Sets [Builder.realtimeUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.realtimeUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun realtimeUrl(realtimeUrl: JsonField) = apply { body.realtimeUrl(realtimeUrl) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index c1bb28cb..b93608b6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -34,26 +34,48 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the org that was modified. */ + /** + * The id of the org that was modified. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun orgId(): String = orgId.getRequired("org_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun status(): Status = status.getRequired("status") /** * If invite emails failed to send for some reason, the patch operation will still complete, but * we will return an error message here + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun sendEmailError(): Optional = Optional.ofNullable(sendEmailError.getNullable("send_email_error")) - /** The id of the org that was modified. */ + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** - * If invite emails failed to send for some reason, the patch operation will still complete, but - * we will return an error message here + * Returns the raw JSON value of [sendEmailError]. + * + * Unlike [sendEmailError], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("send_email_error") @ExcludeMissing @@ -113,11 +135,22 @@ private constructor( /** The id of the org that was modified. */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - /** The id of the org that was modified. */ + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } fun status(status: Status) = status(JsonField.of(status)) + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun status(status: JsonField) = apply { this.status = status } /** @@ -127,16 +160,16 @@ private constructor( fun sendEmailError(sendEmailError: String?) = sendEmailError(JsonField.ofNullable(sendEmailError)) - /** - * If invite emails failed to send for some reason, the patch operation will still complete, - * but we will return an error message here - */ + /** Alias for calling [Builder.sendEmailError] with `sendEmailError.orElse(null)`. */ fun sendEmailError(sendEmailError: Optional) = sendEmailError(sendEmailError.getOrNull()) /** - * If invite emails failed to send for some reason, the patch operation will still complete, - * but we will return an error message here + * Sets [Builder.sendEmailError] to an arbitrary JSON value. + * + * You should usually call [Builder.sendEmailError] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun sendEmailError(sendEmailError: JsonField) = apply { this.sendEmailError = sendEmailError diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 8da4413e..4c402f51 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -10,6 +10,7 @@ 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 @@ -41,48 +42,111 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the project */ + /** + * Unique identifier for the project + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the project */ + /** + * Name of the project + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique id for the organization that the project belongs under */ + /** + * Unique id for the organization that the project belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun orgId(): String = orgId.getRequired("org_id") - /** Date of project creation */ + /** + * Date of project creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Date of project deletion, or null if the project is still active */ + /** + * Date of project deletion, or null if the project is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) - /** Identifies the user who created the project */ + /** + * Identifies the user who created the project + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the project */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the project */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique id for the organization that the project belongs under */ + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Date of project creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Date of project deletion, or null if the project is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt + /** + * Returns the raw JSON value of [settings]. + * + * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonField = settings - /** Identifies the user who created the project */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @@ -150,52 +214,92 @@ private constructor( /** Unique identifier for the project */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the project */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the project */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - /** Unique id for the organization that the project belongs under */ + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Date of project creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of project creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of project creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Date of project deletion, or null if the project is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of project deletion, or null if the project is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of project deletion, or null if the project is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) + /** Alias for calling [Builder.settings] with `settings.orElse(null)`. */ fun settings(settings: Optional) = settings(settings.getOrNull()) + /** + * Sets [Builder.settings] to an arbitrary JSON value. + * + * You should usually call [Builder.settings] with a well-typed [ProjectSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun settings(settings: JsonField) = apply { this.settings = settings } /** Identifies the user who created the project */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the project */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the project */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 6d92a603..7a08ff1b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,23 +33,35 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the project */ + /** + * Name of the project + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() /** * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * project belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() - /** Name of the project */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * project belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() @@ -78,23 +91,35 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the project */ + /** + * Name of the project + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") /** * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the project belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) - /** Name of the project */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @@ -146,7 +171,13 @@ private constructor( /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the project */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** @@ -156,17 +187,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -244,7 +273,12 @@ private constructor( /** Name of the project */ fun name(name: String) = apply { body.name(name) } - /** Name of the project */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** @@ -254,17 +288,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the project belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index c011f50b..e28ba4aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -133,13 +133,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -148,43 +142,38 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } - /** Name of the project to search for */ + /** Alias for calling [Builder.projectName] with `projectName.orElse(null)`. */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** @@ -196,13 +185,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index ea2b6b82..2ca20280 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -14,6 +14,7 @@ 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 @@ -32,10 +33,19 @@ private constructor( /** Project id */ fun projectId(): String = projectId - /** A list of project logs feedback items */ + /** + * A list of project logs feedback items + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun feedback(): List = body.feedback() - /** A list of project logs feedback items */ + /** + * Returns the raw JSON value of [feedback]. + * + * Unlike [feedback], this method doesn't throw if the JSON field has an unexpected type. + */ fun _feedback(): JsonField> = body._feedback() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -68,10 +78,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of project logs feedback items */ + /** + * A list of project logs feedback items + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun feedback(): List = feedback.getRequired("feedback") - /** A list of project logs feedback items */ + /** + * Returns the raw JSON value of [feedback]. + * + * Unlike [feedback], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("feedback") @ExcludeMissing fun _feedback(): JsonField> = feedback @@ -121,12 +140,22 @@ private constructor( /** A list of project logs feedback items */ fun feedback(feedback: List) = feedback(JsonField.of(feedback)) - /** A list of project logs feedback items */ + /** + * Sets [Builder.feedback] to an arbitrary JSON value. + * + * You should usually call [Builder.feedback] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ fun feedback(feedback: JsonField>) = apply { this.feedback = feedback.map { it.toMutableList() } } - /** A list of project logs feedback items */ + /** + * Adds a single [FeedbackProjectLogsItem] to [Builder.feedback]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { this.feedback = (this.feedback ?: JsonField.of(mutableListOf())).also { @@ -217,12 +246,22 @@ private constructor( /** A list of project logs feedback items */ fun feedback(feedback: List) = apply { body.feedback(feedback) } - /** A list of project logs feedback items */ + /** + * Sets [Builder.feedback] to an arbitrary JSON value. + * + * You should usually call [Builder.feedback] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun feedback(feedback: JsonField>) = apply { body.feedback(feedback) } - /** A list of project logs feedback items */ + /** + * Adds a single [FeedbackProjectLogsItem] to [Builder.feedback]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { body.addFeedback(feedback) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 1d82f560..5d240328 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -164,37 +164,13 @@ private constructor( fun limit(limit: Long?) = apply { this.limit = limit } /** - * limit the number of traces fetched + * Alias for [Builder.limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** @@ -211,18 +187,7 @@ private constructor( */ fun maxRootSpanId(maxRootSpanId: String?) = apply { this.maxRootSpanId = maxRootSpanId } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) @@ -240,18 +205,7 @@ private constructor( */ fun maxXactId(maxXactId: String?) = apply { this.maxXactId = maxXactId } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** @@ -262,12 +216,7 @@ private constructor( */ fun version(version: String?) = apply { this.version = version } - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 4eb11877..bb400c64 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -13,6 +13,7 @@ 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 @@ -42,6 +43,9 @@ private constructor( * earliest. * * The string can be obtained directly from the `cursor` property of the previous fetch query + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun cursor(): Optional = body.cursor() @@ -58,6 +62,9 @@ private constructor( * * The `limit` parameter controls the number of full traces to return. So you may end up with * more individual rows than the specified limit if you are fetching events containing traces. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun limit(): Optional = body.limit() @@ -72,6 +79,9 @@ private constructor( * for the next page can be found as the row with the minimum (earliest) value of the tuple * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating * fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun maxRootSpanId(): Optional = body.maxRootSpanId() @@ -86,6 +96,9 @@ private constructor( * for the next page can be found as the row with the minimum (earliest) value of the tuple * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating * fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun maxXactId(): Optional = body.maxXactId() @@ -94,66 +107,44 @@ private constructor( * * The version id is essentially a filter on the latest event transaction id. You can use the * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun version(): Optional = body.version() /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. + * Returns the raw JSON value of [cursor]. * - * The string can be obtained directly from the `cursor` property of the previous fetch query + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ fun _cursor(): JsonField = body._cursor() /** - * limit the number of traces fetched + * Returns the raw JSON value of [limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. */ fun _limit(): JsonField = body._limit() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * Returns the raw JSON value of [maxRootSpanId]. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Unlike [maxRootSpanId], this method doesn't throw if the JSON field has an unexpected type. */ fun _maxRootSpanId(): JsonField = body._maxRootSpanId() /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. + * Returns the raw JSON value of [maxXactId]. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. + * Unlike [maxXactId], this method doesn't throw if the JSON field has an unexpected type. */ fun _maxXactId(): JsonField = body._maxXactId() /** - * Retrieve a snapshot of events from a past time + * Returns the raw JSON value of [version]. * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. */ fun _version(): JsonField = body._version() @@ -205,6 +196,9 @@ private constructor( * * The string can be obtained directly from the `cursor` property of the previous fetch * query + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun cursor(): Optional = Optional.ofNullable(cursor.getNullable("cursor")) @@ -222,6 +216,9 @@ private constructor( * The `limit` parameter controls the number of full traces to return. So you may end up * with more individual rows than the specified limit if you are fetching events containing * traces. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) @@ -236,6 +233,9 @@ private constructor( * cursor for the next page can be found as the row with the minimum (earliest) value of the * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun maxRootSpanId(): Optional = Optional.ofNullable(maxRootSpanId.getNullable("max_root_span_id")) @@ -251,6 +251,9 @@ private constructor( * cursor for the next page can be found as the row with the minimum (earliest) value of the * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of * paginating fetch queries. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun maxXactId(): Optional = Optional.ofNullable(maxXactId.getNullable("max_xact_id")) @@ -260,70 +263,47 @@ private constructor( * * The version id is essentially a filter on the latest event transaction id. You can use * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun version(): Optional = Optional.ofNullable(version.getNullable("version")) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Returns the raw JSON value of [cursor]. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. + * Returns the raw JSON value of [limit]. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Returns the raw JSON value of [maxRootSpanId]. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Unlike [maxRootSpanId], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId(): JsonField = maxRootSpanId /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Returns the raw JSON value of [maxXactId]. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Unlike [maxXactId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("max_xact_id") @ExcludeMissing fun _maxXactId(): JsonField = maxXactId /** - * Retrieve a snapshot of events from a past time + * Returns the raw JSON value of [version]. * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @@ -383,21 +363,15 @@ private constructor( */ fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Sets [Builder.cursor] to an arbitrary JSON value. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * You should usually call [Builder.cursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun cursor(cursor: JsonField) = apply { this.cursor = cursor } @@ -419,53 +393,21 @@ private constructor( fun limit(limit: Long?) = limit(JsonField.ofNullable(limit)) /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. + * Alias for [Builder.limit]. * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * limit the number of traces fetched + * Sets [Builder.limit] to an arbitrary JSON value. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of - * the event log. You will most likely want to exclude any such duplicate, outdated rows - * (by `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events - * containing traces. + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun limit(limit: JsonField) = apply { this.limit = limit } @@ -484,32 +426,16 @@ private constructor( fun maxRootSpanId(maxRootSpanId: String?) = maxRootSpanId(JsonField.ofNullable(maxRootSpanId)) - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. + * Sets [Builder.maxRootSpanId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * You should usually call [Builder.maxRootSpanId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun maxRootSpanId(maxRootSpanId: JsonField) = apply { this.maxRootSpanId = maxRootSpanId @@ -529,31 +455,15 @@ private constructor( */ fun maxXactId(maxXactId: String?) = maxXactId(JsonField.ofNullable(maxXactId)) - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor - * of the explicit 'cursor' returned by object fetch requests. Please prefer the - * 'cursor' argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor + * Sets [Builder.maxXactId] to an arbitrary JSON value. * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of - * the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an - * overview of paginating fetch queries. + * You should usually call [Builder.maxXactId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } @@ -566,21 +476,15 @@ private constructor( */ fun version(version: String?) = version(JsonField.ofNullable(version)) - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) /** - * Retrieve a snapshot of events from a past time + * Sets [Builder.version] to an arbitrary JSON value. * - * The version id is essentially a filter on the latest event transaction id. You can - * use the `max_xact_id` returned by a past fetch as the version to reproduce that exact - * fetch. + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun version(version: JsonField) = apply { this.version = version } @@ -676,21 +580,14 @@ private constructor( */ fun cursor(cursor: String?) = apply { body.cursor(cursor) } - /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query - */ + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * Sets [Builder.cursor] to an arbitrary JSON value. * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun cursor(cursor: JsonField) = apply { body.cursor(cursor) } @@ -712,53 +609,20 @@ private constructor( fun limit(limit: Long?) = apply { body.limit(limit) } /** - * limit the number of traces fetched + * Alias for [Builder.limit]. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * This unboxed primitive overload exists for backwards compatibility. */ fun limit(limit: Long) = limit(limit as Long?) - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. - */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * limit the number of traces fetched + * Sets [Builder.limit] to an arbitrary JSON value. * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun limit(limit: JsonField) = apply { body.limit(limit) } @@ -776,32 +640,16 @@ private constructor( */ fun maxRootSpanId(maxRootSpanId: String?) = apply { body.maxRootSpanId(maxRootSpanId) } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxRootSpanId] with `maxRootSpanId.orElse(null)`. */ fun maxRootSpanId(maxRootSpanId: Optional) = maxRootSpanId(maxRootSpanId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * Sets [Builder.maxRootSpanId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * You should usually call [Builder.maxRootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun maxRootSpanId(maxRootSpanId: JsonField) = apply { body.maxRootSpanId(maxRootSpanId) @@ -821,31 +669,15 @@ private constructor( */ fun maxXactId(maxXactId: String?) = apply { body.maxXactId(maxXactId) } - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ + /** Alias for calling [Builder.maxXactId] with `maxXactId.orElse(null)`. */ fun maxXactId(maxXactId: Optional) = maxXactId(maxXactId.getOrNull()) /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * Sets [Builder.maxXactId] to an arbitrary JSON value. * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * You should usually call [Builder.maxXactId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun maxXactId(maxXactId: JsonField) = apply { body.maxXactId(maxXactId) } @@ -857,19 +689,14 @@ private constructor( */ fun version(version: String?) = apply { body.version(version) } - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) /** - * Retrieve a snapshot of events from a past time + * Sets [Builder.version] to an arbitrary JSON value. * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun version(version: JsonField) = apply { body.version(version) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 00032977..040efe5b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -14,6 +14,7 @@ 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 @@ -32,10 +33,19 @@ private constructor( /** Project id */ fun projectId(): String = projectId - /** A list of project logs events to insert */ + /** + * A list of project logs events to insert + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = body.events() - /** A list of project logs events to insert */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ fun _events(): JsonField> = body._events() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -68,10 +78,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of project logs events to insert */ + /** + * A list of project logs events to insert + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun events(): List = events.getRequired("events") - /** A list of project logs events to insert */ + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events @@ -121,12 +140,22 @@ private constructor( /** A list of project logs events to insert */ fun events(events: List) = events(JsonField.of(events)) - /** A list of project logs events to insert */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ fun events(events: JsonField>) = apply { this.events = events.map { it.toMutableList() } } - /** A list of project logs events to insert */ + /** + * Adds a single [InsertProjectLogsEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: InsertProjectLogsEvent) = apply { events = (events ?: JsonField.of(mutableListOf())).also { @@ -216,10 +245,20 @@ private constructor( /** A list of project logs events to insert */ fun events(events: List) = apply { body.events(events) } - /** A list of project logs events to insert */ + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun events(events: JsonField>) = apply { body.events(events) } - /** A list of project logs events to insert */ + /** + * Adds a single [InsertProjectLogsEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addEvent(event: InsertProjectLogsEvent) = apply { body.addEvent(event) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 760777fa..c45131c8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -81,6 +81,9 @@ private constructor( /** * A unique identifier for the project logs event. If you don't provide one, BrainTrust will * generate one for you + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun id(): String = id.getRequired("id") @@ -88,28 +91,59 @@ private constructor( * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the project logs (see the `version` parameter) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** The timestamp the project logs event was created */ + /** + * The timestamp the project logs event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun created(): OffsetDateTime = created.getRequired("created") - /** A literal 'g' which identifies the log as a project log */ + /** + * A literal 'g' which identifies the log as a project log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun logId(): LogId = logId.getRequired("log_id") - /** Unique id for the organization that the project belongs under */ + /** + * Unique id for the organization that the project belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun orgId(): String = orgId.getRequired("org_id") - /** Unique identifier for the project */ + /** + * Unique identifier for the project + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** A unique identifier for the trace this project logs event belongs to */ + /** + * A unique identifier for the trace this project logs event belongs to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") /** * A unique identifier used to link different project logs events together as part of a full * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full * details on tracing + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun spanId(): String = spanId.getRequired("span_id") @@ -117,6 +151,9 @@ private constructor( * Context is additional information about the code that produced the project logs event. It is * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the * location in code which produced the project logs event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun context(): Optional = Optional.ofNullable(context.getNullable("context")) @@ -136,7 +173,12 @@ private constructor( /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ @JsonProperty("input") @ExcludeMissing fun _input(): JsonValue = input - /** Whether this span is a root span */ + /** + * Whether this span is a root span + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun isRoot(): Optional = Optional.ofNullable(isRoot.getNullable("is_root")) /** @@ -145,6 +187,9 @@ private constructor( * example, you could log the `prompt`, example's `id`, or anything else that would be useful to * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys * must be strings + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) @@ -152,10 +197,18 @@ private constructor( * Metrics are numerical measurements tracking the execution of the code that produced the * project logs event. Use "start" and "end" to track the time span over which the project logs * event was produced + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - /** Indicates the event was copied from another object. */ + /** + * Indicates the event was copied from another object. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) /** @@ -175,112 +228,160 @@ private constructor( * generated and grouth truth summary. The word similarity score could help you determine * whether the summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Human-identifying attributes of the span, such as name, type, etc. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun spanAttributes(): Optional = Optional.ofNullable(spanAttributes.getNullable("span_attributes")) /** * An array of the parent `span_ids` of this project logs event. This should be empty for the * root span of a trace, and should most often contain just one parent element for subspans + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun spanParents(): Optional> = Optional.ofNullable(spanParents.getNullable("span_parents")) - /** A list of tags to log */ + /** + * A list of tags to log + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the project logs (see the `version` parameter) + * Returns the raw JSON value of [_xactId]. + * + * Unlike [_xactId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - /** The timestamp the project logs event was created */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** A literal 'g' which identifies the log as a project log */ + /** + * Returns the raw JSON value of [logId]. + * + * Unlike [logId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId - /** Unique id for the organization that the project belongs under */ + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Unique identifier for the project */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** A unique identifier for the trace this project logs event belongs to */ + /** + * Returns the raw JSON value of [rootSpanId]. + * + * Unlike [rootSpanId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId(): JsonField = rootSpanId /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * Returns the raw JSON value of [spanId]. + * + * Unlike [spanId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_id") @ExcludeMissing fun _spanId(): JsonField = spanId /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - /** Whether this span is a root span */ + /** + * Returns the raw JSON value of [isRoot]. + * + * Unlike [isRoot], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("is_root") @ExcludeMissing fun _isRoot(): JsonField = isRoot /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Returns the raw JSON value of [metrics]. + * + * Unlike [metrics], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics - /** Indicates the event was copied from another object. */ + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to - * help you sort, filter, and compare logs. + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Returns the raw JSON value of [spanAttributes]. + * + * Unlike [spanAttributes], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes(): JsonField = spanAttributes /** - * An array of the parent `span_ids` of this project logs event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans + * Returns the raw JSON value of [spanParents]. + * + * Unlike [spanParents], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("span_parents") @ExcludeMissing fun _spanParents(): JsonField> = spanParents - /** A list of tags to log */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -395,8 +496,10 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun id(id: JsonField) = apply { this.id = id } @@ -408,40 +511,69 @@ private constructor( fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the project logs (see the `version` parameter) + * Sets [Builder._xactId] to an arbitrary JSON value. + * + * You should usually call [Builder._xactId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) - /** The timestamp the project logs event was created */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** A literal 'g' which identifies the log as a project log */ fun logId(logId: LogId) = logId(JsonField.of(logId)) - /** A literal 'g' which identifies the log as a project log */ + /** + * Sets [Builder.logId] to an arbitrary JSON value. + * + * You should usually call [Builder.logId] with a well-typed [LogId] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun logId(logId: JsonField) = apply { this.logId = logId } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - /** Unique id for the organization that the project belongs under */ + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** A unique identifier for the trace this project logs event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - /** A unique identifier for the trace this project logs event belongs to */ + /** + * Sets [Builder.rootSpanId] to an arbitrary JSON value. + * + * You should usually call [Builder.rootSpanId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } /** @@ -452,9 +584,10 @@ private constructor( fun spanId(spanId: String) = spanId(JsonField.of(spanId)) /** - * A unique identifier used to link different project logs events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * Sets [Builder.spanId] to an arbitrary JSON value. + * + * You should usually call [Builder.spanId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun spanId(spanId: JsonField) = apply { this.spanId = spanId } @@ -465,17 +598,14 @@ private constructor( */ fun context(context: Context?) = context(JsonField.ofNullable(context)) - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ fun context(context: Optional) = context(context.getOrNull()) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [Context] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun context(context: JsonField) = apply { this.context = context } @@ -500,13 +630,22 @@ private constructor( /** Whether this span is a root span */ fun isRoot(isRoot: Boolean?) = isRoot(JsonField.ofNullable(isRoot)) - /** Whether this span is a root span */ + /** + * Alias for [Builder.isRoot]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun isRoot(isRoot: Boolean) = isRoot(isRoot as Boolean?) - /** Whether this span is a root span */ + /** Alias for calling [Builder.isRoot] with `isRoot.orElse(null)`. */ fun isRoot(isRoot: Optional) = isRoot(isRoot.getOrNull()) - /** Whether this span is a root span */ + /** + * Sets [Builder.isRoot] to an arbitrary JSON value. + * + * You should usually call [Builder.isRoot] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun isRoot(isRoot: JsonField) = apply { this.isRoot = isRoot } /** @@ -518,21 +657,15 @@ private constructor( */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } @@ -543,27 +676,30 @@ private constructor( */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ + /** Alias for calling [Builder.metrics] with `metrics.orElse(null)`. */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Sets [Builder.metrics] to an arbitrary JSON value. + * + * You should usually call [Builder.metrics] with a well-typed [Metrics] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Indicates the event was copied from another object. */ fun origin(origin: ObjectReference?) = origin(JsonField.ofNullable(origin)) - /** Indicates the event was copied from another object. */ + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) - /** Indicates the event was copied from another object. */ + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [ObjectReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } /** @@ -586,25 +722,14 @@ private constructor( */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. - */ + /** Alias for calling [Builder.scores] with `scores.orElse(null)`. */ fun scores(scores: Optional) = scores(scores.getOrNull()) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed [Scores] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun scores(scores: JsonField) = apply { this.scores = scores } @@ -612,11 +737,17 @@ private constructor( fun spanAttributes(spanAttributes: SpanAttributes?) = spanAttributes(JsonField.ofNullable(spanAttributes)) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** Alias for calling [Builder.spanAttributes] with `spanAttributes.orElse(null)`. */ fun spanAttributes(spanAttributes: Optional) = spanAttributes(spanAttributes.getOrNull()) - /** Human-identifying attributes of the span, such as name, type, etc. */ + /** + * Sets [Builder.spanAttributes] to an arbitrary JSON value. + * + * You should usually call [Builder.spanAttributes] with a well-typed [SpanAttributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun spanAttributes(spanAttributes: JsonField) = apply { this.spanAttributes = spanAttributes } @@ -628,26 +759,24 @@ private constructor( */ fun spanParents(spanParents: List?) = spanParents(JsonField.ofNullable(spanParents)) - /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans - */ + /** Alias for calling [Builder.spanParents] with `spanParents.orElse(null)`. */ fun spanParents(spanParents: Optional>) = spanParents(spanParents.getOrNull()) /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * Sets [Builder.spanParents] to an arbitrary JSON value. + * + * You should usually call [Builder.spanParents] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun spanParents(spanParents: JsonField>) = apply { this.spanParents = spanParents.map { it.toMutableList() } } /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans + * Adds a single [String] to [spanParents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addSpanParent(spanParent: String) = apply { spanParents = @@ -659,15 +788,25 @@ private constructor( /** A list of tags to log */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags to log */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags to log */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags to log */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } @@ -835,29 +974,59 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the file in code where the project logs event was created */ + /** + * Name of the file in code where the project logs event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerFilename(): Optional = Optional.ofNullable(callerFilename.getNullable("caller_filename")) - /** The function in code which created the project logs event */ + /** + * The function in code which created the project logs event + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerFunctionname(): Optional = Optional.ofNullable(callerFunctionname.getNullable("caller_functionname")) - /** Line of code where the project logs event was created */ + /** + * Line of code where the project logs event was created + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun callerLineno(): Optional = Optional.ofNullable(callerLineno.getNullable("caller_lineno")) - /** Name of the file in code where the project logs event was created */ + /** + * Returns the raw JSON value of [callerFilename]. + * + * Unlike [callerFilename], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename(): JsonField = callerFilename - /** The function in code which created the project logs event */ + /** + * Returns the raw JSON value of [callerFunctionname]. + * + * Unlike [callerFunctionname], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("caller_functionname") @ExcludeMissing fun _callerFunctionname(): JsonField = callerFunctionname - /** Line of code where the project logs event was created */ + /** + * Returns the raw JSON value of [callerLineno]. + * + * Unlike [callerLineno], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno(): JsonField = callerLineno @@ -907,11 +1076,17 @@ private constructor( fun callerFilename(callerFilename: String?) = callerFilename(JsonField.ofNullable(callerFilename)) - /** Name of the file in code where the project logs event was created */ + /** Alias for calling [Builder.callerFilename] with `callerFilename.orElse(null)`. */ fun callerFilename(callerFilename: Optional) = callerFilename(callerFilename.getOrNull()) - /** Name of the file in code where the project logs event was created */ + /** + * Sets [Builder.callerFilename] to an arbitrary JSON value. + * + * You should usually call [Builder.callerFilename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerFilename(callerFilename: JsonField) = apply { this.callerFilename = callerFilename } @@ -920,11 +1095,20 @@ private constructor( fun callerFunctionname(callerFunctionname: String?) = callerFunctionname(JsonField.ofNullable(callerFunctionname)) - /** The function in code which created the project logs event */ + /** + * Alias for calling [Builder.callerFunctionname] with + * `callerFunctionname.orElse(null)`. + */ fun callerFunctionname(callerFunctionname: Optional) = callerFunctionname(callerFunctionname.getOrNull()) - /** The function in code which created the project logs event */ + /** + * Sets [Builder.callerFunctionname] to an arbitrary JSON value. + * + * You should usually call [Builder.callerFunctionname] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerFunctionname(callerFunctionname: JsonField) = apply { this.callerFunctionname = callerFunctionname } @@ -932,13 +1116,23 @@ private constructor( /** Line of code where the project logs event was created */ fun callerLineno(callerLineno: Long?) = callerLineno(JsonField.ofNullable(callerLineno)) - /** Line of code where the project logs event was created */ + /** + * Alias for [Builder.callerLineno]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun callerLineno(callerLineno: Long) = callerLineno(callerLineno as Long?) - /** Line of code where the project logs event was created */ + /** Alias for calling [Builder.callerLineno] with `callerLineno.orElse(null)`. */ fun callerLineno(callerLineno: Optional) = callerLineno(callerLineno.getOrNull()) - /** Line of code where the project logs event was created */ + /** + * Sets [Builder.callerLineno] to an arbitrary JSON value. + * + * You should usually call [Builder.callerLineno] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun callerLineno(callerLineno: JsonField) = apply { this.callerLineno = callerLineno } @@ -1007,10 +1201,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The model used for this example */ + /** + * The model used for this example + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun model(): Optional = Optional.ofNullable(model.getNullable("model")) - /** The model used for this example */ + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model @JsonAnyGetter @@ -1051,10 +1254,16 @@ private constructor( /** The model used for this example */ fun model(model: String?) = model(JsonField.ofNullable(model)) - /** The model used for this example */ + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ fun model(model: Optional) = model(model.getOrNull()) - /** The model used for this example */ + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun model(model: JsonField) = apply { this.model = model } fun additionalProperties(additionalProperties: Map) = apply { @@ -1148,6 +1357,9 @@ private constructor( /** * The number of tokens in the completion generated by the model (only set if this is an LLM * span) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun completionTokens(): Optional = Optional.ofNullable(completionTokens.getNullable("completion_tokens")) @@ -1155,12 +1367,18 @@ private constructor( /** * A unix timestamp recording when the section of code which produced the project logs event * finished + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun end(): Optional = Optional.ofNullable(end.getNullable("end")) /** * The number of tokens in the prompt used to generate the project logs event (only set if * this is an LLM span) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun promptTokens(): Optional = Optional.ofNullable(promptTokens.getNullable("prompt_tokens")) @@ -1168,41 +1386,59 @@ private constructor( /** * A unix timestamp recording when the section of code which produced the project logs event * started + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun start(): Optional = Optional.ofNullable(start.getNullable("start")) - /** The total number of tokens in the input and output of the project logs event. */ + /** + * The total number of tokens in the input and output of the project logs event. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tokens(): Optional = Optional.ofNullable(tokens.getNullable("tokens")) /** - * The number of tokens in the completion generated by the model (only set if this is an LLM - * span) + * Returns the raw JSON value of [completionTokens]. + * + * Unlike [completionTokens], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("completion_tokens") @ExcludeMissing fun _completionTokens(): JsonField = completionTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * finished + * Returns the raw JSON value of [end]. + * + * Unlike [end], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * Returns the raw JSON value of [promptTokens]. + * + * Unlike [promptTokens], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens(): JsonField = promptTokens /** - * A unix timestamp recording when the section of code which produced the project logs event - * started + * Returns the raw JSON value of [start]. + * + * Unlike [start], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start - /** The total number of tokens in the input and output of the project logs event. */ + /** + * Returns the raw JSON value of [tokens]. + * + * Unlike [tokens], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens @JsonAnyGetter @@ -1279,22 +1515,25 @@ private constructor( completionTokens(JsonField.ofNullable(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Alias for [Builder.completionTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun completionTokens(completionTokens: Long) = completionTokens(completionTokens as Long?) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Alias for calling [Builder.completionTokens] with `completionTokens.orElse(null)`. */ fun completionTokens(completionTokens: Optional) = completionTokens(completionTokens.getOrNull()) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * Sets [Builder.completionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.completionTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun completionTokens(completionTokens: JsonField) = apply { this.completionTokens = completionTokens @@ -1307,20 +1546,21 @@ private constructor( fun end(end: Double?) = end(JsonField.ofNullable(end)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * Alias for [Builder.end]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun end(end: Double) = end(end as Double?) - /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished - */ + /** Alias for calling [Builder.end] with `end.orElse(null)`. */ fun end(end: Optional) = end(end.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished + * Sets [Builder.end] to an arbitrary JSON value. + * + * You should usually call [Builder.end] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun end(end: JsonField) = apply { this.end = end } @@ -1331,20 +1571,21 @@ private constructor( fun promptTokens(promptTokens: Long?) = promptTokens(JsonField.ofNullable(promptTokens)) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * Alias for [Builder.promptTokens]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun promptTokens(promptTokens: Long) = promptTokens(promptTokens as Long?) - /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) - */ + /** Alias for calling [Builder.promptTokens] with `promptTokens.orElse(null)`. */ fun promptTokens(promptTokens: Optional) = promptTokens(promptTokens.getOrNull()) /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) + * Sets [Builder.promptTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.promptTokens] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun promptTokens(promptTokens: JsonField) = apply { this.promptTokens = promptTokens @@ -1357,33 +1598,44 @@ private constructor( fun start(start: Double?) = start(JsonField.ofNullable(start)) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * Alias for [Builder.start]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun start(start: Double) = start(start as Double?) - /** - * A unix timestamp recording when the section of code which produced the project logs - * event started - */ + /** Alias for calling [Builder.start] with `start.orElse(null)`. */ fun start(start: Optional) = start(start.getOrNull()) /** - * A unix timestamp recording when the section of code which produced the project logs - * event started + * Sets [Builder.start] to an arbitrary JSON value. + * + * You should usually call [Builder.start] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun start(start: JsonField) = apply { this.start = start } /** The total number of tokens in the input and output of the project logs event. */ fun tokens(tokens: Long?) = tokens(JsonField.ofNullable(tokens)) - /** The total number of tokens in the input and output of the project logs event. */ + /** + * Alias for [Builder.tokens]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun tokens(tokens: Long) = tokens(tokens as Long?) - /** The total number of tokens in the input and output of the project logs event. */ + /** Alias for calling [Builder.tokens] with `tokens.orElse(null)`. */ fun tokens(tokens: Optional) = tokens(tokens.getOrNull()) - /** The total number of tokens in the input and output of the project logs event. */ + /** + * Sets [Builder.tokens] to an arbitrary JSON value. + * + * You should usually call [Builder.tokens] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tokens(tokens: JsonField) = apply { this.tokens = tokens } fun additionalProperties(additionalProperties: Map) = apply { 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 21c79f2d..83e93aa0 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 @@ -64,66 +64,156 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the project score */ + /** + * Unique identifier for the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the project score */ + /** + * Name of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the project score belongs under */ + /** + * Unique identifier for the project that the project score belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** The type of the configured score */ + /** + * The type of the configured score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun userId(): String = userId.getRequired("user_id") - /** For categorical-type project scores, the list of all categories */ + /** + * For categorical-type project scores, the list of all categories + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun config(): Optional = Optional.ofNullable(config.getNullable("config")) - /** Date of project score creation */ + /** + * Date of project score creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Textual description of the project score */ + /** + * Textual description of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * An optional LexoRank-based string that sets the sort position for the score in the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun position(): Optional = Optional.ofNullable(position.getNullable("position")) - /** Unique identifier for the project score */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the project score */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the project score belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** The type of the configured score */ + /** + * Returns the raw JSON value of [scoreType]. + * + * Unlike [scoreType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("score_type") @ExcludeMissing fun _scoreType(): JsonField = scoreType + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - /** For categorical-type project scores, the list of all categories */ + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("categories") @ExcludeMissing fun _categories(): JsonField = categories + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - /** Date of project score creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Textual description of the project score */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position @JsonAnyGetter @@ -202,81 +292,140 @@ private constructor( /** Unique identifier for the project score */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the project score */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the project score */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the project score belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType) = scoreType(JsonField.of(scoreType)) - /** The type of the configured score */ + /** + * Sets [Builder.scoreType] to an arbitrary JSON value. + * + * You should usually call [Builder.scoreType] with a well-typed [ProjectScoreType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } fun userId(userId: String) = userId(JsonField.of(userId)) + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ fun categories(categories: Optional) = categories(categories.getOrNull()) - /** For categorical-type project scores, the list of all categories */ + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun categories(categories: JsonField) = apply { this.categories = categories } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [categories] with `Categories.ofCategorical(categorical)`. */ fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) - /** For weighted-type project scores, the weights of each score */ + /** Alias for calling [categories] with `Categories.ofWeighted(weighted)`. */ fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) - /** For minimum-type project scores, the list of included scores */ + /** Alias for calling [categories] with `Categories.ofMinimum(minimum)`. */ fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ fun config(config: Optional) = config(config.getOrNull()) + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ProjectScoreConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun config(config: JsonField) = apply { this.config = config } /** Date of project score creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of project score creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of project score creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the project score */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project score */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } /** An optional LexoRank-based string that sets the sort position for the score in the UI */ fun position(position: String?) = position(JsonField.ofNullable(position)) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** Alias for calling [Builder.position] with `position.orElse(null)`. */ fun position(position: Optional) = position(position.getOrNull()) - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun position(position: JsonField) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index 9637cd01..6536e6c0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -10,6 +10,7 @@ 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 @@ -26,16 +27,34 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the category */ + /** + * Name of the category + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Numerical value of the category. Must be between 0 and 1, inclusive */ + /** + * Numerical value of the category. Must be between 0 and 1, inclusive + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun value(): Double = value.getRequired("value") - /** Name of the category */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Numerical value of the category. Must be between 0 and 1, inclusive */ + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @@ -87,13 +106,23 @@ private constructor( /** Name of the category */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the category */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Numerical value of the category. Must be between 0 and 1, inclusive */ fun value(value: Double) = value(JsonField.of(value)) - /** Numerical value of the category. Must be between 0 and 1, inclusive */ + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index c612a666..7351c2fb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -9,6 +9,7 @@ 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 @@ -33,20 +34,47 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun destination(): Optional = Optional.ofNullable(destination.getNullable("destination")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun multiSelect(): Optional = Optional.ofNullable(multiSelect.getNullable("multi_select")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun online(): Optional = Optional.ofNullable(online.getNullable("online")) + /** + * Returns the raw JSON value of [destination]. + * + * Unlike [destination], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("destination") @ExcludeMissing fun _destination(): JsonField = destination + /** + * Returns the raw JSON value of [multiSelect]. + * + * Unlike [multiSelect], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("multi_select") @ExcludeMissing fun _multiSelect(): JsonField = multiSelect + /** + * Returns the raw JSON value of [online]. + * + * Unlike [online], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("online") @ExcludeMissing fun _online(): JsonField = online @JsonAnyGetter @@ -92,22 +120,51 @@ private constructor( fun destination(destination: String?) = destination(JsonField.ofNullable(destination)) + /** Alias for calling [Builder.destination] with `destination.orElse(null)`. */ fun destination(destination: Optional) = destination(destination.getOrNull()) + /** + * Sets [Builder.destination] to an arbitrary JSON value. + * + * You should usually call [Builder.destination] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun destination(destination: JsonField) = apply { this.destination = destination } fun multiSelect(multiSelect: Boolean?) = multiSelect(JsonField.ofNullable(multiSelect)) + /** + * Alias for [Builder.multiSelect]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun multiSelect(multiSelect: Boolean) = multiSelect(multiSelect as Boolean?) + /** Alias for calling [Builder.multiSelect] with `multiSelect.orElse(null)`. */ fun multiSelect(multiSelect: Optional) = multiSelect(multiSelect.getOrNull()) + /** + * Sets [Builder.multiSelect] to an arbitrary JSON value. + * + * You should usually call [Builder.multiSelect] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun multiSelect(multiSelect: JsonField) = apply { this.multiSelect = multiSelect } fun online(online: OnlineScoreConfig?) = online(JsonField.ofNullable(online)) + /** Alias for calling [Builder.online] with `online.orElse(null)`. */ fun online(online: Optional) = online(online.getOrNull()) + /** + * Sets [Builder.online] to an arbitrary JSON value. + * + * You should usually call [Builder.online] with a well-typed [OnlineScoreConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun online(online: JsonField) = apply { this.online = online } fun additionalProperties(additionalProperties: Map) = apply { 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 3a475043..606810a8 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 @@ -43,38 +43,92 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the project score */ + /** + * Name of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the project score belongs under */ + /** + * Unique identifier for the project that the project score belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** The type of the configured score */ + /** + * The type of the configured score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun scoreType(): ProjectScoreType = body.scoreType() - /** For categorical-type project scores, the list of all categories */ + /** + * For categorical-type project scores, the list of all categories + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun categories(): Optional = body.categories() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun config(): Optional = body.config() - /** Textual description of the project score */ + /** + * Textual description of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the project score */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the project score belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** The type of the configured score */ + /** + * Returns the raw JSON value of [scoreType]. + * + * Unlike [scoreType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _scoreType(): JsonField = body._scoreType() - /** For categorical-type project scores, the list of all categories */ + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ fun _categories(): JsonField = body._categories() + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ fun _config(): JsonField = body._config() - /** Textual description of the project score */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -116,47 +170,101 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the project score */ + /** + * Name of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the project score belongs under */ + /** + * Unique identifier for the project that the project score belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** The type of the configured score */ + /** + * The type of the configured score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") - /** For categorical-type project scores, the list of all categories */ + /** + * For categorical-type project scores, the list of all categories + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun config(): Optional = Optional.ofNullable(config.getNullable("config")) - /** Textual description of the project score */ + /** + * Textual description of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the project score */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the project score belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** The type of the configured score */ + /** + * Returns the raw JSON value of [scoreType]. + * + * Unlike [scoreType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("score_type") @ExcludeMissing fun _scoreType(): JsonField = scoreType - /** For categorical-type project scores, the list of all categories */ + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("categories") @ExcludeMissing fun _categories(): JsonField = categories + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - /** Textual description of the project score */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description @@ -223,19 +331,37 @@ private constructor( /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the project score */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the project score belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType) = scoreType(JsonField.of(scoreType)) - /** The type of the configured score */ + /** + * Sets [Builder.scoreType] to an arbitrary JSON value. + * + * You should usually call [Builder.scoreType] with a well-typed [ProjectScoreType] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } @@ -243,39 +369,59 @@ private constructor( /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ fun categories(categories: Optional) = categories(categories.getOrNull()) - /** For categorical-type project scores, the list of all categories */ + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun categories(categories: JsonField) = apply { this.categories = categories } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [categories] with `Categories.ofCategorical(categorical)`. */ fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) - /** For weighted-type project scores, the weights of each score */ + /** Alias for calling [categories] with `Categories.ofWeighted(weighted)`. */ fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) - /** For minimum-type project scores, the list of included scores */ + /** Alias for calling [categories] with `Categories.ofMinimum(minimum)`. */ fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ fun config(config: Optional) = config(config.getOrNull()) + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ProjectScoreConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun config(config: JsonField) = apply { this.config = config } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the project score */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project score */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -364,54 +510,91 @@ private constructor( /** Name of the project score */ fun name(name: String) = apply { body.name(name) } - /** Name of the project score */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the project score belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType) = apply { body.scoreType(scoreType) } - /** The type of the configured score */ + /** + * Sets [Builder.scoreType] to an arbitrary JSON value. + * + * You should usually call [Builder.scoreType] with a well-typed [ProjectScoreType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ 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) } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ fun categories(categories: Optional) = categories(categories.getOrNull()) - /** For categorical-type project scores, the list of all categories */ + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun categories(categories: JsonField) = apply { body.categories(categories) } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [categories] with `Categories.ofCategorical(categorical)`. */ fun categoriesOfCategorical(categorical: List) = apply { body.categoriesOfCategorical(categorical) } - /** For weighted-type project scores, the weights of each score */ + /** Alias for calling [categories] with `Categories.ofWeighted(weighted)`. */ fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } - /** For minimum-type project scores, the list of included scores */ + /** Alias for calling [categories] with `Categories.ofMinimum(minimum)`. */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ fun config(config: Optional) = config(config.getOrNull()) + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ProjectScoreConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the project score */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project score */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { 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 18c456c6..29356a33 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 @@ -154,13 +154,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -169,49 +163,44 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } - /** Project id */ + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } - /** Name of the project to search for */ + /** Alias for calling [Builder.projectName] with `projectName.orElse(null)`. */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_score to search for */ @@ -219,20 +208,22 @@ private constructor( this.projectScoreName = projectScoreName } - /** Name of the project_score to search for */ + /** Alias for calling [Builder.projectScoreName] with `projectScoreName.orElse(null)`. */ fun projectScoreName(projectScoreName: Optional) = projectScoreName(projectScoreName.getOrNull()) /** The type of the configured score */ fun scoreType(scoreType: ScoreType?) = apply { this.scoreType = scoreType } - /** The type of the configured score */ + /** Alias for calling [Builder.scoreType] with `scoreType.orElse(null)`. */ fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) - /** The type of the configured score */ + /** Alias for calling [scoreType] with `ScoreType.ofProject(project)`. */ fun scoreType(project: ProjectScoreType) = scoreType(ScoreType.ofProject(project)) - /** The type of the configured score */ + /** + * Alias for calling [scoreType] with `ScoreType.ofProjectScoreTypes(projectScoreTypes)`. + */ fun scoreTypeOfProjectScoreTypes(projectScoreTypes: List) = scoreType(ScoreType.ofProjectScoreTypes(projectScoreTypes)) @@ -245,13 +236,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) 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 3c35ed4a..88048533 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 @@ -44,38 +44,92 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the project score */ + /** + * Name of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the project score belongs under */ + /** + * Unique identifier for the project that the project score belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** The type of the configured score */ + /** + * The type of the configured score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun scoreType(): ProjectScoreType = body.scoreType() - /** For categorical-type project scores, the list of all categories */ + /** + * For categorical-type project scores, the list of all categories + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun categories(): Optional = body.categories() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun config(): Optional = body.config() - /** Textual description of the project score */ + /** + * Textual description of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the project score */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the project score belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** The type of the configured score */ + /** + * Returns the raw JSON value of [scoreType]. + * + * Unlike [scoreType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _scoreType(): JsonField = body._scoreType() - /** For categorical-type project scores, the list of all categories */ + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ fun _categories(): JsonField = body._categories() + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ fun _config(): JsonField = body._config() - /** Textual description of the project score */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -117,47 +171,101 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the project score */ + /** + * Name of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the project score belongs under */ + /** + * Unique identifier for the project that the project score belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** The type of the configured score */ + /** + * The type of the configured score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun scoreType(): ProjectScoreType = scoreType.getRequired("score_type") - /** For categorical-type project scores, the list of all categories */ + /** + * For categorical-type project scores, the list of all categories + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun config(): Optional = Optional.ofNullable(config.getNullable("config")) - /** Textual description of the project score */ + /** + * Textual description of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the project score */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the project score belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** The type of the configured score */ + /** + * Returns the raw JSON value of [scoreType]. + * + * Unlike [scoreType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("score_type") @ExcludeMissing fun _scoreType(): JsonField = scoreType - /** For categorical-type project scores, the list of all categories */ + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("categories") @ExcludeMissing fun _categories(): JsonField = categories + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - /** Textual description of the project score */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description @@ -224,19 +332,37 @@ private constructor( /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the project score */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the project score belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType) = scoreType(JsonField.of(scoreType)) - /** The type of the configured score */ + /** + * Sets [Builder.scoreType] to an arbitrary JSON value. + * + * You should usually call [Builder.scoreType] with a well-typed [ProjectScoreType] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } @@ -244,39 +370,59 @@ private constructor( /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ fun categories(categories: Optional) = categories(categories.getOrNull()) - /** For categorical-type project scores, the list of all categories */ + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun categories(categories: JsonField) = apply { this.categories = categories } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [categories] with `Categories.ofCategorical(categorical)`. */ fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) - /** For weighted-type project scores, the weights of each score */ + /** Alias for calling [categories] with `Categories.ofWeighted(weighted)`. */ fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) - /** For minimum-type project scores, the list of included scores */ + /** Alias for calling [categories] with `Categories.ofMinimum(minimum)`. */ fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ fun config(config: Optional) = config(config.getOrNull()) + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ProjectScoreConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun config(config: JsonField) = apply { this.config = config } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the project score */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project score */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -365,54 +511,91 @@ private constructor( /** Name of the project score */ fun name(name: String) = apply { body.name(name) } - /** Name of the project score */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the project score belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType) = apply { body.scoreType(scoreType) } - /** The type of the configured score */ + /** + * Sets [Builder.scoreType] to an arbitrary JSON value. + * + * You should usually call [Builder.scoreType] with a well-typed [ProjectScoreType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ 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) } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ fun categories(categories: Optional) = categories(categories.getOrNull()) - /** For categorical-type project scores, the list of all categories */ + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun categories(categories: JsonField) = apply { body.categories(categories) } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [categories] with `Categories.ofCategorical(categorical)`. */ fun categoriesOfCategorical(categorical: List) = apply { body.categoriesOfCategorical(categorical) } - /** For weighted-type project scores, the weights of each score */ + /** Alias for calling [categories] with `Categories.ofWeighted(weighted)`. */ fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } - /** For minimum-type project scores, the list of included scores */ + /** Alias for calling [categories] with `Categories.ofMinimum(minimum)`. */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ fun config(config: Optional) = config(config.getOrNull()) + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ProjectScoreConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the project score */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project score */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { 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 402cb014..ad921421 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 @@ -48,32 +48,77 @@ private constructor( /** ProjectScore id */ fun projectScoreId(): String = projectScoreId - /** For categorical-type project scores, the list of all categories */ + /** + * For categorical-type project scores, the list of all categories + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun categories(): Optional = body.categories() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun config(): Optional = body.config() - /** Textual description of the project score */ + /** + * Textual description of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the project score */ + /** + * Name of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() - /** The type of the configured score */ + /** + * The type of the configured score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun scoreType(): Optional = body.scoreType() - /** For categorical-type project scores, the list of all categories */ + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ fun _categories(): JsonField = body._categories() + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ fun _config(): JsonField = body._config() - /** Textual description of the project score */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** Name of the project score */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** The type of the configured score */ + /** + * Returns the raw JSON value of [scoreType]. + * + * Unlike [scoreType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _scoreType(): JsonField = body._scoreType() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -119,42 +164,87 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** For categorical-type project scores, the list of all categories */ + /** + * For categorical-type project scores, the list of all categories + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun categories(): Optional = Optional.ofNullable(categories.getNullable("categories")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun config(): Optional = Optional.ofNullable(config.getNullable("config")) - /** Textual description of the project score */ + /** + * Textual description of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the project score */ + /** + * Name of the project score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** The type of the configured score */ + /** + * The type of the configured score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun scoreType(): Optional = Optional.ofNullable(scoreType.getNullable("score_type")) - /** For categorical-type project scores, the list of all categories */ + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("categories") @ExcludeMissing fun _categories(): JsonField = categories + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - /** Textual description of the project score */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** Name of the project score */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The type of the configured score */ + /** + * Returns the raw JSON value of [scoreType]. + * + * Unlike [scoreType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("score_type") @ExcludeMissing fun _scoreType(): JsonField = scoreType @@ -209,39 +299,59 @@ private constructor( /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ fun categories(categories: Optional) = categories(categories.getOrNull()) - /** For categorical-type project scores, the list of all categories */ + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun categories(categories: JsonField) = apply { this.categories = categories } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [categories] with `Categories.ofCategorical(categorical)`. */ fun categoriesOfCategorical(categorical: List) = categories(Categories.ofCategorical(categorical)) - /** For weighted-type project scores, the weights of each score */ + /** Alias for calling [categories] with `Categories.ofWeighted(weighted)`. */ fun categories(weighted: Categories.Weighted) = categories(Categories.ofWeighted(weighted)) - /** For minimum-type project scores, the list of included scores */ + /** Alias for calling [categories] with `Categories.ofMinimum(minimum)`. */ fun categoriesOfMinimum(minimum: List) = categories(Categories.ofMinimum(minimum)) fun config(config: ProjectScoreConfig?) = config(JsonField.ofNullable(config)) + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ fun config(config: Optional) = config(config.getOrNull()) + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ProjectScoreConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun config(config: JsonField) = apply { this.config = config } /** Textual description of the project score */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the project score */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project score */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -249,19 +359,31 @@ private constructor( /** Name of the project score */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the project score */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the project score */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType?) = scoreType(JsonField.ofNullable(scoreType)) - /** The type of the configured score */ + /** Alias for calling [Builder.scoreType] with `scoreType.orElse(null)`. */ fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) - /** The type of the configured score */ + /** + * Sets [Builder.scoreType] to an arbitrary JSON value. + * + * You should usually call [Builder.scoreType] with a well-typed [ProjectScoreType] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } @@ -352,54 +474,85 @@ private constructor( /** For categorical-type project scores, the list of all categories */ fun categories(categories: Categories?) = apply { body.categories(categories) } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ fun categories(categories: Optional) = categories(categories.getOrNull()) - /** For categorical-type project scores, the list of all categories */ + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun categories(categories: JsonField) = apply { body.categories(categories) } - /** For categorical-type project scores, the list of all categories */ + /** Alias for calling [categories] with `Categories.ofCategorical(categorical)`. */ fun categoriesOfCategorical(categorical: List) = apply { body.categoriesOfCategorical(categorical) } - /** For weighted-type project scores, the weights of each score */ + /** Alias for calling [categories] with `Categories.ofWeighted(weighted)`. */ fun categories(weighted: Categories.Weighted) = apply { body.categories(weighted) } - /** For minimum-type project scores, the list of included scores */ + /** Alias for calling [categories] with `Categories.ofMinimum(minimum)`. */ fun categoriesOfMinimum(minimum: List) = apply { body.categoriesOfMinimum(minimum) } fun config(config: ProjectScoreConfig?) = apply { body.config(config) } + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ fun config(config: Optional) = config(config.getOrNull()) + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ProjectScoreConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun config(config: JsonField) = apply { body.config(config) } /** Textual description of the project score */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the project score */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project score */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** Name of the project score */ fun name(name: String?) = apply { body.name(name) } - /** Name of the project score */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the project score */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** The type of the configured score */ fun scoreType(scoreType: ProjectScoreType?) = apply { body.scoreType(scoreType) } - /** The type of the configured score */ + /** Alias for calling [Builder.scoreType] with `scoreType.orElse(null)`. */ fun scoreType(scoreType: Optional) = scoreType(scoreType.getOrNull()) - /** The type of the configured score */ + /** + * Sets [Builder.scoreType] to an arbitrary JSON value. + * + * You should usually call [Builder.scoreType] with a well-typed [ProjectScoreType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun scoreType(scoreType: JsonField) = apply { body.scoreType(scoreType) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index 6a1912e4..dec2d996 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -37,29 +37,57 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the experiment to use as the default baseline for comparisons */ + /** + * The id of the experiment to use as the default baseline for comparisons + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun baselineExperimentId(): Optional = Optional.ofNullable(baselineExperimentId.getNullable("baseline_experiment_id")) - /** The key used to join two experiments (defaults to `input`) */ + /** + * The key used to join two experiments (defaults to `input`) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun comparisonKey(): Optional = Optional.ofNullable(comparisonKey.getNullable("comparison_key")) - /** The order of the fields to display in the trace view */ + /** + * The order of the fields to display in the trace view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun spanFieldOrder(): Optional> = Optional.ofNullable(spanFieldOrder.getNullable("spanFieldOrder")) - /** The id of the experiment to use as the default baseline for comparisons */ + /** + * Returns the raw JSON value of [baselineExperimentId]. + * + * Unlike [baselineExperimentId], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("baseline_experiment_id") @ExcludeMissing fun _baselineExperimentId(): JsonField = baselineExperimentId - /** The key used to join two experiments (defaults to `input`) */ + /** + * Returns the raw JSON value of [comparisonKey]. + * + * Unlike [comparisonKey], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("comparison_key") @ExcludeMissing fun _comparisonKey(): JsonField = comparisonKey - /** The order of the fields to display in the trace view */ + /** + * Returns the raw JSON value of [spanFieldOrder]. + * + * Unlike [spanFieldOrder], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("spanFieldOrder") @ExcludeMissing fun _spanFieldOrder(): JsonField> = spanFieldOrder @@ -109,11 +137,20 @@ private constructor( fun baselineExperimentId(baselineExperimentId: String?) = baselineExperimentId(JsonField.ofNullable(baselineExperimentId)) - /** The id of the experiment to use as the default baseline for comparisons */ + /** + * Alias for calling [Builder.baselineExperimentId] with + * `baselineExperimentId.orElse(null)`. + */ fun baselineExperimentId(baselineExperimentId: Optional) = baselineExperimentId(baselineExperimentId.getOrNull()) - /** The id of the experiment to use as the default baseline for comparisons */ + /** + * Sets [Builder.baselineExperimentId] to an arbitrary JSON value. + * + * You should usually call [Builder.baselineExperimentId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun baselineExperimentId(baselineExperimentId: JsonField) = apply { this.baselineExperimentId = baselineExperimentId } @@ -122,11 +159,17 @@ private constructor( fun comparisonKey(comparisonKey: String?) = comparisonKey(JsonField.ofNullable(comparisonKey)) - /** The key used to join two experiments (defaults to `input`) */ + /** Alias for calling [Builder.comparisonKey] with `comparisonKey.orElse(null)`. */ fun comparisonKey(comparisonKey: Optional) = comparisonKey(comparisonKey.getOrNull()) - /** The key used to join two experiments (defaults to `input`) */ + /** + * Sets [Builder.comparisonKey] to an arbitrary JSON value. + * + * You should usually call [Builder.comparisonKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun comparisonKey(comparisonKey: JsonField) = apply { this.comparisonKey = comparisonKey } @@ -135,16 +178,26 @@ private constructor( fun spanFieldOrder(spanFieldOrder: List?) = spanFieldOrder(JsonField.ofNullable(spanFieldOrder)) - /** The order of the fields to display in the trace view */ + /** Alias for calling [Builder.spanFieldOrder] with `spanFieldOrder.orElse(null)`. */ fun spanFieldOrder(spanFieldOrder: Optional>) = spanFieldOrder(spanFieldOrder.getOrNull()) - /** The order of the fields to display in the trace view */ + /** + * Sets [Builder.spanFieldOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.spanFieldOrder] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun spanFieldOrder(spanFieldOrder: JsonField>) = apply { this.spanFieldOrder = spanFieldOrder.map { it.toMutableList() } } - /** The order of the fields to display in the trace view */ + /** + * Adds a single [SpanFieldOrder] to [Builder.spanFieldOrder]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addSpanFieldOrder(spanFieldOrder: SpanFieldOrder) = apply { this.spanFieldOrder = (this.spanFieldOrder ?: JsonField.of(mutableListOf())).also { @@ -200,22 +253,58 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun columnId(): String = columnId.getRequired("column_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): String = objectType.getRequired("object_type") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun position(): String = position.getRequired("position") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun layout(): Optional = Optional.ofNullable(layout.getNullable("layout")) + /** + * Returns the raw JSON value of [columnId]. + * + * Unlike [columnId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("column_id") @ExcludeMissing fun _columnId(): JsonField = columnId + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + /** + * Returns the raw JSON value of [layout]. + * + * Unlike [layout], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("layout") @ExcludeMissing fun _layout(): JsonField = layout @JsonAnyGetter @@ -273,20 +362,49 @@ private constructor( fun columnId(columnId: String) = columnId(JsonField.of(columnId)) + /** + * Sets [Builder.columnId] to an arbitrary JSON value. + * + * You should usually call [Builder.columnId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun columnId(columnId: JsonField) = apply { this.columnId = columnId } fun objectType(objectType: String) = objectType(JsonField.of(objectType)) + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } fun position(position: String) = position(JsonField.of(position)) + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun position(position: JsonField) = apply { this.position = position } fun layout(layout: Layout?) = layout(JsonField.ofNullable(layout)) + /** Alias for calling [Builder.layout] with `layout.orElse(null)`. */ fun layout(layout: Optional) = layout(layout.getOrNull()) + /** + * Sets [Builder.layout] to an arbitrary JSON value. + * + * You should usually call [Builder.layout] with a well-typed [Layout] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun layout(layout: JsonField) = apply { this.layout = layout } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 69a309f6..13fd21d3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -10,6 +10,7 @@ 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 @@ -45,45 +46,108 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the project tag */ + /** + * Unique identifier for the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the project tag */ + /** + * Name of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the project tag belongs under */ + /** + * Unique identifier for the project that the project tag belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun userId(): String = userId.getRequired("user_id") - /** Color of the tag for the UI */ + /** + * Color of the tag for the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - /** Date of project tag creation */ + /** + * Date of project tag creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Textual description of the project tag */ + /** + * Textual description of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Unique identifier for the project tag */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the project tag */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the project tag belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - /** Color of the tag for the UI */ + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - /** Date of project tag creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Textual description of the project tag */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description @JsonAnyGetter @@ -152,50 +216,89 @@ private constructor( /** Unique identifier for the project tag */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the project tag */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the project tag */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the project tag belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } fun userId(userId: String) = userId(JsonField.of(userId)) + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) - /** Color of the tag for the UI */ + /** Alias for calling [Builder.color] with `color.orElse(null)`. */ fun color(color: Optional) = color(color.getOrNull()) - /** Color of the tag for the UI */ + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun color(color: JsonField) = apply { this.color = color } /** Date of project tag creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of project tag creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of project tag creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the project tag */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project tag */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 1944b66e..2535deb8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,28 +33,64 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the project tag */ + /** + * Name of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the project tag belongs under */ + /** + * Unique identifier for the project that the project tag belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** Color of the tag for the UI */ + /** + * Color of the tag for the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun color(): Optional = body.color() - /** Textual description of the project tag */ + /** + * Textual description of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the project tag */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the project tag belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** Color of the tag for the UI */ + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ fun _color(): JsonField = body._color() - /** Textual description of the project tag */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -88,29 +125,65 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the project tag */ + /** + * Name of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the project tag belongs under */ + /** + * Unique identifier for the project that the project tag belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Color of the tag for the UI */ + /** + * Color of the tag for the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - /** Textual description of the project tag */ + /** + * Textual description of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the project tag */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the project tag belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Color of the tag for the UI */ + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - /** Textual description of the project tag */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description @@ -170,31 +243,55 @@ private constructor( /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the project tag */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the project tag belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) - /** Color of the tag for the UI */ + /** Alias for calling [Builder.color] with `color.orElse(null)`. */ fun color(color: Optional) = color(color.getOrNull()) - /** Color of the tag for the UI */ + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun color(color: JsonField) = apply { this.color = color } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the project tag */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project tag */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -280,31 +377,53 @@ private constructor( /** Name of the project tag */ fun name(name: String) = apply { body.name(name) } - /** Name of the project tag */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the project tag belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Color of the tag for the UI */ fun color(color: String?) = apply { body.color(color) } - /** Color of the tag for the UI */ + /** Alias for calling [Builder.color] with `color.orElse(null)`. */ fun color(color: Optional) = color(color.getOrNull()) - /** Color of the tag for the UI */ + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun color(color: JsonField) = apply { body.color(color) } /** Textual description of the project tag */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the project tag */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project tag */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 431a8583..7141cfde 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -147,13 +147,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -162,55 +156,50 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } - /** Project id */ + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } - /** Name of the project to search for */ + /** Alias for calling [Builder.projectName] with `projectName.orElse(null)`. */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the project_tag to search for */ fun projectTagName(projectTagName: String?) = apply { this.projectTagName = projectTagName } - /** Name of the project_tag to search for */ + /** Alias for calling [Builder.projectTagName] with `projectTagName.orElse(null)`. */ fun projectTagName(projectTagName: Optional) = projectTagName(projectTagName.getOrNull()) @@ -223,13 +212,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index ab167ca1..19ffe1ef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -13,6 +13,7 @@ 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 @@ -33,28 +34,64 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the project tag */ + /** + * Name of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the project tag belongs under */ + /** + * Unique identifier for the project that the project tag belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** Color of the tag for the UI */ + /** + * Color of the tag for the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun color(): Optional = body.color() - /** Textual description of the project tag */ + /** + * Textual description of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the project tag */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the project tag belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** Color of the tag for the UI */ + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ fun _color(): JsonField = body._color() - /** Textual description of the project tag */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -89,29 +126,65 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the project tag */ + /** + * Name of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the project tag belongs under */ + /** + * Unique identifier for the project that the project tag belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Color of the tag for the UI */ + /** + * Color of the tag for the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - /** Textual description of the project tag */ + /** + * Textual description of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the project tag */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the project tag belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Color of the tag for the UI */ + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - /** Textual description of the project tag */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description @@ -171,31 +244,55 @@ private constructor( /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the project tag */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the project tag belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) - /** Color of the tag for the UI */ + /** Alias for calling [Builder.color] with `color.orElse(null)`. */ fun color(color: Optional) = color(color.getOrNull()) - /** Color of the tag for the UI */ + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun color(color: JsonField) = apply { this.color = color } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the project tag */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project tag */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -281,31 +378,53 @@ private constructor( /** Name of the project tag */ fun name(name: String) = apply { body.name(name) } - /** Name of the project tag */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the project tag belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Color of the tag for the UI */ fun color(color: String?) = apply { body.color(color) } - /** Color of the tag for the UI */ + /** Alias for calling [Builder.color] with `color.orElse(null)`. */ fun color(color: Optional) = color(color.getOrNull()) - /** Color of the tag for the UI */ + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun color(color: JsonField) = apply { body.color(color) } /** Textual description of the project tag */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the project tag */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project tag */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 8a93825d..79216682 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -13,6 +13,7 @@ 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,22 +38,49 @@ private constructor( /** ProjectTag id */ fun projectTagId(): String = projectTagId - /** Color of the tag for the UI */ + /** + * Color of the tag for the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun color(): Optional = body.color() - /** Textual description of the project tag */ + /** + * Textual description of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the project tag */ + /** + * Name of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() - /** Color of the tag for the UI */ + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ fun _color(): JsonField = body._color() - /** Textual description of the project tag */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** Name of the project tag */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -91,25 +119,52 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Color of the tag for the UI */ + /** + * Color of the tag for the UI + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun color(): Optional = Optional.ofNullable(color.getNullable("color")) - /** Textual description of the project tag */ + /** + * Textual description of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the project tag */ + /** + * Name of the project tag + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** Color of the tag for the UI */ + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color - /** Textual description of the project tag */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** Name of the project tag */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -156,19 +211,31 @@ private constructor( /** Color of the tag for the UI */ fun color(color: String?) = color(JsonField.ofNullable(color)) - /** Color of the tag for the UI */ + /** Alias for calling [Builder.color] with `color.orElse(null)`. */ fun color(color: Optional) = color(color.getOrNull()) - /** Color of the tag for the UI */ + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun color(color: JsonField) = apply { this.color = color } /** Textual description of the project tag */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the project tag */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project tag */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -176,10 +243,16 @@ private constructor( /** Name of the project tag */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the project tag */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the project tag */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { @@ -260,28 +333,44 @@ private constructor( /** Color of the tag for the UI */ fun color(color: String?) = apply { body.color(color) } - /** Color of the tag for the UI */ + /** Alias for calling [Builder.color] with `color.orElse(null)`. */ fun color(color: Optional) = color(color.getOrNull()) - /** Color of the tag for the UI */ + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun color(color: JsonField) = apply { body.color(color) } /** Textual description of the project tag */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the project tag */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the project tag */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** Name of the project tag */ fun name(name: String?) = apply { body.name(name) } - /** Name of the project tag */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the project tag */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index f47cf5da..beb5ed84 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -13,6 +13,7 @@ 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,21 +38,34 @@ private constructor( /** Project id */ fun projectId(): String = projectId - /** Name of the project */ + /** + * Name of the project + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() /** * Project settings. Patch operations replace all settings, so make sure you include all * settings you want to keep. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun settings(): Optional = body.settings() - /** Name of the project */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Returns the raw JSON value of [settings]. + * + * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. */ fun _settings(): JsonField = body._settings() @@ -88,22 +102,35 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the project */ + /** + * Name of the project + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** * Project settings. Patch operations replace all settings, so make sure you include all * settings you want to keep. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun settings(): Optional = Optional.ofNullable(settings.getNullable("settings")) - /** Name of the project */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Returns the raw JSON value of [settings]. + * + * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("settings") @ExcludeMissing @@ -150,10 +177,16 @@ private constructor( /** Name of the project */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the project */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the project */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** @@ -162,15 +195,15 @@ private constructor( */ fun settings(settings: ProjectSettings?) = settings(JsonField.ofNullable(settings)) - /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. - */ + /** Alias for calling [Builder.settings] with `settings.orElse(null)`. */ fun settings(settings: Optional) = settings(settings.getOrNull()) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Sets [Builder.settings] to an arbitrary JSON value. + * + * You should usually call [Builder.settings] with a well-typed [ProjectSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun settings(settings: JsonField) = apply { this.settings = settings } @@ -252,10 +285,15 @@ private constructor( /** Name of the project */ fun name(name: String?) = apply { body.name(name) } - /** Name of the project */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the project */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** @@ -264,15 +302,15 @@ private constructor( */ fun settings(settings: ProjectSettings?) = apply { body.settings(settings) } - /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. - */ + /** Alias for calling [Builder.settings] with `settings.orElse(null)`. */ fun settings(settings: Optional) = settings(settings.getOrNull()) /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. + * Sets [Builder.settings] to an arbitrary JSON value. + * + * You should usually call [Builder.settings] with a well-typed [ProjectSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun settings(settings: JsonField) = apply { body.settings(settings) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 5e093784..a55bbce4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -58,95 +58,206 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") /** * The transaction id of an event is unique to the network operation that processed the event * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve * a versioned snapshot of the prompt (see the `version` parameter) + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun _xactId(): String = _xactId.getRequired("_xact_id") - /** A literal 'p' which identifies the object as a project prompt */ + /** + * A literal 'p' which identifies the object as a project prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun logId(): LogId = logId.getRequired("log_id") - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the organization */ + /** + * Unique identifier for the organization + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun orgId(): String = orgId.getRequired("org_id") - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = slug.getRequired("slug") - /** Date of prompt creation */ + /** + * Date of prompt creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) - /** User-controlled metadata about the prompt */ + /** + * User-controlled metadata about the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * a versioned snapshot of the prompt (see the `version` parameter) + * Returns the raw JSON value of [_xactId]. + * + * Unlike [_xactId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("_xact_id") @ExcludeMissing fun __xactId(): JsonField = _xactId - /** A literal 'p' which identifies the object as a project prompt */ + /** + * Returns the raw JSON value of [logId]. + * + * Unlike [logId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("log_id") @ExcludeMissing fun _logId(): JsonField = logId - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the organization */ + /** + * Returns the raw JSON value of [orgId]. + * + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** Date of prompt creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType - /** User-controlled metadata about the prompt */ + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_data") @ExcludeMissing fun _promptData(): JsonField = promptData - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -236,7 +347,12 @@ private constructor( /** Unique identifier for the prompt */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** @@ -247,66 +363,113 @@ private constructor( fun _xactId(_xactId: String) = _xactId(JsonField.of(_xactId)) /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the prompt (see the `version` parameter) + * Sets [Builder._xactId] to an arbitrary JSON value. + * + * You should usually call [Builder._xactId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) - /** A literal 'p' which identifies the object as a project prompt */ + /** + * Sets [Builder.logId] to an arbitrary JSON value. + * + * You should usually call [Builder.logId] with a well-typed [LogId] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun logId(logId: JsonField) = apply { this.logId = logId } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - /** Unique identifier for the organization */ + /** + * Sets [Builder.orgId] to an arbitrary JSON value. + * + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** Date of prompt creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of prompt creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of prompt creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { this.functionType = functionType } @@ -314,33 +477,55 @@ private constructor( /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** User-controlled metadata about the prompt */ + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - /** User-controlled metadata about the prompt */ + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 3eee9b8f..74098627 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -35,44 +35,107 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = body.slug() - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionType(): Optional = body.functionType() - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun promptData(): Optional = body.promptData() - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = body.tags() - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ fun _slug(): JsonField = body._slug() - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionType(): JsonField = body._functionType() - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _promptData(): JsonField = body._promptData() - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ fun _tags(): JsonField> = body._tags() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -116,53 +179,117 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = slug.getRequired("slug") - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_data") @ExcludeMissing fun _promptData(): JsonField = promptData - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -230,28 +357,52 @@ private constructor( /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -259,9 +410,17 @@ private constructor( fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { this.functionType = functionType } @@ -269,10 +428,16 @@ private constructor( /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } @@ -280,15 +445,25 @@ private constructor( /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } @@ -379,35 +554,65 @@ private constructor( /** Name of the prompt */ fun name(name: String) = apply { body.name(name) } - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Unique identifier for the prompt */ fun slug(slug: String) = apply { body.slug(slug) } - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun slug(slug: JsonField) = apply { body.slug(slug) } /** Textual description of the prompt */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { body.functionType(functionType) } @@ -415,22 +620,38 @@ private constructor( /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ fun tags(tags: List?) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { body.addTag(tag) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index cd072c2a..3df455f9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -54,25 +54,70 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun origin(): Optional = Optional.ofNullable(origin.getNullable("origin")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun parser(): Optional = Optional.ofNullable(parser.getNullable("parser")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun prompt(): Optional = Optional.ofNullable(prompt.getNullable("prompt")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun toolFunctions(): Optional> = Optional.ofNullable(toolFunctions.getNullable("tool_functions")) + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + /** + * Returns the raw JSON value of [origin]. + * + * Unlike [origin], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("origin") @ExcludeMissing fun _origin(): JsonField = origin + /** + * Returns the raw JSON value of [parser]. + * + * Unlike [parser], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("parser") @ExcludeMissing fun _parser(): JsonField = parser + /** + * Returns the raw JSON value of [prompt]. + * + * Unlike [prompt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField = prompt + /** + * Returns the raw JSON value of [toolFunctions]. + * + * Unlike [toolFunctions], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tool_functions") @ExcludeMissing fun _toolFunctions(): JsonField> = toolFunctions @@ -126,42 +171,86 @@ private constructor( fun options(options: PromptOptions?) = options(JsonField.ofNullable(options)) + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ fun options(options: Optional) = options(options.getOrNull()) + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [PromptOptions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun options(options: JsonField) = apply { this.options = options } fun origin(origin: Origin?) = origin(JsonField.ofNullable(origin)) + /** Alias for calling [Builder.origin] with `origin.orElse(null)`. */ fun origin(origin: Optional) = origin(origin.getOrNull()) + /** + * Sets [Builder.origin] to an arbitrary JSON value. + * + * You should usually call [Builder.origin] with a well-typed [Origin] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun origin(origin: JsonField) = apply { this.origin = origin } fun parser(parser: Parser?) = parser(JsonField.ofNullable(parser)) + /** Alias for calling [Builder.parser] with `parser.orElse(null)`. */ fun parser(parser: Optional) = parser(parser.getOrNull()) + /** + * Sets [Builder.parser] to an arbitrary JSON value. + * + * You should usually call [Builder.parser] with a well-typed [Parser] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun parser(parser: JsonField) = apply { this.parser = parser } fun prompt(prompt: Prompt?) = prompt(JsonField.ofNullable(prompt)) + /** Alias for calling [Builder.prompt] with `prompt.orElse(null)`. */ fun prompt(prompt: Optional) = prompt(prompt.getOrNull()) + /** + * Sets [Builder.prompt] to an arbitrary JSON value. + * + * You should usually call [Builder.prompt] with a well-typed [Prompt] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun prompt(prompt: JsonField) = apply { this.prompt = prompt } + /** Alias for calling [prompt] with `Prompt.ofCompletion(completion)`. */ fun prompt(completion: Prompt.Completion) = prompt(Prompt.ofCompletion(completion)) + /** Alias for calling [prompt] with `Prompt.ofChat(chat)`. */ fun prompt(chat: Prompt.Chat) = prompt(Prompt.ofChat(chat)) fun toolFunctions(toolFunctions: List?) = toolFunctions(JsonField.ofNullable(toolFunctions)) + /** Alias for calling [Builder.toolFunctions] with `toolFunctions.orElse(null)`. */ fun toolFunctions(toolFunctions: Optional>) = toolFunctions(toolFunctions.getOrNull()) + /** + * Sets [Builder.toolFunctions] to an arbitrary JSON value. + * + * You should usually call [Builder.toolFunctions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun toolFunctions(toolFunctions: JsonField>) = apply { this.toolFunctions = toolFunctions.map { it.toMutableList() } } + /** + * Adds a single [ToolFunction] to [toolFunctions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addToolFunction(toolFunction: ToolFunction) = apply { toolFunctions = (toolFunctions ?: JsonField.of(mutableListOf())).also { @@ -169,9 +258,11 @@ private constructor( } } + /** Alias for calling [addToolFunction] with `ToolFunction.ofFunction(function)`. */ fun addToolFunction(function: ToolFunction.Function) = addToolFunction(ToolFunction.ofFunction(function)) + /** Alias for calling [addToolFunction] with `ToolFunction.ofGlobal(global)`. */ fun addToolFunction(global: ToolFunction.Global) = addToolFunction(ToolFunction.ofGlobal(global)) @@ -222,17 +313,45 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun projectId(): Optional = Optional.ofNullable(projectId.getNullable("project_id")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun promptId(): Optional = Optional.ofNullable(promptId.getNullable("prompt_id")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun promptVersion(): Optional = Optional.ofNullable(promptVersion.getNullable("prompt_version")) + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [promptId]. + * + * Unlike [promptId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_id") @ExcludeMissing fun _promptId(): JsonField = promptId + /** + * Returns the raw JSON value of [promptVersion]. + * + * Unlike [promptVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion(): JsonField = promptVersion @@ -280,14 +399,35 @@ private constructor( fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } fun promptId(promptId: String) = promptId(JsonField.of(promptId)) + /** + * Sets [Builder.promptId] to an arbitrary JSON value. + * + * You should usually call [Builder.promptId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptId(promptId: JsonField) = apply { this.promptId = promptId } fun promptVersion(promptVersion: String) = promptVersion(JsonField.of(promptVersion)) + /** + * Sets [Builder.promptVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.promptVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptVersion(promptVersion: JsonField) = apply { this.promptVersion = promptVersion } @@ -348,18 +488,46 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun choiceScores(): ChoiceScores = choiceScores.getRequired("choice_scores") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun useCot(): Boolean = useCot.getRequired("use_cot") + /** + * Returns the raw JSON value of [choiceScores]. + * + * Unlike [choiceScores], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("choice_scores") @ExcludeMissing fun _choiceScores(): JsonField = choiceScores + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [useCot]. + * + * Unlike [useCot], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("use_cot") @ExcludeMissing fun _useCot(): JsonField = useCot @JsonAnyGetter @@ -414,16 +582,37 @@ private constructor( fun choiceScores(choiceScores: ChoiceScores) = choiceScores(JsonField.of(choiceScores)) + /** + * Sets [Builder.choiceScores] to an arbitrary JSON value. + * + * You should usually call [Builder.choiceScores] with a well-typed [ChoiceScores] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun choiceScores(choiceScores: JsonField) = apply { this.choiceScores = choiceScores } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun type(type: JsonField) = apply { this.type = type } fun useCot(useCot: Boolean) = useCot(JsonField.of(useCot)) + /** + * Sets [Builder.useCot] to an arbitrary JSON value. + * + * You should usually call [Builder.useCot] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun useCot(useCot: JsonField) = apply { this.useCot = useCot } fun additionalProperties(additionalProperties: Map) = apply { @@ -795,12 +984,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun content(): String = content.getRequired("content") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -851,10 +1060,24 @@ private constructor( fun content(content: String) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -1019,18 +1242,48 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun messages(): List = messages.getRequired("messages") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun tools(): Optional = Optional.ofNullable(tools.getNullable("tools")) + /** + * Returns the raw JSON value of [messages]. + * + * Unlike [messages], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("messages") @ExcludeMissing fun _messages(): JsonField> = messages + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tools") @ExcludeMissing fun _tools(): JsonField = tools @JsonAnyGetter @@ -1084,10 +1337,22 @@ private constructor( fun messages(messages: List) = messages(JsonField.of(messages)) + /** + * Sets [Builder.messages] to an arbitrary JSON value. + * + * You should usually call [Builder.messages] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun messages(messages: JsonField>) = apply { this.messages = messages.map { it.toMutableList() } } + /** + * Adds a single [Message] to [messages]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMessage(message: Message) = apply { messages = (messages ?: JsonField.of(mutableListOf())).also { @@ -1095,27 +1360,47 @@ private constructor( } } + /** Alias for calling [addMessage] with `Message.ofSystem(system)`. */ fun addMessage(system: Message.System) = addMessage(Message.ofSystem(system)) + /** Alias for calling [addMessage] with `Message.ofUser(user)`. */ fun addMessage(user: Message.User) = addMessage(Message.ofUser(user)) + /** Alias for calling [addMessage] with `Message.ofAssistant(assistant)`. */ fun addMessage(assistant: Message.Assistant) = addMessage(Message.ofAssistant(assistant)) + /** Alias for calling [addMessage] with `Message.ofTool(tool)`. */ fun addMessage(tool: Message.Tool) = addMessage(Message.ofTool(tool)) + /** Alias for calling [addMessage] with `Message.ofFunction(function)`. */ fun addMessage(function: Message.Function) = addMessage(Message.ofFunction(function)) + /** Alias for calling [addMessage] with `Message.ofFallback(fallback)`. */ fun addMessage(fallback: Message.Fallback) = addMessage(Message.ofFallback(fallback)) fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun tools(tools: String) = tools(JsonField.of(tools)) + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun tools(tools: JsonField) = apply { this.tools = tools } fun additionalProperties(additionalProperties: Map) = apply { @@ -1391,19 +1676,50 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -1457,14 +1773,35 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = @@ -1634,19 +1971,50 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -1700,19 +2068,42 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: Content) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } + /** Alias for calling [content] with `Content.ofText(text)`. */ fun content(text: String) = content(Content.ofText(text)) + /** Alias for calling [content] with `Content.ofArray(array)`. */ fun contentOfArray(array: List) = content(Content.ofArray(array)) fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = @@ -2216,31 +2607,82 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun toolCalls(): Optional> = Optional.ofNullable(toolCalls.getNullable("tool_calls")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("function_call") @ExcludeMissing fun _functionCall(): JsonField = functionCall + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [toolCalls]. + * + * Unlike [toolCalls], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls(): JsonField> = toolCalls @@ -2304,41 +2746,90 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String?) = content(JsonField.ofNullable(content)) + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ fun content(content: Optional) = content(content.getOrNull()) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun functionCall(functionCall: FunctionCall?) = functionCall(JsonField.ofNullable(functionCall)) + /** + * Alias for calling [Builder.functionCall] with + * `functionCall.orElse(null)`. + */ fun functionCall(functionCall: Optional) = functionCall(functionCall.getOrNull()) + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed + * [FunctionCall] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun functionCall(functionCall: JsonField) = apply { this.functionCall = functionCall } fun name(name: String?) = name(JsonField.ofNullable(name)) + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun toolCalls(toolCalls: List?) = toolCalls(JsonField.ofNullable(toolCalls)) + /** Alias for calling [Builder.toolCalls] with `toolCalls.orElse(null)`. */ fun toolCalls(toolCalls: Optional>) = toolCalls(toolCalls.getOrNull()) + /** + * Sets [Builder.toolCalls] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCalls] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ fun toolCalls(toolCalls: JsonField>) = apply { this.toolCalls = toolCalls.map { it.toMutableList() } } + /** + * Adds a single [ChatCompletionMessageToolCall] to [toolCalls]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ fun addToolCall(toolCall: ChatCompletionMessageToolCall) = apply { toolCalls = (toolCalls ?: JsonField.of(mutableListOf())).also { @@ -2495,14 +2986,36 @@ private constructor( immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun arguments(): String = arguments.getRequired("arguments") + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * Returns the raw JSON value of [arguments]. + * + * Unlike [arguments], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("arguments") @ExcludeMissing fun _arguments(): JsonField = arguments + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -2556,12 +3069,26 @@ private constructor( fun arguments(arguments: String) = arguments(JsonField.of(arguments)) + /** + * Sets [Builder.arguments] to an arbitrary JSON value. + * + * You should usually call [Builder.arguments] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun arguments(arguments: JsonField) = apply { this.arguments = arguments } fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = @@ -2647,20 +3174,51 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun toolCallId(): Optional = Optional.ofNullable(toolCallId.getNullable("tool_call_id")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + /** + * Returns the raw JSON value of [toolCallId]. + * + * Unlike [toolCallId], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId(): JsonField = toolCallId @@ -2716,14 +3274,35 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) + /** + * Sets [Builder.toolCallId] to an arbitrary JSON value. + * + * You should usually call [Builder.toolCallId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun toolCallId(toolCallId: JsonField) = apply { this.toolCallId = toolCallId } @@ -2895,17 +3474,49 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @@ -2962,14 +3573,35 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String) = content(JsonField.of(content)) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = @@ -3136,13 +3768,34 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun role(): Role = role.getRequired("role") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ fun content(): Optional = Optional.ofNullable(content.getNullable("content")) + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content @@ -3195,12 +3848,27 @@ private constructor( fun role(role: Role) = role(JsonField.of(role)) + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun role(role: JsonField) = apply { this.role = role } fun content(content: String?) = content(JsonField.ofNullable(content)) + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ fun content(content: Optional) = content(content.getOrNull()) + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun content(content: JsonField) = apply { this.content = content } fun additionalProperties(additionalProperties: Map) = @@ -3619,12 +4287,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun id(): String = id.getRequired("id") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -3675,10 +4363,24 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun id(id: JsonField) = apply { this.id = id } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -3840,12 +4542,32 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -3896,10 +4618,24 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index ab888cab..d9c17853 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -166,13 +166,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -181,61 +175,56 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Project id */ fun projectId(projectId: String?) = apply { this.projectId = projectId } - /** Project id */ + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) /** Name of the project to search for */ fun projectName(projectName: String?) = apply { this.projectName = projectName } - /** Name of the project to search for */ + /** Alias for calling [Builder.projectName] with `projectName.orElse(null)`. */ fun projectName(projectName: Optional) = projectName(projectName.getOrNull()) /** Name of the prompt to search for */ fun promptName(promptName: String?) = apply { this.promptName = promptName } - /** Name of the prompt to search for */ + /** Alias for calling [Builder.promptName] with `promptName.orElse(null)`. */ fun promptName(promptName: Optional) = promptName(promptName.getOrNull()) /** Retrieve prompt with a specific slug */ fun slug(slug: String?) = apply { this.slug = slug } - /** Retrieve prompt with a specific slug */ + /** Alias for calling [Builder.slug] with `slug.orElse(null)`. */ fun slug(slug: Optional) = slug(slug.getOrNull()) /** @@ -247,13 +236,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) @@ -265,12 +248,7 @@ private constructor( */ fun version(version: String?) = apply { this.version = version } - /** - * Retrieve prompt at a specific version. - * - * The version id can either be a transaction id (e.g. '1000192656880881099') or a version - * identifier (e.g. '81cd05ee665fdfb3'). - */ + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ fun version(version: Optional) = version(version.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 4680666c..2b833a99 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -45,16 +45,43 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun model(): Optional = Optional.ofNullable(model.getNullable("model")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun params(): Optional = Optional.ofNullable(params.getNullable("params")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun position(): Optional = Optional.ofNullable(position.getNullable("position")) + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + /** + * Returns the raw JSON value of [params]. + * + * Unlike [params], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position @JsonAnyGetter @@ -100,29 +127,52 @@ private constructor( fun model(model: String) = model(JsonField.of(model)) + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun model(model: JsonField) = apply { this.model = model } fun params(params: Params) = params(JsonField.of(params)) + /** + * Sets [Builder.params] to an arbitrary JSON value. + * + * You should usually call [Builder.params] with a well-typed [Params] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun params(params: JsonField) = apply { this.params = params } + /** Alias for calling [params] with `Params.ofOpenAIModel(openaiModel)`. */ fun params(openaiModel: Params.OpenAIModelParams) = params(Params.ofOpenAIModel(openaiModel)) + /** Alias for calling [params] with `Params.ofAnthropicModel(anthropicModel)`. */ fun params(anthropicModel: Params.AnthropicModelParams) = params(Params.ofAnthropicModel(anthropicModel)) + /** Alias for calling [params] with `Params.ofGoogleModel(googleModel)`. */ fun params(googleModel: Params.GoogleModelParams) = params(Params.ofGoogleModel(googleModel)) + /** Alias for calling [params] with `Params.ofWindowAiModel(windowAiModel)`. */ fun params(windowAiModel: Params.WindowAiModelParams) = params(Params.ofWindowAiModel(windowAiModel)) + /** Alias for calling [params] with `Params.ofJsCompletion(jsCompletion)`. */ fun params(jsCompletion: Params.JsCompletionParams) = params(Params.ofJsCompletion(jsCompletion)) fun position(position: String) = position(JsonField.of(position)) + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun position(position: JsonField) = apply { this.position = position } fun additionalProperties(additionalProperties: Map) = apply { @@ -400,86 +450,213 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun frequencyPenalty(): Optional = Optional.ofNullable(frequencyPenalty.getNullable("frequency_penalty")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun functionCall(): Optional = Optional.ofNullable(functionCall.getNullable("function_call")) - /** The successor to max_tokens */ + /** + * The successor to max_tokens + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun maxCompletionTokens(): Optional = Optional.ofNullable(maxCompletionTokens.getNullable("max_completion_tokens")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun maxTokens(): Optional = Optional.ofNullable(maxTokens.getNullable("max_tokens")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun n(): Optional = Optional.ofNullable(n.getNullable("n")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun presencePenalty(): Optional = Optional.ofNullable(presencePenalty.getNullable("presence_penalty")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun reasoningEffort(): Optional = Optional.ofNullable(reasoningEffort.getNullable("reasoning_effort")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun responseFormat(): Optional = Optional.ofNullable(responseFormat.getNullable("response_format")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun stop(): Optional> = Optional.ofNullable(stop.getNullable("stop")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun toolChoice(): Optional = Optional.ofNullable(toolChoice.getNullable("tool_choice")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + /** + * Returns the raw JSON value of [frequencyPenalty]. + * + * Unlike [frequencyPenalty], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("frequency_penalty") @ExcludeMissing fun _frequencyPenalty(): JsonField = frequencyPenalty + /** + * Returns the raw JSON value of [functionCall]. + * + * Unlike [functionCall], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_call") @ExcludeMissing fun _functionCall(): JsonField = functionCall - /** The successor to max_tokens */ + /** + * Returns the raw JSON value of [maxCompletionTokens]. + * + * Unlike [maxCompletionTokens], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("max_completion_tokens") @ExcludeMissing fun _maxCompletionTokens(): JsonField = maxCompletionTokens + /** + * Returns the raw JSON value of [maxTokens]. + * + * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens + /** + * Returns the raw JSON value of [n]. + * + * Unlike [n], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("n") @ExcludeMissing fun _n(): JsonField = n + /** + * Returns the raw JSON value of [presencePenalty]. + * + * Unlike [presencePenalty], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("presence_penalty") @ExcludeMissing fun _presencePenalty(): JsonField = presencePenalty + /** + * Returns the raw JSON value of [reasoningEffort]. + * + * Unlike [reasoningEffort], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("reasoning_effort") @ExcludeMissing fun _reasoningEffort(): JsonField = reasoningEffort + /** + * Returns the raw JSON value of [responseFormat]. + * + * Unlike [responseFormat], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("response_format") @ExcludeMissing fun _responseFormat(): JsonField = responseFormat + /** + * Returns the raw JSON value of [stop]. + * + * Unlike [stop], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("stop") @ExcludeMissing fun _stop(): JsonField> = stop + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("temperature") @ExcludeMissing fun _temperature(): JsonField = temperature + /** + * Returns the raw JSON value of [toolChoice]. + * + * Unlike [toolChoice], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice(): JsonField = toolChoice + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + /** + * Returns the raw JSON value of [useCache]. + * + * Unlike [useCache], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("use_cache") @ExcludeMissing fun _useCache(): JsonField = useCache @@ -560,6 +737,13 @@ private constructor( fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) + /** + * Sets [Builder.frequencyPenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.frequencyPenalty] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun frequencyPenalty(frequencyPenalty: JsonField) = apply { this.frequencyPenalty = frequencyPenalty } @@ -567,13 +751,25 @@ private constructor( fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) + /** + * Sets [Builder.functionCall] to an arbitrary JSON value. + * + * You should usually call [Builder.functionCall] with a well-typed [FunctionCall] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun functionCall(functionCall: JsonField) = apply { this.functionCall = functionCall } + /** + * Alias for calling [functionCall] with + * `FunctionCall.ofUnionMember0(unionMember0)`. + */ fun functionCall(unionMember0: FunctionCall.UnionMember0) = functionCall(FunctionCall.ofUnionMember0(unionMember0)) + /** Alias for calling [functionCall] with `FunctionCall.ofFunction(function)`. */ fun functionCall(function: FunctionCall.Function) = functionCall(FunctionCall.ofFunction(function)) @@ -581,22 +777,49 @@ private constructor( fun maxCompletionTokens(maxCompletionTokens: Double) = maxCompletionTokens(JsonField.of(maxCompletionTokens)) - /** The successor to max_tokens */ + /** + * Sets [Builder.maxCompletionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxCompletionTokens] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun maxCompletionTokens(maxCompletionTokens: JsonField) = apply { this.maxCompletionTokens = maxCompletionTokens } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) + /** + * Sets [Builder.maxTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTokens] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } fun n(n: Double) = n(JsonField.of(n)) + /** + * Sets [Builder.n] to an arbitrary JSON value. + * + * You should usually call [Builder.n] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun n(n: JsonField) = apply { this.n = n } fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) + /** + * Sets [Builder.presencePenalty] to an arbitrary JSON value. + * + * You should usually call [Builder.presencePenalty] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun presencePenalty(presencePenalty: JsonField) = apply { this.presencePenalty = presencePenalty } @@ -604,6 +827,13 @@ private constructor( fun reasoningEffort(reasoningEffort: ReasoningEffort) = reasoningEffort(JsonField.of(reasoningEffort)) + /** + * Sets [Builder.reasoningEffort] to an arbitrary JSON value. + * + * You should usually call [Builder.reasoningEffort] with a well-typed + * [ReasoningEffort] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ fun reasoningEffort(reasoningEffort: JsonField) = apply { this.reasoningEffort = reasoningEffort } @@ -611,28 +841,59 @@ private constructor( fun responseFormat(responseFormat: ResponseFormat?) = responseFormat(JsonField.ofNullable(responseFormat)) + /** + * Alias for calling [Builder.responseFormat] with `responseFormat.orElse(null)`. + */ fun responseFormat(responseFormat: Optional) = responseFormat(responseFormat.getOrNull()) + /** + * Sets [Builder.responseFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.responseFormat] with a well-typed + * [ResponseFormat] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ fun responseFormat(responseFormat: JsonField) = apply { this.responseFormat = responseFormat } + /** + * Alias for calling [responseFormat] with + * `ResponseFormat.ofJsonObject(jsonObject)`. + */ fun responseFormat(jsonObject: ResponseFormat.JsonObject) = responseFormat(ResponseFormat.ofJsonObject(jsonObject)) + /** + * Alias for calling [responseFormat] with + * `ResponseFormat.ofJsonSchema(jsonSchema)`. + */ fun responseFormat(jsonSchema: ResponseFormat.JsonSchema) = responseFormat(ResponseFormat.ofJsonSchema(jsonSchema)) + /** Alias for calling [responseFormat] with `ResponseFormat.ofText(text)`. */ fun responseFormat(text: ResponseFormat.Text) = responseFormat(ResponseFormat.ofText(text)) fun stop(stop: List) = stop(JsonField.of(stop)) + /** + * Sets [Builder.stop] to an arbitrary JSON value. + * + * You should usually call [Builder.stop] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun stop(stop: JsonField>) = apply { this.stop = stop.map { it.toMutableList() } } + /** + * Adds a single [String] to [Builder.stop]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addStop(stop: String) = apply { this.stop = (this.stop ?: JsonField.of(mutableListOf())).also { @@ -642,28 +903,60 @@ private constructor( fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun temperature(temperature: JsonField) = apply { this.temperature = temperature } fun toolChoice(toolChoice: ToolChoice) = toolChoice(JsonField.of(toolChoice)) + /** + * Sets [Builder.toolChoice] to an arbitrary JSON value. + * + * You should usually call [Builder.toolChoice] with a well-typed [ToolChoice] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun toolChoice(toolChoice: JsonField) = apply { this.toolChoice = toolChoice } + /** + * Alias for calling [toolChoice] with `ToolChoice.ofUnionMember0(unionMember0)`. + */ fun toolChoice(unionMember0: ToolChoice.UnionMember0) = toolChoice(ToolChoice.ofUnionMember0(unionMember0)) + /** Alias for calling [toolChoice] with `ToolChoice.ofFunction(function)`. */ fun toolChoice(function: ToolChoice.Function) = toolChoice(ToolChoice.ofFunction(function)) fun topP(topP: Double) = topP(JsonField.of(topP)) + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun topP(topP: JsonField) = apply { this.topP = topP } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + /** + * Sets [Builder.useCache] to an arbitrary JSON value. + * + * You should usually call [Builder.useCache] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun useCache(useCache: JsonField) = apply { this.useCache = useCache } fun additionalProperties(additionalProperties: Map) = apply { @@ -963,8 +1256,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -1012,6 +1316,13 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = @@ -1350,8 +1661,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1399,6 +1721,13 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1563,14 +1892,36 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun jsonSchema(): InnerJsonSchema = jsonSchema.getRequired("json_schema") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [jsonSchema]. + * + * Unlike [jsonSchema], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("json_schema") @ExcludeMissing fun _jsonSchema(): JsonField = jsonSchema + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -1623,12 +1974,26 @@ private constructor( fun jsonSchema(jsonSchema: InnerJsonSchema) = jsonSchema(JsonField.of(jsonSchema)) + /** + * Sets [Builder.jsonSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.jsonSchema] with a well-typed + * [InnerJsonSchema] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun jsonSchema(jsonSchema: JsonField) = apply { this.jsonSchema = jsonSchema } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -1682,27 +2047,71 @@ private constructor( immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ fun schema(): Optional = Optional.ofNullable(schema.getNullable("schema")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ fun strict(): Optional = Optional.ofNullable(strict.getNullable("strict")) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [schema]. + * + * Unlike [schema], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("schema") @ExcludeMissing fun _schema(): JsonField = schema + /** + * Returns the raw JSON value of [strict]. + * + * Unlike [strict], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("strict") @ExcludeMissing fun _strict(): JsonField = strict @@ -1763,29 +2172,65 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun description(description: String) = description(JsonField.of(description)) + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun description(description: JsonField) = apply { this.description = description } fun schema(schema: Schema) = schema(JsonField.of(schema)) + /** + * Sets [Builder.schema] to an arbitrary JSON value. + * + * You should usually call [Builder.schema] with a well-typed [Schema] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun schema(schema: JsonField) = apply { this.schema = schema } + /** Alias for calling [schema] with `Schema.ofObject(object_)`. */ fun schema(object_: Schema.Object) = schema(Schema.ofObject(object_)) + /** Alias for calling [schema] with `Schema.ofString(string)`. */ fun schema(string: String) = schema(Schema.ofString(string)) fun strict(strict: Boolean?) = strict(JsonField.ofNullable(strict)) + /** + * Alias for [Builder.strict]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun strict(strict: Boolean) = strict(strict as Boolean?) + /** Alias for calling [Builder.strict] with `strict.orElse(null)`. */ fun strict(strict: Optional) = strict(strict.getOrNull()) + /** + * Sets [Builder.strict] to an arbitrary JSON value. + * + * You should usually call [Builder.strict] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun strict(strict: JsonField) = apply { this.strict = strict } fun additionalProperties(additionalProperties: Map) = @@ -2199,8 +2644,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -2248,6 +2704,13 @@ private constructor( fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -2660,14 +3123,36 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun function(): InnerFunction = function.getRequired("function") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded with + * an unexpected value). + */ fun type(): Type = type.getRequired("type") + /** + * Returns the raw JSON value of [function]. + * + * Unlike [function], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("function") @ExcludeMissing fun _function(): JsonField = function + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -2719,12 +3204,26 @@ private constructor( fun function(function: InnerFunction) = function(JsonField.of(function)) + /** + * Sets [Builder.function] to an arbitrary JSON value. + * + * You should usually call [Builder.function] with a well-typed + * [InnerFunction] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun function(function: JsonField) = apply { this.function = function } fun type(type: Type) = type(JsonField.of(type)) + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = @@ -2769,8 +3268,19 @@ private constructor( immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the server + * responded with an unexpected value). + */ fun name(): String = name.getRequired("name") + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @@ -2820,6 +3330,13 @@ private constructor( fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = @@ -3036,45 +3553,115 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun maxTokens(): Double = maxTokens.getRequired("max_tokens") + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ fun temperature(): Double = temperature.getRequired("temperature") - /** This is a legacy parameter that should not be used. */ + /** + * This is a legacy parameter that should not be used. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun maxTokensToSample(): Optional = Optional.ofNullable(maxTokensToSample.getNullable("max_tokens_to_sample")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun stopSequences(): Optional> = Optional.ofNullable(stopSequences.getNullable("stop_sequences")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun topK(): Optional = Optional.ofNullable(topK.getNullable("top_k")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun topP(): Optional = Optional.ofNullable(topP.getNullable("top_p")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + /** + * Returns the raw JSON value of [maxTokens]. + * + * Unlike [maxTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("temperature") @ExcludeMissing fun _temperature(): JsonField = temperature - /** This is a legacy parameter that should not be used. */ + /** + * Returns the raw JSON value of [maxTokensToSample]. + * + * Unlike [maxTokensToSample], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("max_tokens_to_sample") @ExcludeMissing fun _maxTokensToSample(): JsonField = maxTokensToSample + /** + * Returns the raw JSON value of [stopSequences]. + * + * Unlike [stopSequences], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("stop_sequences") @ExcludeMissing fun _stopSequences(): JsonField> = stopSequences + /** + * Returns the raw JSON value of [topK]. + * + * Unlike [topK], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("top_k") @ExcludeMissing fun _topK(): JsonField = topK + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("top_p") @ExcludeMissing fun _topP(): JsonField = topP + /** + * Returns the raw JSON value of [useCache]. + * + * Unlike [useCache], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("use_cache") @ExcludeMissing fun _useCache(): JsonField = useCache @@ -3142,10 +3729,24 @@ private constructor( fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) + /** + * Sets [Builder.maxTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTokens] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun temperature(temperature: JsonField) = apply { this.temperature = temperature } @@ -3154,7 +3755,13 @@ private constructor( fun maxTokensToSample(maxTokensToSample: Double) = maxTokensToSample(JsonField.of(maxTokensToSample)) - /** This is a legacy parameter that should not be used. */ + /** + * Sets [Builder.maxTokensToSample] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTokensToSample] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun maxTokensToSample(maxTokensToSample: JsonField) = apply { this.maxTokensToSample = maxTokensToSample } @@ -3162,10 +3769,22 @@ private constructor( fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) + /** + * Sets [Builder.stopSequences] to an arbitrary JSON value. + * + * You should usually call [Builder.stopSequences] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun stopSequences(stopSequences: JsonField>) = apply { this.stopSequences = stopSequences.map { it.toMutableList() } } + /** + * Adds a single [String] to [stopSequences]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addStopSequence(stopSequence: String) = apply { stopSequences = (stopSequences ?: JsonField.of(mutableListOf())).also { @@ -3175,14 +3794,35 @@ private constructor( fun topK(topK: Double) = topK(JsonField.of(topK)) + /** + * Sets [Builder.topK] to an arbitrary JSON value. + * + * You should usually call [Builder.topK] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun topK(topK: JsonField) = apply { this.topK = topK } fun topP(topP: Double) = topP(JsonField.of(topP)) + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun topP(topP: JsonField) = apply { this.topP = topP } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + /** + * Sets [Builder.useCache] to an arbitrary JSON value. + * + * You should usually call [Builder.useCache] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun useCache(useCache: JsonField) = apply { this.useCache = useCache } fun additionalProperties(additionalProperties: Map) = apply { @@ -3261,31 +3901,79 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun maxOutputTokens(): Optional = Optional.ofNullable(maxOutputTokens.getNullable("maxOutputTokens")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun topP(): Optional = Optional.ofNullable(topP.getNullable("topP")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + /** + * Returns the raw JSON value of [maxOutputTokens]. + * + * Unlike [maxOutputTokens], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens(): JsonField = maxOutputTokens + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("temperature") @ExcludeMissing fun _temperature(): JsonField = temperature + /** + * Returns the raw JSON value of [topK]. + * + * Unlike [topK], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK + /** + * Returns the raw JSON value of [topP]. + * + * Unlike [topP], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("topP") @ExcludeMissing fun _topP(): JsonField = topP + /** + * Returns the raw JSON value of [useCache]. + * + * Unlike [useCache], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("use_cache") @ExcludeMissing fun _useCache(): JsonField = useCache @@ -3342,26 +4030,61 @@ private constructor( fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) + /** + * Sets [Builder.maxOutputTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.maxOutputTokens] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ fun maxOutputTokens(maxOutputTokens: JsonField) = apply { this.maxOutputTokens = maxOutputTokens } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun temperature(temperature: JsonField) = apply { this.temperature = temperature } fun topK(topK: Double) = topK(JsonField.of(topK)) + /** + * Sets [Builder.topK] to an arbitrary JSON value. + * + * You should usually call [Builder.topK] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun topK(topK: JsonField) = apply { this.topK = topK } fun topP(topP: Double) = topP(JsonField.of(topP)) + /** + * Sets [Builder.topP] to an arbitrary JSON value. + * + * You should usually call [Builder.topP] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun topP(topP: JsonField) = apply { this.topP = topP } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + /** + * Sets [Builder.useCache] to an arbitrary JSON value. + * + * You should usually call [Builder.useCache] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun useCache(useCache: JsonField) = apply { this.useCache = useCache } fun additionalProperties(additionalProperties: Map) = apply { @@ -3432,20 +4155,49 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun temperature(): Optional = Optional.ofNullable(temperature.getNullable("temperature")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun topK(): Optional = Optional.ofNullable(topK.getNullable("topK")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + /** + * Returns the raw JSON value of [temperature]. + * + * Unlike [temperature], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("temperature") @ExcludeMissing fun _temperature(): JsonField = temperature + /** + * Returns the raw JSON value of [topK]. + * + * Unlike [topK], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("topK") @ExcludeMissing fun _topK(): JsonField = topK + /** + * Returns the raw JSON value of [useCache]. + * + * Unlike [useCache], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("use_cache") @ExcludeMissing fun _useCache(): JsonField = useCache @@ -3495,16 +4247,37 @@ private constructor( fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) + /** + * Sets [Builder.temperature] to an arbitrary JSON value. + * + * You should usually call [Builder.temperature] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun temperature(temperature: JsonField) = apply { this.temperature = temperature } fun topK(topK: Double) = topK(JsonField.of(topK)) + /** + * Sets [Builder.topK] to an arbitrary JSON value. + * + * You should usually call [Builder.topK] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun topK(topK: JsonField) = apply { this.topK = topK } fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + /** + * Sets [Builder.useCache] to an arbitrary JSON value. + * + * You should usually call [Builder.useCache] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun useCache(useCache: JsonField) = apply { this.useCache = useCache } fun additionalProperties(additionalProperties: Map) = apply { @@ -3567,9 +4340,19 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ fun useCache(): Optional = Optional.ofNullable(useCache.getNullable("use_cache")) + /** + * Returns the raw JSON value of [useCache]. + * + * Unlike [useCache], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("use_cache") @ExcludeMissing fun _useCache(): JsonField = useCache @@ -3613,6 +4396,13 @@ private constructor( fun useCache(useCache: Boolean) = useCache(JsonField.of(useCache)) + /** + * Sets [Builder.useCache] to an arbitrary JSON value. + * + * You should usually call [Builder.useCache] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun useCache(useCache: JsonField) = apply { this.useCache = useCache } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index cf0797b3..5ab67b6c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -35,44 +35,107 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = body.slug() - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun functionType(): Optional = body.functionType() - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun promptData(): Optional = body.promptData() - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = body.tags() - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ fun _slug(): JsonField = body._slug() - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _functionType(): JsonField = body._functionType() - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _promptData(): JsonField = body._promptData() - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ fun _tags(): JsonField> = body._tags() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -116,53 +179,117 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the prompt belongs under */ + /** + * Unique identifier for the project that the prompt belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun slug(): String = slug.getRequired("slug") - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun functionType(): Optional = Optional.ofNullable(functionType.getNullable("function_type")) - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the prompt belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [functionType]. + * + * Unlike [functionType], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("function_type") @ExcludeMissing fun _functionType(): JsonField = functionType - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_data") @ExcludeMissing fun _promptData(): JsonField = promptData - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -230,28 +357,52 @@ private constructor( /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -259,9 +410,17 @@ private constructor( fun functionType(functionType: FunctionType?) = functionType(JsonField.ofNullable(functionType)) + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { this.functionType = functionType } @@ -269,10 +428,16 @@ private constructor( /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } @@ -280,15 +445,25 @@ private constructor( /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } @@ -379,35 +554,65 @@ private constructor( /** Name of the prompt */ fun name(name: String) = apply { body.name(name) } - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the prompt belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** Unique identifier for the prompt */ fun slug(slug: String) = apply { body.slug(slug) } - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun slug(slug: JsonField) = apply { body.slug(slug) } /** Textual description of the prompt */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } fun functionType(functionType: FunctionType?) = apply { body.functionType(functionType) } + /** Alias for calling [Builder.functionType] with `functionType.orElse(null)`. */ fun functionType(functionType: Optional) = functionType(functionType.getOrNull()) + /** + * Sets [Builder.functionType] to an arbitrary JSON value. + * + * You should usually call [Builder.functionType] with a well-typed [FunctionType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun functionType(functionType: JsonField) = apply { body.functionType(functionType) } @@ -415,22 +620,38 @@ private constructor( /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** A list of tags for the prompt */ fun tags(tags: List?) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { body.addTag(tag) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index d8447483..c4f6f117 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -14,6 +14,7 @@ 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,34 +39,79 @@ private constructor( /** Prompt id */ fun promptId(): String = promptId - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun promptData(): Optional = body.promptData() - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun slug(): Optional = body.slug() - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tags(): Optional> = body.tags() - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _promptData(): JsonField = body._promptData() - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ fun _slug(): JsonField = body._slug() - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ fun _tags(): JsonField> = body._tags() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -110,40 +156,85 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Textual description of the prompt */ + /** + * Textual description of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the prompt */ + /** + * Name of the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** The prompt, model, and its parameters */ + /** + * The prompt, model, and its parameters + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun promptData(): Optional = Optional.ofNullable(promptData.getNullable("prompt_data")) - /** Unique identifier for the prompt */ + /** + * Unique identifier for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun slug(): Optional = Optional.ofNullable(slug.getNullable("slug")) - /** A list of tags for the prompt */ + /** + * A list of tags for the prompt + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun tags(): Optional> = Optional.ofNullable(tags.getNullable("tags")) - /** Textual description of the prompt */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** Name of the prompt */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The prompt, model, and its parameters */ + /** + * Returns the raw JSON value of [promptData]. + * + * Unlike [promptData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("prompt_data") @ExcludeMissing fun _promptData(): JsonField = promptData - /** Unique identifier for the prompt */ + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug - /** A list of tags for the prompt */ + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags @JsonAnyGetter @@ -196,10 +287,16 @@ private constructor( /** Textual description of the prompt */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -207,19 +304,31 @@ private constructor( /** Name of the prompt */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the prompt */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = promptData(JsonField.ofNullable(promptData)) - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { this.promptData = promptData } @@ -227,24 +336,40 @@ private constructor( /** Unique identifier for the prompt */ fun slug(slug: String?) = slug(JsonField.ofNullable(slug)) - /** Unique identifier for the prompt */ + /** Alias for calling [Builder.slug] with `slug.orElse(null)`. */ fun slug(slug: Optional) = slug(slug.getOrNull()) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun slug(slug: JsonField) = apply { this.slug = slug } /** A list of tags for the prompt */ fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun tags(tags: JsonField>) = apply { this.tags = tags.map { it.toMutableList() } } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } @@ -336,49 +461,81 @@ private constructor( /** Textual description of the prompt */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the prompt */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the prompt */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** Name of the prompt */ fun name(name: String?) = apply { body.name(name) } - /** Name of the prompt */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the prompt */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData?) = apply { body.promptData(promptData) } - /** The prompt, model, and its parameters */ + /** Alias for calling [Builder.promptData] with `promptData.orElse(null)`. */ fun promptData(promptData: Optional) = promptData(promptData.getOrNull()) - /** The prompt, model, and its parameters */ + /** + * Sets [Builder.promptData] to an arbitrary JSON value. + * + * You should usually call [Builder.promptData] with a well-typed [PromptData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun promptData(promptData: JsonField) = apply { body.promptData(promptData) } /** Unique identifier for the prompt */ fun slug(slug: String?) = apply { body.slug(slug) } - /** Unique identifier for the prompt */ + /** Alias for calling [Builder.slug] with `slug.orElse(null)`. */ fun slug(slug: Optional) = slug(slug.getOrNull()) - /** Unique identifier for the prompt */ + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun slug(slug: JsonField) = apply { body.slug(slug) } /** A list of tags for the prompt */ fun tags(tags: List?) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ fun tags(tags: Optional>) = tags(tags.getOrNull()) - /** A list of tags for the prompt */ + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tags(tags: JsonField>) = apply { body.tags(tags) } - /** A list of tags for the prompt */ + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: String) = apply { body.addTag(tag) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index a938b801..3a1bb0be 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -9,6 +9,7 @@ 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 @@ -48,70 +49,146 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Email of the author of the most recent commit */ + /** + * Email of the author of the most recent commit + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun authorEmail(): Optional = Optional.ofNullable(authorEmail.getNullable("author_email")) - /** Name of the author of the most recent commit */ + /** + * Name of the author of the most recent commit + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun authorName(): Optional = Optional.ofNullable(authorName.getNullable("author_name")) - /** Name of the branch the most recent commit belongs to */ + /** + * Name of the branch the most recent commit belongs to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun branch(): Optional = Optional.ofNullable(branch.getNullable("branch")) - /** SHA of most recent commit */ + /** + * SHA of most recent commit + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun commit(): Optional = Optional.ofNullable(commit.getNullable("commit")) - /** Most recent commit message */ + /** + * Most recent commit message + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun commitMessage(): Optional = Optional.ofNullable(commitMessage.getNullable("commit_message")) - /** Time of the most recent commit */ + /** + * Time of the most recent commit + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun commitTime(): Optional = Optional.ofNullable(commitTime.getNullable("commit_time")) - /** Whether or not the repo had uncommitted changes when snapshotted */ + /** + * Whether or not the repo had uncommitted changes when snapshotted + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun dirty(): Optional = Optional.ofNullable(dirty.getNullable("dirty")) /** * If the repo was dirty when run, this includes the diff between the current state of the repo * and the most recent commit. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun gitDiff(): Optional = Optional.ofNullable(gitDiff.getNullable("git_diff")) - /** Name of the tag on the most recent commit */ + /** + * Name of the tag on the most recent commit + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tag(): Optional = Optional.ofNullable(tag.getNullable("tag")) - /** Email of the author of the most recent commit */ + /** + * Returns the raw JSON value of [authorEmail]. + * + * Unlike [authorEmail], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("author_email") @ExcludeMissing fun _authorEmail(): JsonField = authorEmail - /** Name of the author of the most recent commit */ + /** + * Returns the raw JSON value of [authorName]. + * + * Unlike [authorName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("author_name") @ExcludeMissing fun _authorName(): JsonField = authorName - /** Name of the branch the most recent commit belongs to */ + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch - /** SHA of most recent commit */ + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit - /** Most recent commit message */ + /** + * Returns the raw JSON value of [commitMessage]. + * + * Unlike [commitMessage], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("commit_message") @ExcludeMissing fun _commitMessage(): JsonField = commitMessage - /** Time of the most recent commit */ + /** + * Returns the raw JSON value of [commitTime]. + * + * Unlike [commitTime], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("commit_time") @ExcludeMissing fun _commitTime(): JsonField = commitTime - /** Whether or not the repo had uncommitted changes when snapshotted */ + /** + * Returns the raw JSON value of [dirty]. + * + * Unlike [dirty], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("dirty") @ExcludeMissing fun _dirty(): JsonField = dirty /** - * If the repo was dirty when run, this includes the diff between the current state of the repo - * and the most recent commit. + * Returns the raw JSON value of [gitDiff]. + * + * Unlike [gitDiff], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("git_diff") @ExcludeMissing fun _gitDiff(): JsonField = gitDiff - /** Name of the tag on the most recent commit */ + /** + * Returns the raw JSON value of [tag]. + * + * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField = tag @JsonAnyGetter @@ -176,48 +253,76 @@ private constructor( /** Email of the author of the most recent commit */ fun authorEmail(authorEmail: String?) = authorEmail(JsonField.ofNullable(authorEmail)) - /** Email of the author of the most recent commit */ + /** Alias for calling [Builder.authorEmail] with `authorEmail.orElse(null)`. */ fun authorEmail(authorEmail: Optional) = authorEmail(authorEmail.getOrNull()) - /** Email of the author of the most recent commit */ + /** + * Sets [Builder.authorEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.authorEmail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun authorEmail(authorEmail: JsonField) = apply { this.authorEmail = authorEmail } /** Name of the author of the most recent commit */ fun authorName(authorName: String?) = authorName(JsonField.ofNullable(authorName)) - /** Name of the author of the most recent commit */ + /** Alias for calling [Builder.authorName] with `authorName.orElse(null)`. */ fun authorName(authorName: Optional) = authorName(authorName.getOrNull()) - /** Name of the author of the most recent commit */ + /** + * Sets [Builder.authorName] to an arbitrary JSON value. + * + * You should usually call [Builder.authorName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun authorName(authorName: JsonField) = apply { this.authorName = authorName } /** Name of the branch the most recent commit belongs to */ fun branch(branch: String?) = branch(JsonField.ofNullable(branch)) - /** Name of the branch the most recent commit belongs to */ + /** Alias for calling [Builder.branch] with `branch.orElse(null)`. */ fun branch(branch: Optional) = branch(branch.getOrNull()) - /** Name of the branch the most recent commit belongs to */ + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun branch(branch: JsonField) = apply { this.branch = branch } /** SHA of most recent commit */ fun commit(commit: String?) = commit(JsonField.ofNullable(commit)) - /** SHA of most recent commit */ + /** Alias for calling [Builder.commit] with `commit.orElse(null)`. */ fun commit(commit: Optional) = commit(commit.getOrNull()) - /** SHA of most recent commit */ + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun commit(commit: JsonField) = apply { this.commit = commit } /** Most recent commit message */ fun commitMessage(commitMessage: String?) = commitMessage(JsonField.ofNullable(commitMessage)) - /** Most recent commit message */ + /** Alias for calling [Builder.commitMessage] with `commitMessage.orElse(null)`. */ fun commitMessage(commitMessage: Optional) = commitMessage(commitMessage.getOrNull()) - /** Most recent commit message */ + /** + * Sets [Builder.commitMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.commitMessage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun commitMessage(commitMessage: JsonField) = apply { this.commitMessage = commitMessage } @@ -225,22 +330,37 @@ private constructor( /** Time of the most recent commit */ fun commitTime(commitTime: String?) = commitTime(JsonField.ofNullable(commitTime)) - /** Time of the most recent commit */ + /** Alias for calling [Builder.commitTime] with `commitTime.orElse(null)`. */ fun commitTime(commitTime: Optional) = commitTime(commitTime.getOrNull()) - /** Time of the most recent commit */ + /** + * Sets [Builder.commitTime] to an arbitrary JSON value. + * + * You should usually call [Builder.commitTime] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun commitTime(commitTime: JsonField) = apply { this.commitTime = commitTime } /** Whether or not the repo had uncommitted changes when snapshotted */ fun dirty(dirty: Boolean?) = dirty(JsonField.ofNullable(dirty)) - /** Whether or not the repo had uncommitted changes when snapshotted */ + /** + * Alias for [Builder.dirty]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun dirty(dirty: Boolean) = dirty(dirty as Boolean?) - /** Whether or not the repo had uncommitted changes when snapshotted */ + /** Alias for calling [Builder.dirty] with `dirty.orElse(null)`. */ fun dirty(dirty: Optional) = dirty(dirty.getOrNull()) - /** Whether or not the repo had uncommitted changes when snapshotted */ + /** + * Sets [Builder.dirty] to an arbitrary JSON value. + * + * You should usually call [Builder.dirty] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun dirty(dirty: JsonField) = apply { this.dirty = dirty } /** @@ -249,25 +369,29 @@ private constructor( */ fun gitDiff(gitDiff: String?) = gitDiff(JsonField.ofNullable(gitDiff)) - /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. - */ + /** Alias for calling [Builder.gitDiff] with `gitDiff.orElse(null)`. */ fun gitDiff(gitDiff: Optional) = gitDiff(gitDiff.getOrNull()) /** - * If the repo was dirty when run, this includes the diff between the current state of the - * repo and the most recent commit. + * Sets [Builder.gitDiff] to an arbitrary JSON value. + * + * You should usually call [Builder.gitDiff] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun gitDiff(gitDiff: JsonField) = apply { this.gitDiff = gitDiff } /** Name of the tag on the most recent commit */ fun tag(tag: String?) = tag(JsonField.ofNullable(tag)) - /** Name of the tag on the most recent commit */ + /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ fun tag(tag: Optional) = tag(tag.getOrNull()) - /** Name of the tag on the most recent commit */ + /** + * Sets [Builder.tag] to an arbitrary JSON value. + * + * You should usually call [Builder.tag] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun tag(tag: JsonField) = apply { this.tag = tag } fun additionalProperties(additionalProperties: Map) = apply { 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 73603212..a01c4d2e 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 @@ -11,6 +11,7 @@ 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 @@ -53,24 +54,54 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the role */ + /** + * Unique identifier for the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the role */ + /** + * Name of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Date of role creation */ + /** + * Date of role creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Date of role deletion, or null if the role is still active */ + /** + * Date of role deletion, or null if the role is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Textual description of the role */ + /** + * Textual description of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * (permission, restrict_object_type) tuples which belong to this role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) @@ -79,6 +110,9 @@ private constructor( * * An inheriting role has all the permissions contained in its member roles, as well as all of * their inherited permissions + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) @@ -90,55 +124,88 @@ private constructor( * other role, but cannot be edited. * * It is forbidden to change the org after creating a role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgId(): Optional = Optional.ofNullable(orgId.getNullable("org_id")) - /** Identifies the user who created the role */ + /** + * Identifies the user who created the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the role */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the role */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Date of role creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Date of role deletion, or null if the role is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - /** Textual description of the role */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Returns the raw JSON value of [memberPermissions]. + * + * Unlike [memberPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("member_permissions") @ExcludeMissing fun _memberPermissions(): JsonField> = memberPermissions /** - * Ids of the roles this role inherits from + * Returns the raw JSON value of [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * Unlike [memberRoles], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * Unique id for the organization that the role belongs under - * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by any - * other role, but cannot be edited. + * Returns the raw JSON value of [orgId]. * - * It is forbidden to change the org after creating a role + * Unlike [orgId], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_id") @ExcludeMissing fun _orgId(): JsonField = orgId - /** Identifies the user who created the role */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @@ -211,56 +278,94 @@ private constructor( /** Unique identifier for the role */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the role */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the role */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Date of role creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of role creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of role creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of role deletion, or null if the role is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of role deletion, or null if the role is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the role */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the role */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** Alias for calling [Builder.memberPermissions] with `memberPermissions.orElse(null)`. */ fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Sets [Builder.memberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.memberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ fun memberPermissions(memberPermissions: JsonField>) = apply { this.memberPermissions = memberPermissions.map { it.toMutableList() } } - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Adds a single [MemberPermission] to [memberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberPermission(memberPermission: MemberPermission) = apply { memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { @@ -276,29 +381,24 @@ private constructor( */ fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) - /** - * Ids of the roles this role inherits from - * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions - */ + /** Alias for calling [Builder.memberRoles] with `memberRoles.orElse(null)`. */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** - * Ids of the roles this role inherits from + * Sets [Builder.memberRoles] to an arbitrary JSON value. * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * You should usually call [Builder.memberRoles] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberRoles(memberRoles: JsonField>) = apply { this.memberRoles = memberRoles.map { it.toMutableList() } } /** - * Ids of the roles this role inherits from + * Adds a single [String] to [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberRole(memberRole: String) = apply { memberRoles = @@ -317,33 +417,29 @@ private constructor( */ fun orgId(orgId: String?) = orgId(JsonField.ofNullable(orgId)) - /** - * Unique id for the organization that the role belongs under - * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. - * - * It is forbidden to change the org after creating a role - */ + /** Alias for calling [Builder.orgId] with `orgId.orElse(null)`. */ fun orgId(orgId: Optional) = orgId(orgId.getOrNull()) /** - * Unique id for the organization that the role belongs under + * Sets [Builder.orgId] to an arbitrary JSON value. * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. - * - * It is forbidden to change the org after creating a role + * You should usually call [Builder.orgId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgId(orgId: JsonField) = apply { this.orgId = orgId } /** Identifies the user who created the role */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the role */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the role */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { @@ -398,23 +494,36 @@ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun permission(): Permission = permission.getRequired("permission") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Each permission permits a certain type of operation on an object in the system + * Returns the raw JSON value of [permission]. * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType @@ -473,10 +582,11 @@ private constructor( fun permission(permission: Permission) = permission(JsonField.of(permission)) /** - * Each permission permits a certain type of operation on an object in the system + * Sets [Builder.permission] to an arbitrary JSON value. * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -486,11 +596,20 @@ private constructor( fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) - /** The object type that the ACL applies to */ + /** + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. + */ fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } 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 28abbef7..747af4d0 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 @@ -14,6 +14,7 @@ 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 @@ -33,13 +34,28 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the role */ + /** + * Name of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Textual description of the role */ + /** + * Textual description of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * (permission, restrict_object_type) tuples which belong to this role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun memberPermissions(): Optional> = body.memberPermissions() /** @@ -47,6 +63,9 @@ private constructor( * * An inheriting role has all the permissions contained in its member roles, as well as all of * their inherited permissions + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun memberRoles(): Optional> = body.memberRoles() @@ -54,30 +73,45 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * role belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() - /** Name of the role */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Textual description of the role */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Returns the raw JSON value of [memberPermissions]. + * + * Unlike [memberPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ fun _memberPermissions(): JsonField> = body._memberPermissions() /** - * Ids of the roles this role inherits from + * Returns the raw JSON value of [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * Unlike [memberRoles], this method doesn't throw if the JSON field has an unexpected type. */ fun _memberRoles(): JsonField> = body._memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() @@ -116,14 +150,29 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the role */ + /** + * Name of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Textual description of the role */ + /** + * Textual description of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * (permission, restrict_object_type) tuples which belong to this role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) @@ -132,6 +181,9 @@ private constructor( * * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) @@ -140,36 +192,51 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) - /** Name of the role */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Textual description of the role */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Returns the raw JSON value of [memberPermissions]. + * + * Unlike [memberPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("member_permissions") @ExcludeMissing fun _memberPermissions(): JsonField> = memberPermissions /** - * Ids of the roles this role inherits from + * Returns the raw JSON value of [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * Unlike [memberRoles], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @@ -230,16 +297,28 @@ private constructor( /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the role */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the role */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the role */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -248,16 +327,28 @@ private constructor( fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Alias for calling [Builder.memberPermissions] with `memberPermissions.orElse(null)`. + */ fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Sets [Builder.memberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.memberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun memberPermissions(memberPermissions: JsonField>) = apply { this.memberPermissions = memberPermissions.map { it.toMutableList() } } - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Adds a single [MemberPermission] to [memberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberPermission(memberPermission: MemberPermission) = apply { memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { @@ -274,30 +365,25 @@ private constructor( fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) - /** - * Ids of the roles this role inherits from - * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions - */ + /** Alias for calling [Builder.memberRoles] with `memberRoles.orElse(null)`. */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** - * Ids of the roles this role inherits from + * Sets [Builder.memberRoles] to an arbitrary JSON value. * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * You should usually call [Builder.memberRoles] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberRoles(memberRoles: JsonField>) = apply { this.memberRoles = memberRoles.map { it.toMutableList() } } /** - * Ids of the roles this role inherits from + * Adds a single [String] to [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberRole(memberRole: String) = apply { memberRoles = @@ -313,17 +399,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -408,16 +492,27 @@ private constructor( /** Name of the role */ fun name(name: String) = apply { body.name(name) } - /** Name of the role */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the role */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the role */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the role */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** (permission, restrict_object_type) tuples which belong to this role */ @@ -425,16 +520,26 @@ private constructor( body.memberPermissions(memberPermissions) } - /** (permission, restrict_object_type) tuples which belong to this role */ + /** Alias for calling [Builder.memberPermissions] with `memberPermissions.orElse(null)`. */ fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Sets [Builder.memberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.memberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ fun memberPermissions(memberPermissions: JsonField>) = apply { body.memberPermissions(memberPermissions) } - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Adds a single [MemberPermission] to [memberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberPermission(memberPermission: MemberPermission) = apply { body.addMemberPermission(memberPermission) } @@ -447,29 +552,24 @@ private constructor( */ fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } - /** - * Ids of the roles this role inherits from - * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions - */ + /** Alias for calling [Builder.memberRoles] with `memberRoles.orElse(null)`. */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** - * Ids of the roles this role inherits from + * Sets [Builder.memberRoles] to an arbitrary JSON value. * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * You should usually call [Builder.memberRoles] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberRoles(memberRoles: JsonField>) = apply { body.memberRoles(memberRoles) } /** - * Ids of the roles this role inherits from + * Adds a single [String] to [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } @@ -480,17 +580,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } @@ -633,23 +730,36 @@ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun permission(): Permission = permission.getRequired("permission") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Each permission permits a certain type of operation on an object in the system + * Returns the raw JSON value of [permission]. * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType @@ -708,10 +818,11 @@ private constructor( fun permission(permission: Permission) = permission(JsonField.of(permission)) /** - * Each permission permits a certain type of operation on an object in the system + * Sets [Builder.permission] to an arbitrary JSON value. * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -721,11 +832,20 @@ private constructor( fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) - /** The object type that the ACL applies to */ + /** + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. + */ fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index df21940e..167baa72 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -133,13 +133,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -148,43 +142,38 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the role to search for */ fun roleName(roleName: String?) = apply { this.roleName = roleName } - /** Name of the role to search for */ + /** Alias for calling [Builder.roleName] with `roleName.orElse(null)`. */ fun roleName(roleName: Optional) = roleName(roleName.getOrNull()) /** @@ -196,13 +185,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) 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 cfb06936..f5fa9c8c 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 @@ -14,6 +14,7 @@ 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 @@ -33,13 +34,28 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the role */ + /** + * Name of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Textual description of the role */ + /** + * Textual description of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * (permission, restrict_object_type) tuples which belong to this role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun memberPermissions(): Optional> = body.memberPermissions() /** @@ -47,6 +63,9 @@ private constructor( * * An inheriting role has all the permissions contained in its member roles, as well as all of * their inherited permissions + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun memberRoles(): Optional> = body.memberRoles() @@ -54,30 +73,45 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that your * API key belongs to multiple organizations, you may specify the name of the organization the * role belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun orgName(): Optional = body.orgName() - /** Name of the role */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Textual description of the role */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Returns the raw JSON value of [memberPermissions]. + * + * Unlike [memberPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ fun _memberPermissions(): JsonField> = body._memberPermissions() /** - * Ids of the roles this role inherits from + * Returns the raw JSON value of [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * Unlike [memberRoles], this method doesn't throw if the JSON field has an unexpected type. */ fun _memberRoles(): JsonField> = body._memberRoles() /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ fun _orgName(): JsonField = body._orgName() @@ -116,14 +150,29 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the role */ + /** + * Name of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Textual description of the role */ + /** + * Textual description of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * (permission, restrict_object_type) tuples which belong to this role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun memberPermissions(): Optional> = Optional.ofNullable(memberPermissions.getNullable("member_permissions")) @@ -132,6 +181,9 @@ private constructor( * * An inheriting role has all the permissions contained in its member roles, as well as all * of their inherited permissions + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun memberRoles(): Optional> = Optional.ofNullable(memberRoles.getNullable("member_roles")) @@ -140,36 +192,51 @@ private constructor( * For nearly all users, this parameter should be unnecessary. But in the rare case that * your API key belongs to multiple organizations, you may specify the name of the * organization the role belongs in. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun orgName(): Optional = Optional.ofNullable(orgName.getNullable("org_name")) - /** Name of the role */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Textual description of the role */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Returns the raw JSON value of [memberPermissions]. + * + * Unlike [memberPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("member_permissions") @ExcludeMissing fun _memberPermissions(): JsonField> = memberPermissions /** - * Ids of the roles this role inherits from + * Returns the raw JSON value of [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * Unlike [memberRoles], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles(): JsonField> = memberRoles /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * Returns the raw JSON value of [orgName]. + * + * Unlike [orgName], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("org_name") @ExcludeMissing fun _orgName(): JsonField = orgName @@ -230,16 +297,28 @@ private constructor( /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the role */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the role */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the role */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -248,16 +327,28 @@ private constructor( fun memberPermissions(memberPermissions: List?) = memberPermissions(JsonField.ofNullable(memberPermissions)) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Alias for calling [Builder.memberPermissions] with `memberPermissions.orElse(null)`. + */ fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Sets [Builder.memberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.memberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun memberPermissions(memberPermissions: JsonField>) = apply { this.memberPermissions = memberPermissions.map { it.toMutableList() } } - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Adds a single [MemberPermission] to [memberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberPermission(memberPermission: MemberPermission) = apply { memberPermissions = (memberPermissions ?: JsonField.of(mutableListOf())).also { @@ -274,30 +365,25 @@ private constructor( fun memberRoles(memberRoles: List?) = memberRoles(JsonField.ofNullable(memberRoles)) - /** - * Ids of the roles this role inherits from - * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions - */ + /** Alias for calling [Builder.memberRoles] with `memberRoles.orElse(null)`. */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** - * Ids of the roles this role inherits from + * Sets [Builder.memberRoles] to an arbitrary JSON value. * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * You should usually call [Builder.memberRoles] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberRoles(memberRoles: JsonField>) = apply { this.memberRoles = memberRoles.map { it.toMutableList() } } /** - * Ids of the roles this role inherits from + * Adds a single [String] to [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as - * all of their inherited permissions + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberRole(memberRole: String) = apply { memberRoles = @@ -313,17 +399,15 @@ private constructor( */ fun orgName(orgName: String?) = orgName(JsonField.ofNullable(orgName)) - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun orgName(orgName: JsonField) = apply { this.orgName = orgName } @@ -408,16 +492,27 @@ private constructor( /** Name of the role */ fun name(name: String) = apply { body.name(name) } - /** Name of the role */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Textual description of the role */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the role */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the role */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** (permission, restrict_object_type) tuples which belong to this role */ @@ -425,16 +520,26 @@ private constructor( body.memberPermissions(memberPermissions) } - /** (permission, restrict_object_type) tuples which belong to this role */ + /** Alias for calling [Builder.memberPermissions] with `memberPermissions.orElse(null)`. */ fun memberPermissions(memberPermissions: Optional>) = memberPermissions(memberPermissions.getOrNull()) - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Sets [Builder.memberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.memberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ fun memberPermissions(memberPermissions: JsonField>) = apply { body.memberPermissions(memberPermissions) } - /** (permission, restrict_object_type) tuples which belong to this role */ + /** + * Adds a single [MemberPermission] to [memberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMemberPermission(memberPermission: MemberPermission) = apply { body.addMemberPermission(memberPermission) } @@ -447,29 +552,24 @@ private constructor( */ fun memberRoles(memberRoles: List?) = apply { body.memberRoles(memberRoles) } - /** - * Ids of the roles this role inherits from - * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions - */ + /** Alias for calling [Builder.memberRoles] with `memberRoles.orElse(null)`. */ fun memberRoles(memberRoles: Optional>) = memberRoles(memberRoles.getOrNull()) /** - * Ids of the roles this role inherits from + * Sets [Builder.memberRoles] to an arbitrary JSON value. * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * You should usually call [Builder.memberRoles] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun memberRoles(memberRoles: JsonField>) = apply { body.memberRoles(memberRoles) } /** - * Ids of the roles this role inherits from + * Adds a single [String] to [memberRoles]. * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions + * @throws IllegalStateException if the field was previously set to a non-list. */ fun addMemberRole(memberRole: String) = apply { body.addMemberRole(memberRole) } @@ -480,17 +580,14 @@ private constructor( */ fun orgName(orgName: String?) = apply { body.orgName(orgName) } - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. - */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. + * Sets [Builder.orgName] to an arbitrary JSON value. + * + * You should usually call [Builder.orgName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ fun orgName(orgName: JsonField) = apply { body.orgName(orgName) } @@ -637,23 +734,36 @@ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun permission(): Permission = permission.getRequired("permission") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Each permission permits a certain type of operation on an object in the system + * Returns the raw JSON value of [permission]. * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType @@ -712,10 +822,11 @@ private constructor( fun permission(permission: Permission) = permission(JsonField.of(permission)) /** - * Each permission permits a certain type of operation on an object in the system + * Sets [Builder.permission] to an arbitrary JSON value. * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -725,11 +836,20 @@ private constructor( fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) - /** The object type that the ACL applies to */ + /** + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. + */ fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } 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 5c41fd74..e3ab8031 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 @@ -14,6 +14,7 @@ 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,42 +39,99 @@ private constructor( /** Role id */ fun roleId(): String = roleId - /** A list of permissions to add to the role */ + /** + * A list of permissions to add to the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun addMemberPermissions(): Optional> = body.addMemberPermissions() - /** A list of role IDs to add to the role's inheriting-from set */ + /** + * A list of role IDs to add to the role's inheriting-from set + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun addMemberRoles(): Optional> = body.addMemberRoles() - /** Textual description of the role */ + /** + * Textual description of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the role */ + /** + * Name of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() - /** A list of permissions to remove from the role */ + /** + * A list of permissions to remove from the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun removeMemberPermissions(): Optional> = body.removeMemberPermissions() - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * A list of role IDs to remove from the role's inheriting-from set + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun removeMemberRoles(): Optional> = body.removeMemberRoles() - /** A list of permissions to add to the role */ + /** + * Returns the raw JSON value of [addMemberPermissions]. + * + * Unlike [addMemberPermissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ fun _addMemberPermissions(): JsonField> = body._addMemberPermissions() - /** A list of role IDs to add to the role's inheriting-from set */ + /** + * Returns the raw JSON value of [addMemberRoles]. + * + * Unlike [addMemberRoles], this method doesn't throw if the JSON field has an unexpected type. + */ fun _addMemberRoles(): JsonField> = body._addMemberRoles() - /** Textual description of the role */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** Name of the role */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** A list of permissions to remove from the role */ + /** + * Returns the raw JSON value of [removeMemberPermissions]. + * + * Unlike [removeMemberPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ fun _removeMemberPermissions(): JsonField> = body._removeMemberPermissions() - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * Returns the raw JSON value of [removeMemberRoles]. + * + * Unlike [removeMemberRoles], this method doesn't throw if the JSON field has an unexpected + * type. + */ fun _removeMemberRoles(): JsonField> = body._removeMemberRoles() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -122,54 +180,112 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** A list of permissions to add to the role */ + /** + * A list of permissions to add to the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun addMemberPermissions(): Optional> = Optional.ofNullable(addMemberPermissions.getNullable("add_member_permissions")) - /** A list of role IDs to add to the role's inheriting-from set */ + /** + * A list of role IDs to add to the role's inheriting-from set + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun addMemberRoles(): Optional> = Optional.ofNullable(addMemberRoles.getNullable("add_member_roles")) - /** Textual description of the role */ + /** + * Textual description of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the role */ + /** + * Name of the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** A list of permissions to remove from the role */ + /** + * A list of permissions to remove from the role + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun removeMemberPermissions(): Optional> = Optional.ofNullable(removeMemberPermissions.getNullable("remove_member_permissions")) - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * A list of role IDs to remove from the role's inheriting-from set + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun removeMemberRoles(): Optional> = Optional.ofNullable(removeMemberRoles.getNullable("remove_member_roles")) - /** A list of permissions to add to the role */ + /** + * Returns the raw JSON value of [addMemberPermissions]. + * + * Unlike [addMemberPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("add_member_permissions") @ExcludeMissing fun _addMemberPermissions(): JsonField> = addMemberPermissions - /** A list of role IDs to add to the role's inheriting-from set */ + /** + * Returns the raw JSON value of [addMemberRoles]. + * + * Unlike [addMemberRoles], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("add_member_roles") @ExcludeMissing fun _addMemberRoles(): JsonField> = addMemberRoles - /** Textual description of the role */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** Name of the role */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** A list of permissions to remove from the role */ + /** + * Returns the raw JSON value of [removeMemberPermissions]. + * + * Unlike [removeMemberPermissions], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("remove_member_permissions") @ExcludeMissing fun _removeMemberPermissions(): JsonField> = removeMemberPermissions - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * Returns the raw JSON value of [removeMemberRoles]. + * + * Unlike [removeMemberRoles], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("remove_member_roles") @ExcludeMissing fun _removeMemberRoles(): JsonField> = removeMemberRoles @@ -229,17 +345,30 @@ private constructor( fun addMemberPermissions(addMemberPermissions: List?) = addMemberPermissions(JsonField.ofNullable(addMemberPermissions)) - /** A list of permissions to add to the role */ + /** + * Alias for calling [Builder.addMemberPermissions] with + * `addMemberPermissions.orElse(null)`. + */ fun addMemberPermissions(addMemberPermissions: Optional>) = addMemberPermissions(addMemberPermissions.getOrNull()) - /** A list of permissions to add to the role */ + /** + * Sets [Builder.addMemberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.addMemberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun addMemberPermissions(addMemberPermissions: JsonField>) = apply { this.addMemberPermissions = addMemberPermissions.map { it.toMutableList() } } - /** A list of permissions to add to the role */ + /** + * Adds a single [AddMemberPermission] to [addMemberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { addMemberPermissions = (addMemberPermissions ?: JsonField.of(mutableListOf())).also { @@ -251,16 +380,26 @@ private constructor( fun addMemberRoles(addMemberRoles: List?) = addMemberRoles(JsonField.ofNullable(addMemberRoles)) - /** A list of role IDs to add to the role's inheriting-from set */ + /** Alias for calling [Builder.addMemberRoles] with `addMemberRoles.orElse(null)`. */ fun addMemberRoles(addMemberRoles: Optional>) = addMemberRoles(addMemberRoles.getOrNull()) - /** A list of role IDs to add to the role's inheriting-from set */ + /** + * Sets [Builder.addMemberRoles] to an arbitrary JSON value. + * + * You should usually call [Builder.addMemberRoles] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun addMemberRoles(addMemberRoles: JsonField>) = apply { this.addMemberRoles = addMemberRoles.map { it.toMutableList() } } - /** A list of role IDs to add to the role's inheriting-from set */ + /** + * Adds a single [String] to [addMemberRoles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAddMemberRole(addMemberRole: String) = apply { addMemberRoles = (addMemberRoles ?: JsonField.of(mutableListOf())).also { @@ -271,10 +410,16 @@ private constructor( /** Textual description of the role */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the role */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the role */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -282,29 +427,48 @@ private constructor( /** Name of the role */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the role */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the role */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** A list of permissions to remove from the role */ fun removeMemberPermissions(removeMemberPermissions: List?) = removeMemberPermissions(JsonField.ofNullable(removeMemberPermissions)) - /** A list of permissions to remove from the role */ + /** + * Alias for calling [Builder.removeMemberPermissions] with + * `removeMemberPermissions.orElse(null)`. + */ fun removeMemberPermissions( removeMemberPermissions: Optional> ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) - /** A list of permissions to remove from the role */ + /** + * Sets [Builder.removeMemberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.removeMemberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ fun removeMemberPermissions( removeMemberPermissions: JsonField> ) = apply { this.removeMemberPermissions = removeMemberPermissions.map { it.toMutableList() } } - /** A list of permissions to remove from the role */ + /** + * Adds a single [RemoveMemberPermission] to [removeMemberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { removeMemberPermissions = (removeMemberPermissions ?: JsonField.of(mutableListOf())).also { @@ -316,16 +480,28 @@ private constructor( fun removeMemberRoles(removeMemberRoles: List?) = removeMemberRoles(JsonField.ofNullable(removeMemberRoles)) - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * Alias for calling [Builder.removeMemberRoles] with `removeMemberRoles.orElse(null)`. + */ fun removeMemberRoles(removeMemberRoles: Optional>) = removeMemberRoles(removeMemberRoles.getOrNull()) - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * Sets [Builder.removeMemberRoles] to an arbitrary JSON value. + * + * You should usually call [Builder.removeMemberRoles] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { this.removeMemberRoles = removeMemberRoles.map { it.toMutableList() } } - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * Adds a single [String] to [removeMemberRoles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRemoveMemberRole(removeMemberRole: String) = apply { removeMemberRoles = (removeMemberRoles ?: JsonField.of(mutableListOf())).also { @@ -422,17 +598,30 @@ private constructor( body.addMemberPermissions(addMemberPermissions) } - /** A list of permissions to add to the role */ + /** + * Alias for calling [Builder.addMemberPermissions] with + * `addMemberPermissions.orElse(null)`. + */ fun addMemberPermissions(addMemberPermissions: Optional>) = addMemberPermissions(addMemberPermissions.getOrNull()) - /** A list of permissions to add to the role */ + /** + * Sets [Builder.addMemberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.addMemberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ fun addMemberPermissions(addMemberPermissions: JsonField>) = apply { body.addMemberPermissions(addMemberPermissions) } - /** A list of permissions to add to the role */ + /** + * Adds a single [AddMemberPermission] to [addMemberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAddMemberPermission(addMemberPermission: AddMemberPermission) = apply { body.addAddMemberPermission(addMemberPermission) } @@ -442,34 +631,55 @@ private constructor( body.addMemberRoles(addMemberRoles) } - /** A list of role IDs to add to the role's inheriting-from set */ + /** Alias for calling [Builder.addMemberRoles] with `addMemberRoles.orElse(null)`. */ fun addMemberRoles(addMemberRoles: Optional>) = addMemberRoles(addMemberRoles.getOrNull()) - /** A list of role IDs to add to the role's inheriting-from set */ + /** + * Sets [Builder.addMemberRoles] to an arbitrary JSON value. + * + * You should usually call [Builder.addMemberRoles] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun addMemberRoles(addMemberRoles: JsonField>) = apply { body.addMemberRoles(addMemberRoles) } - /** A list of role IDs to add to the role's inheriting-from set */ + /** + * Adds a single [String] to [addMemberRoles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addAddMemberRole(addMemberRole: String) = apply { body.addAddMemberRole(addMemberRole) } /** Textual description of the role */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the role */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the role */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** Name of the role */ fun name(name: String?) = apply { body.name(name) } - /** Name of the role */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the role */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** A list of permissions to remove from the role */ @@ -478,17 +688,30 @@ private constructor( body.removeMemberPermissions(removeMemberPermissions) } - /** A list of permissions to remove from the role */ + /** + * Alias for calling [Builder.removeMemberPermissions] with + * `removeMemberPermissions.orElse(null)`. + */ fun removeMemberPermissions( removeMemberPermissions: Optional> ) = removeMemberPermissions(removeMemberPermissions.getOrNull()) - /** A list of permissions to remove from the role */ + /** + * Sets [Builder.removeMemberPermissions] to an arbitrary JSON value. + * + * You should usually call [Builder.removeMemberPermissions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ fun removeMemberPermissions( removeMemberPermissions: JsonField> ) = apply { body.removeMemberPermissions(removeMemberPermissions) } - /** A list of permissions to remove from the role */ + /** + * Adds a single [RemoveMemberPermission] to [removeMemberPermissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRemoveMemberPermission(removeMemberPermission: RemoveMemberPermission) = apply { body.addRemoveMemberPermission(removeMemberPermission) } @@ -498,16 +721,26 @@ private constructor( body.removeMemberRoles(removeMemberRoles) } - /** A list of role IDs to remove from the role's inheriting-from set */ + /** Alias for calling [Builder.removeMemberRoles] with `removeMemberRoles.orElse(null)`. */ fun removeMemberRoles(removeMemberRoles: Optional>) = removeMemberRoles(removeMemberRoles.getOrNull()) - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * Sets [Builder.removeMemberRoles] to an arbitrary JSON value. + * + * You should usually call [Builder.removeMemberRoles] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { body.removeMemberRoles(removeMemberRoles) } - /** A list of role IDs to remove from the role's inheriting-from set */ + /** + * Adds a single [String] to [removeMemberRoles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addRemoveMemberRole(removeMemberRole: String) = apply { body.addRemoveMemberRole(removeMemberRole) } @@ -656,23 +889,36 @@ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun permission(): Permission = permission.getRequired("permission") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Each permission permits a certain type of operation on an object in the system + * Returns the raw JSON value of [permission]. * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType @@ -731,10 +977,11 @@ private constructor( fun permission(permission: Permission) = permission(JsonField.of(permission)) /** - * Each permission permits a certain type of operation on an object in the system + * Sets [Builder.permission] to an arbitrary JSON value. * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -744,11 +991,20 @@ private constructor( fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) - /** The object type that the ACL applies to */ + /** + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. + */ fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } @@ -816,23 +1072,36 @@ 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 + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun permission(): Permission = permission.getRequired("permission") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun restrictObjectType(): Optional = Optional.ofNullable(restrictObjectType.getNullable("restrict_object_type")) /** - * Each permission permits a certain type of operation on an object in the system + * Returns the raw JSON value of [permission]. * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Unlike [permission], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("permission") @ExcludeMissing fun _permission(): JsonField = permission - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [restrictObjectType]. + * + * Unlike [restrictObjectType], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType(): JsonField = restrictObjectType @@ -891,10 +1160,11 @@ private constructor( fun permission(permission: Permission) = permission(JsonField.of(permission)) /** - * Each permission permits a certain type of operation on an object in the system + * Sets [Builder.permission] to an arbitrary JSON value. * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * You should usually call [Builder.permission] with a well-typed [Permission] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun permission(permission: JsonField) = apply { this.permission = permission @@ -904,11 +1174,20 @@ private constructor( fun restrictObjectType(restrictObjectType: AclObjectType?) = restrictObjectType(JsonField.ofNullable(restrictObjectType)) - /** The object type that the ACL applies to */ + /** + * Alias for calling [Builder.restrictObjectType] with + * `restrictObjectType.orElse(null)`. + */ fun restrictObjectType(restrictObjectType: Optional) = restrictObjectType(restrictObjectType.getOrNull()) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.restrictObjectType] to an arbitrary JSON value. + * + * You should usually call [Builder.restrictObjectType] with a well-typed + * [AclObjectType] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ fun restrictObjectType(restrictObjectType: JsonField) = apply { this.restrictObjectType = restrictObjectType } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index ff05be5e..9c3bc79e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -10,6 +10,7 @@ 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 @@ -34,36 +35,81 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Number of improvements in the score */ + /** + * Number of improvements in the score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun improvements(): Long = improvements.getRequired("improvements") - /** Name of the score */ + /** + * Name of the score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Number of regressions in the score */ + /** + * Number of regressions in the score + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun regressions(): Long = regressions.getRequired("regressions") - /** Average score across all examples */ + /** + * Average score across all examples + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun score(): Double = score.getRequired("score") - /** Difference in score between the current and comparison experiment */ + /** + * Difference in score between the current and comparison experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun diff(): Optional = Optional.ofNullable(diff.getNullable("diff")) - /** Number of improvements in the score */ + /** + * Returns the raw JSON value of [improvements]. + * + * Unlike [improvements], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("improvements") @ExcludeMissing fun _improvements(): JsonField = improvements - /** Name of the score */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Number of regressions in the score */ + /** + * Returns the raw JSON value of [regressions]. + * + * Unlike [regressions], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("regressions") @ExcludeMissing fun _regressions(): JsonField = regressions - /** Average score across all examples */ + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("score") @ExcludeMissing fun _score(): JsonField = score - /** Difference in score between the current and comparison experiment */ + /** + * Returns the raw JSON value of [diff]. + * + * Unlike [diff], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("diff") @ExcludeMissing fun _diff(): JsonField = diff @JsonAnyGetter @@ -126,31 +172,58 @@ private constructor( /** Number of improvements in the score */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) - /** Number of improvements in the score */ + /** + * Sets [Builder.improvements] to an arbitrary JSON value. + * + * You should usually call [Builder.improvements] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun improvements(improvements: JsonField) = apply { this.improvements = improvements } /** Name of the score */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the score */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Number of regressions in the score */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) - /** Number of regressions in the score */ + /** + * Sets [Builder.regressions] to an arbitrary JSON value. + * + * You should usually call [Builder.regressions] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun regressions(regressions: JsonField) = apply { this.regressions = regressions } /** Average score across all examples */ fun score(score: Double) = score(JsonField.of(score)) - /** Average score across all examples */ + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun score(score: JsonField) = apply { this.score = score } /** Difference in score between the current and comparison experiment */ fun diff(diff: Double) = diff(JsonField.of(diff)) - /** Difference in score between the current and comparison experiment */ + /** + * Sets [Builder.diff] to an arbitrary JSON value. + * + * You should usually call [Builder.diff] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun diff(diff: JsonField) = apply { this.diff = diff } fun additionalProperties(additionalProperties: Map) = apply { 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 4f5c77c1..56bcd6b4 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 @@ -9,6 +9,7 @@ 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 @@ -27,16 +28,34 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the span, for display purposes only */ + /** + * Name of the span, for display purposes only + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** Type of the span, for display purposes only */ + /** + * Type of the span, for display purposes only + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - /** Name of the span, for display purposes only */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Type of the span, for display purposes only */ + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -80,19 +99,29 @@ private constructor( /** Name of the span, for display purposes only */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the span, for display purposes only */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the span, for display purposes only */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Type of the span, for display purposes only */ fun type(type: SpanType?) = type(JsonField.ofNullable(type)) - /** Type of the span, for display purposes only */ + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ fun type(type: Optional) = type(type.getOrNull()) - /** Type of the span, for display purposes only */ + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [SpanType] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index ab9266fa..f368b153 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -10,6 +10,7 @@ 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 @@ -47,71 +48,147 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the span iframe */ + /** + * Unique identifier for the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the span iframe */ + /** + * Name of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Unique identifier for the project that the span iframe belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** URL to embed the project viewer in an iframe */ + /** + * URL to embed the project viewer in an iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun url(): String = url.getRequired("url") - /** Date of span iframe creation */ + /** + * Date of span iframe creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Date of span iframe deletion, or null if the span iframe is still active */ + /** + * Date of span iframe deletion, or null if the span iframe is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Textual description of the span iframe */ + /** + * Textual description of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Whether to post messages to the iframe containing the span's data. This is useful when you * want to render more data than fits in the URL. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) - /** Identifies the user who created the span iframe */ + /** + * Identifies the user who created the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** Unique identifier for the span iframe */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the span iframe */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** URL to embed the project viewer in an iframe */ + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - /** Date of span iframe creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Date of span iframe deletion, or null if the span iframe is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - /** Textual description of the span iframe */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Returns the raw JSON value of [postMessage]. + * + * Unlike [postMessage], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("post_message") @ExcludeMissing fun _postMessage(): JsonField = postMessage - /** Identifies the user who created the span iframe */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId @JsonAnyGetter @@ -186,52 +263,91 @@ private constructor( /** Unique identifier for the span iframe */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the span iframe */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the span iframe */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) - /** URL to embed the project viewer in an iframe */ + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun url(url: JsonField) = apply { this.url = url } /** Date of span iframe creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of span iframe creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of span iframe creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Date of span iframe deletion, or null if the span iframe is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of span iframe deletion, or null if the span iframe is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of span iframe deletion, or null if the span iframe is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the span iframe */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the span iframe */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { this.description = description } /** @@ -241,30 +357,36 @@ private constructor( fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Alias for [Builder.postMessage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) - /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. - */ + /** Alias for calling [Builder.postMessage] with `postMessage.orElse(null)`. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Sets [Builder.postMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.postMessage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage } /** Identifies the user who created the span iframe */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the span iframe */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the span iframe */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 9f81c14e..1f1631e9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,39 +33,79 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the span iframe */ + /** + * Name of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Unique identifier for the project that the span iframe belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** URL to embed the project viewer in an iframe */ + /** + * URL to embed the project viewer in an iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun url(): String = body.url() - /** Textual description of the span iframe */ + /** + * Textual description of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() /** * Whether to post messages to the iframe containing the span's data. This is useful when you * want to render more data than fits in the URL. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun postMessage(): Optional = body.postMessage() - /** Name of the span iframe */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** URL to embed the project viewer in an iframe */ + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ fun _url(): JsonField = body._url() - /** Textual description of the span iframe */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Returns the raw JSON value of [postMessage]. + * + * Unlike [postMessage], this method doesn't throw if the JSON field has an unexpected type. */ fun _postMessage(): JsonField = body._postMessage() @@ -101,43 +142,83 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the span iframe */ + /** + * Name of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Unique identifier for the project that the span iframe belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** URL to embed the project viewer in an iframe */ + /** + * URL to embed the project viewer in an iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun url(): String = url.getRequired("url") - /** Textual description of the span iframe */ + /** + * Textual description of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) - /** Name of the span iframe */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** URL to embed the project viewer in an iframe */ + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - /** Textual description of the span iframe */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Returns the raw JSON value of [postMessage]. + * + * Unlike [postMessage], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("post_message") @ExcludeMissing @@ -202,28 +283,52 @@ private constructor( /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the span iframe */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) - /** URL to embed the project viewer in an iframe */ + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun url(url: JsonField) = apply { this.url = url } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the span iframe */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the span iframe */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -235,20 +340,21 @@ private constructor( fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Alias for [Builder.postMessage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) - /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. - */ + /** Alias for calling [Builder.postMessage] with `postMessage.orElse(null)`. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Sets [Builder.postMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.postMessage] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage @@ -337,28 +443,50 @@ private constructor( /** Name of the span iframe */ fun name(name: String) = apply { body.name(name) } - /** Name of the span iframe */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** URL to embed the project viewer in an iframe */ fun url(url: String) = apply { body.url(url) } - /** URL to embed the project viewer in an iframe */ + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun url(url: JsonField) = apply { body.url(url) } /** Textual description of the span iframe */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the span iframe */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the span iframe */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** @@ -368,20 +496,21 @@ private constructor( fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Alias for [Builder.postMessage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) - /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. - */ + /** Alias for calling [Builder.postMessage] with `postMessage.orElse(null)`. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Sets [Builder.postMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.postMessage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index 87ccce77..f2dd183a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -133,13 +133,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -148,43 +142,38 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** Name of the span_iframe to search for */ fun spanIframeName(spanIframeName: String?) = apply { this.spanIframeName = spanIframeName } - /** Name of the span_iframe to search for */ + /** Alias for calling [Builder.spanIframeName] with `spanIframeName.orElse(null)`. */ fun spanIframeName(spanIframeName: Optional) = spanIframeName(spanIframeName.getOrNull()) @@ -197,13 +186,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index d3dc8f16..9a65ea97 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -13,6 +13,7 @@ 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 @@ -32,39 +33,79 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the span iframe */ + /** + * Name of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Unique identifier for the project that the span iframe belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = body.projectId() - /** URL to embed the project viewer in an iframe */ + /** + * URL to embed the project viewer in an iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun url(): String = body.url() - /** Textual description of the span iframe */ + /** + * Textual description of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() /** * Whether to post messages to the iframe containing the span's data. This is useful when you * want to render more data than fits in the URL. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun postMessage(): Optional = body.postMessage() - /** Name of the span iframe */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _projectId(): JsonField = body._projectId() - /** URL to embed the project viewer in an iframe */ + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ fun _url(): JsonField = body._url() - /** Textual description of the span iframe */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Returns the raw JSON value of [postMessage]. + * + * Unlike [postMessage], this method doesn't throw if the JSON field has an unexpected type. */ fun _postMessage(): JsonField = body._postMessage() @@ -101,43 +142,83 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the span iframe */ + /** + * Name of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Unique identifier for the project that the span iframe belongs under + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectId(): String = projectId.getRequired("project_id") - /** URL to embed the project viewer in an iframe */ + /** + * URL to embed the project viewer in an iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun url(): String = url.getRequired("url") - /** Textual description of the span iframe */ + /** + * Textual description of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) - /** Name of the span iframe */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - /** URL to embed the project viewer in an iframe */ + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - /** Textual description of the span iframe */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Returns the raw JSON value of [postMessage]. + * + * Unlike [postMessage], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("post_message") @ExcludeMissing @@ -202,28 +283,52 @@ private constructor( /** Name of the span iframe */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the span iframe */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } /** URL to embed the project viewer in an iframe */ fun url(url: String) = url(JsonField.of(url)) - /** URL to embed the project viewer in an iframe */ + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun url(url: JsonField) = apply { this.url = url } /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the span iframe */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the span iframe */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -235,20 +340,21 @@ private constructor( fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Alias for [Builder.postMessage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) - /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. - */ + /** Alias for calling [Builder.postMessage] with `postMessage.orElse(null)`. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Sets [Builder.postMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.postMessage] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage @@ -337,28 +443,50 @@ private constructor( /** Name of the span iframe */ fun name(name: String) = apply { body.name(name) } - /** Name of the span iframe */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Unique identifier for the project that the span iframe belongs under */ fun projectId(projectId: String) = apply { body.projectId(projectId) } - /** Unique identifier for the project that the span iframe belongs under */ + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectId(projectId: JsonField) = apply { body.projectId(projectId) } /** URL to embed the project viewer in an iframe */ fun url(url: String) = apply { body.url(url) } - /** URL to embed the project viewer in an iframe */ + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun url(url: JsonField) = apply { body.url(url) } /** Textual description of the span iframe */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the span iframe */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the span iframe */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** @@ -368,20 +496,21 @@ private constructor( fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Alias for [Builder.postMessage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) - /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. - */ + /** Alias for calling [Builder.postMessage] with `postMessage.orElse(null)`. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Sets [Builder.postMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.postMessage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 7282d348..5e3efac6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -13,6 +13,7 @@ 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,34 +38,65 @@ private constructor( /** SpanIframe id */ fun spanIframeId(): String = spanIframeId - /** Textual description of the span iframe */ + /** + * Textual description of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun description(): Optional = body.description() - /** Name of the span iframe */ + /** + * Name of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() /** * Whether to post messages to the iframe containing the span's data. This is useful when you * want to render more data than fits in the URL. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ fun postMessage(): Optional = body.postMessage() - /** URL to embed the project viewer in an iframe */ + /** + * URL to embed the project viewer in an iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun url(): Optional = body.url() - /** Textual description of the span iframe */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ fun _description(): JsonField = body._description() - /** Name of the span iframe */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() /** - * Whether to post messages to the iframe containing the span's data. This is useful when you - * want to render more data than fits in the URL. + * Returns the raw JSON value of [postMessage]. + * + * Unlike [postMessage], this method doesn't throw if the JSON field has an unexpected type. */ fun _postMessage(): JsonField = body._postMessage() - /** URL to embed the project viewer in an iframe */ + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ fun _url(): JsonField = body._url() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -104,40 +136,71 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Textual description of the span iframe */ + /** + * Textual description of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun description(): Optional = Optional.ofNullable(description.getNullable("description")) - /** Name of the span iframe */ + /** + * Name of the span iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** * Whether to post messages to the iframe containing the span's data. This is useful when * you want to render more data than fits in the URL. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ fun postMessage(): Optional = Optional.ofNullable(postMessage.getNullable("post_message")) - /** URL to embed the project viewer in an iframe */ + /** + * URL to embed the project viewer in an iframe + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun url(): Optional = Optional.ofNullable(url.getNullable("url")) - /** Textual description of the span iframe */ + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - /** Name of the span iframe */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Returns the raw JSON value of [postMessage]. + * + * Unlike [postMessage], this method doesn't throw if the JSON field has an unexpected type. */ @JsonProperty("post_message") @ExcludeMissing fun _postMessage(): JsonField = postMessage - /** URL to embed the project viewer in an iframe */ + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @@ -187,10 +250,16 @@ private constructor( /** Textual description of the span iframe */ fun description(description: String?) = description(JsonField.ofNullable(description)) - /** Textual description of the span iframe */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the span iframe */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun description(description: JsonField) = apply { this.description = description } @@ -198,10 +267,16 @@ private constructor( /** Name of the span iframe */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the span iframe */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the span iframe */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** @@ -211,20 +286,21 @@ private constructor( fun postMessage(postMessage: Boolean?) = postMessage(JsonField.ofNullable(postMessage)) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Alias for [Builder.postMessage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) - /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. - */ + /** Alias for calling [Builder.postMessage] with `postMessage.orElse(null)`. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful - * when you want to render more data than fits in the URL. + * Sets [Builder.postMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.postMessage] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ fun postMessage(postMessage: JsonField) = apply { this.postMessage = postMessage @@ -233,10 +309,16 @@ private constructor( /** URL to embed the project viewer in an iframe */ fun url(url: String?) = url(JsonField.ofNullable(url)) - /** URL to embed the project viewer in an iframe */ + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ fun url(url: Optional) = url(url.getOrNull()) - /** URL to embed the project viewer in an iframe */ + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { @@ -318,19 +400,30 @@ private constructor( /** Textual description of the span iframe */ fun description(description: String?) = apply { body.description(description) } - /** Textual description of the span iframe */ + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ fun description(description: Optional) = description(description.getOrNull()) - /** Textual description of the span iframe */ + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun description(description: JsonField) = apply { body.description(description) } /** Name of the span iframe */ fun name(name: String?) = apply { body.name(name) } - /** Name of the span iframe */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the span iframe */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** @@ -340,30 +433,36 @@ private constructor( fun postMessage(postMessage: Boolean?) = apply { body.postMessage(postMessage) } /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Alias for [Builder.postMessage]. + * + * This unboxed primitive overload exists for backwards compatibility. */ fun postMessage(postMessage: Boolean) = postMessage(postMessage as Boolean?) - /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. - */ + /** Alias for calling [Builder.postMessage] with `postMessage.orElse(null)`. */ fun postMessage(postMessage: Optional) = postMessage(postMessage.getOrNull()) /** - * Whether to post messages to the iframe containing the span's data. This is useful when - * you want to render more data than fits in the URL. + * Sets [Builder.postMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.postMessage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ fun postMessage(postMessage: JsonField) = apply { body.postMessage(postMessage) } /** URL to embed the project viewer in an iframe */ fun url(url: String?) = apply { body.url(url) } - /** URL to embed the project viewer in an iframe */ + /** Alias for calling [Builder.url] with `url.orElse(null)`. */ fun url(url: Optional) = url(url.getOrNull()) - /** URL to embed the project viewer in an iframe */ + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun url(url: JsonField) = apply { body.url(url) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 949d6300..1c29da9d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -10,6 +10,7 @@ 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 @@ -41,39 +42,84 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the dataset */ + /** + * Name of the dataset + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun datasetName(): String = datasetName.getRequired("dataset_name") - /** URL to the dataset's page in the Braintrust app */ + /** + * URL to the dataset's page in the Braintrust app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun datasetUrl(): String = datasetUrl.getRequired("dataset_url") - /** Name of the project that the dataset belongs to */ + /** + * Name of the project that the dataset belongs to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectName(): String = projectName.getRequired("project_name") - /** URL to the project's page in the Braintrust app */ + /** + * URL to the project's page in the Braintrust app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectUrl(): String = projectUrl.getRequired("project_url") - /** Summary of a dataset's data */ + /** + * Summary of a dataset's data + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun dataSummary(): Optional = Optional.ofNullable(dataSummary.getNullable("data_summary")) - /** Name of the dataset */ + /** + * Returns the raw JSON value of [datasetName]. + * + * Unlike [datasetName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName(): JsonField = datasetName - /** URL to the dataset's page in the Braintrust app */ + /** + * Returns the raw JSON value of [datasetUrl]. + * + * Unlike [datasetUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl(): JsonField = datasetUrl - /** Name of the project that the dataset belongs to */ + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_name") @ExcludeMissing fun _projectName(): JsonField = projectName - /** URL to the project's page in the Braintrust app */ + /** + * Returns the raw JSON value of [projectUrl]. + * + * Unlike [projectUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl - /** Summary of a dataset's data */ + /** + * Returns the raw JSON value of [dataSummary]. + * + * Unlike [dataSummary], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("data_summary") @ExcludeMissing fun _dataSummary(): JsonField = dataSummary @@ -138,34 +184,64 @@ private constructor( /** Name of the dataset */ fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) - /** Name of the dataset */ + /** + * Sets [Builder.datasetName] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } /** URL to the dataset's page in the Braintrust app */ fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) - /** URL to the dataset's page in the Braintrust app */ + /** + * Sets [Builder.datasetUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.datasetUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } /** Name of the project that the dataset belongs to */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - /** Name of the project that the dataset belongs to */ + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectName(projectName: JsonField) = apply { this.projectName = projectName } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) - /** URL to the project's page in the Braintrust app */ + /** + * Sets [Builder.projectUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.projectUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } /** Summary of a dataset's data */ fun dataSummary(dataSummary: DataSummary?) = dataSummary(JsonField.ofNullable(dataSummary)) - /** Summary of a dataset's data */ + /** Alias for calling [Builder.dataSummary] with `dataSummary.orElse(null)`. */ fun dataSummary(dataSummary: Optional) = dataSummary(dataSummary.getOrNull()) - /** Summary of a dataset's data */ + /** + * Sets [Builder.dataSummary] to an arbitrary JSON value. + * + * You should usually call [Builder.dataSummary] with a well-typed [DataSummary] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun dataSummary(dataSummary: JsonField) = apply { this.dataSummary = dataSummary } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index b23ca9e9..8c39f8c2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -10,6 +10,7 @@ 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 @@ -47,55 +48,119 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the experiment */ + /** + * Name of the experiment + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun experimentName(): String = experimentName.getRequired("experiment_name") - /** URL to the experiment's page in the Braintrust app */ + /** + * URL to the experiment's page in the Braintrust app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun experimentUrl(): String = experimentUrl.getRequired("experiment_url") - /** Name of the project that the experiment belongs to */ + /** + * Name of the project that the experiment belongs to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectName(): String = projectName.getRequired("project_name") - /** URL to the project's page in the Braintrust app */ + /** + * URL to the project's page in the Braintrust app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun projectUrl(): String = projectUrl.getRequired("project_url") - /** The experiment which scores are baselined against */ + /** + * The experiment which scores are baselined against + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun comparisonExperimentName(): Optional = Optional.ofNullable(comparisonExperimentName.getNullable("comparison_experiment_name")) - /** Summary of the experiment's metrics */ + /** + * Summary of the experiment's metrics + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun metrics(): Optional = Optional.ofNullable(metrics.getNullable("metrics")) - /** Summary of the experiment's scores */ + /** + * Summary of the experiment's scores + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun scores(): Optional = Optional.ofNullable(scores.getNullable("scores")) - /** Name of the experiment */ + /** + * Returns the raw JSON value of [experimentName]. + * + * Unlike [experimentName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName(): JsonField = experimentName - /** URL to the experiment's page in the Braintrust app */ + /** + * Returns the raw JSON value of [experimentUrl]. + * + * Unlike [experimentUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("experiment_url") @ExcludeMissing fun _experimentUrl(): JsonField = experimentUrl - /** Name of the project that the experiment belongs to */ + /** + * Returns the raw JSON value of [projectName]. + * + * Unlike [projectName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_name") @ExcludeMissing fun _projectName(): JsonField = projectName - /** URL to the project's page in the Braintrust app */ + /** + * Returns the raw JSON value of [projectUrl]. + * + * Unlike [projectUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("project_url") @ExcludeMissing fun _projectUrl(): JsonField = projectUrl - /** The experiment which scores are baselined against */ + /** + * Returns the raw JSON value of [comparisonExperimentName]. + * + * Unlike [comparisonExperimentName], this method doesn't throw if the JSON field has an + * unexpected type. + */ @JsonProperty("comparison_experiment_name") @ExcludeMissing fun _comparisonExperimentName(): JsonField = comparisonExperimentName - /** Summary of the experiment's metrics */ + /** + * Returns the raw JSON value of [metrics]. + * + * Unlike [metrics], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("metrics") @ExcludeMissing fun _metrics(): JsonField = metrics - /** Summary of the experiment's scores */ + /** + * Returns the raw JSON value of [scores]. + * + * Unlike [scores], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("scores") @ExcludeMissing fun _scores(): JsonField = scores @JsonAnyGetter @@ -164,7 +229,13 @@ private constructor( /** Name of the experiment */ fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) - /** Name of the experiment */ + /** + * Sets [Builder.experimentName] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun experimentName(experimentName: JsonField) = apply { this.experimentName = experimentName } @@ -172,7 +243,13 @@ private constructor( /** URL to the experiment's page in the Braintrust app */ fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) - /** URL to the experiment's page in the Braintrust app */ + /** + * Sets [Builder.experimentUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.experimentUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun experimentUrl(experimentUrl: JsonField) = apply { this.experimentUrl = experimentUrl } @@ -180,24 +257,45 @@ private constructor( /** Name of the project that the experiment belongs to */ fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - /** Name of the project that the experiment belongs to */ + /** + * Sets [Builder.projectName] to an arbitrary JSON value. + * + * You should usually call [Builder.projectName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectName(projectName: JsonField) = apply { this.projectName = projectName } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) - /** URL to the project's page in the Braintrust app */ + /** + * Sets [Builder.projectUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.projectUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } /** The experiment which scores are baselined against */ fun comparisonExperimentName(comparisonExperimentName: String?) = comparisonExperimentName(JsonField.ofNullable(comparisonExperimentName)) - /** The experiment which scores are baselined against */ + /** + * Alias for calling [Builder.comparisonExperimentName] with + * `comparisonExperimentName.orElse(null)`. + */ fun comparisonExperimentName(comparisonExperimentName: Optional) = comparisonExperimentName(comparisonExperimentName.getOrNull()) - /** The experiment which scores are baselined against */ + /** + * Sets [Builder.comparisonExperimentName] to an arbitrary JSON value. + * + * You should usually call [Builder.comparisonExperimentName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun comparisonExperimentName(comparisonExperimentName: JsonField) = apply { this.comparisonExperimentName = comparisonExperimentName } @@ -205,19 +303,29 @@ private constructor( /** Summary of the experiment's metrics */ fun metrics(metrics: Metrics?) = metrics(JsonField.ofNullable(metrics)) - /** Summary of the experiment's metrics */ + /** Alias for calling [Builder.metrics] with `metrics.orElse(null)`. */ fun metrics(metrics: Optional) = metrics(metrics.getOrNull()) - /** Summary of the experiment's metrics */ + /** + * Sets [Builder.metrics] to an arbitrary JSON value. + * + * You should usually call [Builder.metrics] with a well-typed [Metrics] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun metrics(metrics: JsonField) = apply { this.metrics = metrics } /** Summary of the experiment's scores */ fun scores(scores: Scores?) = scores(JsonField.ofNullable(scores)) - /** Summary of the experiment's scores */ + /** Alias for calling [Builder.scores] with `scores.orElse(null)`. */ fun scores(scores: Optional) = scores(scores.getOrNull()) - /** Summary of the experiment's scores */ + /** + * Sets [Builder.scores] to an arbitrary JSON value. + * + * You should usually call [Builder.scores] with a well-typed [Scores] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun scores(scores: JsonField) = apply { this.scores = scores } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index b064f7aa..a2e2f9c3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -10,6 +10,7 @@ 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 @@ -40,40 +41,94 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the user */ + /** + * Unique identifier for the user + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** URL of the user's Avatar image */ + /** + * URL of the user's Avatar image + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun avatarUrl(): Optional = Optional.ofNullable(avatarUrl.getNullable("avatar_url")) - /** Date of user creation */ + /** + * Date of user creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** The user's email */ + /** + * The user's email + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun email(): Optional = Optional.ofNullable(email.getNullable("email")) - /** Family name of the user */ + /** + * Family name of the user + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun familyName(): Optional = Optional.ofNullable(familyName.getNullable("family_name")) - /** Given name of the user */ + /** + * Given name of the user + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun givenName(): Optional = Optional.ofNullable(givenName.getNullable("given_name")) - /** Unique identifier for the user */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** URL of the user's Avatar image */ + /** + * Returns the raw JSON value of [avatarUrl]. + * + * Unlike [avatarUrl], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl(): JsonField = avatarUrl - /** Date of user creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** The user's email */ + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - /** Family name of the user */ + /** + * Returns the raw JSON value of [familyName]. + * + * Unlike [familyName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("family_name") @ExcludeMissing fun _familyName(): JsonField = familyName - /** Given name of the user */ + /** + * Returns the raw JSON value of [givenName]. + * + * Unlike [givenName], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("given_name") @ExcludeMissing fun _givenName(): JsonField = givenName @JsonAnyGetter @@ -136,52 +191,86 @@ private constructor( /** Unique identifier for the user */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the user */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** URL of the user's Avatar image */ fun avatarUrl(avatarUrl: String?) = avatarUrl(JsonField.ofNullable(avatarUrl)) - /** URL of the user's Avatar image */ + /** Alias for calling [Builder.avatarUrl] with `avatarUrl.orElse(null)`. */ fun avatarUrl(avatarUrl: Optional) = avatarUrl(avatarUrl.getOrNull()) - /** URL of the user's Avatar image */ + /** + * Sets [Builder.avatarUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.avatarUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun avatarUrl(avatarUrl: JsonField) = apply { this.avatarUrl = avatarUrl } /** Date of user creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of user creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of user creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** The user's email */ fun email(email: String?) = email(JsonField.ofNullable(email)) - /** The user's email */ + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ fun email(email: Optional) = email(email.getOrNull()) - /** The user's email */ + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun email(email: JsonField) = apply { this.email = email } /** Family name of the user */ fun familyName(familyName: String?) = familyName(JsonField.ofNullable(familyName)) - /** Family name of the user */ + /** Alias for calling [Builder.familyName] with `familyName.orElse(null)`. */ fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) - /** Family name of the user */ + /** + * Sets [Builder.familyName] to an arbitrary JSON value. + * + * You should usually call [Builder.familyName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun familyName(familyName: JsonField) = apply { this.familyName = familyName } /** Given name of the user */ fun givenName(givenName: String?) = givenName(JsonField.ofNullable(givenName)) - /** Given name of the user */ + /** Alias for calling [Builder.givenName] with `givenName.orElse(null)`. */ fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) - /** Given name of the user */ + /** + * Sets [Builder.givenName] to an arbitrary JSON value. + * + * You should usually call [Builder.givenName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun givenName(givenName: JsonField) = apply { this.givenName = givenName } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index d259099e..d456383c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -153,22 +153,13 @@ private constructor( */ fun email(email: Email?) = apply { this.email = email } - /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email - */ + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ fun email(email: Optional) = email(email.getOrNull()) - /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email - */ + /** Alias for calling [email] with `Email.ofString(string)`. */ fun email(string: String) = email(Email.ofString(string)) - /** - * Email of the user to search for. You may pass the param multiple times to filter for more - * than one email - */ + /** Alias for calling [email] with `Email.ofStrings(strings)`. */ fun emailOfStrings(strings: List) = email(Email.ofStrings(strings)) /** @@ -180,13 +171,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -195,22 +180,13 @@ private constructor( */ fun familyName(familyName: FamilyName?) = apply { this.familyName = familyName } - /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name - */ + /** Alias for calling [Builder.familyName] with `familyName.orElse(null)`. */ fun familyName(familyName: Optional) = familyName(familyName.getOrNull()) - /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name - */ + /** Alias for calling [familyName] with `FamilyName.ofString(string)`. */ fun familyName(string: String) = familyName(FamilyName.ofString(string)) - /** - * Family name of the user to search for. You may pass the param multiple times to filter - * for more than one family name - */ + /** Alias for calling [familyName] with `FamilyName.ofStrings(strings)`. */ fun familyNameOfStrings(strings: List) = familyName(FamilyName.ofStrings(strings)) /** @@ -219,22 +195,13 @@ private constructor( */ fun givenName(givenName: GivenName?) = apply { this.givenName = givenName } - /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name - */ + /** Alias for calling [Builder.givenName] with `givenName.orElse(null)`. */ fun givenName(givenName: Optional) = givenName(givenName.getOrNull()) - /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name - */ + /** Alias for calling [givenName] with `GivenName.ofString(string)`. */ fun givenName(string: String) = givenName(GivenName.ofString(string)) - /** - * Given name of the user to search for. You may pass the param multiple times to filter for - * more than one given name - */ + /** Alias for calling [givenName] with `GivenName.ofStrings(strings)`. */ fun givenNameOfStrings(strings: List) = givenName(GivenName.ofStrings(strings)) /** @@ -243,37 +210,32 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** Filter search results to within a particular organization */ fun orgName(orgName: String?) = apply { this.orgName = orgName } - /** Filter search results to within a particular organization */ + /** Alias for calling [Builder.orgName] with `orgName.orElse(null)`. */ fun orgName(orgName: Optional) = orgName(orgName.getOrNull()) /** @@ -285,13 +247,7 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) 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 031f9f92..c53b8ab5 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 @@ -54,69 +54,159 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Unique identifier for the view */ + /** + * Unique identifier for the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun id(): String = id.getRequired("id") - /** Name of the view */ + /** + * Name of the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") - /** Type of table that the view corresponds to. */ + /** + * Type of table that the view corresponds to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) - /** Date of view creation */ + /** + * Date of view creation + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun created(): Optional = Optional.ofNullable(created.getNullable("created")) - /** Date of role deletion, or null if the role is still active */ + /** + * Date of role deletion, or null if the role is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Options for the view in the app */ + /** + * Options for the view in the app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - /** Identifies the user who created the view */ + /** + * Identifies the user who created the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** The view definition */ + /** + * The view definition + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) - /** Unique identifier for the view */ + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** Name of the view */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Type of table that the view corresponds to. */ + /** + * Returns the raw JSON value of [viewType]. + * + * Unlike [viewType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType - /** Date of view creation */ + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - /** Date of role deletion, or null if the role is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - /** Options for the view in the app */ + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options - /** Identifies the user who created the view */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - /** The view definition */ + /** + * Returns the raw JSON value of [viewData]. + * + * Unlike [viewData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @@ -195,25 +285,46 @@ private constructor( /** Unique identifier for the view */ fun id(id: String) = id(JsonField.of(id)) - /** Unique identifier for the view */ + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun id(id: JsonField) = apply { this.id = id } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the view */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -221,55 +332,90 @@ private constructor( /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) - /** Type of table that the view corresponds to. */ + /** Alias for calling [Builder.viewType] with `viewType.orElse(null)`. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - /** Type of table that the view corresponds to. */ + /** + * Sets [Builder.viewType] to an arbitrary JSON value. + * + * You should usually call [Builder.viewType] with a well-typed [ViewType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun viewType(viewType: JsonField) = apply { this.viewType = viewType } /** Date of view creation */ fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) - /** Date of view creation */ + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ fun created(created: Optional) = created(created.getOrNull()) - /** Date of view creation */ + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun created(created: JsonField) = apply { this.created = created } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of role deletion, or null if the role is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of role deletion, or null if the role is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) - /** Options for the view in the app */ + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ fun options(options: Optional) = options(options.getOrNull()) - /** Options for the view in the app */ + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [ViewOptions] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the view */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the view */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) - /** The view definition */ + /** Alias for calling [Builder.viewData] with `viewData.orElse(null)`. */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) - /** The view definition */ + /** + * Sets [Builder.viewData] to an arbitrary JSON value. + * + * You should usually call [Builder.viewData] with a well-typed [ViewData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun viewData(viewData: JsonField) = apply { this.viewData = viewData } fun additionalProperties(additionalProperties: Map) = apply { 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 c9846755..e123c1da 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 @@ -35,52 +35,124 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the view */ + /** + * Name of the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = body.objectId() - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = body.objectType() - /** Type of table that the view corresponds to. */ + /** + * Type of table that the view corresponds to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun viewType(): Optional = body.viewType() - /** Date of role deletion, or null if the role is still active */ + /** + * Date of role deletion, or null if the role is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = body.deletedAt() - /** Options for the view in the app */ + /** + * Options for the view in the app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun options(): Optional = body.options() - /** Identifies the user who created the view */ + /** + * Identifies the user who created the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = body.userId() - /** The view definition */ + /** + * The view definition + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun viewData(): Optional = body.viewData() - /** Name of the view */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectId(): JsonField = body._objectId() - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectType(): JsonField = body._objectType() - /** Type of table that the view corresponds to. */ + /** + * Returns the raw JSON value of [viewType]. + * + * Unlike [viewType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _viewType(): JsonField = body._viewType() - /** Date of role deletion, or null if the role is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ fun _deletedAt(): JsonField = body._deletedAt() - /** Options for the view in the app */ + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ fun _options(): JsonField = body._options() - /** Identifies the user who created the view */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _userId(): JsonField = body._userId() - /** The view definition */ + /** + * Returns the raw JSON value of [viewData]. + * + * Unlike [viewData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _viewData(): JsonField = body._viewData() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -127,57 +199,129 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the view */ + /** + * Name of the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") - /** Type of table that the view corresponds to. */ + /** + * Type of table that the view corresponds to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) - /** Date of role deletion, or null if the role is still active */ + /** + * Date of role deletion, or null if the role is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Options for the view in the app */ + /** + * Options for the view in the app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - /** Identifies the user who created the view */ + /** + * Identifies the user who created the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** The view definition */ + /** + * The view definition + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) - /** Name of the view */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Type of table that the view corresponds to. */ + /** + * Returns the raw JSON value of [viewType]. + * + * Unlike [viewType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType - /** Date of role deletion, or null if the role is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - /** Options for the view in the app */ + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options - /** Identifies the user who created the view */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - /** The view definition */ + /** + * Returns the raw JSON value of [viewData]. + * + * Unlike [viewData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @@ -249,19 +393,37 @@ private constructor( /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the view */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -269,19 +431,31 @@ private constructor( /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) - /** Type of table that the view corresponds to. */ + /** Alias for calling [Builder.viewType] with `viewType.orElse(null)`. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - /** Type of table that the view corresponds to. */ + /** + * Sets [Builder.viewType] to an arbitrary JSON value. + * + * You should usually call [Builder.viewType] with a well-typed [ViewType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun viewType(viewType: JsonField) = apply { this.viewType = viewType } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of role deletion, or null if the role is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of role deletion, or null if the role is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } @@ -289,28 +463,46 @@ private constructor( /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) - /** Options for the view in the app */ + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ fun options(options: Optional) = options(options.getOrNull()) - /** Options for the view in the app */ + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [ViewOptions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the view */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the view */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) - /** The view definition */ + /** Alias for calling [Builder.viewData] with `viewData.orElse(null)`. */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) - /** The view definition */ + /** + * Sets [Builder.viewData] to an arbitrary JSON value. + * + * You should usually call [Builder.viewData] with a well-typed [ViewData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun viewData(viewData: JsonField) = apply { this.viewData = viewData } fun additionalProperties(additionalProperties: Map) = apply { @@ -400,64 +592,109 @@ private constructor( /** Name of the view */ fun name(name: String) = apply { body.name(name) } - /** Name of the view */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the view applies to */ fun objectId(objectId: String) = apply { body.objectId(objectId) } - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } - /** Type of table that the view corresponds to. */ + /** Alias for calling [Builder.viewType] with `viewType.orElse(null)`. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - /** Type of table that the view corresponds to. */ + /** + * Sets [Builder.viewType] to an arbitrary JSON value. + * + * You should usually call [Builder.viewType] with a well-typed [ViewType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } - /** Date of role deletion, or null if the role is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of role deletion, or null if the role is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } /** Options for the view in the app */ fun options(options: ViewOptions?) = apply { body.options(options) } - /** Options for the view in the app */ + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ fun options(options: Optional) = options(options.getOrNull()) - /** Options for the view in the app */ + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [ViewOptions] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun options(options: JsonField) = apply { body.options(options) } /** Identifies the user who created the view */ fun userId(userId: String?) = apply { body.userId(userId) } - /** Identifies the user who created the view */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the view */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { body.userId(userId) } /** The view definition */ fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } - /** The view definition */ + /** Alias for calling [Builder.viewData] with `viewData.orElse(null)`. */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) - /** The view definition */ + /** + * Sets [Builder.viewData] to an arbitrary JSON value. + * + * You should usually call [Builder.viewData] with a well-typed [ViewData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 70d0d8ce..8ab619b7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -9,6 +9,7 @@ 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 @@ -28,8 +29,17 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun search(): Optional = Optional.ofNullable(search.getNullable("search")) + /** + * Returns the raw JSON value of [search]. + * + * Unlike [search], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("search") @ExcludeMissing fun _search(): JsonField = search @JsonAnyGetter @@ -69,8 +79,16 @@ private constructor( fun search(search: ViewDataSearch?) = search(JsonField.ofNullable(search)) + /** Alias for calling [Builder.search] with `search.orElse(null)`. */ fun search(search: Optional) = search(search.getOrNull()) + /** + * Sets [Builder.search] to an arbitrary JSON value. + * + * You should usually call [Builder.search] with a well-typed [ViewDataSearch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun search(search: JsonField) = apply { this.search = search } fun additionalProperties(additionalProperties: Map) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 6d12484b..3b39ddb7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.checkKnown 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,20 +38,56 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun filter(): Optional> = Optional.ofNullable(filter.getNullable("filter")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun match(): Optional> = Optional.ofNullable(match.getNullable("match")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun sort(): Optional> = Optional.ofNullable(sort.getNullable("sort")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun tag(): Optional> = Optional.ofNullable(tag.getNullable("tag")) + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField> = filter + /** + * Returns the raw JSON value of [match]. + * + * Unlike [match], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("match") @ExcludeMissing fun _match(): JsonField> = match + /** + * Returns the raw JSON value of [sort]. + * + * Unlike [sort], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("sort") @ExcludeMissing fun _sort(): JsonField> = sort + /** + * Returns the raw JSON value of [tag]. + * + * Unlike [tag], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("tag") @ExcludeMissing fun _tag(): JsonField> = tag @JsonAnyGetter @@ -99,12 +136,25 @@ private constructor( fun filter(filter: List?) = filter(JsonField.ofNullable(filter)) + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ fun filter(filter: Optional>) = filter(filter.getOrNull()) + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun filter(filter: JsonField>) = apply { this.filter = filter.map { it.toMutableList() } } + /** + * Adds a single [JsonValue] to [Builder.filter]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addFilter(filter: JsonValue) = apply { this.filter = (this.filter ?: JsonField.of(mutableListOf())).also { @@ -114,12 +164,25 @@ private constructor( fun match(match: List?) = match(JsonField.ofNullable(match)) + /** Alias for calling [Builder.match] with `match.orElse(null)`. */ fun match(match: Optional>) = match(match.getOrNull()) + /** + * Sets [Builder.match] to an arbitrary JSON value. + * + * You should usually call [Builder.match] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun match(match: JsonField>) = apply { this.match = match.map { it.toMutableList() } } + /** + * Adds a single [JsonValue] to [Builder.match]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addMatch(match: JsonValue) = apply { this.match = (this.match ?: JsonField.of(mutableListOf())).also { @@ -129,12 +192,25 @@ private constructor( fun sort(sort: List?) = sort(JsonField.ofNullable(sort)) + /** Alias for calling [Builder.sort] with `sort.orElse(null)`. */ fun sort(sort: Optional>) = sort(sort.getOrNull()) + /** + * Sets [Builder.sort] to an arbitrary JSON value. + * + * You should usually call [Builder.sort] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun sort(sort: JsonField>) = apply { this.sort = sort.map { it.toMutableList() } } + /** + * Adds a single [JsonValue] to [Builder.sort]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addSort(sort: JsonValue) = apply { this.sort = (this.sort ?: JsonField.of(mutableListOf())).also { @@ -144,12 +220,25 @@ private constructor( fun tag(tag: List?) = tag(JsonField.ofNullable(tag)) + /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ fun tag(tag: Optional>) = tag(tag.getOrNull()) + /** + * Sets [Builder.tag] to an arbitrary JSON value. + * + * You should usually call [Builder.tag] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun tag(tag: JsonField>) = apply { this.tag = tag.map { it.toMutableList() } } + /** + * Adds a single [JsonValue] to [Builder.tag]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addTag(tag: JsonValue) = apply { this.tag = (this.tag ?: JsonField.of(mutableListOf())).also { checkKnown("tag", it).add(tag) } 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 859f6c54..64ac535e 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 @@ -13,6 +13,7 @@ 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 @@ -31,16 +32,34 @@ private constructor( /** View id */ fun viewId(): String = viewId - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = body.objectId() - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = body.objectType() - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectId(): JsonField = body._objectId() - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectType(): JsonField = body._objectType() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -76,16 +95,34 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType @@ -139,13 +176,25 @@ private constructor( /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -235,13 +284,24 @@ private constructor( /** The id of the object the view applies to */ fun objectId(objectId: String) = apply { body.objectId(objectId) } - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { 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 f7438d8e..db3c13bb 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 @@ -160,13 +160,7 @@ private constructor( */ fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) /** @@ -175,31 +169,26 @@ private constructor( */ fun ids(ids: Ids?) = apply { this.ids = ids } - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [Builder.ids] with `ids.orElse(null)`. */ fun ids(ids: Optional) = ids(ids.getOrNull()) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofString(string)`. */ fun ids(string: String) = ids(Ids.ofString(string)) - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ + /** Alias for calling [ids] with `Ids.ofStrings(strings)`. */ fun idsOfStrings(strings: List) = ids(Ids.ofStrings(strings)) /** Limit the number of objects to return */ fun limit(limit: Long?) = apply { this.limit = limit } - /** Limit the number of objects to return */ + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun limit(limit: Long) = limit(limit as Long?) - /** Limit the number of objects to return */ + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) /** @@ -211,26 +200,20 @@ private constructor( */ fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull()) /** Name of the view to search for */ fun viewName(viewName: String?) = apply { this.viewName = viewName } - /** Name of the view to search for */ + /** Alias for calling [Builder.viewName] with `viewName.orElse(null)`. */ fun viewName(viewName: Optional) = viewName(viewName.getOrNull()) /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = apply { this.viewType = viewType } - /** Type of table that the view corresponds to. */ + /** Alias for calling [Builder.viewType] with `viewType.orElse(null)`. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 40ff24c4..13231bb1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -10,6 +10,7 @@ import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.checkKnown 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,37 +45,92 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun columnOrder(): Optional> = Optional.ofNullable(columnOrder.getNullable("columnOrder")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun columnSizing(): Optional = Optional.ofNullable(columnSizing.getNullable("columnSizing")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun columnVisibility(): Optional = Optional.ofNullable(columnVisibility.getNullable("columnVisibility")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun grouping(): Optional = Optional.ofNullable(grouping.getNullable("grouping")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun layout(): Optional = Optional.ofNullable(layout.getNullable("layout")) + /** + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun rowHeight(): Optional = Optional.ofNullable(rowHeight.getNullable("rowHeight")) + /** + * Returns the raw JSON value of [columnOrder]. + * + * Unlike [columnOrder], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("columnOrder") @ExcludeMissing fun _columnOrder(): JsonField> = columnOrder + /** + * Returns the raw JSON value of [columnSizing]. + * + * Unlike [columnSizing], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("columnSizing") @ExcludeMissing fun _columnSizing(): JsonField = columnSizing + /** + * Returns the raw JSON value of [columnVisibility]. + * + * Unlike [columnVisibility], this method doesn't throw if the JSON field has an unexpected + * type. + */ @JsonProperty("columnVisibility") @ExcludeMissing fun _columnVisibility(): JsonField = columnVisibility + /** + * Returns the raw JSON value of [grouping]. + * + * Unlike [grouping], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping + /** + * Returns the raw JSON value of [layout]. + * + * Unlike [layout], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("layout") @ExcludeMissing fun _layout(): JsonField = layout + /** + * Returns the raw JSON value of [rowHeight]. + * + * Unlike [rowHeight], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("rowHeight") @ExcludeMissing fun _rowHeight(): JsonField = rowHeight @JsonAnyGetter @@ -129,12 +185,25 @@ private constructor( fun columnOrder(columnOrder: List?) = columnOrder(JsonField.ofNullable(columnOrder)) + /** Alias for calling [Builder.columnOrder] with `columnOrder.orElse(null)`. */ fun columnOrder(columnOrder: Optional>) = columnOrder(columnOrder.getOrNull()) + /** + * Sets [Builder.columnOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.columnOrder] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun columnOrder(columnOrder: JsonField>) = apply { this.columnOrder = columnOrder.map { it.toMutableList() } } + /** + * Adds a single [String] to [Builder.columnOrder]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ fun addColumnOrder(columnOrder: String) = apply { this.columnOrder = (this.columnOrder ?: JsonField.of(mutableListOf())).also { @@ -145,9 +214,17 @@ private constructor( fun columnSizing(columnSizing: ColumnSizing?) = columnSizing(JsonField.ofNullable(columnSizing)) + /** Alias for calling [Builder.columnSizing] with `columnSizing.orElse(null)`. */ fun columnSizing(columnSizing: Optional) = columnSizing(columnSizing.getOrNull()) + /** + * Sets [Builder.columnSizing] to an arbitrary JSON value. + * + * You should usually call [Builder.columnSizing] with a well-typed [ColumnSizing] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun columnSizing(columnSizing: JsonField) = apply { this.columnSizing = columnSizing } @@ -155,29 +232,59 @@ private constructor( fun columnVisibility(columnVisibility: ColumnVisibility?) = columnVisibility(JsonField.ofNullable(columnVisibility)) + /** Alias for calling [Builder.columnVisibility] with `columnVisibility.orElse(null)`. */ fun columnVisibility(columnVisibility: Optional) = columnVisibility(columnVisibility.getOrNull()) + /** + * Sets [Builder.columnVisibility] to an arbitrary JSON value. + * + * You should usually call [Builder.columnVisibility] with a well-typed [ColumnVisibility] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ fun columnVisibility(columnVisibility: JsonField) = apply { this.columnVisibility = columnVisibility } fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) + /** Alias for calling [Builder.grouping] with `grouping.orElse(null)`. */ fun grouping(grouping: Optional) = grouping(grouping.getOrNull()) + /** + * Sets [Builder.grouping] to an arbitrary JSON value. + * + * You should usually call [Builder.grouping] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun grouping(grouping: JsonField) = apply { this.grouping = grouping } fun layout(layout: String?) = layout(JsonField.ofNullable(layout)) + /** Alias for calling [Builder.layout] with `layout.orElse(null)`. */ fun layout(layout: Optional) = layout(layout.getOrNull()) + /** + * Sets [Builder.layout] to an arbitrary JSON value. + * + * You should usually call [Builder.layout] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun layout(layout: JsonField) = apply { this.layout = layout } fun rowHeight(rowHeight: String?) = rowHeight(JsonField.ofNullable(rowHeight)) + /** Alias for calling [Builder.rowHeight] with `rowHeight.orElse(null)`. */ fun rowHeight(rowHeight: Optional) = rowHeight(rowHeight.getOrNull()) + /** + * Sets [Builder.rowHeight] to an arbitrary JSON value. + * + * You should usually call [Builder.rowHeight] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun rowHeight(rowHeight: JsonField) = apply { this.rowHeight = rowHeight } fun additionalProperties(additionalProperties: Map) = apply { 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 7112d267..720246b3 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 @@ -35,52 +35,124 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Name of the view */ + /** + * Name of the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = body.name() - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = body.objectId() - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = body.objectType() - /** Type of table that the view corresponds to. */ + /** + * Type of table that the view corresponds to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun viewType(): Optional = body.viewType() - /** Date of role deletion, or null if the role is still active */ + /** + * Date of role deletion, or null if the role is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun deletedAt(): Optional = body.deletedAt() - /** Options for the view in the app */ + /** + * Options for the view in the app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun options(): Optional = body.options() - /** Identifies the user who created the view */ + /** + * Identifies the user who created the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = body.userId() - /** The view definition */ + /** + * The view definition + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun viewData(): Optional = body.viewData() - /** Name of the view */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectId(): JsonField = body._objectId() - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectType(): JsonField = body._objectType() - /** Type of table that the view corresponds to. */ + /** + * Returns the raw JSON value of [viewType]. + * + * Unlike [viewType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _viewType(): JsonField = body._viewType() - /** Date of role deletion, or null if the role is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ fun _deletedAt(): JsonField = body._deletedAt() - /** Options for the view in the app */ + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ fun _options(): JsonField = body._options() - /** Identifies the user who created the view */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _userId(): JsonField = body._userId() - /** The view definition */ + /** + * Returns the raw JSON value of [viewData]. + * + * Unlike [viewData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _viewData(): JsonField = body._viewData() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -127,57 +199,129 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** Name of the view */ + /** + * Name of the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun name(): String = name.getRequired("name") - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") - /** Type of table that the view corresponds to. */ + /** + * Type of table that the view corresponds to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) - /** Date of role deletion, or null if the role is still active */ + /** + * Date of role deletion, or null if the role is still active + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun deletedAt(): Optional = Optional.ofNullable(deletedAt.getNullable("deleted_at")) - /** Options for the view in the app */ + /** + * Options for the view in the app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - /** Identifies the user who created the view */ + /** + * Identifies the user who created the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** The view definition */ + /** + * The view definition + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) - /** Name of the view */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Type of table that the view corresponds to. */ + /** + * Returns the raw JSON value of [viewType]. + * + * Unlike [viewType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType - /** Date of role deletion, or null if the role is still active */ + /** + * Returns the raw JSON value of [deletedAt]. + * + * Unlike [deletedAt], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt(): JsonField = deletedAt - /** Options for the view in the app */ + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options - /** Identifies the user who created the view */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - /** The view definition */ + /** + * Returns the raw JSON value of [viewData]. + * + * Unlike [viewData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData @JsonAnyGetter @@ -249,19 +393,37 @@ private constructor( /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) - /** Name of the view */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -269,19 +431,31 @@ private constructor( /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) - /** Type of table that the view corresponds to. */ + /** Alias for calling [Builder.viewType] with `viewType.orElse(null)`. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - /** Type of table that the view corresponds to. */ + /** + * Sets [Builder.viewType] to an arbitrary JSON value. + * + * You should usually call [Builder.viewType] with a well-typed [ViewType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun viewType(viewType: JsonField) = apply { this.viewType = viewType } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = deletedAt(JsonField.ofNullable(deletedAt)) - /** Date of role deletion, or null if the role is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of role deletion, or null if the role is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } @@ -289,28 +463,46 @@ private constructor( /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) - /** Options for the view in the app */ + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ fun options(options: Optional) = options(options.getOrNull()) - /** Options for the view in the app */ + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [ViewOptions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the view */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the view */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) - /** The view definition */ + /** Alias for calling [Builder.viewData] with `viewData.orElse(null)`. */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) - /** The view definition */ + /** + * Sets [Builder.viewData] to an arbitrary JSON value. + * + * You should usually call [Builder.viewData] with a well-typed [ViewData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun viewData(viewData: JsonField) = apply { this.viewData = viewData } fun additionalProperties(additionalProperties: Map) = apply { @@ -400,64 +592,109 @@ private constructor( /** Name of the view */ fun name(name: String) = apply { body.name(name) } - /** Name of the view */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** The id of the object the view applies to */ fun objectId(objectId: String) = apply { body.objectId(objectId) } - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } - /** Type of table that the view corresponds to. */ + /** Alias for calling [Builder.viewType] with `viewType.orElse(null)`. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - /** Type of table that the view corresponds to. */ + /** + * Sets [Builder.viewType] to an arbitrary JSON value. + * + * You should usually call [Builder.viewType] with a well-typed [ViewType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime?) = apply { body.deletedAt(deletedAt) } - /** Date of role deletion, or null if the role is still active */ + /** Alias for calling [Builder.deletedAt] with `deletedAt.orElse(null)`. */ fun deletedAt(deletedAt: Optional) = deletedAt(deletedAt.getOrNull()) - /** Date of role deletion, or null if the role is still active */ + /** + * Sets [Builder.deletedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deletedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun deletedAt(deletedAt: JsonField) = apply { body.deletedAt(deletedAt) } /** Options for the view in the app */ fun options(options: ViewOptions?) = apply { body.options(options) } - /** Options for the view in the app */ + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ fun options(options: Optional) = options(options.getOrNull()) - /** Options for the view in the app */ + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [ViewOptions] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun options(options: JsonField) = apply { body.options(options) } /** Identifies the user who created the view */ fun userId(userId: String?) = apply { body.userId(userId) } - /** Identifies the user who created the view */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the view */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { body.userId(userId) } /** The view definition */ fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } - /** The view definition */ + /** Alias for calling [Builder.viewData] with `viewData.orElse(null)`. */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) - /** The view definition */ + /** + * Sets [Builder.viewData] to an arbitrary JSON value. + * + * You should usually call [Builder.viewData] with a well-typed [ViewData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { 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 6521f2e1..a442a37a 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 @@ -39,46 +39,109 @@ private constructor( /** View id */ fun viewId(): String = viewId - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = body.objectId() - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = body.objectType() - /** Name of the view */ + /** + * Name of the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun name(): Optional = body.name() - /** Options for the view in the app */ + /** + * Options for the view in the app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun options(): Optional = body.options() - /** Identifies the user who created the view */ + /** + * Identifies the user who created the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun userId(): Optional = body.userId() - /** The view definition */ + /** + * The view definition + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun viewData(): Optional = body.viewData() - /** Type of table that the view corresponds to. */ + /** + * Type of table that the view corresponds to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun viewType(): Optional = body.viewType() - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectId(): JsonField = body._objectId() - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _objectType(): JsonField = body._objectType() - /** Name of the view */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ fun _name(): JsonField = body._name() - /** Options for the view in the app */ + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ fun _options(): JsonField = body._options() - /** Identifies the user who created the view */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ fun _userId(): JsonField = body._userId() - /** The view definition */ + /** + * Returns the raw JSON value of [viewData]. + * + * Unlike [viewData], this method doesn't throw if the JSON field has an unexpected type. + */ fun _viewData(): JsonField = body._viewData() - /** Type of table that the view corresponds to. */ + /** + * Returns the raw JSON value of [viewType]. + * + * Unlike [viewType], this method doesn't throw if the JSON field has an unexpected type. + */ fun _viewType(): JsonField = body._viewType() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -129,48 +192,111 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The id of the object the view applies to */ + /** + * The id of the object the view applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectId(): String = objectId.getRequired("object_id") - /** The object type that the ACL applies to */ + /** + * The object type that the ACL applies to + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ fun objectType(): AclObjectType = objectType.getRequired("object_type") - /** Name of the view */ + /** + * Name of the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - /** Options for the view in the app */ + /** + * Options for the view in the app + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun options(): Optional = Optional.ofNullable(options.getNullable("options")) - /** Identifies the user who created the view */ + /** + * Identifies the user who created the view + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun userId(): Optional = Optional.ofNullable(userId.getNullable("user_id")) - /** The view definition */ + /** + * The view definition + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun viewData(): Optional = Optional.ofNullable(viewData.getNullable("view_data")) - /** Type of table that the view corresponds to. */ + /** + * Type of table that the view corresponds to. + * + * @throws BraintrustInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ fun viewType(): Optional = Optional.ofNullable(viewType.getNullable("view_type")) - /** The id of the object the view applies to */ + /** + * Returns the raw JSON value of [objectId]. + * + * Unlike [objectId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_id") @ExcludeMissing fun _objectId(): JsonField = objectId - /** The object type that the ACL applies to */ + /** + * Returns the raw JSON value of [objectType]. + * + * Unlike [objectType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("object_type") @ExcludeMissing fun _objectType(): JsonField = objectType - /** Name of the view */ + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Options for the view in the app */ + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options - /** Identifies the user who created the view */ + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - /** The view definition */ + /** + * Returns the raw JSON value of [viewData]. + * + * Unlike [viewData], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("view_data") @ExcludeMissing fun _viewData(): JsonField = viewData - /** Type of table that the view corresponds to. */ + /** + * Returns the raw JSON value of [viewType]. + * + * Unlike [viewType], this method doesn't throw if the JSON field has an unexpected type. + */ @JsonProperty("view_type") @ExcludeMissing fun _viewType(): JsonField = viewType @JsonAnyGetter @@ -237,13 +363,25 @@ private constructor( /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectId(objectId: JsonField) = apply { this.objectId = objectId } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = objectType(JsonField.of(objectType)) - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { this.objectType = objectType } @@ -251,46 +389,76 @@ private constructor( /** Name of the view */ fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Name of the view */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the view */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun name(name: JsonField) = apply { this.name = name } /** Options for the view in the app */ fun options(options: ViewOptions?) = options(JsonField.ofNullable(options)) - /** Options for the view in the app */ + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ fun options(options: Optional) = options(options.getOrNull()) - /** Options for the view in the app */ + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [ViewOptions] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun options(options: JsonField) = apply { this.options = options } /** Identifies the user who created the view */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - /** Identifies the user who created the view */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the view */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun userId(userId: JsonField) = apply { this.userId = userId } /** The view definition */ fun viewData(viewData: ViewData?) = viewData(JsonField.ofNullable(viewData)) - /** The view definition */ + /** Alias for calling [Builder.viewData] with `viewData.orElse(null)`. */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) - /** The view definition */ + /** + * Sets [Builder.viewData] to an arbitrary JSON value. + * + * You should usually call [Builder.viewData] with a well-typed [ViewData] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun viewData(viewData: JsonField) = apply { this.viewData = viewData } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = viewType(JsonField.ofNullable(viewType)) - /** Type of table that the view corresponds to. */ + /** Alias for calling [Builder.viewType] with `viewType.orElse(null)`. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - /** Type of table that the view corresponds to. */ + /** + * Sets [Builder.viewType] to an arbitrary JSON value. + * + * You should usually call [Builder.viewType] with a well-typed [ViewType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun viewType(viewType: JsonField) = apply { this.viewType = viewType } fun additionalProperties(additionalProperties: Map) = apply { @@ -383,58 +551,97 @@ private constructor( /** The id of the object the view applies to */ fun objectId(objectId: String) = apply { body.objectId(objectId) } - /** The id of the object the view applies to */ + /** + * Sets [Builder.objectId] to an arbitrary JSON value. + * + * You should usually call [Builder.objectId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun objectId(objectId: JsonField) = apply { body.objectId(objectId) } /** The object type that the ACL applies to */ fun objectType(objectType: AclObjectType) = apply { body.objectType(objectType) } - /** The object type that the ACL applies to */ + /** + * Sets [Builder.objectType] to an arbitrary JSON value. + * + * You should usually call [Builder.objectType] with a well-typed [AclObjectType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ fun objectType(objectType: JsonField) = apply { body.objectType(objectType) } /** Name of the view */ fun name(name: String?) = apply { body.name(name) } - /** Name of the view */ + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ fun name(name: Optional) = name(name.getOrNull()) - /** Name of the view */ + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun name(name: JsonField) = apply { body.name(name) } /** Options for the view in the app */ fun options(options: ViewOptions?) = apply { body.options(options) } - /** Options for the view in the app */ + /** Alias for calling [Builder.options] with `options.orElse(null)`. */ fun options(options: Optional) = options(options.getOrNull()) - /** Options for the view in the app */ + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [ViewOptions] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun options(options: JsonField) = apply { body.options(options) } /** Identifies the user who created the view */ fun userId(userId: String?) = apply { body.userId(userId) } - /** Identifies the user who created the view */ + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Identifies the user who created the view */ + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ fun userId(userId: JsonField) = apply { body.userId(userId) } /** The view definition */ fun viewData(viewData: ViewData?) = apply { body.viewData(viewData) } - /** The view definition */ + /** Alias for calling [Builder.viewData] with `viewData.orElse(null)`. */ fun viewData(viewData: Optional) = viewData(viewData.getOrNull()) - /** The view definition */ + /** + * Sets [Builder.viewData] to an arbitrary JSON value. + * + * You should usually call [Builder.viewData] with a well-typed [ViewData] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun viewData(viewData: JsonField) = apply { body.viewData(viewData) } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType?) = apply { body.viewType(viewType) } - /** Type of table that the view corresponds to. */ + /** Alias for calling [Builder.viewType] with `viewType.orElse(null)`. */ fun viewType(viewType: Optional) = viewType(viewType.getOrNull()) - /** Type of table that the view corresponds to. */ + /** + * Sets [Builder.viewType] to an arbitrary JSON value. + * + * You should usually call [Builder.viewType] with a well-typed [ViewType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ fun viewType(viewType: JsonField) = apply { body.viewType(viewType) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { From f4d99903225690cfb6fad53ac26fee5c3615977f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 16:33:43 +0000 Subject: [PATCH 83/87] chore(internal): make test classes internal (#153) --- .../test/kotlin/com/braintrustdata/api/models/AISecretTest.kt | 2 +- .../com/braintrustdata/api/models/AclBatchUpdateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/AclBatchUpdateResponseTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/AclFindAndDeleteParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/AclListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/AclRetrieveParamsTest.kt | 2 +- .../src/test/kotlin/com/braintrustdata/api/models/AclTest.kt | 2 +- .../com/braintrustdata/api/models/AiSecretCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt | 2 +- .../api/models/AiSecretFindAndDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/AiSecretListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt | 2 +- .../com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt | 2 +- .../com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ApiKeyListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt | 2 +- .../src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt | 2 +- .../api/models/ChatCompletionContentPartImageTest.kt | 2 +- .../api/models/ChatCompletionContentPartTextTest.kt | 2 +- .../api/models/ChatCompletionMessageToolCallTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt | 2 +- .../com/braintrustdata/api/models/CreateApiKeyOutputTest.kt | 2 +- .../braintrustdata/api/models/CrossObjectInsertResponseTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/DataSummaryTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetDeleteParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/DatasetEventTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetFetchParamsTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetInsertParamsTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/DatasetTest.kt | 2 +- .../com/braintrustdata/api/models/DatasetUpdateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/EnvVarCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/EnvVarListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/EnvVarListResponseTest.kt | 2 +- .../com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt | 2 +- .../com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt | 2 +- .../src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt | 2 +- .../com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/EvalCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ExperimentCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt | 2 +- .../braintrustdata/api/models/ExperimentFeedbackParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ExperimentFetchParamsTest.kt | 2 +- .../braintrustdata/api/models/ExperimentFetchPostParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ExperimentInsertParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ExperimentListParamsTest.kt | 2 +- .../braintrustdata/api/models/ExperimentRetrieveParamsTest.kt | 2 +- .../braintrustdata/api/models/ExperimentSummarizeParamsTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt | 2 +- .../com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/FeedbackDatasetItemTest.kt | 2 +- .../com/braintrustdata/api/models/FeedbackExperimentItemTest.kt | 2 +- .../braintrustdata/api/models/FeedbackProjectLogsItemTest.kt | 2 +- .../com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt | 2 +- .../braintrustdata/api/models/FetchDatasetEventsResponseTest.kt | 2 +- .../api/models/FetchExperimentEventsResponseTest.kt | 2 +- .../api/models/FetchProjectLogsEventsResponseTest.kt | 2 +- .../com/braintrustdata/api/models/FunctionCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/FunctionDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/FunctionInvokeParamsTest.kt | 2 +- .../com/braintrustdata/api/models/FunctionListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/FunctionReplaceParamsTest.kt | 2 +- .../com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/FunctionTest.kt | 2 +- .../com/braintrustdata/api/models/FunctionUpdateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/GroupCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/GroupDeleteParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/GroupReplaceParamsTest.kt | 2 +- .../com/braintrustdata/api/models/GroupRetrieveParamsTest.kt | 2 +- .../src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt | 2 +- .../com/braintrustdata/api/models/GroupUpdateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/InsertDatasetEventTest.kt | 2 +- .../com/braintrustdata/api/models/InsertEventsResponseTest.kt | 2 +- .../com/braintrustdata/api/models/InsertExperimentEventTest.kt | 2 +- .../com/braintrustdata/api/models/InsertProjectLogsEventTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt | 2 +- .../com/braintrustdata/api/models/OnlineScoreConfigTest.kt | 2 +- .../braintrustdata/api/models/OrganizationDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/OrganizationListParamsTest.kt | 2 +- .../api/models/OrganizationMemberUpdateParamsTest.kt | 2 +- .../braintrustdata/api/models/OrganizationRetrieveParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/OrganizationTest.kt | 2 +- .../braintrustdata/api/models/OrganizationUpdateParamsTest.kt | 2 +- .../api/models/PatchOrganizationMembersOutputTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectListParamsTest.kt | 2 +- .../braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt | 2 +- .../braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectLogsEventTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectScoreCategoryTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectScoreConfigTest.kt | 2 +- .../braintrustdata/api/models/ProjectScoreCreateParamsTest.kt | 2 +- .../braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectScoreListParamsTest.kt | 2 +- .../braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt | 2 +- .../braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt | 2 +- .../braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectTagListParamsTest.kt | 2 +- .../braintrustdata/api/models/ProjectTagReplaceParamsTest.kt | 2 +- .../braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/ProjectTest.kt | 2 +- .../com/braintrustdata/api/models/ProjectUpdateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/PromptCreateParamsTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt | 2 +- .../com/braintrustdata/api/models/PromptDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/PromptListParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt | 2 +- .../com/braintrustdata/api/models/PromptReplaceParamsTest.kt | 2 +- .../com/braintrustdata/api/models/PromptRetrieveParamsTest.kt | 2 +- .../src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt | 2 +- .../com/braintrustdata/api/models/PromptUpdateParamsTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt | 2 +- .../com/braintrustdata/api/models/RoleCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/RoleDeleteParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/RoleReplaceParamsTest.kt | 2 +- .../com/braintrustdata/api/models/RoleRetrieveParamsTest.kt | 2 +- .../src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt | 2 +- .../com/braintrustdata/api/models/RoleUpdateParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/SpanAttributesTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt | 2 +- .../com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt | 2 +- .../com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt | 2 +- .../com/braintrustdata/api/models/SpanIframeListParamsTest.kt | 2 +- .../braintrustdata/api/models/SpanIframeReplaceParamsTest.kt | 2 +- .../braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt | 2 +- .../com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt | 2 +- .../braintrustdata/api/models/SummarizeDatasetResponseTest.kt | 2 +- .../api/models/SummarizeExperimentResponseTest.kt | 2 +- .../braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/UserListParamsTest.kt | 2 +- .../com/braintrustdata/api/models/UserRetrieveParamsTest.kt | 2 +- .../src/test/kotlin/com/braintrustdata/api/models/UserTest.kt | 2 +- .../com/braintrustdata/api/models/ViewCreateParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt | 2 +- .../test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt | 2 +- .../com/braintrustdata/api/models/ViewDeleteParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt | 2 +- .../com/braintrustdata/api/models/ViewReplaceParamsTest.kt | 2 +- .../com/braintrustdata/api/models/ViewRetrieveParamsTest.kt | 2 +- .../src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt | 2 +- .../com/braintrustdata/api/models/ViewUpdateParamsTest.kt | 2 +- .../kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt | 2 +- .../braintrustdata/api/services/async/AclServiceAsyncTest.kt | 2 +- .../api/services/async/AiSecretServiceAsyncTest.kt | 2 +- .../braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt | 2 +- .../api/services/async/DatasetServiceAsyncTest.kt | 2 +- .../braintrustdata/api/services/async/EnvVarServiceAsyncTest.kt | 2 +- .../braintrustdata/api/services/async/EvalServiceAsyncTest.kt | 2 +- .../api/services/async/ExperimentServiceAsyncTest.kt | 2 +- .../api/services/async/FunctionServiceAsyncTest.kt | 2 +- .../braintrustdata/api/services/async/GroupServiceAsyncTest.kt | 2 +- .../api/services/async/OrganizationServiceAsyncTest.kt | 2 +- .../api/services/async/ProjectScoreServiceAsyncTest.kt | 2 +- .../api/services/async/ProjectServiceAsyncTest.kt | 2 +- .../api/services/async/ProjectTagServiceAsyncTest.kt | 2 +- .../braintrustdata/api/services/async/PromptServiceAsyncTest.kt | 2 +- .../braintrustdata/api/services/async/RoleServiceAsyncTest.kt | 2 +- .../api/services/async/SpanIframeServiceAsyncTest.kt | 2 +- .../api/services/async/TopLevelServiceAsyncTest.kt | 2 +- .../braintrustdata/api/services/async/UserServiceAsyncTest.kt | 2 +- .../braintrustdata/api/services/async/ViewServiceAsyncTest.kt | 2 +- .../api/services/async/organizations/MemberServiceAsyncTest.kt | 2 +- .../api/services/async/projects/LogServiceAsyncTest.kt | 2 +- .../com/braintrustdata/api/services/blocking/AclServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/AiSecretServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/ApiKeyServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/DatasetServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/EnvVarServiceTest.kt | 2 +- .../com/braintrustdata/api/services/blocking/EvalServiceTest.kt | 2 +- .../api/services/blocking/ExperimentServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/FunctionServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/GroupServiceTest.kt | 2 +- .../api/services/blocking/OrganizationServiceTest.kt | 2 +- .../api/services/blocking/ProjectScoreServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/ProjectServiceTest.kt | 2 +- .../api/services/blocking/ProjectTagServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/PromptServiceTest.kt | 2 +- .../com/braintrustdata/api/services/blocking/RoleServiceTest.kt | 2 +- .../api/services/blocking/SpanIframeServiceTest.kt | 2 +- .../braintrustdata/api/services/blocking/TopLevelServiceTest.kt | 2 +- .../com/braintrustdata/api/services/blocking/UserServiceTest.kt | 2 +- .../com/braintrustdata/api/services/blocking/ViewServiceTest.kt | 2 +- .../api/services/blocking/organizations/MemberServiceTest.kt | 2 +- .../api/services/blocking/projects/LogServiceTest.kt | 2 +- 210 files changed, 210 insertions(+), 210 deletions(-) diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt index d4b40e30..d7241b89 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AISecretTest.kt @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AISecretTest { +internal class AISecretTest { @Test fun createAISecret() { 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 4ad8ce2c..fefded29 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AclBatchUpdateParamsTest { +internal class AclBatchUpdateParamsTest { @Test fun create() { 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 02a05b7e..b04bfa85 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 @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AclBatchUpdateResponseTest { +internal class AclBatchUpdateResponseTest { @Test fun createAclBatchUpdateResponse() { 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 4e3b9c42..20eb299f 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AclCreateParamsTest { +internal class AclCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt index 51793459..a520f8ce 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AclDeleteParamsTest { +internal class AclDeleteParamsTest { @Test fun create() { 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 c965416f..d6b03177 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AclFindAndDeleteParamsTest { +internal class AclFindAndDeleteParamsTest { @Test fun create() { 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 f8fb38e1..3cfdbe75 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 @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AclListParamsTest { +internal class AclListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt index fd23f612..8ad3dfac 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AclRetrieveParamsTest { +internal class AclRetrieveParamsTest { @Test fun create() { 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 61d63fab..39258080 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 @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AclTest { +internal class AclTest { @Test fun createAcl() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt index 213130fd..d91d0d19 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretCreateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AiSecretCreateParamsTest { +internal class AiSecretCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt index a59725a1..2d9d6f3a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AiSecretDeleteParamsTest { +internal class AiSecretDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt index f46d2fb2..d7365a0b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AiSecretFindAndDeleteParamsTest { +internal class AiSecretFindAndDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt index fff7ec47..3e18fc34 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AiSecretListParamsTest { +internal class AiSecretListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt index b716129c..cde09c24 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretReplaceParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AiSecretReplaceParamsTest { +internal class AiSecretReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt index 5c6d07cc..a9f2f2aa 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AiSecretRetrieveParamsTest { +internal class AiSecretRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt index b45e1c86..627ea2bf 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretUpdateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class AiSecretUpdateParamsTest { +internal class AiSecretUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt index d450a958..315dc13b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyCreateParamsTest { +internal class ApiKeyCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt index 0b7c5a7d..f7546c55 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyDeleteParamsTest { +internal class ApiKeyDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index 41532fd3..fc950cfe 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyListParamsTest { +internal class ApiKeyListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt index 2170ff30..f5ca88f6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyRetrieveParamsTest { +internal class ApiKeyRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt index 5d9ab3b9..099b0e65 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ApiKeyTest { +internal class ApiKeyTest { @Test fun createApiKey() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt index fbf9f7e4..b826be89 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImageTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ChatCompletionContentPartImageTest { +internal class ChatCompletionContentPartImageTest { @Test fun createChatCompletionContentPartImage() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt index 5e71c215..2e8d9c23 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartTextTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ChatCompletionContentPartTextTest { +internal class ChatCompletionContentPartTextTest { @Test fun createChatCompletionContentPartText() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt index c609ef38..b140cc39 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCallTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ChatCompletionMessageToolCallTest { +internal class ChatCompletionMessageToolCallTest { @Test fun createChatCompletionMessageToolCall() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt index 7cced6c5..5eb775e3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CodeBundleTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class CodeBundleTest { +internal class CodeBundleTest { @Test fun createCodeBundle() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt index 6bfead25..f9057687 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class CreateApiKeyOutputTest { +internal class CreateApiKeyOutputTest { @Test fun createCreateApiKeyOutput() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt index 6ce8e5d3..4abcfb9d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class CrossObjectInsertResponseTest { +internal class CrossObjectInsertResponseTest { @Test fun createCrossObjectInsertResponse() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt index 4cc2a2db..f7759625 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DataSummaryTest { +internal class DataSummaryTest { @Test fun createDataSummary() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index 53e0d257..e9bd56e1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetCreateParamsTest { +internal class DatasetCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt index 8b41dbf4..1d74f765 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetDeleteParamsTest { +internal class DatasetDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt index 2226864c..14d3a5c7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetEventTest { +internal class DatasetEventTest { @Test fun createDatasetEvent() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index 512fb176..5c8d41e3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetFeedbackParamsTest { +internal class DatasetFeedbackParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index 1a2a1725..6e81ad31 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetFetchParamsTest { +internal class DatasetFetchParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index 3120e7e1..53eeec48 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetFetchPostParamsTest { +internal class DatasetFetchPostParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index 7278beb1..4b535b10 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -8,7 +8,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetInsertParamsTest { +internal class DatasetInsertParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index de58fd44..98586408 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetListParamsTest { +internal class DatasetListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt index 95326568..147e6451 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetRetrieveParamsTest { +internal class DatasetRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index 83303cf0..de4e5a5b 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetSummarizeParamsTest { +internal class DatasetSummarizeParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt index 829a918e..5751efca 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetTest { +internal class DatasetTest { @Test fun createDataset() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index c7976ff2..ebdf0e4f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class DatasetUpdateParamsTest { +internal class DatasetUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt index d5e8e9f1..1af40d88 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarCreateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EnvVarCreateParamsTest { +internal class EnvVarCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt index b6264f9d..e7c988b4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EnvVarDeleteParamsTest { +internal class EnvVarDeleteParamsTest { @Test fun create() { 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 c946d12b..e150aed4 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 @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EnvVarListParamsTest { +internal class EnvVarListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt index 35b86df1..801245e2 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarListResponseTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EnvVarListResponseTest { +internal class EnvVarListResponseTest { @Test fun createEnvVarListResponse() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt index 68d9ebd2..74d5e35f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarReplaceParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EnvVarReplaceParamsTest { +internal class EnvVarReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt index bca82bdc..d2eee241 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EnvVarRetrieveParamsTest { +internal class EnvVarRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt index 224dddbb..6df9126a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EnvVarTest { +internal class EnvVarTest { @Test fun createEnvVar() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt index e4ad1080..81bdf42a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EnvVarUpdateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EnvVarUpdateParamsTest { +internal class EnvVarUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt index 869fa93c..ec0f8d22 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/EvalCreateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EvalCreateParamsTest { +internal class EvalCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 0b43f784..d7f74f35 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentCreateParamsTest { +internal class ExperimentCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt index 30220ebc..cc7edd11 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentDeleteParamsTest { +internal class ExperimentDeleteParamsTest { @Test fun create() { 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 dbcac3f4..bc31377c 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 @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentEventTest { +internal class ExperimentEventTest { @Test fun createExperimentEvent() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index edb22bd0..5ce9c787 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentFeedbackParamsTest { +internal class ExperimentFeedbackParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index a699676d..6f3ff78f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentFetchParamsTest { +internal class ExperimentFetchParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index f537a14a..d8445769 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentFetchPostParamsTest { +internal class ExperimentFetchPostParamsTest { @Test fun create() { 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 6525a6ce..aeaadaf0 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 @@ -8,7 +8,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentInsertParamsTest { +internal class ExperimentInsertParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 06a265e5..f0da65fc 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentListParamsTest { +internal class ExperimentListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt index b9530a24..435a99fd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentRetrieveParamsTest { +internal class ExperimentRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index 257ca247..3a506159 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentSummarizeParamsTest { +internal class ExperimentSummarizeParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt index 2d2df4e3..534b2774 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentTest { +internal class ExperimentTest { @Test fun createExperiment() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index e7ed2b95..2284d934 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ExperimentUpdateParamsTest { +internal class ExperimentUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index 6543fca7..b10a7fce 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FeedbackDatasetItemTest { +internal class FeedbackDatasetItemTest { @Test fun createFeedbackDatasetItem() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index eef4dee8..2b36a2b7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FeedbackExperimentItemTest { +internal class FeedbackExperimentItemTest { @Test fun createFeedbackExperimentItem() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index 34f44497..6fea45de 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FeedbackProjectLogsItemTest { +internal class FeedbackProjectLogsItemTest { @Test fun createFeedbackProjectLogsItem() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt index a1b62a0b..bafdb30c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FeedbackResponseSchemaTest { +internal class FeedbackResponseSchemaTest { @Test fun createFeedbackResponseSchema() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt index 29bcfe3b..ced9effd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FetchDatasetEventsResponseTest { +internal class FetchDatasetEventsResponseTest { @Test fun createFetchDatasetEventsResponse() { 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 4bd1e40e..7ec8e63b 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 @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FetchExperimentEventsResponseTest { +internal class FetchExperimentEventsResponseTest { @Test fun createFetchExperimentEventsResponse() { 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 9ddf349e..ae7b0b5a 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 @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FetchProjectLogsEventsResponseTest { +internal class FetchProjectLogsEventsResponseTest { @Test fun createFetchProjectLogsEventsResponse() { 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 b0062e5f..a4747bcf 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 @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FunctionCreateParamsTest { +internal class FunctionCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt index 480affa6..4b8a7c19 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FunctionDeleteParamsTest { +internal class FunctionDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt index 4a9bbd1f..988dc6e4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionInvokeParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FunctionInvokeParamsTest { +internal class FunctionInvokeParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 289b3695..94f2cc3c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FunctionListParamsTest { +internal class FunctionListParamsTest { @Test fun create() { 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 86799252..a1c6af81 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 @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FunctionReplaceParamsTest { +internal class FunctionReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt index 95d6777e..9890c9f3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FunctionRetrieveParamsTest { +internal class FunctionRetrieveParamsTest { @Test fun create() { 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 69851128..b42ee0e0 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 @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FunctionTest { +internal class FunctionTest { @Test fun createFunction() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index cd43ea77..261982cd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class FunctionUpdateParamsTest { +internal class FunctionUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index c9d71536..4707e762 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class GroupCreateParamsTest { +internal class GroupCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt index e7f479a6..362fe3f6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class GroupDeleteParamsTest { +internal class GroupDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index c5cd5eb4..152279d4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class GroupListParamsTest { +internal class GroupListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index 093c89bc..d5c3f0ec 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class GroupReplaceParamsTest { +internal class GroupReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt index 289d5b88..ea355d6a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class GroupRetrieveParamsTest { +internal class GroupRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt index 1acccdaa..235fb2a1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class GroupTest { +internal class GroupTest { @Test fun createGroup() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index cb449a6e..ece1b27d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class GroupUpdateParamsTest { +internal class GroupUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt index f81a9b5e..176a9e81 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventTest.kt @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InsertDatasetEventTest { +internal class InsertDatasetEventTest { @Test fun createInsertDatasetEvent() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt index 96d2a732..bc8f0a96 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InsertEventsResponseTest { +internal class InsertEventsResponseTest { @Test fun createInsertEventsResponse() { 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 90c5a67c..3f52dc7f 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 @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InsertExperimentEventTest { +internal class InsertExperimentEventTest { @Test fun createInsertExperimentEvent() { 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 3d0fc82f..b3812878 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 @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InsertProjectLogsEventTest { +internal class InsertProjectLogsEventTest { @Test fun createInsertProjectLogsEvent() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt index cc848c7c..a1dc0294 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class MetricSummaryTest { +internal class MetricSummaryTest { @Test fun createMetricSummary() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt index d859fcd0..cd116d19 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ObjectReferenceTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ObjectReferenceTest { +internal class ObjectReferenceTest { @Test fun createObjectReference() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt index 33f7f133..01f4d508 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OnlineScoreConfigTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class OnlineScoreConfigTest { +internal class OnlineScoreConfigTest { @Test fun createOnlineScoreConfig() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt index b86730ee..7bd8b264 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class OrganizationDeleteParamsTest { +internal class OrganizationDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index 823cdd9c..fe4df3d0 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class OrganizationListParamsTest { +internal class OrganizationListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt index ccb97ded..a9430430 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class OrganizationMemberUpdateParamsTest { +internal class OrganizationMemberUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt index d7faaa14..b0f6faaf 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class OrganizationRetrieveParamsTest { +internal class OrganizationRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt index d458dc17..d5220152 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class OrganizationTest { +internal class OrganizationTest { @Test fun createOrganization() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt index 00ff172f..f1cf977a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class OrganizationUpdateParamsTest { +internal class OrganizationUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt index dabc2d8c..8a00b5e5 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutputTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PatchOrganizationMembersOutputTest { +internal class PatchOrganizationMembersOutputTest { @Test fun createPatchOrganizationMembersOutput() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index 32b8bed3..c9ffd874 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectCreateParamsTest { +internal class ProjectCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt index b55b368f..3e30198e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectDeleteParamsTest { +internal class ProjectDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 2f0484be..0e309b60 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectListParamsTest { +internal class ProjectListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index d7a429e1..516e71e3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectLogFeedbackParamsTest { +internal class ProjectLogFeedbackParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index 6e341ea3..61d382e2 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectLogFetchParamsTest { +internal class ProjectLogFetchParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 9d2530b0..6bed5b0e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectLogFetchPostParamsTest { +internal class ProjectLogFetchPostParamsTest { @Test fun create() { 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 868951f5..d238976b 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 @@ -8,7 +8,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectLogInsertParamsTest { +internal class ProjectLogInsertParamsTest { @Test fun create() { 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 60cbff52..ac983318 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 @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectLogsEventTest { +internal class ProjectLogsEventTest { @Test fun createProjectLogsEvent() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt index 071ceffa..ad7bf543 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectRetrieveParamsTest { +internal class ProjectRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt index 95a3b093..eb62ebe7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreCategoryTest { +internal class ProjectScoreCategoryTest { @Test fun createProjectScoreCategory() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt index 762e01a3..40346457 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreConfigTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreConfigTest { +internal class ProjectScoreConfigTest { @Test fun createProjectScoreConfig() { 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 09035879..af4c04c3 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreCreateParamsTest { +internal class ProjectScoreCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt index f341257a..3ba5951f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreDeleteParamsTest { +internal class ProjectScoreDeleteParamsTest { @Test fun create() { 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 1dce4750..4f67003d 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 @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreListParamsTest { +internal class ProjectScoreListParamsTest { @Test fun create() { 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 fc7147da..50960ecf 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreReplaceParamsTest { +internal class ProjectScoreReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt index d5ba83a1..a6f2bd61 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreRetrieveParamsTest { +internal class ProjectScoreRetrieveParamsTest { @Test fun create() { 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 377bc562..576f47a4 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 @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreTest { +internal class ProjectScoreTest { @Test fun createProjectScore() { 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 df455978..5c2a615d 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectScoreUpdateParamsTest { +internal class ProjectScoreUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt index f5216655..7a9c2f21 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectSettingsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectSettingsTest { +internal class ProjectSettingsTest { @Test fun createProjectSettings() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt index 04649ccf..221e1eb7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectTagCreateParamsTest { +internal class ProjectTagCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt index 30ff07c4..7de39ed3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectTagDeleteParamsTest { +internal class ProjectTagDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index b0008157..1a227720 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectTagListParamsTest { +internal class ProjectTagListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt index 9e25d87a..c3c2cb8c 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectTagReplaceParamsTest { +internal class ProjectTagReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt index a1d9d5ee..bceb5438 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectTagRetrieveParamsTest { +internal class ProjectTagRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt index d9a83759..23968bbb 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectTagTest { +internal class ProjectTagTest { @Test fun createProjectTag() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt index 343aa380..0bda9b77 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectTagUpdateParamsTest { +internal class ProjectTagUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt index 0a924ec6..15ac6b29 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectTest { +internal class ProjectTest { @Test fun createProject() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index 55bd050e..231a5855 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectUpdateParamsTest { +internal class ProjectUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 80c96334..4b481b7f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptCreateParamsTest { +internal class PromptCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index 66346100..88789045 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptDataTest { +internal class PromptDataTest { @Test fun createPromptData() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt index ac1b91bb..5fa9d727 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptDeleteParamsTest { +internal class PromptDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index 913ef416..66dd05b3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptListParamsTest { +internal class PromptListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt index beaa5bd4..05a4e211 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptOptionsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptOptionsTest { +internal class PromptOptionsTest { @Test fun createPromptOptions() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index b25b4263..a3b083cf 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptReplaceParamsTest { +internal class PromptReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt index 622fb8c9..a5915832 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptRetrieveParamsTest { +internal class PromptRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index fed67a6f..15360d72 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptTest { +internal class PromptTest { @Test fun createPrompt() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index 00490393..70bfe5a7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class PromptUpdateParamsTest { +internal class PromptUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt index 83eec5e0..402272fd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RepoInfoTest { +internal class RepoInfoTest { @Test fun createRepoInfo() { 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 0f51ab11..9310f639 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RoleCreateParamsTest { +internal class RoleCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt index 3d7f97a5..6552fe89 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RoleDeleteParamsTest { +internal class RoleDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 9a390aec..6908d93f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RoleListParamsTest { +internal class RoleListParamsTest { @Test fun create() { 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 bb1f5ff7..d278709c 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RoleReplaceParamsTest { +internal class RoleReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt index 696fe39a..72b41378 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RoleRetrieveParamsTest { +internal class RoleRetrieveParamsTest { @Test fun create() { 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 d26022f4..c3adf0e4 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 @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RoleTest { +internal class RoleTest { @Test fun createRole() { 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 5fb7036c..5108aba7 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class RoleUpdateParamsTest { +internal class RoleUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt index 35c169e5..e37b5561 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ScoreSummaryTest { +internal class ScoreSummaryTest { @Test fun createScoreSummary() { 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 9a2631a4..c8368446 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 @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SpanAttributesTest { +internal class SpanAttributesTest { @Test fun createSpanAttributes() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt index a972b937..13eb4eef 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIFrameTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SpanIFrameTest { +internal class SpanIFrameTest { @Test fun createSpanIFrame() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt index baf7a58f..16fcf240 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeCreateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SpanIframeCreateParamsTest { +internal class SpanIframeCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt index a1a4a437..a2f0c37f 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SpanIframeDeleteParamsTest { +internal class SpanIframeDeleteParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt index 50d720b8..da762a78 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SpanIframeListParamsTest { +internal class SpanIframeListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt index 305c97ad..f641330c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SpanIframeReplaceParamsTest { +internal class SpanIframeReplaceParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt index ad6927a4..adab9365 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SpanIframeRetrieveParamsTest { +internal class SpanIframeRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt index b6f5b3b9..fd52b975 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParamsTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SpanIframeUpdateParamsTest { +internal class SpanIframeUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt index a9675505..78017764 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SummarizeDatasetResponseTest { +internal class SummarizeDatasetResponseTest { @Test fun createSummarizeDatasetResponse() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt index 35580e00..2b332170 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SummarizeExperimentResponseTest { +internal class SummarizeExperimentResponseTest { @Test fun createSummarizeExperimentResponse() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt index 56273dcf..fa29626f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt @@ -4,7 +4,7 @@ package com.braintrustdata.api.models import org.junit.jupiter.api.Test -class TopLevelHelloWorldParamsTest { +internal class TopLevelHelloWorldParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 02f28453..6600197f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class UserListParamsTest { +internal class UserListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt index f1686cc4..6c4f828f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt @@ -5,7 +5,7 @@ package com.braintrustdata.api.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class UserRetrieveParamsTest { +internal class UserRetrieveParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt index fe6f4802..56a1074a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt @@ -6,7 +6,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class UserTest { +internal class UserTest { @Test fun createUser() { 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 3d041001..c237c2ce 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 @@ -8,7 +8,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewCreateParamsTest { +internal class ViewCreateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt index 7d1baa55..bd1ce88f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewDataSearchTest { +internal class ViewDataSearchTest { @Test fun createViewDataSearch() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt index 10157eee..b1dabd9e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewDataTest { +internal class ViewDataTest { @Test fun createViewData() { 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 e13cbc01..6d6c784c 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 @@ -6,7 +6,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewDeleteParamsTest { +internal class ViewDeleteParamsTest { @Test fun create() { 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 821a120b..96d39d8a 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 @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewListParamsTest { +internal class ViewListParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt index a4691564..1c0aceec 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewOptionsTest { +internal class ViewOptionsTest { @Test fun createViewOptions() { 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 47686395..6dd1cd82 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 @@ -8,7 +8,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewReplaceParamsTest { +internal class ViewReplaceParamsTest { @Test fun create() { 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 61d70c16..17c8a2dd 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 @@ -6,7 +6,7 @@ import com.braintrustdata.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewRetrieveParamsTest { +internal class ViewRetrieveParamsTest { @Test fun create() { 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 a9d8e232..e8ba2a61 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 @@ -7,7 +7,7 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewTest { +internal class ViewTest { @Test fun createView() { 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 fb4c4f8f..36044079 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 @@ -7,7 +7,7 @@ import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ViewUpdateParamsTest { +internal class ViewUpdateParamsTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 1d611bfb..2716a7ab 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @WireMockTest -class ErrorHandlingTest { +internal class ErrorHandlingTest { companion object { 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 3f295376..97eca503 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 @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class AclServiceAsyncTest { +internal class AclServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt index cc5d3c0a..f9dd58e3 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/AiSecretServiceAsyncTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class AiSecretServiceAsyncTest { +internal class AiSecretServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt index f7d5a9ac..71d9172a 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ApiKeyServiceAsyncTest { +internal class ApiKeyServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt index a0c5552c..dba276c4 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncTest.kt @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class DatasetServiceAsyncTest { +internal class DatasetServiceAsyncTest { @Test fun create() { 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 cceef9ea..9d95d5e8 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 @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class EnvVarServiceAsyncTest { +internal class EnvVarServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt index a8d438bf..965be9d0 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/EvalServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class EvalServiceAsyncTest { +internal class EvalServiceAsyncTest { @Test fun create() { 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 7703f1fc..854ef1dd 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 @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ExperimentServiceAsyncTest { +internal class ExperimentServiceAsyncTest { @Test fun create() { 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 ea23ac2d..8e65f276 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 @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class FunctionServiceAsyncTest { +internal class FunctionServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt index 314e7023..5b8f2e23 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class GroupServiceAsyncTest { +internal class GroupServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt index b89247bd..17e8d406 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class OrganizationServiceAsyncTest { +internal class OrganizationServiceAsyncTest { @Test fun retrieve() { 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 05701364..cf9b25d3 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 @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ProjectScoreServiceAsyncTest { +internal class ProjectScoreServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt index 1d4af2db..79ae13f8 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ProjectServiceAsyncTest { +internal class ProjectServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt index 8105ac95..8f4ee746 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ProjectTagServiceAsyncTest { +internal class ProjectTagServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt index e44cb335..2216c197 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class PromptServiceAsyncTest { +internal class PromptServiceAsyncTest { @Test fun create() { 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 79732937..45d60fc2 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 @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class RoleServiceAsyncTest { +internal class RoleServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt index e10665eb..7f3f4d1c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/SpanIframeServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class SpanIframeServiceAsyncTest { +internal class SpanIframeServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt index dee09b2e..08b3dbdf 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class TopLevelServiceAsyncTest { +internal class TopLevelServiceAsyncTest { @Test fun helloWorld() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt index 38f452e7..39fa2e1c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class UserServiceAsyncTest { +internal class UserServiceAsyncTest { @Test fun retrieve() { 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 c45c5a58..829ac4ec 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 @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ViewServiceAsyncTest { +internal class ViewServiceAsyncTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt index 12efbd59..aad7f865 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class MemberServiceAsyncTest { +internal class MemberServiceAsyncTest { @Test fun update() { 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 a78f59db..035fda7e 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 @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class LogServiceAsyncTest { +internal class LogServiceAsyncTest { @Test fun feedback() { 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 c0c9530f..f50e01c6 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 @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class AclServiceTest { +internal class AclServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt index 6da192a1..6d9e6bd1 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AiSecretServiceTest.kt @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class AiSecretServiceTest { +internal class AiSecretServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt index 46eefb44..953d839e 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ApiKeyServiceTest { +internal class ApiKeyServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index d1b98d7b..3f79928e 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class DatasetServiceTest { +internal class DatasetServiceTest { @Test fun create() { 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 8a70237d..77382bfc 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 @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class EnvVarServiceTest { +internal class EnvVarServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt index e363273c..2409d221 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/EvalServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class EvalServiceTest { +internal class EvalServiceTest { @Test fun create() { 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 19639ab4..1f41453e 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 @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ExperimentServiceTest { +internal class ExperimentServiceTest { @Test fun create() { 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 0dee1b40..1398db02 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 @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class FunctionServiceTest { +internal class FunctionServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index 5bb132ad..ef587787 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class GroupServiceTest { +internal class GroupServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt index 97c88d5c..35ab34c7 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class OrganizationServiceTest { +internal class OrganizationServiceTest { @Test fun retrieve() { 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 fef6caa5..e09d814c 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 @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ProjectScoreServiceTest { +internal class ProjectScoreServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 51fa7715..8e31fe94 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ProjectServiceTest { +internal class ProjectServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt index 503f9390..709ed83a 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ProjectTagServiceTest { +internal class ProjectTagServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index 4d3cd8e9..e972b345 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class PromptServiceTest { +internal class PromptServiceTest { @Test fun create() { 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 b402e232..219fd06e 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 @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class RoleServiceTest { +internal class RoleServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt index a7d4d465..c17eec2b 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/SpanIframeServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class SpanIframeServiceTest { +internal class SpanIframeServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt index a1e4f554..de7c1385 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class TopLevelServiceTest { +internal class TopLevelServiceTest { @Test fun helloWorld() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index bdf88104..70032d95 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class UserServiceTest { +internal class UserServiceTest { @Test fun retrieve() { 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 401da3f7..4019925d 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 @@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ViewServiceTest { +internal class ViewServiceTest { @Test fun create() { diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt index d23dacb9..cf30ad12 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class MemberServiceTest { +internal class MemberServiceTest { @Test fun update() { 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 01b768a6..d0ccaad0 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 @@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class LogServiceTest { +internal class LogServiceTest { @Test fun feedback() { From 28a35683de525b8de0ca345bb246ed537104788d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 00:09:10 +0000 Subject: [PATCH 84/87] chore(internal): add generated comment (#154) --- .../main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt index 215eea16..03c719df 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/http/QueryParams.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package com.braintrustdata.api.core.http import com.braintrustdata.api.core.toImmutable From 6b504cbb091ddbfff7b2487dd143cab9e3d4da01 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 00:12:51 +0000 Subject: [PATCH 85/87] docs: add `build` method comments (#155) --- .../client/okhttp/BraintrustOkHttpClient.kt | 5 + .../okhttp/BraintrustOkHttpClientAsync.kt | 5 + .../braintrustdata/api/core/ClientOptions.kt | 12 + .../com/braintrustdata/api/core/Timeout.kt | 5 + .../api/errors/BraintrustError.kt | 5 + .../com/braintrustdata/api/models/AISecret.kt | 19 ++ .../com/braintrustdata/api/models/Acl.kt | 15 + .../api/models/AclBatchUpdateParams.kt | 36 +++ .../api/models/AclBatchUpdateResponse.kt | 13 + .../api/models/AclCreateParams.kt | 26 ++ .../api/models/AclDeleteParams.kt | 12 + .../api/models/AclFindAndDeleteParams.kt | 26 ++ .../braintrustdata/api/models/AclListPage.kt | 7 +- .../api/models/AclListPageAsync.kt | 7 +- .../api/models/AclListParams.kt | 13 + .../api/models/AclRetrieveParams.kt | 12 + .../api/models/AiSecretCreateParams.kt | 29 ++ .../api/models/AiSecretDeleteParams.kt | 12 + .../api/models/AiSecretFindAndDeleteParams.kt | 24 ++ .../api/models/AiSecretListPage.kt | 7 +- .../api/models/AiSecretListPageAsync.kt | 7 +- .../api/models/AiSecretListParams.kt | 5 + .../api/models/AiSecretReplaceParams.kt | 29 ++ .../api/models/AiSecretRetrieveParams.kt | 12 + .../api/models/AiSecretUpdateParams.kt | 22 ++ .../com/braintrustdata/api/models/ApiKey.kt | 14 + .../api/models/ApiKeyCreateParams.kt | 24 ++ .../api/models/ApiKeyDeleteParams.kt | 12 + .../api/models/ApiKeyListPage.kt | 7 +- .../api/models/ApiKeyListPageAsync.kt | 7 +- .../api/models/ApiKeyListParams.kt | 5 + .../api/models/ApiKeyRetrieveParams.kt | 12 + .../models/ChatCompletionContentPartImage.kt | 25 ++ .../models/ChatCompletionContentPartText.kt | 12 + .../models/ChatCompletionMessageToolCall.kt | 27 ++ .../braintrustdata/api/models/CodeBundle.kt | 79 +++++ .../api/models/CreateApiKeyOutput.kt | 15 + .../api/models/CrossObjectInsertResponse.kt | 20 ++ .../braintrustdata/api/models/DataSummary.kt | 12 + .../com/braintrustdata/api/models/Dataset.kt | 19 ++ .../api/models/DatasetCreateParams.kt | 31 ++ .../api/models/DatasetDeleteParams.kt | 12 + .../braintrustdata/api/models/DatasetEvent.kt | 23 ++ .../api/models/DatasetFeedbackParams.kt | 25 ++ .../api/models/DatasetFetchParams.kt | 12 + .../api/models/DatasetFetchPostParams.kt | 17 + .../api/models/DatasetInsertParams.kt | 25 ++ .../api/models/DatasetListPage.kt | 7 +- .../api/models/DatasetListPageAsync.kt | 7 +- .../api/models/DatasetListParams.kt | 5 + .../api/models/DatasetRetrieveParams.kt | 12 + .../api/models/DatasetSummarizeParams.kt | 12 + .../api/models/DatasetUpdateParams.kt | 22 ++ .../com/braintrustdata/api/models/EnvVar.kt | 15 + .../api/models/EnvVarCreateParams.kt | 28 ++ .../api/models/EnvVarDeleteParams.kt | 12 + .../api/models/EnvVarListParams.kt | 5 + .../api/models/EnvVarListResponse.kt | 12 + .../api/models/EnvVarReplaceParams.kt | 28 ++ .../api/models/EnvVarRetrieveParams.kt | 12 + .../api/models/EnvVarUpdateParams.kt | 25 ++ .../api/models/EvalCreateParams.kt | 302 ++++++++++++++++++ .../braintrustdata/api/models/Experiment.kt | 20 ++ .../api/models/ExperimentCreateParams.kt | 29 ++ .../api/models/ExperimentDeleteParams.kt | 12 + .../api/models/ExperimentEvent.kt | 38 +++ .../api/models/ExperimentFeedbackParams.kt | 25 ++ .../api/models/ExperimentFetchParams.kt | 12 + .../api/models/ExperimentFetchPostParams.kt | 17 + .../api/models/ExperimentInsertParams.kt | 25 ++ .../api/models/ExperimentListPage.kt | 7 +- .../api/models/ExperimentListPageAsync.kt | 7 +- .../api/models/ExperimentListParams.kt | 5 + .../api/models/ExperimentRetrieveParams.kt | 12 + .../api/models/ExperimentSummarizeParams.kt | 12 + .../api/models/ExperimentUpdateParams.kt | 22 ++ .../api/models/FeedbackDatasetItem.kt | 17 + .../api/models/FeedbackExperimentItem.kt | 22 ++ .../api/models/FeedbackProjectLogsItem.kt | 22 ++ .../api/models/FeedbackResponseSchema.kt | 12 + .../api/models/FetchDatasetEventsResponse.kt | 12 + .../models/FetchExperimentEventsResponse.kt | 12 + .../models/FetchProjectLogsEventsResponse.kt | 12 + .../com/braintrustdata/api/models/Function.kt | 123 +++++++ .../api/models/FunctionCreateParams.kt | 129 ++++++++ .../api/models/FunctionDeleteParams.kt | 12 + .../api/models/FunctionInvokeParams.kt | 140 ++++++++ .../api/models/FunctionInvokeResponse.kt | 5 + .../api/models/FunctionListPage.kt | 7 +- .../api/models/FunctionListPageAsync.kt | 7 +- .../api/models/FunctionListParams.kt | 5 + .../api/models/FunctionReplaceParams.kt | 129 ++++++++ .../api/models/FunctionRetrieveParams.kt | 12 + .../api/models/FunctionUpdateParams.kt | 98 ++++++ .../com/braintrustdata/api/models/Group.kt | 14 + .../api/models/GroupCreateParams.kt | 24 ++ .../api/models/GroupDeleteParams.kt | 12 + .../api/models/GroupListPage.kt | 7 +- .../api/models/GroupListPageAsync.kt | 7 +- .../api/models/GroupListParams.kt | 5 + .../api/models/GroupReplaceParams.kt | 24 ++ .../api/models/GroupRetrieveParams.kt | 12 + .../api/models/GroupUpdateParams.kt | 17 + .../api/models/InsertDatasetEvent.kt | 10 + .../api/models/InsertEventsResponse.kt | 12 + .../api/models/InsertExperimentEvent.kt | 25 ++ .../api/models/InsertProjectLogsEvent.kt | 25 ++ .../api/models/MetricSummary.kt | 16 + .../api/models/ObjectReference.kt | 15 + .../api/models/OnlineScoreConfig.kt | 39 +++ .../braintrustdata/api/models/Organization.kt | 13 + .../api/models/OrganizationDeleteParams.kt | 12 + .../api/models/OrganizationListPage.kt | 7 +- .../api/models/OrganizationListPageAsync.kt | 7 +- .../api/models/OrganizationListParams.kt | 5 + .../models/OrganizationMemberUpdateParams.kt | 20 ++ .../api/models/OrganizationRetrieveParams.kt | 12 + .../api/models/OrganizationUpdateParams.kt | 17 + .../models/PatchOrganizationMembersOutput.kt | 13 + .../com/braintrustdata/api/models/Project.kt | 14 + .../api/models/ProjectCreateParams.kt | 24 ++ .../api/models/ProjectDeleteParams.kt | 12 + .../api/models/ProjectListPage.kt | 7 +- .../api/models/ProjectListPageAsync.kt | 7 +- .../api/models/ProjectListParams.kt | 5 + .../api/models/ProjectLogFeedbackParams.kt | 25 ++ .../api/models/ProjectLogFetchParams.kt | 12 + .../api/models/ProjectLogFetchPostParams.kt | 17 + .../api/models/ProjectLogInsertParams.kt | 25 ++ .../api/models/ProjectLogsEvent.kt | 39 +++ .../api/models/ProjectRetrieveParams.kt | 12 + .../braintrustdata/api/models/ProjectScore.kt | 21 ++ .../api/models/ProjectScoreCategory.kt | 13 + .../api/models/ProjectScoreConfig.kt | 5 + .../api/models/ProjectScoreCreateParams.kt | 33 ++ .../api/models/ProjectScoreDeleteParams.kt | 12 + .../api/models/ProjectScoreListPage.kt | 7 +- .../api/models/ProjectScoreListPageAsync.kt | 7 +- .../api/models/ProjectScoreListParams.kt | 5 + .../api/models/ProjectScoreReplaceParams.kt | 33 ++ .../api/models/ProjectScoreRetrieveParams.kt | 12 + .../api/models/ProjectScoreUpdateParams.kt | 22 ++ .../api/models/ProjectSettings.kt | 19 ++ .../braintrustdata/api/models/ProjectTag.kt | 15 + .../api/models/ProjectTagCreateParams.kt | 26 ++ .../api/models/ProjectTagDeleteParams.kt | 12 + .../api/models/ProjectTagListPage.kt | 7 +- .../api/models/ProjectTagListPageAsync.kt | 7 +- .../api/models/ProjectTagListParams.kt | 5 + .../api/models/ProjectTagReplaceParams.kt | 26 ++ .../api/models/ProjectTagRetrieveParams.kt | 12 + .../api/models/ProjectTagUpdateParams.kt | 17 + .../api/models/ProjectUpdateParams.kt | 17 + .../com/braintrustdata/api/models/Prompt.kt | 23 ++ .../api/models/PromptCreateParams.kt | 28 ++ .../braintrustdata/api/models/PromptData.kt | 168 ++++++++++ .../api/models/PromptDeleteParams.kt | 12 + .../api/models/PromptListPage.kt | 7 +- .../api/models/PromptListPageAsync.kt | 7 +- .../api/models/PromptListParams.kt | 5 + .../api/models/PromptOptions.kt | 132 ++++++++ .../api/models/PromptReplaceParams.kt | 28 ++ .../api/models/PromptRetrieveParams.kt | 12 + .../api/models/PromptUpdateParams.kt | 17 + .../com/braintrustdata/api/models/RepoInfo.kt | 5 + .../com/braintrustdata/api/models/Role.kt | 25 ++ .../api/models/RoleCreateParams.kt | 36 +++ .../api/models/RoleDeleteParams.kt | 12 + .../braintrustdata/api/models/RoleListPage.kt | 7 +- .../api/models/RoleListPageAsync.kt | 7 +- .../api/models/RoleListParams.kt | 5 + .../api/models/RoleReplaceParams.kt | 36 +++ .../api/models/RoleRetrieveParams.kt | 12 + .../api/models/RoleUpdateParams.kt | 41 +++ .../braintrustdata/api/models/ScoreSummary.kt | 15 + .../api/models/SpanAttributes.kt | 5 + .../braintrustdata/api/models/SpanIFrame.kt | 15 + .../api/models/SpanIframeCreateParams.kt | 28 ++ .../api/models/SpanIframeDeleteParams.kt | 12 + .../api/models/SpanIframeListPage.kt | 7 +- .../api/models/SpanIframeListPageAsync.kt | 7 +- .../api/models/SpanIframeListParams.kt | 5 + .../api/models/SpanIframeReplaceParams.kt | 28 ++ .../api/models/SpanIframeRetrieveParams.kt | 12 + .../api/models/SpanIframeUpdateParams.kt | 17 + .../api/models/SummarizeDatasetResponse.kt | 15 + .../api/models/SummarizeExperimentResponse.kt | 25 ++ .../api/models/TopLevelHelloWorldParams.kt | 5 + .../com/braintrustdata/api/models/User.kt | 12 + .../braintrustdata/api/models/UserListPage.kt | 7 +- .../api/models/UserListPageAsync.kt | 7 +- .../api/models/UserListParams.kt | 5 + .../api/models/UserRetrieveParams.kt | 12 + .../com/braintrustdata/api/models/View.kt | 16 + .../api/models/ViewCreateParams.kt | 30 ++ .../com/braintrustdata/api/models/ViewData.kt | 5 + .../api/models/ViewDataSearch.kt | 5 + .../api/models/ViewDeleteParams.kt | 27 ++ .../braintrustdata/api/models/ViewListPage.kt | 7 +- .../api/models/ViewListPageAsync.kt | 7 +- .../api/models/ViewListParams.kt | 13 + .../braintrustdata/api/models/ViewOptions.kt | 15 + .../api/models/ViewReplaceParams.kt | 30 ++ .../api/models/ViewRetrieveParams.kt | 14 + .../api/models/ViewUpdateParams.kt | 27 ++ 205 files changed, 4253 insertions(+), 32 deletions(-) diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 3bcb97dc..3800c0ed 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -151,6 +151,11 @@ class BraintrustOkHttpClient private constructor() { fun fromEnv() = apply { clientOptions.fromEnv() } + /** + * Returns an immutable instance of [BraintrustClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): BraintrustClient = BraintrustClientImpl( clientOptions diff --git a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index 008b59ad..52efdd0a 100755 --- a/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-java-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -153,6 +153,11 @@ class BraintrustOkHttpClientAsync private constructor() { fun fromEnv() = apply { clientOptions.fromEnv() } + /** + * Returns an immutable instance of [BraintrustClientAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): BraintrustClientAsync = BraintrustClientAsyncImpl( clientOptions diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 0c70ecf4..53b6d493 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -179,6 +179,18 @@ private constructor( fun fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } } + /** + * Returns an immutable instance of [ClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt index 0ca642cc..06ee42fa 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/core/Timeout.kt @@ -132,6 +132,11 @@ private constructor( /** Alias for calling [Builder.request] with `request.orElse(null)`. */ fun request(request: Optional) = request(request.getOrNull()) + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Timeout = Timeout(connect, read, write, request) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index afcc62d2..42865ed6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -60,6 +60,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [BraintrustError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): BraintrustError = BraintrustError(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt index 041565d0..1019fd7b 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AISecret.kt @@ -355,6 +355,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [AISecret]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .orgId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AISecret = AISecret( checkRequired("id", id), @@ -428,6 +442,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } 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 09ff74d7..514087dd 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 @@ -472,6 +472,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Acl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ._objectOrgId() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Acl = Acl( checkRequired("id", id), 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 2160900e..de92b67f 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 @@ -288,6 +288,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( (addAcls ?: JsonMissing.of()).map { it.toImmutable() }, @@ -520,6 +525,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AclBatchUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): AclBatchUpdateParams = AclBatchUpdateParams( body.build(), @@ -888,6 +898,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [AddAcl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AddAcl = AddAcl( checkRequired("objectId", objectId), @@ -1279,6 +1302,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RemoveAcl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RemoveAcl = RemoveAcl( checkRequired("objectId", objectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt index bb393790..ee549d63 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclBatchUpdateResponse.kt @@ -212,6 +212,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [AclBatchUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .addedAcls() + * .removedAcls() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AclBatchUpdateResponse = AclBatchUpdateResponse( checkRequired("addedAcls", addedAcls).map { it.toImmutable() }, 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 387d9a11..27d4477a 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 @@ -512,6 +512,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("objectId", objectId), @@ -804,6 +817,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AclCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AclCreateParams = AclCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index 53bbe12f..1aaf3f66 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [AclDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aclId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AclDeleteParams = AclDeleteParams( checkRequired("aclId", aclId), 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 968fe6ce..5f778de3 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 @@ -509,6 +509,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("objectId", objectId), @@ -801,6 +814,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AclFindAndDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AclFindAndDeleteParams = AclFindAndDeleteParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index f265a4be..5804bf46 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -150,7 +150,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index 9d691383..acd71877 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -152,7 +152,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } 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 c61cbd7d..bf957172 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 @@ -288,6 +288,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AclListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AclListParams = AclListParams( checkRequired("objectId", objectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index a91c07d2..a591bf37 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AclRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aclId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AclRetrieveParams = AclRetrieveParams( checkRequired("aclId", aclId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt index 9092df23..1fbb51db 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretCreateParams.kt @@ -366,6 +366,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -615,6 +627,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AiSecretCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AiSecretCreateParams = AiSecretCreateParams( body.build(), @@ -682,6 +706,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt index b62db648..2fa3533f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [AiSecretDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aiSecretId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AiSecretDeleteParams = AiSecretDeleteParams( checkRequired("aiSecretId", aiSecretId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt index 4dfef4d2..40ba1a94 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretFindAndDeleteParams.kt @@ -215,6 +215,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } @@ -413,6 +425,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AiSecretFindAndDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AiSecretFindAndDeleteParams = AiSecretFindAndDeleteParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt index 31ca38f9..af920955 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPage.kt @@ -156,7 +156,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt index 09526724..441b79ce 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListPageAsync.kt @@ -163,7 +163,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index da87f527..d05d9d2d 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -306,6 +306,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AiSecretListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): AiSecretListParams = AiSecretListParams( aiSecretName, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt index 875a99c6..9a5a51dd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretReplaceParams.kt @@ -366,6 +366,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -615,6 +627,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AiSecretReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AiSecretReplaceParams = AiSecretReplaceParams( body.build(), @@ -682,6 +706,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt index 63959bb2..7ff996d2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AiSecretRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aiSecretId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AiSecretRetrieveParams = AiSecretRetrieveParams( checkRequired("aiSecretId", aiSecretId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt index 42e63b47..751a2ce2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretUpdateParams.kt @@ -305,6 +305,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body(metadata, name, secret, type, additionalProperties.toImmutable()) } @@ -533,6 +538,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [AiSecretUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aiSecretId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AiSecretUpdateParams = AiSecretUpdateParams( checkRequired("aiSecretId", aiSecretId), @@ -601,6 +618,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 0a18e742..6cebb35a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -283,6 +283,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ApiKey]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .previewName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ApiKey = ApiKey( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt index 2b0fe95a..f00eaec8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt @@ -218,6 +218,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } @@ -416,6 +428,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ApiKeyCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ApiKeyCreateParams = ApiKeyCreateParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt index f0404eda..cc0903b2 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [ApiKeyDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .apiKeyId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ApiKeyDeleteParams = ApiKeyDeleteParams( checkRequired("apiKeyId", apiKeyId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt index 0b0839e1..4d1e410a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt @@ -150,7 +150,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt index 86f19e49..28dc1058 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt @@ -152,7 +152,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index 46f9e571..e5b8a26a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -287,6 +287,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ApiKeyListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ApiKeyListParams = ApiKeyListParams( apiKeyName, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt index 50963e4d..1a0b9c18 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ApiKeyRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .apiKeyId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ApiKeyRetrieveParams = ApiKeyRetrieveParams( checkRequired("apiKeyId", apiKeyId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt index 0a47e4ef..5a3d774a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartImage.kt @@ -144,6 +144,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ChatCompletionContentPartImage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .imageUrl() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ChatCompletionContentPartImage = ChatCompletionContentPartImage( checkRequired("imageUrl", imageUrl), @@ -276,6 +289,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ImageUrl]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ImageUrl = ImageUrl(checkRequired("url", url), detail, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt index 6d1a633b..4d14c0cf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionContentPartText.kt @@ -139,6 +139,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ChatCompletionContentPartText]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ChatCompletionContentPartText = ChatCompletionContentPartText( checkRequired("type", type), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt index 2add01f0..6c3fcd98 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ChatCompletionMessageToolCall.kt @@ -170,6 +170,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ChatCompletionMessageToolCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .function() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ChatCompletionMessageToolCall = ChatCompletionMessageToolCall( checkRequired("id", id), @@ -306,6 +320,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .arguments() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("arguments", arguments), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt index f113a8c9..56c5f85e 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CodeBundle.kt @@ -232,6 +232,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [CodeBundle]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): CodeBundle = CodeBundle( checkRequired("bundleId", bundleId), @@ -551,6 +565,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Experiment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .evalName() + * .position() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Experiment = Experiment( checkRequired("evalName", evalName), @@ -798,6 +826,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Type]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Type = Type(checkRequired("type", type), additionalProperties.toImmutable()) } @@ -1060,6 +1100,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Scorer]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .index() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Scorer = Scorer( checkRequired("index", index), @@ -1435,6 +1488,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .index() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("index", index), @@ -1686,6 +1752,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RuntimeContext]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RuntimeContext = RuntimeContext( checkRequired("runtime", runtime), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index b3162489..24beff8e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -314,6 +314,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [CreateApiKeyOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .key() + * .name() + * .previewName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): CreateApiKeyOutput = CreateApiKeyOutput( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index b041b845..2b7bead1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -193,6 +193,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [CrossObjectInsertResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): CrossObjectInsertResponse = CrossObjectInsertResponse( dataset, @@ -262,6 +267,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Dataset]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Dataset = Dataset(additionalProperties.toImmutable()) } @@ -342,6 +352,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Experiment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Experiment = Experiment(additionalProperties.toImmutable()) } @@ -422,6 +437,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectLogs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ProjectLogs = ProjectLogs(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index 2b0bb6d7..cdcf9fe8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -118,6 +118,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [DataSummary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .totalRecords() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DataSummary = DataSummary( checkRequired("totalRecords", totalRecords), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index f1d396e8..e0a65784 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -363,6 +363,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Dataset]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Dataset = Dataset( checkRequired("id", id), @@ -437,6 +451,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index 50a2261f..fb4cd2c4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -315,6 +315,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -544,6 +557,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetCreateParams = DatasetCreateParams( body.build(), @@ -612,6 +638,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 8f43631d..67c7b316 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [DatasetDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetDeleteParams = DatasetDeleteParams( checkRequired("datasetId", datasetId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 116cce7b..28bf576a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -531,6 +531,24 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [DatasetEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .created() + * .datasetId() + * .projectId() + * .rootSpanId() + * .spanId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetEvent = DatasetEvent( checkRequired("id", id), @@ -652,6 +670,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index efa54e3d..bb641fb0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -182,6 +182,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedback() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("feedback", feedback).map { it.toImmutable() }, @@ -381,6 +393,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetFeedbackParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .feedback() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetFeedbackParams = DatasetFeedbackParams( checkRequired("datasetId", datasetId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 36fa92fa..30277ee0 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -317,6 +317,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetFetchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetFetchParams = DatasetFetchParams( checkRequired("datasetId", datasetId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index dda145f4..b829eb13 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -507,6 +507,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( cursor, @@ -817,6 +822,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetFetchPostParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetFetchPostParams = DatasetFetchPostParams( checkRequired("datasetId", datasetId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 55c6c8ec..8ed1370b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -182,6 +182,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("events", events).map { it.toImmutable() }, @@ -378,6 +390,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetInsertParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetInsertParams = DatasetInsertParams( checkRequired("datasetId", datasetId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index ae489e32..51260d7d 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -156,7 +156,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index edf89d75..7e0a0e47 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -161,7 +161,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index b7818b13..e9216491 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -313,6 +313,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): DatasetListParams = DatasetListParams( datasetName, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index a75b190a..ef2657ae 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetRetrieveParams = DatasetRetrieveParams( checkRequired("datasetId", datasetId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 8a27ca2d..84dedcec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -195,6 +195,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetSummarizeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetSummarizeParams = DatasetSummarizeParams( checkRequired("datasetId", datasetId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index eb2b4cf2..038dc497 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -274,6 +274,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body(description, metadata, name, additionalProperties.toImmutable()) } @@ -492,6 +497,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [DatasetUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetUpdateParams = DatasetUpdateParams( checkRequired("datasetId", datasetId), @@ -561,6 +578,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt index 668c0861..739d7149 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVar.kt @@ -288,6 +288,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [EnvVar]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): EnvVar = EnvVar( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt index 201e9993..ba236659 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarCreateParams.kt @@ -313,6 +313,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -538,6 +552,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [EnvVarCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): EnvVarCreateParams = EnvVarCreateParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt index d9d09741..8675b2e0 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [EnvVarDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .envVarId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): EnvVarDeleteParams = EnvVarDeleteParams( checkRequired("envVarId", envVarId), 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 1afc6fa8..cae2986b 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 @@ -249,6 +249,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [EnvVarListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): EnvVarListParams = EnvVarListParams( envVarName, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt index 52b019c9..dc10c986 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarListResponse.kt @@ -130,6 +130,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [EnvVarListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objects() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): EnvVarListResponse = EnvVarListResponse( checkRequired("objects", objects).map { it.toImmutable() }, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt index 20e9ac8c..4c9da803 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarReplaceParams.kt @@ -313,6 +313,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -538,6 +552,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [EnvVarReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): EnvVarReplaceParams = EnvVarReplaceParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt index 0e424916..588b7b7c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [EnvVarRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .envVarId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): EnvVarRetrieveParams = EnvVarRetrieveParams( checkRequired("envVarId", envVarId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt index e5e94255..58ba35d3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EnvVarUpdateParams.kt @@ -222,6 +222,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body(checkRequired("name", name), value, additionalProperties.toImmutable()) } @@ -422,6 +434,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [EnvVarUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .envVarId() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): EnvVarUpdateParams = EnvVarUpdateParams( checkRequired("envVarId", envVarId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt index abc2abdf..96d00635 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/EvalCreateParams.kt @@ -1122,6 +1122,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .projectId() + * .scores() + * .task() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("data", data), @@ -1668,6 +1683,21 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [EvalCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .projectId() + * .scores() + * .task() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): EvalCreateParams = EvalCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } @@ -1989,6 +2019,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [DatasetId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetId = DatasetId( checkRequired("datasetId", datasetId), @@ -2061,6 +2103,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [_InternalBtql]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): _InternalBtql = _InternalBtql(additionalProperties.toImmutable()) } @@ -2284,6 +2331,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectDatasetName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetName() + * .projectName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectDatasetName = ProjectDatasetName( checkRequired("datasetName", datasetName), @@ -2357,6 +2417,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [_InternalBtql]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): _InternalBtql = _InternalBtql(additionalProperties.toImmutable()) } @@ -2511,6 +2576,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [DatasetRows]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): DatasetRows = DatasetRows( checkRequired("data", data).map { it.toImmutable() }, @@ -2931,6 +3008,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FunctionId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionId = FunctionId( checkRequired("functionId", functionId), @@ -3134,6 +3223,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectSlug]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectName() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectSlug = ProjectSlug( checkRequired("projectName", projectName), @@ -3275,6 +3377,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [GlobalFunction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .globalFunction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): GlobalFunction = GlobalFunction( checkRequired("globalFunction", globalFunction), @@ -3485,6 +3599,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [PromptSessionId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .promptSessionFunctionId() + * .promptSessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PromptSessionId = PromptSessionId( checkRequired("promptSessionFunctionId", promptSessionFunctionId), @@ -3690,6 +3817,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InlineCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .inlineContext() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InlineCode = InlineCode( checkRequired("code", code), @@ -3835,6 +3975,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InlineContext]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InlineContext = InlineContext( checkRequired("runtime", runtime), @@ -4135,6 +4288,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InlinePrompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inlinePrompt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InlinePrompt = InlinePrompt( checkRequired("inlinePrompt", inlinePrompt), @@ -4554,6 +4719,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FunctionId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionId = FunctionId( checkRequired("functionId", functionId), @@ -4757,6 +4934,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectSlug]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectName() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectSlug = ProjectSlug( checkRequired("projectName", projectName), @@ -4898,6 +5088,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [GlobalFunction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .globalFunction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): GlobalFunction = GlobalFunction( checkRequired("globalFunction", globalFunction), @@ -5108,6 +5310,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [PromptSessionId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .promptSessionFunctionId() + * .promptSessionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PromptSessionId = PromptSessionId( checkRequired("promptSessionFunctionId", promptSessionFunctionId), @@ -5313,6 +5528,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InlineCode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .inlineContext() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InlineCode = InlineCode( checkRequired("code", code), @@ -5458,6 +5686,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InlineContext]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InlineContext = InlineContext( checkRequired("runtime", runtime), @@ -5758,6 +5999,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InlinePrompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inlinePrompt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InlinePrompt = InlinePrompt( checkRequired("inlinePrompt", inlinePrompt), @@ -5929,6 +6182,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [GitMetadataSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .collect() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): GitMetadataSettings = GitMetadataSettings( checkRequired("collect", collect), @@ -6271,6 +6536,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -6656,6 +6926,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [SpanParentStruct]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanParentStruct = SpanParentStruct( checkRequired("objectId", objectId), @@ -6842,6 +7125,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [PropagatedEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): PropagatedEvent = PropagatedEvent(additionalProperties.toImmutable()) } @@ -7044,6 +7332,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RowIds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .rootSpanId() + * .spanId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RowIds = RowIds( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 6aac3eb1..78d87c27 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -592,6 +592,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Experiment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * .public_() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Experiment = Experiment( checkRequired("id", id), @@ -672,6 +687,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index b3c21a00..bee4ab93 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -668,6 +668,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("projectId", projectId), @@ -1023,6 +1035,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentCreateParams = ExperimentCreateParams( body.build(), @@ -1091,6 +1115,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index 6239af74..78bec198 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -201,6 +201,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [ExperimentDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentDeleteParams = ExperimentDeleteParams( checkRequired("experimentId", experimentId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index 009aab07..aa0f500c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -812,6 +812,24 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ExperimentEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .created() + * .experimentId() + * .projectId() + * .rootSpanId() + * .spanId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentEvent = ExperimentEvent( checkRequired("id", id), @@ -1042,6 +1060,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Context]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Context = Context( callerFilename, @@ -1171,6 +1194,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } @@ -1543,6 +1571,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metrics]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metrics = Metrics( callerFilename, @@ -1643,6 +1676,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Scores]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Scores = Scores(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 1d338421..2558dfff 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -182,6 +182,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedback() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("feedback", feedback).map { it.toImmutable() }, @@ -381,6 +393,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentFeedbackParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentId() + * .feedback() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( checkRequired("experimentId", experimentId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 0edbea15..777128ee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -317,6 +317,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentFetchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentFetchParams = ExperimentFetchParams( checkRequired("experimentId", experimentId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index 42a6bf11..180f8e6a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -507,6 +507,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( cursor, @@ -817,6 +822,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentFetchPostParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentFetchPostParams = ExperimentFetchPostParams( checkRequired("experimentId", experimentId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index 52aad5c8..16a00bbe 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -182,6 +182,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("events", events).map { it.toImmutable() }, @@ -378,6 +390,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentInsertParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentId() + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentInsertParams = ExperimentInsertParams( checkRequired("experimentId", experimentId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 246697bc..3c803f0b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -160,7 +160,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index a47c0c97..cfdcebc5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -164,7 +164,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 71db2f5c..39694dc8 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -314,6 +314,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ExperimentListParams = ExperimentListParams( endingBefore, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 042891d4..54ba50ec 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( checkRequired("experimentId", experimentId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index d6df3b64..b67078a3 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -231,6 +231,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentSummarizeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( checkRequired("experimentId", experimentId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 2b2b32af..74a29345 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -558,6 +558,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( baseExpId, @@ -878,6 +883,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ExperimentUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ExperimentUpdateParams = ExperimentUpdateParams( checkRequired("experimentId", experimentId), @@ -947,6 +964,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index 95b2eb66..363314e1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -279,6 +279,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FeedbackDatasetItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FeedbackDatasetItem = FeedbackDatasetItem( checkRequired("id", id), @@ -354,6 +366,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index f0c2949a..406a2fd1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -333,6 +333,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FeedbackExperimentItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FeedbackExperimentItem = FeedbackExperimentItem( checkRequired("id", id), @@ -410,6 +422,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -493,6 +510,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Scores]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Scores = Scores(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index 5bc5746b..3741b996 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -333,6 +333,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FeedbackProjectLogsItem]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FeedbackProjectLogsItem = FeedbackProjectLogsItem( checkRequired("id", id), @@ -410,6 +422,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -493,6 +510,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Scores]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Scores = Scores(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index c87c941a..8bbcb0f7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -112,6 +112,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FeedbackResponseSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FeedbackResponseSchema = FeedbackResponseSchema( checkRequired("status", status), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index 4d0220c2..627d9ef7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -175,6 +175,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FetchDatasetEventsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FetchDatasetEventsResponse = FetchDatasetEventsResponse( checkRequired("events", events).map { it.toImmutable() }, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index 6bbddad4..585ff788 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -176,6 +176,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FetchExperimentEventsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FetchExperimentEventsResponse = FetchExperimentEventsResponse( checkRequired("events", events).map { it.toImmutable() }, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index ac15fc3d..81de5770 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -179,6 +179,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FetchProjectLogsEventsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse( checkRequired("events", events).map { it.toImmutable() }, 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 64717439..9811c9a5 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 @@ -678,6 +678,25 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .functionData() + * .logId() + * .name() + * .orgId() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("id", id), @@ -958,6 +977,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Prompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Prompt = Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } @@ -1215,6 +1246,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Code]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Code = Code( checkRequired("data", data), @@ -1639,6 +1683,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Bundle]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Bundle = Bundle( checkRequired("bundleId", bundleId), @@ -1943,6 +2002,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Inline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .runtimeContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Inline = Inline( checkRequired("code", code), @@ -2098,6 +2171,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RuntimeContext]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RuntimeContext = RuntimeContext( checkRequired("runtime", runtime), @@ -2603,6 +2690,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Global]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Global = Global( checkRequired("name", name), @@ -2898,6 +2998,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FunctionSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): FunctionSchema = FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } @@ -3095,6 +3200,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -3299,6 +3409,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Origin]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Origin = Origin( checkRequired("objectId", objectId), 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 9e9a4bdf..f902f77a 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 @@ -664,6 +664,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionData() + * .name() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("functionData", functionData), @@ -1006,6 +1021,21 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [FunctionCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionData() + * .name() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionCreateParams = FunctionCreateParams( body.build(), @@ -1272,6 +1302,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Prompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Prompt = Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } @@ -1529,6 +1571,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Code]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Code = Code( checkRequired("data", data), @@ -1953,6 +2008,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Bundle]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Bundle = Bundle( checkRequired("bundleId", bundleId), @@ -2257,6 +2327,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Inline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .runtimeContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Inline = Inline( checkRequired("code", code), @@ -2412,6 +2496,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RuntimeContext]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RuntimeContext = RuntimeContext( checkRequired("runtime", runtime), @@ -2917,6 +3015,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Global]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Global = Global( checkRequired("name", name), @@ -3117,6 +3228,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FunctionSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): FunctionSchema = FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } @@ -3438,6 +3554,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Origin]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Origin = Origin( checkRequired("objectId", objectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index f2070a12..28d9eacc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [FunctionDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionDeleteParams = FunctionDeleteParams( checkRequired("functionId", functionId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt index b9d63939..407d29b9 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeParams.kt @@ -501,6 +501,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( expected, @@ -811,6 +816,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [FunctionInvokeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionInvokeParams = FunctionInvokeParams( checkRequired("functionId", functionId), @@ -1203,6 +1220,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [System]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): System = System( checkRequired("role", role), @@ -1494,6 +1523,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [User]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): User = User( checkRequired("role", role), @@ -2174,6 +2215,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Assistant]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Assistant = Assistant( checkRequired("role", role), @@ -2420,6 +2473,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FunctionCall]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .arguments() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionCall = FunctionCall( checkRequired("arguments", arguments), @@ -2630,6 +2696,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Tool]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Tool = Tool( checkRequired("role", role), @@ -2916,6 +2994,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("name", name), @@ -3173,6 +3264,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Fallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Fallback = Fallback( checkRequired("role", role), @@ -3357,6 +3460,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } @@ -3843,6 +3951,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [SpanParentStruct]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanParentStruct = SpanParentStruct( checkRequired("objectId", objectId), @@ -4029,6 +4150,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [PropagatedEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): PropagatedEvent = PropagatedEvent(additionalProperties.toImmutable()) } @@ -4231,6 +4357,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RowIds]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .rootSpanId() + * .spanId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RowIds = RowIds( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt index 3320310c..d7035b68 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionInvokeResponse.kt @@ -70,6 +70,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FunctionInvokeResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): FunctionInvokeResponse = FunctionInvokeResponse(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 1ed3037c..4f51a5ad 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -156,7 +156,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index 4b4eebea..5979e5bf 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -163,7 +163,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 454c33dd..6883357c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -349,6 +349,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [FunctionListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): FunctionListParams = FunctionListParams( endingBefore, 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 0903fccd..78279e3e 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 @@ -664,6 +664,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionData() + * .name() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("functionData", functionData), @@ -1006,6 +1021,21 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [FunctionReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionData() + * .name() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionReplaceParams = FunctionReplaceParams( body.build(), @@ -1272,6 +1302,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Prompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Prompt = Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } @@ -1529,6 +1571,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Code]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Code = Code( checkRequired("data", data), @@ -1953,6 +2008,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Bundle]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Bundle = Bundle( checkRequired("bundleId", bundleId), @@ -2257,6 +2327,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Inline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .runtimeContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Inline = Inline( checkRequired("code", code), @@ -2412,6 +2496,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RuntimeContext]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RuntimeContext = RuntimeContext( checkRequired("runtime", runtime), @@ -2917,6 +3015,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Global]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Global = Global( checkRequired("name", name), @@ -3117,6 +3228,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FunctionSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): FunctionSchema = FunctionSchema(parameters, returns, additionalProperties.toImmutable()) } @@ -3438,6 +3554,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Origin]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Origin = Origin( checkRequired("objectId", objectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index a1ec37a0..e76a50f4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [FunctionRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionRetrieveParams = FunctionRetrieveParams( checkRequired("functionId", functionId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 11a615a1..be7afe1f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -420,6 +420,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( description, @@ -693,6 +698,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [FunctionUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .functionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionUpdateParams = FunctionUpdateParams( checkRequired("functionId", functionId), @@ -960,6 +977,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Prompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Prompt = Prompt(checkRequired("type", type), additionalProperties.toImmutable()) } @@ -1217,6 +1246,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Code]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Code = Code( checkRequired("data", data), @@ -1641,6 +1683,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Bundle]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bundleId() + * .location() + * .runtimeContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Bundle = Bundle( checkRequired("bundleId", bundleId), @@ -1945,6 +2002,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Inline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .runtimeContext() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Inline = Inline( checkRequired("code", code), @@ -2100,6 +2171,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RuntimeContext]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .runtime() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RuntimeContext = RuntimeContext( checkRequired("runtime", runtime), @@ -2605,6 +2690,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Global]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Global = Global( checkRequired("name", name), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 02e1c660..4ab379e6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -452,6 +452,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Group]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .orgId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Group = Group( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 3494b349..cda2eae4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -427,6 +427,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -701,6 +713,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [GroupCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): GroupCreateParams = GroupCreateParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index 52f95360..07473a4f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [GroupDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): GroupDeleteParams = GroupDeleteParams( checkRequired("groupId", groupId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index b0123cdf..33debe68 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -150,7 +150,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index 5a17d75a..7b8849b1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -152,7 +152,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index 810d7b33..f2d91464 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -287,6 +287,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [GroupListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): GroupListParams = GroupListParams( endingBefore, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 9a52d7dc..b11f2119 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -427,6 +427,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -701,6 +713,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [GroupReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): GroupReplaceParams = GroupReplaceParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index a3aece35..1105cf21 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [GroupRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): GroupRetrieveParams = GroupRetrieveParams( checkRequired("groupId", groupId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 55465b89..8009fc68 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -515,6 +515,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( (addMemberGroups ?: JsonMissing.of()).map { it.toImmutable() }, @@ -842,6 +847,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [GroupUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .groupId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): GroupUpdateParams = GroupUpdateParams( checkRequired("groupId", groupId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt index a85c0c55..abeb2f43 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt @@ -780,6 +780,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InsertDatasetEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): InsertDatasetEvent = InsertDatasetEvent( id, @@ -902,6 +907,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index a2436a67..8d756030 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -133,6 +133,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InsertEventsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .rowIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InsertEventsResponse = InsertEventsResponse( checkRequired("rowIds", rowIds).map { it.toImmutable() }, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt index 13aa14a8..946c2f68 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt @@ -1000,6 +1000,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InsertExperimentEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): InsertExperimentEvent = InsertExperimentEvent( id, @@ -1230,6 +1235,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Context]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Context = Context( callerFilename, @@ -1359,6 +1369,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } @@ -1731,6 +1746,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metrics]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metrics = Metrics( callerFilename, @@ -1831,6 +1851,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Scores]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Scores = Scores(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt index cd8dd98c..af3e8ffb 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt @@ -992,6 +992,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InsertProjectLogsEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): InsertProjectLogsEvent = InsertProjectLogsEvent( id, @@ -1222,6 +1227,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Context]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Context = Context( callerFilename, @@ -1351,6 +1361,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } @@ -1723,6 +1738,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metrics]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metrics = Metrics( callerFilename, @@ -1823,6 +1843,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Scores]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Scores = Scores(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index f9183713..a6233247 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -278,6 +278,22 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [MetricSummary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .improvements() + * .metric() + * .name() + * .regressions() + * .unit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): MetricSummary = MetricSummary( checkRequired("improvements", improvements), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt index 20aaf4ed..381f219f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ObjectReference.kt @@ -253,6 +253,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ObjectReference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ObjectReference = ObjectReference( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt index 41ee565c..22191392 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OnlineScoreConfig.kt @@ -293,6 +293,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [OnlineScoreConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .samplingRate() + * .scorers() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): OnlineScoreConfig = OnlineScoreConfig( checkRequired("samplingRate", samplingRate), @@ -568,6 +581,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("id", id), @@ -823,6 +849,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Global]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Global = Global( checkRequired("name", name), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index fc1fc26e..532da10b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -329,6 +329,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Organization]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Organization = Organization( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index ba3170a9..a6d936fa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -201,6 +201,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [OrganizationDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .organizationId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): OrganizationDeleteParams = OrganizationDeleteParams( checkRequired("organizationId", organizationId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index 8bff63be..6683eed2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -160,7 +160,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index cdc6536a..0c6503ba 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -165,7 +165,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index fae0f2e8..7e469d20 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -274,6 +274,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [OrganizationListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OrganizationListParams = OrganizationListParams( endingBefore, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 350ff674..11ffafd2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -337,6 +337,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body(inviteUsers, orgId, orgName, removeUsers, additionalProperties.toImmutable()) } @@ -574,6 +579,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [OrganizationMemberUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OrganizationMemberUpdateParams = OrganizationMemberUpdateParams( body.build(), @@ -971,6 +981,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InviteUsers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): InviteUsers = InviteUsers( (emails ?: JsonMissing.of()).map { it.toImmutable() }, @@ -1159,6 +1174,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RemoveUsers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): RemoveUsers = RemoveUsers( (emails ?: JsonMissing.of()).map { it.toImmutable() }, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index 3d45ef35..86b3cebc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [OrganizationRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .organizationId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( checkRequired("organizationId", organizationId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 21c12848..36741dd2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -371,6 +371,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( apiUrl, @@ -630,6 +635,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [OrganizationUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .organizationId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): OrganizationUpdateParams = OrganizationUpdateParams( checkRequired("organizationId", organizationId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt index b93608b6..7a4c2743 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersOutput.kt @@ -194,6 +194,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [PatchOrganizationMembersOutput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .orgId() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PatchOrganizationMembersOutput = PatchOrganizationMembersOutput( checkRequired("orgId", orgId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 4c402f51..3d0007dd 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -321,6 +321,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Project]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .orgId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Project = Project( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 7a08ff1b..25f67ec7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -218,6 +218,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body(checkRequired("name", name), orgName, additionalProperties.toImmutable()) } @@ -416,6 +428,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectCreateParams = ProjectCreateParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index 969df0a9..d5ac8442 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [ProjectDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectDeleteParams = ProjectDeleteParams( checkRequired("projectId", projectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index d970247c..1d934cf4 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -156,7 +156,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 2ef21803..f206043f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -161,7 +161,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index e28ba4aa..dd3d4d9b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -287,6 +287,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ProjectListParams = ProjectListParams( endingBefore, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 2ca20280..13ea4533 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -182,6 +182,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .feedback() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("feedback", feedback).map { it.toImmutable() }, @@ -381,6 +393,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectLogFeedbackParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * .feedback() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( checkRequired("projectId", projectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 5d240328..f9a83228 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -317,6 +317,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectLogFetchParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectLogFetchParams = ProjectLogFetchParams( checkRequired("projectId", projectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index bb400c64..6b1ffba5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -507,6 +507,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( cursor, @@ -817,6 +822,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectLogFetchPostParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectLogFetchPostParams = ProjectLogFetchPostParams( checkRequired("projectId", projectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index 040efe5b..629a3f65 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -182,6 +182,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("events", events).map { it.toImmutable() }, @@ -378,6 +390,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectLogInsertParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * .events() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectLogInsertParams = ProjectLogInsertParams( checkRequired("projectId", projectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index c45131c8..f4371612 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -830,6 +830,25 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectLogsEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .created() + * .logId() + * .orgId() + * .projectId() + * .rootSpanId() + * .spanId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectLogsEvent = ProjectLogsEvent( checkRequired("id", id), @@ -1156,6 +1175,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Context]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Context = Context( callerFilename, @@ -1285,6 +1309,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(model, additionalProperties.toImmutable()) } @@ -1657,6 +1686,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metrics]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metrics = Metrics( callerFilename, @@ -1757,6 +1791,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Scores]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Scores = Scores(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index 6694a858..36e479aa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectRetrieveParams = ProjectRetrieveParams( checkRequired("projectId", projectId), 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 83e93aa0..023cbd6f 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 @@ -447,6 +447,22 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectScore]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * .scoreType() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectScore = ProjectScore( checkRequired("id", id), @@ -697,6 +713,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Weighted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index 6536e6c0..b4504114 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -144,6 +144,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectScoreCategory]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectScoreCategory = ProjectScoreCategory( checkRequired("name", name), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt index 7351c2fb..4ec3a301 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreConfig.kt @@ -186,6 +186,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectScoreConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ProjectScoreConfig = ProjectScoreConfig(destination, multiSelect, online, additionalProperties.toImmutable()) } 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 606810a8..6b60c606 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 @@ -445,6 +445,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .scoreType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -714,6 +728,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectScoreCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .scoreType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectScoreCreateParams = ProjectScoreCreateParams( body.build(), @@ -956,6 +984,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Weighted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 291b304d..8e26501a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -201,6 +201,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [ProjectScoreDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectScoreId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( checkRequired("projectScoreId", projectScoreId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index f0864a38..904e8477 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -160,7 +160,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index f3328758..0f5c5540 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -165,7 +165,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } 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 29356a33..4e16fae1 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 @@ -338,6 +338,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectScoreListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ProjectScoreListParams = ProjectScoreListParams( endingBefore, 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 88048533..439137c0 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 @@ -446,6 +446,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .scoreType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -715,6 +729,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectScoreReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .scoreType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectScoreReplaceParams = ProjectScoreReplaceParams( body.build(), @@ -957,6 +985,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Weighted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 9521a052..e2694fa2 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectScoreRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectScoreId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( checkRequired("projectScoreId", projectScoreId), 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 ad921421..f008ac19 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 @@ -407,6 +407,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( categories, @@ -672,6 +677,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectScoreUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectScoreId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectScoreUpdateParams = ProjectScoreUpdateParams( checkRequired("projectScoreId", projectScoreId), @@ -915,6 +932,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Weighted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Weighted = Weighted(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt index dec2d996..57bc8590 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectSettings.kt @@ -224,6 +224,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ProjectSettings = ProjectSettings( baselineExperimentId, @@ -426,6 +431,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [SpanFieldOrder]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .columnId() + * .objectType() + * .position() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanFieldOrder = SpanFieldOrder( checkRequired("columnId", columnId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 13fd21d3..180ffb4e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -320,6 +320,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ProjectTag]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectTag = ProjectTag( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 2535deb8..ddb134a6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -315,6 +315,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -543,6 +556,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectTagCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectTagCreateParams = ProjectTagCreateParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 1f3d8f1c..9e495e9a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -201,6 +201,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [ProjectTagDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectTagId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( checkRequired("projectTagId", projectTagId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index 3fdf0ee1..59ff4610 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -160,7 +160,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index 885b7cbe..d7ff05b7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -164,7 +164,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 7141cfde..8dd8c729 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -314,6 +314,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectTagListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ProjectTagListParams = ProjectTagListParams( endingBefore, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index 19ffe1ef..d4b0801e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -316,6 +316,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -544,6 +557,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectTagReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectTagReplaceParams = ProjectTagReplaceParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index 90bd6349..36ea7037 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectTagRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectTagId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( checkRequired("projectTagId", projectTagId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 79216682..6a457c6e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -274,6 +274,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body(color, description, name, additionalProperties.toImmutable()) } @@ -490,6 +495,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectTagUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectTagId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectTagUpdateParams = ProjectTagUpdateParams( checkRequired("projectTagId", projectTagId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index beb5ed84..3c6ecfc1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -226,6 +226,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body(name, settings, additionalProperties.toImmutable()) } @@ -431,6 +436,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ProjectUpdateParams = ProjectUpdateParams( checkRequired("projectId", projectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index a55bbce4..aa64928b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -549,6 +549,24 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Prompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ._xactId() + * .logId() + * .name() + * .orgId() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Prompt = Prompt( checkRequired("id", id), @@ -838,6 +856,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 74098627..a7e0dcef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -488,6 +488,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -771,6 +785,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [PromptCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PromptCreateParams = PromptCreateParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 3df455f9..c47b3a79 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -285,6 +285,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [PromptData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): PromptData = PromptData( options, @@ -451,6 +456,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Origin]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Origin = Origin(projectId, promptId, promptVersion, additionalProperties.toImmutable()) } @@ -634,6 +644,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Parser]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .choiceScores() + * .type() + * .useCot() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Parser = Parser( checkRequired("choiceScores", choiceScores), @@ -705,6 +729,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ChoiceScores]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ChoiceScores = ChoiceScores(additionalProperties.toImmutable()) } @@ -1102,6 +1131,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Completion]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Completion = Completion( checkRequired("content", content), @@ -1425,6 +1467,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Chat]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .messages() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Chat = Chat( checkRequired("messages", messages).map { it.toImmutable() }, @@ -1826,6 +1881,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [System]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): System = System( checkRequired("role", role), @@ -2128,6 +2195,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [User]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): User = User( checkRequired("role", role), @@ -2859,6 +2938,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Assistant]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Assistant = Assistant( checkRequired("role", role), @@ -3113,6 +3204,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [FunctionCall]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .arguments() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): FunctionCall = FunctionCall( checkRequired("arguments", arguments), @@ -3329,6 +3434,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Tool]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Tool = Tool( checkRequired("role", role), @@ -3626,6 +3743,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("name", name), @@ -3893,6 +4023,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Fallback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .role() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Fallback = Fallback( checkRequired("role", role), @@ -4405,6 +4547,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("id", id), @@ -4660,6 +4815,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Global]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Global = Global( checkRequired("name", name), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index a76243f9..548ac609 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [PromptDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .promptId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PromptDeleteParams = PromptDeleteParams( checkRequired("promptId", promptId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index a54dbe4f..54e69368 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -150,7 +150,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index 940430e6..d360b8a7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -152,7 +152,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index d9c17853..01178d8c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -349,6 +349,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [PromptListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): PromptListParams = PromptListParams( endingBefore, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt index 2b833a99..c13395bf 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptOptions.kt @@ -194,6 +194,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [PromptOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): PromptOptions = PromptOptions(model, params, position, additionalProperties.toImmutable()) } @@ -981,6 +986,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [OpenAIModelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OpenAIModelParams = OpenAIModelParams( frequencyPenalty, @@ -1347,6 +1357,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("name", name), @@ -1752,6 +1774,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [JsonObject]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): JsonObject = JsonObject( checkRequired("type", type), @@ -2018,6 +2052,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [JsonSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .jsonSchema() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): JsonSchema = JsonSchema( checkRequired("jsonSchema", jsonSchema), @@ -2255,6 +2302,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InnerJsonSchema]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InnerJsonSchema = InnerJsonSchema( checkRequired("name", name), @@ -2474,6 +2534,12 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Object]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + */ fun build(): Object = Object(additionalProperties.toImmutable()) } @@ -2735,6 +2801,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Text]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Text = Text(checkRequired("type", type), additionalProperties.toImmutable()) } @@ -3248,6 +3326,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Function]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .function() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Function = Function( checkRequired("function", function), @@ -3361,6 +3452,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InnerFunction]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InnerFunction = InnerFunction( checkRequired("name", name), @@ -3847,6 +3951,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [AnthropicModelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTokens() + * .temperature() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AnthropicModelParams = AnthropicModelParams( checkRequired("maxTokens", maxTokens), @@ -4109,6 +4226,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [GoogleModelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): GoogleModelParams = GoogleModelParams( maxOutputTokens, @@ -4302,6 +4424,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [WindowAiModelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): WindowAiModelParams = WindowAiModelParams( temperature, @@ -4427,6 +4554,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [JsCompletionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): JsCompletionParams = JsCompletionParams(useCache, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index 5ab67b6c..7521b155 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -488,6 +488,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -771,6 +785,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [PromptReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PromptReplaceParams = PromptReplaceParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index 039b2d8a..bd674855 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [PromptRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .promptId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PromptRetrieveParams = PromptRetrieveParams( checkRequired("promptId", promptId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index c4f6f117..2e6f019a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -394,6 +394,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( description, @@ -655,6 +660,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [PromptUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .promptId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): PromptUpdateParams = PromptUpdateParams( checkRequired("promptId", promptId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index 3a1bb0be..0ce351bc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -413,6 +413,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RepoInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): RepoInfo = RepoInfo( authorEmail, 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 a01c4d2e..43105f4e 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 @@ -461,6 +461,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Role]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Role = Role( checkRequired("id", id), @@ -633,6 +646,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [MemberPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .permission() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): MemberPermission = MemberPermission( checkRequired("permission", permission), 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 747af4d0..d33aa0b9 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 @@ -430,6 +430,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -708,6 +720,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RoleCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RoleCreateParams = RoleCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } @@ -869,6 +893,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [MemberPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .permission() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): MemberPermission = MemberPermission( checkRequired("permission", permission), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index 1eae7094..9136f6ee 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -200,6 +200,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [RoleDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RoleDeleteParams = RoleDeleteParams( checkRequired("roleId", roleId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index f0957758..9cae9580 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -150,7 +150,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index baef96f9..8e13282e 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -152,7 +152,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 167baa72..0b4654b6 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -287,6 +287,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RoleListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): RoleListParams = RoleListParams( endingBefore, 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 f5fa9c8c..97635d9d 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 @@ -430,6 +430,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -708,6 +720,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RoleReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RoleReplaceParams = RoleReplaceParams( body.build(), @@ -873,6 +897,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [MemberPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .permission() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): MemberPermission = MemberPermission( checkRequired("permission", permission), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index 70a23fdd..1afba4b5 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RoleRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RoleRetrieveParams = RoleRetrieveParams( checkRequired("roleId", roleId), 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 e3ab8031..da629d22 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 @@ -528,6 +528,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body( (addMemberPermissions ?: JsonMissing.of()).map { it.toImmutable() }, @@ -862,6 +867,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [RoleUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .roleId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RoleUpdateParams = RoleUpdateParams( checkRequired("roleId", roleId), @@ -1028,6 +1045,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [AddMemberPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .permission() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): AddMemberPermission = AddMemberPermission( checkRequired("permission", permission), @@ -1211,6 +1240,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [RemoveMemberPermission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .permission() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): RemoveMemberPermission = RemoveMemberPermission( checkRequired("permission", permission), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index 9c3bc79e..2d7c5189 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -245,6 +245,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ScoreSummary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .improvements() + * .name() + * .regressions() + * .score() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ScoreSummary = ScoreSummary( checkRequired("improvements", improvements), 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 56bcd6b4..68f8d827 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 @@ -143,6 +143,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [SpanAttributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): SpanAttributes = SpanAttributes(name, type, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt index f368b153..bd4d2359 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIFrame.kt @@ -408,6 +408,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [SpanIFrame]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanIFrame = SpanIFrame( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt index 1f1631e9..6883efec 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeCreateParams.kt @@ -379,6 +379,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -631,6 +645,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [SpanIframeCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanIframeCreateParams = SpanIframeCreateParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt index ca88a657..da0b2c4a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeDeleteParams.kt @@ -201,6 +201,18 @@ private constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [SpanIframeDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .spanIframeId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanIframeDeleteParams = SpanIframeDeleteParams( checkRequired("spanIframeId", spanIframeId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt index 26329957..0018bcf6 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPage.kt @@ -160,7 +160,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt index b851e390..b7d9bd94 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListPageAsync.kt @@ -164,7 +164,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index f2dd183a..bc8f76e3 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -288,6 +288,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [SpanIframeListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): SpanIframeListParams = SpanIframeListParams( endingBefore, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt index 9a65ea97..0b05cad8 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeReplaceParams.kt @@ -379,6 +379,20 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -631,6 +645,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [SpanIframeReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .projectId() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanIframeReplaceParams = SpanIframeReplaceParams( body.build(), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt index 241438c1..003e528f 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [SpanIframeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .spanIframeId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanIframeRetrieveParams = SpanIframeRetrieveParams( checkRequired("spanIframeId", spanIframeId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt index 5e3efac6..d5fa952c 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeUpdateParams.kt @@ -340,6 +340,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Body = Body(description, name, postMessage, url, additionalProperties.toImmutable()) } @@ -582,6 +587,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [SpanIframeUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .spanIframeId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SpanIframeUpdateParams = SpanIframeUpdateParams( checkRequired("spanIframeId", spanIframeId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index 1c29da9d..78210f20 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -265,6 +265,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [SummarizeDatasetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .datasetName() + * .datasetUrl() + * .projectName() + * .projectUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SummarizeDatasetResponse = SummarizeDatasetResponse( checkRequired("datasetName", datasetName), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 8c39f8c2..1c8a412a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -347,6 +347,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [SummarizeExperimentResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .experimentName() + * .experimentUrl() + * .projectName() + * .projectUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): SummarizeExperimentResponse = SummarizeExperimentResponse( checkRequired("experimentName", experimentName), @@ -420,6 +435,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Metrics]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Metrics = Metrics(additionalProperties.toImmutable()) } @@ -500,6 +520,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Scores]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): Scores = Scores(additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index a3a17747..e6ef1cd1 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -144,6 +144,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [TopLevelHelloWorldParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): TopLevelHelloWorldParams = TopLevelHelloWorldParams(additionalHeaders.build(), additionalQueryParams.build()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index a2e2f9c3..ac80f854 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -292,6 +292,18 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [User]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): User = User( checkRequired("id", id), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index c02d5269..c1feb5eb 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -150,7 +150,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 82830d2e..23c28a26 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -152,7 +152,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index d456383c..de1003a9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -349,6 +349,11 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [UserListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): UserListParams = UserListParams( email, diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index b5982ab9..4d668314 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -166,6 +166,18 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [UserRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): UserRetrieveParams = UserRetrieveParams( checkRequired("userId", userId), 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 c53b8ab5..f7439666 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 @@ -437,6 +437,22 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [View]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): View = View( checkRequired("id", id), 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 e123c1da..da386fa5 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 @@ -524,6 +524,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -814,6 +829,21 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ViewCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ViewCreateParams = ViewCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index 8ab619b7..60697d88 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -110,6 +110,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ViewData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ViewData = ViewData(search, additionalProperties.toImmutable()) } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index 3b39ddb7..35428978 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -263,6 +263,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ViewDataSearch]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ViewDataSearch = ViewDataSearch( (filter ?: JsonMissing.of()).map { it.toImmutable() }, 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 64ac535e..75878782 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 @@ -218,6 +218,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("objectId", objectId), @@ -421,6 +434,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ViewDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .viewId() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ViewDeleteParams = ViewDeleteParams( checkRequired("viewId", viewId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index fde4f5ac..cd5fd5b9 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -150,7 +150,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index 0a5f58fb..e02a4656 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -152,7 +152,12 @@ private constructor( this.additionalProperties.put(key, value) } - fun build() = Response(objects, additionalProperties.toImmutable()) + /** + * Returns an immutable instance of [Response]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Response = Response(objects, additionalProperties.toImmutable()) } } 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 db3c13bb..b72d35c8 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 @@ -314,6 +314,19 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ViewListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ViewListParams = ViewListParams( checkRequired("objectId", objectId), diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 13231bb1..bf4af30f 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -306,6 +306,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ViewOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ViewOptions = ViewOptions( (columnOrder ?: JsonMissing.of()).map { it.toImmutable() }, @@ -377,6 +382,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ColumnSizing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ColumnSizing = ColumnSizing(additionalProperties.toImmutable()) } @@ -456,6 +466,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [ColumnVisibility]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ColumnVisibility = ColumnVisibility(additionalProperties.toImmutable()) } 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 720246b3..8f84c8c9 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 @@ -524,6 +524,21 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("name", name), @@ -814,6 +829,21 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ViewReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .objectId() + * .objectType() + * .viewType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ViewReplaceParams = ViewReplaceParams( body.build(), 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 873b0815..8ff82f27 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 @@ -192,6 +192,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ViewRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .viewId() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ViewRetrieveParams = ViewRetrieveParams( checkRequired("viewId", viewId), 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 a442a37a..1d810b26 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 @@ -480,6 +480,19 @@ private constructor( keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): Body = Body( checkRequired("objectId", objectId), @@ -761,6 +774,20 @@ private constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ViewUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .viewId() + * .objectId() + * .objectType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ViewUpdateParams = ViewUpdateParams( checkRequired("viewId", viewId), From f1411950e6f4807ac2ec5f34ed12ecbc70b51fad Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 00:24:11 +0000 Subject: [PATCH 86/87] chore(internal): refactor query param serialization impl and tests (#156) --- .../api/models/AclListParams.kt | 33 ++++++--- .../api/models/AiSecretListParams.kt | 45 +++++++++---- .../api/models/ApiKeyListParams.kt | 33 ++++++--- .../api/models/DatasetFetchParams.kt | 19 +++--- .../api/models/DatasetListParams.kt | 37 ++++++---- .../api/models/DatasetSummarizeParams.kt | 13 ++-- .../api/models/EnvVarListParams.kt | 31 ++++++--- .../api/models/ExperimentFetchParams.kt | 19 +++--- .../api/models/ExperimentListParams.kt | 37 ++++++---- .../api/models/ExperimentSummarizeParams.kt | 17 +++-- .../api/models/FunctionListParams.kt | 41 +++++++----- .../api/models/GroupListParams.kt | 33 ++++++--- .../api/models/OrganizationListParams.kt | 31 ++++++--- .../api/models/ProjectListParams.kt | 33 ++++++--- .../api/models/ProjectLogFetchParams.kt | 19 +++--- .../api/models/ProjectScoreListParams.kt | 51 ++++++++++---- .../api/models/ProjectTagListParams.kt | 37 ++++++---- .../api/models/PromptListParams.kt | 41 +++++++----- .../api/models/RoleListParams.kt | 33 ++++++--- .../api/models/SpanIframeListParams.kt | 33 ++++++--- .../api/models/UserListParams.kt | 67 +++++++++++++++---- .../api/models/ViewListParams.kt | 37 ++++++---- .../api/models/ViewRetrieveParams.kt | 15 +++-- .../api/models/AclListParamsTest.kt | 39 ++++++----- .../api/models/AiSecretListParamsTest.kt | 36 +++++----- .../api/models/ApiKeyListParamsTest.kt | 31 +++++---- .../api/models/DatasetFetchParamsTest.kt | 24 ++++--- .../api/models/DatasetListParamsTest.kt | 35 +++++----- .../api/models/DatasetSummarizeParamsTest.kt | 14 ++-- .../api/models/EnvVarListParamsTest.kt | 29 ++++---- .../api/models/ExperimentFetchParamsTest.kt | 24 ++++--- .../api/models/ExperimentListParamsTest.kt | 35 +++++----- .../models/ExperimentSummarizeParamsTest.kt | 20 ++++-- .../api/models/FunctionListParamsTest.kt | 39 ++++++----- .../api/models/GroupListParamsTest.kt | 31 +++++---- .../api/models/OrganizationListParamsTest.kt | 29 ++++---- .../api/models/ProjectListParamsTest.kt | 31 +++++---- .../api/models/ProjectLogFetchParamsTest.kt | 24 ++++--- .../api/models/ProjectScoreListParamsTest.kt | 41 ++++++------ .../api/models/ProjectTagListParamsTest.kt | 35 +++++----- .../api/models/PromptListParamsTest.kt | 39 ++++++----- .../api/models/RoleListParamsTest.kt | 31 +++++---- .../api/models/SpanIframeListParamsTest.kt | 31 +++++---- .../api/models/UserListParamsTest.kt | 35 +++++----- .../api/models/ViewListParamsTest.kt | 43 +++++++----- .../api/models/ViewRetrieveParamsTest.kt | 28 +++++--- .../async/FunctionServiceAsyncTest.kt | 4 +- .../services/blocking/FunctionServiceTest.kt | 4 +- 48 files changed, 930 insertions(+), 557 deletions(-) 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 bf957172..a49c07f5 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 @@ -78,17 +78,28 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("object_id", objectId) + put("object_type", objectType.asString()) + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt index d05d9d2d..4359719a 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/AiSecretListParams.kt @@ -80,18 +80,39 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.aiSecretName?.let { queryParams.put("ai_secret_name", listOf(it.toString())) } - this.aiSecretType?.let { queryParams.put("ai_secret_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + aiSecretName?.let { put("ai_secret_name", it) } + aiSecretType?.accept( + object : AiSecretType.Visitor { + override fun visitString(string: String) { + put("ai_secret_type", string) + } + + override fun visitStrings(strings: List) { + put("ai_secret_type", strings.joinToString(",")) + } + } + ) + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt index e5b8a26a..03c6a458 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt @@ -77,17 +77,28 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.apiKeyName?.let { queryParams.put("api_key_name", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + apiKeyName?.let { put("api_key_name", it) } + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index 30277ee0..b00ce504 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -88,15 +88,16 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + maxRootSpanId?.let { put("max_root_span_id", it) } + maxXactId?.let { put("max_xact_id", it) } + version?.let { put("version", it) } + putAll(additionalQueryParams) + } + .build() fun getPathParam(index: Int): String { return when (index) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index e9216491..90416929 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -85,19 +85,30 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.datasetName?.let { queryParams.put("dataset_name", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + datasetName?.let { put("dataset_name", it) } + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + projectId?.let { put("project_id", it) } + projectName?.let { put("project_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index 84dedcec..d188b51b 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -32,12 +32,13 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.summarizeData?.let { queryParams.put("summarize_data", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + summarizeData?.let { put("summarize_data", it.toString()) } + putAll(additionalQueryParams) + } + .build() fun getPathParam(index: Int): String { return when (index) { 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 cae2986b..4977d934 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 @@ -61,16 +61,27 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.envVarName?.let { queryParams.put("env_var_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.objectId?.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType?.let { queryParams.put("object_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + envVarName?.let { put("env_var_name", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + objectId?.let { put("object_id", it) } + objectType?.let { put("object_type", it.asString()) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 777128ee..93faaa22 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -88,15 +88,16 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + maxRootSpanId?.let { put("max_root_span_id", it) } + maxXactId?.let { put("max_xact_id", it) } + version?.let { put("version", it) } + putAll(additionalQueryParams) + } + .build() fun getPathParam(index: Int): String { return when (index) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 39694dc8..6e2f5bef 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -85,19 +85,30 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.experimentName?.let { queryParams.put("experiment_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + experimentName?.let { put("experiment_name", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + projectId?.let { put("project_id", it) } + projectName?.let { put("project_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index b67078a3..10cf6fc7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -43,15 +43,14 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.comparisonExperimentId?.let { - queryParams.put("comparison_experiment_id", listOf(it.toString())) - } - this.summarizeScores?.let { queryParams.put("summarize_scores", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + comparisonExperimentId?.let { put("comparison_experiment_id", it) } + summarizeScores?.let { put("summarize_scores", it.toString()) } + putAll(additionalQueryParams) + } + .build() fun getPathParam(index: Int): String { return when (index) { diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index 6883357c..534f5284 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -98,21 +98,32 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.functionName?.let { queryParams.put("function_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.slug?.let { queryParams.put("slug", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + functionName?.let { put("function_name", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + projectId?.let { put("project_id", it) } + projectName?.let { put("project_name", it) } + slug?.let { put("slug", it) } + startingAfter?.let { put("starting_after", it) } + version?.let { put("version", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index f2d91464..94cc7e6a 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -77,17 +77,28 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.groupName?.let { queryParams.put("group_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + groupName?.let { put("group_name", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index 7e469d20..ee4d5674 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -73,16 +73,27 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index dd3d4d9b..6b30061c 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -77,17 +77,28 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + projectName?.let { put("project_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index f9a83228..a3629afc 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -88,15 +88,16 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { queryParams.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { queryParams.put("max_xact_id", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + limit?.let { put("limit", it.toString()) } + maxRootSpanId?.let { put("max_root_span_id", it) } + maxXactId?.let { put("max_xact_id", it) } + version?.let { put("version", it) } + putAll(additionalQueryParams) + } + .build() fun getPathParam(index: Int): String { return when (index) { 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 4e16fae1..a1946a16 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 @@ -89,20 +89,43 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.projectScoreName?.let { queryParams.put("project_score_name", listOf(it.toString())) } - this.scoreType?.let { queryParams.put("score_type", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + projectId?.let { put("project_id", it) } + projectName?.let { put("project_name", it) } + projectScoreName?.let { put("project_score_name", it) } + scoreType?.accept( + object : ScoreType.Visitor { + override fun visitProject(project: ProjectScoreType) { + put("score_type", project.asString()) + } + + override fun visitProjectScoreTypes( + projectScoreTypes: List + ) { + put("score_type", projectScoreTypes.joinToString(",") { it.asString() }) + } + } + ) + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 8dd8c729..9bc9a039 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -85,19 +85,30 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.projectTagName?.let { queryParams.put("project_tag_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + projectId?.let { put("project_id", it) } + projectName?.let { put("project_name", it) } + projectTagName?.let { put("project_tag_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 01178d8c..d5c704fa 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -98,21 +98,32 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.projectId?.let { queryParams.put("project_id", listOf(it.toString())) } - this.projectName?.let { queryParams.put("project_name", listOf(it.toString())) } - this.promptName?.let { queryParams.put("prompt_name", listOf(it.toString())) } - this.slug?.let { queryParams.put("slug", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.version?.let { queryParams.put("version", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + projectId?.let { put("project_id", it) } + projectName?.let { put("project_name", it) } + promptName?.let { put("prompt_name", it) } + slug?.let { put("slug", it) } + startingAfter?.let { put("starting_after", it) } + version?.let { put("version", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index 0b4654b6..333d1d99 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -77,17 +77,28 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.roleName?.let { queryParams.put("role_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + roleName?.let { put("role_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt index bc8f76e3..fdfa8f86 100644 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/SpanIframeListParams.kt @@ -77,17 +77,28 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.spanIframeName?.let { queryParams.put("span_iframe_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + spanIframeName?.let { put("span_iframe_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) diff --git a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index de1003a9..55618ca7 100755 --- a/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-java-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -94,19 +94,60 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.email?.let { queryParams.put("email", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.familyName?.let { queryParams.put("family_name", listOf(it.toString())) } - this.givenName?.let { queryParams.put("given_name", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.orgName?.let { queryParams.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + email?.accept( + object : Email.Visitor { + override fun visitString(string: String) { + put("email", string) + } + + override fun visitStrings(strings: List) { + put("email", strings.joinToString(",")) + } + } + ) + endingBefore?.let { put("ending_before", it) } + familyName?.accept( + object : FamilyName.Visitor { + override fun visitString(string: String) { + put("family_name", string) + } + + override fun visitStrings(strings: List) { + put("family_name", strings.joinToString(",")) + } + } + ) + givenName?.accept( + object : GivenName.Visitor { + override fun visitString(string: String) { + put("given_name", string) + } + + override fun visitStrings(strings: List) { + put("given_name", strings.joinToString(",")) + } + } + ) + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + orgName?.let { put("org_name", it) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) 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 b72d35c8..ef2525d5 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 @@ -86,19 +86,30 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { queryParams.put("ending_before", listOf(it.toString())) } - this.ids?.let { queryParams.put("ids", listOf(it.toString())) } - this.limit?.let { queryParams.put("limit", listOf(it.toString())) } - this.startingAfter?.let { queryParams.put("starting_after", listOf(it.toString())) } - this.viewName?.let { queryParams.put("view_name", listOf(it.toString())) } - this.viewType?.let { queryParams.put("view_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("object_id", objectId) + put("object_type", objectType.asString()) + endingBefore?.let { put("ending_before", it) } + ids?.accept( + object : Ids.Visitor { + override fun visitString(string: String) { + put("ids", string) + } + + override fun visitStrings(strings: List) { + put("ids", strings.joinToString(",")) + } + } + ) + limit?.let { put("limit", it.toString()) } + startingAfter?.let { put("starting_after", it) } + viewName?.let { put("view_name", it) } + viewType?.let { put("view_type", it.asString()) } + putAll(additionalQueryParams) + } + .build() fun toBuilder() = Builder().from(this) 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 8ff82f27..0e6067a2 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 @@ -34,13 +34,14 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectId.let { queryParams.put("object_id", listOf(it.toString())) } - this.objectType.let { queryParams.put("object_type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("object_id", objectId) + put("object_type", objectType.asString()) + putAll(additionalQueryParams) + } + .build() fun getPathParam(index: Int): String { return when (index) { 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 3cfdbe75..e5288078 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 @@ -31,17 +31,20 @@ internal class AclListParamsTest { .limit(0L) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclObjectType.ORGANIZATION.toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("object_type", "organization") + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test @@ -51,9 +54,15 @@ internal class AclListParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclObjectType.ORGANIZATION) .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("object_type", "organization") + .build() + ) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt index 3e18fc34..20af378c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/AiSecretListParamsTest.kt @@ -33,27 +33,29 @@ internal class AiSecretListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ai_secret_name", "ai_secret_name") - expected.put( - "ai_secret_type", - AiSecretListParams.AiSecretType.ofString("string").toString(), - ) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - AiSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ai_secret_name", "ai_secret_name") + .put("ai_secret_type", "string") + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = AiSecretListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt index fc950cfe..e9582d7c 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt @@ -31,23 +31,28 @@ internal class ApiKeyListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("api_key_name", "api_key_name") - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("api_key_name", "api_key_name") + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = ApiKeyListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index 6e81ad31..1c31fd85 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -29,20 +29,28 @@ internal class DatasetFetchParamsTest { .maxXactId("max_xact_id") .version("version") .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("limit", "0") + .put("max_root_span_id", "max_root_span_id") + .put("max_xact_id", "max_xact_id") + .put("version", "version") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index 98586408..a6ffbbd4 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -35,25 +35,30 @@ internal class DatasetListParamsTest { .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("dataset_name", "dataset_name") - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("dataset_name", "dataset_name") + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_name", "project_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = DatasetListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index de4e5a5b..24bc6c0f 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -23,9 +23,11 @@ internal class DatasetSummarizeParamsTest { .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .summarizeData(true) .build() - val expected = QueryParams.builder() - expected.put("summarize_data", "true") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("summarize_data", "true").build()) } @Test @@ -34,8 +36,10 @@ internal class DatasetSummarizeParamsTest { DatasetSummarizeParams.builder() .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } @Test 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 e150aed4..4978303f 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 @@ -29,22 +29,27 @@ internal class EnvVarListParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(EnvVarObjectType.ORGANIZATION) .build() - val expected = QueryParams.builder() - expected.put("env_var_name", "env_var_name") - expected.put( - "ids", - EnvVarListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", EnvVarObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("env_var_name", "env_var_name") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("object_type", "organization") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = EnvVarListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index 6f3ff78f..a4d0d229 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -29,12 +29,18 @@ internal class ExperimentFetchParamsTest { .maxXactId("max_xact_id") .version("version") .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("limit", "0") + .put("max_root_span_id", "max_root_span_id") + .put("max_xact_id", "max_xact_id") + .put("version", "version") + .build() + ) } @Test @@ -43,8 +49,10 @@ internal class ExperimentFetchParamsTest { ExperimentFetchParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index f0da65fc..9c1814c3 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -35,25 +35,30 @@ internal class ExperimentListParamsTest { .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("experiment_name", "experiment_name") - expected.put( - "ids", - ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("experiment_name", "experiment_name") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_name", "project_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = ExperimentListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index 3a506159..3260545d 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -25,10 +25,16 @@ internal class ExperimentSummarizeParamsTest { .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .summarizeScores(true) .build() - val expected = QueryParams.builder() - expected.put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("summarize_scores", "true") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("comparison_experiment_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("summarize_scores", "true") + .build() + ) } @Test @@ -37,8 +43,10 @@ internal class ExperimentSummarizeParamsTest { ExperimentSummarizeParams.builder() .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } @Test diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 94f2cc3c..00e37ef9 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -39,27 +39,32 @@ internal class FunctionListParamsTest { .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .version("version") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("function_name", "function_name") - expected.put( - "ids", - FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("slug", "slug") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("function_name", "function_name") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_name", "project_name") + .put("slug", "slug") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("version", "version") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = FunctionListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index 152279d4..17892a31 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -31,23 +31,28 @@ internal class GroupListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("group_name", "group_name") - expected.put( - "ids", - GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("group_name", "group_name") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = GroupListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index fe4df3d0..32cdfdf6 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -29,22 +29,27 @@ internal class OrganizationListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = OrganizationListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 0e309b60..9f6452cd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -31,23 +31,28 @@ internal class ProjectListParamsTest { .projectName("project_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_name", "project_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("project_name", "project_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = ProjectListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index 61d382e2..2f305737 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -29,12 +29,18 @@ internal class ProjectLogFetchParamsTest { .maxXactId("max_xact_id") .version("version") .build() - val expected = QueryParams.builder() - expected.put("limit", "0") - expected.put("max_root_span_id", "max_root_span_id") - expected.put("max_xact_id", "max_xact_id") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("limit", "0") + .put("max_root_span_id", "max_root_span_id") + .put("max_xact_id", "max_xact_id") + .put("version", "version") + .build() + ) } @Test @@ -43,8 +49,10 @@ internal class ProjectLogFetchParamsTest { ProjectLogFetchParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } @Test 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 4f67003d..e1ff4653 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 @@ -37,30 +37,31 @@ internal class ProjectScoreListParamsTest { .scoreType(ProjectScoreType.SLIDER) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("project_score_name", "project_score_name") - expected.put( - "score_type", - ProjectScoreListParams.ScoreType.ofProject(ProjectScoreType.SLIDER.toString()) - .toString(), - ) - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_name", "project_name") + .put("project_score_name", "project_score_name") + .put("score_type", "slider") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = ProjectScoreListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index 1a227720..5b43e3ad 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -35,25 +35,30 @@ internal class ProjectTagListParamsTest { .projectTagName("project_tag_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("project_tag_name", "project_tag_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_name", "project_name") + .put("project_tag_name", "project_tag_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = ProjectTagListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index 66dd05b3..ef6a5e48 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -39,27 +39,32 @@ internal class PromptListParamsTest { .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .version("version") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("project_name", "project_name") - expected.put("prompt_name", "prompt_name") - expected.put("slug", "slug") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("version", "version") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_name", "project_name") + .put("prompt_name", "prompt_name") + .put("slug", "slug") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("version", "version") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = PromptListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 6908d93f..c023fec1 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -31,23 +31,28 @@ internal class RoleListParamsTest { .roleName("role_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("role_name", "role_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("role_name", "role_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = RoleListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt index da762a78..47aed4d6 100644 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/SpanIframeListParamsTest.kt @@ -31,23 +31,28 @@ internal class SpanIframeListParamsTest { .spanIframeName("span_iframe_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - SpanIframeListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("span_iframe_name", "span_iframe_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("span_iframe_name", "span_iframe_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = SpanIframeListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 6600197f..59ea68cd 100755 --- a/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-java-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -35,25 +35,30 @@ internal class UserListParamsTest { .orgName("org_name") .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val expected = QueryParams.builder() - expected.put("email", UserListParams.Email.ofString("string").toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("family_name", UserListParams.FamilyName.ofString("string").toString()) - expected.put("given_name", UserListParams.GivenName.ofString("string").toString()) - expected.put( - "ids", - UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("org_name", "org_name") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("email", "string") + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("family_name", "string") + .put("given_name", "string") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("org_name", "org_name") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) } @Test fun queryParamsWithoutOptionalFields() { val params = UserListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } 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 96d39d8a..05c283a8 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 @@ -35,19 +35,22 @@ internal class ViewListParamsTest { .viewName("view_name") .viewType(ViewType.PROJECTS) .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclObjectType.ORGANIZATION.toString()) - expected.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put( - "ids", - ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString(), - ) - expected.put("limit", "0") - expected.put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("view_name", "view_name") - expected.put("view_type", ViewType.PROJECTS.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("object_type", "organization") + .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("ids", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("limit", "0") + .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("view_name", "view_name") + .put("view_type", "projects") + .build() + ) } @Test @@ -57,9 +60,15 @@ internal class ViewListParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclObjectType.ORGANIZATION) .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("object_type", "organization") + .build() + ) } } 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 17c8a2dd..d73a583b 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 @@ -25,10 +25,16 @@ internal class ViewRetrieveParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclObjectType.ORGANIZATION) .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("object_type", "organization") + .build() + ) } @Test @@ -39,10 +45,16 @@ internal class ViewRetrieveParamsTest { .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .objectType(AclObjectType.ORGANIZATION) .build() - val expected = QueryParams.builder() - expected.put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - expected.put("object_type", AclObjectType.ORGANIZATION.toString()) - assertThat(params._queryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("object_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("object_type", "organization") + .build() + ) } @Test 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 8e65f276..74787883 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 @@ -15,7 +15,6 @@ import com.braintrustdata.api.models.FunctionUpdateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptOptions import kotlin.jvm.optionals.getOrNull -import kotlin.test.assertNotNull import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -368,8 +367,7 @@ internal class FunctionServiceAsyncTest { val response = responseFuture.get() val unwrappedResponse = response.getOrNull() - assertNotNull(unwrappedResponse) - unwrappedResponse.validate() + unwrappedResponse?.validate() } @Test 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 1398db02..5666dd34 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 @@ -15,7 +15,6 @@ import com.braintrustdata.api.models.FunctionUpdateParams import com.braintrustdata.api.models.PromptData import com.braintrustdata.api.models.PromptOptions import kotlin.jvm.optionals.getOrNull -import kotlin.test.assertNotNull import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -362,8 +361,7 @@ internal class FunctionServiceTest { ) val unwrappedResponse = response.getOrNull() - assertNotNull(unwrappedResponse) - unwrappedResponse.validate() + unwrappedResponse?.validate() } @Test From 7eb96b280e5cf748294c3545b33df5f269df3396 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Mar 2025 00:24:54 +0000 Subject: [PATCH 87/87] release: 0.8.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 123 ++++++++++++++++++++++++++++++++++ README.md | 8 +-- build.gradle.kts | 2 +- 4 files changed, 129 insertions(+), 6 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1b77f506..6538ca91 100755 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.7.0" + ".": "0.8.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bd0c5a5d..5898a8aa 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,128 @@ # Changelog +## 0.8.0 (2025-03-18) + +Full Changelog: [v0.7.0...v0.8.0](https://github.com/braintrustdata/braintrust-java/compare/v0.7.0...v0.8.0) + +### ⚠ BREAKING CHANGES + +* **client:** refactor multipart formdata impl ([#132](https://github.com/braintrustdata/braintrust-java/issues/132)) + +### Features + +* **api:** api update ([#64](https://github.com/braintrustdata/braintrust-java/issues/64)) ([f1d956d](https://github.com/braintrustdata/braintrust-java/commit/f1d956dec36db180eba1333303361fe577229fbd)) +* **api:** api update ([#66](https://github.com/braintrustdata/braintrust-java/issues/66)) ([02b0490](https://github.com/braintrustdata/braintrust-java/commit/02b0490c081fc51c4c11b12cf8592dc513ac7a1f)) +* **api:** api update ([#67](https://github.com/braintrustdata/braintrust-java/issues/67)) ([2ca59f7](https://github.com/braintrustdata/braintrust-java/commit/2ca59f78f8e775f10b4c09e040e7f55ec27612b1)) +* **api:** api update ([#68](https://github.com/braintrustdata/braintrust-java/issues/68)) ([288a26d](https://github.com/braintrustdata/braintrust-java/commit/288a26dc55ba27313879a00ace18304408adefe9)) +* **api:** manual updates ([#100](https://github.com/braintrustdata/braintrust-java/issues/100)) ([8aea924](https://github.com/braintrustdata/braintrust-java/commit/8aea924ce9c2992c1f620f63c077de8e508852f6)) +* **api:** manual updates ([#107](https://github.com/braintrustdata/braintrust-java/issues/107)) ([893c7c9](https://github.com/braintrustdata/braintrust-java/commit/893c7c9d9397aa0b5abd0b13f8d3d889aa2c6636)) +* **api:** manual updates ([#148](https://github.com/braintrustdata/braintrust-java/issues/148)) ([03f4bce](https://github.com/braintrustdata/braintrust-java/commit/03f4bce0a262fd275057a74fc5cc6736e9df6a70)) +* **api:** manual updates ([#149](https://github.com/braintrustdata/braintrust-java/issues/149)) ([98e4bf7](https://github.com/braintrustdata/braintrust-java/commit/98e4bf7ddd7fd4709b2c4bc12d6f208316f98ac0)) +* **api:** manual updates ([#150](https://github.com/braintrustdata/braintrust-java/issues/150)) ([be6e2a6](https://github.com/braintrustdata/braintrust-java/commit/be6e2a679a76caf1e7ef03422ef91087a2c75981)) +* **api:** manual updates ([#151](https://github.com/braintrustdata/braintrust-java/issues/151)) ([be0354d](https://github.com/braintrustdata/braintrust-java/commit/be0354dbb77893f24083ea294531d8f7a1e00309)) +* **api:** manual updates ([#91](https://github.com/braintrustdata/braintrust-java/issues/91)) ([5e9b07e](https://github.com/braintrustdata/braintrust-java/commit/5e9b07e8f84aff42457a97000302fa2e890282b2)) +* **api:** manual updates ([#93](https://github.com/braintrustdata/braintrust-java/issues/93)) ([3c635ad](https://github.com/braintrustdata/braintrust-java/commit/3c635adb8c1d2e6e26f20e764ac5b9de50b4f2db)) +* **api:** manual updates ([#95](https://github.com/braintrustdata/braintrust-java/issues/95)) ([0e97915](https://github.com/braintrustdata/braintrust-java/commit/0e97915cf7aaa7f1610d56b7c281c28b84ead0ac)) +* **api:** manual updates ([#96](https://github.com/braintrustdata/braintrust-java/issues/96)) ([711a5bc](https://github.com/braintrustdata/braintrust-java/commit/711a5bcf08739214cb62ef99a8de9e267c7afb34)) +* **api:** manual updates ([#97](https://github.com/braintrustdata/braintrust-java/issues/97)) ([f229777](https://github.com/braintrustdata/braintrust-java/commit/f229777ec23714e3e3adfdb6678cffccb13a89f9)) +* **api:** manual updates ([#98](https://github.com/braintrustdata/braintrust-java/issues/98)) ([d27a782](https://github.com/braintrustdata/braintrust-java/commit/d27a7828e50e8e0c91c6b9a527796d0352a8a554)) +* **api:** manual updates ([#99](https://github.com/braintrustdata/braintrust-java/issues/99)) ([eb3e689](https://github.com/braintrustdata/braintrust-java/commit/eb3e6891d822772b04258b63d3ecb1db96537186)) +* **client:** accept `InputStream` and `Path` for file params ([#136](https://github.com/braintrustdata/braintrust-java/issues/136)) ([92073d0](https://github.com/braintrustdata/braintrust-java/commit/92073d0365dcb479ba2565a41305f56f882fecb3)) +* **client:** add logging when debug env is set ([#106](https://github.com/braintrustdata/braintrust-java/issues/106)) ([0bad87e](https://github.com/braintrustdata/braintrust-java/commit/0bad87e1644242cfdbe21d92bf19d138536900f0)) +* **client:** allow configuring timeouts granularly ([#130](https://github.com/braintrustdata/braintrust-java/issues/130)) ([606ebb7](https://github.com/braintrustdata/braintrust-java/commit/606ebb74dcc339190eeefe2b072f273783445edc)) +* **client:** detect binary incompatible jackson versions ([#137](https://github.com/braintrustdata/braintrust-java/issues/137)) ([de216b5](https://github.com/braintrustdata/braintrust-java/commit/de216b560305cb737647cbc34e7775d84ee0e11e)) +* **client:** get rid of annoying checked exceptions ([#118](https://github.com/braintrustdata/braintrust-java/issues/118)) ([0aabe74](https://github.com/braintrustdata/braintrust-java/commit/0aabe74100f814d12b472e5f4d8344b851804d0a)) +* **client:** support `JsonField#asX()` for known values ([#114](https://github.com/braintrustdata/braintrust-java/issues/114)) ([550e1a8](https://github.com/braintrustdata/braintrust-java/commit/550e1a8e92513d874055b527c8b20188078fe312)) +* **client:** support raw response access ([#131](https://github.com/braintrustdata/braintrust-java/issues/131)) ([cc8b5a5](https://github.com/braintrustdata/braintrust-java/commit/cc8b5a5d66ca1a077e58cbf145e468effbfba2c3)) +* **client:** update enum `asX` methods ([#113](https://github.com/braintrustdata/braintrust-java/issues/113)) ([ed83ac5](https://github.com/braintrustdata/braintrust-java/commit/ed83ac52612873519062919eae567a1e82b3b221)) +* generate and publish docs ([#138](https://github.com/braintrustdata/braintrust-java/issues/138)) ([d951553](https://github.com/braintrustdata/braintrust-java/commit/d9515531787d8f63c33c977118ea6c58378ee7f9)) + + +### Bug Fixes + +* **client:** add missing `@JvmStatic` ([#124](https://github.com/braintrustdata/braintrust-java/issues/124)) ([c4e0b8a](https://github.com/braintrustdata/braintrust-java/commit/c4e0b8ad6755613242bcc135c36dd7538adb8c99)) +* **client:** mark some request bodies as optional ([#120](https://github.com/braintrustdata/braintrust-java/issues/120)) ([274c95c](https://github.com/braintrustdata/braintrust-java/commit/274c95c6df23554f747392fb51a50f3a327125af)) + + +### Chores + +* **api:** manual updates ([#72](https://github.com/braintrustdata/braintrust-java/issues/72)) ([b6c9f43](https://github.com/braintrustdata/braintrust-java/commit/b6c9f43a2a14533b88d39666809b5ee7ce670504)) +* **client:** expose `Optional`, not nullable, from `ClientOptions` ([#135](https://github.com/braintrustdata/braintrust-java/issues/135)) ([bd8a24d](https://github.com/braintrustdata/braintrust-java/commit/bd8a24d41ddc414c3797a303c2b48ecd643d772b)) +* **client:** refactor multipart formdata impl ([#132](https://github.com/braintrustdata/braintrust-java/issues/132)) ([a32b711](https://github.com/braintrustdata/braintrust-java/commit/a32b7113952189d2624dcbb534a6da5dc36a3224)) +* **client:** use deep identity methods for primitive array types ([#126](https://github.com/braintrustdata/braintrust-java/issues/126)) ([effc197](https://github.com/braintrustdata/braintrust-java/commit/effc19754eb651f3531959839e9a803d4b056587)) +* **deps:** bump jackson to 2.18.1 ([#101](https://github.com/braintrustdata/braintrust-java/issues/101)) ([1d5c887](https://github.com/braintrustdata/braintrust-java/commit/1d5c887b11473e110a197d004a278f9abf8ed4c4)) +* **docs:** add faq to readme ([#119](https://github.com/braintrustdata/braintrust-java/issues/119)) ([5b4d07f](https://github.com/braintrustdata/braintrust-java/commit/5b4d07fc3da4e77c62bdffddd4f6e215401755b2)) +* **docs:** reorganize readme ([#115](https://github.com/braintrustdata/braintrust-java/issues/115)) ([b65c599](https://github.com/braintrustdata/braintrust-java/commit/b65c5991e1451302fd20fb345d82c89fbd47bc80)) +* **internal:** add `.kotlin` to `.gitignore` ([#139](https://github.com/braintrustdata/braintrust-java/issues/139)) ([1e4c3e5](https://github.com/braintrustdata/braintrust-java/commit/1e4c3e584f71562c26dde78c3366c75e1e5dd8bb)) +* **internal:** add async service tests ([#125](https://github.com/braintrustdata/braintrust-java/issues/125)) ([5dc06c8](https://github.com/braintrustdata/braintrust-java/commit/5dc06c8acd281951e841146b1b16803f017c9948)) +* **internal:** add generated comment ([#154](https://github.com/braintrustdata/braintrust-java/issues/154)) ([28a3568](https://github.com/braintrustdata/braintrust-java/commit/28a35683de525b8de0ca345bb246ed537104788d)) +* **internal:** codegen related update ([#105](https://github.com/braintrustdata/braintrust-java/issues/105)) ([ad0fed3](https://github.com/braintrustdata/braintrust-java/commit/ad0fed3824772a29ce635f672c2feb6f7c2beb17)) +* **internal:** codegen related update ([#109](https://github.com/braintrustdata/braintrust-java/issues/109)) ([a8b7cd7](https://github.com/braintrustdata/braintrust-java/commit/a8b7cd7d1e5346b702483b336f9a1d9f71f38c11)) +* **internal:** codegen related update ([#111](https://github.com/braintrustdata/braintrust-java/issues/111)) ([029cbc7](https://github.com/braintrustdata/braintrust-java/commit/029cbc78bf94c707da26f3550db354480909bd78)) +* **internal:** codegen related update ([#117](https://github.com/braintrustdata/braintrust-java/issues/117)) ([aaaef18](https://github.com/braintrustdata/braintrust-java/commit/aaaef188d4fbe8ba97fcc55fe1dac15d527cf1ec)) +* **internal:** codegen related update ([#122](https://github.com/braintrustdata/braintrust-java/issues/122)) ([c9d3840](https://github.com/braintrustdata/braintrust-java/commit/c9d3840c4fded6c0ece296ceb60a5526c3d81c75)) +* **internal:** codegen related update ([#123](https://github.com/braintrustdata/braintrust-java/issues/123)) ([9dbc537](https://github.com/braintrustdata/braintrust-java/commit/9dbc537a6271bc2bbd2839515f77eeb58951e4ab)) +* **internal:** codegen related update ([#145](https://github.com/braintrustdata/braintrust-java/issues/145)) ([23f0da4](https://github.com/braintrustdata/braintrust-java/commit/23f0da4fecedf41ae2a2f573ed0f8e25938057cf)) +* **internal:** codegen related update ([#146](https://github.com/braintrustdata/braintrust-java/issues/146)) ([4a82e6f](https://github.com/braintrustdata/braintrust-java/commit/4a82e6f3159a2b6697f8dbe23304a693e0448ebb)) +* **internal:** don't use `JvmOverloads` in interfaces ([84daad7](https://github.com/braintrustdata/braintrust-java/commit/84daad738819f265ff28ab6c351008a7018e0340)) +* **internal:** get rid of configuration cache ([#116](https://github.com/braintrustdata/braintrust-java/issues/116)) ([1a69b73](https://github.com/braintrustdata/braintrust-java/commit/1a69b73fdc5eb657e72fd3b3d8d3c4f34378cbc3)) +* **internal:** improve sync service tests ([5dc06c8](https://github.com/braintrustdata/braintrust-java/commit/5dc06c8acd281951e841146b1b16803f017c9948)) +* **internal:** make body class constructors private ([b417ac7](https://github.com/braintrustdata/braintrust-java/commit/b417ac7d07cc916a3928a17a57406b08ed014fa0)) +* **internal:** make body classes for multipart requests ([b417ac7](https://github.com/braintrustdata/braintrust-java/commit/b417ac7d07cc916a3928a17a57406b08ed014fa0)) +* **internal:** make test classes internal ([#153](https://github.com/braintrustdata/braintrust-java/issues/153)) ([f4d9990](https://github.com/braintrustdata/braintrust-java/commit/f4d99903225690cfb6fad53ac26fee5c3615977f)) +* **internal:** misc formatting changes ([b417ac7](https://github.com/braintrustdata/braintrust-java/commit/b417ac7d07cc916a3928a17a57406b08ed014fa0)) +* **internal:** reenable warnings as errors ([#141](https://github.com/braintrustdata/braintrust-java/issues/141)) ([84daad7](https://github.com/braintrustdata/braintrust-java/commit/84daad738819f265ff28ab6c351008a7018e0340)) +* **internal:** refactor `ErrorHandlingTest` ([#129](https://github.com/braintrustdata/braintrust-java/issues/129)) ([f61300b](https://github.com/braintrustdata/braintrust-java/commit/f61300b640f71f7d5ce0dee685b0d0524da59d08)) +* **internal:** refactor `PhantomReachableClosingAsyncStreamResponse` impl ([#110](https://github.com/braintrustdata/braintrust-java/issues/110)) ([d1647df](https://github.com/braintrustdata/braintrust-java/commit/d1647dff5977260e2346ad1eeaa5105cc82f8463)) +* **internal:** refactor `ServiceParamsTest` ([#127](https://github.com/braintrustdata/braintrust-java/issues/127)) ([4104744](https://github.com/braintrustdata/braintrust-java/commit/410474405bf5b56695aea53e7d560d7cc48bc144)) +* **internal:** refactor query param serialization impl and tests ([#156](https://github.com/braintrustdata/braintrust-java/issues/156)) ([f141195](https://github.com/braintrustdata/braintrust-java/commit/f1411950e6f4807ac2ec5f34ed12ecbc70b51fad)) +* **internal:** remove unnecessary non-null asserts in tests ([274c95c](https://github.com/braintrustdata/braintrust-java/commit/274c95c6df23554f747392fb51a50f3a327125af)) +* **internal:** remove unused script ([#147](https://github.com/braintrustdata/braintrust-java/issues/147)) ([6eee272](https://github.com/braintrustdata/braintrust-java/commit/6eee2722878aa0bfd85f8f11b6a99fb5aa2b4036)) +* **internal:** rename internal body classes ([b417ac7](https://github.com/braintrustdata/braintrust-java/commit/b417ac7d07cc916a3928a17a57406b08ed014fa0)) +* **internal:** update some formatting in `Values.kt` ([550e1a8](https://github.com/braintrustdata/braintrust-java/commit/550e1a8e92513d874055b527c8b20188078fe312)) +* **internal:** update variable names in tests ([#142](https://github.com/braintrustdata/braintrust-java/issues/142)) ([e8882a7](https://github.com/braintrustdata/braintrust-java/commit/e8882a710bff95c91accdcd7bd293f24a724fb7f)) +* **internal:** use `assertNotNull` in tests for type narrowing ([274c95c](https://github.com/braintrustdata/braintrust-java/commit/274c95c6df23554f747392fb51a50f3a327125af)) +* **internal:** use `getOrNull` instead of `orElse(null)` ([#140](https://github.com/braintrustdata/braintrust-java/issues/140)) ([1db71f8](https://github.com/braintrustdata/braintrust-java/commit/1db71f8bc37728717ecbfcffb31f6b3afbe4380a)) +* **internal:** use better test example values ([#112](https://github.com/braintrustdata/braintrust-java/issues/112)) ([b417ac7](https://github.com/braintrustdata/braintrust-java/commit/b417ac7d07cc916a3928a17a57406b08ed014fa0)) +* rebuild project due to codegen change ([#69](https://github.com/braintrustdata/braintrust-java/issues/69)) ([a7c0606](https://github.com/braintrustdata/braintrust-java/commit/a7c0606dca2139ba230c5d4813dcf76f1ec59d08)) +* rebuild project due to codegen change ([#70](https://github.com/braintrustdata/braintrust-java/issues/70)) ([ccb8dd5](https://github.com/braintrustdata/braintrust-java/commit/ccb8dd583d9783e0466503fa848a1ef5fd577e20)) +* rebuild project due to codegen change ([#71](https://github.com/braintrustdata/braintrust-java/issues/71)) ([0c35214](https://github.com/braintrustdata/braintrust-java/commit/0c35214c2e1b903f741cf39c6a4d7289b13b6271)) +* rebuild project due to codegen change ([#73](https://github.com/braintrustdata/braintrust-java/issues/73)) ([a7a6379](https://github.com/braintrustdata/braintrust-java/commit/a7a6379e2b4e7a8944aa89df8de05ca116db8af8)) +* rebuild project due to codegen change ([#74](https://github.com/braintrustdata/braintrust-java/issues/74)) ([d665d0f](https://github.com/braintrustdata/braintrust-java/commit/d665d0f6cfd44d1bee4ea5dd02d00c0a63203b0c)) +* rebuild project due to codegen change ([#75](https://github.com/braintrustdata/braintrust-java/issues/75)) ([9ac5669](https://github.com/braintrustdata/braintrust-java/commit/9ac566913ab54368b5e1eb10c5e6c20fc86ff75a)) +* rebuild project due to codegen change ([#76](https://github.com/braintrustdata/braintrust-java/issues/76)) ([6498c99](https://github.com/braintrustdata/braintrust-java/commit/6498c997bc0fb2ae68e842ab6b69110115fa458b)) +* rebuild project due to codegen change ([#77](https://github.com/braintrustdata/braintrust-java/issues/77)) ([7c9b2ad](https://github.com/braintrustdata/braintrust-java/commit/7c9b2adb46f8e24d9a3c908400596d96795b8ede)) +* rebuild project due to codegen change ([#78](https://github.com/braintrustdata/braintrust-java/issues/78)) ([fa5ee1f](https://github.com/braintrustdata/braintrust-java/commit/fa5ee1f34562b8ac88122f183ee307aec99ff496)) +* rebuild project due to codegen change ([#79](https://github.com/braintrustdata/braintrust-java/issues/79)) ([9e17de0](https://github.com/braintrustdata/braintrust-java/commit/9e17de04225a4a334fe068f5cbd7e3116c765782)) +* rebuild project due to codegen change ([#80](https://github.com/braintrustdata/braintrust-java/issues/80)) ([223ed2e](https://github.com/braintrustdata/braintrust-java/commit/223ed2e21d18538cff3875f3697b2c0ded1b4ad3)) +* rebuild project due to codegen change ([#81](https://github.com/braintrustdata/braintrust-java/issues/81)) ([44f5fbe](https://github.com/braintrustdata/braintrust-java/commit/44f5fbe68fcb12f0d08a091c88c39bf87f8855af)) +* rebuild project due to codegen change ([#83](https://github.com/braintrustdata/braintrust-java/issues/83)) ([c9d6eae](https://github.com/braintrustdata/braintrust-java/commit/c9d6eae2658ce543a3ccba996373b923e4371cd7)) +* rebuild project due to codegen change ([#84](https://github.com/braintrustdata/braintrust-java/issues/84)) ([8f2a24b](https://github.com/braintrustdata/braintrust-java/commit/8f2a24b0683f51df845f3a433d66994288149e6a)) +* rebuild project due to codegen change ([#86](https://github.com/braintrustdata/braintrust-java/issues/86)) ([d83611f](https://github.com/braintrustdata/braintrust-java/commit/d83611fa8e3155f295f276573235d1bfd6f68371)) +* rebuild project due to codegen change ([#88](https://github.com/braintrustdata/braintrust-java/issues/88)) ([2e62835](https://github.com/braintrustdata/braintrust-java/commit/2e62835d07807e4e1aa018180fac6ca3de574e8e)) +* rebuild project due to codegen change ([#90](https://github.com/braintrustdata/braintrust-java/issues/90)) ([e353324](https://github.com/braintrustdata/braintrust-java/commit/e35332464b9e4a83bef95f90866c0de79bc8c0ff)) +* rebuild project due to codegen change ([#94](https://github.com/braintrustdata/braintrust-java/issues/94)) ([1cd427d](https://github.com/braintrustdata/braintrust-java/commit/1cd427d2b43bbfb35c1ef70ae0e20ff7c66bb876)) + + +### Documentation + +* add `build` method comments ([#155](https://github.com/braintrustdata/braintrust-java/issues/155)) ([6b504cb](https://github.com/braintrustdata/braintrust-java/commit/6b504cbb091ddbfff7b2487dd143cab9e3d4da01)) +* add immutability explanation to readme ([#121](https://github.com/braintrustdata/braintrust-java/issues/121)) ([6a15c6f](https://github.com/braintrustdata/braintrust-java/commit/6a15c6f103419b9ebd420a5a40de9b675c5302f0)) +* add more phantom reachability docs ([d1647df](https://github.com/braintrustdata/braintrust-java/commit/d1647dff5977260e2346ad1eeaa5105cc82f8463)) +* add raw response readme documentation ([#133](https://github.com/braintrustdata/braintrust-java/issues/133)) ([711d655](https://github.com/braintrustdata/braintrust-java/commit/711d6554708df00be676d724775d090a8f1f5723)) +* deduplicate and refine comments ([#152](https://github.com/braintrustdata/braintrust-java/issues/152)) ([73fb462](https://github.com/braintrustdata/braintrust-java/commit/73fb462b4574596a30820dbab116ba57fab47460)) +* document `JsonValue` construction in readme ([#144](https://github.com/braintrustdata/braintrust-java/issues/144)) ([33fa7ab](https://github.com/braintrustdata/braintrust-java/commit/33fa7ab33b83c408b14fc770b451ac9bb10bd1ca)) +* note required fields in `builder` javadoc ([#134](https://github.com/braintrustdata/braintrust-java/issues/134)) ([c0d11e5](https://github.com/braintrustdata/braintrust-java/commit/c0d11e5cd44c38cb272cab21f18432e25dc204a0)) +* readme parameter tweaks ([5dc06c8](https://github.com/braintrustdata/braintrust-java/commit/5dc06c8acd281951e841146b1b16803f017c9948)) +* revise readme docs about nested params ([#143](https://github.com/braintrustdata/braintrust-java/issues/143)) ([0a06490](https://github.com/braintrustdata/braintrust-java/commit/0a06490b643d90b0666d2f3505dd20e8d519251c)) +* update URLs from stainlessapi.com to stainless.com ([#128](https://github.com/braintrustdata/braintrust-java/issues/128)) ([57e17de](https://github.com/braintrustdata/braintrust-java/commit/57e17de51ce9372dee4dab1f3ad67a040d7900bb)) + + +### Styles + +* **internal:** move identity methods to bottom of error class ([#104](https://github.com/braintrustdata/braintrust-java/issues/104)) ([fd04071](https://github.com/braintrustdata/braintrust-java/commit/fd04071cbeb2abb04310bd4389279dbaadb9a302)) +* **internal:** reduce verbosity of identity methods ([#103](https://github.com/braintrustdata/braintrust-java/issues/103)) ([f09c5a0](https://github.com/braintrustdata/braintrust-java/commit/f09c5a01a41e464796e781e9923a96f501786242)) + ## 0.7.0 (2024-10-01) Full Changelog: [v0.6.0...v0.7.0](https://github.com/braintrustdata/braintrust-java/compare/v0.6.0...v0.7.0) diff --git a/README.md b/README.md index 2212fe0a..99c7eb77 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.braintrustdata.api/braintrust-java)](https://central.sonatype.com/artifact/com.braintrustdata.api/braintrust-java/0.7.0) -[![javadoc](https://javadoc.io/badge2/com.braintrustdata.api/braintrust-java/0.7.0/javadoc.svg)](https://javadoc.io/doc/com.braintrustdata.api/braintrust-java/0.7.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.braintrustdata.api/braintrust-java)](https://central.sonatype.com/artifact/com.braintrustdata.api/braintrust-java/0.8.0) +[![javadoc](https://javadoc.io/badge2/com.braintrustdata.api/braintrust-java/0.8.0/javadoc.svg)](https://javadoc.io/doc/com.braintrustdata.api/braintrust-java/0.8.0) @@ -22,7 +22,7 @@ The REST API documentation can be found on [www.braintrustdata.com](https://www. ### Gradle ```kotlin -implementation("com.braintrustdata.api:braintrust-java:0.7.0") +implementation("com.braintrustdata.api:braintrust-java:0.8.0") ``` ### Maven @@ -31,7 +31,7 @@ implementation("com.braintrustdata.api:braintrust-java:0.7.0") com.braintrustdata.api braintrust-java - 0.7.0 + 0.8.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 8954c1c2..3a613beb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.braintrustdata.api" - version = "0.7.0" // x-release-please-version + version = "0.8.0" // x-release-please-version } subprojects {